@alpacakit/agents 0.1.0-beta.35 → 0.1.0-beta.37

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 (66) hide show
  1. package/README.md +39 -10
  2. package/dist/agents/claude.d.ts +9 -2
  3. package/dist/agents/claude.d.ts.map +1 -1
  4. package/dist/agents/claude.js +46 -5
  5. package/dist/agents/codex.d.ts +1 -1
  6. package/dist/agents/codex.js +1 -1
  7. package/dist/agents/openai-compatible/engine.d.ts +5 -4
  8. package/dist/agents/openai-compatible/engine.d.ts.map +1 -1
  9. package/dist/agents/openai-compatible/engine.js +5 -4
  10. package/dist/config/agent-configs.d.ts +3 -1
  11. package/dist/config/agent-configs.d.ts.map +1 -1
  12. package/dist/config/agent-configs.js +23 -2
  13. package/dist/config/compose.d.ts.map +1 -1
  14. package/dist/config/compose.js +1 -0
  15. package/dist/config/index.d.ts +2 -1
  16. package/dist/config/index.d.ts.map +1 -1
  17. package/dist/config/index.js +1 -1
  18. package/dist/config/model.d.ts +6 -0
  19. package/dist/config/model.d.ts.map +1 -1
  20. package/dist/config/values.d.ts +19 -0
  21. package/dist/config/values.d.ts.map +1 -1
  22. package/dist/config/values.js +18 -0
  23. package/dist/core/error.d.ts +25 -0
  24. package/dist/core/error.d.ts.map +1 -1
  25. package/dist/core/error.js +15 -0
  26. package/dist/core/node-controlled-exec.d.ts.map +1 -1
  27. package/dist/core/node-controlled-exec.js +31 -8
  28. package/dist/core/node-ports.d.ts.map +1 -1
  29. package/dist/core/node-ports.js +20 -0
  30. package/dist/core/ports.d.ts +5 -0
  31. package/dist/core/ports.d.ts.map +1 -1
  32. package/dist/fleet/policy.d.ts.map +1 -1
  33. package/dist/fleet/policy.js +3 -0
  34. package/dist/index.d.ts +5 -6
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -5
  37. package/dist/internal/controlled-process/host-controller.d.ts +3 -2
  38. package/dist/internal/controlled-process/host-controller.d.ts.map +1 -1
  39. package/dist/internal/controlled-process/host-controller.js +63 -23
  40. package/dist/internal/controlled-process/input-transport.d.ts +17 -0
  41. package/dist/internal/controlled-process/input-transport.d.ts.map +1 -0
  42. package/dist/internal/controlled-process/input-transport.js +188 -0
  43. package/dist/internal/controlled-process/lifecycle.d.ts +1 -1
  44. package/dist/internal/controlled-process/lifecycle.d.ts.map +1 -1
  45. package/dist/internal/controlled-process/lifecycle.js +1 -0
  46. package/dist/internal/controlled-process/schema.d.ts +2 -2
  47. package/dist/internal/controlled-process/schema.js +1 -1
  48. package/dist/internal/controlled-process/shim-runtime.d.ts.map +1 -1
  49. package/dist/internal/controlled-process/shim-runtime.js +43 -4
  50. package/dist/internal/controlled-process/supervisor-coordinator.d.ts.map +1 -1
  51. package/dist/internal/controlled-process/supervisor-coordinator.js +4 -2
  52. package/dist/internal/controlled-process/supervisor-model.d.ts +24 -2
  53. package/dist/internal/controlled-process/supervisor-model.d.ts.map +1 -1
  54. package/dist/internal/controlled-process/supervisor-runtime.d.ts.map +1 -1
  55. package/dist/internal/controlled-process/supervisor-runtime.js +116 -15
  56. package/dist/internal/controlled-process/supervisor-schema.d.ts +66 -3
  57. package/dist/internal/controlled-process/supervisor-schema.d.ts.map +1 -1
  58. package/dist/internal/controlled-process/supervisor-schema.js +31 -3
  59. package/dist/internal/controlled-process/supervisor-values.d.ts +5 -0
  60. package/dist/internal/controlled-process/supervisor-values.d.ts.map +1 -1
  61. package/dist/internal/controlled-process/supervisor-values.js +5 -0
  62. package/dist/internal/controlled-process/values.d.ts +4 -4
  63. package/dist/internal/controlled-process/values.js +4 -4
  64. package/dist/structured/run-structured.d.ts.map +1 -1
  65. package/dist/structured/run-structured.js +2 -5
  66. package/package.json +3 -11
@@ -2,22 +2,26 @@
2
2
  import { spawn } from "node:child_process";
3
3
  import { randomBytes } from "node:crypto";
4
4
  import { CHILD_PROCESS_TERMINATION_KIND } from "../../core/controlled-process.js";
5
+ import { CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE } from "../../core/error.js";
5
6
  import { readString } from "../../core/json.js";
6
7
  import { closeWritableFd, readableFd, writableFd } from "./child-fd.js";
7
8
  import { readFramedRecords, readRequiredFrame, writeFramedRecord, } from "./framed-transport.js";
9
+ import { ControlledProcessLaunchError, launchFailure, transferWorkerInput, } from "./input-transport.js";
8
10
  import { assertSecureRuntimeDirectory, resolveSupervisorSocketNamespace, SignedRecordStore, supervisorSocketPath, } from "./record-store.js";
9
11
  import { controlledProcessRecordIdSchema, shimProcessIdSchema, supervisorCapabilitySchema, supervisorInstanceIdSchema, supervisorSocketLocatorSchema, } from "./schema.js";
10
12
  import { SupervisorCoordinator } from "./supervisor-coordinator.js";
11
13
  import { createSupervisorPlatformAdapter } from "./supervisor-platform.js";
12
- import { shimRunningSchema, supervisorBootstrapSchema, supervisorHostAckSchema, workerExitSchema, } from "./supervisor-schema.js";
14
+ import { shimLaunchFailedSchema, shimRunningSchema, supervisorBootstrapSchema, supervisorHostAckSchema, workerExitSchema, } from "./supervisor-schema.js";
13
15
  import { SupervisorSocketServer } from "./supervisor-transport.js";
14
16
  import { PROCESS_PROBE_KIND, SHIM_FRAME_KIND, SUPERVISOR_BOOTSTRAP_FRAME_KIND, SUPERVISOR_CONVERGENCE_REASON, SUPERVISOR_REQUEST_KIND, SUPERVISOR_RESPONSE_KIND, } from "./supervisor-values.js";
15
17
  import { encodeProcessStartToken } from "./token.js";
16
18
  import { CONTROLLED_PROCESS_PROTOCOL_VERSION, CONTROLLED_PROCESS_STATE, } from "./values.js";
17
19
  const HOST_BOOTSTRAP_FD = 3;
18
20
  const HOST_IDENTITY_FD = 4;
21
+ const HOST_INPUT_FD = 5;
19
22
  const SHIM_CONTROL_FD = 3;
20
23
  const SHIM_STATUS_FD = 4;
24
+ const SHIM_INPUT_FD = 5;
21
25
  const RANDOM_ID_BYTES = 16;
22
26
  const CAPABILITY_BYTES = 32;
23
27
  const ATTACHED_STDOUT = process.stdout;
@@ -30,6 +34,7 @@ const SUPERVISOR_RUNTIME_DEPENDENCIES = {
30
34
  };
31
35
  export async function runControlledProcessSupervisor(dependencies = SUPERVISOR_RUNTIME_DEPENDENCIES) {
32
36
  const hostInput = readableFd(HOST_BOOTSTRAP_FD);
37
+ const hostData = readableFd(HOST_INPUT_FD);
33
38
  const hostOutput = {
34
39
  stream: writableFd(HOST_IDENTITY_FD),
35
40
  closePromise: null,
@@ -41,6 +46,7 @@ export async function runControlledProcessSupervisor(dependencies = SUPERVISOR_R
41
46
  bootstrap,
42
47
  frames,
43
48
  hostInput,
49
+ hostData,
44
50
  hostOutput,
45
51
  dependencies,
46
52
  });
@@ -49,7 +55,7 @@ export async function runControlledProcessSupervisor(dependencies = SUPERVISOR_R
49
55
  if (hostOutput.closePromise === null) {
50
56
  await writeFramedRecord(hostOutput.stream, {
51
57
  kind: SUPERVISOR_BOOTSTRAP_FRAME_KIND.launchFailed,
52
- reason: error instanceof Error ? error.message : "Supervisor launch failed.",
58
+ failure: launchFailureFromUnknown(error),
53
59
  }).catch(() => undefined);
54
60
  await closeHostOutput(hostOutput).catch(() => undefined);
55
61
  }
@@ -57,6 +63,7 @@ export async function runControlledProcessSupervisor(dependencies = SUPERVISOR_R
57
63
  }
58
64
  }
59
65
  // biome-ignore lint/complexity/noExcessiveLinesPerFunction: The lifecycle sequence is kept contiguous because section 5.103 forbids a new runtime owner.
66
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: The lifecycle sequence keeps failure custody and cleanup flags in one owner.
60
67
  async function runSupervisorSession(input) {
61
68
  const platform = createSupervisorPlatformAdapter();
62
69
  const runtimeDirectory = await assertSecureRuntimeDirectory(input.bootstrap.runtimeDirectory, platform.uid);
@@ -72,6 +79,7 @@ async function runSupervisorSession(input) {
72
79
  let shimPid = null;
73
80
  let shimControl = null;
74
81
  let shimStatus = null;
82
+ let shimInput = null;
75
83
  let shimClosed = null;
76
84
  let lifecycleMonitor = null;
77
85
  let lifecycleMonitorInFlight = null;
@@ -80,7 +88,8 @@ async function runSupervisorSession(input) {
80
88
  let initialPersistCommitted = false;
81
89
  let initialPersistReceipt = null;
82
90
  let identityDelivered = false;
83
- let ready = false;
91
+ let workerReady = false;
92
+ let hostCustodyStarted = false;
84
93
  let rollbackAttempted = false;
85
94
  let ownershipLossObserved = false;
86
95
  let ownershipLossPromise = null;
@@ -133,7 +142,7 @@ async function runSupervisorSession(input) {
133
142
  stopLifecycleMonitor();
134
143
  input.hostInput.destroy();
135
144
  await beforeOwnershipLossDeadline(Promise.all([
136
- settleOwnershipLossHostOutput(input.hostOutput, convergenceDescription(reason, identityDelivered)),
145
+ settleOwnershipLossHostOutput(input.hostOutput, reason, convergenceDescription(reason, identityDelivered)),
137
146
  server.settleAcceptedSessions(),
138
147
  ]).then(() => undefined), deadline, "Supervisor ownership-loss host output or session drain timed out.");
139
148
  const persistReceipt = initialPersistReceipt;
@@ -196,7 +205,7 @@ async function runSupervisorSession(input) {
196
205
  void startOwnershipLossConvergence(SUPERVISOR_CONVERGENCE_REASON.socketOwnershipLost);
197
206
  return;
198
207
  }
199
- if (ready &&
208
+ if (hostCustodyStarted &&
200
209
  hostIdleDeadline !== null &&
201
210
  Date.now() >= hostIdleDeadline) {
202
211
  void startOwnershipLossConvergence(SUPERVISOR_CONVERGENCE_REASON.hostIdleTimeout);
@@ -228,6 +237,8 @@ async function runSupervisorSession(input) {
228
237
  shimClosed = waitForShimClose(shim);
229
238
  shimControl = shim.stdio[SHIM_CONTROL_FD];
230
239
  shimStatus = shim.stdio[SHIM_STATUS_FD];
240
+ shimInput = shim.stdio.at(SHIM_INPUT_FD);
241
+ shimInput.on("error", () => { });
231
242
  const pid = requireShimPid(shim);
232
243
  shimPid = pid;
233
244
  const record = {
@@ -281,7 +292,19 @@ async function runSupervisorSession(input) {
281
292
  return response;
282
293
  };
283
294
  trackLocalCoordinatorOperation(attachOutput(shim, runLocalCoordinatorOperation));
284
- trackLocalCoordinatorOperation(pumpShimStatus(shimStatus, runLocalCoordinatorOperation).catch(() => runLocalCoordinatorOperation(async (current) => current.recordProtocolFailure())));
295
+ let resolveShimReady = () => { };
296
+ let rejectShimReady = (_error) => { };
297
+ const shimReady = new Promise((resolve, reject) => {
298
+ resolveShimReady = resolve;
299
+ rejectShimReady = reject;
300
+ });
301
+ void shimReady.catch(() => undefined);
302
+ trackLocalCoordinatorOperation(pumpShimStatus(shimStatus, runLocalCoordinatorOperation, resolveShimReady).catch(async (error) => {
303
+ rejectShimReady(error);
304
+ if (!(error instanceof ControlledProcessLaunchError)) {
305
+ await runLocalCoordinatorOperation(async (current) => current.recordProtocolFailure());
306
+ }
307
+ }));
285
308
  shim.once("exit", () => {
286
309
  trackLocalCoordinatorOperation(runLocalCoordinatorOperation(async (current) => current.recordShimExit()));
287
310
  });
@@ -291,7 +314,17 @@ async function runSupervisorSession(input) {
291
314
  await writeFramedRecord(shimControl, {
292
315
  kind: SHIM_FRAME_KIND.bootstrap,
293
316
  worker: input.bootstrap.worker,
317
+ input: input.bootstrap.input,
318
+ inputTimeoutMs: input.bootstrap.timing.hostIdleTimeoutMs,
319
+ });
320
+ const inputRelay = transferWorkerInput({
321
+ readable: input.hostData,
322
+ writable: shimInput,
323
+ manifest: input.bootstrap.input,
324
+ stage: "supervisor_to_shim",
325
+ timeoutMs: input.bootstrap.timing.hostIdleTimeoutMs,
294
326
  });
327
+ void inputRelay.catch(() => undefined);
295
328
  await observeOwnership(true);
296
329
  const persistOperation = (input.dependencies.persistInitialRecord ??
297
330
  SUPERVISOR_RUNTIME_DEPENDENCIES.persistInitialRecord)(activeCoordinator);
@@ -336,10 +369,18 @@ async function runSupervisorSession(input) {
336
369
  await runCoordinatorOperation(async (current) => current.acknowledge());
337
370
  coordinatorAckMayHaveCommitted = true;
338
371
  await input.dependencies.writeShimAck(shimControl);
372
+ const [inputRelaySettlement, shimReadySettlement] = await Promise.allSettled([inputRelay, shimReady]);
373
+ if (shimReadySettlement.status === "rejected") {
374
+ throw shimReadySettlement.reason;
375
+ }
376
+ if (inputRelaySettlement.status === "rejected") {
377
+ throw inputRelaySettlement.reason;
378
+ }
339
379
  await observeOwnership(false);
340
380
  coordinatorTickEnabled = true;
341
- ready = true;
342
- recordHostActivity({ kind: "ready" });
381
+ workerReady = true;
382
+ hostCustodyStarted = true;
383
+ recordHostActivity({ kind: "custody_started" });
343
384
  await closeHostOutput(input.hostOutput);
344
385
  input.hostInput.destroy();
345
386
  await released;
@@ -354,17 +395,50 @@ async function runSupervisorSession(input) {
354
395
  }
355
396
  shimControl.destroy();
356
397
  shimStatus.destroy();
398
+ shimInput.destroy();
357
399
  }
358
400
  catch (primaryFailure) {
359
401
  await observeOwnership(false).catch(() => undefined);
360
402
  if (ownershipLossPromise !== null) {
361
403
  await ownershipLossPromise;
362
404
  }
363
- if (ready || rollbackAttempted) {
405
+ if (workerReady || rollbackAttempted) {
364
406
  stopLifecycleMonitor();
365
407
  await settleLifecycleMonitor().catch(() => undefined);
366
408
  throw primaryFailure;
367
409
  }
410
+ if (primaryFailure instanceof ControlledProcessLaunchError &&
411
+ identityDelivered &&
412
+ coordinator !== null &&
413
+ shimControl !== null &&
414
+ shimStatus !== null &&
415
+ shimClosed !== null &&
416
+ input.hostOutput.closePromise === null) {
417
+ input.hostData.destroy();
418
+ hostCustodyStarted = true;
419
+ recordHostActivity({ kind: "custody_started" });
420
+ const failureReported = await writeStructuredLaunchFailure(input.hostOutput, launchFailureFromUnknown(primaryFailure)).then(() => true, () => false);
421
+ if (!failureReported && ownershipLossPromise !== null) {
422
+ await ownershipLossPromise;
423
+ }
424
+ if (failureReported) {
425
+ await released;
426
+ await shimClosed;
427
+ await settleLocalCoordinatorOperations();
428
+ stopLifecycleMonitor();
429
+ await settleLifecycleMonitor();
430
+ const finalization = await (input.dependencies.finalizeSupervisorSocket ??
431
+ SUPERVISOR_RUNTIME_DEPENDENCIES.finalizeSupervisorSocket)(server);
432
+ if (finalization.kind === "ownership_lost") {
433
+ await startOwnershipLossConvergence(SUPERVISOR_CONVERGENCE_REASON.socketOwnershipLost);
434
+ }
435
+ shimControl.destroy();
436
+ shimStatus.destroy();
437
+ shimInput?.destroy();
438
+ input.hostInput.destroy();
439
+ return;
440
+ }
441
+ }
368
442
  try {
369
443
  rollbackAttempted = true;
370
444
  if (coordinator !== null &&
@@ -410,6 +484,7 @@ async function runSupervisorSession(input) {
410
484
  }
411
485
  finally {
412
486
  input.hostInput.destroy();
487
+ input.hostData.destroy();
413
488
  }
414
489
  throw primaryFailure;
415
490
  }
@@ -518,16 +593,20 @@ async function convergeAfterOwnershipLoss(input) {
518
593
  await beforeOwnershipLossDeadline(input.settleLifecycleMonitor(), input.deadline, "Supervisor ownership-loss lifecycle monitor did not settle.");
519
594
  return selfSigkill();
520
595
  }
521
- function settleOwnershipLossHostOutput(hostOutput, reason) {
596
+ function settleOwnershipLossHostOutput(hostOutput, reason, description) {
597
+ if (reason === SUPERVISOR_CONVERGENCE_REASON.hostIdleTimeout) {
598
+ hostOutput.stream.destroy();
599
+ return waitForWritableFinish(hostOutput.stream);
600
+ }
522
601
  return hostOutput.closePromise === null
523
- ? writeLaunchFailure(hostOutput, reason)
602
+ ? writeLaunchFailure(hostOutput, description)
524
603
  : hostOutput.closePromise;
525
604
  }
526
605
  function isHostActivityEvidence(input) {
527
606
  if (input.convergenceStarted) {
528
607
  return false;
529
608
  }
530
- if (input.activity.kind === "ready") {
609
+ if (input.activity.kind === "custody_started") {
531
610
  return true;
532
611
  }
533
612
  const beforeDeadline = input.hostIdleDeadline === null || input.now < input.hostIdleDeadline;
@@ -620,7 +699,7 @@ function spawnShim(bootstrap) {
620
699
  const shim = spawn(process.execPath, [bootstrap.shimEntryPath], {
621
700
  detached: true,
622
701
  env: {},
623
- stdio: ["ignore", "pipe", "pipe", "pipe", "pipe"],
702
+ stdio: ["ignore", "pipe", "pipe", "pipe", "pipe", "pipe"],
624
703
  });
625
704
  shim.once("error", () => { });
626
705
  return shim;
@@ -653,12 +732,19 @@ function attachOutput(shim, runCoordinatorOperation) {
653
732
  pumpOutput(stderr, ATTACHED_STDERR),
654
733
  ]).then(async () => runCoordinatorOperation(async (coordinator) => coordinator.recordOutputClosed()), async () => runCoordinatorOperation(async (coordinator) => coordinator.recordProtocolFailure()));
655
734
  }
656
- async function pumpShimStatus(status, runCoordinatorOperation) {
735
+ async function pumpShimStatus(status, runCoordinatorOperation, onRunning) {
736
+ let running = false;
657
737
  for await (const frame of readFramedRecords(status)) {
658
738
  const kind = readString(frame, "kind");
659
739
  if (kind === SHIM_FRAME_KIND.running) {
660
740
  shimRunningSchema.parse(frame);
661
741
  await runCoordinatorOperation(async (coordinator) => coordinator.running());
742
+ running = true;
743
+ onRunning();
744
+ }
745
+ else if (kind === SHIM_FRAME_KIND.launchFailed) {
746
+ const failure = shimLaunchFailedSchema.parse(frame);
747
+ throw new ControlledProcessLaunchError(failure.failure);
662
748
  }
663
749
  else if (kind === SHIM_FRAME_KIND.workerExit) {
664
750
  const workerExit = workerExitSchema.parse(frame);
@@ -671,6 +757,9 @@ async function pumpShimStatus(status, runCoordinatorOperation) {
671
757
  throw new Error("Shim status frame is invalid.");
672
758
  }
673
759
  }
760
+ if (!running) {
761
+ throw launchFailure(CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE.protocolViolation, "control_protocol", null, null, "Shim status closed before reporting running.");
762
+ }
674
763
  }
675
764
  async function handleRequest(coordinator, kind) {
676
765
  if (kind === SUPERVISOR_REQUEST_KIND.probe) {
@@ -815,10 +904,22 @@ function requireCapturedCoordinator(coordinator) {
815
904
  async function writeLaunchFailure(hostOutput, reason) {
816
905
  await writeFramedRecord(hostOutput.stream, {
817
906
  kind: SUPERVISOR_BOOTSTRAP_FRAME_KIND.launchFailed,
818
- reason,
907
+ failure: launchFailure(CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE.protocolViolation, "control_protocol", null, null, reason).failure,
819
908
  });
820
909
  await closeHostOutput(hostOutput);
821
910
  }
911
+ async function writeStructuredLaunchFailure(hostOutput, failure) {
912
+ await writeFramedRecord(hostOutput.stream, {
913
+ kind: SUPERVISOR_BOOTSTRAP_FRAME_KIND.launchFailed,
914
+ failure,
915
+ });
916
+ await closeHostOutput(hostOutput);
917
+ }
918
+ function launchFailureFromUnknown(error) {
919
+ return error instanceof ControlledProcessLaunchError
920
+ ? error.failure
921
+ : launchFailure(CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE.protocolViolation, "control_protocol", null, null, error instanceof Error ? error.message : "Supervisor launch failed.", error).failure;
922
+ }
822
923
  function closeHostOutput(hostOutput) {
823
924
  hostOutput.closePromise ??= closeWritableFd(hostOutput.stream, HOST_IDENTITY_FD);
824
925
  return hostOutput.closePromise;
@@ -8,8 +8,14 @@ export declare const supervisorBootstrapSchema: z.ZodReadonly<z.ZodObject<{
8
8
  args: z.ZodReadonly<z.ZodArray<z.ZodString>>;
9
9
  cwd: z.ZodString;
10
10
  env: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
11
- stdin: z.ZodNullable<z.ZodString>;
12
11
  }, z.core.$strip>>;
12
+ input: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
13
+ kind: z.ZodLiteral<"none">;
14
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
15
+ kind: z.ZodLiteral<"stream">;
16
+ byteLength: z.ZodNumber;
17
+ sha256: z.ZodString;
18
+ }, z.core.$strip>>], "kind">;
13
19
  timing: z.ZodReadonly<z.ZodObject<{
14
20
  termGraceMs: z.ZodNumber;
15
21
  killProbeTimeoutMs: z.ZodNumber;
@@ -29,7 +35,30 @@ export declare const supervisorIdentityFrameSchema: z.ZodReadonly<z.ZodObject<{
29
35
  }, z.core.$strip>>;
30
36
  export declare const supervisorLaunchFailedFrameSchema: z.ZodReadonly<z.ZodObject<{
31
37
  kind: z.ZodLiteral<"launch_failed">;
32
- reason: z.ZodString;
38
+ failure: z.ZodReadonly<z.ZodObject<{
39
+ code: z.ZodEnum<{
40
+ readonly inputEarlyEof: "input_early_eof";
41
+ readonly inputOverrun: "input_overrun";
42
+ readonly inputDigestMismatch: "input_digest_mismatch";
43
+ readonly inputWriteFailed: "input_write_failed";
44
+ readonly inputTransferTimeout: "input_transfer_timeout";
45
+ readonly workerExited: "worker_exited_during_launch";
46
+ readonly protocolViolation: "protocol_violation";
47
+ }>;
48
+ retryability: z.ZodEnum<{
49
+ readonly permanent: "permanent";
50
+ readonly transient: "transient";
51
+ }>;
52
+ stage: z.ZodEnum<{
53
+ host_to_supervisor: "host_to_supervisor";
54
+ supervisor_to_shim: "supervisor_to_shim";
55
+ shim_to_worker: "shim_to_worker";
56
+ control_protocol: "control_protocol";
57
+ }>;
58
+ expectedBytes: z.ZodNullable<z.ZodNumber>;
59
+ actualBytes: z.ZodNullable<z.ZodNumber>;
60
+ message: z.ZodString;
61
+ }, z.core.$strip>>;
33
62
  }, z.core.$strip>>;
34
63
  export declare const shimBootstrapSchema: z.ZodReadonly<z.ZodObject<{
35
64
  kind: z.ZodLiteral<"shim_bootstrap">;
@@ -38,8 +67,15 @@ export declare const shimBootstrapSchema: z.ZodReadonly<z.ZodObject<{
38
67
  args: z.ZodReadonly<z.ZodArray<z.ZodString>>;
39
68
  cwd: z.ZodString;
40
69
  env: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
41
- stdin: z.ZodNullable<z.ZodString>;
42
70
  }, z.core.$strip>>;
71
+ input: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
72
+ kind: z.ZodLiteral<"none">;
73
+ }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
74
+ kind: z.ZodLiteral<"stream">;
75
+ byteLength: z.ZodNumber;
76
+ sha256: z.ZodString;
77
+ }, z.core.$strip>>], "kind">;
78
+ inputTimeoutMs: z.ZodNumber;
43
79
  }, z.core.$strip>>;
44
80
  export declare const shimAckSchema: z.ZodReadonly<z.ZodObject<{
45
81
  kind: z.ZodLiteral<"shim_ack">;
@@ -47,6 +83,33 @@ export declare const shimAckSchema: z.ZodReadonly<z.ZodObject<{
47
83
  export declare const shimRunningSchema: z.ZodReadonly<z.ZodObject<{
48
84
  kind: z.ZodLiteral<"shim_running">;
49
85
  }, z.core.$strip>>;
86
+ export declare const shimLaunchFailedSchema: z.ZodReadonly<z.ZodObject<{
87
+ kind: z.ZodLiteral<"shim_launch_failed">;
88
+ failure: z.ZodReadonly<z.ZodObject<{
89
+ code: z.ZodEnum<{
90
+ readonly inputEarlyEof: "input_early_eof";
91
+ readonly inputOverrun: "input_overrun";
92
+ readonly inputDigestMismatch: "input_digest_mismatch";
93
+ readonly inputWriteFailed: "input_write_failed";
94
+ readonly inputTransferTimeout: "input_transfer_timeout";
95
+ readonly workerExited: "worker_exited_during_launch";
96
+ readonly protocolViolation: "protocol_violation";
97
+ }>;
98
+ retryability: z.ZodEnum<{
99
+ readonly permanent: "permanent";
100
+ readonly transient: "transient";
101
+ }>;
102
+ stage: z.ZodEnum<{
103
+ host_to_supervisor: "host_to_supervisor";
104
+ supervisor_to_shim: "supervisor_to_shim";
105
+ shim_to_worker: "shim_to_worker";
106
+ control_protocol: "control_protocol";
107
+ }>;
108
+ expectedBytes: z.ZodNullable<z.ZodNumber>;
109
+ actualBytes: z.ZodNullable<z.ZodNumber>;
110
+ message: z.ZodString;
111
+ }, z.core.$strip>>;
112
+ }, z.core.$strip>>;
50
113
  export declare const workerExitSchema: z.ZodReadonly<z.ZodObject<{
51
114
  kind: z.ZodLiteral<"worker_exit">;
52
115
  code: z.ZodNullable<z.ZodNumber>;
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor-schema.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/supervisor-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoDxB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;kBAMK,CAAC;AAE5C,eAAO,MAAM,uBAAuB;;kBAEK,CAAC;AAE1C,eAAO,MAAM,6BAA6B;;;;;;kBAGK,CAAC;AAEhD,eAAO,MAAM,iCAAiC;;;kBAGK,CAAC;AAEpD,eAAO,MAAM,mBAAmB;;;;;;;;;kBAGK,CAAC;AAEtC,eAAO,MAAM,aAAa;;kBAEK,CAAC;AAEhC,eAAO,MAAM,iBAAiB;;kBAEK,CAAC;AAEpC,eAAO,MAAM,gBAAgB;;;;kBAIK,CAAC;AAEnC,eAAO,MAAM,uBAAuB;;;;;;4BAIK,CAAC;AAE1C,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAaK,CAAC"}
1
+ {"version":3,"file":"supervisor-schema.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/supervisor-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8ExB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;kBAOK,CAAC;AAE5C,eAAO,MAAM,uBAAuB;;kBAEK,CAAC;AAE1C,eAAO,MAAM,6BAA6B;;;;;;kBAGK,CAAC;AAEhD,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;kBAGK,CAAC;AAEpD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;kBAKK,CAAC;AAEtC,eAAO,MAAM,aAAa;;kBAEK,CAAC;AAEhC,eAAO,MAAM,iBAAiB;;kBAEK,CAAC;AAEpC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;kBAGK,CAAC;AAEzC,eAAO,MAAM,gBAAgB;;;;kBAIK,CAAC;AAEnC,eAAO,MAAM,uBAAuB;;;;;;4BAIK,CAAC;AAE1C,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAaK,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { strictReadonlyObject } from "@alpacakit/core";
2
2
  import { z } from "zod";
3
+ import { CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE, CONTROLLED_PROCESS_LAUNCH_FAILURE_RETRYABILITY, } from "../../core/error.js";
3
4
  import { childProcessTerminationResultSchema, controlledProcessIdentitySchema, } from "./schema.js";
4
- import { SHIM_FRAME_KIND, SUPERVISOR_BOOTSTRAP_FRAME_KIND, SUPERVISOR_REQUEST_KIND, SUPERVISOR_RESPONSE_KIND, } from "./supervisor-values.js";
5
+ import { SHIM_FRAME_KIND, SUPERVISOR_BOOTSTRAP_FRAME_KIND, SUPERVISOR_REQUEST_KIND, SUPERVISOR_RESPONSE_KIND, WORKER_INPUT_KIND, } from "./supervisor-values.js";
5
6
  const nonBlankStringSchema = z
6
7
  .string()
7
8
  .min(1)
@@ -12,7 +13,27 @@ const workerOptionsSchema = strictReadonlyObject({
12
13
  args: z.array(z.string()).readonly(),
13
14
  cwd: nonBlankStringSchema,
14
15
  env: z.record(z.string(), z.string()).readonly(),
15
- stdin: z.string().nullable(),
16
+ });
17
+ const workerInputManifestSchema = z.discriminatedUnion("kind", [
18
+ strictReadonlyObject({ kind: z.literal(WORKER_INPUT_KIND.none) }),
19
+ strictReadonlyObject({
20
+ kind: z.literal(WORKER_INPUT_KIND.stream),
21
+ byteLength: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
22
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u),
23
+ }),
24
+ ]);
25
+ const launchFailureSchema = strictReadonlyObject({
26
+ code: z.enum(CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE),
27
+ retryability: z.enum(CONTROLLED_PROCESS_LAUNCH_FAILURE_RETRYABILITY),
28
+ stage: z.enum([
29
+ "host_to_supervisor",
30
+ "supervisor_to_shim",
31
+ "shim_to_worker",
32
+ "control_protocol",
33
+ ]),
34
+ expectedBytes: z.number().int().nonnegative().nullable(),
35
+ actualBytes: z.number().int().nonnegative().nullable(),
36
+ message: nonBlankStringSchema,
16
37
  });
17
38
  // A worker that is still running is re-probed every `probeIntervalMs`, and an
18
39
  // accepted request is the only thing that resets the idle deadline. An idle
@@ -33,6 +54,7 @@ export const supervisorBootstrapSchema = strictReadonlyObject({
33
54
  runtimeDirectory: nonBlankStringSchema,
34
55
  shimEntryPath: nonBlankStringSchema,
35
56
  worker: workerOptionsSchema,
57
+ input: workerInputManifestSchema,
36
58
  timing: timingOptionsSchema,
37
59
  });
38
60
  export const supervisorHostAckSchema = strictReadonlyObject({
@@ -44,11 +66,13 @@ export const supervisorIdentityFrameSchema = strictReadonlyObject({
44
66
  });
45
67
  export const supervisorLaunchFailedFrameSchema = strictReadonlyObject({
46
68
  kind: z.literal(SUPERVISOR_BOOTSTRAP_FRAME_KIND.launchFailed),
47
- reason: z.string().min(1),
69
+ failure: launchFailureSchema,
48
70
  });
49
71
  export const shimBootstrapSchema = strictReadonlyObject({
50
72
  kind: z.literal(SHIM_FRAME_KIND.bootstrap),
51
73
  worker: workerOptionsSchema,
74
+ input: workerInputManifestSchema,
75
+ inputTimeoutMs: durationSchema,
52
76
  });
53
77
  export const shimAckSchema = strictReadonlyObject({
54
78
  kind: z.literal(SHIM_FRAME_KIND.ack),
@@ -56,6 +80,10 @@ export const shimAckSchema = strictReadonlyObject({
56
80
  export const shimRunningSchema = strictReadonlyObject({
57
81
  kind: z.literal(SHIM_FRAME_KIND.running),
58
82
  });
83
+ export const shimLaunchFailedSchema = strictReadonlyObject({
84
+ kind: z.literal(SHIM_FRAME_KIND.launchFailed),
85
+ failure: launchFailureSchema,
86
+ });
59
87
  export const workerExitSchema = strictReadonlyObject({
60
88
  kind: z.literal(SHIM_FRAME_KIND.workerExit),
61
89
  code: z.number().int().nullable(),
@@ -8,8 +8,13 @@ export declare const SHIM_FRAME_KIND: {
8
8
  readonly bootstrap: "shim_bootstrap";
9
9
  readonly ack: "shim_ack";
10
10
  readonly running: "shim_running";
11
+ readonly launchFailed: "shim_launch_failed";
11
12
  readonly workerExit: "worker_exit";
12
13
  };
14
+ export declare const WORKER_INPUT_KIND: {
15
+ readonly none: "none";
16
+ readonly stream: "stream";
17
+ };
13
18
  export declare const SUPERVISOR_REQUEST_KIND: {
14
19
  readonly probe: "probe";
15
20
  readonly terminate: "terminate";
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor-values.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/supervisor-values.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B;;;;;CAKlC,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC;AAEX,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC;AAEX,eAAO,MAAM,wBAAwB;;;;CAI3B,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;CAGhC,CAAC;AAEX,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC"}
1
+ {"version":3,"file":"supervisor-values.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/supervisor-values.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B;;;;;CAKlC,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;;CAMlB,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC;AAEX,eAAO,MAAM,wBAAwB;;;;CAI3B,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAC;AAEX,eAAO,MAAM,6BAA6B;;;CAGhC,CAAC;AAEX,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC"}
@@ -8,8 +8,13 @@ export const SHIM_FRAME_KIND = {
8
8
  bootstrap: "shim_bootstrap",
9
9
  ack: "shim_ack",
10
10
  running: "shim_running",
11
+ launchFailed: "shim_launch_failed",
11
12
  workerExit: "worker_exit",
12
13
  };
14
+ export const WORKER_INPUT_KIND = {
15
+ none: "none",
16
+ stream: "stream",
17
+ };
13
18
  export const SUPERVISOR_REQUEST_KIND = {
14
19
  probe: "probe",
15
20
  terminate: "terminate",
@@ -1,4 +1,4 @@
1
- export declare const CONTROLLED_PROCESS_PROTOCOL_VERSION: "alpacakit-supervisor-v1";
1
+ export declare const CONTROLLED_PROCESS_PROTOCOL_VERSION: "alpacakit-supervisor-v2";
2
2
  export declare const CONTROLLED_PROCESS_PLATFORM: {
3
3
  readonly darwin: "darwin";
4
4
  readonly linux: "linux";
@@ -32,8 +32,8 @@ export declare const SUPERVISOR_AUTHENTICATION_REJECTION_REASON: {
32
32
  readonly replay: "replay";
33
33
  };
34
34
  export declare const SUPERVISOR_MAC_DOMAIN: {
35
- readonly record: "alpacakit-supervisor-v1/record/v1";
36
- readonly supervisorChallenge: "alpacakit-supervisor-v1/auth/supervisor/v1";
37
- readonly clientProof: "alpacakit-supervisor-v1/auth/client/v1";
35
+ readonly record: "alpacakit-supervisor-v2/record/v1";
36
+ readonly supervisorChallenge: "alpacakit-supervisor-v2/auth/supervisor/v1";
37
+ readonly clientProof: "alpacakit-supervisor-v2/auth/client/v1";
38
38
  };
39
39
  //# sourceMappingURL=values.d.ts.map
@@ -1,4 +1,4 @@
1
- export const CONTROLLED_PROCESS_PROTOCOL_VERSION = "alpacakit-supervisor-v1";
1
+ export const CONTROLLED_PROCESS_PROTOCOL_VERSION = "alpacakit-supervisor-v2";
2
2
  export const CONTROLLED_PROCESS_PLATFORM = {
3
3
  darwin: "darwin",
4
4
  linux: "linux",
@@ -32,7 +32,7 @@ export const SUPERVISOR_AUTHENTICATION_REJECTION_REASON = {
32
32
  replay: "replay",
33
33
  };
34
34
  export const SUPERVISOR_MAC_DOMAIN = {
35
- record: "alpacakit-supervisor-v1/record/v1",
36
- supervisorChallenge: "alpacakit-supervisor-v1/auth/supervisor/v1",
37
- clientProof: "alpacakit-supervisor-v1/auth/client/v1",
35
+ record: "alpacakit-supervisor-v2/record/v1",
36
+ supervisorChallenge: "alpacakit-supervisor-v2/auth/supervisor/v1",
37
+ clientProof: "alpacakit-supervisor-v2/auth/client/v1",
38
38
  };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zB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,SAAS,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,4BAA4B,CAAC,CAAC,IAAI;IAC5C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,OAAO,EAChD,OAAO,EAAE,UAAU,GAAG,oBAAoB,CAAC,CAAC,CAAC,GAC5C,OAAO,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAEpC;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,4BAA4B,CAAC,CAAC,CAAC,CAGjC;AAmJD,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACjC,gBAAgB,CAAC,CAAC,CAAC,CAMrB"}
@@ -34,16 +34,13 @@ function defaultRepairPrompt(ctx) {
34
34
  ? "(no output block was found)"
35
35
  : ctx.previousBlock.slice(0, PREVIOUS_BLOCK_TRUNCATE_CHARS);
36
36
  return [
37
- ctx.basePrompt,
38
- "",
39
- ctx.contractInstruction,
40
- "",
41
37
  "Your previous reply did not satisfy the contract.",
42
38
  "Previous block:",
43
39
  previous,
44
40
  "Problems:",
45
41
  ...issueLines,
46
- "Reply again with only the corrected JSON between the markers.",
42
+ `Return the corrected JSON in the original required shape between ${ctx.markers.start} and ${ctx.markers.end}.`,
43
+ "Do not repeat the contract or add commentary.",
47
44
  ].join("\n");
48
45
  }
49
46
  function toIssuePath(path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpacakit/agents",
3
- "version": "0.1.0-beta.35",
3
+ "version": "0.1.0-beta.37",
4
4
  "description": "Run AI coding agents programmatically: execute, stream, classify failures, fail over.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,10 +25,6 @@
25
25
  "types": "./dist/codex/index.d.ts",
26
26
  "import": "./dist/codex/index.js"
27
27
  },
28
- "./keyring": {
29
- "types": "./dist/keyring/index.d.ts",
30
- "import": "./dist/keyring/index.js"
31
- },
32
28
  "./testing": {
33
29
  "types": "./dist/testing/index.d.ts",
34
30
  "import": "./dist/testing/index.js"
@@ -49,22 +45,18 @@
49
45
  },
50
46
  "dependencies": {
51
47
  "zod": "^4.3.6",
52
- "@alpacakit/core": "0.1.0-beta.35"
48
+ "@alpacakit/core": "0.1.0-beta.37"
53
49
  },
54
50
  "devDependencies": {
55
51
  "typescript": "^5.9.3",
56
52
  "vitest": "^4.0.18"
57
53
  },
58
54
  "peerDependencies": {
59
- "@earendil-works/pi-coding-agent": "0.75.5",
60
- "@napi-rs/keyring": "^1.3.0"
55
+ "@earendil-works/pi-coding-agent": "0.75.5"
61
56
  },
62
57
  "peerDependenciesMeta": {
63
58
  "@earendil-works/pi-coding-agent": {
64
59
  "optional": true
65
- },
66
- "@napi-rs/keyring": {
67
- "optional": true
68
60
  }
69
61
  },
70
62
  "scripts": {