@danceiny/gotry 0.0.1-rc.16 → 0.0.1-rc.17
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 +47 -13
- package/README.zh-CN.md +20 -10
- package/bin/gotry-booking-copilot.js +53 -0
- package/bin/gotry-bootstrap.js +111 -51
- package/bin/gotry-inner.js +442 -60
- package/bin/gotry-runtime-resolution.d.ts +27 -0
- package/bin/gotry-runtime-resolution.js +50 -0
- package/bin/gotry.js +1 -1
- package/cordis.gotry-patch.yml +5 -1
- package/dist/capabilities/agent-reach-deep.js +1 -1
- package/dist/capabilities/agent-reach.js +1 -1
- package/dist/capabilities/anything.js +1 -1
- package/dist/capabilities/artifacts.js +1 -1
- package/dist/capabilities/effect.js +1 -1
- package/dist/capabilities/fact-log.js +1 -1
- package/dist/capabilities/flyai.js +20 -6
- package/dist/capabilities/hbcli.js +1 -1
- package/dist/capabilities/incident-log.js +1 -1
- package/dist/capabilities/model-override.js +18 -0
- package/dist/capabilities/opensky.js +1 -1
- package/dist/capabilities/resilience.js +1 -1
- package/dist/capabilities/session/action-cache.js +1 -1
- package/dist/capabilities/session/adapters/ctrip-flight.js +1 -1
- package/dist/capabilities/session/adapters/meituan-local.js +1 -1
- package/dist/capabilities/session/benchmark.js +1 -1
- package/dist/capabilities/session/extension-bridge.js +19 -6
- package/dist/capabilities/session/extension-channel.js +3 -3
- package/dist/capabilities/session/extension-distribution.js +234 -0
- package/dist/capabilities/session/extract.js +1 -1
- package/dist/capabilities/session/golden-score.js +92 -0
- package/dist/capabilities/session/health-watch.js +1 -1
- package/dist/capabilities/session/read-guard.js +1 -1
- package/dist/capabilities/session/static-flight-golden.js +137 -0
- package/dist/capabilities/session/transport.js +1 -1
- package/dist/capabilities/session/wizard.js +21 -251
- package/dist/capabilities/session-consent.js +1 -1
- package/dist/capabilities/session-login.js +11 -5
- package/dist/capabilities/session-search.js +46 -4
- package/dist/capabilities/weather.js +168 -46
- package/dist/data/session-golden-20.json +25 -0
- package/dist/data/sf-golden-manifest.json +102 -0
- package/dist/data/sf-static-routes.json +91 -0
- package/dist/scripts/action-cache-tests.js +1 -1
- package/dist/scripts/agent-planning-budget-e2e.js +227 -0
- package/dist/scripts/agent-planning-budget-tests.js +173 -0
- package/dist/scripts/agent-reach-deep-tests.js +1 -1
- package/dist/scripts/agent-reach-tests.js +1 -1
- package/dist/scripts/agent-reach-wrapper-tests.js +1 -1
- package/dist/scripts/anything-tests.js +1 -1
- package/dist/scripts/async-collect.js +1 -1
- package/dist/scripts/benchmark-environment-bridge-e2e.js +981 -0
- package/dist/scripts/benchmark-environment-bridge-tests.js +2544 -0
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +335 -0
- package/dist/scripts/booking-copilot-availability-policy-v2-tests.js +1355 -0
- package/dist/scripts/booking-copilot-bin-proof-tests.js +89 -0
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +113 -0
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +356 -0
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +557 -0
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +140 -0
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +202 -0
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +102 -0
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +374 -0
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +447 -0
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +205 -0
- package/dist/scripts/booking-copilot-server-proof-tests.js +317 -0
- package/dist/scripts/booking-copilot-startup-proof-tests.js +283 -0
- package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +3935 -0
- package/dist/scripts/booking-saga-tests.js +1 -1
- package/dist/scripts/booking-surface-contract-proof-tests.js +393 -0
- package/dist/scripts/booking-surface-v2-contract-proof-tests.js +1174 -0
- package/dist/scripts/bootstrap-tests.js +30 -10
- package/dist/scripts/build-changelog.js +1 -1
- package/dist/scripts/changelog-tests.js +1 -1
- package/dist/scripts/companion-tests.js +1 -1
- package/dist/scripts/diff-test.js +1 -1
- package/dist/scripts/dsh-runtime-closure-tests.js +225 -0
- package/dist/scripts/dsh-runtime-closure.js +150 -0
- package/dist/scripts/effect-tests.js +1 -1
- package/dist/scripts/engine-run.js +1 -1
- package/dist/scripts/engine-tests.js +1 -1
- package/dist/scripts/evaluation-cadence-tests.js +347 -0
- package/dist/scripts/evaluation-contract-tests.js +574 -0
- package/dist/scripts/extension-distribution-cli.js +35 -0
- package/dist/scripts/extension-distribution-tests.js +341 -0
- package/dist/scripts/extension-tests.js +128 -23
- package/dist/scripts/fact-gate-tests.js +1 -1
- package/dist/scripts/flyai-tests.js +1 -1
- package/dist/scripts/hbcli-e2e-tests.js +1 -1
- package/dist/scripts/hbcli-tests.js +1 -1
- package/dist/scripts/health-watch-cli.js +1 -1
- package/dist/scripts/i18n-tests.js +1 -1
- package/dist/scripts/incident-tests.js +1 -1
- package/dist/scripts/journey-tests.js +1 -1
- package/dist/scripts/ledger-tests.js +1 -1
- package/dist/scripts/ledger-workflow-crash.js +1 -1
- package/dist/scripts/memory-capture-tests.js +1 -1
- package/dist/scripts/memory-decay-tests.js +1 -1
- package/dist/scripts/memory-metrics.js +1 -1
- package/dist/scripts/memory-value-report.js +1 -1
- package/dist/scripts/model-override-e2e.js +176 -0
- package/dist/scripts/nightly-evidence-tests.js +1 -1
- package/dist/scripts/nightly-evidence.js +1 -1
- package/dist/scripts/nudge-digest.js +1 -1
- package/dist/scripts/onboarding-tests.js +21 -53
- package/dist/scripts/opensky-check.js +1 -1
- package/dist/scripts/opensky-tests.js +1 -1
- package/dist/scripts/pnpm-dsh-closure-proof.js +20 -0
- package/dist/scripts/price-drift-tests.js +1 -1
- package/dist/scripts/price-drift-watch.js +1 -1
- package/dist/scripts/probe-poi-tests.js +1 -1
- package/dist/scripts/product-metrics.js +1 -1
- package/dist/scripts/publish-preverify.js +40 -4
- package/dist/scripts/realtime-pricing-tests.js +1 -1
- package/dist/scripts/replay-async.js +1 -1
- package/dist/scripts/replay-real.js +1 -1
- package/dist/scripts/replay.js +1 -1
- package/dist/scripts/session-attach-diagnose.js +1 -1
- package/dist/scripts/session-attach-poc.js +1 -1
- package/dist/scripts/session-benchmark.js +1 -1
- package/dist/scripts/session-extract-tests.js +1 -1
- package/dist/scripts/session-login.js +1 -1
- package/dist/scripts/session-tests.js +70 -20
- package/dist/scripts/sf-live-benchmark.js +338 -0
- package/dist/scripts/sf-live-cli-tests.js +21 -0
- package/dist/scripts/sf-soft-score-tests.js +108 -0
- package/dist/scripts/sf-summary.js +93 -0
- package/dist/scripts/skeleton-check.js +1 -1
- package/dist/scripts/skeleton-integration-test.js +1 -1
- package/dist/scripts/skills-contract-tests.js +1 -1
- package/dist/scripts/smoke-session-gate-tests.js +29 -0
- package/dist/scripts/smoke.js +79 -33
- package/dist/scripts/state-cli-tests.js +1 -1
- package/dist/scripts/state-cli.js +1 -1
- package/dist/scripts/static-golden-tests.js +299 -0
- package/dist/scripts/time-eval-tests.js +1 -1
- package/dist/scripts/travel-timeline-tests.js +1 -1
- package/dist/scripts/unified-tests.js +1 -1
- package/dist/scripts/weather-tests.js +694 -44
- package/dist/scripts/z3-race-tests.js +1 -1
- package/dist/src/artifact-gate.js +1 -1
- package/dist/src/benchmark-agent-conformance.js +370 -0
- package/dist/src/benchmark-environment-bridge.js +384 -0
- package/dist/src/benchmark-headless-child-diagnostics.js +173 -0
- package/dist/src/benchmark-tool-isolation.js +124 -0
- package/dist/src/bookable-facts.js +1 -1
- package/dist/src/booking-saga.js +1 -1
- package/dist/src/booking-surface/availability-policy-v2.js +830 -0
- package/dist/src/booking-surface/canonical-schema.js +113 -0
- package/dist/src/booking-surface/contracts-v2.js +89 -0
- package/dist/src/booking-surface/contracts.js +46 -0
- package/dist/src/booking-surface/dsh-planner.js +453 -0
- package/dist/src/booking-surface/dsh-plugin.js +93 -0
- package/dist/src/booking-surface/error-codes.js +94 -0
- package/dist/src/booking-surface/index.js +15 -0
- package/dist/src/booking-surface/profile.js +68 -0
- package/dist/src/booking-surface/runtime-v2.js +1771 -0
- package/dist/src/booking-surface/runtime.js +351 -0
- package/dist/src/booking-surface/server-v2.js +334 -0
- package/dist/src/booking-surface/server.js +302 -0
- package/dist/src/booking-surface/startup.js +159 -0
- package/dist/src/booking-surface/validation-v2.js +319 -0
- package/dist/src/booking-surface/validation.js +809 -0
- package/dist/src/bridge.js +1 -1
- package/dist/src/companions.js +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/dsh-llm.js +1 -1
- package/dist/src/engine.js +1 -1
- package/dist/src/evaluation-cadence.js +234 -0
- package/dist/src/evaluation-contracts.js +906 -0
- package/dist/src/i18n.js +1 -1
- package/dist/src/index.js +50 -19
- package/dist/src/journey.js +1 -1
- package/dist/src/loop.js +1 -1
- package/dist/src/memory-capture.js +1 -1
- package/dist/src/memory-decay.js +1 -1
- package/dist/src/memory-utility.js +1 -1
- package/dist/src/mock-llm.js +1 -1
- package/dist/src/model.js +1 -1
- package/dist/src/realtime-pricing.js +1 -1
- package/dist/src/slot-spec.js +1 -1
- package/dist/src/state-ledger.js +2 -1
- package/dist/src/time-anchor.js +1 -1
- package/dist/src/tool-budget.js +136 -0
- package/dist/src/tool-packet.js +1 -1
- package/dist/src/travel-slots.js +1 -1
- package/dist/src/travel-timeline.js +1 -1
- package/dist/src/unified.js +1 -1
- package/dist/src/wish-pool.js +1 -1
- package/dist/src/z3-shared.js +1 -1
- package/extension/README.md +31 -7
- package/package.json +286 -11
- package/schemas/booking.surface.v1.schema.json +927 -0
- package/schemas/booking.surface.v2.schema.json +61 -0
- package/ts/capabilities/flyai.ts +16 -3
- package/ts/capabilities/session/extension-bridge.ts +37 -14
- package/ts/capabilities/session/extension-channel.ts +6 -3
- package/ts/capabilities/session/extension-distribution.ts +264 -0
- package/ts/capabilities/session/golden-score.ts +139 -0
- package/ts/capabilities/session/health-watch.ts +1 -1
- package/ts/capabilities/session/static-flight-golden.ts +209 -0
- package/ts/capabilities/session/wizard.ts +34 -176
- package/ts/capabilities/session-login.ts +15 -5
- package/ts/capabilities/session-search.ts +40 -3
- package/ts/capabilities/weather.ts +141 -52
- package/ts/package.json +3 -3
- package/ts/src/benchmark-agent-conformance.ts +448 -0
- package/ts/src/benchmark-environment-bridge.ts +348 -0
- package/ts/src/benchmark-headless-child-diagnostics.ts +184 -0
- package/ts/src/benchmark-tool-isolation.ts +166 -0
- package/ts/src/booking-surface/availability-policy-v2.ts +523 -0
- package/ts/src/booking-surface/canonical-schema.js +113 -0
- package/ts/src/booking-surface/contracts-v2.ts +118 -0
- package/ts/src/booking-surface/contracts.ts +380 -0
- package/ts/src/booking-surface/dsh-planner.ts +452 -0
- package/ts/src/booking-surface/dsh-plugin.js +93 -0
- package/ts/src/booking-surface/error-codes.ts +101 -0
- package/ts/src/booking-surface/index.ts +12 -0
- package/ts/src/booking-surface/profile.ts +42 -0
- package/ts/src/booking-surface/runtime-v2.ts +1466 -0
- package/ts/src/booking-surface/runtime.ts +483 -0
- package/ts/src/booking-surface/server-v2.ts +247 -0
- package/ts/src/booking-surface/server.ts +324 -0
- package/ts/src/booking-surface/startup.ts +196 -0
- package/ts/src/booking-surface/validation-v2.ts +205 -0
- package/ts/src/booking-surface/validation.ts +453 -0
- package/ts/src/index.ts +64 -11
- package/ts/src/state-ledger.ts +1 -0
- package/ts/src/tool-budget.ts +165 -0
- package/dist/scripts/wizard-bootstrap.js +0 -32
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util'
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
3
|
+
|
|
4
|
+
const BRIDGE_TOOL = 'gotry_benchmark_environment'
|
|
5
|
+
const DENIED = 'BENCHMARK_TOOL_NOT_ALLOWED'
|
|
6
|
+
const SURFACE_VIOLATION = 'BENCHMARK_TOOL_SURFACE_VIOLATION'
|
|
7
|
+
|
|
8
|
+
type Disposer = () => void | Promise<void>
|
|
9
|
+
type ScopedTools = {
|
|
10
|
+
restrict?: (filter: { allow: string[] }) => unknown
|
|
11
|
+
guard?: (check: (execution: { name: string; agent?: unknown; [key: string]: unknown }) => string | undefined) => unknown
|
|
12
|
+
presentAs?: (mode: 'native') => unknown
|
|
13
|
+
}
|
|
14
|
+
type Agent = {
|
|
15
|
+
ctx?: {
|
|
16
|
+
tools?: ScopedTools
|
|
17
|
+
effect?: (action: () => unknown, label?: string) => unknown
|
|
18
|
+
on?: (event: string, listener: (...args: any[]) => unknown, options?: { prepend?: boolean }) => unknown
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
type RootTools = {
|
|
22
|
+
get?: (name: string, agent?: unknown) => unknown
|
|
23
|
+
schemas?: (agent?: unknown) => unknown
|
|
24
|
+
}
|
|
25
|
+
type EventBus = {
|
|
26
|
+
on?: (event: string, listener: (...args: any[]) => unknown, options?: { prepend?: boolean }) => unknown
|
|
27
|
+
effect?: (action: () => unknown, label?: string) => unknown
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function requireDisposer(value: unknown, capability: string): Disposer {
|
|
31
|
+
if (typeof value !== 'function') throw new Error(`benchmark environment ${capability} disposer unavailable`)
|
|
32
|
+
return value as Disposer
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Install the benchmark bridge's fail-closed, exact-tool per-agent boundary. */
|
|
36
|
+
export function installBenchmarkToolIsolation(ctx: Context): void {
|
|
37
|
+
const rootTools = ctx.tools as unknown as RootTools
|
|
38
|
+
if (typeof rootTools.get !== 'function') throw new Error('benchmark environment root tool lookup unavailable')
|
|
39
|
+
if (typeof rootTools.schemas !== 'function') throw new Error('benchmark environment root tool schemas unavailable')
|
|
40
|
+
const bridgeDefinition = rootTools.get(BRIDGE_TOOL)
|
|
41
|
+
if (!bridgeDefinition) throw new Error('benchmark environment bridge definition unavailable')
|
|
42
|
+
const rootSchemas = rootTools.schemas()
|
|
43
|
+
const expected = Array.isArray(rootSchemas)
|
|
44
|
+
? rootSchemas.filter(schema => schema && typeof schema === 'object' && (schema as { name?: unknown }).name === BRIDGE_TOOL)
|
|
45
|
+
: []
|
|
46
|
+
if (expected.length !== 1) throw new Error('benchmark environment bridge schema unavailable')
|
|
47
|
+
const expectedSchemas = structuredClone(expected)
|
|
48
|
+
|
|
49
|
+
const getService = (ctx as unknown as { get?: (name: string) => unknown }).get
|
|
50
|
+
const agents = typeof getService === 'function'
|
|
51
|
+
? getService.call(ctx, 'agents')
|
|
52
|
+
: (ctx as unknown as { agents?: unknown }).agents
|
|
53
|
+
const listAgents = (agents as { list?: () => unknown[] } | undefined)?.list
|
|
54
|
+
if (typeof listAgents !== 'function') throw new Error('benchmark environment agent registry unavailable')
|
|
55
|
+
if (listAgents.call(agents).length > 0) throw new Error('benchmark environment isolation requires cold-start; live agents are not allowed')
|
|
56
|
+
|
|
57
|
+
const bus = ctx as unknown as EventBus
|
|
58
|
+
if (typeof bus.on !== 'function') throw new Error('benchmark environment isolation event bus unavailable')
|
|
59
|
+
if (typeof bus.effect !== 'function') throw new Error('benchmark environment isolation effect unavailable')
|
|
60
|
+
|
|
61
|
+
const active = new Map<unknown, Disposer>()
|
|
62
|
+
let stopping = false
|
|
63
|
+
const assertSurface = (agent: unknown, schemas: unknown = rootTools.schemas!(agent)): void => {
|
|
64
|
+
if (!active.has(agent)
|
|
65
|
+
|| rootTools.get!(BRIDGE_TOOL, agent) !== bridgeDefinition
|
|
66
|
+
|| !isDeepStrictEqual(schemas, expectedSchemas)) {
|
|
67
|
+
throw new Error(SURFACE_VIOLATION)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const take = (agent: unknown): void | Promise<void> => {
|
|
71
|
+
const dispose = active.get(agent)
|
|
72
|
+
if (!dispose) return
|
|
73
|
+
active.delete(agent)
|
|
74
|
+
return dispose()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
requireDisposer(bus.effect(function* () {
|
|
78
|
+
yield requireDisposer(bus.on!('agent/created', (payload: { agent?: Agent }) => {
|
|
79
|
+
if (stopping) throw new Error(SURFACE_VIOLATION)
|
|
80
|
+
const agent = payload.agent
|
|
81
|
+
const tools = agent?.ctx?.tools
|
|
82
|
+
const agentEffect = agent?.ctx?.effect
|
|
83
|
+
const agentOn = agent?.ctx?.on
|
|
84
|
+
if (!agent) throw new Error('benchmark environment created agent unavailable')
|
|
85
|
+
if (typeof tools?.restrict !== 'function') throw new Error('benchmark environment scoped restrict unavailable')
|
|
86
|
+
if (typeof tools.guard !== 'function') throw new Error('benchmark environment scoped guard unavailable')
|
|
87
|
+
if (typeof tools.presentAs !== 'function') throw new Error('benchmark environment scoped presentAs unavailable')
|
|
88
|
+
if (typeof agentEffect !== 'function') throw new Error('benchmark environment scoped effect unavailable')
|
|
89
|
+
if (typeof agentOn !== 'function') throw new Error('benchmark environment scoped event bus unavailable')
|
|
90
|
+
if (active.has(agent)) throw new Error('benchmark environment duplicate agent isolation')
|
|
91
|
+
|
|
92
|
+
let owned: Disposer | undefined
|
|
93
|
+
owned = requireDisposer(agentEffect.call(agent.ctx, function* () {
|
|
94
|
+
yield () => {
|
|
95
|
+
if (active.get(agent) === owned) active.delete(agent)
|
|
96
|
+
}
|
|
97
|
+
yield requireDisposer(tools.guard!(execution => {
|
|
98
|
+
if (stopping || execution.name !== BRIDGE_TOOL || !execution.agent) return DENIED
|
|
99
|
+
return rootTools.get!(BRIDGE_TOOL, execution.agent) === bridgeDefinition ? undefined : DENIED
|
|
100
|
+
}), 'scoped guard')
|
|
101
|
+
yield requireDisposer(agentOn.call(agent.ctx, 'system-prompt/assemble', async (
|
|
102
|
+
_assembly: unknown,
|
|
103
|
+
_context: unknown,
|
|
104
|
+
next?: () => Promise<unknown>,
|
|
105
|
+
) => {
|
|
106
|
+
if (stopping) throw new Error(SURFACE_VIOLATION)
|
|
107
|
+
if (typeof next !== 'function') throw new Error('benchmark environment scoped assembly continuation unavailable')
|
|
108
|
+
const result = await next()
|
|
109
|
+
if (stopping) throw new Error(SURFACE_VIOLATION)
|
|
110
|
+
return result
|
|
111
|
+
}, { prepend: true }), 'scoped assembly listener')
|
|
112
|
+
yield requireDisposer(tools.presentAs!('native'), 'scoped presentAs')
|
|
113
|
+
yield requireDisposer(tools.restrict!({ allow: [BRIDGE_TOOL] }), 'scoped restrict')
|
|
114
|
+
}, 'benchmark-environment-agent-tool-isolation'), 'scoped effect')
|
|
115
|
+
active.set(agent, owned)
|
|
116
|
+
try {
|
|
117
|
+
assertSurface(agent)
|
|
118
|
+
} catch (error) {
|
|
119
|
+
try {
|
|
120
|
+
const pending = take(agent)
|
|
121
|
+
pending?.catch(() => undefined)
|
|
122
|
+
} catch {
|
|
123
|
+
// Preserve the stable admission error after invoking the owned cleanup.
|
|
124
|
+
}
|
|
125
|
+
throw error
|
|
126
|
+
}
|
|
127
|
+
}), 'agent/created listener')
|
|
128
|
+
|
|
129
|
+
yield requireDisposer(bus.on!('agent/disposed', (payload: { agent?: unknown }) => {
|
|
130
|
+
if (payload.agent) return take(payload.agent)
|
|
131
|
+
}), 'agent/disposed listener')
|
|
132
|
+
|
|
133
|
+
yield requireDisposer(bus.on!('system-prompt/assemble', async (
|
|
134
|
+
_assembly: unknown,
|
|
135
|
+
context: { agent?: unknown; scope?: unknown } | undefined,
|
|
136
|
+
next?: () => Promise<unknown>,
|
|
137
|
+
) => {
|
|
138
|
+
if (typeof next !== 'function') throw new Error('benchmark environment assembly continuation unavailable')
|
|
139
|
+
const result = await next()
|
|
140
|
+
const agent = context?.agent
|
|
141
|
+
if (!agent) return result
|
|
142
|
+
if (stopping || context?.scope !== agent || !result || typeof result !== 'object') throw new Error(SURFACE_VIOLATION)
|
|
143
|
+
assertSurface(agent, (result as { tools?: unknown }).tools)
|
|
144
|
+
return result
|
|
145
|
+
}, { prepend: true }), 'system-prompt/assemble listener')
|
|
146
|
+
|
|
147
|
+
yield requireDisposer(bus.on!('agent/pre-step', async (
|
|
148
|
+
payload: { agent?: unknown },
|
|
149
|
+
next?: () => Promise<unknown>,
|
|
150
|
+
) => {
|
|
151
|
+
if (typeof next !== 'function') throw new Error('benchmark environment pre-step continuation unavailable')
|
|
152
|
+
const decision = await next()
|
|
153
|
+
const agent = payload.agent
|
|
154
|
+
if (stopping || !agent) throw new Error(SURFACE_VIOLATION)
|
|
155
|
+
assertSurface(agent)
|
|
156
|
+
return decision
|
|
157
|
+
}, { prepend: true }), 'agent/pre-step listener')
|
|
158
|
+
|
|
159
|
+
yield () => {
|
|
160
|
+
// The agent fiber, not this plugin fiber, owns scoped effects. On HMR the
|
|
161
|
+
// live agent must remain quarantined until its own disposal/process exit.
|
|
162
|
+
active.clear()
|
|
163
|
+
}
|
|
164
|
+
yield () => { stopping = true }
|
|
165
|
+
}, 'benchmark-environment-tool-isolation'), 'root effect')
|
|
166
|
+
}
|