@danceiny/gotry 0.0.1-rc.8 → 0.2.0-rc.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -217
- package/README.zh-CN.md +222 -0
- package/bin/gotry-backend.js +53 -0
- package/bin/gotry-booking-copilot.js +53 -0
- package/bin/gotry-bootstrap.js +1744 -0
- package/bin/gotry-inner.js +733 -83
- package/bin/gotry-process-liveness.d.ts +27 -0
- package/bin/gotry-process-liveness.js +97 -0
- package/bin/gotry-runtime-resolution.d.ts +27 -0
- package/bin/gotry-runtime-resolution.js +49 -0
- package/bin/gotry.js +1 -1
- package/client/client.js +203 -0
- package/cordis.gotry-patch.yml +80 -49
- package/data/airline-airports.json +39 -0
- package/data/stations-12306-verify.json +524 -0
- package/dist/capabilities/agent-reach-deep.js +45 -122
- package/dist/capabilities/agent-reach.js +101 -146
- package/dist/capabilities/anything.js +135 -94
- package/dist/capabilities/artifacts.js +370 -0
- package/dist/capabilities/channel-health.js +131 -0
- package/dist/capabilities/channel-registry.js +256 -0
- package/dist/capabilities/doctor.js +546 -0
- package/dist/capabilities/effect.js +394 -0
- package/dist/capabilities/external-event.js +149 -0
- package/dist/capabilities/fact-log.js +55 -0
- package/dist/capabilities/flyai-config.js +337 -0
- package/dist/capabilities/flyai.js +968 -0
- package/dist/capabilities/fx-contract.js +293 -0
- package/dist/capabilities/geo-atlas.js +246 -0
- package/dist/capabilities/ground-transfer.js +509 -0
- package/dist/capabilities/hbcli.js +260 -123
- package/dist/capabilities/hotelbyte-transaction.js +194 -0
- package/dist/capabilities/incident-log.js +131 -61
- package/dist/capabilities/itinerary-artifact.js +190 -0
- package/dist/capabilities/itinerary-deck-artifact.js +194 -0
- package/dist/capabilities/itinerary-deck-export.js +339 -0
- package/dist/capabilities/lavish-local.js +924 -0
- package/dist/capabilities/model-override.js +38 -0
- package/dist/capabilities/opensky.js +54 -43
- package/dist/capabilities/resilience.js +191 -0
- package/dist/capabilities/session/action-cache.js +126 -0
- package/dist/capabilities/session/adapters/ctrip-flight.js +141 -0
- 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 +54 -0
- 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 +50 -0
- 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 +107 -0
- package/dist/capabilities/session/static-flight-golden.js +150 -0
- package/dist/capabilities/session/transport.js +109 -0
- 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 +686 -0
- 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 +72 -0
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +242 -0
- package/dist/scripts/agent-planning-turn-deadline-tests.js +185 -0
- package/dist/scripts/agent-reach-deep-tests.js +30 -40
- package/dist/scripts/agent-reach-error-tests.js +354 -0
- package/dist/scripts/agent-reach-tests.js +26 -18
- package/dist/scripts/agent-reach-wrapper-tests.js +50 -50
- package/dist/scripts/anything-tests.js +116 -60
- package/dist/scripts/artifact-client-contract-tests.js +220 -0
- package/dist/scripts/artifacts-capability-tests.js +727 -0
- package/dist/scripts/async-collect.js +68 -10
- package/dist/scripts/benchmark-environment-bridge-e2e.js +741 -0
- package/dist/scripts/benchmark-environment-bridge-tests.js +1452 -0
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +126 -0
- package/dist/scripts/booking-copilot-availability-policy-tests.js +265 -0
- package/dist/scripts/booking-copilot-bin-proof-tests.js +66 -0
- package/dist/scripts/booking-copilot-cleanup-proof-helper.js +76 -0
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +144 -0
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +424 -0
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +2839 -0
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +309 -0
- package/dist/scripts/booking-copilot-dsh-readiness-proof.js +238 -0
- package/dist/scripts/booking-copilot-dsh-warmer-proof.js +123 -0
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +156 -0
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +70 -0
- package/dist/scripts/booking-copilot-intent-proof-tests.js +422 -0
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +184 -0
- package/dist/scripts/booking-copilot-planner-live-probe.js +95 -0
- package/dist/scripts/booking-copilot-proof-runtime.js +42 -0
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +210 -0
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +2349 -0
- package/dist/scripts/booking-copilot-server-proof-tests.js +784 -0
- package/dist/scripts/booking-copilot-startup-proof-tests.js +94 -0
- package/dist/scripts/booking-executor-tests.js +80 -0
- package/dist/scripts/booking-recovery-chain-tests.js +182 -0
- package/dist/scripts/booking-saga-tests.js +125 -0
- package/dist/scripts/booking-surface-contract-proof-tests.js +212 -0
- package/dist/scripts/bootstrap-tests.js +1479 -0
- package/dist/scripts/bridge-events-tests.js +239 -0
- package/dist/scripts/bridge-ledger-tests.js +428 -0
- package/dist/scripts/build-changelog.js +238 -0
- package/dist/scripts/build-metrics-report.js +331 -0
- package/dist/scripts/changelog-tests.js +118 -0
- package/dist/scripts/channel-probe-tests.js +103 -0
- package/dist/scripts/channel-probe.js +169 -0
- package/dist/scripts/channel-registry-tests.js +208 -0
- package/dist/scripts/companion-tests.js +67 -0
- package/dist/scripts/dida-cookie-probe.js +87 -0
- package/dist/scripts/dida-runner-stop-tests.js +311 -0
- package/dist/scripts/dida-sw-probe.js +114 -0
- package/dist/scripts/diff-test.js +17 -12
- package/dist/scripts/doctor-tests.js +564 -0
- package/dist/scripts/dsh-artifact-e2e.js +279 -0
- package/dist/scripts/dsh-artifact-web-e2e.js +675 -0
- package/dist/scripts/dsh-http-proxy-sse-proof.js +90 -0
- package/dist/scripts/dsh-runtime-closure-tests.js +182 -0
- package/dist/scripts/dsh-runtime-closure.js +162 -0
- package/dist/scripts/dsh-session-v3-migration-proof.js +109 -0
- package/dist/scripts/dsh-subprocess-local-proof.js +150 -0
- package/dist/scripts/dsh-target-closure-proof.js +178 -0
- package/dist/scripts/effect-tests.js +539 -0
- package/dist/scripts/engine-run.js +1 -3
- package/dist/scripts/engine-tests.js +16 -10
- package/dist/scripts/evaluation-cadence-tests.js +174 -0
- package/dist/scripts/evaluation-contract-tests.js +268 -0
- package/dist/scripts/extension-distribution-cli.js +39 -0
- package/dist/scripts/extension-distribution-tests.js +443 -0
- package/dist/scripts/extension-tests.js +988 -0
- package/dist/scripts/external-event-tests.js +350 -0
- package/dist/scripts/fact-gate-tests.js +869 -0
- package/dist/scripts/fixtures/extension-bridge-unref-child.mjs +21 -0
- package/dist/scripts/flight-hotel-anchor-363-registered-e2e.js +169 -0
- package/dist/scripts/flight-malformed-tests.js +159 -0
- package/dist/scripts/flyai-setup-tests.js +228 -0
- package/dist/scripts/flyai-setup-tool-tests.js +54 -0
- package/dist/scripts/flyai-tests.js +692 -0
- package/dist/scripts/flyai-tool-registration-contract-tests.js +91 -0
- package/dist/scripts/fx-contract-tests.js +201 -0
- package/dist/scripts/g5-guard-tests.js +131 -0
- package/dist/scripts/g5-guard.js +189 -0
- package/dist/scripts/gen-lunar-anchors.js +106 -0
- package/dist/scripts/geo-atlas-tests.js +283 -0
- package/dist/scripts/gotry-backend-kernel-tests.js +206 -0
- package/dist/scripts/gotry-try-demo-tests.js +79 -0
- package/dist/scripts/gotry-try-demo.js +49 -0
- package/dist/scripts/ground-transfer-tests.js +956 -0
- package/dist/scripts/hbcli-e2e-tests.js +159 -0
- package/dist/scripts/hbcli-live-optin-tests.js +96 -0
- package/dist/scripts/hbcli-release-contract-tests.js +122 -0
- package/dist/scripts/hbcli-tests.js +121 -69
- package/dist/scripts/health-watch-cli.js +73 -0
- package/dist/scripts/hotel-date-gate-tests.js +496 -0
- package/dist/scripts/hotelbyte-reconcile-tests.js +141 -0
- package/dist/scripts/hotelbyte-spawn-e2e-tests.js +373 -0
- package/dist/scripts/i18n-tests.js +41 -0
- package/dist/scripts/incident-tests.js +281 -87
- package/dist/scripts/issue-194-job-id-guard-tests.js +106 -0
- package/dist/scripts/issue-233-cancel-refund-commission-tests.js +392 -0
- package/dist/scripts/issue-271-liveness-tests.js +569 -0
- package/dist/scripts/issue-289-model-retry-real-tests.js +296 -0
- package/dist/scripts/issue-289-model-retry-tests.js +441 -0
- package/dist/scripts/issue-289-web-retry-e2e.js +630 -0
- package/dist/scripts/issue-338-home-city-e2e.js +577 -0
- package/dist/scripts/issue343-real-entry-e2e.js +160 -0
- package/dist/scripts/issue436-persisted-routing-e2e.js +247 -0
- package/dist/scripts/itinerary-artifact-tests.js +368 -0
- package/dist/scripts/itinerary-deck-artifact-tests.js +416 -0
- package/dist/scripts/itinerary-deck-export-tests.js +552 -0
- package/dist/scripts/itinerary-deck-tests.js +435 -0
- package/dist/scripts/itinerary-html-tests.js +426 -0
- package/dist/scripts/journey-tests.js +22 -27
- package/dist/scripts/kernel-manifest-evidence.js +109 -0
- package/dist/scripts/kernel-manifest-gate.js +126 -0
- package/dist/scripts/kernel-manifest-tests.js +212 -0
- package/dist/scripts/kernel-manifest-trace-entry.js +7 -0
- package/dist/scripts/kernel-manifest-trace-hook.mjs +28 -0
- package/dist/scripts/kernel-manifest.js +369 -0
- package/dist/scripts/lavish-local-tests.js +1226 -0
- package/dist/scripts/lavish-product-tools-tests.js +537 -0
- package/dist/scripts/ledger-repair-apply-tests.js +316 -0
- package/dist/scripts/ledger-repair-plan-tests.js +375 -0
- package/dist/scripts/ledger-tests.js +480 -0
- package/dist/scripts/ledger-workflow-crash.js +32 -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 +49 -0
- package/dist/scripts/memory-lifecycle-tests.js +657 -0
- package/dist/scripts/memory-lifecycle.js +196 -0
- package/dist/scripts/memory-metrics.js +29 -31
- package/dist/scripts/memory-value-report.js +631 -0
- package/dist/scripts/memory-value-tests.js +328 -0
- package/dist/scripts/metrics-report-tests.js +151 -0
- package/dist/scripts/model-override-e2e.js +137 -0
- package/dist/scripts/nightly-evidence-tests.js +161 -0
- package/dist/scripts/nightly-evidence.js +286 -0
- package/dist/scripts/nudge-digest.js +43 -42
- package/dist/scripts/observability-tests.js +381 -0
- package/dist/scripts/onboarding-tests.js +161 -0
- package/dist/scripts/opensky-check.js +18 -13
- package/dist/scripts/opensky-tests.js +28 -28
- package/dist/scripts/persona-surface-guard-tests.js +49 -0
- package/dist/scripts/pnpm-dsh-closure-proof.js +17 -0
- package/dist/scripts/policy-anchor-359-registered-e2e.js +214 -0
- package/dist/scripts/price-drift-tests.js +340 -0
- package/dist/scripts/price-drift-watch.js +447 -0
- package/dist/scripts/probe-poi-tests.js +53 -45
- package/dist/scripts/product-metrics.js +483 -0
- package/dist/scripts/publish-preverify.js +110 -0
- package/dist/scripts/realtime-pricing-tests.js +76 -0
- package/dist/scripts/recall-tests.js +513 -0
- package/dist/scripts/replay-async.js +20 -18
- package/dist/scripts/replay-real.js +18 -18
- package/dist/scripts/replay.js +52 -82
- package/dist/scripts/session-attach-diagnose.js +31 -0
- package/dist/scripts/session-attach-poc.js +62 -0
- 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 +60 -0
- package/dist/scripts/session-link-tests.js +478 -0
- package/dist/scripts/session-login.js +29 -0
- package/dist/scripts/session-tests.js +862 -0
- package/dist/scripts/session-zones-tests.js +358 -0
- package/dist/scripts/sf-live-benchmark.js +367 -0
- package/dist/scripts/sf-live-challenge-stop-tests.js +453 -0
- package/dist/scripts/sf-live-cli-tests.js +92 -0
- package/dist/scripts/sf-live-options.js +46 -0
- package/dist/scripts/sf-manifest-tests.js +30 -0
- package/dist/scripts/sf-manifest.js +33 -0
- package/dist/scripts/sf-soft-score-tests.js +67 -0
- package/dist/scripts/sf-summary-tests.js +324 -0
- package/dist/scripts/sf-summary.js +525 -0
- package/dist/scripts/share-tests.js +432 -0
- package/dist/scripts/skeleton-check.js +16 -14
- package/dist/scripts/skeleton-integration-test.js +28 -11
- package/dist/scripts/skills-contract-tests.js +51 -46
- package/dist/scripts/smoke-session-gate-tests.js +21 -0
- package/dist/scripts/smoke.js +703 -219
- package/dist/scripts/spawn-bounded-abort-tests.js +241 -0
- package/dist/scripts/sponsor-reuse-tests.js +262 -0
- package/dist/scripts/state-cli-tests.js +261 -0
- package/dist/scripts/state-cli.js +585 -0
- package/dist/scripts/state-repair-cli.js +66 -0
- package/dist/scripts/state-repair-tests.js +140 -0
- package/dist/scripts/static-golden-tests.js +165 -0
- package/dist/scripts/time-eval-tests.js +210 -192
- package/dist/scripts/travel-timeline-tests.js +59 -0
- package/dist/scripts/turn-handoff-collect-tests.js +169 -0
- package/dist/scripts/turn-handoff-collect.js +161 -0
- package/dist/scripts/turn-policy-tests.js +55 -0
- package/dist/scripts/typed-contract-canary.js +176 -0
- package/dist/scripts/tz-resolver-sanity.js +50 -0
- package/dist/scripts/tz-resolver-tests.js +584 -0
- package/dist/scripts/unified-tests.js +23 -19
- package/dist/scripts/visa-policy-tests.js +62 -0
- package/dist/scripts/weather-tests.js +276 -41
- package/dist/scripts/wish-channel-gate-tests.js +54 -0
- package/dist/scripts/write-gate-tests.js +522 -0
- package/dist/scripts/z3-lifecycle-fault-tests.js +188 -0
- package/dist/scripts/z3-lifecycle-tests.js +170 -0
- package/dist/scripts/z3-race-repeat-tests.js +39 -0
- package/dist/scripts/z3-race-tests.js +41 -0
- package/dist/src/artifact-gate.js +829 -0
- package/dist/src/backend/kernel.js +91 -0
- package/dist/src/backend/modules/booking-copilot.js +92 -0
- package/dist/src/backend/modules/booking-executor.js +124 -0
- package/dist/src/backend/modules/session-search.js +551 -0
- package/dist/src/benchmark-agent-conformance.js +578 -0
- package/dist/src/benchmark-environment-bridge.js +515 -0
- package/dist/src/benchmark-headless-child-diagnostics.js +166 -0
- package/dist/src/benchmark-tool-isolation.js +151 -0
- package/dist/src/bookable-facts.js +533 -0
- package/dist/src/booking-saga.js +97 -0
- package/dist/src/booking-surface/availability-policy.js +697 -0
- package/dist/src/booking-surface/booking-intent.js +43 -0
- package/dist/src/booking-surface/cancel-refund-commission.js +379 -0
- package/dist/src/booking-surface/canonical-schema.js +116 -0
- package/dist/src/booking-surface/contracts.js +75 -0
- package/dist/src/booking-surface/dsh-planner.js +1854 -0
- package/dist/src/booking-surface/dsh-plugin.js +378 -0
- package/dist/src/booking-surface/dsh-worker.js +98 -0
- package/dist/src/booking-surface/error-codes.js +231 -0
- package/dist/src/booking-surface/index.js +9 -0
- package/dist/src/booking-surface/managed-dsh-cleanup-diagnostic.js +97 -0
- package/dist/src/booking-surface/managed-dsh-run-port.js +244 -0
- package/dist/src/booking-surface/profile.js +24 -0
- package/dist/src/booking-surface/recovery-chain.js +367 -0
- package/dist/src/booking-surface/runtime.js +1968 -0
- package/dist/src/booking-surface/server.js +674 -0
- package/dist/src/booking-surface/startup.js +168 -0
- package/dist/src/booking-surface/validation.js +261 -0
- package/dist/src/bridge.js +20 -13
- package/dist/src/companions.js +86 -0
- package/dist/src/contracts.js +21 -43
- package/dist/src/dsh-llm.js +97 -111
- package/dist/src/engine.js +276 -193
- package/dist/src/evaluation-cadence.js +97 -0
- package/dist/src/evaluation-contracts.js +283 -0
- package/dist/src/flight-pack-adapter.js +54 -0
- package/dist/src/flight-pack-contract.js +2 -0
- package/dist/src/flyai-setup-tool.js +70 -0
- package/dist/src/gotry-backend.js +125 -0
- package/dist/src/hotel-date-gate.js +118 -0
- package/dist/src/i18n.js +88 -0
- package/dist/src/index.js +2305 -731
- 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 +358 -162
- package/dist/src/memory-capture.js +180 -32
- package/dist/src/memory-decay.js +47 -0
- package/dist/src/memory-lifecycle.js +1310 -0
- package/dist/src/memory-utility.js +27 -40
- package/dist/src/mock-llm.js +36 -61
- package/dist/src/model.js +81 -36
- package/dist/src/realtime-pricing.js +103 -0
- package/dist/src/recall/card.js +74 -0
- package/dist/src/recall/evaluator.js +140 -0
- package/dist/src/recall/integration.js +17 -0
- package/dist/src/recall/tick.js +166 -0
- package/dist/src/session-link/plan-it-action.js +48 -0
- package/dist/src/session-link/session-link.js +248 -0
- package/dist/src/session-zones.js +507 -0
- package/dist/src/share/adapters.js +51 -0
- package/dist/src/share/share-consent.js +76 -0
- package/dist/src/share/share-deck.js +58 -0
- package/dist/src/share/share-token.js +146 -0
- package/dist/src/slot-spec.js +84 -106
- package/dist/src/state-ledger.js +767 -0
- 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 +59 -0
- 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 +538 -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 +255 -0
- package/ts/capabilities/artifacts.ts +428 -0
- package/ts/capabilities/fact-log.ts +54 -0
- package/ts/capabilities/flyai-config.ts +388 -0
- package/ts/capabilities/flyai.ts +1274 -0
- package/ts/capabilities/hbcli.ts +253 -71
- package/ts/capabilities/incident-log.ts +88 -59
- package/ts/capabilities/itinerary-artifact.ts +214 -0
- package/ts/capabilities/itinerary-deck-artifact.ts +218 -0
- package/ts/capabilities/itinerary-deck-export.ts +378 -0
- package/ts/capabilities/opensky.ts +121 -0
- package/ts/capabilities/session/action-cache.ts +148 -0
- package/ts/capabilities/session/adapters/ctrip-flight.ts +181 -0
- package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
- package/ts/capabilities/session/adapters/dida-portal.ts +338 -0
- package/ts/capabilities/session/adapters/meituan-local.ts +70 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +392 -0
- package/ts/capabilities/session/benchmark.ts +276 -0
- package/ts/capabilities/session/bridge-ledger.ts +333 -0
- package/ts/capabilities/session/extension-bridge.ts +794 -0
- package/ts/capabilities/session/extension-channel.ts +144 -0
- package/ts/capabilities/session/extension-distribution.ts +266 -0
- package/ts/capabilities/session/extract.ts +54 -0
- package/ts/capabilities/session/golden-score.ts +139 -0
- package/ts/capabilities/session/health-watch.ts +264 -0
- package/ts/capabilities/session/read-guard.ts +141 -0
- package/ts/capabilities/session/static-flight-golden.ts +209 -0
- package/ts/capabilities/session/transport.ts +146 -0
- package/ts/capabilities/session/wizard.ts +140 -0
- package/ts/capabilities/session-consent.ts +211 -0
- package/ts/capabilities/session-login.ts +208 -0
- package/ts/capabilities/session-search.ts +893 -0
- package/ts/capabilities/weather.ts +330 -0
- package/ts/dsh-runtime/vendor/README.md +68 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/LICENSE +21 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +405 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +404 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/client/client.js +1584 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/cordis.patch.yml +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/icon.svg +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/amap.js +595 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/nominatim.js +63 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/osrm.js +58 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/photon.js +55 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-file.js +87 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-route.js +131 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/geo.js +232 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/index.js +120 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +40 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/staticmap-route.js +115 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/geocode.js +127 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/poi.js +84 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/routes.js +267 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/amap.d.ts +90 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/nominatim.d.ts +17 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/osrm.d.ts +15 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/photon.d.ts +22 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-file.d.ts +33 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-route.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/geo.d.ts +61 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/index.d.ts +18 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +14 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/staticmap-route.d.ts +31 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/geocode.d.ts +11 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/poi.d.ts +9 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/routes.d.ts +75 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/types.d.ts +68 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +97 -0
- package/ts/package.json +296 -3
- package/ts/scripts/async-collect.ts +91 -0
- package/ts/scripts/map-tools-vendor-package-proof.ts +404 -0
- package/ts/scripts/skeleton-check.ts +1 -1
- package/ts/scripts/skeleton-integration-test.ts +23 -1
- package/ts/scripts/state-cli.ts +568 -0
- package/ts/scripts/turn-handoff-collect.ts +178 -0
- package/ts/src/artifact-gate.ts +991 -0
- package/ts/src/benchmark-agent-conformance.ts +619 -0
- package/ts/src/benchmark-environment-bridge.ts +538 -0
- package/ts/src/benchmark-headless-child-diagnostics.ts +184 -0
- package/ts/src/benchmark-tool-isolation.ts +166 -0
- package/ts/src/bookable-facts.ts +837 -0
- package/ts/src/booking-saga.ts +133 -0
- package/ts/src/booking-surface/availability-policy.ts +522 -0
- package/ts/src/booking-surface/booking-intent.ts +86 -0
- package/ts/src/booking-surface/cancel-refund-commission.ts +488 -0
- package/ts/src/booking-surface/canonical-schema.js +116 -0
- package/ts/src/booking-surface/contracts.ts +475 -0
- package/ts/src/booking-surface/dsh-planner.ts +1949 -0
- package/ts/src/booking-surface/dsh-plugin.js +378 -0
- package/ts/src/booking-surface/dsh-worker.ts +110 -0
- package/ts/src/booking-surface/error-codes.ts +241 -0
- package/ts/src/booking-surface/index.ts +9 -0
- package/ts/src/booking-surface/managed-dsh-cleanup-diagnostic.ts +151 -0
- package/ts/src/booking-surface/managed-dsh-run-port.ts +273 -0
- package/ts/src/booking-surface/profile.ts +42 -0
- package/ts/src/booking-surface/recovery-chain.ts +409 -0
- package/ts/src/booking-surface/runtime.ts +1793 -0
- package/ts/src/booking-surface/server.ts +733 -0
- package/ts/src/booking-surface/startup.ts +201 -0
- package/ts/src/booking-surface/validation.ts +217 -0
- package/ts/src/companions.ts +113 -0
- package/ts/src/contracts.ts +13 -3
- package/ts/src/dsh-llm.ts +44 -11
- package/ts/src/flyai-setup-tool.ts +77 -0
- package/ts/src/index.ts +2107 -224
- 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 +278 -40
- package/ts/src/memory-capture.ts +283 -0
- package/ts/src/memory-decay.ts +55 -0
- package/ts/src/memory-utility.ts +70 -0
- package/ts/src/mock-llm.ts +4 -8
- package/ts/src/model.ts +88 -2
- package/ts/src/recall/card.ts +106 -0
- package/ts/src/recall/evaluator.ts +170 -0
- package/ts/src/recall/integration.ts +35 -0
- package/ts/src/recall/tick.ts +213 -0
- package/ts/src/session-link/plan-it-action.ts +78 -0
- package/ts/src/session-link/session-link.ts +275 -0
- package/ts/src/share/adapters.ts +93 -0
- package/ts/src/share/share-consent.ts +105 -0
- package/ts/src/share/share-deck.ts +85 -0
- package/ts/src/share/share-token.ts +166 -0
- package/ts/src/slot-spec.ts +172 -0
- package/ts/src/state-ledger.ts +912 -0
- package/ts/src/subagent-job-id-guard.ts +72 -0
- package/ts/src/time-anchor.ts +338 -0
- package/ts/src/tool-packet.ts +32 -0
- package/ts/src/travel-slots.ts +219 -0
- package/ts/src/travel-timeline.ts +83 -0
- package/ts/src/turn-deadline.ts +366 -0
- package/ts/src/turn-policy.ts +154 -0
- package/ts/src/unified.ts +360 -89
- package/ts/src/wish-pool.ts +79 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionTransport(会话检索传输层,RFC §3.2;2026-08-28 定案 puppeteer-core):
|
|
3
|
+
* - mode=cdp(默认):attach 用户日常 Chrome——Chrome 144+ 调试服务(chrome://inspect 开关)
|
|
4
|
+
* 与 playwright 不兼容(握手后 CDP 初始化悬挂,实测三轮),与 puppeteer 完全兼容(实测 2256 cookies)。
|
|
5
|
+
* 发现走 user-data-dir 的 DevToolsActivePort 文件(HTTP 发现面已硬化 404;Origin 头=403,安全设计)。
|
|
6
|
+
* close() 只 disconnect,绝不关用户浏览器。
|
|
7
|
+
* - mode=persistent(测试/后备):puppeteer.launch 专用 profile(测试用 mktemp 隔离匿名态)。
|
|
8
|
+
* fail-closed(RFC §3.3-④):guard 装不上 = 整个会话打不开——不存在「无守卫的会话」这一形态。
|
|
9
|
+
* 永不抛错:任何启动失败降级为 TransportFailure,由 session-search 编排层消费。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { readFileSync } from 'node:fs'
|
|
13
|
+
import { homedir } from 'node:os'
|
|
14
|
+
import { attachReadGuardPuppeteer, type ReadGuardHandle } from './read-guard.ts'
|
|
15
|
+
import type { Browser, Page } from 'puppeteer-core'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* puppeteer-core 为可选依赖(D-14:产品运行时零硬依赖,缺则优雅降级)。
|
|
19
|
+
* 顶层动态 import——npm 形态若未装 puppeteer-core,openSession 返回 TransportFailure
|
|
20
|
+
* 而非在模块加载期炸掉整个插件(2026-08-28 发布面实测:静态 import 会拖垮 index.ts 加载链)。
|
|
21
|
+
*/
|
|
22
|
+
async function loadPuppeteer(): Promise<typeof import('puppeteer-core') | { missing: true }> {
|
|
23
|
+
try {
|
|
24
|
+
return await import('puppeteer-core')
|
|
25
|
+
} catch {
|
|
26
|
+
return { missing: true }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TransportFailure {
|
|
31
|
+
ok: false
|
|
32
|
+
summary: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SessionTransport {
|
|
36
|
+
ok: true
|
|
37
|
+
browser: Browser
|
|
38
|
+
page: Page
|
|
39
|
+
guard: ReadGuardHandle
|
|
40
|
+
close(): Promise<void>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TransportOptions {
|
|
44
|
+
/** 传输模式:cdp=attach 用户日常 Chrome(默认,登录态=用户本人,founder 2026-08-28 定案);persistent=专用 profile(测试/后备) */
|
|
45
|
+
mode?: 'cdp' | 'persistent'
|
|
46
|
+
/** persistent 模式专用 profile 目录(测试用 mktemp 隔离匿名态;缺省 tmpdir) */
|
|
47
|
+
profileDir?: string
|
|
48
|
+
/** persistent 模式 headless(默认 true);cdp 模式恒为用户可见窗口 */
|
|
49
|
+
headless?: boolean
|
|
50
|
+
/** ReadGuard 审计落盘路径(缺省仅内存计数) */
|
|
51
|
+
auditPath?: string
|
|
52
|
+
/**
|
|
53
|
+
* 是否挂 ReadGuard(默认 true;检索面强制:检索会话不存在无守卫形态)。
|
|
54
|
+
* 唯一豁免 = 登录 bootstrap(guard:false):那是用户本人的凭证入口页,agent 只开页+只读轮询
|
|
55
|
+
* cookie 名,从不检索/点提交——守卫若在场,反而会物理 abort 用户自己的登录 POST
|
|
56
|
+
* (护照登录端点多为 POST /login/submit,命中写词模式),既挡登录又让我们站在用户
|
|
57
|
+
* 凭证流的中间(隐私+可靠性双输)。该形态下不发起任何检索导航、不落审计。
|
|
58
|
+
*/
|
|
59
|
+
guard?: boolean
|
|
60
|
+
/**
|
|
61
|
+
* 开**自己的新标签页**(默认 false=沿用既有首页——那是用户的页面!)。
|
|
62
|
+
* 人机共治纪律(2026-08-29 founder:「我根本就看不到登录页面」):登录与检索一律
|
|
63
|
+
* newPage 开自己的页,绝不劫持用户已有标签页;closeOwnPage 控制收尾是否关掉自己开的页。
|
|
64
|
+
*/
|
|
65
|
+
newPage?: boolean
|
|
66
|
+
/** newPage:true 时,close() 是否连自己开的标签页一起关(默认 true;登录引导保持 false——把登录页留给用户) */
|
|
67
|
+
closeOwnPage?: boolean
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function devtoolsWsEndpoint(): { ws: string } | { err: string } {
|
|
71
|
+
try {
|
|
72
|
+
const udd = process.env.CHROME_USER_DATA_DIR ?? `${homedir()}/Library/Application Support/Google/Chrome`
|
|
73
|
+
const [port, wsPath] = readFileSync(`${udd}/DevToolsActivePort`, 'utf8').trim().split('\n')
|
|
74
|
+
if (!port || !wsPath?.startsWith('/devtools/browser/')) {
|
|
75
|
+
return { err: `DevToolsActivePort 内容异常: ${String(port)}/${String(wsPath)}` }
|
|
76
|
+
}
|
|
77
|
+
return { ws: `ws://127.0.0.1:${port.trim()}${wsPath.trim()}` }
|
|
78
|
+
} catch {
|
|
79
|
+
return { err: '日常 Chrome 未开调试端口。开启方法:Chrome 打开 chrome://inspect/#remote-debugging → 打开开关(Chrome 144+)' }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function openSession(opts: TransportOptions = {}): Promise<SessionTransport | TransportFailure> {
|
|
84
|
+
const pp = await loadPuppeteer()
|
|
85
|
+
if ('missing' in pp) {
|
|
86
|
+
return { ok: false, summary: 'puppeteer-core 未安装(可选依赖):会话检索不可用,官方通道 gotry_flyai_search 仍可用。安装:npm i -D puppeteer-core' }
|
|
87
|
+
}
|
|
88
|
+
const puppeteer = pp.default
|
|
89
|
+
const useCdp = opts.mode === 'cdp' || (opts.mode !== 'persistent' && !opts.profileDir)
|
|
90
|
+
let browser: Browser
|
|
91
|
+
let isCdp = false
|
|
92
|
+
if (useCdp) {
|
|
93
|
+
const d = devtoolsWsEndpoint()
|
|
94
|
+
if ('err' in d) return { ok: false, summary: d.err }
|
|
95
|
+
try {
|
|
96
|
+
browser = await puppeteer.connect({ browserWSEndpoint: d.ws, defaultViewport: null })
|
|
97
|
+
isCdp = true
|
|
98
|
+
} catch (e) {
|
|
99
|
+
const msg = e instanceof Error ? e.message : (e as { message?: string })?.message ?? JSON.stringify(e).slice(0, 200)
|
|
100
|
+
return { ok: false, summary: `cdp attach 失败:${String(msg).split('\n')[0]}` }
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
const { tmpdir } = await import('node:os')
|
|
104
|
+
const profileDir = opts.profileDir ?? `${tmpdir()}/gotry-session-profile`
|
|
105
|
+
try {
|
|
106
|
+
browser = await puppeteer.launch({ channel: 'chrome', headless: opts.headless ?? true, userDataDir: profileDir })
|
|
107
|
+
} catch (e) {
|
|
108
|
+
return { ok: false, summary: `chrome launch failed: ${e instanceof Error ? e.message.split('\n')[0] : String(e)}` }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// fail-closed:guard 装不上即断开返回失败——不给无守卫的检索会话形态
|
|
112
|
+
// (唯一豁免:登录 bootstrap 显式 guard:false,见 TransportOptions 注释)
|
|
113
|
+
let guard: ReadGuardHandle | undefined
|
|
114
|
+
if (opts.guard !== false) {
|
|
115
|
+
try {
|
|
116
|
+
guard = await attachReadGuardPuppeteer(browser as unknown as Parameters<typeof attachReadGuardPuppeteer>[0], opts.auditPath)
|
|
117
|
+
} catch (e) {
|
|
118
|
+
await (isCdp ? browser.disconnect() : browser.close()).catch(() => { /* ignore */ })
|
|
119
|
+
return { ok: false, summary: `read-guard attach failed: ${e instanceof Error ? e.message.split('\n')[0] : String(e)}` }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// 标签页纪律:ownPage=自己开的新页(newPage:true)——用它,收尾按 closeOwnPage 关;
|
|
123
|
+
// 否则沿用既有首页(仅 persistent 兼容形态;cdp 检索/登录一律 newPage)
|
|
124
|
+
let ownPage: boolean = false
|
|
125
|
+
let page
|
|
126
|
+
if (opts.newPage) {
|
|
127
|
+
page = await browser.newPage()
|
|
128
|
+
ownPage = true
|
|
129
|
+
} else {
|
|
130
|
+
page = (await browser.pages())[0] ?? await browser.newPage()
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
ok: true,
|
|
134
|
+
browser,
|
|
135
|
+
page,
|
|
136
|
+
guard: guard ?? { blockedCount: () => 0, requestCount: () => 0 },
|
|
137
|
+
close: async () => {
|
|
138
|
+
// 自己开的标签页按 closeOwnPage 收尾(登录引导保持 false——登录页留给用户);
|
|
139
|
+
// cdp:只断开连接,绝不关用户浏览器;persistent:关自己拉起的实例
|
|
140
|
+
if (ownPage && (opts.closeOwnPage ?? true)) {
|
|
141
|
+
await (page as { close(): Promise<void> }).close().catch(() => { /* ignore */ })
|
|
142
|
+
}
|
|
143
|
+
await (isCdp ? browser.disconnect() : browser.close()).catch(() => { /* ignore */ })
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会话扩展 onboarding wizard(RFC docs/rfc/user-session-data-rfc.md §3.3,ADR-21 上架后重设)。
|
|
3
|
+
*
|
|
4
|
+
* 单一职责(2026-09-02 重设):**只做 Node 端两件事**——
|
|
5
|
+
* ① 扩展文件从源落位到 `~/.gotry/extension`(幂等)
|
|
6
|
+
* ② source/dest 静态预检 + manifest.key 校验(给 health-watch 前的快照)
|
|
7
|
+
*
|
|
8
|
+
* 浏览器商店安装是浏览器的事,dsh 渲染 verdict.installUrl 是 dsh UI 的事;
|
|
9
|
+
* gotry **不再**弹 GUI 面板(pbcopy/osascript/zenity/msg)、不再 open 浏览器、
|
|
10
|
+
* 不再写一墙文字 CLI 指引。任何"装到能用"的 UX 都由浏览器商店 + dsh UI 分担。
|
|
11
|
+
*
|
|
12
|
+
* 历史形态回顾:
|
|
13
|
+
* - 2026-08-30 初版:5 步编排 + 剪贴板 + GUI 面板 + 健康探活(全栈闭环初衷好,但越界管了浏览器)
|
|
14
|
+
* - 2026-09-02 上架后:缩为 2 步(ensure + watch precheck),纯 Node 职责
|
|
15
|
+
*
|
|
16
|
+
* 接口契约:
|
|
17
|
+
* - `runOnboardingWizard({ dryRun, extensionDir?, sourceDir? })` 返回 2 步 OnboardingResult
|
|
18
|
+
* - `defaultExtensionDir()` / `describeExtensionDir()` 留作公开工具
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs'
|
|
22
|
+
import { homedir } from 'node:os'
|
|
23
|
+
import { join } from 'node:path'
|
|
24
|
+
|
|
25
|
+
export interface OnboardingStep {
|
|
26
|
+
step: 'ensure-extension-files' | 'watch-extension-ready'
|
|
27
|
+
status: 'ok' | 'skip' | 'fail'
|
|
28
|
+
summary: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface OnboardingOptions {
|
|
32
|
+
/** 零网络零浏览器;只校验命令编排与输出形态;run-all §40 必走 */
|
|
33
|
+
dryRun?: boolean
|
|
34
|
+
/** 扩展落位目录(默认 ~/.gotry/extension) */
|
|
35
|
+
extensionDir?: string
|
|
36
|
+
/** 源扩展目录(默认仓库 ./extension/,随 npm 装入 dist/extension) */
|
|
37
|
+
sourceDir?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface OnboardingResult {
|
|
41
|
+
ok: boolean
|
|
42
|
+
steps: OnboardingStep[]
|
|
43
|
+
extensionDir: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const DEFAULT_SOURCE_DIR_CANDIDATES = [
|
|
47
|
+
join(process.cwd(), 'extension'),
|
|
48
|
+
join(process.cwd(), 'dist', 'extension'),
|
|
49
|
+
join(process.cwd(), 'ts', '..', 'extension'),
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
function resolveExtensionSourceDir(): string {
|
|
53
|
+
for (const candidate of DEFAULT_SOURCE_DIR_CANDIDATES) {
|
|
54
|
+
if (existsSync(join(candidate, 'manifest.json'))) return candidate
|
|
55
|
+
}
|
|
56
|
+
return DEFAULT_SOURCE_DIR_CANDIDATES[0]!
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function defaultExtensionDir(): string {
|
|
60
|
+
return join(homedir(), '.gotry', 'extension')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 落位扩展文件(幂等);缺源/源不全会 fail-soft,提示用户重跑 `gotry setup` */
|
|
64
|
+
function ensureExtensionFiles(source: string, target: string, dryRun: boolean): OnboardingStep {
|
|
65
|
+
if (dryRun) return { step: 'ensure-extension-files', status: 'skip', summary: '[dry-run] skip 扩展落位' }
|
|
66
|
+
try {
|
|
67
|
+
if (!existsSync(source) || !existsSync(join(source, 'manifest.json'))) {
|
|
68
|
+
return { step: 'ensure-extension-files', status: 'fail', summary: `源扩展目录缺失 manifest.json: ${source}(先跑 npx @danceiny/gotry setup 落位)` }
|
|
69
|
+
}
|
|
70
|
+
mkdirSync(target, { recursive: true })
|
|
71
|
+
const required = ['manifest.json', 'background.js', 'content-main.js', 'content-bridge.js']
|
|
72
|
+
for (const f of required) {
|
|
73
|
+
const src = join(source, f)
|
|
74
|
+
if (!existsSync(src)) return { step: 'ensure-extension-files', status: 'fail', summary: `源扩展缺 ${f}(重新 npm install 或 gotry setup)` }
|
|
75
|
+
copyFileSync(src, join(target, f))
|
|
76
|
+
}
|
|
77
|
+
return { step: 'ensure-extension-files', status: 'ok', summary: `扩展已落位 ${target}(manifest+3 文件)` }
|
|
78
|
+
} catch (e) {
|
|
79
|
+
return { step: 'ensure-extension-files', status: 'fail', summary: `扩展落位失败: ${e instanceof Error ? e.message.slice(0, 120) : String(e)}` }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 静态预检:落位目录可见 + manifest.key 存在(扩展 ID 稳定)+ 源未新于 dest */
|
|
84
|
+
async function watchExtensionReady(dryRun: boolean, sourceDir: string, extensionDir: string): Promise<OnboardingStep> {
|
|
85
|
+
if (dryRun) return { step: 'watch-extension-ready', status: 'skip', summary: '[dry-run] skip health-watch precheck' }
|
|
86
|
+
if (!existsSync(extensionDir) || !existsSync(join(extensionDir, 'manifest.json'))) {
|
|
87
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: `落位缺失 manifest.json:${extensionDir}` }
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const srcStat = statSync(sourceDir)
|
|
91
|
+
const dstStat = statSync(extensionDir)
|
|
92
|
+
if (srcStat.mtimeMs > dstStat.mtimeMs) {
|
|
93
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: `扩展文件可能过期(源比落位新);重跑 npx @danceiny/gotry setup` }
|
|
94
|
+
}
|
|
95
|
+
const manifest = JSON.parse(await (await import('node:fs/promises')).readFile(join(extensionDir, 'manifest.json'), 'utf8'))
|
|
96
|
+
if (typeof manifest.key !== 'string' || manifest.key.length < 100) {
|
|
97
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: 'manifest.key 缺失或过短,扩展 ID 不能稳定' }
|
|
98
|
+
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: `静态预检失败: ${e instanceof Error ? e.message.slice(0, 120) : String(e)}` }
|
|
101
|
+
}
|
|
102
|
+
return { step: 'watch-extension-ready', status: 'ok', summary: '扩展文件就绪(manifest.key 校验通过,后台轮询就绪态由 health-watch 接管)' }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 主入口(2 步):①扩展落位 ②watch precheck 静态预检。
|
|
107
|
+
* 真 health-watch 由 health-watch.ts 单独负责,不并入 wizard。
|
|
108
|
+
*/
|
|
109
|
+
export async function runOnboardingWizard(opts: OnboardingOptions = {}): Promise<OnboardingResult> {
|
|
110
|
+
const dryRun = opts.dryRun ?? false
|
|
111
|
+
const extensionDir = opts.extensionDir ?? defaultExtensionDir()
|
|
112
|
+
const sourceDir = opts.sourceDir ?? resolveExtensionSourceDir()
|
|
113
|
+
|
|
114
|
+
const steps: OnboardingStep[] = []
|
|
115
|
+
steps.push(ensureExtensionFiles(sourceDir, extensionDir, dryRun))
|
|
116
|
+
steps.push(await watchExtensionReady(dryRun, sourceDir, extensionDir))
|
|
117
|
+
|
|
118
|
+
const ok = steps.every((s) => s.status !== 'fail')
|
|
119
|
+
return { ok, steps, extensionDir }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** stdout 人话化打印(给 bootstrap 子进程单行 JSON 输出之外的兜底形态) */
|
|
123
|
+
export function printWizardResult(result: OnboardingResult, destination: NodeJS.WritableStream = process.stdout): void {
|
|
124
|
+
const tag = (s: OnboardingStep): string => {
|
|
125
|
+
if (s.status === 'ok') return '✅'
|
|
126
|
+
if (s.status === 'skip') return '⏭ '
|
|
127
|
+
return '❌'
|
|
128
|
+
}
|
|
129
|
+
for (const s of result.steps) {
|
|
130
|
+
destination.write(`${tag(s)} ${s.step}: ${s.summary}\n`)
|
|
131
|
+
}
|
|
132
|
+
destination.write(`extensionDir=${result.extensionDir}; overall=${result.ok ? 'ok' : 'has-failures'}\n`)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** 公开诊断探针(bootstrap 报告用) */
|
|
136
|
+
export function describeExtensionDir(extensionDir: string): { exists: boolean; fileCount: number; hasManifest: boolean } {
|
|
137
|
+
if (!existsSync(extensionDir)) return { exists: false, fileCount: 0, hasManifest: false }
|
|
138
|
+
const files = readdirSync(extensionDir)
|
|
139
|
+
return { exists: true, fileCount: files.length, hasManifest: files.includes('manifest.json') }
|
|
140
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionConsent——账号会话授权闸(RFC 合规支柱④「用户明示授权 + 站点白名单 + 随时可关」进代码)。
|
|
3
|
+
*
|
|
4
|
+
* founder 口径(2026-08-29):「OTA 这些都是工具,不要区分什么主路径/降级路径;
|
|
5
|
+
* 这要用到用户的账号,所以必须跟用户确认(请求授权)。」
|
|
6
|
+
* 运行时原生审批卡语义是 allowed-once(逐调用批准)——首日落地后 founder 实测纠偏:
|
|
7
|
+
* 「每次都要弹,经常无法点击」→ 逐次弹卡把授权变成了骚扰。授权模型 v2:
|
|
8
|
+
*
|
|
9
|
+
* - 每会话每站点**首次调用**弹审批卡;allowed-once 记入该 agent 的 granted 集,
|
|
10
|
+
* 会话内同站点后续调用直接放行(不再弹);
|
|
11
|
+
* - rejected/cancelled 视为**会话内吊销**(denied 集):本会话不再弹卡、不再执行,
|
|
12
|
+
* 返回值明确告诉模型「改走其他工具,不要反复尝试」——防止反复开页骚扰用户;
|
|
13
|
+
* - 审批通道缺席(unavailable,如 headless 一问一答)→ deny 且**不**记 denied
|
|
14
|
+
* (通道回来后还能问一次);
|
|
15
|
+
* - sessionAccess = 'ask'(默认)| 'allow'(用户已明示预授权,放行)| 'off'(随时可关);
|
|
16
|
+
* - 授权状态存 Weak<agent>——会话结束即遗忘,绝不跨会话持久化(明示授权不默认延续)。
|
|
17
|
+
* 审计:批准/拒绝事件由 dsh ApprovalService 落 session log(approval/asked + decided),
|
|
18
|
+
* 本模块不重复建账。站点白名单 = ACCOUNT_TOOLS 注册表(新会话适配器接入时登记)。
|
|
19
|
+
*
|
|
20
|
+
* site 绑定(2026-09-10 #308):同一工具多个 kind(例如 gotry_session_search → flight/hotel/dida/train)
|
|
21
|
+
* 必须按与 execute 同源的 interpretArgs 选 site(包装 query 优先);授权与拒绝均按 site
|
|
22
|
+
* 分桶。缺省 kind 保持工具合同的 flight 默认值;unknown/malformed kind 失败关闭(deny,
|
|
23
|
+
* 不扩权),防止新站点未登记就放行。train 虽是 12306 公开查询面,仍经过本闸的 off/ask/allow。
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
27
|
+
import { interpretArgs } from '../src/tool-packet.ts'
|
|
28
|
+
|
|
29
|
+
export type SessionAccess = 'ask' | 'allow' | 'off'
|
|
30
|
+
export type ApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable'
|
|
31
|
+
|
|
32
|
+
/** dsh-tools PreToolDecision 同构(自持类型,纯函数可离线测试) */
|
|
33
|
+
export type ConsentDecision =
|
|
34
|
+
| { kind: 'allow' }
|
|
35
|
+
| { kind: 'deny'; reason: string }
|
|
36
|
+
| { kind: 'ask'; reason?: string }
|
|
37
|
+
|
|
38
|
+
export interface ApprovalSeam {
|
|
39
|
+
request(r: { agent?: unknown; toolName: string; callId?: string; reason?: string; signal?: AbortSignal }): Promise<ApprovalOutcome>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 工具级 site 表(无 kind 维度时使用):key=工具名,value=站点。
|
|
44
|
+
* 复合工具(同一名字下多 kind)在 SITE_FOR_KIND 中显式登记。
|
|
45
|
+
*/
|
|
46
|
+
export const ACCOUNT_TOOLS: Record<string, string> = {
|
|
47
|
+
gotry_session_search: 'ctrip-flight',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const SITE_LABEL: Record<string, string> = {
|
|
51
|
+
'ctrip-flight': '携程机票',
|
|
52
|
+
'ctrip-hotel': '携程酒店',
|
|
53
|
+
'dida-portal': 'Dida 供应商门户',
|
|
54
|
+
'train-12306': '12306 余票(公开查询面)',
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 复合工具 × kind → site(#308:site 绑定)。
|
|
59
|
+
* 仅对显式登记的 kind 放行,未知 kind → 失败关闭(防止未登记站点扩权)。
|
|
60
|
+
* 12306 公开查询面(kind=train)仍受本工具的会话授权总闸约束,不因公开查询而绕过 off/ask/allow。
|
|
61
|
+
*/
|
|
62
|
+
export const SITE_FOR_KIND: Record<string, Record<string, string>> = {
|
|
63
|
+
gotry_session_search: {
|
|
64
|
+
flight: 'ctrip-flight',
|
|
65
|
+
hotel: 'ctrip-hotel',
|
|
66
|
+
dida: 'dida-portal',
|
|
67
|
+
train: 'train-12306',
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface AuthState {
|
|
72
|
+
granted: Set<string>
|
|
73
|
+
denied: Set<string>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ConsentGateOptions {
|
|
77
|
+
/** 主闸语义:ask=每会话每站点首调弹卡(默认);allow=配置级预授权放行;off=总闸关 */
|
|
78
|
+
access: () => string
|
|
79
|
+
/** 审批缝懒解析(审批服务晚于插件注册,与 dsh-tools serviceAsk 同协议,缺席=运行时原生 ask→fail-closed) */
|
|
80
|
+
approval?: () => ApprovalSeam | undefined
|
|
81
|
+
/** 授权状态仓(Weak:随 agent/会话回收;测试注入) */
|
|
82
|
+
store?: WeakMap<object, AuthState>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type ConsentExec = { name?: string; agent?: object; callId?: string; arguments?: unknown }
|
|
86
|
+
export type ConsentGate = (exec: ConsentExec, next: () => Promise<ConsentDecision>) => Promise<ConsentDecision>
|
|
87
|
+
|
|
88
|
+
/** 会话检索工具支持的 kind;gate 与 execute 共用此选择结果。 */
|
|
89
|
+
export const SESSION_SEARCH_KINDS = ['flight', 'hotel', 'train', 'dida'] as const
|
|
90
|
+
export type SessionSearchKind = typeof SESSION_SEARCH_KINDS[number]
|
|
91
|
+
|
|
92
|
+
export type SessionSearchKindSelection =
|
|
93
|
+
| { ok: true; kind: SessionSearchKind }
|
|
94
|
+
| { ok: false; reason: string }
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Select the kind exactly as the session tool execute path does.
|
|
98
|
+
* `interpretArgs` is intentionally the only query-wrapper normalizer: a
|
|
99
|
+
* wrapped query wins over conflicting flat fields, and omitted kind keeps the
|
|
100
|
+
* documented flight default. Explicit malformed/unknown kinds fail closed.
|
|
101
|
+
*/
|
|
102
|
+
export function resolveSessionSearchKind(args: unknown): SessionSearchKindSelection {
|
|
103
|
+
if (args === undefined) return { ok: true, kind: 'flight' }
|
|
104
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
105
|
+
return { ok: false, reason: 'gotry_session_search 参数必须是对象;无法安全选择 kind,已失败关闭' }
|
|
106
|
+
}
|
|
107
|
+
const selected = interpretArgs<{ kind?: unknown }>(args as { query?: unknown } & Record<string, unknown>)
|
|
108
|
+
if (!selected || typeof selected !== 'object' || Array.isArray(selected)) {
|
|
109
|
+
return { ok: false, reason: 'gotry_session_search 参数包装形态无效;无法安全选择 kind,已失败关闭' }
|
|
110
|
+
}
|
|
111
|
+
if (!Object.prototype.hasOwnProperty.call(selected, 'kind')) return { ok: true, kind: 'flight' }
|
|
112
|
+
const kind = (selected as { kind?: unknown }).kind
|
|
113
|
+
if (typeof kind !== 'string' || kind.length === 0) {
|
|
114
|
+
return { ok: false, reason: 'gotry_session_search 收到 malformed kind;无法安全选择站点,已失败关闭' }
|
|
115
|
+
}
|
|
116
|
+
if (!(SESSION_SEARCH_KINDS as readonly string[]).includes(kind)) {
|
|
117
|
+
return { ok: false, reason: `gotry_session_search 收到未知 kind=${kind};只支持 ${SESSION_SEARCH_KINDS.join('/')},未知 kind 失败关闭` }
|
|
118
|
+
}
|
|
119
|
+
return { ok: true, kind: kind as SessionSearchKind }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 解析 site(#308):对复合工具(缺省 kind=flight,未知/malformed kind → fail-closed);对未在
|
|
124
|
+
* SITE_FOR_KIND 登记的工具走原 ACCOUNT_TOOLS 表保持兼容。无 site → 放行(非账号面工具)。
|
|
125
|
+
*/
|
|
126
|
+
export function resolveSiteForExec(exec: ConsentExec): { site: string } | { failClosed: true; reason: string } | null {
|
|
127
|
+
const name = exec.name
|
|
128
|
+
if (!name) return null
|
|
129
|
+
const map = SITE_FOR_KIND[name]
|
|
130
|
+
if (map) {
|
|
131
|
+
const selected = resolveSessionSearchKind(exec.arguments)
|
|
132
|
+
if (!selected.ok) return { failClosed: true, reason: selected.reason }
|
|
133
|
+
const site = map[selected.kind]
|
|
134
|
+
if (!site) return { failClosed: true, reason: `工具 ${name} 的 kind=${selected.kind} 未登记站点;失败关闭` }
|
|
135
|
+
return { site }
|
|
136
|
+
}
|
|
137
|
+
const site = ACCOUNT_TOOLS[name]
|
|
138
|
+
if (!site) return null
|
|
139
|
+
return { site }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function reasonFor(toolName: string, site: string): string {
|
|
143
|
+
return `工具 ${toolName} 将使用你本人已登录的浏览器会话,在「${SITE_LABEL[site] ?? site}」进行只读检索`
|
|
144
|
+
+ '(ReadGuard 物理只读:写请求在网络层即中止,agent 永不接触凭证与验证码);'
|
|
145
|
+
+ '本次批准仅在本会话内有效,会话结束即失效,不会跨会话延续。'
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 账号会话授权闸:挂 dsh `tools/pre-execute` waterfall。
|
|
150
|
+
* 契约:
|
|
151
|
+
* - 非账号面工具 → next() 放行(零开销);
|
|
152
|
+
* - off → 拒绝(随时可关);
|
|
153
|
+
* - 会话内已拒绝 → 拒绝且不弹卡(拒绝=本会话吊销;按 site 分桶,跨站不互授);
|
|
154
|
+
* - 会话内已批准 / allow 预授权 → 放行;
|
|
155
|
+
* - 复合工具未知/malformed kind → fail-closed deny(不扩权),缺省 kind=flight;
|
|
156
|
+
* - 其余 → ApprovalService.request();allowed-once 按 site 入会话 granted;
|
|
157
|
+
* rejected/cancelled 按 site 入会话 denied(本会话不在请求);
|
|
158
|
+
* 无审批通道 → deny(fail-closed,headless 无用户 = 无授权)。
|
|
159
|
+
*/
|
|
160
|
+
export function createConsentGate(opts: ConsentGateOptions): ConsentGate {
|
|
161
|
+
const store = opts.store ?? new WeakMap<object, AuthState>()
|
|
162
|
+
const approvalOf = opts.approval ?? (() => undefined)
|
|
163
|
+
return async (exec, next) => {
|
|
164
|
+
const resolved = resolveSiteForExec(exec)
|
|
165
|
+
if (!resolved) return next()
|
|
166
|
+
if ('failClosed' in resolved) return { kind: 'deny', reason: resolved.reason }
|
|
167
|
+
const { site } = resolved
|
|
168
|
+
if ((opts.access() ?? 'ask') === 'off') {
|
|
169
|
+
return { kind: 'deny', reason: `工具 ${exec.name} 已被配置关闭(sessionAccess=off)。如需重新启用账号会话检索,请到配置中重新开启 sessionAccess。` }
|
|
170
|
+
}
|
|
171
|
+
const state = (exec.agent && store.get(exec.agent)) || undefined
|
|
172
|
+
if (state?.denied.has(site)) {
|
|
173
|
+
return { kind: 'deny', reason: `你已在本会话拒绝过「${SITE_LABEL[site] ?? site}」的账号会话检索。为避免反复打扰,本会话不再请求授权,请改用其他工具继续推进。` }
|
|
174
|
+
}
|
|
175
|
+
if (state?.granted.has(site) || (opts.access() === 'allow' && exec.agent)) return next()
|
|
176
|
+
const approval = opts.approval?.()
|
|
177
|
+
if (!approval || !exec.agent) return { kind: 'ask', reason: reasonFor(exec.name ?? '', site) }
|
|
178
|
+
let outcome: string
|
|
179
|
+
try {
|
|
180
|
+
outcome = await approval.request({ agent: exec.agent, toolName: exec.name ?? '', callId: exec.callId, reason: reasonFor(exec.name ?? '', site) })
|
|
181
|
+
} catch {
|
|
182
|
+
outcome = 'unavailable'
|
|
183
|
+
}
|
|
184
|
+
if (outcome === 'allowed-once') {
|
|
185
|
+
remember(store, exec.agent, site, 'grant')
|
|
186
|
+
return next()
|
|
187
|
+
}
|
|
188
|
+
if (outcome === 'rejected' || outcome === 'cancelled') {
|
|
189
|
+
remember(store, exec.agent, site, 'deny')
|
|
190
|
+
return { kind: 'deny', reason: `你刚刚拒绝了工具 ${exec.name} 的账号会话授权(本次拒绝仅在本会话内生效)。为避免反复打扰,本会话不再重复请求授权,请改用其他工具继续推进。` }
|
|
191
|
+
}
|
|
192
|
+
return { kind: 'deny', reason: `工具 ${exec.name} 需要你授权,但当前没有可用的审批通道。在 headless 一问一答场景下没有审批界面,请改用 web 会话来使用账号会话检索。` }
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function remember(store: WeakMap<object, AuthState>, agent: object, site: string, mode: 'grant' | 'deny'): void {
|
|
197
|
+
const prev = store.get(agent) ?? { granted: new Set<string>(), denied: new Set<string>() }
|
|
198
|
+
if (mode === 'grant') prev.granted.add(site)
|
|
199
|
+
else prev.denied.add(site)
|
|
200
|
+
store.set(agent, prev)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** 从运行时上下文懒解析审批缝(与 dsh-tools serviceAsk 的 ctx.get('approval') 同一协议) */
|
|
204
|
+
export function approvalFromContext(ctx: Context): () => ApprovalSeam | undefined {
|
|
205
|
+
return () => {
|
|
206
|
+
const get = (ctx as unknown as { get?: (n: string) => unknown }).get
|
|
207
|
+
if (typeof get !== 'function') return undefined
|
|
208
|
+
const approval = get.call(ctx, 'approval') as ApprovalSeam | undefined
|
|
209
|
+
return approval && typeof approval.request === 'function' ? approval : undefined
|
|
210
|
+
}
|
|
211
|
+
}
|