@danceiny/gotry 0.0.1-rc.9 → 0.2.0-rc.28
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 +1788 -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 +161 -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 +553 -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 +676 -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/provider-detail-sanitize.js +64 -0
- package/dist/capabilities/resilience.js +191 -0
- package/dist/capabilities/route-provider-conformance.js +341 -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-path-measure-tests.js +133 -0
- package/dist/scripts/anything-path-measure.js +150 -0
- package/dist/scripts/anything-tests.js +250 -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 +126 -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 +1549 -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/city-scenario-tier-tests.js +234 -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 +600 -0
- package/dist/scripts/drill-multiuser-ledger-tests.js +1076 -0
- package/dist/scripts/drill-sdk-descendant-cleanup-tests.js +606 -0
- package/dist/scripts/drill-w2a-sensor-tests.js +788 -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-llm-tests.js +437 -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 +150 -0
- package/dist/scripts/g5-guard.js +193 -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/m3-cohort-tests.js +714 -0
- package/dist/scripts/m3-cohort.js +310 -0
- 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 +203 -0
- package/dist/scripts/nightly-evidence.js +303 -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/outcome-projection-tests.js +427 -0
- package/dist/scripts/persona-sim-tests.js +603 -0
- package/dist/scripts/persona-sim.js +1081 -0
- 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 +22 -18
- package/dist/scripts/replay-real.js +18 -18
- package/dist/scripts/replay.js +54 -82
- package/dist/scripts/route-provider-conformance-tests.js +391 -0
- 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-zone-crash.js +49 -0
- package/dist/scripts/session-zone-ledger-tests.js +432 -0
- package/dist/scripts/session-zone-observation-tests.js +492 -0
- package/dist/scripts/session-zone-observe.js +135 -0
- package/dist/scripts/session-zone-wiring-tests.js +566 -0
- package/dist/scripts/session-zones-tests.js +374 -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 +244 -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 +565 -198
- 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 +212 -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 +60 -20
- 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 +46 -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/city-scenario-tier.js +378 -0
- package/dist/src/companions.js +48 -74
- package/dist/src/contracts.js +21 -43
- package/dist/src/dsh-llm.js +171 -115
- 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 +2385 -881
- 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 +331 -161
- package/dist/src/m3-cohort.js +1577 -0
- 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/outcome-projection.js +746 -0
- 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-zone-ledger.js +312 -0
- package/dist/src/session-zone-observation.js +354 -0
- package/dist/src/session-zone-wiring.js +658 -0
- package/dist/src/session-zones.js +510 -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 +696 -524
- 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 +600 -360
- 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 +282 -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 +586 -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 +17 -3
- package/ts/src/dsh-llm.ts +152 -17
- package/ts/src/flyai-setup-tool.ts +77 -0
- package/ts/src/index.ts +2123 -200
- 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 +234 -26
- 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 +1166 -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 +444 -105
- package/ts/src/wish-pool.ts +79 -0
- package/dist/scripts/session-attach-wait.js +0 -41
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rebuild the offline sf-01..08 evidence summary from one coherent batch.
|
|
3
|
+
*
|
|
4
|
+
* The default root is retained for humans, while tests and proofs must pass
|
|
5
|
+
* --evidence-root explicitly so no shared founder state is read or written.
|
|
6
|
+
*/
|
|
7
|
+
import { mkdirSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { dirname, join, resolve } from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { SESSION_FIELD_ACCURACY_THRESHOLD } from '../capabilities/session/benchmark.js';
|
|
12
|
+
export const EXPECTED_QUERY_IDS = Array.from({ length: 8 }, (_, index) => `sf-${(index + 1).toString().padStart(2, '0')}`);
|
|
13
|
+
function isObject(value) {
|
|
14
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function stringValue(value) {
|
|
17
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
18
|
+
}
|
|
19
|
+
function nestedString(value, ...keys) {
|
|
20
|
+
let current = value;
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
if (!isObject(current))
|
|
23
|
+
return null;
|
|
24
|
+
current = current[key];
|
|
25
|
+
}
|
|
26
|
+
return stringValue(current);
|
|
27
|
+
}
|
|
28
|
+
function firstString(record, paths) {
|
|
29
|
+
for (const path of paths) {
|
|
30
|
+
const value = path.length === 1 ? record[path[0]] : nestedString(record, ...path);
|
|
31
|
+
const result = stringValue(value);
|
|
32
|
+
if (result !== null)
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function parseTime(value) {
|
|
38
|
+
if (value === null)
|
|
39
|
+
return Number.NEGATIVE_INFINITY;
|
|
40
|
+
const parsed = Date.parse(value);
|
|
41
|
+
return Number.isFinite(parsed) ? parsed : Number.NEGATIVE_INFINITY;
|
|
42
|
+
}
|
|
43
|
+
function canonicalFilename(file) {
|
|
44
|
+
// sf-live-benchmark uses runStartedAt.replace(/[:.]/g, '-') for every
|
|
45
|
+
// evidence filename. Only that exact ISO-with-safe-time-punctuation form
|
|
46
|
+
// is a legacy batch identity; arbitrary filenames remain unknown.
|
|
47
|
+
const match = /^(\d{4}-\d{2}-\d{2}T\d{2})-(\d{2})-(\d{2})-(\d{3})Z\.json$/.exec(file);
|
|
48
|
+
if (match === null)
|
|
49
|
+
return null;
|
|
50
|
+
const captureAt = `${match[1]}:${match[2]}:${match[3]}.${match[4]}Z`;
|
|
51
|
+
const chronologyMs = parseTime(captureAt);
|
|
52
|
+
if (!Number.isFinite(chronologyMs))
|
|
53
|
+
return null;
|
|
54
|
+
return { stem: file.slice(0, -'.json'.length), captureAt, chronologyMs };
|
|
55
|
+
}
|
|
56
|
+
function captureAt(record) {
|
|
57
|
+
return firstString(record, [
|
|
58
|
+
['evidence_captured_at'],
|
|
59
|
+
['captured_at'],
|
|
60
|
+
['capture_time'],
|
|
61
|
+
['evidence_capture_time'],
|
|
62
|
+
['official_captured_at'],
|
|
63
|
+
['evidence', 'captured_at'],
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
function startedAt(record) {
|
|
67
|
+
return firstString(record, [
|
|
68
|
+
['started_at'],
|
|
69
|
+
['evidence', 'started_at'],
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
function sessionFetchedAt(record) {
|
|
73
|
+
return nestedString(record.session, 'fetched_at');
|
|
74
|
+
}
|
|
75
|
+
function explicitBatch(record) {
|
|
76
|
+
const values = [
|
|
77
|
+
stringValue(record.batch_id),
|
|
78
|
+
stringValue(record.batchId),
|
|
79
|
+
stringValue(record.run_id),
|
|
80
|
+
stringValue(record.runId),
|
|
81
|
+
nestedString(record.batch, 'id'),
|
|
82
|
+
nestedString(record.batch, 'batch_id'),
|
|
83
|
+
].filter((value) => value !== null);
|
|
84
|
+
const unique = Array.from(new Set(values));
|
|
85
|
+
const capture = firstString(record, [
|
|
86
|
+
['batch_captured_at'],
|
|
87
|
+
['batch_capture_at'],
|
|
88
|
+
['batch_started_at'],
|
|
89
|
+
['run_started_at'],
|
|
90
|
+
['batch', 'captured_at'],
|
|
91
|
+
['batch', 'started_at'],
|
|
92
|
+
]);
|
|
93
|
+
const validCapture = capture !== null && Number.isFinite(parseTime(capture)) ? capture : null;
|
|
94
|
+
return {
|
|
95
|
+
id: unique[0] ?? null,
|
|
96
|
+
captureAt: validCapture,
|
|
97
|
+
conflict: unique.length > 1 ? `conflicting explicit batch IDs: ${unique.join(', ')}` : null,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function recordChronology(record, captured, started) {
|
|
101
|
+
return Math.max(parseTime(captured), parseTime(started), parseTime(sessionFetchedAt(record)));
|
|
102
|
+
}
|
|
103
|
+
function relativePath(root, path) {
|
|
104
|
+
return path.startsWith(`${root}/`) ? path.slice(root.length + 1) : path;
|
|
105
|
+
}
|
|
106
|
+
function inventoryFiles(evidenceRoot) {
|
|
107
|
+
const files = [];
|
|
108
|
+
const invalidRecords = [];
|
|
109
|
+
const canonicalGroups = new Map();
|
|
110
|
+
for (const queryId of EXPECTED_QUERY_IDS) {
|
|
111
|
+
const queryDir = join(evidenceRoot, queryId);
|
|
112
|
+
let names;
|
|
113
|
+
try {
|
|
114
|
+
if (!statSync(queryDir).isDirectory()) {
|
|
115
|
+
invalidRecords.push({ query_id: queryId, file: queryId, reason: 'query path is not a directory' });
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
names = readdirSync(queryDir).filter((name) => name.endsWith('.json')).sort();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error.code === 'ENOENT')
|
|
122
|
+
continue;
|
|
123
|
+
invalidRecords.push({ query_id: queryId, file: queryId, reason: error instanceof Error ? error.message : String(error) });
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
for (const name of names) {
|
|
127
|
+
const entry = {
|
|
128
|
+
queryId,
|
|
129
|
+
file: relativePath(evidenceRoot, join(queryDir, name)),
|
|
130
|
+
absolutePath: join(queryDir, name),
|
|
131
|
+
canonical: canonicalFilename(name),
|
|
132
|
+
};
|
|
133
|
+
files.push(entry);
|
|
134
|
+
if (entry.canonical !== null) {
|
|
135
|
+
const group = canonicalGroups.get(entry.canonical.stem) ?? [];
|
|
136
|
+
group.push(entry);
|
|
137
|
+
canonicalGroups.set(entry.canonical.stem, group);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const candidates = Array.from(canonicalGroups.entries()).map(([stem, group]) => {
|
|
142
|
+
const canonical = group.find((entry) => entry.canonical !== null)?.canonical ?? null;
|
|
143
|
+
return {
|
|
144
|
+
id: stem,
|
|
145
|
+
identitySource: 'canonical_filename',
|
|
146
|
+
captureAt: canonical?.captureAt ?? null,
|
|
147
|
+
chronologyMs: canonical?.chronologyMs ?? Number.NEGATIVE_INFINITY,
|
|
148
|
+
files: group,
|
|
149
|
+
records: [],
|
|
150
|
+
conflictReason: null,
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
return { files, candidates, invalidRecords };
|
|
154
|
+
}
|
|
155
|
+
function readRecords(inventory) {
|
|
156
|
+
const records = [];
|
|
157
|
+
const malformedRecords = [];
|
|
158
|
+
const invalidRecords = [];
|
|
159
|
+
const unknownBatchRecords = [];
|
|
160
|
+
for (const file of inventory) {
|
|
161
|
+
let parsed;
|
|
162
|
+
try {
|
|
163
|
+
parsed = JSON.parse(readFileSync(file.absolutePath, 'utf8'));
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
malformedRecords.push({ query_id: file.queryId, file: file.file, reason: error instanceof Error ? error.message : String(error) });
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (!isObject(parsed)) {
|
|
170
|
+
invalidRecords.push({ query_id: file.queryId, file: file.file, reason: 'record must be a JSON object' });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (parsed.query_id !== file.queryId) {
|
|
174
|
+
invalidRecords.push({ query_id: file.queryId, file: file.file, reason: `query_id must be ${file.queryId}` });
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const explicit = explicitBatch(parsed);
|
|
178
|
+
if (explicit.conflict !== null) {
|
|
179
|
+
invalidRecords.push({ query_id: file.queryId, file: file.file, reason: explicit.conflict });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const captured = captureAt(parsed);
|
|
183
|
+
const started = startedAt(parsed);
|
|
184
|
+
const loaded = {
|
|
185
|
+
...file,
|
|
186
|
+
record: parsed,
|
|
187
|
+
explicitBatchId: explicit.id,
|
|
188
|
+
explicitBatchCaptureAt: explicit.captureAt,
|
|
189
|
+
captureAt: captured,
|
|
190
|
+
startedAt: started,
|
|
191
|
+
chronologyMs: recordChronology(parsed, captured, started),
|
|
192
|
+
};
|
|
193
|
+
records.push(loaded);
|
|
194
|
+
if (file.canonical === null && (explicit.id === null || explicit.captureAt === null)) {
|
|
195
|
+
unknownBatchRecords.push({
|
|
196
|
+
query_id: file.queryId,
|
|
197
|
+
file: file.file,
|
|
198
|
+
reason: explicit.id === null ? 'missing defensible batch identity' : 'explicit batch ID lacks a valid batch capture timestamp',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return { records, malformedRecords, invalidRecords, unknownBatchRecords };
|
|
203
|
+
}
|
|
204
|
+
function completeCandidates(initial, records) {
|
|
205
|
+
const candidates = initial.map((candidate) => {
|
|
206
|
+
const members = records.filter((record) => record.canonical?.stem === candidate.id);
|
|
207
|
+
const explicitIds = Array.from(new Set(members.map((record) => record.explicitBatchId).filter((value) => value !== null)));
|
|
208
|
+
const conflictReason = explicitIds.length > 1 ? `conflicting explicit batch IDs in filename batch: ${explicitIds.join(', ')}` : null;
|
|
209
|
+
const explicitCaptureTimes = Array.from(new Set(members.map((record) => record.explicitBatchCaptureAt).filter((value) => value !== null)));
|
|
210
|
+
const captureAt = candidate.captureAt;
|
|
211
|
+
return {
|
|
212
|
+
...candidate,
|
|
213
|
+
id: conflictReason === null && explicitIds.length === 1 ? explicitIds[0] : candidate.id,
|
|
214
|
+
identitySource: conflictReason === null && explicitIds.length === 1 ? 'explicit_batch_id+canonical_filename' : candidate.identitySource,
|
|
215
|
+
captureAt,
|
|
216
|
+
records: members,
|
|
217
|
+
conflictReason: conflictReason ?? (explicitCaptureTimes.length > 1 ? `conflicting explicit batch capture times: ${explicitCaptureTimes.join(', ')}` : null),
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
const canonicalStems = new Set(initial.flatMap((candidate) => candidate.files.map((file) => file.canonical?.stem).filter((value) => value !== undefined)));
|
|
221
|
+
const explicitOnly = new Map();
|
|
222
|
+
for (const record of records) {
|
|
223
|
+
if (record.canonical !== null || record.explicitBatchId === null || record.explicitBatchCaptureAt === null)
|
|
224
|
+
continue;
|
|
225
|
+
const group = explicitOnly.get(record.explicitBatchId) ?? [];
|
|
226
|
+
group.push(record);
|
|
227
|
+
explicitOnly.set(record.explicitBatchId, group);
|
|
228
|
+
}
|
|
229
|
+
for (const [id, members] of explicitOnly) {
|
|
230
|
+
if (canonicalStems.has(members[0].canonical?.stem ?? ''))
|
|
231
|
+
continue;
|
|
232
|
+
const captureTimes = Array.from(new Set(members.map((record) => record.explicitBatchCaptureAt).filter((value) => value !== null)));
|
|
233
|
+
const captureAt = captureTimes[0] ?? null;
|
|
234
|
+
candidates.push({
|
|
235
|
+
id,
|
|
236
|
+
identitySource: 'explicit_batch_id',
|
|
237
|
+
captureAt,
|
|
238
|
+
chronologyMs: parseTime(captureAt),
|
|
239
|
+
files: members,
|
|
240
|
+
records: members,
|
|
241
|
+
conflictReason: captureTimes.length > 1 ? `conflicting explicit batch capture times: ${captureTimes.join(', ')}` : null,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return candidates;
|
|
245
|
+
}
|
|
246
|
+
function chooseBatch(candidates) {
|
|
247
|
+
return candidates.slice().sort((left, right) => {
|
|
248
|
+
if (right.chronologyMs !== left.chronologyMs)
|
|
249
|
+
return right.chronologyMs - left.chronologyMs;
|
|
250
|
+
if (right.files.length !== left.files.length)
|
|
251
|
+
return right.files.length - left.files.length;
|
|
252
|
+
return right.id.localeCompare(left.id);
|
|
253
|
+
})[0] ?? null;
|
|
254
|
+
}
|
|
255
|
+
function selectBatchRecords(batch) {
|
|
256
|
+
const selected = new Map();
|
|
257
|
+
for (const record of batch.records) {
|
|
258
|
+
const previous = selected.get(record.queryId);
|
|
259
|
+
if (previous === undefined || record.chronologyMs > previous.chronologyMs || (record.chronologyMs === previous.chronologyMs && record.file > previous.file))
|
|
260
|
+
selected.set(record.queryId, record);
|
|
261
|
+
}
|
|
262
|
+
return selected;
|
|
263
|
+
}
|
|
264
|
+
function numberValue(value) {
|
|
265
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
266
|
+
}
|
|
267
|
+
function sourceFields(record) {
|
|
268
|
+
const requested = stringValue(record.requested_source);
|
|
269
|
+
const effective = stringValue(record.effective_source) ?? stringValue(record.official_source) ?? nestedString(record.official, 'source');
|
|
270
|
+
return {
|
|
271
|
+
official: stringValue(record.official_source) ?? effective,
|
|
272
|
+
requested,
|
|
273
|
+
effective,
|
|
274
|
+
fallback: stringValue(record.fallback_reason),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function sourceBucket(record) {
|
|
278
|
+
const normalizedRequested = record.requested_source?.toLowerCase();
|
|
279
|
+
const normalizedEffective = record.effective_source?.toLowerCase() ?? '';
|
|
280
|
+
if (normalizedRequested === 'static' || normalizedEffective.startsWith('static'))
|
|
281
|
+
return 'static_query_ids';
|
|
282
|
+
if (normalizedEffective === 'manual-golden' || normalizedEffective === 'manual')
|
|
283
|
+
return 'manual_golden_query_ids';
|
|
284
|
+
if (normalizedEffective === 'flyai' || normalizedEffective.startsWith('flyai'))
|
|
285
|
+
return 'flyai_query_ids';
|
|
286
|
+
return 'unknown_query_ids';
|
|
287
|
+
}
|
|
288
|
+
function comparatorScope(requested, effective) {
|
|
289
|
+
const wanted = requested?.toLowerCase() ?? '';
|
|
290
|
+
const actual = effective?.toLowerCase() ?? '';
|
|
291
|
+
if (wanted === 'static' || wanted === 'manual' || actual.startsWith('static') || actual.startsWith('manual'))
|
|
292
|
+
return 'deterministic_only';
|
|
293
|
+
if (wanted === 'flyai' && actual === 'flyai')
|
|
294
|
+
return 'live_provider';
|
|
295
|
+
return 'unknown';
|
|
296
|
+
}
|
|
297
|
+
function toSummaryRecord(item, batchId, batchIdentitySource) {
|
|
298
|
+
const record = item.record;
|
|
299
|
+
const fields = sourceFields(record);
|
|
300
|
+
const session = isObject(record.session) ? record.session : null;
|
|
301
|
+
const soft = isObject(record.softScore) ? record.softScore : null;
|
|
302
|
+
const segments = session && Array.isArray(session.route_segments) ? session.route_segments : [];
|
|
303
|
+
const firstSegment = isObject(segments[0]) ? segments[0] : null;
|
|
304
|
+
const verdict = stringValue(session?.verdict) ?? stringValue(record.sessionVerdict);
|
|
305
|
+
const price = numberValue(session?.price);
|
|
306
|
+
const sessionFlight = verdict === 'hit' && firstSegment !== null
|
|
307
|
+
? {
|
|
308
|
+
flight_no: stringValue(firstSegment.transport_number) ?? '',
|
|
309
|
+
dep: stringValue(firstSegment.departure_at) ?? '',
|
|
310
|
+
arr: stringValue(firstSegment.arrival_at) ?? '',
|
|
311
|
+
price: price ?? 0,
|
|
312
|
+
}
|
|
313
|
+
: null;
|
|
314
|
+
const sessionFetched = sessionFetchedAt(record);
|
|
315
|
+
const softScore = soft === null ? null : {
|
|
316
|
+
accuracy: numberValue(soft.accuracy) ?? 0,
|
|
317
|
+
pass: soft.pass === true,
|
|
318
|
+
missing: Array.isArray(soft.missing) ? soft.missing.filter((value) => typeof value === 'string') : [],
|
|
319
|
+
incorrect: Array.isArray(soft.incorrect) ? soft.incorrect.filter((value) => typeof value === 'string') : [],
|
|
320
|
+
};
|
|
321
|
+
return {
|
|
322
|
+
query_id: item.queryId,
|
|
323
|
+
expected: record.expected ?? null,
|
|
324
|
+
official_source: fields.official,
|
|
325
|
+
requested_source: fields.requested,
|
|
326
|
+
effective_source: fields.effective,
|
|
327
|
+
fallback_reason: fields.fallback,
|
|
328
|
+
comparator_evidence_scope: comparatorScope(fields.requested, fields.effective),
|
|
329
|
+
batch_id: batchId,
|
|
330
|
+
batch_identity_source: batchIdentitySource,
|
|
331
|
+
evidence_captured_at: item.captureAt,
|
|
332
|
+
started_at: item.startedAt,
|
|
333
|
+
capture: {
|
|
334
|
+
evidence_captured_at: item.captureAt,
|
|
335
|
+
started_at: item.startedAt,
|
|
336
|
+
session_fetched_at: sessionFetched,
|
|
337
|
+
},
|
|
338
|
+
official_provenance: record.official_provenance ?? null,
|
|
339
|
+
manifest_provenance: record.manifest_provenance ?? record.manifest ?? null,
|
|
340
|
+
manifest_sha256: stringValue(record.manifest_sha256) ?? nestedString(record.manifest_provenance, 'sha256'),
|
|
341
|
+
manifest_hash: stringValue(record.manifest_hash) ?? nestedString(record.manifest_provenance, 'hash'),
|
|
342
|
+
batch_provenance: record.batch_provenance ?? null,
|
|
343
|
+
session_verdict: verdict,
|
|
344
|
+
session_flight: sessionFlight,
|
|
345
|
+
soft_score: softScore,
|
|
346
|
+
session_latency_ms: numberValue(record.sessionLatencyMs),
|
|
347
|
+
session_error: stringValue(record.sessionError),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function challengeStopHit(item) {
|
|
351
|
+
// 新证据:session.verdict / doubleSource.state 承载语义;旧证据(改写 bug 时代):
|
|
352
|
+
// session.verdict 被改写为 error,但顶层 sessionVerdict 仍是 challenged——一并识别
|
|
353
|
+
if (nestedString(item.record.session, 'verdict') === 'challenged')
|
|
354
|
+
return true;
|
|
355
|
+
if (stringValue(item.record.sessionVerdict) === 'challenged')
|
|
356
|
+
return true;
|
|
357
|
+
const state = nestedString(item.record.doubleSource, 'state');
|
|
358
|
+
return state === 'challenge_stop' || state === 'guard_violation';
|
|
359
|
+
}
|
|
360
|
+
function buildErrors(summary, conflictReason) {
|
|
361
|
+
const errors = [];
|
|
362
|
+
if (summary.selected_batch.batch_id === null)
|
|
363
|
+
errors.push('no defensible batch identity found');
|
|
364
|
+
if (conflictReason !== null)
|
|
365
|
+
errors.push(conflictReason);
|
|
366
|
+
if (summary.missing_query_ids.length > 0)
|
|
367
|
+
errors.push(`missing query IDs: ${summary.missing_query_ids.join(', ')}`);
|
|
368
|
+
if (summary.selected_malformed_records.length > 0)
|
|
369
|
+
errors.push(`malformed JSON: ${summary.selected_malformed_records.map((item) => item.file).join(', ')}`);
|
|
370
|
+
if (summary.selected_invalid_records.length > 0)
|
|
371
|
+
errors.push(`invalid records: ${summary.selected_invalid_records.map((item) => item.file).join(', ')}`);
|
|
372
|
+
if (summary.challenge_stop_detected)
|
|
373
|
+
errors.push('challenge/guard stop evidence: batch is not a complete calibration');
|
|
374
|
+
return errors;
|
|
375
|
+
}
|
|
376
|
+
export function parseCliArgs(args) {
|
|
377
|
+
let evidenceRoot = null;
|
|
378
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
379
|
+
const arg = args[index];
|
|
380
|
+
if (arg === '--evidence-root') {
|
|
381
|
+
const value = args[index + 1];
|
|
382
|
+
if (value === undefined || value.startsWith('--'))
|
|
383
|
+
throw new Error('--evidence-root requires a path');
|
|
384
|
+
evidenceRoot = value;
|
|
385
|
+
index += 1;
|
|
386
|
+
}
|
|
387
|
+
else if (arg.startsWith('--evidence-root=')) {
|
|
388
|
+
const value = arg.slice('--evidence-root='.length);
|
|
389
|
+
if (value.length === 0)
|
|
390
|
+
throw new Error('--evidence-root requires a path');
|
|
391
|
+
evidenceRoot = value;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
throw new Error(`unknown argument: ${arg}`);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return { evidenceRoot: resolve(evidenceRoot ?? join(homedir(), '.gotry', 'evidence', 'session')) };
|
|
398
|
+
}
|
|
399
|
+
export function buildSummary(evidenceRoot, generatedAt = new Date().toISOString()) {
|
|
400
|
+
const root = resolve(evidenceRoot);
|
|
401
|
+
const inventory = inventoryFiles(root);
|
|
402
|
+
const loaded = readRecords(inventory.files);
|
|
403
|
+
const candidates = completeCandidates(inventory.candidates, loaded.records);
|
|
404
|
+
const batch = chooseBatch(candidates);
|
|
405
|
+
const selected = batch === null ? new Map() : selectBatchRecords(batch);
|
|
406
|
+
const selectedRecords = EXPECTED_QUERY_IDS.flatMap((queryId) => {
|
|
407
|
+
const item = selected.get(queryId);
|
|
408
|
+
return item === undefined || batch === null ? [] : [toSummaryRecord(item, batch.id, batch.identitySource)];
|
|
409
|
+
});
|
|
410
|
+
const selectedFiles = new Set(batch?.files.map((file) => file.file) ?? []);
|
|
411
|
+
const selectedMalformed = loaded.malformedRecords.filter((item) => selectedFiles.has(item.file));
|
|
412
|
+
const selectedInvalid = [...inventory.invalidRecords, ...loaded.invalidRecords].filter((item) => selectedFiles.has(item.file));
|
|
413
|
+
const missingQueryIds = EXPECTED_QUERY_IDS.filter((queryId) => !selected.has(queryId));
|
|
414
|
+
const batchCaptureAt = batch?.captureAt ?? null;
|
|
415
|
+
const summary = {
|
|
416
|
+
schema_version: 'gotry_sf_summary_v2',
|
|
417
|
+
generated_at: generatedAt,
|
|
418
|
+
started_at: batchCaptureAt,
|
|
419
|
+
batch_capture_at: batchCaptureAt,
|
|
420
|
+
selected_batch: {
|
|
421
|
+
batch_id: batch?.id ?? null,
|
|
422
|
+
identity_source: batch?.identitySource ?? null,
|
|
423
|
+
started_at: batchCaptureAt,
|
|
424
|
+
record_count: selectedRecords.length,
|
|
425
|
+
query_ids: selectedRecords.map((record) => record.query_id),
|
|
426
|
+
},
|
|
427
|
+
status: 'fail_closed',
|
|
428
|
+
status_scope: 'batch_integrity_only',
|
|
429
|
+
total: selectedRecords.length,
|
|
430
|
+
threshold: SESSION_FIELD_ACCURACY_THRESHOLD,
|
|
431
|
+
accuracy_pass: selectedRecords.filter((record) => record.soft_score?.pass === true).length,
|
|
432
|
+
accuracy_eligible: selectedRecords.filter((record) => record.soft_score !== null).length,
|
|
433
|
+
comparable: selectedRecords.filter((record) => {
|
|
434
|
+
const item = selected.get(record.query_id);
|
|
435
|
+
return item !== undefined && isObject(item.record.doubleSource) && item.record.doubleSource.state === 'comparable';
|
|
436
|
+
}).length,
|
|
437
|
+
live_provider_comparable: selectedRecords.filter((record) => {
|
|
438
|
+
const item = selected.get(record.query_id);
|
|
439
|
+
return record.comparator_evidence_scope === 'live_provider' && item !== undefined && isObject(item.record.doubleSource) && item.record.doubleSource.state === 'comparable';
|
|
440
|
+
}).length,
|
|
441
|
+
hit: selectedRecords.filter((record) => record.session_verdict === 'hit').length,
|
|
442
|
+
challenge: selectedRecords.filter((record) => record.session_verdict === 'challenged').length,
|
|
443
|
+
challenge_stop_detected: selectedRecords.some((record) => challengeStopHit(selected.get(record.query_id))),
|
|
444
|
+
live_under_15s: selectedRecords.filter((record) => record.session_verdict === 'hit' && record.session_latency_ms !== null && record.session_latency_ms < 15_000).length,
|
|
445
|
+
missing_query_ids: missingQueryIds,
|
|
446
|
+
malformed_records: loaded.malformedRecords,
|
|
447
|
+
invalid_records: [...inventory.invalidRecords, ...loaded.invalidRecords],
|
|
448
|
+
selected_malformed_records: selectedMalformed,
|
|
449
|
+
selected_invalid_records: selectedInvalid,
|
|
450
|
+
unknown_batch_records: loaded.unknownBatchRecords,
|
|
451
|
+
sources: {
|
|
452
|
+
manual_golden_query_ids: [],
|
|
453
|
+
static_query_ids: [],
|
|
454
|
+
flyai_query_ids: [],
|
|
455
|
+
unknown_query_ids: [],
|
|
456
|
+
},
|
|
457
|
+
records: selectedRecords,
|
|
458
|
+
errors: [],
|
|
459
|
+
};
|
|
460
|
+
for (const record of summary.records)
|
|
461
|
+
summary.sources[sourceBucket(record)].push(record.query_id);
|
|
462
|
+
summary.errors = buildErrors(summary, batch?.conflictReason ?? (batch === null ? null : null));
|
|
463
|
+
summary.status = summary.errors.length === 0 ? 'ok' : 'fail_closed';
|
|
464
|
+
const summaryPath = join(root, 'sf-summary', `${generatedAt.replace(/[:.]/g, '-')}.json`);
|
|
465
|
+
mkdirSync(dirname(summaryPath), { recursive: true });
|
|
466
|
+
writeFileSync(summaryPath, JSON.stringify(summary, null, 2));
|
|
467
|
+
return { summary, summaryPath };
|
|
468
|
+
}
|
|
469
|
+
export function main(args = process.argv.slice(2)) {
|
|
470
|
+
try {
|
|
471
|
+
const options = parseCliArgs(args);
|
|
472
|
+
const { summary, summaryPath } = buildSummary(options.evidenceRoot);
|
|
473
|
+
console.log('──── sf-summary (coherent offline batch) ────');
|
|
474
|
+
console.log(`status: ${summary.status}`);
|
|
475
|
+
console.log('status scope: offline batch integrity only; live availability requires independent session verification');
|
|
476
|
+
console.log(`selected batch: ${summary.selected_batch.batch_id ?? '(none)'}`);
|
|
477
|
+
console.log(`batch capture: ${summary.batch_capture_at ?? '(unknown)'}`);
|
|
478
|
+
console.log(`generated at: ${summary.generated_at}`);
|
|
479
|
+
console.log(`total: ${summary.total}/${EXPECTED_QUERY_IDS.length}`);
|
|
480
|
+
console.log(`session verdict=hit (offline record, unverified): ${summary.hit}/${summary.total}`);
|
|
481
|
+
console.log(`double-source comparable (all scopes): ${summary.comparable}/${summary.total}`);
|
|
482
|
+
console.log(`live-provider comparable: ${summary.live_provider_comparable}/${summary.total}`);
|
|
483
|
+
if (summary.sources.static_query_ids.length > 0 || summary.sources.manual_golden_query_ids.length > 0)
|
|
484
|
+
console.log('static/manual comparator: deterministic only; no live provider inventory proof');
|
|
485
|
+
if (summary.challenge_stop_detected)
|
|
486
|
+
console.log('challenge stop detected: 部分批次为挑战截断产物(RFC §3.5),不计为完整/有效校准');
|
|
487
|
+
console.log(`soft score ≥${summary.threshold * 100}%: ${summary.accuracy_pass}/${summary.accuracy_eligible}`);
|
|
488
|
+
console.log(`manual golden query_ids: ${summary.sources.manual_golden_query_ids.join(', ') || '(none)'}`);
|
|
489
|
+
console.log(`static query_ids: ${summary.sources.static_query_ids.join(', ') || '(none)'}`);
|
|
490
|
+
console.log(`flyai query_ids: ${summary.sources.flyai_query_ids.join(', ') || '(none)'}`);
|
|
491
|
+
console.log(`unknown source query_ids: ${summary.sources.unknown_query_ids.join(', ') || '(none)'}`);
|
|
492
|
+
if (summary.missing_query_ids.length > 0)
|
|
493
|
+
console.error(`missing query IDs: ${summary.missing_query_ids.join(', ')}`);
|
|
494
|
+
if (summary.selected_malformed_records.length > 0)
|
|
495
|
+
console.error(`malformed JSON: ${summary.selected_malformed_records.map((item) => item.file).join(', ')}`);
|
|
496
|
+
if (summary.selected_invalid_records.length > 0)
|
|
497
|
+
console.error(`invalid records: ${summary.selected_invalid_records.map((item) => item.file).join(', ')}`);
|
|
498
|
+
if (summary.malformed_records.length > summary.selected_malformed_records.length)
|
|
499
|
+
console.error(`diagnostic malformed JSON outside selected batch: ${summary.malformed_records.length - summary.selected_malformed_records.length}`);
|
|
500
|
+
console.log(`summary: ${summaryPath}`);
|
|
501
|
+
return summary.status === 'ok' ? 0 : 1;
|
|
502
|
+
}
|
|
503
|
+
catch (error) {
|
|
504
|
+
console.error(`[sf-summary] fail-closed: ${error instanceof Error ? error.message : String(error)}`);
|
|
505
|
+
return 1;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
// Issue #420: realpathSync canonicalizes the invocation path and the module
|
|
509
|
+
// URL so the entrypoint guard still recognizes file- and directory-symlink
|
|
510
|
+
// invocations. Without canonicalization, `resolve(process.argv[1])` keeps the
|
|
511
|
+
// symlink path while `fileURLToPath(import.meta.url)` is the real path, and
|
|
512
|
+
// the mismatch silently skips main(). When imported from another module,
|
|
513
|
+
// `process.argv[1]` points at the importer, not at this file, so the guard
|
|
514
|
+
// still fails and main() stays inert.
|
|
515
|
+
function canonicalEntry(p) {
|
|
516
|
+
try {
|
|
517
|
+
return realpathSync(p);
|
|
518
|
+
}
|
|
519
|
+
catch {
|
|
520
|
+
return resolve(p);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
const invokedPath = process.argv[1] === undefined ? null : resolve(process.argv[1]);
|
|
524
|
+
if (invokedPath !== null && canonicalEntry(invokedPath) === canonicalEntry(fileURLToPath(import.meta.url)))
|
|
525
|
+
process.exitCode = main();
|