@leitwerk-dev/test-support 0.3.0 → 0.4.0
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/dist/{chunk-OE4NHDVS.js → chunk-3RWI5WJK.js} +2 -2
- package/dist/{chunk-5BZSJ4OO.js → chunk-DNUGHAYN.js} +37 -4
- package/dist/chunk-DNUGHAYN.js.map +1 -0
- package/dist/{chunk-P2FF4AP7.js → chunk-FDXRT6UZ.js} +57 -2
- package/dist/chunk-FDXRT6UZ.js.map +1 -0
- package/dist/{chunk-E4Y7XND5.js → chunk-WRAVDPEM.js} +16 -27
- package/dist/chunk-WRAVDPEM.js.map +1 -0
- package/dist/extension-integration-harness.d.ts +2 -2
- package/dist/extension-integration-harness.d.ts.map +1 -1
- package/dist/fixtures.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/integration-harness.d.ts +2 -0
- package/dist/integration-harness.d.ts.map +1 -1
- package/dist/integration.d.ts +1 -1
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +54 -101
- package/dist/integration.js.map +1 -1
- package/dist/local-git.d.ts +9 -0
- package/dist/local-git.d.ts.map +1 -1
- package/dist/local-git.js +31 -0
- package/dist/local-git.js.map +1 -1
- package/dist/model-provider-fixtures.d.ts +7 -0
- package/dist/model-provider-fixtures.d.ts.map +1 -1
- package/dist/process.d.ts +32 -2
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +24 -15
- package/dist/process.js.map +1 -1
- package/dist/server-extension-test-harness.d.ts +3 -1
- package/dist/server-extension-test-harness.d.ts.map +1 -1
- package/dist/stub-worker-entry.js +1 -1
- package/dist/supported-question-fixtures.d.ts.map +1 -1
- package/dist/worker-testing/index.d.ts +1 -1
- package/dist/worker-testing/index.d.ts.map +1 -1
- package/dist/worker-testing/index.js +7 -4
- package/dist/worker-testing/index.js.map +1 -1
- package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +15 -0
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/extension-integration-harness.ts +44 -139
- package/src/index.ts +2 -0
- package/src/integration-harness.ts +17 -1
- package/src/integration.ts +1 -0
- package/src/local-git.ts +34 -0
- package/src/model-provider-fixtures.ts +40 -0
- package/src/process.ts +22 -12
- package/src/server-extension-test-harness.ts +40 -1
- package/src/supported-question-fixtures.ts +0 -20
- package/src/worker-testing/index.ts +1 -0
- package/src/worker-testing/schema-driven-stub-pi.ts +11 -23
- package/src/worker-testing/stub-pi-tree-handle.ts +34 -1
- package/src/worker-testing/worker-start-payload.ts +1 -0
- package/dist/chunk-5BZSJ4OO.js.map +0 -1
- package/dist/chunk-E4Y7XND5.js.map +0 -1
- package/dist/chunk-P2FF4AP7.js.map +0 -1
- /package/dist/{chunk-OE4NHDVS.js.map → chunk-3RWI5WJK.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSchemaDrivenStubPiFactory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WRAVDPEM.js";
|
|
4
4
|
|
|
5
5
|
// src/worker-testing/in-process-worker-spawn.ts
|
|
6
6
|
import { EventEmitter } from "events";
|
|
@@ -87,4 +87,4 @@ function createInProcessWorkerSpawn(options = {}) {
|
|
|
87
87
|
export {
|
|
88
88
|
createInProcessWorkerSpawn
|
|
89
89
|
};
|
|
90
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-3RWI5WJK.js.map
|
|
@@ -10,14 +10,29 @@ import {
|
|
|
10
10
|
createEventBus
|
|
11
11
|
} from "@leitwerk-dev/process-sdk";
|
|
12
12
|
import { flushAsyncWork } from "@leitwerk-dev/worker-protocol";
|
|
13
|
-
function createPollingTestExtension(manifest, setup) {
|
|
13
|
+
function createPollingTestExtension(manifest, setup, manual = false) {
|
|
14
14
|
let provider;
|
|
15
15
|
return {
|
|
16
16
|
/** @internal */
|
|
17
17
|
manifest,
|
|
18
18
|
/** @internal */
|
|
19
19
|
setupServer(api) {
|
|
20
|
-
provider = setup(
|
|
20
|
+
provider = setup(
|
|
21
|
+
manual ? {
|
|
22
|
+
...api,
|
|
23
|
+
get(token) {
|
|
24
|
+
const value = api.get(token);
|
|
25
|
+
return token === coreHostCapabilities.serverSetup && value && !Array.isArray(value) ? {
|
|
26
|
+
...value,
|
|
27
|
+
polling: {
|
|
28
|
+
create: ({ pollOnce }) => ({
|
|
29
|
+
poll: pollOnce
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
} : value;
|
|
33
|
+
}
|
|
34
|
+
} : api
|
|
35
|
+
);
|
|
21
36
|
},
|
|
22
37
|
/** @public */
|
|
23
38
|
poll() {
|
|
@@ -67,6 +82,22 @@ function createDefaultServerSetupDeps() {
|
|
|
67
82
|
serverBaseUrl: "https://leitwerk.example",
|
|
68
83
|
components: {},
|
|
69
84
|
externalWrites: createInMemoryExternalWriteLog(),
|
|
85
|
+
publications: {
|
|
86
|
+
publication: () => null,
|
|
87
|
+
publicationByExternalId: () => null,
|
|
88
|
+
reservePublication() {
|
|
89
|
+
throw new Error("Configure publication storage for this test");
|
|
90
|
+
},
|
|
91
|
+
finishPublication() {
|
|
92
|
+
throw new Error("Configure publication storage for this test");
|
|
93
|
+
},
|
|
94
|
+
releaseRejectedPublication() {
|
|
95
|
+
throw new Error("Configure publication storage for this test");
|
|
96
|
+
},
|
|
97
|
+
markPublicationTriggered() {
|
|
98
|
+
throw new Error("Configure publication storage for this test");
|
|
99
|
+
}
|
|
100
|
+
},
|
|
70
101
|
polling: {
|
|
71
102
|
create(options) {
|
|
72
103
|
return { poll: options.pollOnce };
|
|
@@ -95,6 +126,7 @@ function createDefaultServerSetupDeps() {
|
|
|
95
126
|
broadcaster: { sendDurable: () => {
|
|
96
127
|
} },
|
|
97
128
|
commands: {
|
|
129
|
+
applyProcessObservation: async () => ({ ok: true, process: null }),
|
|
98
130
|
getDeferredProcessActivationSnapshots: () => ({ outcome: "process_not_found" }),
|
|
99
131
|
activateDeferredProcess: async () => ({
|
|
100
132
|
ok: true,
|
|
@@ -126,7 +158,8 @@ function createDefaultServerSetupDeps() {
|
|
|
126
158
|
resolveUiDefaults: async () => ({}),
|
|
127
159
|
resolveUiOptions: async () => ({}),
|
|
128
160
|
resolveUiRelaunchInput: async (_launcherId, previousInput) => ({ ...previousInput }),
|
|
129
|
-
resolveUiLauncher: async () => ({ ok: false, errors: [] })
|
|
161
|
+
resolveUiLauncher: async () => ({ ok: false, errors: [] }),
|
|
162
|
+
resolveUiLauncherPreview: async () => ({ ok: false, errors: [] })
|
|
130
163
|
},
|
|
131
164
|
launcherRecentValues: {
|
|
132
165
|
list: () => ({}),
|
|
@@ -189,4 +222,4 @@ export {
|
|
|
189
222
|
createInMemoryExternalWriteLog,
|
|
190
223
|
createTestServerSetupCapability
|
|
191
224
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-DNUGHAYN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server-extension-test-harness.ts"],"sourcesContent":["import { type ExtensionCatalog, setupServerExtensions } from \"@leitwerk-dev/extension-runtime\";\nimport { buildExtensionCatalogFromModules } from \"@leitwerk-dev/extension-runtime/testing\";\nimport {\n\tbindExternalWrites,\n\ttype ExternalWriteLogRepoLike,\n} from \"@leitwerk-dev/external-writes/internal\";\nimport {\n\ttype CoreServerSetupDeps,\n\tcoreHostCapabilities,\n\tcreateCapabilityAccessor,\n\tcreateEventBus,\n\ttype IntegrationToolDefinition,\n\ttype LeitwerkExtensionModule,\n\ttype ProvidedCapability,\n\ttype ServerExtensionAPI,\n\ttype ServerExtensionEventMap,\n} from \"@leitwerk-dev/process-sdk\";\nimport { flushAsyncWork } from \"@leitwerk-dev/worker-protocol\";\n\nexport { flushAsyncWork };\n\n/** Register a test provider and expose its poll result without erasing its type. @public */\nexport function createPollingTestExtension<T>(\n\tmanifest: LeitwerkExtensionModule[\"manifest\"],\n\tsetup: (api: ServerExtensionAPI) =>\n\t\t| {\n\t\t\t\t/** @internal */\n\t\t\t\tpoll(): Promise<T>;\n\t\t }\n\t\t| undefined,\n\t/** Disable scheduled polling so tests control every observation. @internal */\n\tmanual = false,\n) {\n\tlet provider: ReturnType<typeof setup>;\n\treturn {\n\t\t/** @internal */\n\t\tmanifest,\n\t\t/** @internal */\n\t\tsetupServer(api: ServerExtensionAPI) {\n\t\t\tprovider = setup(\n\t\t\t\tmanual\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...api,\n\t\t\t\t\t\t\tget<T>(token: import(\"@leitwerk-dev/process-sdk\").CapabilityToken<T>) {\n\t\t\t\t\t\t\t\tconst value = api.get(token);\n\t\t\t\t\t\t\t\treturn token === coreHostCapabilities.serverSetup && value && !Array.isArray(value)\n\t\t\t\t\t\t\t\t\t? ({\n\t\t\t\t\t\t\t\t\t\t\t...value,\n\t\t\t\t\t\t\t\t\t\t\tpolling: {\n\t\t\t\t\t\t\t\t\t\t\t\tcreate: ({ pollOnce }: { pollOnce: () => Promise<unknown> }) => ({\n\t\t\t\t\t\t\t\t\t\t\t\t\tpoll: pollOnce,\n\t\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t} as T)\n\t\t\t\t\t\t\t\t\t: value;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: api,\n\t\t\t);\n\t\t},\n\t\t/** @public */\n\t\tpoll() {\n\t\t\tif (!provider) throw new Error(`Test provider '${manifest.id}' has not been initialized`);\n\t\t\treturn provider.poll();\n\t\t},\n\t};\n}\n\n/** @internal */\nexport function createToolCollector(\n\twrites: ExternalWriteLogRepoLike = createInMemoryExternalWriteLog(),\n) {\n\tconst tools = new Map<string, IntegrationToolDefinition>();\n\tconst api = {\n\t\ttool: (tool: IntegrationToolDefinition) =>\n\t\t\ttools.set(tool.name, {\n\t\t\t\t...tool,\n\t\t\t\texecute: (ctx, args) =>\n\t\t\t\t\ttool.execute(\n\t\t\t\t\t\t{ ...ctx, externalWrites: bindExternalWrites(writes, ctx.process.id) },\n\t\t\t\t\t\targs,\n\t\t\t\t\t),\n\t\t\t}),\n\t} as unknown as ServerExtensionAPI;\n\treturn {\n\t\t/** @internal */\n\t\tapi,\n\t\t/** @internal */\n\t\ttools,\n\t};\n}\n\n/** @internal */\nexport interface InMemoryExternalWriteLog {\n\t/** @internal */\n\trecords: {\n\t\t/** @internal */\n\t\tdedupKey: string;\n\t}[];\n\t/** @internal */\n\thasDedupKey(key: string): boolean;\n\t/** @internal */\n\trecord(input: {\n\t\t/** @internal */\n\t\tdedupKey: string;\n\t}): {\n\t\t/** @internal */\n\t\tdedupKey: string;\n\t};\n\t/** @internal */\n\tgetDedupKeys(): ReadonlySet<string>;\n}\n\n/** @internal */\nexport function createInMemoryExternalWriteLog(): InMemoryExternalWriteLog {\n\tconst dedupKeys = new Set<string>();\n\tconst records: { dedupKey: string }[] = [];\n\treturn {\n\t\trecords,\n\t\thasDedupKey(key: string) {\n\t\t\treturn dedupKeys.has(key);\n\t\t},\n\t\trecord(input: { dedupKey: string }) {\n\t\t\tdedupKeys.add(input.dedupKey);\n\t\t\trecords.push(input);\n\t\t\treturn input;\n\t\t},\n\t\tgetDedupKeys() {\n\t\t\treturn dedupKeys;\n\t\t},\n\t};\n}\n\nfunction createDefaultServerSetupDeps(): CoreServerSetupDeps {\n\treturn {\n\t\tserverBaseUrl: \"https://leitwerk.example\",\n\t\tcomponents: {},\n\t\texternalWrites: createInMemoryExternalWriteLog(),\n\t\tpublications: {\n\t\t\tpublication: () => null,\n\t\t\tpublicationByExternalId: () => null,\n\t\t\treservePublication() {\n\t\t\t\tthrow new Error(\"Configure publication storage for this test\");\n\t\t\t},\n\t\t\tfinishPublication() {\n\t\t\t\tthrow new Error(\"Configure publication storage for this test\");\n\t\t\t},\n\t\t\treleaseRejectedPublication() {\n\t\t\t\tthrow new Error(\"Configure publication storage for this test\");\n\t\t\t},\n\t\t\tmarkPublicationTriggered() {\n\t\t\t\tthrow new Error(\"Configure publication storage for this test\");\n\t\t\t},\n\t\t},\n\t\tpolling: {\n\t\t\tcreate(options) {\n\t\t\t\treturn { poll: options.pollOnce };\n\t\t\t},\n\t\t},\n\t\trepositoryCredentials: { register: () => {} },\n\t\tprocesses: {\n\t\t\tcreate: () => {\n\t\t\t\tthrow new Error(\"not used\");\n\t\t\t},\n\t\t\tgetById: () => null,\n\t\t\tlistAll: () => [],\n\t\t\tupdate: () => null,\n\t\t},\n\t\tprojects: {\n\t\t\tcreate: () => {\n\t\t\t\tthrow new Error(\"not used\");\n\t\t\t},\n\t\t\tgetByInstanceAndKey: () => null,\n\t\t\tupdate: () => null,\n\t\t\tlistByInstance: () => [],\n\t\t},\n\t\tevents: { create: () => {}, listByInstance: () => [] },\n\t\tbroadcaster: { sendDurable: () => {} },\n\t\tcommands: {\n\t\t\tapplyProcessObservation: async () => ({ ok: true, process: null }),\n\t\t\tgetDeferredProcessActivationSnapshots: () => ({ outcome: \"process_not_found\" }),\n\t\t\tactivateDeferredProcess: async () => ({\n\t\t\t\tok: true,\n\t\t\t\tprocess: null,\n\t\t\t\tdata: { outcome: \"not_applicable\" },\n\t\t\t}),\n\t\t\tparkDeferredProcessActivationFailure: async () => ({\n\t\t\t\tok: true,\n\t\t\t\tprocess: null,\n\t\t\t\tdata: { outcome: \"parked\" },\n\t\t\t}),\n\t\t\tstartProcess: async () => ({ ok: true, process: null }),\n\t\t\tabortProcess: async () => ({ ok: true, process: null }),\n\t\t\tretryProcess: async () => ({ ok: true, process: null }),\n\t\t\tcontinueFailedTurn: async () => ({ ok: true, process: null }),\n\t\t\tqueueInputs: async () => ({ ok: true, process: null }),\n\t\t},\n\t\tprocessActions: {\n\t\t\tlistVisibleActions: () => [],\n\t\t\texecuteAction: async () => ({ ok: true, process: null }),\n\t\t},\n\t\texternalSources: {\n\t\t\tlistArmed: () => [],\n\t\t\tfire: async () => ({ ok: true, process: null }),\n\t\t},\n\t\tgetSupervisor: () => undefined,\n\t\tlauncherService: {\n\t\t\tlistUiLaunchers: () => [],\n\t\t\tresolveUiDefaults: async () => ({}),\n\t\t\tresolveUiOptions: async () => ({}),\n\t\t\tresolveUiRelaunchInput: async (_launcherId, previousInput) => ({ ...previousInput }),\n\t\t\tresolveUiLauncher: async () => ({ ok: false as const, errors: [] }),\n\t\t\tresolveUiLauncherPreview: async () => ({ ok: false as const, errors: [] }),\n\t\t},\n\t\tlauncherRecentValues: {\n\t\t\tlist: () => ({}),\n\t\t\trecord: () => {},\n\t\t},\n\t\tlauncherModelConfigs: {\n\t\t\tgetSchema: async () => null,\n\t\t\tpreview: async () => null,\n\t\t},\n\t\tlaunchPlans: {\n\t\t\tasync prepare(launchPlan, opts) {\n\t\t\t\treturn {\n\t\t\t\t\tok: true as const,\n\t\t\t\t\tlaunchPlan,\n\t\t\t\t\tmodelConfig: opts?.modelConfig ?? {},\n\t\t\t\t\twarnings: [],\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\tlaunchRuns: {\n\t\t\tasync startProgrammatic() {\n\t\t\t\tthrow new Error(\"not used\");\n\t\t\t},\n\t\t\tasync startWatcher() {\n\t\t\t\tthrow new Error(\"not used\");\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** @public */\nexport function createTestServerSetupCapability(\n\toverrides: Partial<CoreServerSetupDeps> = {},\n): CoreServerSetupDeps {\n\tconst defaults = createDefaultServerSetupDeps();\n\treturn {\n\t\t...defaults,\n\t\t...overrides,\n\t\tprocesses: { ...defaults.processes, ...overrides.processes },\n\t\tprojects: { ...defaults.projects, ...overrides.projects },\n\t\tevents: { ...defaults.events, ...overrides.events },\n\t\tbroadcaster: { ...defaults.broadcaster, ...overrides.broadcaster },\n\t\tcommands: { ...defaults.commands, ...overrides.commands },\n\t\tprocessActions: { ...defaults.processActions, ...overrides.processActions },\n\t\texternalSources: { ...defaults.externalSources, ...overrides.externalSources },\n\t\tlauncherService: { ...defaults.launcherService, ...overrides.launcherService },\n\t\tlauncherRecentValues: {\n\t\t\t...defaults.launcherRecentValues,\n\t\t\t...overrides.launcherRecentValues,\n\t\t},\n\t\tlauncherModelConfigs: {\n\t\t\t...defaults.launcherModelConfigs,\n\t\t\t...overrides.launcherModelConfigs,\n\t\t},\n\t\tlaunchPlans: { ...defaults.launchPlans, ...overrides.launchPlans },\n\t\tlaunchRuns: { ...defaults.launchRuns, ...overrides.launchRuns },\n\t};\n}\n\n/** @internal */\nexport interface ServerExtensionTestHarness {\n\t/** @internal */\n\tcatalog: ExtensionCatalog;\n\t/** @internal */\n\tevents: ReturnType<typeof createEventBus>;\n\t/** @internal */\n\tserverSetup: CoreServerSetupDeps;\n\t/** @internal */\n\tstartHooks: Array<() => void | Promise<void>>;\n\t/** @internal */\n\tstopHooks: Array<() => void | Promise<void>>;\n\t/** @internal */\n\tflushAsyncWork: typeof flushAsyncWork;\n}\n\n/** @internal */\nexport async function setupServerExtensionTest(input: {\n\t/** @internal */\n\tmodules: readonly LeitwerkExtensionModule[];\n\t/** @internal */\n\tprovidedCapabilities?: readonly ProvidedCapability[];\n\t/** @internal */\n\tserverSetup?: Partial<CoreServerSetupDeps>;\n\t/** @internal */\n\tonStart?: (handler: () => void | Promise<void>) => void;\n\t/** @internal */\n\tonStop?: (handler: () => void | Promise<void>) => void;\n}): Promise<ServerExtensionTestHarness> {\n\tconst catalog = await buildExtensionCatalogFromModules(input.modules);\n\tconst events = createEventBus<ServerExtensionEventMap>();\n\tconst serverSetup = createTestServerSetupCapability(input.serverSetup);\n\tconst capabilities = createCapabilityAccessor([\n\t\t{\n\t\t\ttoken: coreHostCapabilities.serverSetup,\n\t\t\tvalue: serverSetup,\n\t\t},\n\t\t...(input.providedCapabilities ?? []),\n\t]);\n\tconst startHooks: Array<() => void | Promise<void>> = [];\n\tconst stopHooks: Array<() => void | Promise<void>> = [];\n\n\tawait setupServerExtensions(catalog, {\n\t\tevents,\n\t\tprovide: capabilities.provide.bind(capabilities),\n\t\tget: capabilities.get.bind(capabilities),\n\t\trequire: capabilities.require.bind(capabilities),\n\t\ttool() {},\n\t\tonStart(handler) {\n\t\t\tstartHooks.push(handler);\n\t\t\tinput.onStart?.(handler);\n\t\t},\n\t\tonStop(handler) {\n\t\t\tstopHooks.push(handler);\n\t\t\tinput.onStop?.(handler);\n\t\t},\n\t});\n\n\treturn {\n\t\tcatalog,\n\t\tevents,\n\t\tserverSetup,\n\t\tstartHooks,\n\t\tstopHooks,\n\t\tflushAsyncWork,\n\t};\n}\n"],"mappings":";AAAA,SAAgC,6BAA6B;AAC7D,SAAS,wCAAwC;AACjD;AAAA,EACC;AAAA,OAEM;AACP;AAAA,EAEC;AAAA,EACA;AAAA,EACA;AAAA,OAMM;AACP,SAAS,sBAAsB;AAKxB,SAAS,2BACf,UACA,OAOA,SAAS,OACR;AACD,MAAI;AACJ,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA,YAAY,KAAyB;AACpC,iBAAW;AAAA,QACV,SACG;AAAA,UACA,GAAG;AAAA,UACH,IAAO,OAA+D;AACrE,kBAAM,QAAQ,IAAI,IAAI,KAAK;AAC3B,mBAAO,UAAU,qBAAqB,eAAe,SAAS,CAAC,MAAM,QAAQ,KAAK,IAC9E;AAAA,cACD,GAAG;AAAA,cACH,SAAS;AAAA,gBACR,QAAQ,CAAC,EAAE,SAAS,OAA6C;AAAA,kBAChE,MAAM;AAAA,gBACP;AAAA,cACD;AAAA,YACD,IACC;AAAA,UACJ;AAAA,QACD,IACC;AAAA,MACJ;AAAA,IACD;AAAA;AAAA,IAEA,OAAO;AACN,UAAI,CAAC,SAAU,OAAM,IAAI,MAAM,kBAAkB,SAAS,EAAE,4BAA4B;AACxF,aAAO,SAAS,KAAK;AAAA,IACtB;AA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AAE,GAAG,SAAS,WAAW,GAAG,UAAU,UAAU;AAAA,IAC3D,UAAU,EAAE,GAAG,SAAS,UAAU,GAAG,UAAU,SAAS;AAAA,IACxD,QAAQ,EAAE,GAAG,SAAS,QAAQ,GAAG,UAAU,OAAO;AAAA,IAClD,aAAa,EAAE,GAAG,SAAS,aAAa,GAAG,UAAU,YAAY;AAAA,IACjE,UAAU,EAAE,GAAG,SAAS,UAAU,GAAG,UAAU,SAAS;AAAA,IACxD,gBAAgB,EAAE,GAAG,SAAS,gBAAgB,GAAG,UAAU,eAAe;AAAA,IAC1E,iBAAiB,EAAE,GAAG,SAAS,iBAAiB,GAAG,UAAU,gBAAgB;AAAA,IAC7E,iBAAiB,EAAE,GAAG,SAAS,iBAAiB,GAAG,UAAU,gBAAgB;AAAA,IAC7E,sBAAsB;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,GAAG,UAAU;AAAA,IACd;AAAA,IACA,sBAAsB;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,GAAG,UAAU;AAAA,IACd;AAAA,IACA,aAAa,EAAE,GAAG,SAAS,aAAa,GAAG,UAAU,YAAY;AAAA,IACjE,YAAY,EAAE,GAAG,SAAS,YAAY,GAAG,UAAU,WAAW;AAAA,EAC/D;AACD;","names":[]}
|
|
@@ -65,8 +65,63 @@ async function postImmediateLaunch(serverBaseUrl, launcherId, body) {
|
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// src/model-provider-fixtures.ts
|
|
69
|
+
import {
|
|
70
|
+
builtinPiProvider,
|
|
71
|
+
defineModelProvider,
|
|
72
|
+
defineModelProviders
|
|
73
|
+
} from "@leitwerk-dev/process-sdk";
|
|
74
|
+
var fixtureModelProfiles = [
|
|
75
|
+
{
|
|
76
|
+
id: "claude_fast",
|
|
77
|
+
thinkingLevel: "medium",
|
|
78
|
+
provider: "anthropic",
|
|
79
|
+
modelId: "claude-sonnet-4-20250514"
|
|
80
|
+
},
|
|
81
|
+
{ id: "local_qwen", thinkingLevel: "low", provider: "ollama", modelId: "qwen2.5-coder:14b" }
|
|
82
|
+
];
|
|
83
|
+
function fixtureModelProviders(...models) {
|
|
84
|
+
return defineModelProviders(
|
|
85
|
+
(rawConfig) => models.map(({ id, modelId, piProvider = id, server = false }) => ({
|
|
86
|
+
definition: defineModelProvider({
|
|
87
|
+
id,
|
|
88
|
+
parseConfig: () => ({ config: {} }),
|
|
89
|
+
worker: builtinPiProvider(piProvider),
|
|
90
|
+
...server ? { server: builtinPiProvider(piProvider) } : {},
|
|
91
|
+
models: () => [{ modelId, availability: "available" }],
|
|
92
|
+
secrets: () => ({})
|
|
93
|
+
}),
|
|
94
|
+
rawConfig
|
|
95
|
+
}))
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function withDefaultModelFixture(config, catalog) {
|
|
99
|
+
if (config.pi.model_profiles.length === 0 && !config.pi.default_model_profile) {
|
|
100
|
+
config.pi.default_model_profile = "test-support-fixture";
|
|
101
|
+
config.pi.model_profiles = [
|
|
102
|
+
{ id: "test-support-fixture", provider: "test-support-fixture", model_id: "fixture" }
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
if (!config.pi.model_profiles.some((profile) => profile.provider === "test-support-fixture"))
|
|
106
|
+
return catalog;
|
|
107
|
+
return {
|
|
108
|
+
...catalog,
|
|
109
|
+
modelProviders: [
|
|
110
|
+
...catalog.modelProviders,
|
|
111
|
+
{
|
|
112
|
+
ownerExtensionId: "test-support-fixture",
|
|
113
|
+
packageName: "@leitwerk-dev/test-support",
|
|
114
|
+
resolve: fixtureModelProviders({ id: "test-support-fixture", modelId: "fixture" })
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
68
120
|
export {
|
|
69
121
|
postImmediateLaunchRequest,
|
|
70
|
-
postImmediateLaunch
|
|
122
|
+
postImmediateLaunch,
|
|
123
|
+
fixtureModelProfiles,
|
|
124
|
+
fixtureModelProviders,
|
|
125
|
+
withDefaultModelFixture
|
|
71
126
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-FDXRT6UZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/http-launch.ts","../src/model-provider-fixtures.ts"],"sourcesContent":["import type { LaunchRun } from \"@leitwerk-dev/domain\";\n\n/** Accepts a launch-run request shape and waits for its admitted process commit. @internal */\nexport async function postImmediateLaunchRequest(\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n): Promise<Response> {\n\tconst url = new URL(String(input));\n\tconst match = /^\\/api\\/launchers\\/([^/]+)\\/launch-runs$/.exec(url.pathname);\n\tif (!match?.[1]) throw new Error(`Expected an immediate launch-run URL, received '${url}'`);\n\tconst body = init?.body ? (JSON.parse(String(init.body)) as Record<string, unknown>) : {};\n\treturn postImmediateLaunch(url.origin, decodeURIComponent(match[1]), body);\n}\n\n/**\n * Admits an immediate launch through the public asynchronous HTTP contract and waits until the\n * process commit or a pre-commit failure is observable. Intended for integration-test setup.\n */\n/** @public */\nexport async function postImmediateLaunch(\n\tserverBaseUrl: string,\n\tlauncherId: string,\n\tbody: Record<string, unknown>,\n): Promise<Response> {\n\tconst admitted = await fetch(\n\t\t`${serverBaseUrl.replace(/\\/$/, \"\")}/api/launchers/${encodeURIComponent(launcherId)}/launch-runs`,\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"content-type\": \"application/json\", \"idempotency-key\": crypto.randomUUID() },\n\t\t\tbody: JSON.stringify({ ...body, schedule: { mode: \"now\" } }),\n\t\t},\n\t);\n\tconst admittedBody = (await admitted.json()) as { launchRunId?: string };\n\tif (admitted.status !== 202 || !admittedBody.launchRunId) {\n\t\treturn new Response(JSON.stringify(admittedBody), {\n\t\t\tstatus: admitted.status,\n\t\t\theaders: { \"content-type\": \"application/json\" },\n\t\t});\n\t}\n\n\tlet launchRun: LaunchRun;\n\tconst deadline = Date.now() + 10_000;\n\tfor (;;) {\n\t\tconst response = await fetch(\n\t\t\t`${serverBaseUrl.replace(/\\/$/, \"\")}/api/launch-runs/${admittedBody.launchRunId}`,\n\t\t);\n\t\tconst responseBody = (await response.json()) as { launchRun: LaunchRun };\n\t\tif (\n\t\t\tresponseBody.launchRun.instanceId ||\n\t\t\t[\"failed\", \"cancelled\"].includes(responseBody.launchRun.status)\n\t\t) {\n\t\t\tlaunchRun = responseBody.launchRun;\n\t\t\tbreak;\n\t\t}\n\t\tif (Date.now() >= deadline) throw new Error(\"Timed out waiting for immediate launch admission\");\n\t\tawait new Promise((resolve) => setTimeout(resolve, 10));\n\t}\n\n\tif (!launchRun.instanceId) {\n\t\tconst failure = launchRun.steps.find((step) => step.status === \"failed\");\n\t\treturn new Response(\n\t\t\tJSON.stringify({\n\t\t\t\terror: failure?.safeSummary ?? \"Launch failed\",\n\t\t\t\tlaunchRunId: launchRun.id,\n\t\t\t}),\n\t\t\t{ status: 400, headers: { \"content-type\": \"application/json\" } },\n\t\t);\n\t}\n\tconst detailResponse = await fetch(\n\t\t`${serverBaseUrl.replace(/\\/$/, \"\")}/api/processes/${encodeURIComponent(launchRun.instanceId)}`,\n\t);\n\tconst detail = (await detailResponse.json()) as { process: unknown; projects?: unknown[] };\n\tconst failure = launchRun.steps.find((step) => step.status === \"failed\");\n\treturn new Response(\n\t\tJSON.stringify({\n\t\t\tprocess: detail.process,\n\t\t\tprojects: detail.projects ?? [],\n\t\t\tlaunchRunId: launchRun.id,\n\t\t\t...(launchRun.status === \"failed\"\n\t\t\t\t? { error: failure?.safeSummary ?? \"Process was created, but startup failed\" }\n\t\t\t\t: {}),\n\t\t}),\n\t\t{\n\t\t\tstatus: launchRun.status === \"failed\" ? 200 : 201,\n\t\t\theaders: { \"content-type\": \"application/json\" },\n\t\t},\n\t);\n}\n","import type { ExtensionCatalog } from \"@leitwerk-dev/extension-runtime\";\nimport {\n\tbuiltinPiProvider,\n\tdefineModelProvider,\n\tdefineModelProviders,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { ConfigSnapshot } from \"@leitwerk-dev/protocol\";\nimport type { ExtensionIntegrationHarnessOptions } from \"./extension-integration-harness.js\";\n\n/** @internal */\nexport const fixtureModelProfiles: NonNullable<ExtensionIntegrationHarnessOptions[\"models\"]> = [\n\t{\n\t\tid: \"claude_fast\",\n\t\tthinkingLevel: \"medium\",\n\t\tprovider: \"anthropic\",\n\t\tmodelId: \"claude-sonnet-4-20250514\",\n\t},\n\t{ id: \"local_qwen\", thinkingLevel: \"low\", provider: \"ollama\", modelId: \"qwen2.5-coder:14b\" },\n];\n\n/** @public */\nexport type FixtureModelProviderSet = ReturnType<typeof defineModelProviders>;\n\n/** @public */\nexport function fixtureModelProviders(\n\t...models: {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tmodelId: string;\n\t\t/** @internal */\n\t\tpiProvider?: string;\n\t\t/** @public */\n\t\tserver?: boolean;\n\t}[]\n): FixtureModelProviderSet {\n\treturn defineModelProviders((rawConfig) =>\n\t\tmodels.map(({ id, modelId, piProvider = id, server = false }) => ({\n\t\t\tdefinition: defineModelProvider({\n\t\t\t\tid,\n\t\t\t\tparseConfig: () => ({ config: {} }),\n\t\t\t\tworker: builtinPiProvider(piProvider),\n\t\t\t\t...(server ? { server: builtinPiProvider(piProvider) } : {}),\n\t\t\t\tmodels: () => [{ modelId, availability: \"available\" }],\n\t\t\t\tsecrets: () => ({}),\n\t\t\t}),\n\t\t\trawConfig,\n\t\t})),\n\t);\n}\n\n/** Explicit model wiring for server tests that do not exercise an LLM. @internal */\nexport function withDefaultModelFixture(\n\tconfig: ConfigSnapshot,\n\tcatalog: ExtensionCatalog,\n): ExtensionCatalog {\n\tif (config.pi.model_profiles.length === 0 && !config.pi.default_model_profile) {\n\t\tconfig.pi.default_model_profile = \"test-support-fixture\";\n\t\tconfig.pi.model_profiles = [\n\t\t\t{ id: \"test-support-fixture\", provider: \"test-support-fixture\", model_id: \"fixture\" },\n\t\t];\n\t}\n\tif (!config.pi.model_profiles.some((profile) => profile.provider === \"test-support-fixture\"))\n\t\treturn catalog;\n\treturn {\n\t\t...catalog,\n\t\tmodelProviders: [\n\t\t\t...catalog.modelProviders,\n\t\t\t{\n\t\t\t\townerExtensionId: \"test-support-fixture\",\n\t\t\t\tpackageName: \"@leitwerk-dev/test-support\",\n\t\t\t\tresolve: fixtureModelProviders({ id: \"test-support-fixture\", modelId: \"fixture\" }),\n\t\t\t},\n\t\t],\n\t};\n}\n"],"mappings":";AAGA,eAAsB,2BACrB,OACA,MACoB;AACpB,QAAM,MAAM,IAAI,IAAI,OAAO,KAAK,CAAC;AACjC,QAAM,QAAQ,2CAA2C,KAAK,IAAI,QAAQ;AAC1E,MAAI,CAAC,QAAQ,CAAC,EAAG,OAAM,IAAI,MAAM,mDAAmD,GAAG,GAAG;AAC1F,QAAM,OAAO,MAAM,OAAQ,KAAK,MAAM,OAAO,KAAK,IAAI,CAAC,IAAgC,CAAC;AACxF,SAAO,oBAAoB,IAAI,QAAQ,mBAAmB,MAAM,CAAC,CAAC,GAAG,IAAI;AAC1E;AAOA,eAAsB,oBACrB,eACA,YACA,MACoB;AACpB,QAAM,WAAW,MAAM;AAAA,IACtB,GAAG,cAAc,QAAQ,OAAO,EAAE,CAAC,kBAAkB,mBAAmB,UAAU,CAAC;AAAA,IACnF;AAAA,MACC,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,oBAAoB,mBAAmB,OAAO,WAAW,EAAE;AAAA,MACtF,MAAM,KAAK,UAAU,EAAE,GAAG,MAAM,UAAU,EAAE,MAAM,MAAM,EAAE,CAAC;AAAA,IAC5D;AAAA,EACD;AACA,QAAM,eAAgB,MAAM,SAAS,KAAK;AAC1C,MAAI,SAAS,WAAW,OAAO,CAAC,aAAa,aAAa;AACzD,WAAO,IAAI,SAAS,KAAK,UAAU,YAAY,GAAG;AAAA,MACjD,QAAQ,SAAS;AAAA,MACjB,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC/C,CA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AA,MACX;AAAA,QACC,kBAAkB;AAAA,QAClB,aAAa;AAAA,QACb,SAAS,sBAAsB,EAAE,IAAI,wBAAwB,SAAS,UAAU,CAAC;AAAA,MAClF;AAAA,IACD;AAAA,EACD;AACD;","names":["failure"]}
|
|
@@ -4,6 +4,11 @@ import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { CURRENT_SESSION_VERSION } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { isEnoent } from "@leitwerk-dev/process-sdk";
|
|
7
|
+
function formatBranchText(entries = [], missingMessageText) {
|
|
8
|
+
return entries.map(
|
|
9
|
+
(entry) => entry.type === "custom_message" ? entry.content : entry.type === "message" ? entry.message ? entry.message.content : missingMessageText : ""
|
|
10
|
+
).filter((value) => typeof value === "string").join("\n\n");
|
|
11
|
+
}
|
|
7
12
|
function stringifyToolResult(result) {
|
|
8
13
|
if (typeof result === "string") {
|
|
9
14
|
return result;
|
|
@@ -474,7 +479,7 @@ var StubPiTreeHandle = class {
|
|
|
474
479
|
createdEntryIds.push(intermediateEntryId);
|
|
475
480
|
}
|
|
476
481
|
}
|
|
477
|
-
} else if (tools.
|
|
482
|
+
} else if ([...tools.keys()].some((name) => name !== "abort_turn") && !hasScriptedChunks) {
|
|
478
483
|
throw new Error(
|
|
479
484
|
`Stub Pi prompt requires a stub tool-call script when tools are provided (${[...tools.keys()].join(", ")})`
|
|
480
485
|
);
|
|
@@ -716,6 +721,7 @@ var StubPiTreeHandleFactory = class {
|
|
|
716
721
|
toolCallScriptResolver: this.toolCallScriptResolver ? (context) => this.toolCallScriptResolver?.({
|
|
717
722
|
...context,
|
|
718
723
|
instanceId: opts.instanceId,
|
|
724
|
+
...opts.iteration ? { iteration: opts.iteration } : {},
|
|
719
725
|
workspaceRoot: opts.workspaceRoot,
|
|
720
726
|
sessionCwd: opts.sessionCwd
|
|
721
727
|
}) : void 0,
|
|
@@ -766,33 +772,15 @@ function synthesizeStubToolArgs(parameters) {
|
|
|
766
772
|
);
|
|
767
773
|
}
|
|
768
774
|
function createSchemaDrivenToolCallScriptResolver() {
|
|
769
|
-
return ({ tools }) => {
|
|
770
|
-
const
|
|
775
|
+
return ({ tools: availableTools }) => {
|
|
776
|
+
const tools = availableTools.filter((tool) => tool.name !== "abort_turn");
|
|
777
|
+
const markdownTool = tools.find((tool) => tool.name === "markdown_result");
|
|
771
778
|
const completionTool = tools.find(
|
|
772
|
-
(
|
|
779
|
+
(tool) => tool.name !== "markdown_result" && tool.name !== "upload_result_images"
|
|
773
780
|
);
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
{
|
|
778
|
-
toolName: markdownTool.name,
|
|
779
|
-
args: synthesizeStubToolArgs(markdownTool.parameters)
|
|
780
|
-
},
|
|
781
|
-
{
|
|
782
|
-
toolName: completionTool.name,
|
|
783
|
-
args: synthesizeStubToolArgs(completionTool.parameters)
|
|
784
|
-
}
|
|
785
|
-
]
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
const tool = markdownTool ?? completionTool ?? tools[0];
|
|
789
|
-
if (!tool) {
|
|
790
|
-
return void 0;
|
|
791
|
-
}
|
|
792
|
-
return {
|
|
793
|
-
toolName: tool.name,
|
|
794
|
-
args: synthesizeStubToolArgs(tool.parameters)
|
|
795
|
-
};
|
|
781
|
+
const selectedTools = markdownTool && completionTool ? [markdownTool, completionTool] : [markdownTool ?? completionTool ?? tools[0]];
|
|
782
|
+
const calls = selectedTools.filter((tool) => tool !== void 0).map((tool) => ({ toolName: tool.name, args: synthesizeStubToolArgs(tool.parameters) }));
|
|
783
|
+
return calls.length > 1 ? { calls } : calls[0];
|
|
796
784
|
};
|
|
797
785
|
}
|
|
798
786
|
function createSchemaDrivenStubPiFactory(options = {}) {
|
|
@@ -802,8 +790,9 @@ function createSchemaDrivenStubPiFactory(options = {}) {
|
|
|
802
790
|
}
|
|
803
791
|
|
|
804
792
|
export {
|
|
793
|
+
formatBranchText,
|
|
805
794
|
StubPiTreeHandle,
|
|
806
795
|
StubPiTreeHandleFactory,
|
|
807
796
|
createSchemaDrivenStubPiFactory
|
|
808
797
|
};
|
|
809
|
-
//# sourceMappingURL=chunk-
|
|
798
|
+
//# sourceMappingURL=chunk-WRAVDPEM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/worker-testing/stub-pi-tree-handle.ts","../src/worker-testing/schema-driven-stub-pi.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { CURRENT_SESSION_VERSION, type SessionHeader } from \"@earendil-works/pi-coding-agent\";\nimport type {\n\tPiCustomMessageInput,\n\tPiCustomTool,\n\tPiEvent,\n\tPiEventHandler,\n\tPiPromptOptions,\n\tPiRunDetails,\n\tPiSessionDiagnostic,\n\tPiSessionDiagnosticHandler,\n\tPiTreeEntry,\n\tPiTreeHandle,\n\tPiTreeNode,\n\tPiTurnExecutionResult,\n} from \"@leitwerk-dev/process-sdk\";\nimport { isEnoent } from \"@leitwerk-dev/process-sdk\";\nimport type {\n\tPiManagedBootstrapOptions,\n\tPiManagedBootstrapResult,\n\tPiTreeHandleFactory,\n\tPiTreeHandleOptions,\n\tPiTreePlanningOptions,\n\tPiTreePlanningSnapshot,\n} from \"@leitwerk-dev/worker\";\n\n/** @public */\nexport interface StubToolCallScriptCall {\n\t/** @public */\n\ttoolName: string;\n\t/** @public */\n\targs: Record<string, unknown>;\n\t/** @internal */\n\tintermediateEntryCount?: number;\n}\n\n/** @public */\nexport type StubToolCallScriptItem =\n\t| StubToolCallScriptCall\n\t| {\n\t\t\t/** @public */\n\t\t\tcalls: readonly StubToolCallScriptCall[];\n\t\t\t/** @public */\n\t\t\ttextChunks?: readonly string[];\n\t\t\t/** @public */\n\t\t\tthinkingChunks?: readonly string[];\n\t\t\t/** @public */\n\t\t\tchunkDelayMs?: number;\n\t\t\t/** Optional scripted model reaction to a tool result, within the same turn. @internal */\n\t\t\tafterToolResult?: (\n\t\t\t\tcall: StubToolCallScriptCall,\n\t\t\t\tresult: unknown,\n\t\t\t) => StubToolCallScriptCall | undefined;\n\t };\n\n/** @public */\nexport interface StubToolCallScriptResolverContext {\n\t/** @public */\n\tpromptText: string;\n\t/** Identified turn prompt, when the SDK prompt uses a custom message. @internal */\n\tidentifiedPromptText?: string;\n\t/** @public */\n\ttools: readonly PiCustomTool[];\n\t/** @public */\n\tinstanceId?: string;\n\t/** Active frozen item when the turn is one item of a mapped LLM turn. @public */\n\titeration?: {\n\t\t/** @public */\n\t\titemKey: string;\n\t\t/** @public */\n\t\titemLabel: string;\n\t\t/** @public */\n\t\titemIndex: number;\n\t\t/** @public */\n\t\titemCount: number;\n\t\t/** @public */\n\t\titem: unknown;\n\t};\n\t/** @public */\n\tworkspaceRoot?: string;\n\t/** @public */\n\tsessionCwd?: string;\n\t/** @public */\n\ttreeFile: string;\n\t/** @internal */\n\tturnSequence: number;\n}\n\n/** @public */\nexport type StubToolCallScriptResolver = (\n\tcontext: StubToolCallScriptResolverContext,\n) => StubToolCallScriptItem | undefined | Promise<StubToolCallScriptItem | undefined>;\n\n/** Formats textual branch entries without choosing a session. @internal */\nexport function formatBranchText(\n\tentries: readonly PiTreeEntry[] = [],\n\tmissingMessageText?: string,\n): string {\n\treturn entries\n\t\t.map((entry) =>\n\t\t\tentry.type === \"custom_message\"\n\t\t\t\t? entry.content\n\t\t\t\t: entry.type === \"message\"\n\t\t\t\t\t? entry.message\n\t\t\t\t\t\t? entry.message.content\n\t\t\t\t\t\t: missingMessageText\n\t\t\t\t\t: \"\",\n\t\t)\n\t\t.filter((value): value is string => typeof value === \"string\")\n\t\t.join(\"\\n\\n\");\n}\n\nfunction stringifyToolResult(result: unknown): string {\n\tif (typeof result === \"string\") {\n\t\treturn result;\n\t}\n\tif (result === undefined) {\n\t\treturn \"ok\";\n\t}\n\ttry {\n\t\treturn JSON.stringify(result, null, 2);\n\t} catch {\n\t\treturn String(result);\n\t}\n}\n\nfunction expandStubToolCallScriptItem(item: StubToolCallScriptItem): StubToolCallScriptCall[] {\n\tif (\"calls\" in item) {\n\t\treturn [...item.calls];\n\t}\n\treturn [item];\n}\n\nfunction stubToolCallId(turnSeq: number, totalCalls: number, index: number): string {\n\tif (totalCalls <= 1) {\n\t\treturn `tool-${turnSeq}`;\n\t}\n\treturn `tool-${turnSeq}-${index + 1}`;\n}\n\n/** @internal */\ninterface StubPiTreeState {\n\t/** @internal */\n\theader?: SessionHeader;\n\t/** @internal */\n\tturnSeq: number;\n\t/** @internal */\n\tcurrentLeafId: string | null;\n\t/** @internal */\n\tentries: Map<string, PiTreeEntry>;\n\t/** @internal */\n\tchildIdsByParent: Map<string | null, string[]>;\n}\n\ninterface PersistedStubPiTreeState {\n\tturnSeq: number;\n\tcurrentLeafId: string | null;\n\tentries: PiTreeEntry[];\n\tchildIdsByParent: Array<{ parentId: string | null; childIds: string[] }>;\n}\n\nfunction createEmptyStubPiTreeState(): StubPiTreeState {\n\treturn {\n\t\tturnSeq: 0,\n\t\tcurrentLeafId: null,\n\t\tentries: new Map<string, PiTreeEntry>(),\n\t\tchildIdsByParent: new Map<string | null, string[]>(),\n\t};\n}\n\nfunction indexStubEntry(state: StubPiTreeState, entry: PiTreeEntry): void {\n\tstate.entries.set(entry.id, entry);\n\tconst siblings = state.childIdsByParent.get(entry.parentId) ?? [];\n\tsiblings.push(entry.id);\n\tstate.childIdsByParent.set(entry.parentId, siblings);\n}\n\nfunction deriveStubLeafIdFromEntries(state: StubPiTreeState): string | null {\n\tlet leafId: string | null = null;\n\tfor (const entryId of state.entries.keys()) {\n\t\tleafId = entryId;\n\t}\n\treturn leafId;\n}\n\nfunction serializeStubPiTreeState(state: StubPiTreeState, recordSessionTrace: boolean): string {\n\tif (recordSessionTrace) {\n\t\treturn `${[\n\t\t\tJSON.stringify({\n\t\t\t\t...state.header,\n\t\t\t\tstubState: { turnSeq: state.turnSeq, currentLeafId: state.currentLeafId },\n\t\t\t}),\n\t\t\t...[...state.entries.values()].map((entry) => JSON.stringify(entry)),\n\t\t].join(\"\\n\")}\\n`;\n\t}\n\tconst persisted: PersistedStubPiTreeState = {\n\t\tturnSeq: state.turnSeq,\n\t\tcurrentLeafId: state.currentLeafId,\n\t\tentries: [...state.entries.values()],\n\t\tchildIdsByParent: [...state.childIdsByParent.entries()].map(([parentId, childIds]) => ({\n\t\t\tparentId,\n\t\t\tchildIds: [...childIds],\n\t\t})),\n\t};\n\treturn JSON.stringify(persisted);\n}\n\nfunction deserializeStubPiTreeState(value: string): StubPiTreeState {\n\tconst lines = value.trim().split(\"\\n\");\n\tconst header = JSON.parse(lines[0]) as SessionHeader & {\n\t\tstubState?: { turnSeq: number; currentLeafId: string | null };\n\t};\n\tif (header.type === \"session\") {\n\t\tconst entries = lines\n\t\t\t.slice(1)\n\t\t\t.filter(Boolean)\n\t\t\t.map((line) => JSON.parse(line) as PiTreeEntry);\n\t\tconst state = createEmptyStubPiTreeState();\n\t\tstate.header = header;\n\t\tstate.turnSeq = header.stubState?.turnSeq ?? 0;\n\t\tstate.currentLeafId = header.stubState?.currentLeafId ?? null;\n\t\tfor (const entry of entries) indexStubEntry(state, entry);\n\t\treturn state;\n\t}\n\tconst parsed = JSON.parse(value) as PersistedStubPiTreeState;\n\treturn {\n\t\tturnSeq: typeof parsed.turnSeq === \"number\" ? parsed.turnSeq : 0,\n\t\tcurrentLeafId:\n\t\t\ttypeof parsed.currentLeafId === \"string\" || parsed.currentLeafId === null\n\t\t\t\t? parsed.currentLeafId\n\t\t\t\t: null,\n\t\tentries: new Map((parsed.entries ?? []).map((entry) => [entry.id, entry])),\n\t\tchildIdsByParent: new Map(\n\t\t\t(parsed.childIdsByParent ?? []).map((entry) => [entry.parentId, [...entry.childIds]]),\n\t\t),\n\t};\n}\n\n/** @public */\nexport class StubPiTreeHandle implements PiTreeHandle {\n\t/** @public */\n\treadonly sessionId: string;\n\t/** @internal */\n\treadonly treeFile: string;\n\t/** @internal */\n\treadonly isResumed: boolean;\n\n\t/** @internal */\n\treadonly prompts: string[] = [];\n\t/** @internal */\n\treadonly steers: string[] = [];\n\t/** @internal */\n\tbeforeTurn?: (\n\t\tkind: \"prompt\" | \"literal\" | \"custom\" | \"continue\",\n\t\toptions: PiPromptOptions | undefined,\n\t\tpromptText: string | undefined,\n\t) => boolean | undefined | Promise<boolean | undefined>;\n\n\tprivate _closed = false;\n\tprivate turnAbort = new AbortController();\n\tprivate branchDriftPending = false;\n\tprivate readonly handlers = new Set<PiEventHandler>();\n\tprivate readonly diagnosticHandlers = new Set<PiSessionDiagnosticHandler>();\n\tprivate readonly toolCallScriptResolver?: StubToolCallScriptResolver;\n\tprivate readonly state: StubPiTreeState;\n\tprivate readonly runDetails: PiRunDetails;\n\tprivate readonly persistState?: (() => Promise<void>) | undefined;\n\tprivate readonly recordSessionTrace: boolean;\n\n\t/** @internal */\n\tconstructor(options: {\n\t\t/** @internal */\n\t\tsessionId: string;\n\t\t/** @internal */\n\t\ttreeFile: string;\n\t\t/** @internal */\n\t\tisResumed: boolean;\n\t\t/** @internal */\n\t\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\t\t/** @internal */\n\t\tstate?: StubPiTreeState;\n\t\t/** @internal */\n\t\trunDetails?: Partial<PiRunDetails>;\n\t\t/** @internal */\n\t\tpersistState?: () => Promise<void>;\n\t\t/** @internal */\n\t\trecordSessionTrace?: boolean;\n\t}) {\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.treeFile = options.treeFile;\n\t\tthis.isResumed = options.isResumed;\n\t\tthis.toolCallScriptResolver = options.toolCallScriptResolver;\n\t\tthis.state = options.state ?? createEmptyStubPiTreeState();\n\t\tthis.persistState = options.persistState;\n\t\tthis.recordSessionTrace = options.recordSessionTrace ?? false;\n\t\tthis.runDetails = {\n\t\t\tloadedAgentsFiles: options.runDetails?.loadedAgentsFiles?.map((file) => ({ ...file })) ?? [],\n\t\t\tloadedSkills: options.runDetails?.loadedSkills?.map((skill) => ({ ...skill })) ?? [],\n\t\t\tavailableToolNames: [...(options.runDetails?.availableToolNames ?? [])],\n\t\t};\n\t}\n\n\t/** @internal */\n\tget closed(): boolean {\n\t\treturn this._closed;\n\t}\n\n\t/** @internal */\n\tfailNextTurnWithBranchDrift(): void {\n\t\tthis.branchDriftPending = true;\n\t}\n\n\tprivate assertOpen(): void {\n\t\tif (this._closed) {\n\t\t\tthrow new Error(\"Handle is closed\");\n\t\t}\n\t}\n\n\tprivate addEntry(entry: PiTreeEntry): void {\n\t\tindexStubEntry(this.state, entry);\n\t\tthis.state.currentLeafId = entry.id;\n\t}\n\n\tprivate createMessageEntry(\n\t\tid: string,\n\t\tparentId: string | null,\n\t\trole: \"user\" | \"assistant\",\n\t\tcontent: unknown,\n\t\ttimestamp: string,\n\t): PiTreeEntry {\n\t\treturn {\n\t\t\tid,\n\t\t\tparentId,\n\t\t\ttype: \"message\",\n\t\t\ttimestamp,\n\t\t\tmessage: {\n\t\t\t\trole,\n\t\t\t\tcontent,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate emitEvent(event: PiEvent): void {\n\t\tfor (const handler of this.handlers) {\n\t\t\thandler(event);\n\t\t}\n\t}\n\n\t/** @internal */\n\tgetRunDetails(): PiRunDetails {\n\t\treturn {\n\t\t\tloadedAgentsFiles: this.runDetails.loadedAgentsFiles.map((file) => ({ ...file })),\n\t\t\tloadedSkills: this.runDetails.loadedSkills.map((skill) => ({ ...skill })),\n\t\t\tavailableToolNames: [...this.runDetails.availableToolNames],\n\t\t};\n\t}\n\n\t/** @internal */\n\tgetLeafId(): string | null {\n\t\treturn this.state.currentLeafId;\n\t}\n\n\t/** @internal */\n\tgetEntry(id: string): PiTreeEntry | undefined {\n\t\treturn this.state.entries.get(id);\n\t}\n\n\t/** @public */\n\tgetBranch(fromId: string | undefined = this.state.currentLeafId ?? undefined): PiTreeEntry[] {\n\t\tif (!fromId) {\n\t\t\treturn [];\n\t\t}\n\t\tconst branch: PiTreeEntry[] = [];\n\t\tlet currentId: string | null = fromId;\n\t\twhile (currentId) {\n\t\t\tconst entry = this.state.entries.get(currentId);\n\t\t\tif (!entry) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbranch.push(entry);\n\t\t\tcurrentId = entry.parentId;\n\t\t}\n\t\tbranch.reverse();\n\t\treturn branch;\n\t}\n\n\t/** @internal */\n\tgetChildren(parentId: string): PiTreeEntry[] {\n\t\treturn (this.state.childIdsByParent.get(parentId) ?? [])\n\t\t\t.map((childId) => this.state.entries.get(childId))\n\t\t\t.filter((entry): entry is PiTreeEntry => entry !== undefined);\n\t}\n\n\t/** @internal */\n\tgetTree(): PiTreeNode[] {\n\t\tconst buildNode = (entry: PiTreeEntry): PiTreeNode => ({\n\t\t\tentry,\n\t\t\tchildren: this.getChildren(entry.id).map(buildNode),\n\t\t});\n\t\treturn (this.state.childIdsByParent.get(null) ?? [])\n\t\t\t.map((entryId) => this.state.entries.get(entryId))\n\t\t\t.filter((entry): entry is PiTreeEntry => entry !== undefined)\n\t\t\t.map(buildNode);\n\t}\n\n\t/** @internal */\n\tasync branch(entryId: string): Promise<void> {\n\t\tthis.assertOpen();\n\t\tif (!this.state.entries.has(entryId)) {\n\t\t\tthrow new Error(`Unknown Pi entry '${entryId}'`);\n\t\t}\n\t\tthis.state.currentLeafId = entryId;\n\t\tawait this.persistState?.();\n\t}\n\n\t/** @internal */\n\tasync branchFromRoot(): Promise<void> {\n\t\tthis.assertOpen();\n\t\tthis.state.currentLeafId = null;\n\t\tawait this.persistState?.();\n\t}\n\n\t/** @internal */\n\tasync resetLeaf(): Promise<void> {\n\t\tawait this.branchFromRoot();\n\t}\n\n\t/** @internal */\n\tasync compact(\n\t\t_customInstructions?: string,\n\t\tdetails?: unknown,\n\t): Promise<{\n\t\t/** @internal */\n\t\tsummary: string;\n\t}> {\n\t\tthis.assertOpen();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst compactionEntryId = `compaction-${++this.state.turnSeq}`;\n\t\tthis.addEntry({\n\t\t\tid: compactionEntryId,\n\t\t\tparentId: this.state.currentLeafId,\n\t\t\ttype: \"compaction\",\n\t\t\ttimestamp,\n\t\t\tdetails,\n\t\t});\n\t\tawait this.persistState?.();\n\t\treturn { summary: \"Stub compaction\" };\n\t}\n\n\tprivate async executeTurn(input: {\n\t\tkind: \"prompt\" | \"literal\" | \"custom\" | \"continue\";\n\t\tpromptText?: string;\n\t\tscriptPromptText?: string;\n\t\toptions?: PiPromptOptions;\n\t\tappendPromptUserMessage: boolean;\n\t}): Promise<PiTurnExecutionResult> {\n\t\tthis.assertOpen();\n\t\tthis.turnAbort = new AbortController();\n\t\tconst signal = this.turnAbort.signal;\n\t\tif ((await this.beforeTurn?.(input.kind, input.options, input.promptText)) === false) {\n\t\t\tinput.options = undefined;\n\t\t}\n\t\tsignal.throwIfAborted();\n\t\tif (this.branchDriftPending) {\n\t\t\tthis.branchDriftPending = false;\n\t\t\tthrow Object.assign(new Error(\"stubbed Pi branch drift\"), {\n\t\t\t\tname: \"PiBranchDriftError\",\n\t\t\t\tfailureCode: \"branch_drift\",\n\t\t\t\ttoTurnFailureOptions: () => ({\n\t\t\t\t\tfailureCode: \"branch_drift\",\n\t\t\t\t\tfailureDetails: { operation: input.kind },\n\t\t\t\t\trecoveryContext: null,\n\t\t\t\t\trestorePrimaryLeaf: false,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t\tif (input.promptText !== undefined) {\n\t\t\tthis.prompts.push(input.promptText);\n\t\t}\n\t\tconst startLeafId = this.state.currentLeafId;\n\t\tconst turnId = `turn-${++this.state.turnSeq}`;\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst createdEntryIds: string[] = [];\n\t\tif (input.appendPromptUserMessage) {\n\t\t\tconst userEntryId = `user-${this.state.turnSeq}`;\n\t\t\tthis.addEntry(\n\t\t\t\tthis.createMessageEntry(\n\t\t\t\t\tuserEntryId,\n\t\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\t\"user\",\n\t\t\t\t\tinput.promptText ?? \"\",\n\t\t\t\t\ttimestamp,\n\t\t\t\t),\n\t\t\t);\n\t\t\tcreatedEntryIds.push(userEntryId);\n\t\t}\n\t\tawait this.persistState?.();\n\t\tsignal.throwIfAborted();\n\t\tthis.emitEvent({ type: \"turn.start\", turnId, data: {}, timestamp });\n\n\t\tconst tools = new Map((input.options?.tools ?? []).map((tool) => [tool.name, tool]));\n\t\tlet assistantContent = input.promptText ?? \"Continued.\";\n\t\tlet assistantContentFromScriptedMarkdown = false;\n\t\tconst scriptedItem = await this.toolCallScriptResolver?.({\n\t\t\ttreeFile: this.treeFile,\n\t\t\tturnSequence: this.state.turnSeq,\n\t\t\tpromptText: input.promptText ?? \"\",\n\t\t\tidentifiedPromptText: input.scriptPromptText,\n\t\t\ttools: input.options?.tools ?? [],\n\t\t});\n\t\tsignal.throwIfAborted();\n\t\tconst hasScriptedChunks = Boolean(\n\t\t\tscriptedItem &&\n\t\t\t\t\"calls\" in scriptedItem &&\n\t\t\t\t(scriptedItem.textChunks?.length ?? 0) + (scriptedItem.thinkingChunks?.length ?? 0),\n\t\t);\n\t\tif (hasScriptedChunks) assistantContent = \"\";\n\t\tif (scriptedItem && \"calls\" in scriptedItem) {\n\t\t\tconst streamed = { thinking: \"\", text: \"\" };\n\t\t\tconst streamEntryId = `stream-${this.state.turnSeq}`;\n\t\t\tconst streamParentId = this.state.currentLeafId;\n\t\t\tconst chunks = [\n\t\t\t\t...(scriptedItem.thinkingChunks ?? []).map((text) => ({\n\t\t\t\t\ttext,\n\t\t\t\t\tstreamType: \"thinking\" as const,\n\t\t\t\t})),\n\t\t\t\t...(scriptedItem.textChunks ?? []).map((text) => ({ text, streamType: \"text\" as const })),\n\t\t\t];\n\t\t\tfor (const { text, streamType } of chunks) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tstreamed[streamType] += text;\n\t\t\t\tassistantContent = streamed.text;\n\t\t\t\tif (this.recordSessionTrace) {\n\t\t\t\t\tconst entry = this.createMessageEntry(\n\t\t\t\t\t\tstreamEntryId,\n\t\t\t\t\t\tstreamParentId,\n\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t...(streamed.thinking ? [{ type: \"thinking\", thinking: streamed.thinking }] : []),\n\t\t\t\t\t\t\t...(streamed.text ? [{ type: \"text\", text: streamed.text }] : []),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t);\n\t\t\t\t\tif (this.state.entries.has(streamEntryId)) this.state.entries.set(streamEntryId, entry);\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.addEntry(entry);\n\t\t\t\t\t\tcreatedEntryIds.push(streamEntryId);\n\t\t\t\t\t}\n\t\t\t\t\tawait this.persistState?.();\n\t\t\t\t}\n\t\t\t\tthis.emitEvent({\n\t\t\t\t\ttype: \"stream.delta\",\n\t\t\t\t\tturnId,\n\t\t\t\t\tdata: { text, streamType },\n\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t});\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tif (scriptedItem.chunkDelayMs)\n\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", abort);\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}, scriptedItem.chunkDelayMs);\n\t\t\t\t\t\tconst abort = () => {\n\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\treject(signal.reason);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tconst scriptedCalls = scriptedItem ? expandStubToolCallScriptItem(scriptedItem) : [];\n\t\tif (scriptedCalls.length > 0) {\n\t\t\tfor (const [callIndex, scriptedCall] of scriptedCalls.entries()) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst toolCallId = stubToolCallId(this.state.turnSeq, scriptedCalls.length, callIndex);\n\t\t\t\tthis.emitEvent({\n\t\t\t\t\ttype: \"tool.call\",\n\t\t\t\t\tturnId,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\tname: scriptedCall.toolName,\n\t\t\t\t\t\targuments: scriptedCall.args,\n\t\t\t\t\t},\n\t\t\t\t\ttimestamp,\n\t\t\t\t});\n\t\t\t\tconst tool = tools.get(scriptedCall.toolName);\n\t\t\t\tif (!tool && scriptedCall.toolName === \"markdown_result\") {\n\t\t\t\t\tconst markdown = (scriptedCall.args as { markdown?: unknown }).markdown;\n\t\t\t\t\tif (typeof markdown === \"string\") {\n\t\t\t\t\t\tassistantContent = markdown;\n\t\t\t\t\t\tassistantContentFromScriptedMarkdown = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (tool) {\n\t\t\t\t\tif (this.recordSessionTrace) {\n\t\t\t\t\t\tconst entryId = `call-${toolCallId}`;\n\t\t\t\t\t\tthis.addEntry(\n\t\t\t\t\t\t\tthis.createMessageEntry(\n\t\t\t\t\t\t\t\tentryId,\n\t\t\t\t\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: \"toolCall\",\n\t\t\t\t\t\t\t\t\t\tid: toolCallId,\n\t\t\t\t\t\t\t\t\t\tname: scriptedCall.toolName,\n\t\t\t\t\t\t\t\t\t\targuments: scriptedCall.args,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tnew Date().toISOString(),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcreatedEntryIds.push(entryId);\n\t\t\t\t\t\tawait this.persistState?.();\n\t\t\t\t\t}\n\t\t\t\t\tconst recordToolResult = async (result: unknown, isError: boolean) => {\n\t\t\t\t\t\tif (!this.recordSessionTrace) return;\n\t\t\t\t\t\tconst entryId = `result-${toolCallId}`;\n\t\t\t\t\t\tconst entry = {\n\t\t\t\t\t\t\tid: entryId,\n\t\t\t\t\t\t\tparentId: this.state.currentLeafId,\n\t\t\t\t\t\t\ttype: \"message\",\n\t\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\t\ttoolName: scriptedCall.toolName,\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: stringifyToolResult(result) }],\n\t\t\t\t\t\t\t\tisError,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tthis.addEntry(entry);\n\t\t\t\t\t\tcreatedEntryIds.push(entryId);\n\t\t\t\t\t\tawait this.persistState?.();\n\t\t\t\t\t};\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tconst blocked = input.options?.shouldBlockToolCall?.(scriptedCall.toolName);\n\t\t\t\t\t\tif (blocked) throw new Error(blocked);\n\t\t\t\t\t\tconst result = await tool.execute(scriptedCall.args, {\n\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tsuspendPromptGuards: input.options?.suspendPromptGuards,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tif (!assistantContentFromScriptedMarkdown) {\n\t\t\t\t\t\t\tassistantContent = stringifyToolResult(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait recordToolResult(result, false);\n\t\t\t\t\t\tconst followUp =\n\t\t\t\t\t\t\tscriptedItem && \"calls\" in scriptedItem\n\t\t\t\t\t\t\t\t? scriptedItem.afterToolResult?.(scriptedCall, result)\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tif (followUp) scriptedCalls.push(followUp);\n\t\t\t\t\t\tthis.emitEvent({\n\t\t\t\t\t\t\ttype: \"tool.result\",\n\t\t\t\t\t\t\tturnId,\n\t\t\t\t\t\t\tdata: { toolCallId, name: scriptedCall.toolName, result },\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait recordToolResult(error instanceof Error ? error.message : String(error), true);\n\t\t\t\t\t\tthis.emitEvent({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\tturnId,\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t\t\ttoolName: scriptedCall.toolName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (let i = 0; i < (scriptedCall.intermediateEntryCount ?? 0); i++) {\n\t\t\t\t\tconst intermediateEntryId =\n\t\t\t\t\t\tscriptedCalls.length === 1\n\t\t\t\t\t\t\t? `intermediate-${this.state.turnSeq}-${i + 1}`\n\t\t\t\t\t\t\t: `intermediate-${this.state.turnSeq}-${callIndex + 1}-${i + 1}`;\n\t\t\t\t\tthis.addEntry(\n\t\t\t\t\t\tthis.createMessageEntry(\n\t\t\t\t\t\t\tintermediateEntryId,\n\t\t\t\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t\t`Intermediate entry ${i + 1}`,\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tcreatedEntryIds.push(intermediateEntryId);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ([...tools.keys()].some((name) => name !== \"abort_turn\") && !hasScriptedChunks) {\n\t\t\tthrow new Error(\n\t\t\t\t`Stub Pi prompt requires a stub tool-call script when tools are provided (${[...tools.keys()].join(\", \")})`,\n\t\t\t);\n\t\t} else if (input.promptText !== undefined && !hasScriptedChunks) {\n\t\t\tthis.emitEvent({\n\t\t\t\ttype: \"stream.delta\",\n\t\t\t\tturnId,\n\t\t\t\tdata: { text: input.promptText },\n\t\t\t\ttimestamp,\n\t\t\t});\n\t\t}\n\n\t\tsignal.throwIfAborted();\n\t\t// Keep the result entry ID without repeating content already saved in the stream entry.\n\t\tthis.addEntry(\n\t\t\tthis.createMessageEntry(\n\t\t\t\tturnId,\n\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\"assistant\",\n\t\t\t\tthis.recordSessionTrace && hasScriptedChunks && scriptedCalls.length === 0\n\t\t\t\t\t? []\n\t\t\t\t\t: assistantContent,\n\t\t\t\ttimestamp,\n\t\t\t),\n\t\t);\n\t\tcreatedEntryIds.push(turnId);\n\t\tawait this.persistState?.();\n\t\tsignal.throwIfAborted();\n\t\tthis.emitEvent({ type: \"turn.end\", turnId, data: {}, timestamp });\n\t\tconst resultEntryId = this.state.currentLeafId;\n\t\tif (!resultEntryId) {\n\t\t\tthrow new Error(\n\t\t\t\tinput.appendPromptUserMessage\n\t\t\t\t\t? \"Stub Pi prompt completed without an active leaf\"\n\t\t\t\t\t: \"Stub Pi continuation completed without an active leaf\",\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tstartLeafId,\n\t\t\tendLeafId: resultEntryId,\n\t\t\tcreatedEntryIds,\n\t\t\tresultEntryId,\n\t\t\tassistantMarkdown: assistantContent,\n\t\t};\n\t}\n\n\t/** @internal */\n\tasync prompt(text: string, options: PiPromptOptions = {}): Promise<PiTurnExecutionResult> {\n\t\treturn await this.executeTurn({\n\t\t\tkind: \"prompt\",\n\t\t\tpromptText: text,\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: true,\n\t\t});\n\t}\n\n\t/** @internal */\n\tasync promptLiteral(text: string, options: PiPromptOptions = {}): Promise<PiTurnExecutionResult> {\n\t\treturn await this.executeTurn({\n\t\t\tkind: \"literal\",\n\t\t\tpromptText: text,\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: true,\n\t\t});\n\t}\n\n\t/** @internal */\n\tasync promptCustom(\n\t\tinput: PiCustomMessageInput,\n\t\toptions: PiPromptOptions = {},\n\t): Promise<PiTurnExecutionResult> {\n\t\tconst startLeafId = this.getLeafId();\n\t\tconst promptEntryId = await this.appendCustomMessage(input);\n\t\tconst result = await this.executeTurn({\n\t\t\tkind: \"custom\",\n\t\t\tscriptPromptText: input.content,\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: false,\n\t\t});\n\t\treturn {\n\t\t\t...result,\n\t\t\tstartLeafId,\n\t\t\tcreatedEntryIds: [promptEntryId, ...result.createdEntryIds],\n\t\t};\n\t}\n\n\t/** @internal */\n\tasync continueTurn(options: PiPromptOptions = {}): Promise<PiTurnExecutionResult> {\n\t\treturn await this.executeTurn({\n\t\t\tkind: \"continue\",\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: false,\n\t\t});\n\t}\n\n\t/** @internal */\n\tasync appendUserMessage(text: string): Promise<string> {\n\t\tthis.assertOpen();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst userEntryId = `user-${++this.state.turnSeq}`;\n\t\tthis.addEntry(\n\t\t\tthis.createMessageEntry(userEntryId, this.state.currentLeafId, \"user\", text, timestamp),\n\t\t);\n\t\tawait this.persistState?.();\n\t\treturn userEntryId;\n\t}\n\n\t/** @internal */\n\tasync appendCustomMessage(input: PiCustomMessageInput): Promise<string> {\n\t\tthis.assertOpen();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst entryId = `custom-${++this.state.turnSeq}`;\n\t\tthis.addEntry({\n\t\t\tid: entryId,\n\t\t\tparentId: this.state.currentLeafId,\n\t\t\ttype: \"custom_message\",\n\t\t\ttimestamp,\n\t\t\tcustomType: \"leitwerk\",\n\t\t\tcontent: input.content,\n\t\t\tdetails: input.details,\n\t\t});\n\t\tawait this.persistState?.();\n\t\treturn entryId;\n\t}\n\n\t/** @internal */\n\tasync steer(text: string): Promise<void> {\n\t\tthis.assertOpen();\n\t\tthis.steers.push(text);\n\t}\n\n\t/** @internal */\n\tasync abortTurn(): Promise<void> {\n\t\tthis.assertOpen();\n\t\tthis.turnAbort.abort(new Error(\"Scripted turn aborted\"));\n\t}\n\n\t/** @internal */\n\tsubscribe(handler: PiEventHandler): () => void {\n\t\tthis.handlers.add(handler);\n\t\treturn () => {\n\t\t\tthis.handlers.delete(handler);\n\t\t};\n\t}\n\n\t/** @internal */\n\tsubscribeDiagnostics(handler: PiSessionDiagnosticHandler): () => void {\n\t\tthis.diagnosticHandlers.add(handler);\n\t\treturn () => {\n\t\t\tthis.diagnosticHandlers.delete(handler);\n\t\t};\n\t}\n\n\t/** @internal */\n\temitDiagnostic(diagnostic: PiSessionDiagnostic): void {\n\t\tfor (const handler of this.diagnosticHandlers) handler(diagnostic);\n\t}\n\n\t/** @internal */\n\tasync close(): Promise<void> {\n\t\tthis.turnAbort.abort(new Error(\"Scripted session closed\"));\n\t\tawait this.persistState?.();\n\t\tthis._closed = true;\n\t\tthis.handlers.clear();\n\t\tthis.diagnosticHandlers.clear();\n\t}\n}\n\n/** @public */\nexport interface StubPiTreeHandleFactoryOptions {\n\t/** @public */\n\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\t/** Persist SDK-readable JSONL with reasoning and tool messages for history/detail tests. @public */\n\trecordSessionTrace?: boolean;\n}\n\n/** @public */\nexport class StubPiTreeHandleFactory implements PiTreeHandleFactory {\n\t/** @public */\n\treadonly sessions: StubPiTreeHandle[] = [];\n\t/** @internal */\n\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\n\tprivate seq = 0;\n\tprivate readonly treeStateByFile = new Map<string, StubPiTreeState>();\n\tprivate readonly recordSessionTrace: boolean;\n\n\t/** @public */\n\tconstructor(options: StubPiTreeHandleFactoryOptions = {}) {\n\t\tthis.toolCallScriptResolver = options.toolCallScriptResolver;\n\t\tthis.recordSessionTrace = options.recordSessionTrace ?? false;\n\t}\n\n\t/** @internal */\n\tasync prepareManagedBootstrap(\n\t\topts: PiManagedBootstrapOptions,\n\t): Promise<PiManagedBootstrapResult> {\n\t\treturn {\n\t\t\tloadedResourceIds: opts.manifest.provenance.map(\n\t\t\t\t(resource: { snapshotPath: string }) => resource.snapshotPath,\n\t\t\t),\n\t\t\tloadedAgentsFiles: [],\n\t\t\tloadedSkillFiles: [],\n\t\t\tresolvedModel: { ...opts.expectedModel },\n\t\t\tdiagnostics: [],\n\t\t};\n\t}\n\n\t/** @internal */\n\tasync inspectPrimaryTree(opts: PiTreePlanningOptions): Promise<PiTreePlanningSnapshot> {\n\t\tlet treeState = this.treeStateByFile.get(opts.treeFile);\n\t\tif (!treeState) {\n\t\t\ttry {\n\t\t\t\ttreeState = deserializeStubPiTreeState(readFileSync(opts.treeFile, \"utf8\"));\n\t\t\t} catch (error) {\n\t\t\t\tif (isEnoent(error)) {\n\t\t\t\t\treturn { currentLeafId: null, entries: [] };\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tcurrentLeafId: treeState.currentLeafId ?? deriveStubLeafIdFromEntries(treeState),\n\t\t\tentries: [...treeState.entries.values()].map((entry) => ({\n\t\t\t\tid: entry.id,\n\t\t\t\tparentId: entry.parentId,\n\t\t\t})),\n\t\t};\n\t}\n\n\t/** @public */\n\tasync createPrimaryTreeHandle(opts: PiTreeHandleOptions): Promise<PiTreeHandle> {\n\t\tconst persistState = async (state: StubPiTreeState): Promise<void> => {\n\t\t\tthis.treeStateByFile.set(opts.treeFile, state);\n\t\t\ttry {\n\t\t\t\tmkdirSync(path.dirname(opts.treeFile), { recursive: true });\n\t\t\t\twriteFileSync(\n\t\t\t\t\topts.treeFile,\n\t\t\t\t\tserializeStubPiTreeState(state, this.recordSessionTrace),\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (\n\t\t\t\t\ttypeof error !== \"object\" ||\n\t\t\t\t\terror === null ||\n\t\t\t\t\t!(\"code\" in error) ||\n\t\t\t\t\t![\"ENOENT\", \"EACCES\", \"EROFS\", \"EPERM\"].includes(\n\t\t\t\t\t\tString((error as { code?: unknown }).code),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tlet treeState = this.treeStateByFile.get(opts.treeFile);\n\t\tif (!treeState && opts.resume) {\n\t\t\ttry {\n\t\t\t\tconst persisted = readFileSync(opts.treeFile, \"utf8\");\n\t\t\t\ttreeState = deserializeStubPiTreeState(persisted);\n\t\t\t} catch (error) {\n\t\t\t\tif (\n\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t\"code\" in error &&\n\t\t\t\t\t(error as { code?: unknown }).code !== \"ENOENT\"\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttreeState ??= createEmptyStubPiTreeState();\n\t\ttreeState.header ??= {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: randomUUID(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: opts.sessionCwd ?? opts.workspaceRoot ?? path.dirname(opts.treeFile),\n\t\t};\n\t\tif (opts.resume) {\n\t\t\ttreeState.currentLeafId = deriveStubLeafIdFromEntries(treeState);\n\t\t}\n\t\tthis.treeStateByFile.set(opts.treeFile, treeState);\n\t\tconst piHandle = new StubPiTreeHandle({\n\t\t\tsessionId: `stub-${++this.seq}`,\n\t\t\ttreeFile: opts.treeFile,\n\t\t\tisResumed: opts.resume,\n\t\t\ttoolCallScriptResolver: this.toolCallScriptResolver\n\t\t\t\t? (context) =>\n\t\t\t\t\t\tthis.toolCallScriptResolver?.({\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tinstanceId: opts.instanceId,\n\t\t\t\t\t\t\t...(opts.iteration ? { iteration: opts.iteration } : {}),\n\t\t\t\t\t\t\tworkspaceRoot: opts.workspaceRoot,\n\t\t\t\t\t\t\tsessionCwd: opts.sessionCwd,\n\t\t\t\t\t\t})\n\t\t\t\t: undefined,\n\t\t\tstate: treeState,\n\t\t\tpersistState: () => persistState(treeState),\n\t\t\trecordSessionTrace: this.recordSessionTrace,\n\t\t\trunDetails: {\n\t\t\t\tavailableToolNames: opts.piConfig?.availableToolNames ?? [],\n\t\t\t},\n\t\t});\n\t\tthis.sessions.push(piHandle);\n\t\tif (!opts.resume) {\n\t\t\tawait persistState(treeState);\n\t\t}\n\t\treturn piHandle;\n\t}\n}\n","import {\n\tStubPiTreeHandleFactory,\n\ttype StubToolCallScriptResolver,\n\ttype StubToolCallScriptResolverContext,\n} from \"./stub-pi-tree-handle.js\";\n\nfunction isObjectLike(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/** @internal */\nexport function synthesizeStubArgValue(key: string, spec: unknown): unknown {\n\tif (key === \"changedProjects\") {\n\t\treturn undefined;\n\t}\n\tconst type = isObjectLike(spec) && typeof spec.type === \"string\" ? spec.type : \"string\";\n\tswitch (type) {\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\treturn 1;\n\t\tcase \"boolean\":\n\t\t\treturn true;\n\t\tcase \"array\": {\n\t\t\tconst itemSpec = isObjectLike(spec) ? spec.items : undefined;\n\t\t\treturn [synthesizeStubArgValue(`${key}_item`, itemSpec)];\n\t\t}\n\t\tcase \"object\":\n\t\t\treturn {};\n\t\tdefault:\n\t\t\treturn `${key} value`;\n\t}\n}\n\n/** @internal */\nexport function synthesizeStubToolArgs(\n\tparameters: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst parameterEntries =\n\t\tisObjectLike(parameters) && parameters.type === \"object\" && isObjectLike(parameters.properties)\n\t\t\t? Object.entries(parameters.properties)\n\t\t\t: Object.entries(parameters);\n\treturn Object.fromEntries(\n\t\tparameterEntries.map(([key, spec]) => [key, synthesizeStubArgValue(key, spec)]),\n\t);\n}\n\n/** @internal */\nexport function createSchemaDrivenToolCallScriptResolver(): StubToolCallScriptResolver {\n\treturn ({ tools: availableTools }: StubToolCallScriptResolverContext) => {\n\t\t// Failure requires an explicit script; the default stub completes successful turns.\n\t\tconst tools = availableTools.filter((tool) => tool.name !== \"abort_turn\");\n\t\tconst markdownTool = tools.find((tool) => tool.name === \"markdown_result\");\n\t\tconst completionTool = tools.find(\n\t\t\t(tool) => tool.name !== \"markdown_result\" && tool.name !== \"upload_result_images\",\n\t\t);\n\t\tconst selectedTools =\n\t\t\tmarkdownTool && completionTool\n\t\t\t\t? [markdownTool, completionTool]\n\t\t\t\t: [markdownTool ?? completionTool ?? tools[0]];\n\t\tconst calls = selectedTools\n\t\t\t.filter((tool) => tool !== undefined)\n\t\t\t.map((tool) => ({ toolName: tool.name, args: synthesizeStubToolArgs(tool.parameters) }));\n\t\treturn calls.length > 1 ? { calls } : calls[0];\n\t};\n}\n\n/** @internal */\nexport function createSchemaDrivenStubPiFactory(\n\toptions: {\n\t\t/** @internal */\n\t\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\t} = {},\n): StubPiTreeHandleFactory {\n\treturn new StubPiTreeHandleFactory({\n\t\ttoolCallScriptResolver:\n\t\t\toptions.toolCallScriptResolver ?? createSchemaDrivenToolCallScriptResolver(),\n\t});\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW,cAAc,qBAAqB;AACvD,OAAO,UAAU;AACjB,SAAS,+BAAmD;AAe5D,SAAS,gBAAgB;AA8ElB,SAAS,iBACf,UAAkC,CAAC,GACnC,oBACS;AACT,SAAO,QACL;AAAA,IAAI,CAAC,UACL,MAAM,SAAS,mBACZ,MAAM,UACN,MAAM,SAAS,YACd,MAAM,UACL,MAAM,QAAQ,UACd,qBACD;AAAA,EACL,EACC,OAAO,CAAC,UAA2B,OAAO,UAAU,QAAQ,EAC5D,KAAK,MAAM;AACd;AAEA,SAAS,oBAAoB,QAAyB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F,WAAO,MAAM,SAAS,IAAI,EAAE,MAAM,IAAI,MAAM,CAAC;AAAA,EAC9C;AACD;AAGO,SAAS,gCACf,UAGI,CAAC,GACqB;AAC1B,SAAO,IAAI,wBAAwB;AAAA,IAClC,wBACC,QAAQ,0BAA0B,yCAAyC;AAAA,EAC7E,CAAC;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExtensionTestCapability } from "./test-capability.js";
|
|
2
2
|
export type { ExtensionTestCapability } from "./test-capability.js";
|
|
3
|
-
import type { Actor, ExternalWriteLog, ProcessInstance, ProcessProject, ProcessTurnRecord } from "@leitwerk-dev/domain";
|
|
3
|
+
import type { Actor, ExternalWriteLog, LaunchModelConfigInput, ProcessInstance, ProcessProject, ProcessTurnRecord } from "@leitwerk-dev/domain";
|
|
4
4
|
import { type ExtensionProcessDefinition, type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
5
5
|
import { type TestObservation } from "./observations.js";
|
|
6
6
|
import { type ProcessFixtureOptions } from "./process-fixtures.js";
|
|
@@ -336,7 +336,7 @@ export interface ExtensionIntegrationHarness {
|
|
|
336
336
|
/** @public */
|
|
337
337
|
process(id: string): ExtensionIntegrationProcess;
|
|
338
338
|
/** @public */
|
|
339
|
-
launch(id: string, input: Record<string, unknown
|
|
339
|
+
launch(id: string, input: Record<string, unknown>, modelConfig?: LaunchModelConfigInput): Promise<ExtensionIntegrationProcess>;
|
|
340
340
|
/** @public */
|
|
341
341
|
createProcess<TParams, TState>(definition: ExtensionProcessDefinition<TParams, TState>, input?: Omit<ProcessFixtureOptions<TParams, TState>, "id" | "processId"> & {
|
|
342
342
|
/** @public */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-integration-harness.d.ts","sourceRoot":"","sources":["../src/extension-integration-harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"extension-integration-harness.d.ts","sourceRoot":"","sources":["../src/extension-integration-harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAIpE,OAAO,KAAK,EACX,KAAK,EACL,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEN,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,MAAM,2BAA2B,CAAC;AAQnC,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG/E,8DAA8D;AAC9D,MAAM,WAAW,4BAA4B;IAC5C,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,GAAG,EAAE,MAAM,CAAC;IACZ,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,KAAK,EAAE,SAAS;QACf,cAAc;QACd,IAAI,EAAE,MAAM,CAAC;QACb,cAAc;QACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,EAAE,CAAC;CACJ;AAED,uDAAuD;AACvD,MAAM,WAAW,0BAA0B;IAC1C,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc;IACd,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc;IACd,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tC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,cAAc;IACd,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,sEAAsE;AACtE,wBAAsB,iCAAiC,CACtD,OAAO,EAAE,kCAAkC,GACzC,OAAO,CAAC,2BAA2B,CAAC,CAwhBtC"}
|
package/dist/fixtures.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/compact-process-detail-fixture.ts","../src/question-fixtures.ts","../src/supported-question-fixtures.ts"],"sourcesContent":["import type {\n\tProcessEvent,\n\tProcessInput,\n\tProcessInstance,\n\tProcessProject,\n\tProcessTurnAnnotation,\n\tProcessTurnRecord,\n\tWorkerLease,\n} from \"@leitwerk-dev/domain\";\nimport {\n\tcreateReadonlyEntryTree,\n\ttype PiSessionEntry,\n\ttype PrimaryPathSnapshot,\n\ttype ProcessDetailUiSnapshotResponseBody,\n\ttype TurnReasoningDetailResponseBody,\n\ttype TurnTraceSnapshot,\n} from \"@leitwerk-dev/protocol\";\nimport {\n\tbuildProcessUiSnapshotProjections,\n\tbuildTurnTraceIndexFromSession,\n\ttype ReadonlyPiSessionTree,\n} from \"@leitwerk-dev/server/testing\";\n\ntype LegacyProcessDetailFixture = Omit<ProcessDetailUiSnapshotResponseBody, \"primaryPath\"> & {\n\tprimaryPath: PrimaryPathSnapshot;\n\tprocess: ProcessInstance;\n\tprojects: ProcessProject[];\n\tinputs: ProcessInput[];\n\tevents: ProcessEvent[];\n\tturnRecords: ProcessTurnRecord[];\n\tturnAnnotations: ProcessTurnAnnotation[];\n\tworkerLease: WorkerLease | null;\n\tpiSessionEntries: PiSessionEntry[];\n};\n\nconst EMPTY_TRACE: TurnTraceSnapshot = {\n\tassistant: { text: \"\", thinking: \"\", lastUpdatedAt: null },\n\ttoolCalls: [],\n\ttraceItems: [],\n\tusage: null,\n\tpiInput: null,\n};\n\n/** @internal */\nexport function createCompactProcessDetailFixtureFactory() {\n\tconst reasoningSourceByInstanceId = new Map<\n\t\tstring,\n\t\t{\n\t\t\tsignature: string | null;\n\t\t\ttraceIndex: Record<string, TurnTraceSnapshot>;\n\t\t\tliveTurnRecordId: string | null;\n\t\t}\n\t>();\n\n\t/** @internal */\n\tfunction compact(input: unknown): ProcessDetailUiSnapshotResponseBody {\n\t\tconst legacy = input as LegacyProcessDetailFixture;\n\t\tif (!Array.isArray(legacy.turnRecords)) {\n\t\t\treturn input as ProcessDetailUiSnapshotResponseBody;\n\t\t}\n\t\tconst sessionEntries = legacy.piSessionEntries ?? [];\n\t\tconst entryTree = createReadonlyEntryTree(sessionEntries);\n\t\tconst sessionTree = {\n\t\t\t...entryTree,\n\t\t\ttreeFile: \"ui-compact-fixture\",\n\t\t\theader: null,\n\t\t\tgetTree: () => [],\n\t\t} as unknown as ReadonlyPiSessionTree;\n\t\tconst traceIndex = buildTurnTraceIndexFromSession({\n\t\t\ttree: sessionTree,\n\t\t\tturnRecords: legacy.turnRecords,\n\t\t\tevents: legacy.events,\n\t\t});\n\t\tconst active = legacy.primaryPath.turnState.activeTurn;\n\t\tif (active)\n\t\t\ttraceIndex[active.turnRecordId] = {\n\t\t\t\t...EMPTY_TRACE,\n\t\t\t\t...traceIndex[active.turnRecordId],\n\t\t\t\tassistant: active.assistant,\n\t\t\t\ttraceItems: active.traceItems,\n\t\t\t\tusage: active.usage,\n\t\t\t\ttoolCalls: active.toolCalls.map(({ result, ...tool }) => ({\n\t\t\t\t\t...tool,\n\t\t\t\t\tresultText:\n\t\t\t\t\t\ttypeof result === \"string\" ? result : result == null ? null : JSON.stringify(result),\n\t\t\t\t\ttruncated: false,\n\t\t\t\t})),\n\t\t\t};\n\t\tconst signature =\n\t\t\tsessionEntries.length > 0 ? `test-session:${JSON.stringify(sessionEntries).length}` : null;\n\t\tconst projections = buildProcessUiSnapshotProjections({\n\t\t\tprocess: legacy.process,\n\t\t\tturnRecords: legacy.turnRecords,\n\t\t\tturnAnnotations: legacy.turnAnnotations,\n\t\t\tevents: legacy.events,\n\t\t\tinputs: legacy.inputs,\n\t\t\tselectedTurn: legacy.selectedTurn ?? null,\n\t\t\tprimaryPathSnapshot: legacy.primaryPath,\n\t\t\tsessionTree,\n\t\t});\n\t\tconst compactDetail: ProcessDetailUiSnapshotResponseBody = {\n\t\t\t...projections,\n\t\t\tinstanceTree: legacy.instanceTree ?? { currentLeafId: null, nodes: [], edges: [] },\n\t\t\tleafOutcomeSnapshots: legacy.leafOutcomeSnapshots,\n\t\t\tquestionRequests: [],\n\t\t\ttoolApprovalRequests: [],\n\t\t\tprocessDisplayName: legacy.processDisplayName,\n\t\t\tprocessFlow: legacy.processFlow,\n\t\t\tdefinesLeafOutcome: legacy.definesLeafOutcome,\n\t\t\tselectedTurn: legacy.selectedTurn ?? null,\n\t\t\tscheduledAction: legacy.scheduledAction ?? null,\n\t\t\tmodelConfiguration: legacy.modelConfiguration,\n\t\t\trunDetails: legacy.runDetails,\n\t\t\tlaunchConfiguration: legacy.launchConfiguration,\n\t\t\tactions: legacy.actions,\n\t\t\ttoolRenderers: legacy.toolRenderers,\n\t\t\tpersistedModelSelectionWarning: null,\n\t\t\tsession: { signature },\n\t\t\tsessionTransfer: null,\n\t\t};\n\t\treasoningSourceByInstanceId.set(projections.process.id, {\n\t\t\tsignature,\n\t\t\ttraceIndex,\n\t\t\tliveTurnRecordId: active?.turnRecordId ?? null,\n\t\t});\n\t\treturn compactDetail;\n\t}\n\n\t/** @internal */\n\tfunction reasoningResponse(\n\t\tinstanceId: string,\n\t\tturnRecordId: string,\n\t): TurnReasoningDetailResponseBody {\n\t\tconst source = reasoningSourceByInstanceId.get(instanceId);\n\t\treturn {\n\t\t\tinstanceId,\n\t\t\tturnRecordId,\n\t\t\tstate: source?.liveTurnRecordId === turnRecordId ? \"live\" : \"committed\",\n\t\t\tthroughEventSequence: 0,\n\t\t\tsessionSignature: source?.signature ?? null,\n\t\t\treasoning: source?.traceIndex[turnRecordId] ?? EMPTY_TRACE,\n\t\t};\n\t}\n\n\treturn {\n\t\t/** @internal */\n\t\tcompact,\n\t\t/** @internal */\n\t\treasoningResponse,\n\t};\n}\n","import type { NormalizedQuestion, ProcessQuestionRequest } from \"@leitwerk-dev/domain\";\n\n/** @internal */\nexport function createTestQuestion(\n\toverrides: Partial<NormalizedQuestion> = {},\n): NormalizedQuestion {\n\treturn {\n\t\tid: \"question_1\",\n\t\tquestion: \"Choose a strategy\",\n\t\tselection: \"single\",\n\t\toptions: [{ id: \"question_1_option_1\", label: \"Safe\", details: \"Small change\" }],\n\t\t...overrides,\n\t};\n}\n\n/** @internal */\nexport function createTestQuestionRequest(\n\toverrides: Partial<ProcessQuestionRequest> = {},\n): ProcessQuestionRequest {\n\treturn {\n\t\tid: \"qst_1\",\n\t\tinstanceId: \"agt_1\",\n\t\tturnRecordId: \"trn_1\",\n\t\ttoolCallId: \"tool_1\",\n\t\tquestions: [createTestQuestion()],\n\t\tstatus: \"open\",\n\t\tanswers: null,\n\t\taskedAt: \"2026-01-01T00:00:00.000Z\",\n\t\tansweredAt: null,\n\t\tansweredBy: null,\n\t\tcancelledAt: null,\n\t\t...overrides,\n\t};\n}\n","import { type Actor, normalizeAskQuestionsInput } from \"@leitwerk-dev/domain\";\n\n/** A normalized question with stable option identities. @public */\nexport interface QuestionFixture {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tquestion: string;\n\t/** @public */\n\tselection: \"single\" | \"multiple\";\n\t/** @public */\n\toptions: readonly {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tlabel: string;\n\t\t/** @public */\n\t\tdetails: string | null;\n\t}[];\n}\n\n/** Correlated question request data without persistence access. @public */\nexport interface QuestionRequestFixture {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnRecordId: string;\n\t/** @public */\n\ttoolCallId: string;\n\t/** @public */\n\tquestions: readonly QuestionFixture[];\n\t/** @public */\n\tstatus: \"open\" | \"answered\" | \"cancelled\";\n\t/** @public */\n\tanswers: readonly string[] | null;\n\t/** @public */\n\taskedAt: string;\n\t/** @public */\n\tansweredAt: string | null;\n\t/** @public */\n\tansweredBy: Actor | null;\n\t/** @public */\n\tcancelledAt: string | null;\n}\n\n/** Question content with generated stable option identities. @public */\nexport interface QuestionFixtureOptions {\n\t/** @public */\n\n\tquestion?: string;\n\n\t/** @public */\n\n\tselection?: \"single\" | \"multiple\";\n\n\t/** @public */\n\n\toptions?: readonly {\n\t\t/** @public */\n\t\tlabel: string;\n\n\t\t/** @public */\n\t\tdetails?: string | null;\n\t}[];\n}\n\n/** Normalize content using the application's question contract. @public */\nexport function createQuestionFixture(options: QuestionFixtureOptions = {}): QuestionFixture {\n\tconst [question] = normalizeAskQuestionsInput({\n\t\tquestions: [\n\t\t\t{\n\t\t\t\tquestion: options.question ?? \"Choose a strategy\",\n\t\t\t\tselection: options.selection ?? \"single\",\n\t\t\t\toptions: options.options ?? [{ label: \"Safe\", details: \"Small change\" }],\n\t\t\t},\n\t\t],\n\t});\n\tif (!question) throw new Error(\"Question normalization returned no question\");\n\treturn question;\n}\n\n/** Resolution determines status and all resolution timestamps. @public */\nexport type QuestionFixtureResolution =\n\t| {\n\t\t\t/** @public */\n\t\t\tstatus: \"answered\";\n\n\t\t\t/** @public */\n\n\t\t\tanswers: readonly string[];\n\n\t\t\t/** @public */\n\n\t\t\tactor?: Actor;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tstatus: \"cancelled\";\n\t };\n\n/** Reference inputs and question content, without durable status overrides. @public */\nexport interface QuestionRequestFixtureOptions {\n\t/** @public */\n\n\tid?: string;\n\n\t/** @public */\n\n\tprocess?: {\n\t\t/** @public */\n\t\tid: string;\n\t};\n\n\t/** @public */\n\n\tturn?: {\n\t\t/** @public */\n\t\tid: string;\n\n\t\t/** @public */\n\t\tinstanceId: string;\n\t};\n\n\t/** @public */\n\n\tquestions?: readonly QuestionFixtureOptions[];\n\n\t/** @public */\n\n\tresolution?: QuestionFixtureResolution;\n}\n\n/** Create a consistent request; reject conflicting process and turn references. @public */\nexport function createQuestionRequestFixture(\n\toptions: QuestionRequestFixtureOptions = {},\n): QuestionRequestFixture {\n\tconst instanceId = options.process?.id ?? options.turn?.instanceId ?? \"agt_test\";\n\tif (options.turn && options.turn.instanceId !== instanceId)\n\t\tthrow new Error(\"Question turn belongs to another process\");\n\tconst questions = normalizeAskQuestionsInput({\n\t\tquestions: (options.questions ?? [{}]).map((q) => ({\n\t\t\tquestion: q.question ?? \"Choose a strategy\",\n\t\t\tselection: q.selection ?? \"single\",\n\t\t\toptions: q.options ?? [{ label: \"Safe\" }],\n\t\t})),\n\t});\n\tconst resolution = options.resolution;\n\tif (resolution?.status === \"answered\" && resolution.answers.length !== questions.length)\n\t\tthrow new Error(\"Supply one answer per question\");\n\treturn {\n\t\tid: options.id ?? \"qst_test\",\n\t\tinstanceId,\n\t\tturnRecordId: options.turn?.id ?? \"trn_test\",\n\t\ttoolCallId: \"tool_test\",\n\t\tquestions,\n\t\tstatus: resolution?.status ?? \"open\",\n\t\taskedAt: \"2026-01-01T00:00:00.000Z\",\n\t\tanswers: resolution?.status === \"answered\" ? [...resolution.answers] : null,\n\t\tansweredAt: resolution?.status === \"answered\" ? \"2026-01-01T00:00:01.000Z\" : null,\n\t\tansweredBy:\n\t\t\tresolution?.status === \"answered\"\n\t\t\t\t? structuredClone(resolution.actor ?? { id: \"test-user\", kind: \"user\", provider: null })\n\t\t\t\t: null,\n\t\tcancelledAt: resolution?.status === \"cancelled\" ? \"2026-01-01T00:00:01.000Z\" : null,\n\t};\n}\n"],"mappings":";;;;;;AASA;AAAA,EACC;AAAA,OAMM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AAcP,IAAM,cAAiC;AAAA,EACtC,WAAW,EAAE,MAAM,IAAI,UAAU,IAAI,eAAe,KAAK;AAAA,EACzD,WAAW,CAAC;AAAA,EACZ,YAAY,CAAC;AAAA,EACb,OAAO;AAAA,EACP,SAAS;AACV;AAGO,SAAS,2CAA2C;AAC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IAClB;AAAA,IACA,cAAc,QAAQ,MAAM,MAAM;AAAA,IAClC,YAAY;AAAA,IACZ;AAAA,IACA,QAAQ,YAAY,UAAU;AAAA,IAC9B,SAAS;AAAA,IACT,SAAS,YAAY,WAAW,aAAa,CAAC,GAAG,WAAW,OAAO,IAAI;AAAA,IACvE,YAAY,YAAY,WAAW,aAAa,6BAA6B;AAAA,IAC7E,YACC,YAAY,WAAW,aACpB,gBAAgB,WAAW,SAAS,EAAE,IAAI,aAAa,MAAM,QAAQ,UAAU,KAAK,CAAC,IACrF;AAAA,IACJ,aAAa,YAAY,WAAW,cAAc,6BAA6B;AAAA,EAChF;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/compact-process-detail-fixture.ts","../src/question-fixtures.ts","../src/supported-question-fixtures.ts"],"sourcesContent":["import type {\n\tProcessEvent,\n\tProcessInput,\n\tProcessInstance,\n\tProcessProject,\n\tProcessTurnAnnotation,\n\tProcessTurnRecord,\n\tWorkerLease,\n} from \"@leitwerk-dev/domain\";\nimport {\n\tcreateReadonlyEntryTree,\n\ttype PiSessionEntry,\n\ttype PrimaryPathSnapshot,\n\ttype ProcessDetailUiSnapshotResponseBody,\n\ttype TurnReasoningDetailResponseBody,\n\ttype TurnTraceSnapshot,\n} from \"@leitwerk-dev/protocol\";\nimport {\n\tbuildProcessUiSnapshotProjections,\n\tbuildTurnTraceIndexFromSession,\n\ttype ReadonlyPiSessionTree,\n} from \"@leitwerk-dev/server/testing\";\n\ntype LegacyProcessDetailFixture = Omit<ProcessDetailUiSnapshotResponseBody, \"primaryPath\"> & {\n\tprimaryPath: PrimaryPathSnapshot;\n\tprocess: ProcessInstance;\n\tprojects: ProcessProject[];\n\tinputs: ProcessInput[];\n\tevents: ProcessEvent[];\n\tturnRecords: ProcessTurnRecord[];\n\tturnAnnotations: ProcessTurnAnnotation[];\n\tworkerLease: WorkerLease | null;\n\tpiSessionEntries: PiSessionEntry[];\n};\n\nconst EMPTY_TRACE: TurnTraceSnapshot = {\n\tassistant: { text: \"\", thinking: \"\", lastUpdatedAt: null },\n\ttoolCalls: [],\n\ttraceItems: [],\n\tusage: null,\n\tpiInput: null,\n};\n\n/** @internal */\nexport function createCompactProcessDetailFixtureFactory() {\n\tconst reasoningSourceByInstanceId = new Map<\n\t\tstring,\n\t\t{\n\t\t\tsignature: string | null;\n\t\t\ttraceIndex: Record<string, TurnTraceSnapshot>;\n\t\t\tliveTurnRecordId: string | null;\n\t\t}\n\t>();\n\n\t/** @internal */\n\tfunction compact(input: unknown): ProcessDetailUiSnapshotResponseBody {\n\t\tconst legacy = input as LegacyProcessDetailFixture;\n\t\tif (!Array.isArray(legacy.turnRecords)) {\n\t\t\treturn input as ProcessDetailUiSnapshotResponseBody;\n\t\t}\n\t\tconst sessionEntries = legacy.piSessionEntries ?? [];\n\t\tconst entryTree = createReadonlyEntryTree(sessionEntries);\n\t\tconst sessionTree = {\n\t\t\t...entryTree,\n\t\t\ttreeFile: \"ui-compact-fixture\",\n\t\t\theader: null,\n\t\t\tgetTree: () => [],\n\t\t} as unknown as ReadonlyPiSessionTree;\n\t\tconst traceIndex = buildTurnTraceIndexFromSession({\n\t\t\ttree: sessionTree,\n\t\t\tturnRecords: legacy.turnRecords,\n\t\t\tevents: legacy.events,\n\t\t});\n\t\tconst active = legacy.primaryPath.turnState.activeTurn;\n\t\tif (active)\n\t\t\ttraceIndex[active.turnRecordId] = {\n\t\t\t\t...EMPTY_TRACE,\n\t\t\t\t...traceIndex[active.turnRecordId],\n\t\t\t\tassistant: active.assistant,\n\t\t\t\ttraceItems: active.traceItems,\n\t\t\t\tusage: active.usage,\n\t\t\t\ttoolCalls: active.toolCalls.map(({ result, ...tool }) => ({\n\t\t\t\t\t...tool,\n\t\t\t\t\tresultText:\n\t\t\t\t\t\ttypeof result === \"string\" ? result : result == null ? null : JSON.stringify(result),\n\t\t\t\t\ttruncated: false,\n\t\t\t\t})),\n\t\t\t};\n\t\tconst signature =\n\t\t\tsessionEntries.length > 0 ? `test-session:${JSON.stringify(sessionEntries).length}` : null;\n\t\tconst projections = buildProcessUiSnapshotProjections({\n\t\t\tprocess: legacy.process,\n\t\t\tturnRecords: legacy.turnRecords,\n\t\t\tturnAnnotations: legacy.turnAnnotations,\n\t\t\tevents: legacy.events,\n\t\t\tinputs: legacy.inputs,\n\t\t\tselectedTurn: legacy.selectedTurn ?? null,\n\t\t\tprimaryPathSnapshot: legacy.primaryPath,\n\t\t\tsessionTree,\n\t\t});\n\t\tconst compactDetail: ProcessDetailUiSnapshotResponseBody = {\n\t\t\t...projections,\n\t\t\tinstanceTree: legacy.instanceTree ?? { currentLeafId: null, nodes: [], edges: [] },\n\t\t\tleafOutcomeSnapshots: legacy.leafOutcomeSnapshots,\n\t\t\tquestionRequests: [],\n\t\t\ttoolApprovalRequests: [],\n\t\t\tprocessDisplayName: legacy.processDisplayName,\n\t\t\tprocessFlow: legacy.processFlow,\n\t\t\tdefinesLeafOutcome: legacy.definesLeafOutcome,\n\t\t\tselectedTurn: legacy.selectedTurn ?? null,\n\t\t\tscheduledAction: legacy.scheduledAction ?? null,\n\t\t\tmodelConfiguration: legacy.modelConfiguration,\n\t\t\trunDetails: legacy.runDetails,\n\t\t\tlaunchConfiguration: legacy.launchConfiguration,\n\t\t\tactions: legacy.actions,\n\t\t\ttoolRenderers: legacy.toolRenderers,\n\t\t\tpersistedModelSelectionWarning: null,\n\t\t\tsession: { signature },\n\t\t\tsessionTransfer: null,\n\t\t};\n\t\treasoningSourceByInstanceId.set(projections.process.id, {\n\t\t\tsignature,\n\t\t\ttraceIndex,\n\t\t\tliveTurnRecordId: active?.turnRecordId ?? null,\n\t\t});\n\t\treturn compactDetail;\n\t}\n\n\t/** @internal */\n\tfunction reasoningResponse(\n\t\tinstanceId: string,\n\t\tturnRecordId: string,\n\t): TurnReasoningDetailResponseBody {\n\t\tconst source = reasoningSourceByInstanceId.get(instanceId);\n\t\treturn {\n\t\t\tinstanceId,\n\t\t\tturnRecordId,\n\t\t\tstate: source?.liveTurnRecordId === turnRecordId ? \"live\" : \"committed\",\n\t\t\tthroughEventSequence: 0,\n\t\t\tsessionSignature: source?.signature ?? null,\n\t\t\treasoning: source?.traceIndex[turnRecordId] ?? EMPTY_TRACE,\n\t\t};\n\t}\n\n\treturn {\n\t\t/** @internal */\n\t\tcompact,\n\t\t/** @internal */\n\t\treasoningResponse,\n\t};\n}\n","import type { NormalizedQuestion, ProcessQuestionRequest } from \"@leitwerk-dev/domain\";\n\n/** @internal */\nexport function createTestQuestion(\n\toverrides: Partial<NormalizedQuestion> = {},\n): NormalizedQuestion {\n\treturn {\n\t\tid: \"question_1\",\n\t\tquestion: \"Choose a strategy\",\n\t\tselection: \"single\",\n\t\toptions: [{ id: \"question_1_option_1\", label: \"Safe\", details: \"Small change\" }],\n\t\t...overrides,\n\t};\n}\n\n/** @internal */\nexport function createTestQuestionRequest(\n\toverrides: Partial<ProcessQuestionRequest> = {},\n): ProcessQuestionRequest {\n\treturn {\n\t\tid: \"qst_1\",\n\t\tinstanceId: \"agt_1\",\n\t\tturnRecordId: \"trn_1\",\n\t\ttoolCallId: \"tool_1\",\n\t\tquestions: [createTestQuestion()],\n\t\tstatus: \"open\",\n\t\tanswers: null,\n\t\taskedAt: \"2026-01-01T00:00:00.000Z\",\n\t\tansweredAt: null,\n\t\tansweredBy: null,\n\t\tcancelledAt: null,\n\t\t...overrides,\n\t};\n}\n","import { type Actor, normalizeAskQuestionsInput } from \"@leitwerk-dev/domain\";\n\n/** A normalized question with stable option identities. @public */\nexport interface QuestionFixture {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tquestion: string;\n\t/** @public */\n\tselection: \"single\" | \"multiple\";\n\t/** @public */\n\toptions: readonly {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tlabel: string;\n\t\t/** @public */\n\t\tdetails: string | null;\n\t}[];\n}\n\n/** Correlated question request data without persistence access. @public */\nexport interface QuestionRequestFixture {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnRecordId: string;\n\t/** @public */\n\ttoolCallId: string;\n\t/** @public */\n\tquestions: readonly QuestionFixture[];\n\t/** @public */\n\tstatus: \"open\" | \"answered\" | \"cancelled\";\n\t/** @public */\n\tanswers: readonly string[] | null;\n\t/** @public */\n\taskedAt: string;\n\t/** @public */\n\tansweredAt: string | null;\n\t/** @public */\n\tansweredBy: Actor | null;\n\t/** @public */\n\tcancelledAt: string | null;\n}\n\n/** Question content with generated stable option identities. @public */\nexport interface QuestionFixtureOptions {\n\t/** @public */\n\tquestion?: string;\n\t/** @public */\n\tselection?: \"single\" | \"multiple\";\n\t/** @public */\n\toptions?: readonly {\n\t\t/** @public */\n\t\tlabel: string;\n\t\t/** @public */\n\t\tdetails?: string | null;\n\t}[];\n}\n\n/** Normalize content using the application's question contract. @public */\nexport function createQuestionFixture(options: QuestionFixtureOptions = {}): QuestionFixture {\n\tconst [question] = normalizeAskQuestionsInput({\n\t\tquestions: [\n\t\t\t{\n\t\t\t\tquestion: options.question ?? \"Choose a strategy\",\n\t\t\t\tselection: options.selection ?? \"single\",\n\t\t\t\toptions: options.options ?? [{ label: \"Safe\", details: \"Small change\" }],\n\t\t\t},\n\t\t],\n\t});\n\tif (!question) throw new Error(\"Question normalization returned no question\");\n\treturn question;\n}\n\n/** Resolution determines status and all resolution timestamps. @public */\nexport type QuestionFixtureResolution =\n\t| {\n\t\t\t/** @public */\n\t\t\tstatus: \"answered\";\n\t\t\t/** @public */\n\t\t\tanswers: readonly string[];\n\t\t\t/** @public */\n\t\t\tactor?: Actor;\n\t }\n\t| {\n\t\t\t/** @public */\n\t\t\tstatus: \"cancelled\";\n\t };\n\n/** Reference inputs and question content, without durable status overrides. @public */\nexport interface QuestionRequestFixtureOptions {\n\t/** @public */\n\tid?: string;\n\t/** @public */\n\tprocess?: {\n\t\t/** @public */\n\t\tid: string;\n\t};\n\t/** @public */\n\tturn?: {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tinstanceId: string;\n\t};\n\t/** @public */\n\tquestions?: readonly QuestionFixtureOptions[];\n\t/** @public */\n\tresolution?: QuestionFixtureResolution;\n}\n\n/** Create a consistent request; reject conflicting process and turn references. @public */\nexport function createQuestionRequestFixture(\n\toptions: QuestionRequestFixtureOptions = {},\n): QuestionRequestFixture {\n\tconst instanceId = options.process?.id ?? options.turn?.instanceId ?? \"agt_test\";\n\tif (options.turn && options.turn.instanceId !== instanceId)\n\t\tthrow new Error(\"Question turn belongs to another process\");\n\tconst questions = normalizeAskQuestionsInput({\n\t\tquestions: (options.questions ?? [{}]).map((q) => ({\n\t\t\tquestion: q.question ?? \"Choose a strategy\",\n\t\t\tselection: q.selection ?? \"single\",\n\t\t\toptions: q.options ?? [{ label: \"Safe\" }],\n\t\t})),\n\t});\n\tconst resolution = options.resolution;\n\tif (resolution?.status === \"answered\" && resolution.answers.length !== questions.length)\n\t\tthrow new Error(\"Supply one answer per question\");\n\treturn {\n\t\tid: options.id ?? \"qst_test\",\n\t\tinstanceId,\n\t\tturnRecordId: options.turn?.id ?? \"trn_test\",\n\t\ttoolCallId: \"tool_test\",\n\t\tquestions,\n\t\tstatus: resolution?.status ?? \"open\",\n\t\taskedAt: \"2026-01-01T00:00:00.000Z\",\n\t\tanswers: resolution?.status === \"answered\" ? [...resolution.answers] : null,\n\t\tansweredAt: resolution?.status === \"answered\" ? \"2026-01-01T00:00:01.000Z\" : null,\n\t\tansweredBy:\n\t\t\tresolution?.status === \"answered\"\n\t\t\t\t? structuredClone(resolution.actor ?? { id: \"test-user\", kind: \"user\", provider: null })\n\t\t\t\t: null,\n\t\tcancelledAt: resolution?.status === \"cancelled\" ? \"2026-01-01T00:00:01.000Z\" : null,\n\t};\n}\n"],"mappings":";;;;;;AASA;AAAA,EACC;AAAA,OAMM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AAcP,IAAM,cAAiC;AAAA,EACtC,WAAW,EAAE,MAAM,IAAI,UAAU,IAAI,eAAe,KAAK;AAA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,WAAW,QAAQ,WAAW,UAAU;AAChF,UAAM,IAAI,MAAM,gCAAgC;AACjD,SAAO;AAAA,IACN,IAAI,QAAQ,MAAM;AAAA,IAClB;AAAA,IACA,cAAc,QAAQ,MAAM,MAAM;AAAA,IAClC,YAAY;AAAA,IACZ;AAAA,IACA,QAAQ,YAAY,UAAU;AAAA,IAC9B,SAAS;AAAA,IACT,SAAS,YAAY,WAAW,aAAa,CAAC,GAAG,WAAW,OAAO,IAAI;AAAA,IACvE,YAAY,YAAY,WAAW,aAAa,6BAA6B;AAAA,IAC7E,YACC,YAAY,WAAW,aACpB,gBAAgB,WAAW,SAAS,EAAE,IAAI,aAAa,MAAM,QAAQ,UAAU,KAAK,CAAC,IACrF;AAAA,IACJ,aAAa,YAAY,WAAW,cAAc,6BAA6B;AAAA,EAChF;AACD;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createInMemoryExternalWriteLog as createInMemoryExternalWriteLogImpl } from "./server-extension-test-harness.js";
|
|
2
2
|
export { FakeLlmProvider } from "./fakes/fake-llm.js";
|
|
3
3
|
export { postImmediateLaunch, postImmediateLaunchRequest } from "./http-launch.js";
|
|
4
|
-
export { type FixtureModelProviderSet, fixtureModelProviders, } from "./model-provider-fixtures.js";
|
|
4
|
+
export { type FixtureModelProviderSet, fixtureModelProfiles, fixtureModelProviders, withDefaultModelFixture, } from "./model-provider-fixtures.js";
|
|
5
5
|
export { createPollingTestExtension, createTestServerSetupCapability, createToolCollector, } from "./server-extension-test-harness.js";
|
|
6
6
|
/** @internal */
|
|
7
7
|
export declare function createInMemoryExternalWriteLog(): ReturnType<typeof createInMemoryExternalWriteLogImpl>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,IAAI,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE1H,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EACN,KAAK,uBAAuB,EAC5B,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,IAAI,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE1H,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EACN,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,0BAA0B,EAC1B,+BAA+B,EAC/B,mBAAmB,GACnB,MAAM,oCAAoC,CAAC;AAE5C,gBAAgB;AAChB,wBAAgB,8BAA8B,IAAI,UAAU,CAC3D,OAAO,kCAAkC,CACzC,CAEA"}
|