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