@danceiny/gotry 0.0.1-rc.21 → 0.0.1-rc.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -194
- package/README.zh-CN.md +115 -210
- package/bin/gotry-backend.js +53 -0
- package/bin/gotry-bootstrap.js +466 -35
- package/bin/gotry-inner.js +255 -36
- package/bin/gotry-process-liveness.d.ts +27 -0
- package/bin/gotry-process-liveness.js +97 -0
- package/bin/gotry-runtime-resolution.d.ts +1 -1
- package/bin/gotry-runtime-resolution.js +2 -2
- package/client/client.js +174 -0
- package/cordis.gotry-patch.yml +70 -93
- package/dist/capabilities/agent-reach-deep.js +45 -122
- package/dist/capabilities/agent-reach.js +63 -148
- package/dist/capabilities/anything.js +89 -75
- package/dist/capabilities/artifacts.js +123 -104
- package/dist/capabilities/channel-health.js +65 -45
- package/dist/capabilities/channel-registry.js +108 -87
- package/dist/capabilities/doctor.js +357 -235
- package/dist/capabilities/effect.js +223 -309
- package/dist/capabilities/fact-log.js +28 -14
- package/dist/capabilities/flyai.js +245 -156
- package/dist/capabilities/ground-transfer.js +509 -0
- package/dist/capabilities/hbcli.js +144 -148
- package/dist/capabilities/hotelbyte-transaction.js +194 -0
- package/dist/capabilities/incident-log.js +131 -61
- package/dist/capabilities/model-override.js +30 -10
- package/dist/capabilities/opensky.js +54 -43
- package/dist/capabilities/resilience.js +50 -32
- package/dist/capabilities/session/action-cache.js +50 -44
- package/dist/capabilities/session/adapters/ctrip-flight.js +119 -62
- package/dist/capabilities/session/adapters/ctrip-hotel.js +125 -110
- package/dist/capabilities/session/adapters/dida-portal.js +206 -0
- package/dist/capabilities/session/adapters/meituan-local.js +35 -54
- package/dist/capabilities/session/adapters/rail-12306.js +169 -112
- package/dist/capabilities/session/benchmark.js +85 -149
- package/dist/capabilities/session/extension-bridge.js +320 -259
- package/dist/capabilities/session/extension-channel.js +57 -76
- package/dist/capabilities/session/extension-distribution.js +115 -119
- package/dist/capabilities/session/extract.js +31 -21
- package/dist/capabilities/session/golden-score.js +55 -33
- package/dist/capabilities/session/health-watch.js +146 -154
- package/dist/capabilities/session/read-guard.js +55 -47
- package/dist/capabilities/session/static-flight-golden.js +49 -36
- package/dist/capabilities/session/transport.js +54 -61
- package/dist/capabilities/session/wizard.js +63 -93
- package/dist/capabilities/session-consent.js +143 -47
- package/dist/capabilities/session-login.js +95 -126
- package/dist/capabilities/session-search.js +391 -253
- package/dist/capabilities/sponsor-plugin.js +341 -0
- package/dist/capabilities/visa-policy.js +87 -73
- package/dist/capabilities/weather.js +163 -235
- package/dist/scripts/action-cache-tests.js +24 -59
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +91 -142
- package/dist/scripts/agent-planning-turn-deadline-tests.js +80 -176
- package/dist/scripts/agent-reach-deep-tests.js +30 -40
- package/dist/scripts/agent-reach-tests.js +26 -18
- package/dist/scripts/agent-reach-wrapper-tests.js +46 -50
- package/dist/scripts/anything-tests.js +58 -62
- package/dist/scripts/artifact-client-contract-tests.js +69 -0
- package/dist/scripts/artifacts-capability-tests.js +235 -0
- package/dist/scripts/async-collect.js +26 -15
- package/dist/scripts/benchmark-environment-bridge-e2e.js +287 -684
- package/dist/scripts/benchmark-environment-bridge-tests.js +818 -3123
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +66 -279
- package/dist/scripts/booking-copilot-availability-policy-tests.js +153 -1257
- package/dist/scripts/booking-copilot-bin-proof-tests.js +22 -45
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +64 -76
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +69 -199
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +393 -759
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +33 -75
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +60 -110
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +28 -66
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +72 -271
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +73 -275
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +784 -3398
- package/dist/scripts/booking-copilot-server-proof-tests.js +63 -168
- package/dist/scripts/booking-copilot-startup-proof-tests.js +38 -124
- package/dist/scripts/booking-executor-tests.js +80 -0
- package/dist/scripts/booking-recovery-chain-tests.js +182 -0
- package/dist/scripts/booking-saga-tests.js +61 -123
- package/dist/scripts/booking-surface-contract-proof-tests.js +152 -1167
- package/dist/scripts/bootstrap-tests.js +1383 -128
- package/dist/scripts/build-changelog.js +89 -130
- package/dist/scripts/build-metrics-report.js +135 -143
- package/dist/scripts/changelog-tests.js +35 -82
- package/dist/scripts/channel-probe-tests.js +44 -116
- package/dist/scripts/channel-probe.js +84 -167
- package/dist/scripts/channel-registry-tests.js +97 -185
- package/dist/scripts/companion-tests.js +25 -70
- package/dist/scripts/dida-cookie-probe.js +87 -0
- package/dist/scripts/dida-sw-probe.js +114 -0
- package/dist/scripts/diff-test.js +17 -12
- package/dist/scripts/doctor-tests.js +428 -120
- package/dist/scripts/dsh-artifact-e2e.js +150 -0
- package/dist/scripts/dsh-artifact-web-e2e.js +443 -0
- package/dist/scripts/dsh-http-proxy-sse-proof.js +90 -0
- package/dist/scripts/dsh-runtime-closure-tests.js +110 -153
- package/dist/scripts/dsh-runtime-closure.js +75 -63
- package/dist/scripts/dsh-session-v3-migration-proof.js +106 -0
- package/dist/scripts/dsh-subprocess-local-proof.js +149 -0
- package/dist/scripts/dsh-target-closure-proof.js +178 -0
- package/dist/scripts/effect-tests.js +165 -552
- package/dist/scripts/engine-run.js +1 -3
- package/dist/scripts/engine-tests.js +16 -10
- package/dist/scripts/evaluation-cadence-tests.js +69 -242
- package/dist/scripts/evaluation-contract-tests.js +193 -499
- package/dist/scripts/extension-distribution-cli.js +19 -15
- package/dist/scripts/extension-distribution-tests.js +98 -211
- package/dist/scripts/extension-tests.js +366 -389
- package/dist/scripts/fact-gate-tests.js +725 -263
- package/dist/scripts/fixtures/extension-bridge-unref-child.mjs +21 -0
- package/dist/scripts/flight-hotel-anchor-363-registered-e2e.js +169 -0
- package/dist/scripts/flight-malformed-tests.js +159 -0
- package/dist/scripts/flyai-tests.js +325 -68
- package/dist/scripts/g5-guard-tests.js +131 -0
- package/dist/scripts/g5-guard.js +189 -0
- package/dist/scripts/gen-lunar-anchors.js +106 -0
- package/dist/scripts/gotry-backend-kernel-tests.js +79 -0
- package/dist/scripts/ground-transfer-tests.js +956 -0
- package/dist/scripts/hbcli-e2e-tests.js +71 -90
- package/dist/scripts/hbcli-live-optin-tests.js +96 -0
- package/dist/scripts/hbcli-release-contract-tests.js +122 -0
- package/dist/scripts/hbcli-tests.js +41 -115
- package/dist/scripts/health-watch-cli.js +42 -28
- package/dist/scripts/hotel-date-gate-tests.js +496 -0
- package/dist/scripts/hotelbyte-reconcile-tests.js +141 -0
- package/dist/scripts/hotelbyte-spawn-e2e-tests.js +373 -0
- package/dist/scripts/i18n-tests.js +16 -9
- package/dist/scripts/incident-tests.js +281 -87
- package/dist/scripts/issue-194-job-id-guard-tests.js +106 -0
- package/dist/scripts/issue-233-cancel-refund-commission-tests.js +392 -0
- package/dist/scripts/issue-271-liveness-tests.js +547 -0
- package/dist/scripts/issue-289-model-retry-real-tests.js +296 -0
- package/dist/scripts/issue-289-model-retry-tests.js +441 -0
- package/dist/scripts/issue-289-web-retry-e2e.js +630 -0
- package/dist/scripts/issue-338-home-city-e2e.js +577 -0
- package/dist/scripts/issue343-real-entry-e2e.js +160 -0
- package/dist/scripts/journey-tests.js +22 -27
- package/dist/scripts/kernel-manifest-evidence.js +109 -0
- package/dist/scripts/kernel-manifest-gate.js +126 -0
- package/dist/scripts/kernel-manifest-tests.js +212 -0
- package/dist/scripts/kernel-manifest-trace-entry.js +7 -0
- package/dist/scripts/kernel-manifest-trace-hook.mjs +28 -0
- package/dist/scripts/kernel-manifest.js +369 -0
- package/dist/scripts/ledger-repair-apply-tests.js +316 -0
- package/dist/scripts/ledger-repair-plan-tests.js +375 -0
- package/dist/scripts/ledger-tests.js +325 -340
- package/dist/scripts/ledger-workflow-crash.js +10 -20
- package/dist/scripts/map-tools-vendor-package-proof.js +206 -134
- package/dist/scripts/memory-capture-tests.js +242 -61
- package/dist/scripts/memory-decay-tests.js +18 -52
- package/dist/scripts/memory-lifecycle-tests.js +657 -0
- package/dist/scripts/memory-lifecycle.js +196 -0
- package/dist/scripts/memory-metrics.js +24 -12
- package/dist/scripts/memory-value-report.js +474 -222
- package/dist/scripts/memory-value-tests.js +328 -0
- package/dist/scripts/metrics-report-tests.js +62 -199
- package/dist/scripts/model-override-e2e.js +66 -105
- package/dist/scripts/nightly-evidence-tests.js +64 -89
- package/dist/scripts/nightly-evidence.js +108 -111
- package/dist/scripts/nudge-digest.js +39 -28
- package/dist/scripts/onboarding-tests.js +63 -88
- package/dist/scripts/opensky-check.js +18 -13
- package/dist/scripts/opensky-tests.js +28 -28
- package/dist/scripts/persona-surface-guard-tests.js +37 -12
- package/dist/scripts/pnpm-dsh-closure-proof.js +2 -5
- package/dist/scripts/policy-anchor-359-registered-e2e.js +214 -0
- package/dist/scripts/price-drift-tests.js +126 -227
- package/dist/scripts/price-drift-watch.js +209 -253
- package/dist/scripts/probe-poi-tests.js +52 -45
- package/dist/scripts/product-metrics.js +187 -273
- package/dist/scripts/publish-preverify.js +47 -41
- package/dist/scripts/realtime-pricing-tests.js +37 -76
- package/dist/scripts/replay-async.js +20 -18
- package/dist/scripts/replay-real.js +16 -18
- package/dist/scripts/replay.js +52 -82
- package/dist/scripts/session-attach-diagnose.js +16 -12
- package/dist/scripts/session-attach-poc.js +34 -37
- package/dist/scripts/session-benchmark.js +66 -147
- package/dist/scripts/session-dida-live-e2e.js +151 -0
- package/dist/scripts/session-extract-tests.js +14 -35
- package/dist/scripts/session-login.js +14 -13
- package/dist/scripts/session-tests.js +545 -583
- package/dist/scripts/sf-live-benchmark.js +92 -110
- package/dist/scripts/sf-live-cli-tests.js +2 -9
- package/dist/scripts/sf-soft-score-tests.js +19 -60
- package/dist/scripts/sf-summary-tests.js +149 -0
- package/dist/scripts/sf-summary.js +466 -84
- package/dist/scripts/skeleton-check.js +16 -14
- package/dist/scripts/skeleton-integration-test.js +11 -10
- package/dist/scripts/skills-contract-tests.js +51 -46
- package/dist/scripts/smoke-session-gate-tests.js +12 -20
- package/dist/scripts/smoke.js +541 -422
- package/dist/scripts/sponsor-reuse-tests.js +262 -0
- package/dist/scripts/state-cli-tests.js +226 -101
- package/dist/scripts/state-cli.js +549 -212
- package/dist/scripts/static-golden-tests.js +46 -180
- package/dist/scripts/time-eval-tests.js +210 -192
- package/dist/scripts/travel-timeline-tests.js +29 -93
- package/dist/scripts/turn-handoff-collect-tests.js +46 -93
- package/dist/scripts/turn-handoff-collect.js +71 -99
- package/dist/scripts/turn-policy-tests.js +28 -29
- package/dist/scripts/typed-contract-canary.js +77 -162
- package/dist/scripts/tz-resolver-sanity.js +50 -0
- package/dist/scripts/tz-resolver-tests.js +584 -0
- package/dist/scripts/unified-tests.js +23 -19
- package/dist/scripts/visa-policy-tests.js +31 -44
- package/dist/scripts/weather-tests.js +121 -543
- package/dist/scripts/wish-channel-gate-tests.js +29 -86
- package/dist/scripts/write-gate-tests.js +522 -0
- package/dist/scripts/z3-lifecycle-fault-tests.js +188 -0
- package/dist/scripts/z3-lifecycle-tests.js +170 -0
- package/dist/scripts/z3-race-repeat-tests.js +39 -0
- package/dist/scripts/z3-race-tests.js +18 -12
- package/dist/src/artifact-gate.js +652 -221
- package/dist/src/backend/kernel.js +91 -0
- package/dist/src/backend/modules/booking-copilot.js +55 -0
- package/dist/src/backend/modules/booking-executor.js +124 -0
- package/dist/src/backend/modules/session-search.js +194 -0
- package/dist/src/benchmark-agent-conformance.js +296 -262
- package/dist/src/benchmark-environment-bridge.js +298 -413
- package/dist/src/benchmark-headless-child-diagnostics.js +93 -100
- package/dist/src/benchmark-tool-isolation.js +94 -67
- package/dist/src/bookable-facts.js +299 -174
- package/dist/src/booking-saga.js +64 -120
- package/dist/src/booking-surface/availability-policy.js +443 -576
- package/dist/src/booking-surface/cancel-refund-commission.js +379 -0
- package/dist/src/booking-surface/contracts.js +24 -80
- package/dist/src/booking-surface/dsh-planner.js +510 -281
- package/dist/src/booking-surface/dsh-plugin.js +17 -1
- package/dist/src/booking-surface/error-codes.js +82 -10
- package/dist/src/booking-surface/index.js +0 -3
- package/dist/src/booking-surface/profile.js +10 -54
- package/dist/src/booking-surface/recovery-chain.js +367 -0
- package/dist/src/booking-surface/runtime.js +765 -891
- package/dist/src/booking-surface/server.js +200 -251
- package/dist/src/booking-surface/startup.js +58 -54
- package/dist/src/booking-surface/validation.js +150 -218
- package/dist/src/bridge.js +20 -13
- package/dist/src/companions.js +48 -74
- package/dist/src/contracts.js +21 -43
- package/dist/src/dsh-llm.js +82 -120
- package/dist/src/engine.js +253 -239
- package/dist/src/evaluation-cadence.js +72 -209
- package/dist/src/evaluation-contracts.js +220 -843
- package/dist/src/flight-pack-adapter.js +54 -0
- package/dist/src/flight-pack-contract.js +2 -0
- package/dist/src/gotry-backend.js +70 -0
- package/dist/src/hotel-date-gate.js +118 -0
- package/dist/src/i18n.js +18 -7
- package/dist/src/index.js +1425 -1629
- package/dist/src/journey.js +132 -81
- package/dist/src/ledger-repair-apply.js +538 -0
- package/dist/src/ledger-repair-plan.js +463 -0
- package/dist/src/loop.js +257 -166
- package/dist/src/memory-capture.js +180 -32
- package/dist/src/memory-decay.js +30 -14
- package/dist/src/memory-lifecycle.js +1310 -0
- package/dist/src/memory-utility.js +27 -40
- package/dist/src/mock-llm.js +36 -61
- package/dist/src/model.js +81 -36
- package/dist/src/realtime-pricing.js +63 -72
- package/dist/src/slot-spec.js +84 -106
- package/dist/src/state-ledger.js +310 -471
- package/dist/src/subagent-job-id-guard.js +58 -0
- package/dist/src/time-anchor.js +231 -33
- package/dist/src/tool-packet.js +20 -8
- package/dist/src/travel-slots.js +58 -35
- package/dist/src/travel-timeline.js +44 -63
- package/dist/src/turn-deadline.js +121 -127
- package/dist/src/turn-policy.js +61 -89
- package/dist/src/tz-resolver.js +143 -0
- package/dist/src/unified.js +504 -381
- package/dist/src/wish-pool.js +39 -14
- package/dist/src/write-gate.js +495 -0
- package/dist/src/z3-shared.js +273 -7
- package/extension/README.md +4 -3
- package/extension/background.js +125 -14
- package/extension/content-bridge.js +23 -1
- package/extension/content-main.js +15 -4
- package/extension/manifest.json +16 -8
- package/package.json +251 -220
- package/ts/capabilities/agent-reach.ts +4 -4
- package/ts/capabilities/anything.ts +1 -1
- package/ts/capabilities/artifacts.ts +46 -9
- package/ts/capabilities/flyai.ts +156 -37
- package/ts/capabilities/hbcli.ts +1 -1
- package/ts/capabilities/incident-log.ts +88 -59
- package/ts/capabilities/session/adapters/ctrip-flight.ts +99 -36
- package/ts/capabilities/session/adapters/dida-portal.ts +250 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +123 -24
- package/ts/capabilities/session/extension-bridge.ts +226 -101
- package/ts/capabilities/session/extension-channel.ts +22 -9
- package/ts/capabilities/session/wizard.ts +2 -2
- package/ts/capabilities/session-consent.ts +98 -14
- package/ts/capabilities/session-login.ts +1 -0
- package/ts/capabilities/session-search.ts +315 -31
- package/ts/dsh-runtime/vendor/README.md +8 -4
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +7 -1
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +5 -3
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +1 -1
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +1 -1
- package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +6 -6
- package/ts/package.json +236 -16
- package/ts/scripts/map-tools-vendor-package-proof.ts +152 -31
- package/ts/scripts/state-cli.ts +418 -51
- package/ts/src/artifact-gate.ts +561 -15
- package/ts/src/benchmark-environment-bridge.ts +37 -20
- package/ts/src/bookable-facts.ts +183 -7
- package/ts/src/booking-surface/cancel-refund-commission.ts +488 -0
- package/ts/src/booking-surface/dsh-planner.ts +240 -32
- package/ts/src/booking-surface/dsh-plugin.js +17 -1
- package/ts/src/booking-surface/error-codes.ts +75 -0
- package/ts/src/booking-surface/recovery-chain.ts +409 -0
- package/ts/src/booking-surface/server.ts +84 -51
- package/ts/src/booking-surface/validation.ts +2 -0
- package/ts/src/contracts.ts +12 -2
- package/ts/src/dsh-llm.ts +4 -8
- package/ts/src/index.ts +609 -90
- package/ts/src/loop.ts +116 -7
- package/ts/src/memory-capture.ts +227 -3
- package/ts/src/mock-llm.ts +4 -8
- package/ts/src/model.ts +88 -2
- package/ts/src/state-ledger.ts +47 -29
- package/ts/src/subagent-job-id-guard.ts +72 -0
- package/ts/src/time-anchor.ts +217 -13
- package/ts/src/unified.ts +316 -54
|
@@ -1,109 +1,89 @@
|
|
|
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
|
+
*/
|
|
1
20
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
|
|
2
21
|
import { homedir } from 'node:os';
|
|
3
22
|
import { join } from 'node:path';
|
|
4
23
|
const DEFAULT_SOURCE_DIR_CANDIDATES = [
|
|
5
24
|
join(process.cwd(), 'extension'),
|
|
6
25
|
join(process.cwd(), 'dist', 'extension'),
|
|
7
|
-
join(process.cwd(), 'ts', '..', 'extension')
|
|
26
|
+
join(process.cwd(), 'ts', '..', 'extension'),
|
|
8
27
|
];
|
|
9
28
|
function resolveExtensionSourceDir() {
|
|
10
|
-
for (const candidate of DEFAULT_SOURCE_DIR_CANDIDATES){
|
|
11
|
-
if (existsSync(join(candidate, 'manifest.json')))
|
|
29
|
+
for (const candidate of DEFAULT_SOURCE_DIR_CANDIDATES) {
|
|
30
|
+
if (existsSync(join(candidate, 'manifest.json')))
|
|
31
|
+
return candidate;
|
|
12
32
|
}
|
|
13
33
|
return DEFAULT_SOURCE_DIR_CANDIDATES[0];
|
|
14
34
|
}
|
|
15
35
|
export function defaultExtensionDir() {
|
|
16
36
|
return join(homedir(), '.gotry', 'extension');
|
|
17
37
|
}
|
|
38
|
+
/** 落位扩展文件(幂等);缺源/源不全会 fail-soft,提示用户重跑 `gotry setup` */
|
|
18
39
|
function ensureExtensionFiles(source, target, dryRun) {
|
|
19
|
-
if (dryRun)
|
|
20
|
-
step: 'ensure-extension-files',
|
|
21
|
-
status: 'skip',
|
|
22
|
-
summary: '[dry-run] skip 扩展落位'
|
|
23
|
-
};
|
|
40
|
+
if (dryRun)
|
|
41
|
+
return { step: 'ensure-extension-files', status: 'skip', summary: '[dry-run] skip 扩展落位' };
|
|
24
42
|
try {
|
|
25
43
|
if (!existsSync(source) || !existsSync(join(source, 'manifest.json'))) {
|
|
26
|
-
return {
|
|
27
|
-
step: 'ensure-extension-files',
|
|
28
|
-
status: 'fail',
|
|
29
|
-
summary: `源扩展目录缺失 manifest.json: ${source}(先跑 npx gotry setup 落位)`
|
|
30
|
-
};
|
|
44
|
+
return { step: 'ensure-extension-files', status: 'fail', summary: `源扩展目录缺失 manifest.json: ${source}(先跑 npx @danceiny/gotry setup 落位)` };
|
|
31
45
|
}
|
|
32
|
-
mkdirSync(target, {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const required = [
|
|
36
|
-
'manifest.json',
|
|
37
|
-
'background.js',
|
|
38
|
-
'content-main.js',
|
|
39
|
-
'content-bridge.js'
|
|
40
|
-
];
|
|
41
|
-
for (const f of required){
|
|
46
|
+
mkdirSync(target, { recursive: true });
|
|
47
|
+
const required = ['manifest.json', 'background.js', 'content-main.js', 'content-bridge.js'];
|
|
48
|
+
for (const f of required) {
|
|
42
49
|
const src = join(source, f);
|
|
43
|
-
if (!existsSync(src))
|
|
44
|
-
step: 'ensure-extension-files',
|
|
45
|
-
status: 'fail',
|
|
46
|
-
summary: `源扩展缺 ${f}(重新 npm install 或 gotry setup)`
|
|
47
|
-
};
|
|
50
|
+
if (!existsSync(src))
|
|
51
|
+
return { step: 'ensure-extension-files', status: 'fail', summary: `源扩展缺 ${f}(重新 npm install 或 gotry setup)` };
|
|
48
52
|
copyFileSync(src, join(target, f));
|
|
49
53
|
}
|
|
50
|
-
return {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return {
|
|
57
|
-
step: 'ensure-extension-files',
|
|
58
|
-
status: 'fail',
|
|
59
|
-
summary: `扩展落位失败: ${e instanceof Error ? e.message.slice(0, 120) : String(e)}`
|
|
60
|
-
};
|
|
54
|
+
return { step: 'ensure-extension-files', status: 'ok', summary: `扩展已落位 ${target}(manifest+3 文件)` };
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
return { step: 'ensure-extension-files', status: 'fail', summary: `扩展落位失败: ${e instanceof Error ? e.message.slice(0, 120) : String(e)}` };
|
|
61
58
|
}
|
|
62
59
|
}
|
|
60
|
+
/** 静态预检:落位目录可见 + manifest.key 存在(扩展 ID 稳定)+ 源未新于 dest */
|
|
63
61
|
async function watchExtensionReady(dryRun, sourceDir, extensionDir) {
|
|
64
|
-
if (dryRun)
|
|
65
|
-
step: 'watch-extension-ready',
|
|
66
|
-
status: 'skip',
|
|
67
|
-
summary: '[dry-run] skip health-watch precheck'
|
|
68
|
-
};
|
|
62
|
+
if (dryRun)
|
|
63
|
+
return { step: 'watch-extension-ready', status: 'skip', summary: '[dry-run] skip health-watch precheck' };
|
|
69
64
|
if (!existsSync(extensionDir) || !existsSync(join(extensionDir, 'manifest.json'))) {
|
|
70
|
-
return {
|
|
71
|
-
step: 'watch-extension-ready',
|
|
72
|
-
status: 'fail',
|
|
73
|
-
summary: `落位缺失 manifest.json:${extensionDir}`
|
|
74
|
-
};
|
|
65
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: `落位缺失 manifest.json:${extensionDir}` };
|
|
75
66
|
}
|
|
76
67
|
try {
|
|
77
68
|
const srcStat = statSync(sourceDir);
|
|
78
69
|
const dstStat = statSync(extensionDir);
|
|
79
70
|
if (srcStat.mtimeMs > dstStat.mtimeMs) {
|
|
80
|
-
return {
|
|
81
|
-
step: 'watch-extension-ready',
|
|
82
|
-
status: 'fail',
|
|
83
|
-
summary: `扩展文件可能过期(源比落位新);重跑 npx gotry setup`
|
|
84
|
-
};
|
|
71
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: `扩展文件可能过期(源比落位新);重跑 npx @danceiny/gotry setup` };
|
|
85
72
|
}
|
|
86
73
|
const manifest = JSON.parse(await (await import('node:fs/promises')).readFile(join(extensionDir, 'manifest.json'), 'utf8'));
|
|
87
74
|
if (typeof manifest.key !== 'string' || manifest.key.length < 100) {
|
|
88
|
-
return {
|
|
89
|
-
step: 'watch-extension-ready',
|
|
90
|
-
status: 'fail',
|
|
91
|
-
summary: 'manifest.key 缺失或过短,扩展 ID 不能稳定'
|
|
92
|
-
};
|
|
75
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: 'manifest.key 缺失或过短,扩展 ID 不能稳定' };
|
|
93
76
|
}
|
|
94
|
-
} catch (e) {
|
|
95
|
-
return {
|
|
96
|
-
step: 'watch-extension-ready',
|
|
97
|
-
status: 'fail',
|
|
98
|
-
summary: `静态预检失败: ${e instanceof Error ? e.message.slice(0, 120) : String(e)}`
|
|
99
|
-
};
|
|
100
77
|
}
|
|
101
|
-
|
|
102
|
-
step: 'watch-extension-ready',
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
78
|
+
catch (e) {
|
|
79
|
+
return { step: 'watch-extension-ready', status: 'fail', summary: `静态预检失败: ${e instanceof Error ? e.message.slice(0, 120) : String(e)}` };
|
|
80
|
+
}
|
|
81
|
+
return { step: 'watch-extension-ready', status: 'ok', summary: '扩展文件就绪(manifest.key 校验通过,后台轮询就绪态由 health-watch 接管)' };
|
|
106
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* 主入口(2 步):①扩展落位 ②watch precheck 静态预检。
|
|
85
|
+
* 真 health-watch 由 health-watch.ts 单独负责,不并入 wizard。
|
|
86
|
+
*/
|
|
107
87
|
export async function runOnboardingWizard(opts = {}) {
|
|
108
88
|
const dryRun = opts.dryRun ?? false;
|
|
109
89
|
const extensionDir = opts.extensionDir ?? defaultExtensionDir();
|
|
@@ -111,37 +91,27 @@ export async function runOnboardingWizard(opts = {}) {
|
|
|
111
91
|
const steps = [];
|
|
112
92
|
steps.push(ensureExtensionFiles(sourceDir, extensionDir, dryRun));
|
|
113
93
|
steps.push(await watchExtensionReady(dryRun, sourceDir, extensionDir));
|
|
114
|
-
const ok = steps.every((s)=>s.status !== 'fail');
|
|
115
|
-
return {
|
|
116
|
-
ok,
|
|
117
|
-
steps,
|
|
118
|
-
extensionDir
|
|
119
|
-
};
|
|
94
|
+
const ok = steps.every((s) => s.status !== 'fail');
|
|
95
|
+
return { ok, steps, extensionDir };
|
|
120
96
|
}
|
|
97
|
+
/** stdout 人话化打印(给 bootstrap 子进程单行 JSON 输出之外的兜底形态) */
|
|
121
98
|
export function printWizardResult(result, destination = process.stdout) {
|
|
122
|
-
const tag = (s)=>{
|
|
123
|
-
if (s.status === 'ok')
|
|
124
|
-
|
|
99
|
+
const tag = (s) => {
|
|
100
|
+
if (s.status === 'ok')
|
|
101
|
+
return '✅';
|
|
102
|
+
if (s.status === 'skip')
|
|
103
|
+
return '⏭ ';
|
|
125
104
|
return '❌';
|
|
126
105
|
};
|
|
127
|
-
for (const s of result.steps){
|
|
106
|
+
for (const s of result.steps) {
|
|
128
107
|
destination.write(`${tag(s)} ${s.step}: ${s.summary}\n`);
|
|
129
108
|
}
|
|
130
109
|
destination.write(`extensionDir=${result.extensionDir}; overall=${result.ok ? 'ok' : 'has-failures'}\n`);
|
|
131
110
|
}
|
|
111
|
+
/** 公开诊断探针(bootstrap 报告用) */
|
|
132
112
|
export function describeExtensionDir(extensionDir) {
|
|
133
|
-
if (!existsSync(extensionDir))
|
|
134
|
-
exists: false,
|
|
135
|
-
fileCount: 0,
|
|
136
|
-
hasManifest: false
|
|
137
|
-
};
|
|
113
|
+
if (!existsSync(extensionDir))
|
|
114
|
+
return { exists: false, fileCount: 0, hasManifest: false };
|
|
138
115
|
const files = readdirSync(extensionDir);
|
|
139
|
-
return {
|
|
140
|
-
exists: true,
|
|
141
|
-
fileCount: files.length,
|
|
142
|
-
hasManifest: files.includes('manifest.json')
|
|
143
|
-
};
|
|
116
|
+
return { exists: true, fileCount: files.length, hasManifest: files.includes('manifest.json') };
|
|
144
117
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
//# sourceURL=ts/capabilities/session/wizard.ts
|
|
@@ -1,46 +1,150 @@
|
|
|
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
|
+
import { interpretArgs } from '../src/tool-packet.js';
|
|
26
|
+
/**
|
|
27
|
+
* 工具级 site 表(无 kind 维度时使用):key=工具名,value=站点。
|
|
28
|
+
* 复合工具(同一名字下多 kind)在 SITE_FOR_KIND 中显式登记。
|
|
29
|
+
*/
|
|
1
30
|
export const ACCOUNT_TOOLS = {
|
|
2
|
-
gotry_session_search: 'ctrip-flight'
|
|
31
|
+
gotry_session_search: 'ctrip-flight',
|
|
3
32
|
};
|
|
4
33
|
const SITE_LABEL = {
|
|
5
|
-
'ctrip-flight': '携程机票'
|
|
34
|
+
'ctrip-flight': '携程机票',
|
|
35
|
+
'ctrip-hotel': '携程酒店',
|
|
36
|
+
'dida-portal': 'Dida 供应商门户',
|
|
37
|
+
'train-12306': '12306 余票(公开查询面)',
|
|
6
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* 复合工具 × kind → site(#308:site 绑定)。
|
|
41
|
+
* 仅对显式登记的 kind 放行,未知 kind → 失败关闭(防止未登记站点扩权)。
|
|
42
|
+
* 12306 公开查询面(kind=train)仍受本工具的会话授权总闸约束,不因公开查询而绕过 off/ask/allow。
|
|
43
|
+
*/
|
|
44
|
+
export const SITE_FOR_KIND = {
|
|
45
|
+
gotry_session_search: {
|
|
46
|
+
flight: 'ctrip-flight',
|
|
47
|
+
hotel: 'ctrip-hotel',
|
|
48
|
+
dida: 'dida-portal',
|
|
49
|
+
train: 'train-12306',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
/** 会话检索工具支持的 kind;gate 与 execute 共用此选择结果。 */
|
|
53
|
+
export const SESSION_SEARCH_KINDS = ['flight', 'hotel', 'train', 'dida'];
|
|
54
|
+
/**
|
|
55
|
+
* Select the kind exactly as the session tool execute path does.
|
|
56
|
+
* `interpretArgs` is intentionally the only query-wrapper normalizer: a
|
|
57
|
+
* wrapped query wins over conflicting flat fields, and omitted kind keeps the
|
|
58
|
+
* documented flight default. Explicit malformed/unknown kinds fail closed.
|
|
59
|
+
*/
|
|
60
|
+
export function resolveSessionSearchKind(args) {
|
|
61
|
+
if (args === undefined)
|
|
62
|
+
return { ok: true, kind: 'flight' };
|
|
63
|
+
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
64
|
+
return { ok: false, reason: 'gotry_session_search 参数必须是对象;无法安全选择 kind,已失败关闭' };
|
|
65
|
+
}
|
|
66
|
+
const selected = interpretArgs(args);
|
|
67
|
+
if (!selected || typeof selected !== 'object' || Array.isArray(selected)) {
|
|
68
|
+
return { ok: false, reason: 'gotry_session_search 参数包装形态无效;无法安全选择 kind,已失败关闭' };
|
|
69
|
+
}
|
|
70
|
+
if (!Object.prototype.hasOwnProperty.call(selected, 'kind'))
|
|
71
|
+
return { ok: true, kind: 'flight' };
|
|
72
|
+
const kind = selected.kind;
|
|
73
|
+
if (typeof kind !== 'string' || kind.length === 0) {
|
|
74
|
+
return { ok: false, reason: 'gotry_session_search 收到 malformed kind;无法安全选择站点,已失败关闭' };
|
|
75
|
+
}
|
|
76
|
+
if (!SESSION_SEARCH_KINDS.includes(kind)) {
|
|
77
|
+
return { ok: false, reason: `gotry_session_search 收到未知 kind=${kind};只支持 ${SESSION_SEARCH_KINDS.join('/')},未知 kind 失败关闭` };
|
|
78
|
+
}
|
|
79
|
+
return { ok: true, kind: kind };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 解析 site(#308):对复合工具(缺省 kind=flight,未知/malformed kind → fail-closed);对未在
|
|
83
|
+
* SITE_FOR_KIND 登记的工具走原 ACCOUNT_TOOLS 表保持兼容。无 site → 放行(非账号面工具)。
|
|
84
|
+
*/
|
|
85
|
+
export function resolveSiteForExec(exec) {
|
|
86
|
+
const name = exec.name;
|
|
87
|
+
if (!name)
|
|
88
|
+
return null;
|
|
89
|
+
const map = SITE_FOR_KIND[name];
|
|
90
|
+
if (map) {
|
|
91
|
+
const selected = resolveSessionSearchKind(exec.arguments);
|
|
92
|
+
if (!selected.ok)
|
|
93
|
+
return { failClosed: true, reason: selected.reason };
|
|
94
|
+
const site = map[selected.kind];
|
|
95
|
+
if (!site)
|
|
96
|
+
return { failClosed: true, reason: `工具 ${name} 的 kind=${selected.kind} 未登记站点;失败关闭` };
|
|
97
|
+
return { site };
|
|
98
|
+
}
|
|
99
|
+
const site = ACCOUNT_TOOLS[name];
|
|
100
|
+
if (!site)
|
|
101
|
+
return null;
|
|
102
|
+
return { site };
|
|
103
|
+
}
|
|
7
104
|
function reasonFor(toolName, site) {
|
|
8
|
-
return
|
|
105
|
+
return `工具 ${toolName} 将使用你本人已登录的浏览器会话,在「${SITE_LABEL[site] ?? site}」进行只读检索`
|
|
106
|
+
+ '(ReadGuard 物理只读:写请求在网络层即中止,agent 永不接触凭证与验证码);'
|
|
107
|
+
+ '本次批准仅在本会话内有效,会话结束即失效,不会跨会话延续。';
|
|
9
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* 账号会话授权闸:挂 dsh `tools/pre-execute` waterfall。
|
|
111
|
+
* 契约:
|
|
112
|
+
* - 非账号面工具 → next() 放行(零开销);
|
|
113
|
+
* - off → 拒绝(随时可关);
|
|
114
|
+
* - 会话内已拒绝 → 拒绝且不弹卡(拒绝=本会话吊销;按 site 分桶,跨站不互授);
|
|
115
|
+
* - 会话内已批准 / allow 预授权 → 放行;
|
|
116
|
+
* - 复合工具未知/malformed kind → fail-closed deny(不扩权),缺省 kind=flight;
|
|
117
|
+
* - 其余 → ApprovalService.request();allowed-once 按 site 入会话 granted;
|
|
118
|
+
* rejected/cancelled 按 site 入会话 denied(本会话不在请求);
|
|
119
|
+
* 无审批通道 → deny(fail-closed,headless 无用户 = 无授权)。
|
|
120
|
+
*/
|
|
10
121
|
export function createConsentGate(opts) {
|
|
11
122
|
const store = opts.store ?? new WeakMap();
|
|
12
|
-
const approvalOf = opts.approval ?? (()=>undefined);
|
|
13
|
-
return async (exec, next)=>{
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
123
|
+
const approvalOf = opts.approval ?? (() => undefined);
|
|
124
|
+
return async (exec, next) => {
|
|
125
|
+
const resolved = resolveSiteForExec(exec);
|
|
126
|
+
if (!resolved)
|
|
127
|
+
return next();
|
|
128
|
+
if ('failClosed' in resolved)
|
|
129
|
+
return { kind: 'deny', reason: resolved.reason };
|
|
130
|
+
const { site } = resolved;
|
|
16
131
|
if ((opts.access() ?? 'ask') === 'off') {
|
|
17
|
-
return {
|
|
18
|
-
kind: 'deny',
|
|
19
|
-
reason: `${exec.name} 已被配置关闭(sessionAccess=off);需要账号会话检索时由用户开启`
|
|
20
|
-
};
|
|
132
|
+
return { kind: 'deny', reason: `工具 ${exec.name} 已被配置关闭(sessionAccess=off)。如需重新启用账号会话检索,请到配置中重新开启 sessionAccess。` };
|
|
21
133
|
}
|
|
22
|
-
const state = exec.agent && store.get(exec.agent) || undefined;
|
|
134
|
+
const state = (exec.agent && store.get(exec.agent)) || undefined;
|
|
23
135
|
if (state?.denied.has(site)) {
|
|
24
|
-
return {
|
|
25
|
-
kind: 'deny',
|
|
26
|
-
reason: `你在本会话已拒绝过「${SITE_LABEL[site] ?? site}」的账号会话检索——本会话不再请求授权,请改走其他工具推进`
|
|
27
|
-
};
|
|
136
|
+
return { kind: 'deny', reason: `你已在本会话拒绝过「${SITE_LABEL[site] ?? site}」的账号会话检索。为避免反复打扰,本会话不再请求授权,请改用其他工具继续推进。` };
|
|
28
137
|
}
|
|
29
|
-
if (state?.granted.has(site) || opts.access() === 'allow' && exec.agent)
|
|
138
|
+
if (state?.granted.has(site) || (opts.access() === 'allow' && exec.agent))
|
|
139
|
+
return next();
|
|
30
140
|
const approval = opts.approval?.();
|
|
31
|
-
if (!approval || !exec.agent)
|
|
32
|
-
kind: 'ask',
|
|
33
|
-
reason: reasonFor(exec.name ?? '', site)
|
|
34
|
-
};
|
|
141
|
+
if (!approval || !exec.agent)
|
|
142
|
+
return { kind: 'ask', reason: reasonFor(exec.name ?? '', site) };
|
|
35
143
|
let outcome;
|
|
36
144
|
try {
|
|
37
|
-
outcome = await approval.request({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
callId: exec.callId,
|
|
41
|
-
reason: reasonFor(exec.name ?? '', site)
|
|
42
|
-
});
|
|
43
|
-
} catch {
|
|
145
|
+
outcome = await approval.request({ agent: exec.agent, toolName: exec.name ?? '', callId: exec.callId, reason: reasonFor(exec.name ?? '', site) });
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
44
148
|
outcome = 'unavailable';
|
|
45
149
|
}
|
|
46
150
|
if (outcome === 'allowed-once') {
|
|
@@ -49,34 +153,26 @@ export function createConsentGate(opts) {
|
|
|
49
153
|
}
|
|
50
154
|
if (outcome === 'rejected' || outcome === 'cancelled') {
|
|
51
155
|
remember(store, exec.agent, site, 'deny');
|
|
52
|
-
return {
|
|
53
|
-
kind: 'deny',
|
|
54
|
-
reason: `你拒绝了 ${exec.name} 的账号会话授权(本会话内生效);不再重复请求,请改走其他工具推进`
|
|
55
|
-
};
|
|
156
|
+
return { kind: 'deny', reason: `你刚刚拒绝了工具 ${exec.name} 的账号会话授权(本次拒绝仅在本会话内生效)。为避免反复打扰,本会话不再重复请求授权,请改用其他工具继续推进。` };
|
|
56
157
|
}
|
|
57
|
-
return {
|
|
58
|
-
kind: 'deny',
|
|
59
|
-
reason: `${exec.name} 需要你授权,但当前没有可用的审批通道(headless 一问一答无审批界面;请在 web 会话中使用账号会话检索)`
|
|
60
|
-
};
|
|
158
|
+
return { kind: 'deny', reason: `工具 ${exec.name} 需要你授权,但当前没有可用的审批通道。在 headless 一问一答场景下没有审批界面,请改用 web 会话来使用账号会话检索。` };
|
|
61
159
|
};
|
|
62
160
|
}
|
|
63
161
|
function remember(store, agent, site, mode) {
|
|
64
|
-
const prev = store.get(agent) ?? {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
else prev.denied.add(site);
|
|
162
|
+
const prev = store.get(agent) ?? { granted: new Set(), denied: new Set() };
|
|
163
|
+
if (mode === 'grant')
|
|
164
|
+
prev.granted.add(site);
|
|
165
|
+
else
|
|
166
|
+
prev.denied.add(site);
|
|
70
167
|
store.set(agent, prev);
|
|
71
168
|
}
|
|
169
|
+
/** 从运行时上下文懒解析审批缝(与 dsh-tools serviceAsk 的 ctx.get('approval') 同一协议) */
|
|
72
170
|
export function approvalFromContext(ctx) {
|
|
73
|
-
return ()=>{
|
|
171
|
+
return () => {
|
|
74
172
|
const get = ctx.get;
|
|
75
|
-
if (typeof get !== 'function')
|
|
173
|
+
if (typeof get !== 'function')
|
|
174
|
+
return undefined;
|
|
76
175
|
const approval = get.call(ctx, 'approval');
|
|
77
176
|
return approval && typeof approval.request === 'function' ? approval : undefined;
|
|
78
177
|
};
|
|
79
178
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
//# sourceURL=ts/capabilities/session-consent.ts
|