Documentation
¶
Overview ¶
Package tripops is the shared itinerary agent surface used by HTTP/MCP and in-viewer chat. Business logic lives here; transports only bind auth and I/O.
Index ¶
- Constants
- func HTTPStatus(err error) int
- func PrepareYAML(b []byte) (itinerary.Trip, error)
- func SchemaJSON(context.Context) (json.RawMessage, error)
- type Config
- type DayDriveStats
- type DriveEstimate
- type DriveLeg
- type DriveWaypoint
- type MutateResult
- type Ops
- type Service
- func (s *Service) ApplyPatch(ctx context.Context, tripID string, p itinerary.Patch) (MutateResult, error)
- func (s *Service) ApplyPatchJSON(ctx context.Context, tripID string, patchJSON []byte) (MutateResult, error)
- func (s *Service) ApplyReplaceDayRoutesJSON(ctx context.Context, tripID string, bodyJSON []byte) (MutateResult, error)
- func (s *Service) Commit(ctx context.Context, id string, yamlBytes []byte, meta *store.Meta) (MutateResult, error)
- func (s *Service) EstimateDrive(ctx context.Context, tripID string, points []DriveWaypoint) (DriveEstimate, error)
- func (s *Service) GetYAML(ctx context.Context, tripID, scope string, day int) (YAMLResult, error)
- func (s *Service) GetYAMLVersion(ctx context.Context, tripID, versionID string) (YAMLResult, error)
- func (s *Service) ListVersions(ctx context.Context, tripID string, limit int) ([]VersionEntry, error)
- func (s *Service) Patch(ctx context.Context, tripID string, patchJSON []byte) (MutateResult, error)
- func (s *Service) ReplaceDayRoutes(ctx context.Context, tripID string, bodyJSON []byte) (MutateResult, error)
- func (s *Service) RestoreVersion(ctx context.Context, tripID, versionID string) (MutateResult, error)
- func (s *Service) SchemaJSON(ctx context.Context) (json.RawMessage, error)
- func (s *Service) Summary(ctx context.Context, tripID string) (TripSummary, error)
- type TripSummary
- type VersionEntry
- type YAMLResult
Constants ¶
const ( SummaryGetSchema = "Itinerary schema and version" SummaryGetTrip = "Compact trip card with day titles and per-day drive_dist/drive_min from bundle (use for drive-time questions; no YAML needed)" SummaryGetTripYAML = "Get itinerary YAML" SummaryPatchTrip = "Patch places info, day narrative, or structure" SummaryReplaceDayRoutes = "" /* 154-byte string literal not displayed */ SummaryListVersions = "List YAML versions" SummaryGetVersion = "Get YAML for a prior version" SummaryRestoreVersion = "Restore a prior YAML version" )
OpenAPI operation summaries — single source for chat tool one-liners.
const SummaryEstimateDrive = "OSRM road distance/time between waypoints (use instead of web search for drive estimates)"
Variables ¶
This section is empty.
Functions ¶
func HTTPStatus ¶
HTTPStatus maps tripops errors to HTTP codes for agent handlers.
func PrepareYAML ¶
PrepareYAML parses and validates itinerary YAML for create/put/restore.
func SchemaJSON ¶
func SchemaJSON(context.Context) (json.RawMessage, error)
SchemaJSON returns the agent schema document.
Types ¶
type Config ¶
type Config struct {
Store store.Store
PublicBaseURL string
RouteMode string // straight | osrm
OSRMBaseURL string // optional; empty uses the public OSRM demo server
}
Config wires store-backed trip ops.
type DayDriveStats ¶
type DayDriveStats struct {
Day int `json:"day"`
DriveDist float64 `json:"drive_dist,omitempty"`
DriveMin int `json:"drive_min,omitempty"`
}
DayDriveStats is precomputed OSRM drive totals for one day (from bundle trip.json).
type DriveEstimate ¶
type DriveEstimate struct {
Legs []DriveLeg `json:"legs"`
DistanceKm float64 `json:"distance_km"`
DurationMinutes float64 `json:"duration_minutes"`
Provider string `json:"provider"` // osrm | mixed | straight
}
DriveEstimate is the OSRM (or straight-line fallback) summary.
type DriveLeg ¶
type DriveLeg struct {
From string `json:"from"`
To string `json:"to"`
DistanceKm float64 `json:"distance_km"`
DurationMinutes float64 `json:"duration_minutes"`
DistanceMeters float64 `json:"distance_meters"`
DurationSeconds float64 `json:"duration_seconds"`
FallbackStraight bool `json:"fallback_straight,omitempty"`
}
DriveLeg is one OSRM leg between consecutive waypoints.
type DriveWaypoint ¶
type DriveWaypoint struct {
Place string `json:"place,omitempty"` // place id from the trip catalog
Lat float64 `json:"lat,omitempty"`
Lon float64 `json:"lon,omitempty"`
Title string `json:"title,omitempty"` // optional label for the response
}
DriveWaypoint is one point on an estimateDrive request.
type MutateResult ¶
type MutateResult struct {
ID string `json:"id"`
VersionID string `json:"version_id,omitempty"`
SchemaVersion int `json:"schema_version"`
ViewerURL string `json:"viewer_url,omitempty"`
BundleOK bool `json:"bundle_ok"`
BundleError string `json:"bundle_error,omitempty"`
}
MutateResult matches OpenAPI MutateResult.
type Ops ¶
type Ops interface {
SchemaJSON(ctx context.Context) (json.RawMessage, error)
Summary(ctx context.Context, tripID string) (TripSummary, error)
GetYAML(ctx context.Context, tripID, scope string, day int) (YAMLResult, error)
GetYAMLVersion(ctx context.Context, tripID, versionID string) (YAMLResult, error)
Patch(ctx context.Context, tripID string, patchJSON []byte) (MutateResult, error)
ReplaceDayRoutes(ctx context.Context, tripID string, bodyJSON []byte) (MutateResult, error)
ListVersions(ctx context.Context, tripID string, limit int) ([]VersionEntry, error)
RestoreVersion(ctx context.Context, tripID, versionID string) (MutateResult, error)
EstimateDrive(ctx context.Context, tripID string, points []DriveWaypoint) (DriveEstimate, error)
}
Ops is the trip-scoped agent surface (no listTrips / createTrip).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements Ops against a Store.
func (*Service) ApplyPatch ¶
func (s *Service) ApplyPatch(ctx context.Context, tripID string, p itinerary.Patch) (MutateResult, error)
ApplyPatch loads, patches, validates, and commits an itinerary.
func (*Service) ApplyPatchJSON ¶
func (s *Service) ApplyPatchJSON(ctx context.Context, tripID string, patchJSON []byte) (MutateResult, error)
ApplyPatchJSON unmarshals a TripPatch and applies it.
func (*Service) ApplyReplaceDayRoutesJSON ¶
func (s *Service) ApplyReplaceDayRoutesJSON(ctx context.Context, tripID string, bodyJSON []byte) (MutateResult, error)
ApplyReplaceDayRoutesJSON parses replaceDayRoutes body and applies it.
func (*Service) Commit ¶
func (s *Service) Commit(ctx context.Context, id string, yamlBytes []byte, meta *store.Meta) (MutateResult, error)
Commit writes YAML + meta and regenerates the viewer bundle.
func (*Service) EstimateDrive ¶
func (s *Service) EstimateDrive(ctx context.Context, tripID string, points []DriveWaypoint) (DriveEstimate, error)
EstimateDrive routes consecutive waypoints with OSRM (overview=false). Prefer place ids from getTripYAML; lat/lon may be used for candidates not yet in the trip.
func (*Service) GetYAMLVersion ¶
func (*Service) ListVersions ¶
func (*Service) ReplaceDayRoutes ¶
func (*Service) RestoreVersion ¶
func (s *Service) RestoreVersion(ctx context.Context, tripID, versionID string) (MutateResult, error)
RestoreVersion makes versionID the current YAML (Ops method).
func (*Service) SchemaJSON ¶
type TripSummary ¶
type TripSummary struct {
ID string `json:"id"`
VersionID string `json:"version_id,omitempty"`
SchemaVersion int `json:"schema_version"`
Trip string `json:"trip"`
Description string `json:"description,omitempty"`
Start string `json:"start,omitempty"`
Days int `json:"days"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
DayTitles []string `json:"day_titles,omitempty"`
Units string `json:"units,omitempty"` // km | mi — bundle distance unit for drive_dist
DayStats []DayDriveStats `json:"day_stats,omitempty"`
}
TripSummary matches OpenAPI TripSummary (plus optional agent fields).
func BuildSummary ¶
BuildSummary loads YAML and builds a TripSummary.
type VersionEntry ¶
type VersionEntry struct {
VersionID string `json:"version_id"`
LastModified string `json:"last_modified,omitempty"` // RFC3339
IsLatest bool `json:"is_latest,omitempty"`
}
VersionEntry is one YAML revision for agent tools.
func ListVersionEntries ¶
func ListVersionEntries(ctx context.Context, st store.Store, tripID string, limit int) ([]VersionEntry, error)
ListVersionEntries lists versions; limit <= 0 means no cap.
type YAMLResult ¶
YAMLResult is itinerary YAML plus version id.
func LoadYAML ¶
func LoadYAML(ctx context.Context, st store.Store, tripID, scope string, day int) (YAMLResult, error)
LoadYAML returns full or day-scoped YAML. Empty scope means full (HTTP/MCP default). Callers that want day-default (viewer chat) must pass scope=day explicitly.
func LoadYAMLVersion ¶
func LoadYAMLVersion(ctx context.Context, st store.Store, tripID, versionID string) (YAMLResult, error)
LoadYAMLVersion returns a prior revision's YAML.