@leitwerk-dev/test-support 0.2.1 → 0.3.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-ECAWLVYB.js → chunk-E4Y7XND5.js} +3 -1
- package/dist/chunk-E4Y7XND5.js.map +1 -0
- package/dist/chunk-KJVNI2UP.js +17 -0
- package/dist/chunk-KJVNI2UP.js.map +1 -0
- package/dist/{chunk-2PCDTYVH.js → chunk-OE4NHDVS.js} +10 -4
- package/dist/chunk-OE4NHDVS.js.map +1 -0
- package/dist/chunk-P2FF4AP7.js +72 -0
- package/dist/chunk-P2FF4AP7.js.map +1 -0
- package/dist/chunk-RY6Y6V5E.js +54 -0
- package/dist/chunk-RY6Y6V5E.js.map +1 -0
- package/dist/extension-integration-harness.d.ts +357 -0
- package/dist/extension-integration-harness.d.ts.map +1 -0
- package/dist/fixtures.d.ts +2 -0
- package/dist/fixtures.d.ts.map +1 -1
- package/dist/fixtures.js +53 -0
- package/dist/fixtures.js.map +1 -1
- package/dist/index.d.ts +2 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -67
- package/dist/index.js.map +1 -1
- package/dist/integration.d.ts +1 -0
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +564 -2
- package/dist/integration.js.map +1 -1
- package/dist/local-git.d.ts.map +1 -1
- package/dist/local-git.js.map +1 -1
- package/dist/observations.d.ts +7 -0
- package/dist/observations.d.ts.map +1 -0
- package/dist/process-fixtures.d.ts +56 -0
- package/dist/process-fixtures.d.ts.map +1 -0
- package/dist/process.d.ts +440 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +484 -0
- package/dist/process.js.map +1 -0
- package/dist/stub-worker-entry.js +1 -1
- package/dist/supported-question-fixtures.d.ts +96 -0
- package/dist/supported-question-fixtures.d.ts.map +1 -0
- package/dist/test-capability.d.ts +9 -0
- package/dist/test-capability.d.ts.map +1 -0
- package/dist/worker-testing/in-process-worker-spawn.d.ts +2 -0
- package/dist/worker-testing/in-process-worker-spawn.d.ts.map +1 -1
- package/dist/worker-testing/index.js +2 -2
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +2 -0
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/package.json +14 -9
- package/src/extension-integration-harness.ts +1059 -0
- package/src/fixtures.ts +16 -0
- package/src/index.ts +4 -19
- package/src/integration.ts +21 -0
- package/src/local-git.ts +1 -0
- package/src/observations.ts +19 -0
- package/src/process-fixtures.ts +123 -0
- package/src/process.ts +768 -0
- package/src/supported-question-fixtures.ts +168 -0
- package/src/test-capability.ts +9 -0
- package/src/worker-testing/in-process-worker-spawn.ts +15 -2
- package/src/worker-testing/stub-pi-tree-handle.ts +5 -0
- package/dist/chunk-2PCDTYVH.js.map +0 -1
- package/dist/chunk-ECAWLVYB.js.map +0 -1
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import type { ExtensionTestCapability } from "./test-capability.js";
|
|
2
|
+
export type { ExtensionTestCapability } from "./test-capability.js";
|
|
3
|
+
import type { Actor, ExternalWriteLog, ProcessInstance, ProcessProject, ProcessTurnRecord } from "@leitwerk-dev/domain";
|
|
4
|
+
import { type ExtensionProcessDefinition, type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
5
|
+
import { type TestObservation } from "./observations.js";
|
|
6
|
+
import { type ProcessFixtureOptions } from "./process-fixtures.js";
|
|
7
|
+
import type { QuestionRequestFixture } from "./supported-question-fixtures.js";
|
|
8
|
+
/** Model-visible inputs for a scripted invocation. @public */
|
|
9
|
+
export interface IntegrationPromptObservation {
|
|
10
|
+
/** @public */
|
|
11
|
+
turnId: string;
|
|
12
|
+
/** Working directory available for fixture repository edits. @public */
|
|
13
|
+
cwd: string;
|
|
14
|
+
/** Opaque branch-session identity for comparing execution relationships. @public */
|
|
15
|
+
branchId: string;
|
|
16
|
+
/** Text inherited by the current branch. @public */
|
|
17
|
+
history: string;
|
|
18
|
+
/** @public */
|
|
19
|
+
tools: readonly {
|
|
20
|
+
/** @public */
|
|
21
|
+
name: string;
|
|
22
|
+
/** @public */
|
|
23
|
+
parameters: Record<string, unknown>;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
/** Rendered result retained at a tree leaf. @public */
|
|
27
|
+
export interface IntegrationLeafObservation {
|
|
28
|
+
/** @public */
|
|
29
|
+
id: string;
|
|
30
|
+
/** @public */
|
|
31
|
+
instanceId: string;
|
|
32
|
+
/** @public */
|
|
33
|
+
leafEntryId: string;
|
|
34
|
+
/** @public */
|
|
35
|
+
turnRecordId: string | null;
|
|
36
|
+
/** @public */
|
|
37
|
+
rendererId: string | null;
|
|
38
|
+
/** @public */
|
|
39
|
+
schemaVersion: number | null;
|
|
40
|
+
/** @public */
|
|
41
|
+
props: Record<string, unknown> | null;
|
|
42
|
+
/** @public */
|
|
43
|
+
fallbackMarkdown: string | null;
|
|
44
|
+
/** @public */
|
|
45
|
+
status: "ready" | "capture_error";
|
|
46
|
+
}
|
|
47
|
+
/** Recorded semantic event. @public */
|
|
48
|
+
export interface IntegrationEventObservation {
|
|
49
|
+
/** @public */
|
|
50
|
+
id: string;
|
|
51
|
+
/** @public */
|
|
52
|
+
eventType: string;
|
|
53
|
+
/** @public */
|
|
54
|
+
data: Record<string, unknown>;
|
|
55
|
+
/** @public */
|
|
56
|
+
createdAt: string;
|
|
57
|
+
}
|
|
58
|
+
/** Durable annotation of process execution. @public */
|
|
59
|
+
export interface IntegrationAnnotationObservation {
|
|
60
|
+
/** @public */
|
|
61
|
+
id: string;
|
|
62
|
+
/** @public */
|
|
63
|
+
annotationType: string;
|
|
64
|
+
/** @public */
|
|
65
|
+
payload: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
/** One scripted model prompt, executed through registered tools. @public */
|
|
68
|
+
export interface IntegrationTurnScript {
|
|
69
|
+
/** @public */
|
|
70
|
+
tools: readonly IntegrationToolCall[];
|
|
71
|
+
/** Scripted reasoning retained by the normal worker path. @public */
|
|
72
|
+
thinking?: readonly string[];
|
|
73
|
+
/** Assistant markdown for turns completed by model output. @public */
|
|
74
|
+
markdown?: string;
|
|
75
|
+
/** Optional model response after an integration-tool result. @public */
|
|
76
|
+
afterToolResult?(call: IntegrationToolCall, result: unknown): IntegrationToolCall | undefined;
|
|
77
|
+
}
|
|
78
|
+
/** @public */
|
|
79
|
+
export interface IntegrationToolCall {
|
|
80
|
+
/** @public */
|
|
81
|
+
name: string;
|
|
82
|
+
/** @public */
|
|
83
|
+
arguments: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** Instruction delivered through the application's durable input queue. @public */
|
|
86
|
+
export interface IntegrationProcessInput {
|
|
87
|
+
/** @public */
|
|
88
|
+
bodyMarkdown: string;
|
|
89
|
+
/** Target a published product branch. @public */
|
|
90
|
+
product?: string;
|
|
91
|
+
}
|
|
92
|
+
/** Durable instruction delivery observations. @public */
|
|
93
|
+
export interface IntegrationInputObservation {
|
|
94
|
+
/** @public */
|
|
95
|
+
id: string;
|
|
96
|
+
/** @public */
|
|
97
|
+
instanceId: string;
|
|
98
|
+
/** @public */
|
|
99
|
+
sequence: number;
|
|
100
|
+
/** @public */
|
|
101
|
+
source: string;
|
|
102
|
+
/** @public */
|
|
103
|
+
kind: string;
|
|
104
|
+
/** @public */
|
|
105
|
+
bodyMarkdown: string;
|
|
106
|
+
/** @public */
|
|
107
|
+
target: {
|
|
108
|
+
/** @public */
|
|
109
|
+
productName?: string;
|
|
110
|
+
/** @public */
|
|
111
|
+
semanticRef?: string;
|
|
112
|
+
} | null;
|
|
113
|
+
/** @public */
|
|
114
|
+
actor: Actor;
|
|
115
|
+
/** @public */
|
|
116
|
+
receivedAt: string;
|
|
117
|
+
/** @public */
|
|
118
|
+
consumedAt: string | null;
|
|
119
|
+
}
|
|
120
|
+
/** Operator approval observations. @public */
|
|
121
|
+
export interface IntegrationApprovalObservation {
|
|
122
|
+
/** @public */
|
|
123
|
+
id: string;
|
|
124
|
+
/** @public */
|
|
125
|
+
instanceId: string;
|
|
126
|
+
/** @public */
|
|
127
|
+
turnRecordId: string;
|
|
128
|
+
/** @public */
|
|
129
|
+
toolCallId: string;
|
|
130
|
+
/** @public */
|
|
131
|
+
toolName: string;
|
|
132
|
+
/** @public */
|
|
133
|
+
arguments: Record<string, unknown>;
|
|
134
|
+
/** @public */
|
|
135
|
+
destination: {
|
|
136
|
+
/** @public */
|
|
137
|
+
id: string;
|
|
138
|
+
/** @public */
|
|
139
|
+
displayName: string;
|
|
140
|
+
/** @public */
|
|
141
|
+
group?: string;
|
|
142
|
+
/** @public */
|
|
143
|
+
description?: string;
|
|
144
|
+
} | null;
|
|
145
|
+
/** @public */
|
|
146
|
+
status: "open" | "accepted" | "feedback" | "declined" | "cancelled";
|
|
147
|
+
/** @public */
|
|
148
|
+
requestedAt: string;
|
|
149
|
+
/** @public */
|
|
150
|
+
resolvedAt: string | null;
|
|
151
|
+
/** @public */
|
|
152
|
+
resolvedBy: Actor | null;
|
|
153
|
+
/** @public */
|
|
154
|
+
feedback: string | null;
|
|
155
|
+
}
|
|
156
|
+
/** Explicit accepted execution setup, independent of process business state. @public */
|
|
157
|
+
export interface AcceptedTurnFixture {
|
|
158
|
+
/** @public */
|
|
159
|
+
turnId: string;
|
|
160
|
+
/** @public */
|
|
161
|
+
execution: {
|
|
162
|
+
/** @public */
|
|
163
|
+
status: "running";
|
|
164
|
+
} | {
|
|
165
|
+
/** @public */
|
|
166
|
+
status: "succeeded";
|
|
167
|
+
/** @public */
|
|
168
|
+
outcome: string;
|
|
169
|
+
/** @public */
|
|
170
|
+
markdown: string;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** Detached durable observations. @public */
|
|
174
|
+
export interface ExtensionIntegrationSnapshot {
|
|
175
|
+
/** Harness-owned process workspace. @public */
|
|
176
|
+
workspaceRoot: string;
|
|
177
|
+
/** @public */
|
|
178
|
+
events: IntegrationEventObservation[];
|
|
179
|
+
/** @public */
|
|
180
|
+
annotations: IntegrationAnnotationObservation[];
|
|
181
|
+
/** @public */
|
|
182
|
+
leafOutcomes: IntegrationLeafObservation[];
|
|
183
|
+
/** @public */
|
|
184
|
+
process: ProcessInstance;
|
|
185
|
+
/** @public */
|
|
186
|
+
params: unknown;
|
|
187
|
+
/** @public */
|
|
188
|
+
state: unknown;
|
|
189
|
+
/** @public */
|
|
190
|
+
projects: ProcessProject[];
|
|
191
|
+
/** @public */
|
|
192
|
+
turns: ProcessTurnRecord[];
|
|
193
|
+
/** @public */
|
|
194
|
+
inputs: IntegrationInputObservation[];
|
|
195
|
+
/** @public */
|
|
196
|
+
questions: QuestionRequestFixture[];
|
|
197
|
+
/** @public */
|
|
198
|
+
approvals: IntegrationApprovalObservation[];
|
|
199
|
+
/** @public */
|
|
200
|
+
writeReceipts: ExternalWriteLog[];
|
|
201
|
+
}
|
|
202
|
+
/** @public */
|
|
203
|
+
export interface ExtensionIntegrationHarnessOptions {
|
|
204
|
+
/** Per-process watcher configuration. @public */
|
|
205
|
+
watchers?: Readonly<Record<string, Record<string, unknown>>>;
|
|
206
|
+
/** Advance extension provider pollers explicitly in tests. @public */
|
|
207
|
+
polling?: "automatic" | "manual";
|
|
208
|
+
/** Host Docker boundary for extensions which require it. @public */
|
|
209
|
+
hostDocker?: {
|
|
210
|
+
/** @public */
|
|
211
|
+
preflight(timeoutMs: number): Promise<void>;
|
|
212
|
+
};
|
|
213
|
+
/** Configuration keyed by extension manifest id. @public */
|
|
214
|
+
extensionConfig?: Readonly<Record<string, unknown>>;
|
|
215
|
+
/** @public */
|
|
216
|
+
extensions: readonly LeitwerkExtensionModule[];
|
|
217
|
+
/** @public */
|
|
218
|
+
capabilities?: readonly ExtensionTestCapability[];
|
|
219
|
+
/** Automatic execution starts admitted work immediately. @public */
|
|
220
|
+
execution?: "automatic" | "manual";
|
|
221
|
+
/** Model catalog used by the supplied provider extensions. @public */
|
|
222
|
+
models?: readonly {
|
|
223
|
+
/** @public */
|
|
224
|
+
id: string;
|
|
225
|
+
/** @public */
|
|
226
|
+
provider: string;
|
|
227
|
+
/** @public */
|
|
228
|
+
modelId: string;
|
|
229
|
+
/** @public */
|
|
230
|
+
thinkingLevel?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
231
|
+
}[];
|
|
232
|
+
/** Default model profile for all registered processes. @public */
|
|
233
|
+
defaultModel?: string;
|
|
234
|
+
/** Model scripts for automatic execution, in prompt order per process. @public */
|
|
235
|
+
script?(instanceId: string, prompt: string, observation: TestObservation<IntegrationPromptObservation>): IntegrationTurnScript | Promise<IntegrationTurnScript>;
|
|
236
|
+
}
|
|
237
|
+
/** HTTP-shaped requests without a Fastify handle. @public */
|
|
238
|
+
export interface ExtensionTestRequest {
|
|
239
|
+
/** @public */
|
|
240
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
241
|
+
/** @public */
|
|
242
|
+
url: string;
|
|
243
|
+
/** @public */
|
|
244
|
+
payload?: Record<string, unknown>;
|
|
245
|
+
/** @public */
|
|
246
|
+
headers?: Record<string, string>;
|
|
247
|
+
}
|
|
248
|
+
/** HTTP response observation. @public */
|
|
249
|
+
export interface ExtensionTestResponse {
|
|
250
|
+
/** @public */
|
|
251
|
+
statusCode: number;
|
|
252
|
+
/** @public */
|
|
253
|
+
body: string;
|
|
254
|
+
/** @public */
|
|
255
|
+
json<T = unknown>(): T;
|
|
256
|
+
}
|
|
257
|
+
/** Accepted turn identity and optional retained result. @public */
|
|
258
|
+
export interface AcceptedTurnReference {
|
|
259
|
+
/** @public */
|
|
260
|
+
id: string;
|
|
261
|
+
/** @public */
|
|
262
|
+
instanceId: string;
|
|
263
|
+
/** @public */
|
|
264
|
+
turnId: string;
|
|
265
|
+
/** @public */
|
|
266
|
+
artifact: {
|
|
267
|
+
/** @public */ kind: "turn_result";
|
|
268
|
+
/** @public */
|
|
269
|
+
turnRecordId: string;
|
|
270
|
+
} | null;
|
|
271
|
+
}
|
|
272
|
+
/** One durably settled worker execution. @public */
|
|
273
|
+
export interface IntegrationTurnResult {
|
|
274
|
+
/** @public */
|
|
275
|
+
turn: ProcessTurnRecord | null;
|
|
276
|
+
/** @public */
|
|
277
|
+
outcome: string | null;
|
|
278
|
+
/** @public */
|
|
279
|
+
failure: string | null;
|
|
280
|
+
/** @public */
|
|
281
|
+
prompts: string[];
|
|
282
|
+
/** @public */
|
|
283
|
+
toolResults: {
|
|
284
|
+
/** @public */ name: string;
|
|
285
|
+
/** @public */
|
|
286
|
+
result: unknown;
|
|
287
|
+
}[];
|
|
288
|
+
/** @public */
|
|
289
|
+
result: AcceptedTurnReference["artifact"];
|
|
290
|
+
}
|
|
291
|
+
/** Durable process commands and observations. @public */
|
|
292
|
+
export interface ExtensionIntegrationProcess {
|
|
293
|
+
/** @public */
|
|
294
|
+
readonly id: string;
|
|
295
|
+
/** @public */
|
|
296
|
+
seedAcceptedTurn(fixture: AcceptedTurnFixture): Promise<TestObservation<AcceptedTurnReference>>;
|
|
297
|
+
/** @public */
|
|
298
|
+
snapshot(): TestObservation<ExtensionIntegrationSnapshot>;
|
|
299
|
+
/** @public */
|
|
300
|
+
waitFor(condition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean, options?: {
|
|
301
|
+
/** @public */ timeoutMs?: number;
|
|
302
|
+
/** @public */
|
|
303
|
+
description?: string;
|
|
304
|
+
}): Promise<TestObservation<ExtensionIntegrationSnapshot>>;
|
|
305
|
+
/** @public */
|
|
306
|
+
runTurn(script?: IntegrationTurnScript): Promise<TestObservation<IntegrationTurnResult>>;
|
|
307
|
+
/** @public */
|
|
308
|
+
action(id: string, input?: Record<string, unknown>): Promise<ExtensionTestResponse>;
|
|
309
|
+
/** @public */
|
|
310
|
+
retry(): Promise<ExtensionTestResponse>;
|
|
311
|
+
/** @public */
|
|
312
|
+
supplyInput(input: IntegrationProcessInput): Promise<TestObservation<ExtensionIntegrationSnapshot>>;
|
|
313
|
+
/** @public */
|
|
314
|
+
answerQuestions(id: string, answers: readonly {
|
|
315
|
+
/** @public */
|
|
316
|
+
selectedOptionIds: readonly string[];
|
|
317
|
+
/** @public */
|
|
318
|
+
freeText: string;
|
|
319
|
+
/** @public */
|
|
320
|
+
comment: string;
|
|
321
|
+
}[]): Promise<ExtensionTestResponse>;
|
|
322
|
+
/** @public */
|
|
323
|
+
respondToApproval(id: string, response: {
|
|
324
|
+
/** @public */
|
|
325
|
+
action: "accept" | "feedback" | "decline";
|
|
326
|
+
/** @public */
|
|
327
|
+
feedback?: string;
|
|
328
|
+
}): Promise<ExtensionTestResponse>;
|
|
329
|
+
}
|
|
330
|
+
/** Disposable persistent extension test environment. @public */
|
|
331
|
+
export interface ExtensionIntegrationHarness {
|
|
332
|
+
/** Detached processes discovered or launched by extensions. @public */
|
|
333
|
+
processes(): TestObservation<ProcessInstance[]>;
|
|
334
|
+
/** @public */
|
|
335
|
+
request(input: ExtensionTestRequest): Promise<ExtensionTestResponse>;
|
|
336
|
+
/** @public */
|
|
337
|
+
process(id: string): ExtensionIntegrationProcess;
|
|
338
|
+
/** @public */
|
|
339
|
+
launch(id: string, input: Record<string, unknown>): Promise<ExtensionIntegrationProcess>;
|
|
340
|
+
/** @public */
|
|
341
|
+
createProcess<TParams, TState>(definition: ExtensionProcessDefinition<TParams, TState>, input?: Omit<ProcessFixtureOptions<TParams, TState>, "id" | "processId"> & {
|
|
342
|
+
/** @public */
|
|
343
|
+
projects?: readonly ProcessProject[];
|
|
344
|
+
}): Promise<ExtensionIntegrationProcess>;
|
|
345
|
+
/** @public */
|
|
346
|
+
restart(options?: {
|
|
347
|
+
/** Update extension wiring on the reopened server. @public */
|
|
348
|
+
extensionConfig?: Readonly<Record<string, unknown>>;
|
|
349
|
+
/** Apply external changes while the server is offline. @public */
|
|
350
|
+
whileStopped?(): void | Promise<void>;
|
|
351
|
+
}): Promise<void>;
|
|
352
|
+
/** @public */
|
|
353
|
+
close(): Promise<void>;
|
|
354
|
+
}
|
|
355
|
+
/** Own server, workers, and disposable persistent storage. @public */
|
|
356
|
+
export declare function createExtensionIntegrationHarness(options: ExtensionIntegrationHarnessOptions): Promise<ExtensionIntegrationHarness>;
|
|
357
|
+
//# sourceMappingURL=extension-integration-harness.d.ts.map
|
|
@@ -0,0 +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;AAKpE,OAAO,KAAK,EACX,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEN,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,MAAM,2BAA2B,CAAC;AAInC,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,MA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AAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACtC,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,CA+nBtC"}
|
package/dist/fixtures.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { createCompactProcessDetailFixtureFactory } from "./compact-process-detail-fixture.js";
|
|
2
|
+
export { createProcessFixture, createProjectFixture, type ProcessFixtureOptions, type ProcessFixturePosition, type ProjectFixtureOptions, } from "./process-fixtures.js";
|
|
2
3
|
export { createTestQuestion, createTestQuestionRequest } from "./question-fixtures.js";
|
|
4
|
+
export { createQuestionFixture, createQuestionRequestFixture, type QuestionFixture, type QuestionFixtureOptions, type QuestionFixtureResolution, type QuestionRequestFixture, type QuestionRequestFixtureOptions, } from "./supported-question-fixtures.js";
|
|
3
5
|
//# sourceMappingURL=fixtures.d.ts.map
|
package/dist/fixtures.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EACN,qBAAqB,EACrB,4BAA4B,EAC5B,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GAClC,MAAM,kCAAkC,CAAC"}
|
package/dist/fixtures.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProcessFixture,
|
|
3
|
+
createProjectFixture
|
|
4
|
+
} from "./chunk-RY6Y6V5E.js";
|
|
5
|
+
|
|
1
6
|
// src/compact-process-detail-fixture.ts
|
|
2
7
|
import {
|
|
3
8
|
createReadonlyEntryTree
|
|
@@ -130,8 +135,56 @@ function createTestQuestionRequest(overrides = {}) {
|
|
|
130
135
|
...overrides
|
|
131
136
|
};
|
|
132
137
|
}
|
|
138
|
+
|
|
139
|
+
// src/supported-question-fixtures.ts
|
|
140
|
+
import { normalizeAskQuestionsInput } from "@leitwerk-dev/domain";
|
|
141
|
+
function createQuestionFixture(options = {}) {
|
|
142
|
+
const [question] = normalizeAskQuestionsInput({
|
|
143
|
+
questions: [
|
|
144
|
+
{
|
|
145
|
+
question: options.question ?? "Choose a strategy",
|
|
146
|
+
selection: options.selection ?? "single",
|
|
147
|
+
options: options.options ?? [{ label: "Safe", details: "Small change" }]
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
if (!question) throw new Error("Question normalization returned no question");
|
|
152
|
+
return question;
|
|
153
|
+
}
|
|
154
|
+
function createQuestionRequestFixture(options = {}) {
|
|
155
|
+
const instanceId = options.process?.id ?? options.turn?.instanceId ?? "agt_test";
|
|
156
|
+
if (options.turn && options.turn.instanceId !== instanceId)
|
|
157
|
+
throw new Error("Question turn belongs to another process");
|
|
158
|
+
const questions = normalizeAskQuestionsInput({
|
|
159
|
+
questions: (options.questions ?? [{}]).map((q) => ({
|
|
160
|
+
question: q.question ?? "Choose a strategy",
|
|
161
|
+
selection: q.selection ?? "single",
|
|
162
|
+
options: q.options ?? [{ label: "Safe" }]
|
|
163
|
+
}))
|
|
164
|
+
});
|
|
165
|
+
const resolution = options.resolution;
|
|
166
|
+
if (resolution?.status === "answered" && resolution.answers.length !== questions.length)
|
|
167
|
+
throw new Error("Supply one answer per question");
|
|
168
|
+
return {
|
|
169
|
+
id: options.id ?? "qst_test",
|
|
170
|
+
instanceId,
|
|
171
|
+
turnRecordId: options.turn?.id ?? "trn_test",
|
|
172
|
+
toolCallId: "tool_test",
|
|
173
|
+
questions,
|
|
174
|
+
status: resolution?.status ?? "open",
|
|
175
|
+
askedAt: "2026-01-01T00:00:00.000Z",
|
|
176
|
+
answers: resolution?.status === "answered" ? [...resolution.answers] : null,
|
|
177
|
+
answeredAt: resolution?.status === "answered" ? "2026-01-01T00:00:01.000Z" : null,
|
|
178
|
+
answeredBy: resolution?.status === "answered" ? structuredClone(resolution.actor ?? { id: "test-user", kind: "user", provider: null }) : null,
|
|
179
|
+
cancelledAt: resolution?.status === "cancelled" ? "2026-01-01T00:00:01.000Z" : null
|
|
180
|
+
};
|
|
181
|
+
}
|
|
133
182
|
export {
|
|
134
183
|
createCompactProcessDetailFixtureFactory,
|
|
184
|
+
createProcessFixture,
|
|
185
|
+
createProjectFixture,
|
|
186
|
+
createQuestionFixture,
|
|
187
|
+
createQuestionRequestFixture,
|
|
135
188
|
createTestQuestion,
|
|
136
189
|
createTestQuestionRequest
|
|
137
190
|
};
|
package/dist/fixtures.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/compact-process-detail-fixture.ts","../src/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"],"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;AAC1D,QAAM,8BAA8B,oBAAI,IAOtC;AAGF,WAAS,QAAQ,OAAqD;AACrE,UAAM,SAAS;AACf,QAAI,CAAC,MAAM,QAAQ,OAAO,WAAW,GAAG;AACvC,aAAO;AAAA,IACR;AACA,UAAM,iBAAiB,OAAO,oBAAoB,CAAC;AACnD,UAAM,YAAY,wBAAwB,cAAc;AACxD,UAAM,cAAc;AAAA,MACnB,GAAG;AAAA,MACH,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,SAAS,MAAM,CAAC;AAAA,IACjB;AACA,UAAM,aAAa,+BAA+B;AAAA,MACjD,MAAM;AAAA,MACN,aAAa,OAAO;AAAA,MACpB,QAAQ,OAAO;AAAA,IAChB,CAAC;AACD,UAAM,SAAS,OAAO,YAAY,UAAU;AAC5C,QAAI;AACH,iBAAW,OAAO,YAAY,IAAI;AAAA,QACjC,GAAG;AAAA,QACH,GAAG,WAAW,OAAO,YAAY;AAAA,QACjC,WAAW,OAAO;AAAA,QAClB,YAAY,OAAO;AAAA,QACnB,OAAO,OAAO;AAAA,QACd,WAAW,OAAO,UAAU,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,OAAO;AAAA,UACzD,GAAG;AAAA,UACH,YACC,OAAO,WAAW,WAAW,SAAS,UAAU,OAAO,OAAO,KAA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C5D,sBAAsB;AAAA,MACtB,kBAAkB,QAAQ,aAAa;AAAA,MACvC,WAAW,QAAQ,WAAW,YAAY,KAAK;AAAA,IAChD;AAAA,EACD;AAEA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA,EACD;AACD;;;ACnJO,SAAS,mBACf,YAAyC,CAAC,GACrB;AACrB,SAAO;AAAA,IACN,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,WAAW;AAAA,IACX,SAAS,CAAC,EAAE,IAAI,uBAAuB,OAAO,QAAQ,SAAS,eAAe,CAAC;AAAA,IAC/E,GAAG;AAAA,EACJ;AACD;AAGO,SAAS,0BACf,YAA6C,CAAC,GACrB;AACzB,SAAO;AAAA,IACN,IAAI;AAAA,IACJ,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,WAAW,CAAC,mBAAmB,CAAC;AAAA,IAChC,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,GAAG;AAAA,EACJ;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\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;AAC1D,QAAM,8BAA8B,oBAAI,IAOtC;AAGF,WAAS,QAAQ,OAAqD;AACrE,UAAM,SAAS;AACf,QAAI,CAAC,MAAM,QAAQ,OAAO,WAAW,GAAG;AACvC,aAAO;AAAA,IACR;AACA,UAAM,iBAAiB,OAAO,oBAAoB,CAAC;AACnD,UAAM,YAAY,wBAAwB,cAAc;AACxD,UAAM,cAAc;AAAA,MACnB,GAAG;AAAA,MACH,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,SAAS,MAAM,CAAC;AAAA,IACjB;AACA,UAAM,aAAa,+BAA+B;AAAA,MACjD,MAAM;AAAA,MACN,aAAa,OAAO;AAAA,MACpB,QAAQ,OAAO;AAAA,IAChB,CAAC;AACD,UAAM,SAAS,OAAO,YAAY,UAAU;AAC5C,QAAI;AACH,iBAAW,OAAO,YAAY,IAAI;AAAA,QACjC,GAAG;AAAA,QACH,GAAG,WAAW,OAAO,YAAY;AAAA,QACjC,WAAW,OAAO;AAAA,QAClB,YAAY,OAAO;AAAA,QACnB,OAAO,OAAO;AAAA,QACd,WAAW,OAAO,UAAU,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,OAAO;AAAA,UACzD,GAAG;AAAA,UACH,YACC,OAAO,WAAW,WAAW,SAAS,UAAU,OAAO,OAAO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IAAI,MAAM,0CAA0C;AAC3D,QAAM,YAAY,2BAA2B;AAAA,IAC5C,YAAY,QAAQ,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO;AAAA,MAClD,UAAU,EAAE,YAAY;AAAA,MACxB,WAAW,EAAE,aAAa;AAAA,MAC1B,SAAS,EAAE,WAAW,CAAC,EAAE,OAAO,OAAO,CAAC;AAAA,IACzC,EAAE;AAAA,EACH,CAAC;AACD,QAAM,aAAa,QAAQ;AAC3B,MAAI,YAAY,WAAW,cAAc,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,25 +1,8 @@
|
|
|
1
|
+
import { createInMemoryExternalWriteLog as createInMemoryExternalWriteLogImpl } from "./server-extension-test-harness.js";
|
|
1
2
|
export { FakeLlmProvider } from "./fakes/fake-llm.js";
|
|
2
3
|
export { postImmediateLaunch, postImmediateLaunchRequest } from "./http-launch.js";
|
|
3
4
|
export { type FixtureModelProviderSet, fixtureModelProviders, } from "./model-provider-fixtures.js";
|
|
4
5
|
export { createPollingTestExtension, createTestServerSetupCapability, createToolCollector, } from "./server-extension-test-harness.js";
|
|
5
6
|
/** @internal */
|
|
6
|
-
export declare function createInMemoryExternalWriteLog():
|
|
7
|
-
/** @internal */
|
|
8
|
-
records: Array<{
|
|
9
|
-
/** @internal */
|
|
10
|
-
dedupKey: string;
|
|
11
|
-
}>;
|
|
12
|
-
/** @internal */
|
|
13
|
-
hasDedupKey(key: string): boolean;
|
|
14
|
-
/** @internal */
|
|
15
|
-
record(input: {
|
|
16
|
-
/** @internal */
|
|
17
|
-
dedupKey: string;
|
|
18
|
-
}): {
|
|
19
|
-
/** @internal */
|
|
20
|
-
dedupKey: string;
|
|
21
|
-
};
|
|
22
|
-
/** @internal */
|
|
23
|
-
getDedupKeys(): ReadonlySet<string>;
|
|
24
|
-
};
|
|
7
|
+
export declare function createInMemoryExternalWriteLog(): ReturnType<typeof createInMemoryExternalWriteLogImpl>;
|
|
25
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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,GACrB,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"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
postImmediateLaunch,
|
|
3
|
+
postImmediateLaunchRequest
|
|
4
|
+
} from "./chunk-P2FF4AP7.js";
|
|
1
5
|
import {
|
|
2
6
|
createInMemoryExternalWriteLog,
|
|
3
7
|
createPollingTestExtension,
|
|
@@ -8,73 +12,6 @@ import {
|
|
|
8
12
|
FakeLlmProvider
|
|
9
13
|
} from "./chunk-EXHTWQAE.js";
|
|
10
14
|
|
|
11
|
-
// src/http-launch.ts
|
|
12
|
-
async function postImmediateLaunchRequest(input, init) {
|
|
13
|
-
const url = new URL(String(input));
|
|
14
|
-
const match = /^\/api\/launchers\/([^/]+)\/launch-runs$/.exec(url.pathname);
|
|
15
|
-
if (!match?.[1]) throw new Error(`Expected an immediate launch-run URL, received '${url}'`);
|
|
16
|
-
const body = init?.body ? JSON.parse(String(init.body)) : {};
|
|
17
|
-
return postImmediateLaunch(url.origin, decodeURIComponent(match[1]), body);
|
|
18
|
-
}
|
|
19
|
-
async function postImmediateLaunch(serverBaseUrl, launcherId, body) {
|
|
20
|
-
const admitted = await fetch(
|
|
21
|
-
`${serverBaseUrl.replace(/\/$/, "")}/api/launchers/${encodeURIComponent(launcherId)}/launch-runs`,
|
|
22
|
-
{
|
|
23
|
-
method: "POST",
|
|
24
|
-
headers: { "content-type": "application/json", "idempotency-key": crypto.randomUUID() },
|
|
25
|
-
body: JSON.stringify({ ...body, schedule: { mode: "now" } })
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
const admittedBody = await admitted.json();
|
|
29
|
-
if (admitted.status !== 202 || !admittedBody.launchRunId) {
|
|
30
|
-
return new Response(JSON.stringify(admittedBody), {
|
|
31
|
-
status: admitted.status,
|
|
32
|
-
headers: { "content-type": "application/json" }
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
let launchRun;
|
|
36
|
-
const deadline = Date.now() + 1e4;
|
|
37
|
-
for (; ; ) {
|
|
38
|
-
const response = await fetch(
|
|
39
|
-
`${serverBaseUrl.replace(/\/$/, "")}/api/launch-runs/${admittedBody.launchRunId}`
|
|
40
|
-
);
|
|
41
|
-
const responseBody = await response.json();
|
|
42
|
-
if (responseBody.launchRun.instanceId || ["failed", "cancelled"].includes(responseBody.launchRun.status)) {
|
|
43
|
-
launchRun = responseBody.launchRun;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
if (Date.now() >= deadline) throw new Error("Timed out waiting for immediate launch admission");
|
|
47
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
48
|
-
}
|
|
49
|
-
if (!launchRun.instanceId) {
|
|
50
|
-
const failure2 = launchRun.steps.find((step) => step.status === "failed");
|
|
51
|
-
return new Response(
|
|
52
|
-
JSON.stringify({
|
|
53
|
-
error: failure2?.safeSummary ?? "Launch failed",
|
|
54
|
-
launchRunId: launchRun.id
|
|
55
|
-
}),
|
|
56
|
-
{ status: 400, headers: { "content-type": "application/json" } }
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
const detailResponse = await fetch(
|
|
60
|
-
`${serverBaseUrl.replace(/\/$/, "")}/api/processes/${encodeURIComponent(launchRun.instanceId)}`
|
|
61
|
-
);
|
|
62
|
-
const detail = await detailResponse.json();
|
|
63
|
-
const failure = launchRun.steps.find((step) => step.status === "failed");
|
|
64
|
-
return new Response(
|
|
65
|
-
JSON.stringify({
|
|
66
|
-
process: detail.process,
|
|
67
|
-
projects: detail.projects ?? [],
|
|
68
|
-
launchRunId: launchRun.id,
|
|
69
|
-
...launchRun.status === "failed" ? { error: failure?.safeSummary ?? "Process was created, but startup failed" } : {}
|
|
70
|
-
}),
|
|
71
|
-
{
|
|
72
|
-
status: launchRun.status === "failed" ? 200 : 201,
|
|
73
|
-
headers: { "content-type": "application/json" }
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
15
|
// src/model-provider-fixtures.ts
|
|
79
16
|
import {
|
|
80
17
|
builtinPiProvider,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/model-provider-fixtures.ts","../src/index.ts"],"sourcesContent":["import {\n\tbuiltinPiProvider,\n\tdefineModelProvider,\n\tdefineModelProviders,\n} from \"@leitwerk-dev/process-sdk\";\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","import { createInMemoryExternalWriteLog as createInMemoryExternalWriteLogImpl } from \"./server-extension-test-harness.js\";\n\nexport { FakeLlmProvider } from \"./fakes/fake-llm.js\";\nexport { postImmediateLaunch, postImmediateLaunchRequest } from \"./http-launch.js\";\nexport {\n\ttype FixtureModelProviderSet,\n\tfixtureModelProviders,\n} from \"./model-provider-fixtures.js\";\nexport {\n\tcreatePollingTestExtension,\n\tcreateTestServerSetupCapability,\n\tcreateToolCollector,\n} from \"./server-extension-test-harness.js\";\n\n/** @internal */\nexport function createInMemoryExternalWriteLog(): ReturnType<\n\ttypeof createInMemoryExternalWriteLogImpl\n> {\n\treturn createInMemoryExternalWriteLogImpl();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAMA,SAAS,yBACZ,QAUuB;AAC1B,SAAO;AAAA,IAAqB,CAAC,cAC5B,OAAO,IAAI,CAAC,EAAE,IAAI,SAAS,aAAa,IAAI,SAAS,MAAM,OAAO;AAAA,MACjE,YAAY,oBAAoB;AAAA,QAC/B;AAAA,QACA,aAAa,OAAO,EAAE,QAAQ,CAAC,EAAE;AAAA,QACjC,QAAQ,kBAAkB,UAAU;AAAA,QACpC,GAAI,SAAS,EAAE,QAAQ,kBAAkB,UAAU,EAAE,IAAI,CAAC;AAAA,QAC1D,QAAQ,MAAM,CAAC,EAAE,SAAS,cAAc,YAAY,CAAC;AAAA,QACrD,SAAS,OAAO,CAAC;AAAA,MAClB,CAAC;AAAA,MACD;AAAA,IACD,EAAE;AAAA,EACH;AACD;;;ACpBO,SAASA,kCAEd;AACD,SAAO,+BAAmC;AAC3C;","names":["createInMemoryExternalWriteLog"]}
|