@leitwerk-dev/worker-protocol 0.1.9 → 0.2.1

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.
Files changed (67) hide show
  1. package/dist/{chunk-DVN32ANP.js → chunk-VR7BWTD7.js} +5 -1
  2. package/dist/chunk-VR7BWTD7.js.map +1 -0
  3. package/dist/docker-config.d.ts +39 -0
  4. package/dist/docker-config.d.ts.map +1 -0
  5. package/dist/index.d.ts +7 -5
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +529 -10
  8. package/dist/index.js.map +1 -1
  9. package/dist/ipc-codec.d.ts +22 -0
  10. package/dist/ipc-codec.d.ts.map +1 -1
  11. package/dist/ipc-decode.d.ts +7 -0
  12. package/dist/ipc-decode.d.ts.map +1 -1
  13. package/dist/ipc-messages.d.ts +339 -25
  14. package/dist/ipc-messages.d.ts.map +1 -1
  15. package/dist/pi-resource-bundle.d.ts +13 -2
  16. package/dist/pi-resource-bundle.d.ts.map +1 -1
  17. package/dist/pi-resource-manifest.d.ts +35 -1
  18. package/dist/pi-resource-manifest.d.ts.map +1 -1
  19. package/dist/testing.d.ts +3 -0
  20. package/dist/testing.d.ts.map +1 -1
  21. package/dist/worker-api-version.d.ts +2 -1
  22. package/dist/worker-api-version.d.ts.map +1 -1
  23. package/dist/worker-ipc-transport.d.ts +7 -0
  24. package/dist/worker-ipc-transport.d.ts.map +1 -1
  25. package/dist/worker-result-image-public.d.ts +2 -0
  26. package/dist/worker-result-image-public.d.ts.map +1 -0
  27. package/dist/worker-result-image-public.js +7 -0
  28. package/dist/worker-result-image-public.js.map +1 -0
  29. package/dist/worker-result-image.d.ts +22 -0
  30. package/dist/worker-result-image.d.ts.map +1 -1
  31. package/dist/worker-result-image.js +28 -54
  32. package/dist/worker-result-image.js.map +1 -1
  33. package/dist/worker-session-snapshot.d.ts +5 -0
  34. package/dist/worker-session-snapshot.d.ts.map +1 -1
  35. package/package.json +7 -7
  36. package/src/docker-config.ts +50 -0
  37. package/src/index.ts +63 -5
  38. package/src/ipc-codec.ts +40 -6
  39. package/src/ipc-decode.ts +17 -2
  40. package/src/ipc-messages.ts +368 -32
  41. package/src/pi-resource-bundle.ts +13 -2
  42. package/src/pi-resource-manifest.ts +35 -1
  43. package/src/testing.ts +8 -0
  44. package/src/worker-api-version.ts +2 -1
  45. package/src/worker-ipc-transport.ts +7 -0
  46. package/src/worker-result-image-public.ts +1 -0
  47. package/src/worker-result-image.ts +25 -1
  48. package/src/worker-session-snapshot.ts +5 -0
  49. package/dist/chunk-DVN32ANP.js.map +0 -1
  50. package/dist/ipc-codec.js +0 -48
  51. package/dist/ipc-codec.js.map +0 -1
  52. package/dist/ipc-decode.js +0 -72
  53. package/dist/ipc-decode.js.map +0 -1
  54. package/dist/ipc-messages.js +0 -14
  55. package/dist/ipc-messages.js.map +0 -1
  56. package/dist/pi-resource-bundle.js +0 -139
  57. package/dist/pi-resource-bundle.js.map +0 -1
  58. package/dist/pi-resource-manifest.js +0 -101
  59. package/dist/pi-resource-manifest.js.map +0 -1
  60. package/dist/testing.js +0 -33
  61. package/dist/testing.js.map +0 -1
  62. package/dist/worker-api-version.js +0 -9
  63. package/dist/worker-api-version.js.map +0 -1
  64. package/dist/worker-ipc-transport.js +0 -8
  65. package/dist/worker-ipc-transport.js.map +0 -1
  66. package/dist/worker-session-snapshot.js +0 -8
  67. package/dist/worker-session-snapshot.js.map +0 -1
@@ -5,422 +5,758 @@ import type {
5
5
  ProcessInputTarget,
6
6
  ProcessLifecycleStatus,
7
7
  ProcessSemanticEntryRefKey,
8
- ProcessTurnRecordPathType,
9
- ProcessTurnType,
10
8
  TurnFailedPayload,
9
+ TurnOutcomePayload,
11
10
  TurnStartRecord,
12
11
  WorkerBootstrapReceipt,
13
12
  } from "@leitwerk-dev/domain";
14
13
  import type { ConfigSnapshot } from "@leitwerk-dev/protocol/config-snapshot";
14
+ import type { InferOutput } from "valibot";
15
+ import type { dockerRegistryCredentialSchema } from "./docker-config.js";
15
16
  import { IPC_PROTOCOL_VERSION, type IpcEnvelope } from "./ipc-codec.js";
16
17
 
18
+ /** @internal */
17
19
  export interface ProcessInstanceSnapshot {
20
+ /** @internal */
18
21
  id?: string;
22
+ /** @internal */
19
23
  processId?: string;
24
+ /** @internal */
20
25
  selectedTurnId?: string | null;
26
+ /** @internal */
21
27
  lifecycleStatus?: ProcessLifecycleStatus;
28
+ /** @internal */
22
29
  currentExecution?: CurrentExecutionRef;
30
+ /** @internal */
23
31
  planRevision?: number;
32
+ /** @internal */
24
33
  title?: string | null;
34
+ /** @internal */
25
35
  externalId?: string | null;
36
+ /** @internal */
26
37
  externalUrl?: string | null;
38
+ /** @internal */
27
39
  metadata?: Record<string, unknown> | null;
40
+ /** @internal */
28
41
  defaultModelProfileId?: string | null;
42
+ /** @internal */
29
43
  turnConfigsJson?: string | null;
44
+ /** @internal */
30
45
  selectedTurnModelProfileId?: string | null;
46
+ /** @internal */
31
47
  paramsJson?: string | null;
48
+ /** @internal */
32
49
  stateJson?: string | null;
50
+ /** @internal */
33
51
  createdAt?: string;
52
+ /** @internal */
34
53
  updatedAt?: string;
35
54
  }
36
55
 
56
+ /** @internal */
37
57
  export interface ProcessProjectSnapshot {
58
+ /** @internal */
38
59
  id?: string;
60
+ /** @internal */
39
61
  instanceId?: string;
62
+ /** @internal */
40
63
  key: string;
64
+ /** @internal */
41
65
  repoLocator: string;
66
+ /** @internal */
42
67
  repoLocatorKind?: "remote_url" | "local_path";
68
+ /** @internal */
43
69
  baseBranch: string;
70
+ /** @internal */
44
71
  workBranch?: string | null;
72
+ /** @internal */
45
73
  externalId?: string | null;
74
+ /** @internal */
46
75
  externalUrl?: string | null;
76
+ /** @internal */
47
77
  metadata?: Record<string, unknown> | null;
78
+ /** @internal */
48
79
  pipelineStatus?: string | null;
80
+ /** @internal */
49
81
  createdAt?: string;
82
+ /** @internal */
50
83
  updatedAt?: string;
51
84
  }
52
85
 
86
+ /** @internal */
53
87
  export interface InputDelivery {
88
+ /** @internal */
54
89
  inputId: string;
90
+ /** @internal */
55
91
  sequence: number;
92
+ /** @internal */
56
93
  source: string;
94
+ /** @internal */
57
95
  kind: string;
96
+ /** @internal */
58
97
  target: ProcessInputTarget | null;
98
+ /** @internal */
59
99
  receivedAt: string;
100
+ /** @internal */
60
101
  bodyMarkdown: string;
61
102
  }
62
103
 
104
+ /** @internal */
63
105
  export interface WorkerRuntimeContextSnapshot {
106
+ /** @internal */
64
107
  processSnapshot: ProcessInstanceSnapshot;
108
+ /** @internal */
65
109
  projectSnapshots: ProcessProjectSnapshot[];
110
+ /** @internal */
66
111
  turnResultMarkdownBySemanticRef?: Partial<Record<ProcessSemanticEntryRefKey, string>>;
112
+ /** @internal */
67
113
  turnResultMarkdownByProduct?: Record<string, string>;
68
114
  }
69
115
 
116
+ /** @internal */
70
117
  export interface WorkerCredentialMaterial {
118
+ /** @internal */
71
119
  providerId: string;
72
- /** Null for generated credentials that are materialized but never synchronized. */
120
+ /** Null for generated credentials that are materialized but never synchronized. @internal */
73
121
  revision: number | null;
74
- /** Secret payload. This type is valid only in worker.start and credential-update frames. */
122
+ /** Secret payload. This type is valid only in worker.start and credential-update frames. @internal */
75
123
  values: Record<string, string>;
76
124
  }
77
125
 
126
+ /** @internal */
78
127
  export interface WorkerGitSshCredential {
128
+ /** @internal */
79
129
  projectKey: string;
130
+ /** @internal */
80
131
  kind: "git_ssh";
132
+ /** @internal */
81
133
  credentialRef: string;
82
- /** Secret values; valid only while preparing worker.start. */
134
+ /** Secret values; valid only while preparing worker.start. @internal */
83
135
  privateKey: string;
136
+ /** @internal */
84
137
  knownHosts: string;
85
138
  }
86
139
 
140
+ /** @internal */
141
+ export interface WorkerGitHttpsCredential {
142
+ /** @internal */
143
+ projectKey: string;
144
+ /** @internal */
145
+ kind: "git_https";
146
+ /** @internal */
147
+ credentialRef: string;
148
+ /** Exact non-secret HTTPS clone URL authorized by the server. @internal */
149
+ repositoryUrl: string;
150
+ /** @internal */
151
+ username: string;
152
+ /** Secret; only delivered through authenticated worker.start. @internal */
153
+ password: string;
154
+ }
155
+
156
+ /** @internal */
157
+ export type WorkerRepositoryCredential = WorkerGitSshCredential | WorkerGitHttpsCredential;
158
+
159
+ /** Secret material allowed only in authenticated worker.start, never snapshots or exports. @internal */
160
+ export interface WorkerDockerRegistryCredential
161
+ extends InferOutput<typeof dockerRegistryCredentialSchema> {}
162
+
163
+ /** @internal */
87
164
  export interface LlmWorkerStartBootstrap {
165
+ /** @internal */
88
166
  kind: "llm";
89
- resourceBundle: { digest: string; archiveBase64: string };
167
+ /** @internal */
168
+ resourceBundle: {
169
+ /** @internal */
170
+ digest: string;
171
+ /** Present for a newly assembled bundle; omitted when the worker can reuse its process volume. @internal */
172
+ archiveBase64?: string;
173
+ };
174
+ /** @internal */
90
175
  credential: WorkerCredentialMaterial | null;
91
176
  }
92
177
 
178
+ /** @internal */
93
179
  export interface AutomaticWorkerStartBootstrap {
180
+ /** @internal */
94
181
  kind: "automatic";
95
182
  }
96
183
 
184
+ /** @internal */
97
185
  export type WorkerRuntimeSettingsSnapshot = ConfigSnapshot["workers"];
98
186
 
187
+ /** @internal */
188
+ export interface DevelopmentToolsStartConfig {
189
+ /** @internal */
190
+ runner: "local" | "isolated";
191
+ /** @internal */
192
+ miseCommand: string;
193
+ /** @internal */
194
+ installTimeoutMs: number;
195
+ /** @internal */
196
+ processStorageRoot: string;
197
+ }
198
+
199
+ /** @internal */
99
200
  export interface IntegrationToolDeclaration {
201
+ /** @internal */
100
202
  name: string;
203
+ /** @internal */
101
204
  description: string;
205
+ /** @internal */
102
206
  parameters: Record<string, unknown>;
103
207
  }
104
208
 
209
+ /** @internal */
105
210
  interface WorkerStartPayloadBase extends WorkerRuntimeContextSnapshot {
211
+ /** @internal */
106
212
  workerLeaseId: string;
213
+ /** @internal */
107
214
  turnStart: TurnStartRecord;
108
215
  /**
109
216
  * The immutable pre-acceptance tree plan from the lease that first accepted
110
217
  * this start. It is supplied only when a replacement resumes a running turn.
111
218
  */
219
+ /** @internal */
112
220
  acceptedPreparedStart?: PreparedTurnStart | null;
221
+ /** @internal */
113
222
  pendingInputs: InputDelivery[];
223
+ /** @internal */
114
224
  treePaths: {
225
+ /** @internal */
115
226
  primaryTreeFile: string;
227
+ /** @internal */
116
228
  workspaceRoot: string;
229
+ /** Process-scoped persistent storage for immutable Pi resource bundles. @internal */
230
+ piResourceBundlesDir: string;
117
231
  };
232
+ /** @internal */
118
233
  resume: boolean;
234
+ /** @internal */
119
235
  resumeLeafEntryId?: string | null;
120
- /** Fresh secret material resolved for this physical worker start only. */
121
- repositoryCredentials?: WorkerGitSshCredential[];
122
- /** Non-secret lifecycle settings supplied to every worker bootstrap type. */
236
+ /** Durable non-secret preparation checkpoint reused by a replacement or Continue start. @internal */
237
+ llmPreparation?: {
238
+ /** @internal */
239
+ sourceTurnRecordId: string;
240
+ /** @internal */
241
+ data: unknown;
242
+ };
243
+ /** Fresh secret material resolved for this physical worker start only. @internal */
244
+ repositoryCredentials?: WorkerRepositoryCredential[];
245
+ /** @internal */
246
+ dockerRegistryCredentials?: WorkerDockerRegistryCredential[];
247
+ /** Non-secret lifecycle settings supplied to every worker bootstrap type. @internal */
123
248
  workerRuntimeSettings?: WorkerRuntimeSettingsSnapshot;
124
- /** Non-secret declarations authorized for the selected LLM turn. */
249
+ /** Non-secret mise adapter settings. Ignored unless the process opts in. @internal */
250
+ developmentTools?: DevelopmentToolsStartConfig;
251
+ /** Non-secret declarations authorized for the selected LLM turn. @internal */
125
252
  integrationTools?: IntegrationToolDeclaration[];
126
253
  }
127
254
 
255
+ /** @internal */
128
256
  export type WorkerStartPayload =
129
257
  | (WorkerStartPayloadBase & {
258
+ /** @internal */
130
259
  bootstrap: LlmWorkerStartBootstrap;
260
+ /** @internal */
131
261
  configSnapshot: ConfigSnapshot;
132
262
  })
133
- | (WorkerStartPayloadBase & { bootstrap: AutomaticWorkerStartBootstrap });
263
+ | (WorkerStartPayloadBase & {
264
+ /** @internal */
265
+ bootstrap: AutomaticWorkerStartBootstrap;
266
+ });
134
267
 
268
+ /** @internal */
135
269
  export interface InputBatchPayload {
270
+ /** @internal */
136
271
  inputs: InputDelivery[];
137
272
  }
138
273
 
274
+ /** @internal */
139
275
  export interface WorkerStopPayload {
276
+ /** @internal */
140
277
  reason: string;
141
278
  }
142
279
 
280
+ /** @internal */
143
281
  export interface WorkerAbortTurnPayload {
282
+ /** @internal */
144
283
  reason: string;
145
284
  }
146
285
 
286
+ /** @internal */
147
287
  export interface WorkerTurnStartAcceptedPayload {
288
+ /** @internal */
148
289
  startRecordId: string;
290
+ /** @internal */
149
291
  turnRecordId: string;
150
292
  }
151
293
 
294
+ /** @internal */
152
295
  export interface WorkerTurnTerminalRecordedPayload {
296
+ /** @internal */
153
297
  turnRecordId: string;
154
298
  }
155
299
 
300
+ /** @internal */
156
301
  export interface WorkerQuestionResponsePayload {
302
+ /** @internal */
157
303
  turnRecordId: string;
304
+ /** @internal */
158
305
  toolCallId: string;
306
+ /** @internal */
159
307
  answers: string[];
160
308
  }
161
309
 
310
+ /** @internal */
162
311
  export interface WorkerQuestionRequestedPayload {
312
+ /** @internal */
163
313
  turnRecordId: string;
314
+ /** @internal */
164
315
  toolCallId: string;
316
+ /** @internal */
165
317
  questions: NormalizedQuestion[];
166
318
  }
167
319
 
320
+ /** @internal */
168
321
  export interface WorkerIntegrationToolRequestPayload {
322
+ /** @internal */
169
323
  turnRecordId: string;
324
+ /** @internal */
170
325
  toolCallId: string;
326
+ /** @internal */
171
327
  toolName: string;
328
+ /** @internal */
172
329
  args: Record<string, unknown>;
173
330
  }
174
331
 
332
+ /** @internal */
175
333
  export interface WorkerIntegrationToolCancelPayload {
334
+ /** @internal */
176
335
  turnRecordId: string;
336
+ /** @internal */
177
337
  toolCallId: string;
338
+ /** @internal */
178
339
  toolName: string;
179
340
  }
180
341
 
342
+ /** @internal */
181
343
  export interface WorkerIntegrationToolResultPayload {
344
+ /** @internal */
182
345
  turnRecordId: string;
346
+ /** @internal */
183
347
  toolCallId: string;
348
+ /** @internal */
184
349
  ok: boolean;
350
+ /** @internal */
185
351
  result?: unknown;
352
+ /** @internal */
186
353
  error?: string;
187
354
  }
188
355
 
356
+ /** @internal */
189
357
  export interface WorkerCredentialUpdateResultPayload {
358
+ /** @internal */
190
359
  providerId: string;
360
+ /** @internal */
191
361
  accepted: boolean;
362
+ /** @internal */
192
363
  currentRevision: number | null;
364
+ /** @internal */
193
365
  safeReason?: string;
194
366
  }
195
367
 
368
+ /** @internal */
196
369
  export type ServerToWorkerMessage =
197
370
  | (Omit<IpcEnvelope, "type" | "payload"> & {
371
+ /** @internal */
198
372
  type: "worker.start";
373
+ /** @internal */
199
374
  payload: WorkerStartPayload;
200
375
  })
201
376
  | (Omit<IpcEnvelope, "type" | "payload"> & {
377
+ /** @internal */
202
378
  type: "worker.turn_start_accepted";
379
+ /** @internal */
203
380
  payload: WorkerTurnStartAcceptedPayload;
204
381
  })
205
382
  | (Omit<IpcEnvelope, "type" | "payload"> & {
383
+ /** @internal */
206
384
  type: "worker.turn_terminal_recorded";
385
+ /** @internal */
207
386
  payload: WorkerTurnTerminalRecordedPayload;
208
387
  })
209
388
  | (Omit<IpcEnvelope, "type" | "payload"> & {
389
+ /** @internal */
210
390
  type: "worker.credential_update_accepted";
391
+ /** @internal */
211
392
  payload: WorkerCredentialUpdateResultPayload;
212
393
  })
213
394
  | (Omit<IpcEnvelope, "type" | "payload"> & {
395
+ /** @internal */
214
396
  type: "worker.question_response";
397
+ /** @internal */
215
398
  payload: WorkerQuestionResponsePayload;
216
399
  })
217
400
  | (Omit<IpcEnvelope, "type" | "payload"> & {
401
+ /** @internal */
218
402
  type: "worker.integration_tool_result";
403
+ /** @internal */
219
404
  payload: WorkerIntegrationToolResultPayload;
220
405
  })
221
406
  | (Omit<IpcEnvelope, "type" | "payload"> & {
407
+ /** @internal */
222
408
  type: "input.batch";
409
+ /** @internal */
223
410
  payload: InputBatchPayload;
224
411
  })
225
412
  | (Omit<IpcEnvelope, "type" | "payload"> & {
413
+ /** @internal */
226
414
  type: "worker.stop";
415
+ /** @internal */
227
416
  payload: WorkerStopPayload;
228
417
  })
229
418
  | (Omit<IpcEnvelope, "type" | "payload"> & {
419
+ /** @internal */
230
420
  type: "worker.abort_turn";
421
+ /** @internal */
231
422
  payload: WorkerAbortTurnPayload;
232
423
  });
233
424
 
425
+ /** @internal */
234
426
  export interface WorkerHelloPayload {
235
- /** Package/runtime version for diagnostics. */
427
+ /** Package/runtime version for diagnostics. @internal */
236
428
  version: string;
237
- /** Server-worker API compatibility version. Missing only on legacy/test workers. */
429
+ /** Server-worker API compatibility version. Missing only on legacy/test workers. @internal */
238
430
  apiVersion?: string;
431
+ /** @internal */
239
432
  capabilities: string[];
240
433
  }
241
434
 
435
+ /** @internal */
436
+ export interface WorkerBootstrapProgressPayload {
437
+ /** @internal */
438
+ phase: "worker_connected" | "preparing_workspace" | "loading_resources" | "preparing_turn";
439
+ }
440
+
441
+ /** @internal */
442
+ export interface WorkerDiagnosticTracePayload {
443
+ /** @internal */
444
+ text: string;
445
+ }
446
+
447
+ /** @internal */
242
448
  export interface WorkerReadyPayload {
449
+ /** @internal */
243
450
  receipt: WorkerBootstrapReceipt;
451
+ /** @internal */
452
+ developmentTools?: {
453
+ /** @internal */
454
+ miseVersion: string;
455
+ /** @internal */
456
+ repositories: Array<{
457
+ /** @internal */
458
+ repositoryKey: string;
459
+ /** @internal */
460
+ tools: Array<{
461
+ /** @internal */
462
+ name: string;
463
+ /** @internal */
464
+ version: string;
465
+ }>;
466
+ }>;
467
+ /** @internal */
468
+ warnings: string[];
469
+ };
470
+ /** @internal */
244
471
  resumed: boolean;
472
+ /** @internal */
245
473
  primaryTreeFile: string;
474
+ /** @internal */
246
475
  workspaceRoot: string;
476
+ /** @internal */
247
477
  aggregatedAgentsSources: string[];
478
+ /** @internal */
248
479
  loadedSkills: string[];
249
- loadedAgentsFiles: Array<{ path: string; sizeBytes: number }>;
250
- loadedSkillFiles: Array<{ name: string; path: string }>;
480
+ /** @internal */
481
+ loadedAgentsFiles: Array<{
482
+ /** @internal */
483
+ path: string;
484
+ /** @internal */
485
+ sizeBytes: number;
486
+ }>;
487
+ /** @internal */
488
+ loadedSkillFiles: Array<{
489
+ /** @internal */
490
+ name: string;
491
+ /** @internal */
492
+ path: string;
493
+ }>;
494
+ /** @internal */
251
495
  rootEntryId?: string | null;
252
496
  }
253
497
 
498
+ /** @internal */
254
499
  export interface WorkerHeartbeatPayload {
255
- /** Diagnostic worker-local runtime state; not the authoritative lease transition channel. */
500
+ /** Diagnostic worker-local runtime state; not the authoritative lease transition channel. @internal */
256
501
  state: string;
502
+ /** @internal */
257
503
  lastSequenceConsumed: number;
504
+ /** @internal */
258
505
  currentTurnId?: string;
506
+ /** @internal */
259
507
  currentSelectedTurnId?: string | null;
260
508
  }
261
509
 
510
+ /** @internal */
262
511
  export interface WorkerStatePayload {
263
- /** Explicit server-visible runtime transition, e.g. idle -> busy or busy -> idle. */
512
+ /** Explicit server-visible runtime transition, e.g. idle -> busy or busy -> idle. @internal */
264
513
  from: string;
514
+ /** @internal */
265
515
  to: string;
516
+ /** @internal */
266
517
  reason: string;
267
518
  }
268
519
 
520
+ /** @internal */
269
521
  export interface WorkerInputConsumedPayload {
522
+ /** @internal */
270
523
  inputId: string;
524
+ /** @internal */
271
525
  sequence: number;
526
+ /** @internal */
272
527
  deliveryMode: string;
528
+ /** @internal */
273
529
  currentPrimaryPathLeafId?: string | null;
530
+ /** @internal */
274
531
  rootEntryId?: string | null;
532
+ /** @internal */
275
533
  targetSemanticRef?: ProcessSemanticEntryRefKey | null;
534
+ /** @internal */
276
535
  targetProductName?: string | null;
536
+ /** @internal */
277
537
  targetEntryId?: string | null;
278
538
  }
279
539
 
540
+ /** @internal */
280
541
  export interface WorkerEventPayload {
542
+ /** @internal */
281
543
  eventType: string;
544
+ /** @internal */
282
545
  selectedTurnId?: string | null;
283
546
  /**
284
547
  * Object-shaped event data emitted by trusted worker senders. Decode helpers
285
548
  * do not deeply validate this field at runtime; they only narrow it at the
286
549
  * protocol boundary after envelope + message-type validation.
287
550
  */
551
+ /** @internal */
288
552
  data: Record<string, unknown>;
289
553
  }
290
554
 
555
+ /** @internal */
291
556
  export interface WorkerTurnStartedPayload {
557
+ /** @internal */
292
558
  startRecordId: string;
559
+ /** @internal */
293
560
  proposedTurnRecordId: string;
294
561
  }
295
562
 
563
+ /** @internal */
296
564
  export interface WorkerCredentialUpdatePayload {
565
+ /** @internal */
297
566
  providerId: string;
567
+ /** @internal */
298
568
  expectedRevision: number;
299
- /** Secret payload. It must not be copied into receipts, events, or turn state. */
569
+ /** Secret payload. It must not be copied into receipts, events, or turn state. @internal */
300
570
  values: Record<string, string>;
301
571
  }
302
572
 
303
- export interface WorkerTurnOutcomePayload {
304
- turnRecordId: string;
305
- turnId: string;
306
- turnType: ProcessTurnType;
307
- outcome: string;
308
- params: Record<string, unknown>;
309
- pathType?: ProcessTurnRecordPathType;
310
- forkPiEntryId?: string | null;
311
- resultPiEntryId?: string | null;
312
- turnResultMarkdown?: string | null;
313
- rootEntryId?: string | null;
314
- }
573
+ /** @internal */
574
+ export interface WorkerTurnOutcomePayload
575
+ extends Omit<TurnOutcomePayload, "instanceId" | "state"> {}
315
576
 
577
+ /** @internal */
316
578
  export interface WorkerTurnFailedPayload
317
579
  extends Omit<TurnFailedPayload, "instanceId" | "errorClass"> {
580
+ /** @internal */
318
581
  errorClass?: string;
319
582
  }
320
583
 
584
+ /** @internal */
321
585
  export interface WorkerLifecycleParkedPayload {
586
+ /** @internal */
322
587
  selectedTurnId: string | null;
588
+ /** @internal */
323
589
  reason?: string;
590
+ /** @internal */
324
591
  errorClass?: string;
325
592
  }
326
593
 
594
+ /** @internal */
327
595
  export interface WorkerCleanupStartedPayload {
596
+ /** @internal */
328
597
  reason: string;
329
598
  }
330
599
 
600
+ /** @internal */
331
601
  export interface WorkerCleanupCompletedPayload {
602
+ /** @internal */
332
603
  releasedLocks: string[];
604
+ /** @internal */
333
605
  removedTransientPaths: string[];
334
606
  }
335
607
 
608
+ /** @internal */
336
609
  export interface WorkerFailedPayload {
610
+ /** @internal */
337
611
  state: string;
612
+ /** @internal */
338
613
  errorCode: string;
614
+ /** @internal */
339
615
  message: string;
616
+ /** @internal */
340
617
  errorClass: string;
618
+ /** @internal */
341
619
  selectedTurnId?: string | null;
620
+ /** @internal */
342
621
  retryAttempt?: number;
343
622
  }
344
623
 
624
+ /** @internal */
345
625
  export type WorkerToServerMessage =
346
626
  | (Omit<IpcEnvelope, "type" | "payload"> & {
627
+ /** @internal */
347
628
  type: "worker.hello";
629
+ /** @internal */
348
630
  payload: WorkerHelloPayload;
349
631
  })
350
632
  | (Omit<IpcEnvelope, "type" | "payload"> & {
633
+ /** @internal */
351
634
  type: "worker.credential_update";
635
+ /** @internal */
352
636
  payload: WorkerCredentialUpdatePayload;
353
637
  })
354
638
  | (Omit<IpcEnvelope, "type" | "payload"> & {
639
+ /** @internal */
640
+ type: "worker.bootstrap_progress";
641
+ /** @internal */
642
+ payload: WorkerBootstrapProgressPayload;
643
+ })
644
+ | (Omit<IpcEnvelope, "type" | "payload"> & {
645
+ /** @internal */
646
+ type: "worker.diagnostic_trace";
647
+ /** @internal */
648
+ payload: WorkerDiagnosticTracePayload;
649
+ })
650
+ | (Omit<IpcEnvelope, "type" | "payload"> & {
651
+ /** @internal */
355
652
  type: "worker.ready";
653
+ /** @internal */
356
654
  payload: WorkerReadyPayload;
357
655
  })
358
656
  | (Omit<IpcEnvelope, "type" | "payload"> & {
657
+ /** @internal */
359
658
  type: "worker.heartbeat";
659
+ /** @internal */
360
660
  payload: WorkerHeartbeatPayload;
361
661
  })
362
662
  | (Omit<IpcEnvelope, "type" | "payload"> & {
663
+ /** @internal */
363
664
  type: "worker.state";
665
+ /** @internal */
364
666
  payload: WorkerStatePayload;
365
667
  })
366
668
  | (Omit<IpcEnvelope, "type" | "payload"> & {
669
+ /** @internal */
367
670
  type: "worker.input_consumed";
671
+ /** @internal */
368
672
  payload: WorkerInputConsumedPayload;
369
673
  })
370
674
  | (Omit<IpcEnvelope, "type" | "payload"> & {
675
+ /** @internal */
371
676
  type: "worker.event";
677
+ /** @internal */
372
678
  payload: WorkerEventPayload;
373
679
  })
374
680
  | (Omit<IpcEnvelope, "type" | "payload"> & {
681
+ /** @internal */
375
682
  type: "worker.turn_started";
683
+ /** @internal */
376
684
  payload: WorkerTurnStartedPayload;
377
685
  })
378
686
  | (Omit<IpcEnvelope, "type" | "payload"> & {
687
+ /** @internal */
379
688
  type: "worker.question_requested";
689
+ /** @internal */
380
690
  payload: WorkerQuestionRequestedPayload;
381
691
  })
382
692
  | (Omit<IpcEnvelope, "type" | "payload"> & {
693
+ /** @internal */
383
694
  type: "worker.integration_tool_request";
695
+ /** @internal */
384
696
  payload: WorkerIntegrationToolRequestPayload;
385
697
  })
386
698
  | (Omit<IpcEnvelope, "type" | "payload"> & {
699
+ /** @internal */
387
700
  type: "worker.integration_tool_cancel";
701
+ /** @internal */
388
702
  payload: WorkerIntegrationToolCancelPayload;
389
703
  })
390
704
  | (Omit<IpcEnvelope, "type" | "payload"> & {
705
+ /** @internal */
391
706
  type: "worker.turn_outcome";
707
+ /** @internal */
392
708
  payload: WorkerTurnOutcomePayload;
393
709
  })
394
710
  | (Omit<IpcEnvelope, "type" | "payload"> & {
711
+ /** @internal */
395
712
  type: "worker.turn_failed";
713
+ /** @internal */
396
714
  payload: WorkerTurnFailedPayload;
397
715
  })
398
716
  | (Omit<IpcEnvelope, "type" | "payload"> & {
717
+ /** @internal */
399
718
  type: "worker.lifecycle_parked";
719
+ /** @internal */
400
720
  payload: WorkerLifecycleParkedPayload;
401
721
  })
402
722
  | (Omit<IpcEnvelope, "type" | "payload"> & {
723
+ /** @internal */
403
724
  type: "worker.cleanup_started";
725
+ /** @internal */
404
726
  payload: WorkerCleanupStartedPayload;
405
727
  })
406
728
  | (Omit<IpcEnvelope, "type" | "payload"> & {
729
+ /** @internal */
407
730
  type: "worker.cleanup_completed";
731
+ /** @internal */
408
732
  payload: WorkerCleanupCompletedPayload;
409
733
  })
410
734
  | (Omit<IpcEnvelope, "type" | "payload"> & {
735
+ /** @internal */
411
736
  type: "worker.failed";
737
+ /** @internal */
412
738
  payload: WorkerFailedPayload;
413
739
  });
414
740
 
741
+ /** @internal */
415
742
  export type AnyIpcMessage = ServerToWorkerMessage | WorkerToServerMessage;
743
+ /** @internal */
416
744
  export type IpcMessageType = AnyIpcMessage["type"];
745
+ /** @internal */
417
746
  export type IpcMessageOfType<TType extends IpcMessageType> = Extract<
418
747
  AnyIpcMessage,
419
- { type: TType }
748
+ {
749
+ /** @internal */
750
+ type: TType;
751
+ }
420
752
  >;
421
753
 
754
+ /** @internal */
422
755
  export function createIpcMessage<TMessage extends AnyIpcMessage>(
423
- args: Omit<TMessage, "protocol" | "sentAt"> & { sentAt?: string },
756
+ args: Omit<TMessage, "protocol" | "sentAt"> & {
757
+ /** @internal */
758
+ sentAt?: string;
759
+ },
424
760
  ): TMessage {
425
761
  return {
426
762
  protocol: IPC_PROTOCOL_VERSION,