@danceiny/gotry 0.0.1-rc.17 → 0.0.1-rc.19
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 +185 -148
- package/README.zh-CN.md +195 -154
- package/bin/gotry-bootstrap.js +246 -26
- package/bin/gotry-inner.js +68 -38
- package/bin/gotry-runtime-resolution.d.ts +1 -1
- package/bin/gotry-runtime-resolution.js +7 -8
- package/cordis.gotry-patch.yml +15 -5
- package/data/stations-12306-verify.json +524 -0
- package/dist/capabilities/agent-reach.js +4 -4
- package/dist/capabilities/channel-health.js +103 -0
- package/dist/capabilities/channel-registry.js +213 -0
- package/dist/capabilities/doctor.js +285 -0
- package/dist/capabilities/effect.js +178 -5
- package/dist/capabilities/flyai.js +13 -0
- package/dist/capabilities/session/adapters/ctrip-hotel.js +207 -0
- package/dist/capabilities/session/adapters/rail-12306.js +285 -0
- package/dist/capabilities/session/extension-bridge.js +14 -1
- package/dist/capabilities/session/extension-channel.js +4 -2
- package/dist/capabilities/session/extension-distribution.js +1 -1
- package/dist/capabilities/session-search.js +311 -0
- package/dist/capabilities/visa-policy.js +126 -0
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +304 -0
- package/dist/scripts/agent-planning-turn-deadline-tests.js +281 -0
- package/dist/scripts/benchmark-environment-bridge-e2e.js +5 -10
- package/dist/scripts/benchmark-environment-bridge-tests.js +148 -142
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +26 -26
- package/dist/scripts/{booking-copilot-availability-policy-v2-tests.js → booking-copilot-availability-policy-tests.js} +115 -115
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +41 -1
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +75 -120
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +370 -61
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +2 -2
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +7 -3
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +15 -9
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +19 -11
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +16 -52
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +3953 -155
- package/dist/scripts/booking-copilot-server-proof-tests.js +58 -23
- package/dist/scripts/booking-copilot-startup-proof-tests.js +10 -119
- package/dist/scripts/booking-surface-contract-proof-tests.js +1154 -326
- package/dist/scripts/bootstrap-tests.js +115 -44
- package/dist/scripts/build-metrics-report.js +339 -0
- package/dist/scripts/channel-probe-tests.js +148 -0
- package/dist/scripts/channel-probe.js +252 -0
- package/dist/scripts/channel-registry-tests.js +262 -0
- package/dist/scripts/doctor-tests.js +121 -0
- package/dist/scripts/effect-tests.js +274 -1
- package/dist/scripts/extension-tests.js +129 -11
- package/dist/scripts/fact-gate-tests.js +91 -2
- package/dist/scripts/flyai-tests.js +17 -1
- package/dist/scripts/hbcli-e2e-tests.js +1 -3
- package/dist/scripts/metrics-report-tests.js +288 -0
- package/dist/scripts/persona-surface-guard-tests.js +19 -0
- package/dist/scripts/session-tests.js +401 -1
- package/dist/scripts/smoke.js +100 -83
- package/dist/scripts/turn-handoff-collect-tests.js +216 -0
- package/dist/scripts/turn-handoff-collect.js +189 -0
- package/dist/scripts/turn-policy-tests.js +56 -0
- package/dist/scripts/typed-contract-canary.js +261 -0
- package/dist/scripts/visa-policy-tests.js +75 -0
- package/dist/scripts/wish-channel-gate-tests.js +111 -0
- package/dist/src/artifact-gate.js +91 -3
- package/dist/src/benchmark-agent-conformance.js +7 -4
- package/dist/src/benchmark-environment-bridge.js +68 -7
- package/dist/src/bookable-facts.js +62 -3
- package/dist/src/booking-surface/{availability-policy-v2.js → availability-policy.js} +89 -89
- package/dist/src/booking-surface/canonical-schema.js +8 -22
- package/dist/src/booking-surface/contracts.js +70 -19
- package/dist/src/booking-surface/dsh-planner.js +310 -177
- package/dist/src/booking-surface/dsh-plugin.js +3 -3
- package/dist/src/booking-surface/index.js +1 -5
- package/dist/src/booking-surface/profile.js +1 -1
- package/dist/src/booking-surface/runtime.js +1682 -247
- package/dist/src/booking-surface/server.js +371 -185
- package/dist/src/booking-surface/startup.js +17 -27
- package/dist/src/booking-surface/validation.js +270 -760
- package/dist/src/index.js +735 -149
- package/dist/src/turn-deadline.js +292 -0
- package/dist/src/turn-policy.js +146 -0
- package/dist/src/wish-pool.js +5 -0
- package/extension/background.js +23 -4
- package/extension/content-main.js +47 -9
- package/extension/manifest.json +27 -9
- package/package.json +6 -26
- package/schemas/booking.surface.schema.json +2593 -0
- package/ts/capabilities/agent-reach.ts +4 -4
- package/ts/capabilities/flyai.ts +21 -3
- package/ts/capabilities/session/action-cache.ts +1 -1
- package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +293 -0
- package/ts/capabilities/session/extension-bridge.ts +32 -2
- package/ts/capabilities/session/extension-channel.ts +9 -8
- package/ts/capabilities/session/extension-distribution.ts +3 -1
- package/ts/capabilities/session/health-watch.ts +1 -1
- package/ts/capabilities/session/read-guard.ts +1 -1
- package/ts/capabilities/session/wizard.ts +1 -1
- package/ts/capabilities/session-search.ts +323 -1
- package/ts/package.json +1 -0
- package/ts/scripts/turn-handoff-collect.ts +178 -0
- package/ts/src/artifact-gate.ts +82 -2
- package/ts/src/benchmark-agent-conformance.ts +14 -6
- package/ts/src/benchmark-environment-bridge.ts +29 -10
- package/ts/src/bookable-facts.ts +109 -5
- package/ts/src/booking-saga.ts +1 -1
- package/ts/src/booking-surface/{availability-policy-v2.ts → availability-policy.ts} +124 -125
- package/ts/src/booking-surface/canonical-schema.js +8 -22
- package/ts/src/booking-surface/contracts.ts +278 -239
- package/ts/src/booking-surface/dsh-planner.ts +333 -194
- package/ts/src/booking-surface/dsh-plugin.js +3 -3
- package/ts/src/booking-surface/index.ts +1 -5
- package/ts/src/booking-surface/profile.ts +11 -11
- package/ts/src/booking-surface/runtime.ts +1351 -351
- package/ts/src/booking-surface/server.ts +282 -175
- package/ts/src/booking-surface/startup.ts +36 -48
- package/ts/src/booking-surface/validation.ts +194 -442
- package/ts/src/contracts.ts +1 -1
- package/ts/src/index.ts +489 -171
- package/ts/src/loop.ts +1 -1
- package/ts/src/state-ledger.ts +1 -1
- package/ts/src/turn-deadline.ts +361 -0
- package/ts/src/turn-policy.ts +154 -0
- package/ts/src/wish-pool.ts +17 -4
- package/dist/scripts/agent-planning-budget-e2e.js +0 -227
- package/dist/scripts/agent-planning-budget-tests.js +0 -173
- package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +0 -3935
- package/dist/scripts/booking-surface-v2-contract-proof-tests.js +0 -1174
- package/dist/src/booking-surface/contracts-v2.js +0 -89
- package/dist/src/booking-surface/runtime-v2.js +0 -1771
- package/dist/src/booking-surface/server-v2.js +0 -334
- package/dist/src/booking-surface/validation-v2.js +0 -319
- package/dist/src/tool-budget.js +0 -136
- package/schemas/booking.surface.v1.schema.json +0 -927
- package/schemas/booking.surface.v2.schema.json +0 -61
- package/ts/src/booking-surface/contracts-v2.ts +0 -118
- package/ts/src/booking-surface/runtime-v2.ts +0 -1466
- package/ts/src/booking-surface/server-v2.ts +0 -247
- package/ts/src/booking-surface/validation-v2.ts +0 -205
- package/ts/src/tool-budget.ts +0 -165
|
@@ -2,17 +2,14 @@ import { mkdirSync } from 'node:fs';
|
|
|
2
2
|
import { isAbsolute, resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { ensureLedger } from '../state-ledger.js';
|
|
5
|
-
import { buildDshPlannerEnvironment, createDshEmbeddedBookingPlanner
|
|
5
|
+
import { buildDshPlannerEnvironment, createDshEmbeddedBookingPlanner } from './dsh-planner.js';
|
|
6
6
|
import { BookingCopilotTaskRuntime } from './runtime.js';
|
|
7
|
-
import {
|
|
8
|
-
import { BOOKING_COPILOT_V2_INGRESS_MODES } from './contracts-v2.js';
|
|
7
|
+
import { BOOKING_COPILOT_INGRESS_MODES } from './contracts.js';
|
|
9
8
|
import { startBookingCopilotServer } from './server.js';
|
|
10
9
|
const DEFAULT_DEPENDENCIES = {
|
|
11
10
|
ensureLedger,
|
|
12
11
|
runtimeFactory: (ledger)=>new BookingCopilotTaskRuntime(ledger),
|
|
13
12
|
createPlanner: createDshEmbeddedBookingPlanner,
|
|
14
|
-
runtimeFactoryV2: (ledger)=>new BookingCopilotTaskRuntimeV2(ledger),
|
|
15
|
-
createPlannerV2: createDshEmbeddedBookingPlannerV2,
|
|
16
13
|
startServer: startBookingCopilotServer
|
|
17
14
|
};
|
|
18
15
|
function parsePort(raw) {
|
|
@@ -31,10 +28,10 @@ export function resolveBookingCopilotStartupConfig(env = process.env) {
|
|
|
31
28
|
if (artifactId !== undefined && !/^[0-9a-f]{40}$/.test(artifactId)) {
|
|
32
29
|
throw new Error('booking_copilot_artifact_id_invalid');
|
|
33
30
|
}
|
|
34
|
-
const rawIngressMode = env.
|
|
31
|
+
const rawIngressMode = env.GOTRY_BOOKING_COPILOT_INGRESS_MODE;
|
|
35
32
|
const ingressMode = rawIngressMode === undefined || rawIngressMode === '' ? 'bff-bound-turn-only' : rawIngressMode;
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error('
|
|
33
|
+
if (!BOOKING_COPILOT_INGRESS_MODES.includes(ingressMode)) {
|
|
34
|
+
throw new Error('booking_copilot_ingress_mode_invalid');
|
|
38
35
|
}
|
|
39
36
|
return {
|
|
40
37
|
apiKey,
|
|
@@ -45,12 +42,11 @@ export function resolveBookingCopilotStartupConfig(env = process.env) {
|
|
|
45
42
|
ingressMode: ingressMode
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
|
-
async function closeAll(server, planner,
|
|
45
|
+
async function closeAll(server, planner, ledger) {
|
|
49
46
|
const failures = [];
|
|
50
47
|
for (const close of [
|
|
51
48
|
server ? ()=>server.close() : undefined,
|
|
52
49
|
planner ? ()=>planner.close() : undefined,
|
|
53
|
-
plannerV2 ? ()=>plannerV2.close() : undefined,
|
|
54
50
|
ledger ? ()=>Promise.resolve(ledger.close()) : undefined
|
|
55
51
|
]){
|
|
56
52
|
if (!close) continue;
|
|
@@ -68,14 +64,14 @@ export async function startBookingCopilotFromEnvironment(env = process.env, depe
|
|
|
68
64
|
const activeDependencies = dependencies;
|
|
69
65
|
const hasIngressBinding = Boolean(activeDependencies.ingressBinding);
|
|
70
66
|
const hasPrincipal = Boolean(activeDependencies.principal);
|
|
71
|
-
if (hasIngressBinding !== hasPrincipal) throw new Error('
|
|
67
|
+
if (hasIngressBinding !== hasPrincipal) throw new Error('booking_copilot_ingress_binding_pair_required');
|
|
72
68
|
const ingressPair = hasIngressBinding && hasPrincipal;
|
|
73
|
-
if (ingressPair && env.
|
|
74
|
-
throw new Error('
|
|
69
|
+
if (ingressPair && env.GOTRY_BOOKING_COPILOT_INGRESS_MODE !== undefined && config.ingressMode === 'bff-bound-turn-only') {
|
|
70
|
+
throw new Error('booking_copilot_ingress_mode_conflict');
|
|
75
71
|
}
|
|
76
|
-
if (!ingressPair && config.ingressMode === 'bff-ingress-binding') throw new Error('
|
|
72
|
+
if (!ingressPair && config.ingressMode === 'bff-ingress-binding') throw new Error('booking_copilot_ingress_binding_required');
|
|
77
73
|
if (ingressPair && (typeof activeDependencies.ingressBinding?.bind !== 'function' || typeof activeDependencies.principal?.subject !== 'string' || activeDependencies.principal.subject.length === 0 || activeDependencies.principal.subject.length > 256 || typeof activeDependencies.principal?.scope !== 'string' || activeDependencies.principal.scope.length === 0 || activeDependencies.principal.scope.length > 256)) {
|
|
78
|
-
throw new Error('
|
|
74
|
+
throw new Error('booking_copilot_ingress_binding_invalid');
|
|
79
75
|
}
|
|
80
76
|
const activeIngressMode = ingressPair ? 'bff-ingress-binding' : 'bff-bound-turn-only';
|
|
81
77
|
mkdirSync(config.stateRoot, {
|
|
@@ -83,7 +79,6 @@ export async function startBookingCopilotFromEnvironment(env = process.env, depe
|
|
|
83
79
|
});
|
|
84
80
|
let ledger;
|
|
85
81
|
let planner;
|
|
86
|
-
let plannerV2;
|
|
87
82
|
let server;
|
|
88
83
|
try {
|
|
89
84
|
ledger = dependencies.ensureLedger(config.stateRoot);
|
|
@@ -91,29 +86,24 @@ export async function startBookingCopilotFromEnvironment(env = process.env, depe
|
|
|
91
86
|
stateRoot: config.stateRoot,
|
|
92
87
|
env: buildDshPlannerEnvironment(env)
|
|
93
88
|
};
|
|
94
|
-
if (!activeDependencies.runtimeFactoryV2 || !activeDependencies.createPlannerV2) throw new Error('booking_copilot_v2_startup_dependency_missing');
|
|
95
89
|
const runtime = activeDependencies.runtimeFactory(ledger);
|
|
96
90
|
planner = await activeDependencies.createPlanner(plannerOptions);
|
|
97
|
-
const runtimeV2 = activeDependencies.runtimeFactoryV2(ledger);
|
|
98
|
-
plannerV2 = await activeDependencies.createPlannerV2(plannerOptions);
|
|
99
91
|
server = await activeDependencies.startServer({
|
|
100
92
|
apiKey: config.apiKey,
|
|
101
93
|
runtime,
|
|
102
94
|
plannerFactory: planner.plannerFactory,
|
|
103
|
-
|
|
104
|
-
runtime: runtimeV2,
|
|
105
|
-
plannerFactory: plannerV2.plannerFactory,
|
|
95
|
+
...ingressPair ? {
|
|
106
96
|
ingressBinding: activeDependencies.ingressBinding,
|
|
107
|
-
principal: activeDependencies.principal
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
principal: activeDependencies.principal
|
|
98
|
+
} : {},
|
|
99
|
+
ingressMode: activeIngressMode,
|
|
110
100
|
host: config.host,
|
|
111
101
|
port: config.port,
|
|
112
102
|
artifactId: config.artifactId
|
|
113
103
|
});
|
|
114
104
|
} catch (error) {
|
|
115
105
|
try {
|
|
116
|
-
await closeAll(server, planner,
|
|
106
|
+
await closeAll(server, planner, ledger);
|
|
117
107
|
} catch (cleanupError) {
|
|
118
108
|
throw new AggregateError([
|
|
119
109
|
error,
|
|
@@ -128,7 +118,7 @@ export async function startBookingCopilotFromEnvironment(env = process.env, depe
|
|
|
128
118
|
async close () {
|
|
129
119
|
if (closed) return;
|
|
130
120
|
closed = true;
|
|
131
|
-
await closeAll(server, planner,
|
|
121
|
+
await closeAll(server, planner, ledger);
|
|
132
122
|
}
|
|
133
123
|
};
|
|
134
124
|
}
|