@danceiny/gotry 0.0.1-rc.9 → 0.2.0-rc.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -219
- package/README.zh-CN.md +222 -0
- package/bin/gotry-backend.js +53 -0
- package/bin/gotry-booking-copilot.js +53 -0
- package/bin/gotry-bootstrap.js +1744 -0
- package/bin/gotry-inner.js +733 -83
- package/bin/gotry-process-liveness.d.ts +27 -0
- package/bin/gotry-process-liveness.js +97 -0
- package/bin/gotry-runtime-resolution.d.ts +27 -0
- package/bin/gotry-runtime-resolution.js +49 -0
- package/bin/gotry.js +1 -1
- package/client/client.js +203 -0
- package/cordis.gotry-patch.yml +80 -56
- package/data/airline-airports.json +39 -0
- package/data/stations-12306-verify.json +524 -0
- package/dist/capabilities/agent-reach-deep.js +45 -122
- package/dist/capabilities/agent-reach.js +101 -146
- package/dist/capabilities/anything.js +135 -94
- package/dist/capabilities/artifacts.js +370 -0
- package/dist/capabilities/channel-health.js +131 -0
- package/dist/capabilities/channel-registry.js +256 -0
- package/dist/capabilities/doctor.js +546 -0
- package/dist/capabilities/effect.js +394 -0
- package/dist/capabilities/external-event.js +149 -0
- package/dist/capabilities/fact-log.js +55 -0
- package/dist/capabilities/flyai-config.js +337 -0
- package/dist/capabilities/flyai.js +947 -110
- package/dist/capabilities/fx-contract.js +293 -0
- package/dist/capabilities/geo-atlas.js +246 -0
- package/dist/capabilities/ground-transfer.js +509 -0
- package/dist/capabilities/hbcli.js +260 -123
- package/dist/capabilities/hotelbyte-transaction.js +194 -0
- package/dist/capabilities/incident-log.js +131 -61
- package/dist/capabilities/itinerary-artifact.js +190 -0
- package/dist/capabilities/itinerary-deck-artifact.js +194 -0
- package/dist/capabilities/itinerary-deck-export.js +339 -0
- package/dist/capabilities/lavish-local.js +924 -0
- package/dist/capabilities/model-override.js +38 -0
- package/dist/capabilities/opensky.js +54 -43
- package/dist/capabilities/resilience.js +191 -0
- package/dist/capabilities/session/action-cache.js +50 -44
- package/dist/capabilities/session/adapters/ctrip-flight.js +120 -62
- package/dist/capabilities/session/adapters/ctrip-hotel.js +222 -0
- package/dist/capabilities/session/adapters/dida-portal.js +274 -0
- package/dist/capabilities/session/adapters/meituan-local.js +35 -54
- package/dist/capabilities/session/adapters/rail-12306.js +342 -0
- package/dist/capabilities/session/benchmark.js +189 -0
- package/dist/capabilities/session/bridge-ledger.js +224 -0
- package/dist/capabilities/session/extension-bridge.js +636 -0
- package/dist/capabilities/session/extension-channel.js +109 -0
- package/dist/capabilities/session/extension-distribution.js +230 -0
- package/dist/capabilities/session/extract.js +31 -21
- package/dist/capabilities/session/golden-score.js +114 -0
- package/dist/capabilities/session/health-watch.js +215 -0
- package/dist/capabilities/session/read-guard.js +75 -24
- package/dist/capabilities/session/static-flight-golden.js +150 -0
- package/dist/capabilities/session/transport.js +97 -83
- package/dist/capabilities/session/wizard.js +117 -0
- package/dist/capabilities/session-consent.js +178 -0
- package/dist/capabilities/session-login.js +170 -0
- package/dist/capabilities/session-search.js +635 -44
- package/dist/capabilities/spawn-bounded.js +203 -0
- package/dist/capabilities/sponsor-plugin.js +341 -0
- package/dist/capabilities/visa-policy.js +140 -0
- package/dist/capabilities/weather.js +243 -138
- package/dist/data/session-golden-20.json +25 -0
- package/dist/data/sf-golden-manifest.json +103 -0
- package/dist/data/sf-static-routes.json +91 -0
- package/dist/scripts/action-cache-tests.js +24 -59
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +242 -0
- package/dist/scripts/agent-planning-turn-deadline-tests.js +185 -0
- package/dist/scripts/agent-reach-deep-tests.js +30 -40
- package/dist/scripts/agent-reach-error-tests.js +354 -0
- package/dist/scripts/agent-reach-tests.js +26 -18
- package/dist/scripts/agent-reach-wrapper-tests.js +50 -50
- package/dist/scripts/anything-tests.js +116 -60
- package/dist/scripts/artifact-client-contract-tests.js +220 -0
- package/dist/scripts/artifacts-capability-tests.js +727 -0
- package/dist/scripts/async-collect.js +50 -11
- package/dist/scripts/benchmark-environment-bridge-e2e.js +741 -0
- package/dist/scripts/benchmark-environment-bridge-tests.js +1452 -0
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +126 -0
- package/dist/scripts/booking-copilot-availability-policy-tests.js +265 -0
- package/dist/scripts/booking-copilot-bin-proof-tests.js +66 -0
- package/dist/scripts/booking-copilot-cleanup-proof-helper.js +76 -0
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +144 -0
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +424 -0
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +2839 -0
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +309 -0
- package/dist/scripts/booking-copilot-dsh-readiness-proof.js +238 -0
- package/dist/scripts/booking-copilot-dsh-warmer-proof.js +123 -0
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +156 -0
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +70 -0
- package/dist/scripts/booking-copilot-intent-proof-tests.js +422 -0
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +184 -0
- package/dist/scripts/booking-copilot-planner-live-probe.js +95 -0
- package/dist/scripts/booking-copilot-proof-runtime.js +42 -0
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +210 -0
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +2349 -0
- package/dist/scripts/booking-copilot-server-proof-tests.js +784 -0
- package/dist/scripts/booking-copilot-startup-proof-tests.js +94 -0
- package/dist/scripts/booking-executor-tests.js +80 -0
- package/dist/scripts/booking-recovery-chain-tests.js +182 -0
- package/dist/scripts/booking-saga-tests.js +125 -0
- package/dist/scripts/booking-surface-contract-proof-tests.js +212 -0
- package/dist/scripts/bootstrap-tests.js +1479 -0
- package/dist/scripts/bridge-events-tests.js +239 -0
- package/dist/scripts/bridge-ledger-tests.js +428 -0
- package/dist/scripts/build-changelog.js +238 -0
- package/dist/scripts/build-metrics-report.js +331 -0
- package/dist/scripts/changelog-tests.js +118 -0
- package/dist/scripts/channel-probe-tests.js +103 -0
- package/dist/scripts/channel-probe.js +169 -0
- package/dist/scripts/channel-registry-tests.js +208 -0
- package/dist/scripts/companion-tests.js +25 -70
- package/dist/scripts/dida-cookie-probe.js +87 -0
- package/dist/scripts/dida-runner-stop-tests.js +311 -0
- package/dist/scripts/dida-sw-probe.js +114 -0
- package/dist/scripts/diff-test.js +17 -12
- package/dist/scripts/doctor-tests.js +564 -0
- package/dist/scripts/dsh-artifact-e2e.js +279 -0
- package/dist/scripts/dsh-artifact-web-e2e.js +675 -0
- package/dist/scripts/dsh-http-proxy-sse-proof.js +90 -0
- package/dist/scripts/dsh-runtime-closure-tests.js +182 -0
- package/dist/scripts/dsh-runtime-closure.js +162 -0
- package/dist/scripts/dsh-session-v3-migration-proof.js +109 -0
- package/dist/scripts/dsh-subprocess-local-proof.js +150 -0
- package/dist/scripts/dsh-target-closure-proof.js +178 -0
- package/dist/scripts/effect-tests.js +539 -0
- package/dist/scripts/engine-run.js +1 -3
- package/dist/scripts/engine-tests.js +16 -10
- package/dist/scripts/evaluation-cadence-tests.js +174 -0
- package/dist/scripts/evaluation-contract-tests.js +268 -0
- package/dist/scripts/extension-distribution-cli.js +39 -0
- package/dist/scripts/extension-distribution-tests.js +443 -0
- package/dist/scripts/extension-tests.js +988 -0
- package/dist/scripts/external-event-tests.js +350 -0
- package/dist/scripts/fact-gate-tests.js +869 -0
- package/dist/scripts/fixtures/extension-bridge-unref-child.mjs +21 -0
- package/dist/scripts/flight-hotel-anchor-363-registered-e2e.js +169 -0
- package/dist/scripts/flight-malformed-tests.js +159 -0
- package/dist/scripts/flyai-setup-tests.js +228 -0
- package/dist/scripts/flyai-setup-tool-tests.js +54 -0
- package/dist/scripts/flyai-tests.js +692 -0
- package/dist/scripts/flyai-tool-registration-contract-tests.js +91 -0
- package/dist/scripts/fx-contract-tests.js +201 -0
- package/dist/scripts/g5-guard-tests.js +131 -0
- package/dist/scripts/g5-guard.js +189 -0
- package/dist/scripts/gen-lunar-anchors.js +106 -0
- package/dist/scripts/geo-atlas-tests.js +283 -0
- package/dist/scripts/gotry-backend-kernel-tests.js +206 -0
- package/dist/scripts/gotry-try-demo-tests.js +79 -0
- package/dist/scripts/gotry-try-demo.js +49 -0
- package/dist/scripts/ground-transfer-tests.js +956 -0
- package/dist/scripts/hbcli-e2e-tests.js +159 -0
- package/dist/scripts/hbcli-live-optin-tests.js +96 -0
- package/dist/scripts/hbcli-release-contract-tests.js +122 -0
- package/dist/scripts/hbcli-tests.js +121 -69
- package/dist/scripts/health-watch-cli.js +73 -0
- package/dist/scripts/hotel-date-gate-tests.js +496 -0
- package/dist/scripts/hotelbyte-reconcile-tests.js +141 -0
- package/dist/scripts/hotelbyte-spawn-e2e-tests.js +373 -0
- package/dist/scripts/i18n-tests.js +41 -0
- package/dist/scripts/incident-tests.js +281 -87
- package/dist/scripts/issue-194-job-id-guard-tests.js +106 -0
- package/dist/scripts/issue-233-cancel-refund-commission-tests.js +392 -0
- package/dist/scripts/issue-271-liveness-tests.js +569 -0
- package/dist/scripts/issue-289-model-retry-real-tests.js +296 -0
- package/dist/scripts/issue-289-model-retry-tests.js +441 -0
- package/dist/scripts/issue-289-web-retry-e2e.js +630 -0
- package/dist/scripts/issue-338-home-city-e2e.js +577 -0
- package/dist/scripts/issue343-real-entry-e2e.js +160 -0
- package/dist/scripts/issue436-persisted-routing-e2e.js +247 -0
- package/dist/scripts/itinerary-artifact-tests.js +368 -0
- package/dist/scripts/itinerary-deck-artifact-tests.js +416 -0
- package/dist/scripts/itinerary-deck-export-tests.js +552 -0
- package/dist/scripts/itinerary-deck-tests.js +435 -0
- package/dist/scripts/itinerary-html-tests.js +426 -0
- package/dist/scripts/journey-tests.js +22 -27
- package/dist/scripts/kernel-manifest-evidence.js +109 -0
- package/dist/scripts/kernel-manifest-gate.js +126 -0
- package/dist/scripts/kernel-manifest-tests.js +212 -0
- package/dist/scripts/kernel-manifest-trace-entry.js +7 -0
- package/dist/scripts/kernel-manifest-trace-hook.mjs +28 -0
- package/dist/scripts/kernel-manifest.js +369 -0
- package/dist/scripts/lavish-local-tests.js +1226 -0
- package/dist/scripts/lavish-product-tools-tests.js +537 -0
- package/dist/scripts/ledger-repair-apply-tests.js +316 -0
- package/dist/scripts/ledger-repair-plan-tests.js +375 -0
- package/dist/scripts/ledger-tests.js +382 -246
- package/dist/scripts/ledger-workflow-crash.js +10 -20
- package/dist/scripts/managed-dsh-cleanup-diagnostic-proof.js +184 -0
- package/dist/scripts/managed-dsh-close-failure-proof.js +172 -0
- package/dist/scripts/managed-dsh-run-port-proof.js +153 -0
- package/dist/scripts/managed-dsh-terminal-proof.js +252 -0
- package/dist/scripts/map-tools-vendor-package-proof.js +365 -0
- package/dist/scripts/memory-capture-tests.js +242 -61
- package/dist/scripts/memory-decay-tests.js +18 -52
- package/dist/scripts/memory-lifecycle-tests.js +657 -0
- package/dist/scripts/memory-lifecycle.js +196 -0
- package/dist/scripts/memory-metrics.js +24 -12
- package/dist/scripts/memory-value-report.js +631 -0
- package/dist/scripts/memory-value-tests.js +328 -0
- package/dist/scripts/metrics-report-tests.js +151 -0
- package/dist/scripts/model-override-e2e.js +137 -0
- package/dist/scripts/nightly-evidence-tests.js +161 -0
- package/dist/scripts/nightly-evidence.js +286 -0
- package/dist/scripts/nudge-digest.js +39 -28
- package/dist/scripts/observability-tests.js +381 -0
- package/dist/scripts/onboarding-tests.js +161 -0
- package/dist/scripts/opensky-check.js +18 -13
- package/dist/scripts/opensky-tests.js +28 -28
- package/dist/scripts/persona-surface-guard-tests.js +49 -0
- package/dist/scripts/pnpm-dsh-closure-proof.js +17 -0
- package/dist/scripts/policy-anchor-359-registered-e2e.js +214 -0
- package/dist/scripts/price-drift-tests.js +340 -0
- package/dist/scripts/price-drift-watch.js +447 -0
- package/dist/scripts/probe-poi-tests.js +53 -45
- package/dist/scripts/product-metrics.js +483 -0
- package/dist/scripts/publish-preverify.js +110 -0
- package/dist/scripts/realtime-pricing-tests.js +76 -0
- package/dist/scripts/recall-tests.js +513 -0
- package/dist/scripts/replay-async.js +20 -18
- package/dist/scripts/replay-real.js +18 -18
- package/dist/scripts/replay.js +52 -82
- package/dist/scripts/session-attach-diagnose.js +20 -20
- package/dist/scripts/session-attach-poc.js +34 -37
- package/dist/scripts/session-benchmark.js +180 -0
- package/dist/scripts/session-dida-live-e2e.js +199 -0
- package/dist/scripts/session-extract-tests.js +14 -35
- package/dist/scripts/session-link-tests.js +478 -0
- package/dist/scripts/session-login.js +27 -46
- package/dist/scripts/session-tests.js +796 -96
- package/dist/scripts/session-zones-tests.js +358 -0
- package/dist/scripts/sf-live-benchmark.js +367 -0
- package/dist/scripts/sf-live-challenge-stop-tests.js +453 -0
- package/dist/scripts/sf-live-cli-tests.js +92 -0
- package/dist/scripts/sf-live-options.js +46 -0
- package/dist/scripts/sf-manifest-tests.js +30 -0
- package/dist/scripts/sf-manifest.js +33 -0
- package/dist/scripts/sf-soft-score-tests.js +67 -0
- package/dist/scripts/sf-summary-tests.js +324 -0
- package/dist/scripts/sf-summary.js +525 -0
- package/dist/scripts/share-tests.js +432 -0
- package/dist/scripts/skeleton-check.js +16 -14
- package/dist/scripts/skeleton-integration-test.js +28 -11
- package/dist/scripts/skills-contract-tests.js +51 -46
- package/dist/scripts/smoke-session-gate-tests.js +21 -0
- package/dist/scripts/smoke.js +690 -246
- package/dist/scripts/spawn-bounded-abort-tests.js +241 -0
- package/dist/scripts/sponsor-reuse-tests.js +262 -0
- package/dist/scripts/state-cli-tests.js +226 -101
- package/dist/scripts/state-cli.js +550 -199
- package/dist/scripts/state-repair-cli.js +66 -0
- package/dist/scripts/state-repair-tests.js +140 -0
- package/dist/scripts/static-golden-tests.js +165 -0
- package/dist/scripts/time-eval-tests.js +210 -192
- package/dist/scripts/travel-timeline-tests.js +29 -93
- package/dist/scripts/turn-handoff-collect-tests.js +169 -0
- package/dist/scripts/turn-handoff-collect.js +161 -0
- package/dist/scripts/turn-policy-tests.js +55 -0
- package/dist/scripts/typed-contract-canary.js +176 -0
- package/dist/scripts/tz-resolver-sanity.js +50 -0
- package/dist/scripts/tz-resolver-tests.js +584 -0
- package/dist/scripts/unified-tests.js +23 -19
- package/dist/scripts/visa-policy-tests.js +62 -0
- package/dist/scripts/weather-tests.js +276 -41
- package/dist/scripts/wish-channel-gate-tests.js +54 -0
- package/dist/scripts/write-gate-tests.js +522 -0
- package/dist/scripts/z3-lifecycle-fault-tests.js +188 -0
- package/dist/scripts/z3-lifecycle-tests.js +170 -0
- package/dist/scripts/z3-race-repeat-tests.js +39 -0
- package/dist/scripts/z3-race-tests.js +41 -0
- package/dist/src/artifact-gate.js +829 -0
- package/dist/src/backend/kernel.js +91 -0
- package/dist/src/backend/modules/booking-copilot.js +92 -0
- package/dist/src/backend/modules/booking-executor.js +124 -0
- package/dist/src/backend/modules/session-search.js +551 -0
- package/dist/src/benchmark-agent-conformance.js +578 -0
- package/dist/src/benchmark-environment-bridge.js +515 -0
- package/dist/src/benchmark-headless-child-diagnostics.js +166 -0
- package/dist/src/benchmark-tool-isolation.js +151 -0
- package/dist/src/bookable-facts.js +533 -0
- package/dist/src/booking-saga.js +97 -0
- package/dist/src/booking-surface/availability-policy.js +697 -0
- package/dist/src/booking-surface/booking-intent.js +43 -0
- package/dist/src/booking-surface/cancel-refund-commission.js +379 -0
- package/dist/src/booking-surface/canonical-schema.js +116 -0
- package/dist/src/booking-surface/contracts.js +75 -0
- package/dist/src/booking-surface/dsh-planner.js +1854 -0
- package/dist/src/booking-surface/dsh-plugin.js +378 -0
- package/dist/src/booking-surface/dsh-worker.js +98 -0
- package/dist/src/booking-surface/error-codes.js +231 -0
- package/dist/src/booking-surface/index.js +9 -0
- package/dist/src/booking-surface/managed-dsh-cleanup-diagnostic.js +97 -0
- package/dist/src/booking-surface/managed-dsh-run-port.js +244 -0
- package/dist/src/booking-surface/profile.js +24 -0
- package/dist/src/booking-surface/recovery-chain.js +367 -0
- package/dist/src/booking-surface/runtime.js +1968 -0
- package/dist/src/booking-surface/server.js +674 -0
- package/dist/src/booking-surface/startup.js +168 -0
- package/dist/src/booking-surface/validation.js +261 -0
- package/dist/src/bridge.js +20 -13
- package/dist/src/companions.js +48 -74
- package/dist/src/contracts.js +21 -43
- package/dist/src/dsh-llm.js +97 -111
- package/dist/src/engine.js +276 -193
- package/dist/src/evaluation-cadence.js +97 -0
- package/dist/src/evaluation-contracts.js +283 -0
- package/dist/src/flight-pack-adapter.js +54 -0
- package/dist/src/flight-pack-contract.js +2 -0
- package/dist/src/flyai-setup-tool.js +70 -0
- package/dist/src/gotry-backend.js +125 -0
- package/dist/src/hotel-date-gate.js +118 -0
- package/dist/src/i18n.js +88 -0
- package/dist/src/index.js +2227 -882
- package/dist/src/itinerary-deck.js +139 -0
- package/dist/src/itinerary-doc-shared.js +661 -0
- package/dist/src/itinerary-html.js +131 -0
- package/dist/src/journey.js +155 -108
- package/dist/src/lavish-tools.js +400 -0
- package/dist/src/ledger-repair-apply.js +538 -0
- package/dist/src/ledger-repair-plan.js +463 -0
- package/dist/src/loop.js +319 -160
- package/dist/src/memory-capture.js +180 -32
- package/dist/src/memory-decay.js +30 -14
- package/dist/src/memory-lifecycle.js +1310 -0
- package/dist/src/memory-utility.js +27 -40
- package/dist/src/mock-llm.js +36 -61
- package/dist/src/model.js +81 -36
- package/dist/src/realtime-pricing.js +103 -0
- package/dist/src/recall/card.js +74 -0
- package/dist/src/recall/evaluator.js +140 -0
- package/dist/src/recall/integration.js +17 -0
- package/dist/src/recall/tick.js +166 -0
- package/dist/src/session-link/plan-it-action.js +48 -0
- package/dist/src/session-link/session-link.js +248 -0
- package/dist/src/session-zones.js +507 -0
- package/dist/src/share/adapters.js +51 -0
- package/dist/src/share/share-consent.js +76 -0
- package/dist/src/share/share-deck.js +58 -0
- package/dist/src/share/share-token.js +146 -0
- package/dist/src/slot-spec.js +84 -106
- package/dist/src/state-ledger.js +435 -516
- package/dist/src/state-repair.js +299 -0
- package/dist/src/subagent-job-id-guard.js +58 -0
- package/dist/src/time-anchor.js +231 -33
- package/dist/src/tool-packet.js +20 -8
- package/dist/src/travel-slots.js +58 -35
- package/dist/src/travel-timeline.js +44 -63
- package/dist/src/turn-deadline.js +287 -0
- package/dist/src/turn-policy.js +118 -0
- package/dist/src/tz-resolver.js +143 -0
- package/dist/src/unified.js +535 -359
- package/dist/src/wish-pool.js +42 -12
- package/dist/src/write-gate.js +495 -0
- package/dist/src/z3-shared.js +284 -0
- package/extension/README.md +21 -0
- package/extension/README.zh-CN.md +21 -0
- package/extension/background.js +463 -0
- package/extension/content-bridge.js +270 -0
- package/extension/content-main.js +111 -0
- package/extension/manifest.json +60 -0
- package/package.json +407 -14
- package/schemas/booking.intent.schema.json +193 -0
- package/schemas/booking.surface.schema.json +2622 -0
- package/ts/capabilities/agent-reach-deep.ts +114 -0
- package/ts/capabilities/agent-reach.ts +198 -0
- package/ts/capabilities/anything.ts +255 -0
- package/ts/capabilities/artifacts.ts +428 -0
- package/ts/capabilities/fact-log.ts +54 -0
- package/ts/capabilities/flyai-config.ts +388 -0
- package/ts/capabilities/flyai.ts +1274 -0
- package/ts/capabilities/hbcli.ts +253 -71
- package/ts/capabilities/incident-log.ts +88 -59
- package/ts/capabilities/itinerary-artifact.ts +214 -0
- package/ts/capabilities/itinerary-deck-artifact.ts +218 -0
- package/ts/capabilities/itinerary-deck-export.ts +378 -0
- package/ts/capabilities/opensky.ts +121 -0
- package/ts/capabilities/session/action-cache.ts +148 -0
- package/ts/capabilities/session/adapters/ctrip-flight.ts +181 -0
- package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
- package/ts/capabilities/session/adapters/dida-portal.ts +338 -0
- package/ts/capabilities/session/adapters/meituan-local.ts +70 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +392 -0
- package/ts/capabilities/session/benchmark.ts +276 -0
- package/ts/capabilities/session/bridge-ledger.ts +333 -0
- package/ts/capabilities/session/extension-bridge.ts +794 -0
- package/ts/capabilities/session/extension-channel.ts +144 -0
- package/ts/capabilities/session/extension-distribution.ts +266 -0
- package/ts/capabilities/session/extract.ts +54 -0
- package/ts/capabilities/session/golden-score.ts +139 -0
- package/ts/capabilities/session/health-watch.ts +264 -0
- package/ts/capabilities/session/read-guard.ts +141 -0
- package/ts/capabilities/session/static-flight-golden.ts +209 -0
- package/ts/capabilities/session/transport.ts +146 -0
- package/ts/capabilities/session/wizard.ts +140 -0
- package/ts/capabilities/session-consent.ts +211 -0
- package/ts/capabilities/session-login.ts +208 -0
- package/ts/capabilities/session-search.ts +893 -0
- package/ts/capabilities/weather.ts +330 -0
- package/ts/dsh-runtime/vendor/README.md +68 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/LICENSE +21 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +405 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +404 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/client/client.js +1584 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/cordis.patch.yml +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/icon.svg +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/amap.js +595 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/nominatim.js +63 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/osrm.js +58 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/photon.js +55 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-file.js +87 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-route.js +131 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/geo.js +232 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/index.js +120 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +40 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/staticmap-route.js +115 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/geocode.js +127 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/poi.js +84 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/routes.js +267 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/amap.d.ts +90 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/nominatim.d.ts +17 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/osrm.d.ts +15 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/photon.d.ts +22 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-file.d.ts +33 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-route.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/geo.d.ts +61 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/index.d.ts +18 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +14 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/staticmap-route.d.ts +31 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/geocode.d.ts +11 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/poi.d.ts +9 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/routes.d.ts +75 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/types.d.ts +68 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +97 -0
- package/ts/package.json +293 -3
- package/ts/scripts/async-collect.ts +91 -0
- package/ts/scripts/map-tools-vendor-package-proof.ts +404 -0
- package/ts/scripts/skeleton-check.ts +1 -1
- package/ts/scripts/skeleton-integration-test.ts +23 -1
- package/ts/scripts/state-cli.ts +568 -0
- package/ts/scripts/turn-handoff-collect.ts +178 -0
- package/ts/src/artifact-gate.ts +991 -0
- package/ts/src/benchmark-agent-conformance.ts +619 -0
- package/ts/src/benchmark-environment-bridge.ts +538 -0
- package/ts/src/benchmark-headless-child-diagnostics.ts +184 -0
- package/ts/src/benchmark-tool-isolation.ts +166 -0
- package/ts/src/bookable-facts.ts +837 -0
- package/ts/src/booking-saga.ts +133 -0
- package/ts/src/booking-surface/availability-policy.ts +522 -0
- package/ts/src/booking-surface/booking-intent.ts +86 -0
- package/ts/src/booking-surface/cancel-refund-commission.ts +488 -0
- package/ts/src/booking-surface/canonical-schema.js +116 -0
- package/ts/src/booking-surface/contracts.ts +475 -0
- package/ts/src/booking-surface/dsh-planner.ts +1949 -0
- package/ts/src/booking-surface/dsh-plugin.js +378 -0
- package/ts/src/booking-surface/dsh-worker.ts +110 -0
- package/ts/src/booking-surface/error-codes.ts +241 -0
- package/ts/src/booking-surface/index.ts +9 -0
- package/ts/src/booking-surface/managed-dsh-cleanup-diagnostic.ts +151 -0
- package/ts/src/booking-surface/managed-dsh-run-port.ts +273 -0
- package/ts/src/booking-surface/profile.ts +42 -0
- package/ts/src/booking-surface/recovery-chain.ts +409 -0
- package/ts/src/booking-surface/runtime.ts +1793 -0
- package/ts/src/booking-surface/server.ts +733 -0
- package/ts/src/booking-surface/startup.ts +201 -0
- package/ts/src/booking-surface/validation.ts +217 -0
- package/ts/src/companions.ts +113 -0
- package/ts/src/contracts.ts +13 -3
- package/ts/src/dsh-llm.ts +44 -11
- package/ts/src/flyai-setup-tool.ts +77 -0
- package/ts/src/index.ts +1948 -198
- package/ts/src/itinerary-deck.ts +189 -0
- package/ts/src/itinerary-doc-shared.ts +741 -0
- package/ts/src/itinerary-html.ts +171 -0
- package/ts/src/loop.ts +223 -25
- package/ts/src/memory-capture.ts +283 -0
- package/ts/src/memory-decay.ts +55 -0
- package/ts/src/memory-utility.ts +70 -0
- package/ts/src/mock-llm.ts +4 -8
- package/ts/src/model.ts +88 -2
- package/ts/src/recall/card.ts +106 -0
- package/ts/src/recall/evaluator.ts +170 -0
- package/ts/src/recall/integration.ts +35 -0
- package/ts/src/recall/tick.ts +213 -0
- package/ts/src/session-link/plan-it-action.ts +78 -0
- package/ts/src/session-link/session-link.ts +275 -0
- package/ts/src/share/adapters.ts +93 -0
- package/ts/src/share/share-consent.ts +105 -0
- package/ts/src/share/share-deck.ts +85 -0
- package/ts/src/share/share-token.ts +166 -0
- package/ts/src/slot-spec.ts +172 -0
- package/ts/src/state-ledger.ts +912 -0
- package/ts/src/subagent-job-id-guard.ts +72 -0
- package/ts/src/time-anchor.ts +338 -0
- package/ts/src/tool-packet.ts +32 -0
- package/ts/src/travel-slots.ts +219 -0
- package/ts/src/travel-timeline.ts +83 -0
- package/ts/src/turn-deadline.ts +366 -0
- package/ts/src/turn-policy.ts +154 -0
- package/ts/src/unified.ts +354 -88
- package/ts/src/wish-pool.ts +79 -0
- package/dist/scripts/session-attach-wait.js +0 -41
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const BOOKING_INTENT_SCHEMA_VERSION = 'booking.intent.v1';
|
|
2
|
+
export const BOOKING_INTENT_TARGETS = [
|
|
3
|
+
'search.results',
|
|
4
|
+
'results.refined',
|
|
5
|
+
'hotel.focused',
|
|
6
|
+
'hotel.selected',
|
|
7
|
+
'offers.loaded',
|
|
8
|
+
'offers.refined',
|
|
9
|
+
'offers.compared',
|
|
10
|
+
'offer.selected',
|
|
11
|
+
'offer.verified',
|
|
12
|
+
'checkout.prepared',
|
|
13
|
+
'order.observed',
|
|
14
|
+
];
|
|
15
|
+
/** Ordered read path; an intent target may not be overshot by its action. */
|
|
16
|
+
export const BOOKING_INTENT_ACTION_ORDINAL = {
|
|
17
|
+
'search.patch': 0,
|
|
18
|
+
'search.run': 1,
|
|
19
|
+
'results.view.patch': 2,
|
|
20
|
+
'hotel.focus': 3,
|
|
21
|
+
'hotel.select': 4,
|
|
22
|
+
'offers.query': 5,
|
|
23
|
+
'offers.view.patch': 6,
|
|
24
|
+
'offers.compare': 7,
|
|
25
|
+
'offer.select': 8,
|
|
26
|
+
'offer.check': 9,
|
|
27
|
+
'checkout.prepare': 10,
|
|
28
|
+
'order.observe': 11,
|
|
29
|
+
};
|
|
30
|
+
export const BOOKING_INTENT_TARGET_ACTION = {
|
|
31
|
+
'search.results': 'search.run',
|
|
32
|
+
'results.refined': 'results.view.patch',
|
|
33
|
+
'hotel.focused': 'hotel.focus',
|
|
34
|
+
'hotel.selected': 'hotel.select',
|
|
35
|
+
'offers.loaded': 'offers.query',
|
|
36
|
+
'offers.refined': 'offers.view.patch',
|
|
37
|
+
'offers.compared': 'offers.compare',
|
|
38
|
+
'offer.selected': 'offer.select',
|
|
39
|
+
'offer.verified': 'offer.check',
|
|
40
|
+
'checkout.prepared': 'checkout.prepare',
|
|
41
|
+
'order.observed': 'order.observe',
|
|
42
|
+
};
|
|
43
|
+
export const BOOKING_INTENT_TARGET_ORDINAL = Object.fromEntries(Object.entries(BOOKING_INTENT_TARGET_ACTION).map(([target, action]) => [target, BOOKING_INTENT_ACTION_ORDINAL[action]]));
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cancel/refund independent outcomes + explicit commission disclosure
|
|
3
|
+
* (issue #233, M5-4 pre-entry contract layer; parent #136).
|
|
4
|
+
*
|
|
5
|
+
* Contract only: pure types + pure functions. Zero network, zero subprocess,
|
|
6
|
+
* zero ledger/schema change, zero supplier call surface — the write path stays
|
|
7
|
+
* sealed behind #136 M5 Entry; receipt/outbox/dispatch authority belongs to
|
|
8
|
+
* #231/#232 and is deliberately NOT modeled here.
|
|
9
|
+
*
|
|
10
|
+
* Frozen sources of truth:
|
|
11
|
+
* - docs/design/write-gate-production-design.md §3 (SupplierOutcome closed set),
|
|
12
|
+
* §4 (commission_disclosure digest enters the request fingerprint; a
|
|
13
|
+
* disclosure change invalidates the old receipt), §7 (outcome × user copy
|
|
14
|
+
* matrix), §8 (cancellation / refund order / wallet refund are separate
|
|
15
|
+
* outcomes; cancel.serviceFee is not the customer refund amount; pending →
|
|
16
|
+
* compensated cancels only the local suggestion and never means "refunded"),
|
|
17
|
+
* §10 (commission/sponsorship disclosure before confirmation; unknown must
|
|
18
|
+
* not default to none), §11 (redaction);
|
|
19
|
+
* - docs/design/fact-writegate-seam.md §2.3 (wording authority per claim type:
|
|
20
|
+
* "cancellation requested" only; refunded only from authoritative evidence).
|
|
21
|
+
*
|
|
22
|
+
* Default-off: nothing in this module is wired into any runtime path. The
|
|
23
|
+
* focused suite ts/scripts/issue-233-cancel-refund-commission-tests.ts pins
|
|
24
|
+
* the contract (run-all §62).
|
|
25
|
+
*/
|
|
26
|
+
import { createHash } from 'node:crypto';
|
|
27
|
+
// ---- 1. Independent outcome closed sets -----------------------------------------
|
|
28
|
+
export const CANCELLATION_OUTCOME_SCHEMA = 'gotry.cancellation_outcome.v1';
|
|
29
|
+
/** Cancel REQUEST outcome. There is deliberately no "cancelled" terminal here:
|
|
30
|
+
* only an explicit supplier cancellation receipt (supplierCancellationConfirmed)
|
|
31
|
+
* upgrades a submission into a confirmed cancellation. */
|
|
32
|
+
export const CANCELLATION_STATUSES = ['not_requested', 'cancel_submitted', 'cancel_failed', 'cancel_unknown'];
|
|
33
|
+
export const REFUND_OUTCOME_SCHEMA = 'gotry.refund_outcome.v1';
|
|
34
|
+
/** Money-arrival outcome. Independent from the cancellation outcome by design:
|
|
35
|
+
* the two objects are never merged into a single success state. */
|
|
36
|
+
export const REFUND_STATUSES = ['not_applicable', 'refund_pending', 'refund_failed', 'refunded', 'refund_unknown'];
|
|
37
|
+
/** ADR-17 ledger alphabet, mirrored read-only for copy consistency checks.
|
|
38
|
+
* This module does not touch the ledger (that is #231's surface). */
|
|
39
|
+
export const LOCAL_LEDGER_STATUSES = ['pending', 'confirmed', 'compensated'];
|
|
40
|
+
/** Refund amount may only be concluded from authoritative refund/wallet records. */
|
|
41
|
+
export const REFUND_AUTHORITY_SOURCES = ['supplier_refund_record', 'wallet_refund_record'];
|
|
42
|
+
/** The supplier cancellation fee is a separate disclosure; it is never a refund amount. */
|
|
43
|
+
export const SERVICE_FEE_SOURCE = 'cancel_return_service_fee';
|
|
44
|
+
/** supplierReferenceNo is used only as a supplier-returned value — never decoded
|
|
45
|
+
* or guessed from customerReferenceNo (write-gate design §2/§6). The only way to
|
|
46
|
+
* construct one is `supplierReferenceNoFromReturn` with an explicit return source. */
|
|
47
|
+
export const SUPPLIER_REFERENCE_RETURN_SOURCES = ['supplier_cancel_return', 'supplier_query_return', 'supplier_refund_return'];
|
|
48
|
+
export function supplierReferenceNoFromReturn(value, source) {
|
|
49
|
+
const trimmed = typeof value === 'string' ? value.trim() : '';
|
|
50
|
+
if (trimmed === '')
|
|
51
|
+
return { ok: false, reason: 'supplier_reference_empty' };
|
|
52
|
+
if (!SUPPLIER_REFERENCE_RETURN_SOURCES.includes(source))
|
|
53
|
+
return { ok: false, reason: 'supplier_reference_not_returned_value' };
|
|
54
|
+
return { ok: true, value: Object.freeze({ value: trimmed, source }) };
|
|
55
|
+
}
|
|
56
|
+
const AMOUNT_RE = /^\d+(\.\d+)?$/;
|
|
57
|
+
function nonEmpty(v) {
|
|
58
|
+
return typeof v === 'string' && v.trim() !== '';
|
|
59
|
+
}
|
|
60
|
+
function validAmount(v) {
|
|
61
|
+
return nonEmpty(v) && AMOUNT_RE.test(v.trim());
|
|
62
|
+
}
|
|
63
|
+
export function cancellationOutcome(input) {
|
|
64
|
+
if (input?.schema !== CANCELLATION_OUTCOME_SCHEMA)
|
|
65
|
+
return { ok: false, reason: 'schema_mismatch' };
|
|
66
|
+
if (!CANCELLATION_STATUSES.includes(input.status))
|
|
67
|
+
return { ok: false, reason: 'unknown_cancellation_status' };
|
|
68
|
+
if (!nonEmpty(input.customerReferenceNo))
|
|
69
|
+
return { ok: false, reason: 'customer_reference_required' };
|
|
70
|
+
if (input.supplierReferenceNo !== undefined) {
|
|
71
|
+
const r = input.supplierReferenceNo;
|
|
72
|
+
if (!nonEmpty(r?.value) || !SUPPLIER_REFERENCE_RETURN_SOURCES.includes(r?.source)) {
|
|
73
|
+
return { ok: false, reason: 'supplier_reference_not_returned_value' };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (input.supplierCancellationConfirmed !== undefined && !nonEmpty(input.supplierCancellationConfirmed?.digest)) {
|
|
77
|
+
return { ok: false, reason: 'supplier_cancellation_receipt_digest_required' };
|
|
78
|
+
}
|
|
79
|
+
if (!nonEmpty(input.observedAt))
|
|
80
|
+
return { ok: false, reason: 'observed_at_required' };
|
|
81
|
+
return { ok: true, value: Object.freeze({ ...input }) };
|
|
82
|
+
}
|
|
83
|
+
export function refundOutcome(input) {
|
|
84
|
+
if (input?.schema !== REFUND_OUTCOME_SCHEMA)
|
|
85
|
+
return { ok: false, reason: 'schema_mismatch' };
|
|
86
|
+
if (!REFUND_STATUSES.includes(input.status))
|
|
87
|
+
return { ok: false, reason: 'unknown_refund_status' };
|
|
88
|
+
if (!nonEmpty(input.observedAt))
|
|
89
|
+
return { ok: false, reason: 'observed_at_required' };
|
|
90
|
+
if (input.customerRefund !== undefined) {
|
|
91
|
+
const cr = input.customerRefund;
|
|
92
|
+
if (!validAmount(cr?.amount) || !nonEmpty(cr?.currency))
|
|
93
|
+
return { ok: false, reason: 'refund_amount_invalid' };
|
|
94
|
+
if (cr.source === SERVICE_FEE_SOURCE)
|
|
95
|
+
return { ok: false, reason: 'service_fee_used_as_refund_amount' };
|
|
96
|
+
}
|
|
97
|
+
if (input.status === 'refunded') {
|
|
98
|
+
const authoritative = input.customerRefund !== undefined &&
|
|
99
|
+
REFUND_AUTHORITY_SOURCES.includes(input.customerRefund.source) &&
|
|
100
|
+
input.evidence !== undefined &&
|
|
101
|
+
REFUND_AUTHORITY_SOURCES.includes(input.evidence?.kind) &&
|
|
102
|
+
nonEmpty(input.evidence?.digest);
|
|
103
|
+
if (!authoritative)
|
|
104
|
+
return { ok: false, reason: 'refund_claimed_without_evidence' };
|
|
105
|
+
}
|
|
106
|
+
if (input.supplierServiceFee !== undefined && (!validAmount(input.supplierServiceFee?.amount) || !nonEmpty(input.supplierServiceFee?.currency))) {
|
|
107
|
+
return { ok: false, reason: 'service_fee_invalid' };
|
|
108
|
+
}
|
|
109
|
+
return { ok: true, value: Object.freeze({ ...input }) };
|
|
110
|
+
}
|
|
111
|
+
export function aftercareFacts(cancel, refund) {
|
|
112
|
+
return Object.freeze({
|
|
113
|
+
cancellationRequested: cancel.status === 'cancel_submitted',
|
|
114
|
+
orderCancelled: cancel.supplierCancellationConfirmed !== undefined
|
|
115
|
+
? true
|
|
116
|
+
: cancel.status === 'cancel_failed'
|
|
117
|
+
? false
|
|
118
|
+
: 'unknown',
|
|
119
|
+
moneyReturned: refund.status === 'refunded'
|
|
120
|
+
? true
|
|
121
|
+
: refund.status === 'refund_failed' || refund.status === 'not_applicable'
|
|
122
|
+
? false
|
|
123
|
+
: 'unknown',
|
|
124
|
+
refundStatus: refund.status,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// ---- 3. Commission / sponsorship disclosure --------------------------------------
|
|
128
|
+
export const COMMISSION_DISCLOSURE_SCHEMA = 'gotry.commission_disclosure.v1';
|
|
129
|
+
export const COMMISSION_BENEFIT_KINDS = ['commission', 'rebate', 'sponsorship', 'preferred_placement'];
|
|
130
|
+
export const COMMISSION_CERTAINTIES = ['known_benefit', 'known_none', 'unknown'];
|
|
131
|
+
export const COMMISSION_SOURCES = ['supplier_field', 'contract_rule'];
|
|
132
|
+
export const COMMISSION_AMOUNT_BASES = ['fixed', 'percent_of_total', 'per_night'];
|
|
133
|
+
const PAID_BY = ['supplier', 'distributor', 'customer'];
|
|
134
|
+
export const COMMISSION_VIOLATION_CODES = [
|
|
135
|
+
'commission_undisclosed',
|
|
136
|
+
'commission_none_without_source',
|
|
137
|
+
'commission_benefit_incomplete',
|
|
138
|
+
'commission_amount_basis_inconsistent',
|
|
139
|
+
'disclosure_digest_mismatch',
|
|
140
|
+
];
|
|
141
|
+
const POSITIVE_NUMBER_RE = /^(0*[1-9][0-9]*(\.[0-9]+)?|0*\.[0-9]*[1-9][0-9]*)$/;
|
|
142
|
+
export function validateCommissionDisclosure(v) {
|
|
143
|
+
if (typeof v !== 'object' || v === null || v.schema !== COMMISSION_DISCLOSURE_SCHEMA) {
|
|
144
|
+
return { ok: false, violations: ['commission_undisclosed'] };
|
|
145
|
+
}
|
|
146
|
+
const d = v;
|
|
147
|
+
if (!COMMISSION_CERTAINTIES.includes(d.certainty))
|
|
148
|
+
return { ok: false, violations: ['commission_undisclosed'] };
|
|
149
|
+
if (!COMMISSION_SOURCES.includes(d.source))
|
|
150
|
+
return { ok: false, violations: ['commission_benefit_incomplete'] };
|
|
151
|
+
const violations = [];
|
|
152
|
+
if (!Array.isArray(d.benefits))
|
|
153
|
+
return { ok: false, violations: ['commission_benefit_incomplete'] };
|
|
154
|
+
if (d.certainty === 'known_none' || d.certainty === 'unknown') {
|
|
155
|
+
if (d.benefits.length > 0)
|
|
156
|
+
violations.push('commission_benefit_incomplete');
|
|
157
|
+
if (d.certainty === 'known_none' && d.source !== 'contract_rule')
|
|
158
|
+
violations.push('commission_none_without_source');
|
|
159
|
+
}
|
|
160
|
+
if (d.certainty === 'known_benefit') {
|
|
161
|
+
if (d.benefits.length === 0)
|
|
162
|
+
violations.push('commission_benefit_incomplete');
|
|
163
|
+
}
|
|
164
|
+
for (const b of d.benefits) {
|
|
165
|
+
if (!COMMISSION_BENEFIT_KINDS.includes(b?.kind) ||
|
|
166
|
+
!PAID_BY.includes(b?.paidBy) ||
|
|
167
|
+
!nonEmpty(b?.paidTo)) {
|
|
168
|
+
violations.push('commission_benefit_incomplete');
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const basis = b.basis;
|
|
172
|
+
if (!COMMISSION_AMOUNT_BASES.includes(basis?.type)) {
|
|
173
|
+
violations.push('commission_amount_basis_inconsistent');
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (basis.type === 'percent_of_total') {
|
|
177
|
+
const okPercent = validAmount(basis.percent) && POSITIVE_NUMBER_RE.test(basis.percent.trim()) && basis.amount === undefined;
|
|
178
|
+
if (!okPercent)
|
|
179
|
+
violations.push('commission_amount_basis_inconsistent');
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const okFixed = validAmount(basis.amount) && nonEmpty(basis.currency) && basis.percent === undefined;
|
|
183
|
+
if (!okFixed)
|
|
184
|
+
violations.push('commission_amount_basis_inconsistent');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return violations.length === 0 ? { ok: true } : { ok: false, violations };
|
|
188
|
+
}
|
|
189
|
+
/** Canonical JSON (sorted keys, stable) — local to keep this module dependency-free. */
|
|
190
|
+
function canonicalJson(value) {
|
|
191
|
+
if (value === null || typeof value !== 'object')
|
|
192
|
+
return JSON.stringify(value) ?? 'null';
|
|
193
|
+
if (Array.isArray(value))
|
|
194
|
+
return `[${value.map(canonicalJson).join(',')}]`;
|
|
195
|
+
const obj = value;
|
|
196
|
+
return `{${Object.keys(obj)
|
|
197
|
+
.sort()
|
|
198
|
+
.map(key => `${JSON.stringify(key)}:${canonicalJson(obj[key])}`)
|
|
199
|
+
.join(',')}}`;
|
|
200
|
+
}
|
|
201
|
+
export function computeDisclosureDigest(disclosure) {
|
|
202
|
+
return createHash('sha256')
|
|
203
|
+
.update(canonicalJson({ schema: disclosure.schema, certainty: disclosure.certainty, benefits: disclosure.benefits, source: disclosure.source }))
|
|
204
|
+
.digest('hex');
|
|
205
|
+
}
|
|
206
|
+
/** Confirmation boundary: no disclosure object at all is a hard reject — a card
|
|
207
|
+
* may not be confirmed without explicit commission disclosure (§10). */
|
|
208
|
+
export function disclosureForConfirmation(v) {
|
|
209
|
+
const checked = validateCommissionDisclosure(v);
|
|
210
|
+
if (!checked.ok)
|
|
211
|
+
return { ok: false, violation: checked.violations[0] };
|
|
212
|
+
const disclosure = v;
|
|
213
|
+
return { ok: true, disclosure, digest: computeDisclosureDigest(disclosure) };
|
|
214
|
+
}
|
|
215
|
+
/** The request-fingerprint field carrying the disclosure digest (design §4). */
|
|
216
|
+
export const COMMISSION_DISCLOSURE_FINGERPRINT_FIELD = 'commission_disclosure';
|
|
217
|
+
export function bindDisclosureToFingerprint(fingerprint, disclosure) {
|
|
218
|
+
const digest = computeDisclosureDigest(disclosure);
|
|
219
|
+
const existing = fingerprint[COMMISSION_DISCLOSURE_FINGERPRINT_FIELD];
|
|
220
|
+
if (typeof existing === 'string' && existing !== digest) {
|
|
221
|
+
// Disclosure caliber changed after confirmation: the old receipt is invalid;
|
|
222
|
+
// re-confirmation against the new disclosure is required.
|
|
223
|
+
return { ok: false, violation: 'disclosure_digest_mismatch' };
|
|
224
|
+
}
|
|
225
|
+
return { ok: true, fingerprint: { ...fingerprint, [COMMISSION_DISCLOSURE_FINGERPRINT_FIELD]: digest }, digest };
|
|
226
|
+
}
|
|
227
|
+
/** Arrival claims. If copy states these while the outcome is not an evidenced
|
|
228
|
+
* `refunded`, the wording contradicts the ledger-side tokens. */
|
|
229
|
+
const ARRIVAL_TOKENS = {
|
|
230
|
+
en: ['refunded', 'refund received', 'refund has arrived'],
|
|
231
|
+
'zh-CN': ['已退款', '退款已到账', '退款到账'],
|
|
232
|
+
};
|
|
233
|
+
const CANCEL_DONE_TOKENS = {
|
|
234
|
+
en: ['cancelled'],
|
|
235
|
+
'zh-CN': ['已取消'],
|
|
236
|
+
};
|
|
237
|
+
const BENEFIT_MARKERS = {
|
|
238
|
+
en: ['commission', 'rebate', 'sponsorship', 'preferred placement'],
|
|
239
|
+
'zh-CN': ['佣金', '返利', '赞助', '优先位'],
|
|
240
|
+
};
|
|
241
|
+
/** A definite benefit claim (only allowed when certainty='known_benefit'). */
|
|
242
|
+
const DEFINITE_BENEFIT_TOKENS = {
|
|
243
|
+
en: ['paid by', '% of total'],
|
|
244
|
+
'zh-CN': ['支付给', '%'],
|
|
245
|
+
};
|
|
246
|
+
const ZH_BENEFIT_KIND = {
|
|
247
|
+
commission: '佣金',
|
|
248
|
+
rebate: '返利',
|
|
249
|
+
sponsorship: '赞助',
|
|
250
|
+
preferred_placement: '优先位',
|
|
251
|
+
};
|
|
252
|
+
export const COPY_VIOLATION_CODES = [
|
|
253
|
+
'copy_claimed_cancelled_without_supplier_evidence',
|
|
254
|
+
'copy_claimed_refund_arrival_without_authority',
|
|
255
|
+
'copy_refund_wording_while_pending_or_unknown',
|
|
256
|
+
'copy_refund_wording_on_local_compensation_only',
|
|
257
|
+
'commission_disclosure_missing_from_summary',
|
|
258
|
+
'commission_status_contradicts_summary',
|
|
259
|
+
];
|
|
260
|
+
export function localLedgerCopy(status, locale) {
|
|
261
|
+
if (locale === 'zh-CN') {
|
|
262
|
+
if (status === 'pending')
|
|
263
|
+
return '本地建议待确认;未下单。';
|
|
264
|
+
if (status === 'confirmed')
|
|
265
|
+
return '本地已确认授权;供应商结果待回执。';
|
|
266
|
+
return '本地账面已补偿;这只是账务动作,退款状态以退款结果为准。';
|
|
267
|
+
}
|
|
268
|
+
if (status === 'pending')
|
|
269
|
+
return 'Local suggestion pending confirmation; no order placed.';
|
|
270
|
+
if (status === 'confirmed')
|
|
271
|
+
return 'Confirmed and authorized locally; supplier outcome pending receipt.';
|
|
272
|
+
return 'Compensated locally; this is a ledger action only — refund state is tracked by the refund outcome.';
|
|
273
|
+
}
|
|
274
|
+
function basisLabel(basis, locale) {
|
|
275
|
+
if (basis.type === 'percent_of_total')
|
|
276
|
+
return locale === 'zh-CN' ? `总价 ${basis.percent}%` : `${basis.percent}% of total`;
|
|
277
|
+
if (basis.type === 'per_night')
|
|
278
|
+
return locale === 'zh-CN' ? `每晚 ${basis.amount} ${basis.currency}` : `${basis.amount} ${basis.currency} per night`;
|
|
279
|
+
return locale === 'zh-CN' ? `固定 ${basis.amount} ${basis.currency}` : `${basis.amount} ${basis.currency} fixed`;
|
|
280
|
+
}
|
|
281
|
+
function disclosureLines(disclosure, locale) {
|
|
282
|
+
const zh = locale === 'zh-CN';
|
|
283
|
+
if (disclosure.certainty === 'unknown')
|
|
284
|
+
return [zh ? '佣金/返利/赞助披露:未知(不默认没有)。' : 'Commission/sponsorship disclosure: unknown (not assumed none).'];
|
|
285
|
+
if (disclosure.certainty === 'known_none')
|
|
286
|
+
return [zh ? '佣金/返利/赞助披露:无(依据合同规则记录)。' : 'Commission/sponsorship disclosure: none (source: contract rule).'];
|
|
287
|
+
return disclosure.benefits.map(b => zh
|
|
288
|
+
? `${ZH_BENEFIT_KIND[b.kind]}:由 ${b.paidBy} 支付给 ${b.paidTo},口径 ${basisLabel(b.basis, locale)}。`
|
|
289
|
+
: `${b.kind.replaceAll('_', ' ')}: paid by ${b.paidBy} to ${b.paidTo} — ${basisLabel(b.basis, locale)}.`);
|
|
290
|
+
}
|
|
291
|
+
export function renderAftercareCopy(cancel, refund, ledgerStatus, disclosure, locale) {
|
|
292
|
+
const zh = locale === 'zh-CN';
|
|
293
|
+
const lines = [localLedgerCopy(ledgerStatus, locale)];
|
|
294
|
+
if (cancel.supplierCancellationConfirmed !== undefined) {
|
|
295
|
+
lines.push(zh ? '供应商回执确认已取消(证据摘要已留存)。' : 'Cancelled per supplier receipt (evidence digest on file).');
|
|
296
|
+
}
|
|
297
|
+
else if (cancel.status === 'not_requested') {
|
|
298
|
+
lines.push(zh ? '未申请取消。' : 'No cancellation requested.');
|
|
299
|
+
}
|
|
300
|
+
else if (cancel.status === 'cancel_submitted') {
|
|
301
|
+
lines.push(zh ? '已提交取消申请;等待供应商确认。' : 'Cancellation requested/submitted; awaiting supplier confirmation.');
|
|
302
|
+
}
|
|
303
|
+
else if (cancel.status === 'cancel_failed') {
|
|
304
|
+
lines.push(zh ? '取消失败。' : 'Cancellation failed.');
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
lines.push(zh ? '取消结果未知;对账中。' : 'Cancellation outcome unknown; reconciling.');
|
|
308
|
+
}
|
|
309
|
+
if (refund.status === 'not_applicable') {
|
|
310
|
+
lines.push(zh ? '不涉及退款。' : 'No refund involved.');
|
|
311
|
+
}
|
|
312
|
+
else if (refund.status === 'refund_pending') {
|
|
313
|
+
lines.push(zh ? '退款处理中;尚未到账。' : 'Refund pending; not yet arrived.');
|
|
314
|
+
}
|
|
315
|
+
else if (refund.status === 'refund_failed') {
|
|
316
|
+
lines.push(zh ? '退款失败;未到账。' : 'Refund failed; the refund did not arrive.');
|
|
317
|
+
}
|
|
318
|
+
else if (refund.status === 'refund_unknown') {
|
|
319
|
+
lines.push(zh ? '退款结果未知;对账中。' : 'Refund outcome unknown; reconciling.');
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
lines.push(zh
|
|
323
|
+
? `退款已到账:${refund.customerRefund?.amount} ${refund.customerRefund?.currency}(依据 ${refund.evidence?.kind})。`
|
|
324
|
+
: `Refund received: ${refund.customerRefund?.amount} ${refund.customerRefund?.currency} per ${refund.evidence?.kind}.`);
|
|
325
|
+
}
|
|
326
|
+
if (refund.supplierServiceFee !== undefined) {
|
|
327
|
+
lines.push(zh
|
|
328
|
+
? `供应商取消手续费(供应商收取,不是退款金额):${refund.supplierServiceFee.amount} ${refund.supplierServiceFee.currency}。`
|
|
329
|
+
: `Supplier cancellation service fee (charged by supplier, not the refund): ${refund.supplierServiceFee.amount} ${refund.supplierServiceFee.currency}.`);
|
|
330
|
+
}
|
|
331
|
+
if (disclosure !== undefined)
|
|
332
|
+
lines.push(...disclosureLines(disclosure, locale));
|
|
333
|
+
return lines.join('\n');
|
|
334
|
+
}
|
|
335
|
+
/** Mechanical token gate: copy shown to the user must not claim states the
|
|
336
|
+
* outcome objects (and the ledger mirror) do not carry, and must not hide the
|
|
337
|
+
* commission disclosure behind a total price. This is a regression anchor for
|
|
338
|
+
* generated/hand-written/LLM copy — not an NLU claim. */
|
|
339
|
+
export function copyTokenViolations(text, state) {
|
|
340
|
+
const violations = [];
|
|
341
|
+
const zh = state.locale === 'zh-CN';
|
|
342
|
+
const hay = zh ? text : text.toLowerCase();
|
|
343
|
+
const has = (tokens) => tokens.some(t => hay.includes(t));
|
|
344
|
+
const arrival = ARRIVAL_TOKENS[state.locale];
|
|
345
|
+
const cancelDone = CANCEL_DONE_TOKENS[state.locale];
|
|
346
|
+
if (state.cancel.supplierCancellationConfirmed === undefined && has(cancelDone)) {
|
|
347
|
+
violations.push('copy_claimed_cancelled_without_supplier_evidence');
|
|
348
|
+
}
|
|
349
|
+
if (state.refund.status !== 'refunded' && has(arrival)) {
|
|
350
|
+
violations.push('copy_claimed_refund_arrival_without_authority');
|
|
351
|
+
if (state.refund.status === 'refund_pending' || state.refund.status === 'refund_unknown') {
|
|
352
|
+
violations.push('copy_refund_wording_while_pending_or_unknown');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (state.ledgerStatus === 'compensated' && state.refund.status === 'not_applicable' && has(arrival)) {
|
|
356
|
+
violations.push('copy_refund_wording_on_local_compensation_only');
|
|
357
|
+
}
|
|
358
|
+
const d = state.disclosure;
|
|
359
|
+
if (d !== undefined) {
|
|
360
|
+
if (d.certainty === 'known_benefit') {
|
|
361
|
+
if (!has(BENEFIT_MARKERS[state.locale]))
|
|
362
|
+
violations.push('commission_disclosure_missing_from_summary');
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
const required = d.certainty === 'unknown'
|
|
366
|
+
? zh
|
|
367
|
+
? hay.includes('佣金') && hay.includes('未知')
|
|
368
|
+
: hay.includes('commission') && hay.includes('unknown')
|
|
369
|
+
: zh
|
|
370
|
+
? hay.includes('无(依据')
|
|
371
|
+
: hay.includes('none');
|
|
372
|
+
if (!required)
|
|
373
|
+
violations.push('commission_disclosure_missing_from_summary');
|
|
374
|
+
if (has(DEFINITE_BENEFIT_TOKENS[state.locale]))
|
|
375
|
+
violations.push('commission_status_contradicts_summary');
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return violations;
|
|
379
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime projection of the canonical booking.surface JSON Schema.
|
|
3
|
+
*
|
|
4
|
+
* dsh tools need self-contained JSON Schemas, while the canonical document is
|
|
5
|
+
* organized with local $refs. This helper derives each action branch directly
|
|
6
|
+
* from those canonical bytes and recursively inlines local references. No
|
|
7
|
+
* model-facing action schema is maintained by hand.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { readFileSync } from 'node:fs'
|
|
11
|
+
|
|
12
|
+
const schemaUrl = new URL('../../../schemas/booking.surface.schema.json', import.meta.url)
|
|
13
|
+
export const canonicalBookingSurfaceSchema = JSON.parse(readFileSync(schemaUrl, 'utf8'))
|
|
14
|
+
const intentSchemaUrl = new URL('../../../schemas/booking.intent.schema.json', import.meta.url)
|
|
15
|
+
export const canonicalBookingIntentSchema = JSON.parse(readFileSync(intentSchemaUrl, 'utf8'))
|
|
16
|
+
|
|
17
|
+
function clone(value) {
|
|
18
|
+
return JSON.parse(JSON.stringify(value))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function definitionFromRef(ref, schema) {
|
|
22
|
+
const prefix = '#/$defs/'
|
|
23
|
+
if (typeof ref !== 'string' || !ref.startsWith(prefix)) {
|
|
24
|
+
throw new Error(`booking_schema_external_ref_forbidden:${String(ref)}`)
|
|
25
|
+
}
|
|
26
|
+
const name = ref.slice(prefix.length)
|
|
27
|
+
const definition = schema.$defs?.[name]
|
|
28
|
+
if (!definition) throw new Error(`booking_schema_missing_definition:${name}`)
|
|
29
|
+
return definition
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function inlineLocalRefs(value, schema, stack = []) {
|
|
33
|
+
if (Array.isArray(value)) return value.map((item) => inlineLocalRefs(item, schema, stack))
|
|
34
|
+
if (typeof value !== 'object' || value === null) return value
|
|
35
|
+
if (typeof value.$ref === 'string') {
|
|
36
|
+
if (stack.includes(value.$ref)) throw new Error(`booking_schema_recursive_ref:${value.$ref}`)
|
|
37
|
+
const { $ref, ...siblings } = value
|
|
38
|
+
return {
|
|
39
|
+
...inlineLocalRefs(definitionFromRef($ref, schema), schema, [...stack, $ref]),
|
|
40
|
+
...inlineLocalRefs(siblings, schema, stack),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, inlineLocalRefs(item, schema, stack)]))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function canonicalActionSchemaForKind(kind, schema, definitionName) {
|
|
47
|
+
const action = schema.$defs?.[definitionName]
|
|
48
|
+
if (!action) throw new Error('booking_schema_action_union_missing')
|
|
49
|
+
if (Array.isArray(action.allOf)) {
|
|
50
|
+
const branch = action.allOf.find((candidate) => candidate?.if?.properties?.kind?.const === kind)
|
|
51
|
+
const input = branch?.then?.properties?.input
|
|
52
|
+
if (!input) throw new Error(`booking_schema_action_kind_missing:${kind}`)
|
|
53
|
+
return clone(inlineLocalRefs({
|
|
54
|
+
type: action.type,
|
|
55
|
+
required: action.required,
|
|
56
|
+
properties: { ...action.properties, kind: { type: 'string', const: kind }, input },
|
|
57
|
+
additionalProperties: action.additionalProperties,
|
|
58
|
+
}, schema))
|
|
59
|
+
}
|
|
60
|
+
if (!Array.isArray(action.oneOf)) throw new Error('booking_schema_action_union_missing')
|
|
61
|
+
const branch = action.oneOf.find((candidate) => candidate?.allOf?.some((part) => part?.properties?.kind?.const === kind))
|
|
62
|
+
const base = schema.$defs?.ActionBase
|
|
63
|
+
const input = branch?.allOf?.find((part) => part?.properties?.input)?.properties?.input
|
|
64
|
+
if (!base || !input) throw new Error(`booking_schema_action_kind_missing:${kind}`)
|
|
65
|
+
return clone(inlineLocalRefs({
|
|
66
|
+
...base,
|
|
67
|
+
properties: { ...base.properties, kind: { type: 'string', const: kind }, input },
|
|
68
|
+
}, schema))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function canonicalBookingActionSchemaForKind(kind) {
|
|
72
|
+
return canonicalActionSchemaForKind(kind, canonicalBookingSurfaceSchema, 'Action')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const DSH_JSON_SCHEMA_KEYS = new Set([
|
|
76
|
+
'type', 'oneOf', 'properties', 'required', 'additionalProperties', 'items',
|
|
77
|
+
'enum', 'const', 'description', 'title', 'default', 'examples',
|
|
78
|
+
])
|
|
79
|
+
|
|
80
|
+
function projectDshSchema(value) {
|
|
81
|
+
if (Array.isArray(value)) return value.map(projectDshSchema)
|
|
82
|
+
if (typeof value !== 'object' || value === null) return value
|
|
83
|
+
return Object.fromEntries(Object.entries(value)
|
|
84
|
+
.filter(([key]) => DSH_JSON_SCHEMA_KEYS.has(key))
|
|
85
|
+
.map(([key, item]) => {
|
|
86
|
+
if (key === 'properties') {
|
|
87
|
+
return [key, Object.fromEntries(Object.entries(item).map(([name, property]) => [name, projectDshSchema(property)]))]
|
|
88
|
+
}
|
|
89
|
+
return [key, projectDshSchema(item)]
|
|
90
|
+
}))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* dsh-tools intentionally supports a smaller enforced JSON-Schema vocabulary.
|
|
95
|
+
* Keep the canonical shape/type/enum/closure guarantees at the model seam;
|
|
96
|
+
* the full canonical AJV validator remains the runtime authority for numeric,
|
|
97
|
+
* pattern, size and uniqueness constraints before an operation can be issued.
|
|
98
|
+
*/
|
|
99
|
+
export function dshBookingActionSchemaForKind(kind) {
|
|
100
|
+
return projectDshSchema(canonicalBookingActionSchemaForKind(kind))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Self-contained intent schema with its sole public-contract ref inlined. */
|
|
104
|
+
export function canonicalBookingIntentProjectionSchema() {
|
|
105
|
+
const intent = clone(canonicalBookingIntentSchema)
|
|
106
|
+
intent.properties.offerCriteria = clone(inlineLocalRefs(
|
|
107
|
+
canonicalBookingSurfaceSchema.$defs.OfferCriteria,
|
|
108
|
+
canonicalBookingSurfaceSchema,
|
|
109
|
+
))
|
|
110
|
+
return intent
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Provider-advertised subset; execute-time validation uses the full form. */
|
|
114
|
+
export function dshBookingIntentProjectionSchema() {
|
|
115
|
+
return projectDshSchema(canonicalBookingIntentProjectionSchema())
|
|
116
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical TypeScript contract for HotelByte's embedded Booking Copilot.
|
|
3
|
+
*
|
|
4
|
+
* Executable facts cross this boundary only as discriminated data. Human text
|
|
5
|
+
* is limited to a user turn or an explanation and is never parsed as an action.
|
|
6
|
+
*/
|
|
7
|
+
/** Compatibility line. Additive compatible changes retain this value; breaking changes must bump it. */
|
|
8
|
+
export const BOOKING_SURFACE_SCHEMA_VERSION = 'booking.surface';
|
|
9
|
+
/** Diagnostic SHA-256 of the exact local schema artifact; it detects drift but is not a compatibility gate. */
|
|
10
|
+
export const BOOKING_SURFACE_SCHEMA_SHA256 = 'a6b4ded86998a25a3345a0813d46cf7c43c9c91c14c5a6cac053af75f8064847';
|
|
11
|
+
export const BOOKING_SURFACE_VERSION_HEADER = 'x-booking-surface-version';
|
|
12
|
+
export const BOOKING_SURFACE_SCHEMA_SHA256_HEADER = 'x-booking-surface-schema-sha256';
|
|
13
|
+
/**
|
|
14
|
+
* Additive capabilities are sender-gated instead of creating a new contract
|
|
15
|
+
* line. A sender may use one only after every currently routable peer has
|
|
16
|
+
* advertised it; an omitted feature list therefore means no optional feature.
|
|
17
|
+
*/
|
|
18
|
+
export const BOOKING_SURFACE_FEATURES = ['trusted-order-observation-v1'];
|
|
19
|
+
export const BOOKING_SURFACE_FEATURES_HEADER = 'x-booking-surface-features';
|
|
20
|
+
function advertisedBookingSurfaceFeatures(advertisement) {
|
|
21
|
+
if (!Array.isArray(advertisement.features))
|
|
22
|
+
return new Set();
|
|
23
|
+
return new Set(advertisement.features.filter((feature) => typeof feature === 'string' && BOOKING_SURFACE_FEATURES.includes(feature)));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Computes the safe fleet intersection. Callers must supply one fresh
|
|
27
|
+
* advertisement for every routable release identity; an empty or mixed set
|
|
28
|
+
* disables optional fields instead of guessing from the schema hash.
|
|
29
|
+
*/
|
|
30
|
+
export function bookingSurfaceFleetFeatures(advertisements) {
|
|
31
|
+
if (advertisements.length === 0)
|
|
32
|
+
return [];
|
|
33
|
+
const advertised = advertisements.map(advertisedBookingSurfaceFeatures);
|
|
34
|
+
return BOOKING_SURFACE_FEATURES.filter((feature) => advertised.every((features) => features.has(feature)));
|
|
35
|
+
}
|
|
36
|
+
export const BOOKING_SURFACES = [
|
|
37
|
+
'tenant',
|
|
38
|
+
'customer_portal',
|
|
39
|
+
'storefront',
|
|
40
|
+
'payment_link',
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Process composition modes are deliberately separate from the payload
|
|
44
|
+
* schema. The default accepts turns already bound by HotelByte's BFF; the
|
|
45
|
+
* second mode is reserved for an in-process BFF binding seam.
|
|
46
|
+
*/
|
|
47
|
+
export const BOOKING_COPILOT_INGRESS_MODES = ['bff-bound-turn-only', 'bff-ingress-binding'];
|
|
48
|
+
export const BOOKING_COPILOT_ACCEPTED_TURN_KINDS = ['user.turn', 'action.receipt.continuation'];
|
|
49
|
+
export const BOOKING_COPILOT_INGRESS_TURN_KIND = 'user.turn.ingress';
|
|
50
|
+
/** Hard task-level operation budget. The counter is persisted in the ledger. */
|
|
51
|
+
export const BOOKING_COPILOT_MAX_OPERATIONS = 20;
|
|
52
|
+
export const BOOKING_READ_ACTION_KINDS = ['search.patch', 'search.run', 'results.view.patch', 'hotel.focus', 'hotel.select', 'offers.query', 'offers.view.patch', 'offers.compare', 'offer.select', 'offer.check', 'checkout.prepare', 'order.observe'];
|
|
53
|
+
/** Full read journey shared by tenant and customer-portal workspaces. */
|
|
54
|
+
export const BOOKING_FULL_JOURNEY_ACTION_KINDS = ['search.patch', 'search.run', 'results.view.patch', 'hotel.focus', 'offers.query', 'offers.view.patch', 'offers.compare', 'offer.select', 'offer.check', 'checkout.prepare', 'order.observe'];
|
|
55
|
+
/** Product-owned least-privilege action matrix. BFF bindings may narrow these lists, never expand them. */
|
|
56
|
+
export const BOOKING_SURFACE_ALLOWED_ACTIONS = {
|
|
57
|
+
tenant: BOOKING_FULL_JOURNEY_ACTION_KINDS,
|
|
58
|
+
customer_portal: BOOKING_FULL_JOURNEY_ACTION_KINDS,
|
|
59
|
+
storefront: ['search.patch', 'search.run', 'results.view.patch', 'hotel.focus'],
|
|
60
|
+
payment_link: ['search.patch', 'search.run', 'results.view.patch', 'hotel.focus', 'hotel.select'],
|
|
61
|
+
};
|
|
62
|
+
/** Stable product-matrix observation for UAT and server readiness proofs. */
|
|
63
|
+
export function bookingSurfaceAllowedActions(surface) {
|
|
64
|
+
return [...BOOKING_SURFACE_ALLOWED_ACTIONS[surface]];
|
|
65
|
+
}
|
|
66
|
+
/** BFF-facing allowlist after optional, fleet-safe feature negotiation. */
|
|
67
|
+
export function bookingSurfaceNegotiatedActions(surface, advertisements) {
|
|
68
|
+
return bookingSurfaceActionsForFeatures(surface, bookingSurfaceFleetFeatures(advertisements));
|
|
69
|
+
}
|
|
70
|
+
/** Applies an already-computed fleet intersection supplied by the trusted BFF. */
|
|
71
|
+
export function bookingSurfaceActionsForFeatures(surface, features) {
|
|
72
|
+
return bookingSurfaceAllowedActions(surface).filter((action) => action !== 'order.observe' || features.includes('trusted-order-observation-v1'));
|
|
73
|
+
}
|
|
74
|
+
export const BOOKING_BLOCKER_CODES = ['no_hotels_matched', 'hotel_not_visible', 'hotel_rates_failed', 'criterion_must_not_met', 'offer_target_not_reached', 'offer_unavailable'];
|
|
75
|
+
export const BOOKING_GAP_CODES = ['byos_mapped_risk', 'check_avail_failed', 'check_avail_unverified', 'component_executor_unavailable', 'hotel_not_visible', 'hotel_rates_failed', 'offer_facts_changed', 'offer_not_loaded', 'offer_unavailable', 'order_not_found', 'order_outcome_not_observed', 'order_state_unknown', 'order_status_unavailable', 'requested_offers_not_loaded', 'search_failed', 'search_form_invalid', 'search_session_expired', 'search_terminal_timeout', 'stale_revision', 'surface_adapter_failed', 'undo_token_not_found', 'unhandled', 'unsupported', 'verified_offer_required', 'workspace_changed_during_action', 'criterion_must_not_met', 'no_hotels_matched', 'offer_target_not_reached'];
|