@danceiny/gotry 0.0.1-rc.18 → 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 +42 -16
- package/README.zh-CN.md +37 -15
- package/bin/gotry-bootstrap.js +236 -3
- package/bin/gotry-inner.js +66 -20
- 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 +87 -2
- 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
|
@@ -7,53 +7,46 @@ import { ensureLedger, type StateLedger } from '../state-ledger.ts'
|
|
|
7
7
|
import {
|
|
8
8
|
buildDshPlannerEnvironment,
|
|
9
9
|
createDshEmbeddedBookingPlanner,
|
|
10
|
-
|
|
11
|
-
type
|
|
12
|
-
type DshEmbeddedBookingPlannerHandleV2,
|
|
13
|
-
type DshEmbeddedBookingPlannerOptionsV1,
|
|
10
|
+
type DshEmbeddedBookingPlannerHandle,
|
|
11
|
+
type DshEmbeddedBookingPlannerOptions,
|
|
14
12
|
} from './dsh-planner.ts'
|
|
15
13
|
import { BookingCopilotTaskRuntime } from './runtime.ts'
|
|
16
|
-
import {
|
|
17
|
-
import { BOOKING_COPILOT_V2_INGRESS_MODES, type BookingCopilotV2IngressMode, type BookingIngressBindingV2, type BookingIngressPrincipalV2 } from './contracts-v2.ts'
|
|
14
|
+
import { BOOKING_COPILOT_INGRESS_MODES, type BookingCopilotIngressMode, type BookingIngressBinding, type BookingIngressPrincipal } from './contracts.ts'
|
|
18
15
|
import {
|
|
19
16
|
startBookingCopilotServer,
|
|
20
|
-
type
|
|
21
|
-
type
|
|
17
|
+
type BookingCopilotServerHandle,
|
|
18
|
+
type BookingCopilotServerOptions,
|
|
22
19
|
} from './server.ts'
|
|
23
20
|
|
|
24
|
-
export interface
|
|
21
|
+
export interface BookingCopilotStartupConfig {
|
|
25
22
|
apiKey: string
|
|
26
23
|
stateRoot: string
|
|
27
24
|
host: string
|
|
28
25
|
port: number
|
|
29
26
|
artifactId?: string
|
|
30
27
|
/** Defaults to bound-turn-only; a complete injected seam enables ingress. */
|
|
31
|
-
ingressMode:
|
|
28
|
+
ingressMode: BookingCopilotIngressMode
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
export interface
|
|
31
|
+
export interface BookingCopilotStartupHandle {
|
|
35
32
|
port: number
|
|
36
33
|
close(): Promise<void>
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
export interface
|
|
36
|
+
export interface BookingCopilotStartupDependencies {
|
|
40
37
|
ensureLedger(stateRoot: string): StateLedger
|
|
41
38
|
runtimeFactory(ledger: StateLedger): BookingCopilotTaskRuntime
|
|
42
|
-
createPlanner(options:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
principal?: BookingIngressPrincipalV2
|
|
48
|
-
startServer(options: BookingCopilotServerOptionsV1): Promise<BookingCopilotServerHandleV1>
|
|
39
|
+
createPlanner(options: DshEmbeddedBookingPlannerOptions): Promise<DshEmbeddedBookingPlannerHandle>
|
|
40
|
+
/** Optional in-process BFF identity seam; standalone use is bound-turn-only. */
|
|
41
|
+
ingressBinding?: BookingIngressBinding
|
|
42
|
+
principal?: BookingIngressPrincipal
|
|
43
|
+
startServer(options: BookingCopilotServerOptions): Promise<BookingCopilotServerHandle>
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
const DEFAULT_DEPENDENCIES:
|
|
46
|
+
const DEFAULT_DEPENDENCIES: BookingCopilotStartupDependencies = {
|
|
52
47
|
ensureLedger,
|
|
53
48
|
runtimeFactory: (ledger) => new BookingCopilotTaskRuntime(ledger),
|
|
54
49
|
createPlanner: createDshEmbeddedBookingPlanner,
|
|
55
|
-
runtimeFactoryV2: (ledger) => new BookingCopilotTaskRuntimeV2(ledger),
|
|
56
|
-
createPlannerV2: createDshEmbeddedBookingPlannerV2,
|
|
57
50
|
startServer: startBookingCopilotServer,
|
|
58
51
|
}
|
|
59
52
|
|
|
@@ -66,7 +59,7 @@ function parsePort(raw: string | undefined): number {
|
|
|
66
59
|
|
|
67
60
|
export function resolveBookingCopilotStartupConfig(
|
|
68
61
|
env: Record<string, string | undefined> = process.env,
|
|
69
|
-
):
|
|
62
|
+
): BookingCopilotStartupConfig {
|
|
70
63
|
const apiKey = env.GOTRY_BOOKING_COPILOT_API_KEY ?? ''
|
|
71
64
|
if (!apiKey) throw new Error('booking_copilot_api_key_required')
|
|
72
65
|
const stateRoot = env.GOTRY_BOOKING_COPILOT_STATE_ROOT ?? ''
|
|
@@ -76,10 +69,10 @@ export function resolveBookingCopilotStartupConfig(
|
|
|
76
69
|
if (artifactId !== undefined && !/^[0-9a-f]{40}$/.test(artifactId)) {
|
|
77
70
|
throw new Error('booking_copilot_artifact_id_invalid')
|
|
78
71
|
}
|
|
79
|
-
const rawIngressMode = env.
|
|
72
|
+
const rawIngressMode = env.GOTRY_BOOKING_COPILOT_INGRESS_MODE
|
|
80
73
|
const ingressMode = rawIngressMode === undefined || rawIngressMode === '' ? 'bff-bound-turn-only' : rawIngressMode
|
|
81
|
-
if (!(
|
|
82
|
-
throw new Error('
|
|
74
|
+
if (!(BOOKING_COPILOT_INGRESS_MODES as readonly string[]).includes(ingressMode)) {
|
|
75
|
+
throw new Error('booking_copilot_ingress_mode_invalid')
|
|
83
76
|
}
|
|
84
77
|
return {
|
|
85
78
|
apiKey,
|
|
@@ -87,21 +80,19 @@ export function resolveBookingCopilotStartupConfig(
|
|
|
87
80
|
host: env.GOTRY_BOOKING_COPILOT_HOST || '127.0.0.1',
|
|
88
81
|
port: parsePort(env.GOTRY_BOOKING_COPILOT_PORT),
|
|
89
82
|
artifactId,
|
|
90
|
-
ingressMode: ingressMode as
|
|
83
|
+
ingressMode: ingressMode as BookingCopilotIngressMode,
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
86
|
|
|
94
87
|
async function closeAll(
|
|
95
|
-
server:
|
|
96
|
-
planner:
|
|
97
|
-
plannerV2: DshEmbeddedBookingPlannerHandleV2 | undefined,
|
|
88
|
+
server: BookingCopilotServerHandle | undefined,
|
|
89
|
+
planner: DshEmbeddedBookingPlannerHandle | undefined,
|
|
98
90
|
ledger: StateLedger | undefined,
|
|
99
91
|
): Promise<void> {
|
|
100
92
|
const failures: unknown[] = []
|
|
101
93
|
for (const close of [
|
|
102
94
|
server ? () => server.close() : undefined,
|
|
103
95
|
planner ? () => planner.close() : undefined,
|
|
104
|
-
plannerV2 ? () => plannerV2.close() : undefined,
|
|
105
96
|
ledger ? () => Promise.resolve(ledger.close()) : undefined,
|
|
106
97
|
]) {
|
|
107
98
|
if (!close) continue
|
|
@@ -117,44 +108,41 @@ async function closeAll(
|
|
|
117
108
|
*/
|
|
118
109
|
export async function startBookingCopilotFromEnvironment(
|
|
119
110
|
env: Record<string, string | undefined> = process.env,
|
|
120
|
-
dependencies:
|
|
121
|
-
): Promise<
|
|
111
|
+
dependencies: BookingCopilotStartupDependencies = DEFAULT_DEPENDENCIES,
|
|
112
|
+
): Promise<BookingCopilotStartupHandle> {
|
|
122
113
|
const config = resolveBookingCopilotStartupConfig(env)
|
|
123
114
|
const activeDependencies = dependencies
|
|
124
115
|
const hasIngressBinding = Boolean(activeDependencies.ingressBinding)
|
|
125
116
|
const hasPrincipal = Boolean(activeDependencies.principal)
|
|
126
|
-
if (hasIngressBinding !== hasPrincipal) throw new Error('
|
|
117
|
+
if (hasIngressBinding !== hasPrincipal) throw new Error('booking_copilot_ingress_binding_pair_required')
|
|
127
118
|
const ingressPair = hasIngressBinding && hasPrincipal
|
|
128
|
-
if (ingressPair && env.
|
|
129
|
-
throw new Error('
|
|
119
|
+
if (ingressPair && env.GOTRY_BOOKING_COPILOT_INGRESS_MODE !== undefined && config.ingressMode === 'bff-bound-turn-only') {
|
|
120
|
+
throw new Error('booking_copilot_ingress_mode_conflict')
|
|
130
121
|
}
|
|
131
|
-
if (!ingressPair && config.ingressMode === 'bff-ingress-binding') throw new Error('
|
|
122
|
+
if (!ingressPair && config.ingressMode === 'bff-ingress-binding') throw new Error('booking_copilot_ingress_binding_required')
|
|
132
123
|
if (ingressPair && (typeof activeDependencies.ingressBinding?.bind !== 'function'
|
|
133
124
|
|| typeof activeDependencies.principal?.subject !== 'string' || activeDependencies.principal.subject.length === 0 || activeDependencies.principal.subject.length > 256
|
|
134
125
|
|| typeof activeDependencies.principal?.scope !== 'string' || activeDependencies.principal.scope.length === 0 || activeDependencies.principal.scope.length > 256)) {
|
|
135
|
-
throw new Error('
|
|
126
|
+
throw new Error('booking_copilot_ingress_binding_invalid')
|
|
136
127
|
}
|
|
137
|
-
const activeIngressMode:
|
|
128
|
+
const activeIngressMode: BookingCopilotIngressMode = ingressPair ? 'bff-ingress-binding' : 'bff-bound-turn-only'
|
|
138
129
|
mkdirSync(config.stateRoot, { recursive: true })
|
|
139
130
|
let ledger: StateLedger | undefined
|
|
140
|
-
let planner:
|
|
141
|
-
let
|
|
142
|
-
let server: BookingCopilotServerHandleV1 | undefined
|
|
131
|
+
let planner: DshEmbeddedBookingPlannerHandle | undefined
|
|
132
|
+
let server: BookingCopilotServerHandle | undefined
|
|
143
133
|
try {
|
|
144
134
|
ledger = dependencies.ensureLedger(config.stateRoot)
|
|
145
135
|
const plannerOptions = { stateRoot: config.stateRoot, env: buildDshPlannerEnvironment(env) }
|
|
146
|
-
if (!activeDependencies.runtimeFactoryV2 || !activeDependencies.createPlannerV2) throw new Error('booking_copilot_v2_startup_dependency_missing')
|
|
147
136
|
const runtime = activeDependencies.runtimeFactory(ledger)
|
|
148
137
|
planner = await activeDependencies.createPlanner(plannerOptions)
|
|
149
|
-
const runtimeV2 = activeDependencies.runtimeFactoryV2(ledger)
|
|
150
|
-
plannerV2 = await activeDependencies.createPlannerV2(plannerOptions)
|
|
151
138
|
server = await activeDependencies.startServer({
|
|
152
139
|
apiKey: config.apiKey, runtime, plannerFactory: planner.plannerFactory,
|
|
153
|
-
|
|
140
|
+
...(ingressPair ? { ingressBinding: activeDependencies.ingressBinding, principal: activeDependencies.principal } : {}),
|
|
141
|
+
ingressMode: activeIngressMode,
|
|
154
142
|
host: config.host, port: config.port, artifactId: config.artifactId,
|
|
155
143
|
})
|
|
156
144
|
} catch (error) {
|
|
157
|
-
try { await closeAll(server, planner,
|
|
145
|
+
try { await closeAll(server, planner, ledger) } catch (cleanupError) {
|
|
158
146
|
throw new AggregateError([error, cleanupError], 'booking_copilot_startup_and_cleanup_failed')
|
|
159
147
|
}
|
|
160
148
|
throw error
|
|
@@ -166,7 +154,7 @@ export async function startBookingCopilotFromEnvironment(
|
|
|
166
154
|
async close() {
|
|
167
155
|
if (closed) return
|
|
168
156
|
closed = true
|
|
169
|
-
await closeAll(server, planner,
|
|
157
|
+
await closeAll(server, planner, ledger)
|
|
170
158
|
},
|
|
171
159
|
}
|
|
172
160
|
}
|