@danceiny/gotry 0.0.1-rc.21 → 0.0.1-rc.24
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 +102 -194
- package/README.zh-CN.md +115 -210
- package/bin/gotry-backend.js +53 -0
- package/bin/gotry-bootstrap.js +466 -35
- package/bin/gotry-inner.js +255 -36
- package/bin/gotry-process-liveness.d.ts +27 -0
- package/bin/gotry-process-liveness.js +97 -0
- package/bin/gotry-runtime-resolution.d.ts +1 -1
- package/bin/gotry-runtime-resolution.js +2 -2
- package/client/client.js +174 -0
- package/cordis.gotry-patch.yml +70 -93
- package/dist/capabilities/agent-reach-deep.js +45 -122
- package/dist/capabilities/agent-reach.js +63 -148
- package/dist/capabilities/anything.js +89 -75
- package/dist/capabilities/artifacts.js +123 -104
- package/dist/capabilities/channel-health.js +65 -45
- package/dist/capabilities/channel-registry.js +108 -87
- package/dist/capabilities/doctor.js +357 -235
- package/dist/capabilities/effect.js +223 -309
- package/dist/capabilities/fact-log.js +28 -14
- package/dist/capabilities/flyai.js +245 -156
- package/dist/capabilities/ground-transfer.js +509 -0
- package/dist/capabilities/hbcli.js +144 -148
- package/dist/capabilities/hotelbyte-transaction.js +194 -0
- package/dist/capabilities/incident-log.js +131 -61
- package/dist/capabilities/model-override.js +30 -10
- package/dist/capabilities/opensky.js +54 -43
- package/dist/capabilities/resilience.js +50 -32
- package/dist/capabilities/session/action-cache.js +50 -44
- package/dist/capabilities/session/adapters/ctrip-flight.js +119 -62
- package/dist/capabilities/session/adapters/ctrip-hotel.js +125 -110
- package/dist/capabilities/session/adapters/dida-portal.js +206 -0
- package/dist/capabilities/session/adapters/meituan-local.js +35 -54
- package/dist/capabilities/session/adapters/rail-12306.js +169 -112
- package/dist/capabilities/session/benchmark.js +85 -149
- package/dist/capabilities/session/extension-bridge.js +320 -259
- package/dist/capabilities/session/extension-channel.js +57 -76
- package/dist/capabilities/session/extension-distribution.js +115 -119
- package/dist/capabilities/session/extract.js +31 -21
- package/dist/capabilities/session/golden-score.js +55 -33
- package/dist/capabilities/session/health-watch.js +146 -154
- package/dist/capabilities/session/read-guard.js +55 -47
- package/dist/capabilities/session/static-flight-golden.js +49 -36
- package/dist/capabilities/session/transport.js +54 -61
- package/dist/capabilities/session/wizard.js +63 -93
- package/dist/capabilities/session-consent.js +143 -47
- package/dist/capabilities/session-login.js +95 -126
- package/dist/capabilities/session-search.js +391 -253
- package/dist/capabilities/sponsor-plugin.js +341 -0
- package/dist/capabilities/visa-policy.js +87 -73
- package/dist/capabilities/weather.js +163 -235
- package/dist/scripts/action-cache-tests.js +24 -59
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +91 -142
- package/dist/scripts/agent-planning-turn-deadline-tests.js +80 -176
- package/dist/scripts/agent-reach-deep-tests.js +30 -40
- package/dist/scripts/agent-reach-tests.js +26 -18
- package/dist/scripts/agent-reach-wrapper-tests.js +46 -50
- package/dist/scripts/anything-tests.js +58 -62
- package/dist/scripts/artifact-client-contract-tests.js +69 -0
- package/dist/scripts/artifacts-capability-tests.js +235 -0
- package/dist/scripts/async-collect.js +26 -15
- package/dist/scripts/benchmark-environment-bridge-e2e.js +287 -684
- package/dist/scripts/benchmark-environment-bridge-tests.js +818 -3123
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +66 -279
- package/dist/scripts/booking-copilot-availability-policy-tests.js +153 -1257
- package/dist/scripts/booking-copilot-bin-proof-tests.js +22 -45
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +64 -76
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +69 -199
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +393 -759
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +33 -75
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +60 -110
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +28 -66
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +72 -271
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +73 -275
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +784 -3398
- package/dist/scripts/booking-copilot-server-proof-tests.js +63 -168
- package/dist/scripts/booking-copilot-startup-proof-tests.js +38 -124
- 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 +61 -123
- package/dist/scripts/booking-surface-contract-proof-tests.js +152 -1167
- package/dist/scripts/bootstrap-tests.js +1383 -128
- package/dist/scripts/build-changelog.js +89 -130
- package/dist/scripts/build-metrics-report.js +135 -143
- package/dist/scripts/changelog-tests.js +35 -82
- package/dist/scripts/channel-probe-tests.js +44 -116
- package/dist/scripts/channel-probe.js +84 -167
- package/dist/scripts/channel-registry-tests.js +97 -185
- package/dist/scripts/companion-tests.js +25 -70
- package/dist/scripts/dida-cookie-probe.js +87 -0
- package/dist/scripts/dida-sw-probe.js +114 -0
- package/dist/scripts/diff-test.js +17 -12
- package/dist/scripts/doctor-tests.js +428 -120
- package/dist/scripts/dsh-artifact-e2e.js +150 -0
- package/dist/scripts/dsh-artifact-web-e2e.js +443 -0
- package/dist/scripts/dsh-http-proxy-sse-proof.js +90 -0
- package/dist/scripts/dsh-runtime-closure-tests.js +110 -153
- package/dist/scripts/dsh-runtime-closure.js +75 -63
- package/dist/scripts/dsh-session-v3-migration-proof.js +106 -0
- package/dist/scripts/dsh-subprocess-local-proof.js +149 -0
- package/dist/scripts/dsh-target-closure-proof.js +178 -0
- package/dist/scripts/effect-tests.js +165 -552
- package/dist/scripts/engine-run.js +1 -3
- package/dist/scripts/engine-tests.js +16 -10
- package/dist/scripts/evaluation-cadence-tests.js +69 -242
- package/dist/scripts/evaluation-contract-tests.js +193 -499
- package/dist/scripts/extension-distribution-cli.js +19 -15
- package/dist/scripts/extension-distribution-tests.js +98 -211
- package/dist/scripts/extension-tests.js +366 -389
- package/dist/scripts/fact-gate-tests.js +725 -263
- 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-tests.js +325 -68
- 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/gotry-backend-kernel-tests.js +79 -0
- package/dist/scripts/ground-transfer-tests.js +956 -0
- package/dist/scripts/hbcli-e2e-tests.js +71 -90
- 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 +41 -115
- package/dist/scripts/health-watch-cli.js +42 -28
- 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 +16 -9
- 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 +547 -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/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/ledger-repair-apply-tests.js +316 -0
- package/dist/scripts/ledger-repair-plan-tests.js +375 -0
- package/dist/scripts/ledger-tests.js +325 -340
- package/dist/scripts/ledger-workflow-crash.js +10 -20
- package/dist/scripts/map-tools-vendor-package-proof.js +206 -134
- 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 +474 -222
- package/dist/scripts/memory-value-tests.js +328 -0
- package/dist/scripts/metrics-report-tests.js +62 -199
- package/dist/scripts/model-override-e2e.js +66 -105
- package/dist/scripts/nightly-evidence-tests.js +64 -89
- package/dist/scripts/nightly-evidence.js +108 -111
- package/dist/scripts/nudge-digest.js +39 -28
- package/dist/scripts/onboarding-tests.js +63 -88
- package/dist/scripts/opensky-check.js +18 -13
- package/dist/scripts/opensky-tests.js +28 -28
- package/dist/scripts/persona-surface-guard-tests.js +37 -12
- package/dist/scripts/pnpm-dsh-closure-proof.js +2 -5
- package/dist/scripts/policy-anchor-359-registered-e2e.js +214 -0
- package/dist/scripts/price-drift-tests.js +126 -227
- package/dist/scripts/price-drift-watch.js +209 -253
- package/dist/scripts/probe-poi-tests.js +52 -45
- package/dist/scripts/product-metrics.js +187 -273
- package/dist/scripts/publish-preverify.js +47 -41
- package/dist/scripts/realtime-pricing-tests.js +37 -76
- package/dist/scripts/replay-async.js +20 -18
- package/dist/scripts/replay-real.js +16 -18
- package/dist/scripts/replay.js +52 -82
- package/dist/scripts/session-attach-diagnose.js +16 -12
- package/dist/scripts/session-attach-poc.js +34 -37
- package/dist/scripts/session-benchmark.js +66 -147
- package/dist/scripts/session-dida-live-e2e.js +151 -0
- package/dist/scripts/session-extract-tests.js +14 -35
- package/dist/scripts/session-login.js +14 -13
- package/dist/scripts/session-tests.js +545 -583
- package/dist/scripts/sf-live-benchmark.js +92 -110
- package/dist/scripts/sf-live-cli-tests.js +2 -9
- package/dist/scripts/sf-soft-score-tests.js +19 -60
- package/dist/scripts/sf-summary-tests.js +149 -0
- package/dist/scripts/sf-summary.js +466 -84
- package/dist/scripts/skeleton-check.js +16 -14
- package/dist/scripts/skeleton-integration-test.js +11 -10
- package/dist/scripts/skills-contract-tests.js +51 -46
- package/dist/scripts/smoke-session-gate-tests.js +12 -20
- package/dist/scripts/smoke.js +541 -422
- package/dist/scripts/sponsor-reuse-tests.js +262 -0
- package/dist/scripts/state-cli-tests.js +226 -101
- package/dist/scripts/state-cli.js +549 -212
- package/dist/scripts/static-golden-tests.js +46 -180
- 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 +46 -93
- package/dist/scripts/turn-handoff-collect.js +71 -99
- package/dist/scripts/turn-policy-tests.js +28 -29
- package/dist/scripts/typed-contract-canary.js +77 -162
- 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 +31 -44
- package/dist/scripts/weather-tests.js +121 -543
- package/dist/scripts/wish-channel-gate-tests.js +29 -86
- 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 +18 -12
- package/dist/src/artifact-gate.js +652 -221
- package/dist/src/backend/kernel.js +91 -0
- package/dist/src/backend/modules/booking-copilot.js +55 -0
- package/dist/src/backend/modules/booking-executor.js +124 -0
- package/dist/src/backend/modules/session-search.js +194 -0
- package/dist/src/benchmark-agent-conformance.js +296 -262
- package/dist/src/benchmark-environment-bridge.js +298 -413
- package/dist/src/benchmark-headless-child-diagnostics.js +93 -100
- package/dist/src/benchmark-tool-isolation.js +94 -67
- package/dist/src/bookable-facts.js +299 -174
- package/dist/src/booking-saga.js +64 -120
- package/dist/src/booking-surface/availability-policy.js +443 -576
- package/dist/src/booking-surface/cancel-refund-commission.js +379 -0
- package/dist/src/booking-surface/contracts.js +24 -80
- package/dist/src/booking-surface/dsh-planner.js +510 -281
- package/dist/src/booking-surface/dsh-plugin.js +17 -1
- package/dist/src/booking-surface/error-codes.js +82 -10
- package/dist/src/booking-surface/index.js +0 -3
- package/dist/src/booking-surface/profile.js +10 -54
- package/dist/src/booking-surface/recovery-chain.js +367 -0
- package/dist/src/booking-surface/runtime.js +765 -891
- package/dist/src/booking-surface/server.js +200 -251
- package/dist/src/booking-surface/startup.js +58 -54
- package/dist/src/booking-surface/validation.js +150 -218
- 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 +82 -120
- package/dist/src/engine.js +253 -239
- package/dist/src/evaluation-cadence.js +72 -209
- package/dist/src/evaluation-contracts.js +220 -843
- package/dist/src/flight-pack-adapter.js +54 -0
- package/dist/src/flight-pack-contract.js +2 -0
- package/dist/src/gotry-backend.js +70 -0
- package/dist/src/hotel-date-gate.js +118 -0
- package/dist/src/i18n.js +18 -7
- package/dist/src/index.js +1425 -1629
- package/dist/src/journey.js +132 -81
- package/dist/src/ledger-repair-apply.js +538 -0
- package/dist/src/ledger-repair-plan.js +463 -0
- package/dist/src/loop.js +257 -166
- 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 +63 -72
- package/dist/src/slot-spec.js +84 -106
- package/dist/src/state-ledger.js +310 -471
- 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 +121 -127
- package/dist/src/turn-policy.js +61 -89
- package/dist/src/tz-resolver.js +143 -0
- package/dist/src/unified.js +504 -381
- package/dist/src/wish-pool.js +39 -14
- package/dist/src/write-gate.js +495 -0
- package/dist/src/z3-shared.js +273 -7
- package/extension/README.md +4 -3
- package/extension/background.js +125 -14
- package/extension/content-bridge.js +23 -1
- package/extension/content-main.js +15 -4
- package/extension/manifest.json +16 -8
- package/package.json +251 -220
- package/ts/capabilities/agent-reach.ts +4 -4
- package/ts/capabilities/anything.ts +1 -1
- package/ts/capabilities/artifacts.ts +46 -9
- package/ts/capabilities/flyai.ts +156 -37
- package/ts/capabilities/hbcli.ts +1 -1
- package/ts/capabilities/incident-log.ts +88 -59
- package/ts/capabilities/session/adapters/ctrip-flight.ts +99 -36
- package/ts/capabilities/session/adapters/dida-portal.ts +250 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +123 -24
- package/ts/capabilities/session/extension-bridge.ts +226 -101
- package/ts/capabilities/session/extension-channel.ts +22 -9
- package/ts/capabilities/session/wizard.ts +2 -2
- package/ts/capabilities/session-consent.ts +98 -14
- package/ts/capabilities/session-login.ts +1 -0
- package/ts/capabilities/session-search.ts +315 -31
- package/ts/dsh-runtime/vendor/README.md +8 -4
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +7 -1
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +5 -3
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +1 -1
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +1 -1
- package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +6 -6
- package/ts/package.json +236 -16
- package/ts/scripts/map-tools-vendor-package-proof.ts +152 -31
- package/ts/scripts/state-cli.ts +418 -51
- package/ts/src/artifact-gate.ts +561 -15
- package/ts/src/benchmark-environment-bridge.ts +37 -20
- package/ts/src/bookable-facts.ts +183 -7
- package/ts/src/booking-surface/cancel-refund-commission.ts +488 -0
- package/ts/src/booking-surface/dsh-planner.ts +240 -32
- package/ts/src/booking-surface/dsh-plugin.js +17 -1
- package/ts/src/booking-surface/error-codes.ts +75 -0
- package/ts/src/booking-surface/recovery-chain.ts +409 -0
- package/ts/src/booking-surface/server.ts +84 -51
- package/ts/src/booking-surface/validation.ts +2 -0
- package/ts/src/contracts.ts +12 -2
- package/ts/src/dsh-llm.ts +4 -8
- package/ts/src/index.ts +609 -90
- package/ts/src/loop.ts +116 -7
- package/ts/src/memory-capture.ts +227 -3
- package/ts/src/mock-llm.ts +4 -8
- package/ts/src/model.ts +88 -2
- package/ts/src/state-ledger.ts +47 -29
- package/ts/src/subagent-job-id-guard.ts +72 -0
- package/ts/src/time-anchor.ts +217 -13
- package/ts/src/unified.ts +316 -54
|
@@ -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
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
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
|
+
*/
|
|
1
7
|
export const BOOKING_SURFACE_SCHEMA_VERSION = 'booking.surface';
|
|
8
|
+
/** SHA-256 of schemas/booking.surface.schema.json; package proof pins drift. */
|
|
2
9
|
export const BOOKING_SURFACE_SCHEMA_SHA256 = 'f9a73339c4c51280bfd63ba67c8b9f495fbbb796573b7a24d35de572f17f5127';
|
|
3
10
|
export const BOOKING_SURFACE_VERSION_HEADER = 'x-booking-surface-version';
|
|
4
11
|
export const BOOKING_SURFACE_SCHEMA_SHA256_HEADER = 'x-booking-surface-schema-sha256';
|
|
@@ -6,92 +13,29 @@ export const BOOKING_SURFACES = [
|
|
|
6
13
|
'tenant',
|
|
7
14
|
'customer_portal',
|
|
8
15
|
'storefront',
|
|
9
|
-
'payment_link'
|
|
10
|
-
];
|
|
11
|
-
export const BOOKING_COPILOT_INGRESS_MODES = [
|
|
12
|
-
'bff-bound-turn-only',
|
|
13
|
-
'bff-ingress-binding'
|
|
14
|
-
];
|
|
15
|
-
export const BOOKING_COPILOT_ACCEPTED_TURN_KINDS = [
|
|
16
|
-
'user.turn',
|
|
17
|
-
'action.receipt.continuation'
|
|
16
|
+
'payment_link',
|
|
18
17
|
];
|
|
18
|
+
/**
|
|
19
|
+
* Process composition modes are deliberately separate from the payload
|
|
20
|
+
* schema. The default accepts turns already bound by HotelByte's BFF; the
|
|
21
|
+
* second mode is reserved for an in-process BFF binding seam.
|
|
22
|
+
*/
|
|
23
|
+
export const BOOKING_COPILOT_INGRESS_MODES = ['bff-bound-turn-only', 'bff-ingress-binding'];
|
|
24
|
+
export const BOOKING_COPILOT_ACCEPTED_TURN_KINDS = ['user.turn', 'action.receipt.continuation'];
|
|
19
25
|
export const BOOKING_COPILOT_INGRESS_TURN_KIND = 'user.turn.ingress';
|
|
26
|
+
/** Hard task-level operation budget. The counter is persisted in the ledger. */
|
|
20
27
|
export const BOOKING_COPILOT_MAX_OPERATIONS = 20;
|
|
21
|
-
export const BOOKING_READ_ACTION_KINDS = [
|
|
22
|
-
|
|
23
|
-
'search.run',
|
|
24
|
-
'results.view.patch',
|
|
25
|
-
'hotel.focus',
|
|
26
|
-
'hotel.select',
|
|
27
|
-
'offers.query',
|
|
28
|
-
'offers.view.patch',
|
|
29
|
-
'offers.compare',
|
|
30
|
-
'offer.select',
|
|
31
|
-
'offer.check',
|
|
32
|
-
'checkout.prepare',
|
|
33
|
-
'order.observe'
|
|
34
|
-
];
|
|
28
|
+
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'];
|
|
29
|
+
/** Product-owned least-privilege action matrix. BFF bindings may narrow these lists, never expand them. */
|
|
35
30
|
export const BOOKING_SURFACE_ALLOWED_ACTIONS = {
|
|
36
31
|
tenant: BOOKING_READ_ACTION_KINDS,
|
|
37
32
|
customer_portal: BOOKING_READ_ACTION_KINDS,
|
|
38
|
-
storefront: [
|
|
39
|
-
|
|
40
|
-
'search.run',
|
|
41
|
-
'results.view.patch',
|
|
42
|
-
'hotel.focus'
|
|
43
|
-
],
|
|
44
|
-
payment_link: [
|
|
45
|
-
'search.patch',
|
|
46
|
-
'search.run',
|
|
47
|
-
'results.view.patch',
|
|
48
|
-
'hotel.focus',
|
|
49
|
-
'hotel.select'
|
|
50
|
-
]
|
|
33
|
+
storefront: ['search.patch', 'search.run', 'results.view.patch', 'hotel.focus'],
|
|
34
|
+
payment_link: ['search.patch', 'search.run', 'results.view.patch', 'hotel.focus', 'hotel.select'],
|
|
51
35
|
};
|
|
36
|
+
/** Stable product-matrix observation for UAT and server readiness proofs. */
|
|
52
37
|
export function bookingSurfaceAllowedActions(surface) {
|
|
53
|
-
return [
|
|
54
|
-
...BOOKING_SURFACE_ALLOWED_ACTIONS[surface]
|
|
55
|
-
];
|
|
38
|
+
return [...BOOKING_SURFACE_ALLOWED_ACTIONS[surface]];
|
|
56
39
|
}
|
|
57
|
-
export const BOOKING_BLOCKER_CODES = [
|
|
58
|
-
|
|
59
|
-
'hotel_not_visible',
|
|
60
|
-
'hotel_rates_failed',
|
|
61
|
-
'criterion_must_not_met',
|
|
62
|
-
'offer_target_not_reached',
|
|
63
|
-
'offer_unavailable'
|
|
64
|
-
];
|
|
65
|
-
export const BOOKING_GAP_CODES = [
|
|
66
|
-
'byos_mapped_risk',
|
|
67
|
-
'check_avail_failed',
|
|
68
|
-
'check_avail_unverified',
|
|
69
|
-
'component_executor_unavailable',
|
|
70
|
-
'hotel_not_visible',
|
|
71
|
-
'hotel_rates_failed',
|
|
72
|
-
'offer_facts_changed',
|
|
73
|
-
'offer_not_loaded',
|
|
74
|
-
'offer_unavailable',
|
|
75
|
-
'order_not_found',
|
|
76
|
-
'order_outcome_not_observed',
|
|
77
|
-
'order_state_unknown',
|
|
78
|
-
'order_status_unavailable',
|
|
79
|
-
'requested_offers_not_loaded',
|
|
80
|
-
'search_failed',
|
|
81
|
-
'search_form_invalid',
|
|
82
|
-
'search_session_expired',
|
|
83
|
-
'search_terminal_timeout',
|
|
84
|
-
'stale_revision',
|
|
85
|
-
'surface_adapter_failed',
|
|
86
|
-
'undo_token_not_found',
|
|
87
|
-
'unhandled',
|
|
88
|
-
'unsupported',
|
|
89
|
-
'verified_offer_required',
|
|
90
|
-
'workspace_changed_during_action',
|
|
91
|
-
'criterion_must_not_met',
|
|
92
|
-
'no_hotels_matched',
|
|
93
|
-
'offer_target_not_reached'
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//# sourceURL=ts/src/booking-surface/contracts.ts
|
|
40
|
+
export const BOOKING_BLOCKER_CODES = ['no_hotels_matched', 'hotel_not_visible', 'hotel_rates_failed', 'criterion_must_not_met', 'offer_target_not_reached', 'offer_unavailable'];
|
|
41
|
+
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'];
|