stitchkit 0.110.4 → 0.110.6

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 (44) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/agent-runtime/branch-observations.d.ts +16 -16
  3. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  4. package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
  5. package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -4
  6. package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -4
  7. package/dist/entrypoints/agent-runtime/testing.js +4 -4
  8. package/dist/entrypoints/agent-runtime.js +4 -4
  9. package/dist/entrypoints/cli.js +1 -1
  10. package/dist/entrypoints/process.js +1 -1
  11. package/dist/entrypoints/server.d.ts +1 -0
  12. package/dist/entrypoints/server.d.ts.map +1 -1
  13. package/dist/entrypoints/server.js +55 -3
  14. package/dist/entrypoints/tools.js +1 -1
  15. package/dist/{index-mpg1t7nv.js → index-0z3kfphz.js} +1 -1
  16. package/dist/{index-5pbtbce0.js → index-7c957abz.js} +1 -1
  17. package/dist/{index-e1sjcjfy.js → index-7r4knwf8.js} +94 -23
  18. package/dist/{index-bm180f2d.js → index-ey15wx6j.js} +1 -1
  19. package/dist/{index-9ket8wzx.js → index-mnk5vgdr.js} +1 -1
  20. package/dist/{index-2tazbwhv.js → index-n7hrpngg.js} +151 -92
  21. package/dist/process/group-diagnostics.d.ts +20 -0
  22. package/dist/process/group-diagnostics.d.ts.map +1 -0
  23. package/dist/process/group-settlement.d.ts +1 -1
  24. package/dist/process/group-settlement.d.ts.map +1 -1
  25. package/dist/process/group.d.ts.map +1 -1
  26. package/dist/server/bun.d.ts +9 -0
  27. package/dist/server/bun.d.ts.map +1 -1
  28. package/dist/server/proxy-origin.d.ts +12 -0
  29. package/dist/server/proxy-origin.d.ts.map +1 -0
  30. package/dist/tools/cli/args-json.d.ts +12 -0
  31. package/dist/tools/cli/args-json.d.ts.map +1 -0
  32. package/dist/tools/cli/args-tokens.d.ts +27 -0
  33. package/dist/tools/cli/args-tokens.d.ts.map +1 -0
  34. package/dist/tools/cli/args.d.ts +4 -0
  35. package/dist/tools/cli/args.d.ts.map +1 -1
  36. package/dist/tools/cli/help.d.ts.map +1 -1
  37. package/llms/cli.2.txt +7 -2
  38. package/llms/cli.txt +17 -0
  39. package/llms/server.2.txt +131 -0
  40. package/llms/server.5.txt +1 -0
  41. package/llms/server.txt +55 -131
  42. package/llms-full.txt +80 -2
  43. package/llms.txt +2 -2
  44. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -15,6 +15,23 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.110.6] - 2026-10-15
19
+
20
+ ### Added
21
+
22
+ - `stitchkit/server`: `createServer({ proxyOrigin: { trustedPeer } })` restores the external HTTP/HTTPS scheme from a single trusted ingress before fetch composition and routing. It validates the real TCP peer and one `X-Forwarded-Proto`, rejects competing URL headers, preserves wire Host/ports and native cancellation, peer lookup and WebSocket upgrade. `trustProxy` remains client-IP-only. The server surface grows by one configuration type, `ProxyOriginConfig`, owned by this entrypoint so the trust decision is explicit and independently testable (I8, I9, I12).
23
+
24
+ ### Fixed
25
+
26
+ - `stitchkit/process`: bounded process-group settlement observations remain readable through nested cleanup errors in Node CI, including up to 16 actual states, the group id, sample count and elapsed time. Observation failures retain their original cause. Cleanup deadlines and the definition of a live process are unchanged; these diagnostics do not claim to repair a historical native termination failure.
27
+ - `stitchkit/process`: stopping a process group repeats `SIGKILL` for members still confirmed alive within the original cleanup deadline. Fresh kernel absence ends further signals; dead-only, invalid and failed process observations never trigger a blind re-signal.
28
+
29
+ ## [0.110.5] - 2026-10-15
30
+
31
+ ### Added
32
+
33
+ - `stitchkit/cli`: `--field:=JSON` assigns a whole JSON value, including explicit `null` for nullable fields, through the existing schema-driven parser. Ordinary `--field null` remains the string `"null"`; optional omission stays absent. Native/discovered help advertises the syntax; malformed JSON and conflicting assignments refuse before dispatch.
34
+
18
35
  ## [0.110.4] - 2026-10-15
19
36
 
20
37
  ### Fixed
@@ -25,20 +25,8 @@ export declare function branchObservation(ids: BranchIdentities, kind: string, r
25
25
  delayMs?: number | undefined;
26
26
  reason?: string | undefined;
27
27
  } | {
28
- effectName: string;
29
- phase: "intent";
30
- runId: string;
31
- id?: string | undefined;
32
- } | {
33
- effectName: string;
34
- phase: "accepted";
28
+ stepName: string;
35
29
  encoded: string;
36
- via: "reconcile" | "run";
37
- runId: string;
38
- id?: string | undefined;
39
- } | {
40
- effectName: string;
41
- phase: "uncertain";
42
30
  runId: string;
43
31
  id?: string | undefined;
44
32
  } | {
@@ -53,15 +41,27 @@ export declare function branchObservation(ids: BranchIdentities, kind: string, r
53
41
  id: string;
54
42
  runId: string;
55
43
  } | {
56
- stepName: string;
44
+ event: string;
45
+ id: string;
57
46
  encoded: string;
58
47
  runId: string;
48
+ } | {
49
+ effectName: string;
50
+ phase: "intent";
51
+ runId: string;
59
52
  id?: string | undefined;
60
53
  } | {
61
- event: string;
62
- id: string;
54
+ effectName: string;
55
+ phase: "accepted";
63
56
  encoded: string;
57
+ via: "reconcile" | "run";
58
+ runId: string;
59
+ id?: string | undefined;
60
+ } | {
61
+ effectName: string;
62
+ phase: "uncertain";
64
63
  runId: string;
64
+ id?: string | undefined;
65
65
  } | {
66
66
  bytes: number;
67
67
  sha256?: string | undefined;
@@ -6,10 +6,10 @@ import {
6
6
  AgentCodingToolAuthorizationSchema2,
7
7
  AgentCodingToolPathAuthorizationSchema2,
8
8
  createAgentCodingTools2
9
- } from "../../index-bm180f2d.js";
9
+ } from "../../index-ey15wx6j.js";
10
10
  import"../../index-2kbysk9s.js";
11
11
  import"../../index-84bf5spd.js";
12
- import"../../index-e1sjcjfy.js";
12
+ import"../../index-7r4knwf8.js";
13
13
  import"../../index-zrtrjkbf.js";
14
14
  import"../../index-636mggad.js";
15
15
  export {
@@ -3,7 +3,7 @@ import {
3
3
  missingSandboxRestrictions2,
4
4
  codingRefusal,
5
5
  createAgentCodingTools2
6
- } from "../../index-bm180f2d.js";
6
+ } from "../../index-ey15wx6j.js";
7
7
  import"../../index-ct75c3at.js";
8
8
  import"../../index-q6crhe1n.js";
9
9
  import"../../index-fynr93w4.js";
@@ -17,7 +17,7 @@ import {
17
17
  nativeCommandOwner,
18
18
  terminateOwnedGroup,
19
19
  startNativeCommand
20
- } from "../../index-e1sjcjfy.js";
20
+ } from "../../index-7r4knwf8.js";
21
21
  import"../../index-zrtrjkbf.js";
22
22
  import {
23
23
  MAX_TIMER_MS
@@ -1,20 +1,20 @@
1
1
  import"../../../index-jna0ejsa.js";
2
- import"../../../index-mpg1t7nv.js";
2
+ import"../../../index-0z3kfphz.js";
3
3
  import"../../../index-8kzct1d6.js";
4
4
  import {
5
5
  initializeAgentRuntimeSqlite2,
6
6
  createSqliteAgentRuntimeStore2
7
- } from "../../../index-5pbtbce0.js";
7
+ } from "../../../index-7c957abz.js";
8
8
  import"../../../index-kqnd6a85.js";
9
9
  import"../../../index-5w6t91ze.js";
10
- import"../../../index-bm180f2d.js";
10
+ import"../../../index-ey15wx6j.js";
11
11
  import"../../../index-ct75c3at.js";
12
12
  import"../../../index-q6crhe1n.js";
13
13
  import"../../../index-fynr93w4.js";
14
14
  import"../../../index-2kbysk9s.js";
15
15
  import"../../../index-84bf5spd.js";
16
+ import"../../../index-7r4knwf8.js";
16
17
  import"../../../index-snef22zr.js";
17
- import"../../../index-e1sjcjfy.js";
18
18
  import"../../../index-zrtrjkbf.js";
19
19
  import"../../../index-636mggad.js";
20
20
 
@@ -1,20 +1,20 @@
1
1
  import"../../../index-jna0ejsa.js";
2
- import"../../../index-mpg1t7nv.js";
2
+ import"../../../index-0z3kfphz.js";
3
3
  import"../../../index-8kzct1d6.js";
4
4
  import {
5
5
  initializeAgentRuntimeSqlite2,
6
6
  createSqliteAgentRuntimeStore2
7
- } from "../../../index-5pbtbce0.js";
7
+ } from "../../../index-7c957abz.js";
8
8
  import"../../../index-kqnd6a85.js";
9
9
  import"../../../index-5w6t91ze.js";
10
- import"../../../index-bm180f2d.js";
10
+ import"../../../index-ey15wx6j.js";
11
11
  import"../../../index-ct75c3at.js";
12
12
  import"../../../index-q6crhe1n.js";
13
13
  import"../../../index-fynr93w4.js";
14
14
  import"../../../index-2kbysk9s.js";
15
15
  import"../../../index-84bf5spd.js";
16
+ import"../../../index-7r4knwf8.js";
16
17
  import"../../../index-snef22zr.js";
17
- import"../../../index-e1sjcjfy.js";
18
18
  import"../../../index-zrtrjkbf.js";
19
19
  import"../../../index-636mggad.js";
20
20
 
@@ -10,18 +10,18 @@ import {
10
10
  advanceToolChronology
11
11
  } from "../../index-jna0ejsa.js";
12
12
  import"../../index-5w6t91ze.js";
13
- import"../../index-bm180f2d.js";
14
- import"../../index-mpg1t7nv.js";
13
+ import"../../index-ey15wx6j.js";
14
+ import"../../index-0z3kfphz.js";
15
15
  import"../../index-ct75c3at.js";
16
16
  import"../../index-q6crhe1n.js";
17
17
  import"../../index-fynr93w4.js";
18
18
  import"../../index-2kbysk9s.js";
19
19
  import"../../index-84bf5spd.js";
20
+ import"../../index-7r4knwf8.js";
20
21
  import"../../index-snef22zr.js";
21
22
  import {
22
23
  createMemoryAgentRuntimeStore2
23
- } from "../../index-9ket8wzx.js";
24
- import"../../index-e1sjcjfy.js";
24
+ } from "../../index-mnk5vgdr.js";
25
25
  import"../../index-zrtrjkbf.js";
26
26
  import {
27
27
  assertPositiveSafeInteger
@@ -5,7 +5,7 @@ import {
5
5
  missingSandboxRestrictions2,
6
6
  recordAgentSandboxProbe2,
7
7
  refuseUnknownSpillReference
8
- } from "../index-bm180f2d.js";
8
+ } from "../index-ey15wx6j.js";
9
9
  import {
10
10
  AgentRecordIdSchema2,
11
11
  AgentRecordVersionSchema2,
@@ -58,7 +58,7 @@ import {
58
58
  AgentHistoryMutationSchema2,
59
59
  ACTIVE_AGENT_RUN_STATES2,
60
60
  createAgentRuntimeStore2
61
- } from "../index-mpg1t7nv.js";
61
+ } from "../index-0z3kfphz.js";
62
62
  import {
63
63
  AgentStoreEventKindSchema2,
64
64
  AgentStoreEventEnvelopeSchema2,
@@ -188,13 +188,13 @@ import {
188
188
  import"../index-56yx8dxp.js";
189
189
  import"../index-2kbysk9s.js";
190
190
  import"../index-84bf5spd.js";
191
+ import"../index-7r4knwf8.js";
191
192
  import {
192
193
  createMemoryAgentRuntimeStore2
193
- } from "../index-9ket8wzx.js";
194
+ } from "../index-mnk5vgdr.js";
194
195
  import {
195
196
  createAgentRuntimeEventSink2
196
197
  } from "../index-616xh7f2.js";
197
- import"../index-e1sjcjfy.js";
198
198
  import"../index-zrtrjkbf.js";
199
199
  import {
200
200
  MAX_TIMER_MS
@@ -16,7 +16,7 @@ import {
16
16
  renderCliView2,
17
17
  pollUntilDone2,
18
18
  createCli2
19
- } from "../index-2tazbwhv.js";
19
+ } from "../index-n7hrpngg.js";
20
20
  import"../index-fynr93w4.js";
21
21
  import"../index-ct75c3at.js";
22
22
  import"../index-q6crhe1n.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "../index-84bf5spd.js";
10
10
  import {
11
11
  startNativeCommand
12
- } from "../index-e1sjcjfy.js";
12
+ } from "../index-7r4knwf8.js";
13
13
  // src/process/command.ts
14
14
  function runNativeCommand(input) {
15
15
  return startNativeCommand(input).result;
@@ -23,6 +23,7 @@ export { createTrustFence, isLoopbackAddress, type TrustFence, type TrustFenceCo
23
23
  export { type MultipartLifecycle, type MultipartResult, parseMultipart, } from '../server/multipart.js';
24
24
  export { generateOpenApiDocument, type OpenApiConfig, type OpenApiDocument, type OpenApiInfo, type OpenApiServer, openApiRoute, } from '../server/openapi.js';
25
25
  export { bindProcessSignals, type ProcessSignalName, type ProcessSignalsBinding, type ProcessSignalsErrorPhase, type ProcessSignalsOptions, type ShutdownTarget, type SignalSource, } from '../server/process-signals.js';
26
+ export type { ProxyOriginConfig } from '../server/proxy-origin.js';
26
27
  export { createRateLimiter, type RateLimitConfig } from '../server/rate-limit.js';
27
28
  export { errorResponse, parseBody, respondJson } from '../server/raw.js';
28
29
  export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from '../server/realtime.js';
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/entrypoints/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EACL,KAAK,eAAe,EACpB,SAAS,EACT,eAAe,EACf,aAAa,EACb,UAAU,EACV,eAAe,EACf,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EACL,KAAK,oBAAoB,EACzB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB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B,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,YAAY,CAAC"}
@@ -335,6 +335,53 @@ function bindSocketRegistry(server, options) {
335
335
  }
336
336
  // src/server/bun.ts
337
337
  import { chmodSync, statSync, unlinkSync } from "node:fs";
338
+
339
+ // src/server/proxy-origin.ts
340
+ import { z } from "zod";
341
+ var ProtocolSchema = z.enum(["http", "https"]);
342
+ var AuthoritySchema = z.string().min(1).max(1024).regex(/^[^\s/\\?#@,;]+$/);
343
+ var conflictingHeaders = ["forwarded", "x-forwarded-host", "x-forwarded-port"];
344
+ function createProxyOrigin(policy) {
345
+ const originals = new WeakMap;
346
+ const original = (request) => originals.get(request) ?? request;
347
+ return {
348
+ bind(server) {
349
+ const requestIP = server.requestIP.bind(server);
350
+ const timeout = server.timeout.bind(server);
351
+ const upgrade = server.upgrade.bind(server);
352
+ server.requestIP = (request) => requestIP(original(request));
353
+ server.timeout = (request, seconds) => timeout(original(request), seconds);
354
+ server.upgrade = (request, options) => upgrade(original(request), options);
355
+ },
356
+ normalize(request, server) {
357
+ const peer = server.requestIP(request)?.address;
358
+ if (!peer || !policy.trustedPeer(peer))
359
+ return request;
360
+ const protocol = ProtocolSchema.safeParse(request.headers.get("x-forwarded-proto"));
361
+ const authority = AuthoritySchema.safeParse(request.headers.get("host"));
362
+ if (!protocol.success || !authority.success || conflictingHeaders.some((name) => request.headers.has(name))) {
363
+ return new Response("Invalid proxy origin", { status: 400 });
364
+ }
365
+ let origin;
366
+ try {
367
+ origin = new URL(`${protocol.data}://${authority.data}`);
368
+ } catch {
369
+ return new Response("Invalid proxy origin", { status: 400 });
370
+ }
371
+ const url = new URL(request.url);
372
+ url.protocol = origin.protocol;
373
+ url.host = origin.host;
374
+ url.port = origin.port;
375
+ if (url.href === request.url)
376
+ return request;
377
+ const normalized = new Request(url, request);
378
+ originals.set(normalized, request);
379
+ return normalized;
380
+ }
381
+ };
382
+ }
383
+
384
+ // src/server/bun.ts
338
385
  function reclaimStaleUnixSocket(path) {
339
386
  const stats = statSync(path, { throwIfNoEntry: false });
340
387
  if (stats === undefined)
@@ -492,17 +539,21 @@ function createServer(config) {
492
539
  const handler = createHandler2(config);
493
540
  const consumerFetch = config.wrapFetch ? config.wrapFetch(handler) : handler;
494
541
  const admittedFetch = lifecycle.wrapFetch(consumerFetch);
542
+ const proxyOrigin = config.proxyOrigin && createProxyOrigin(config.proxyOrigin);
495
543
  const fetch = async (request, server) => {
544
+ const normalized = proxyOrigin && server ? proxyOrigin.normalize(request, server) : request;
545
+ if (normalized instanceof Response)
546
+ return normalized;
496
547
  if (socket && socketRoutePrefix) {
497
- const pathname = new URL(request.url).pathname;
548
+ const pathname = new URL(normalized.url).pathname;
498
549
  if (pathname.startsWith(socketRoutePrefix)) {
499
- return await socket.route.handler(request, {
550
+ return await socket.route.handler(normalized, {
500
551
  params: { socketPath: pathname.slice(socketRoutePrefix.length) },
501
552
  server
502
553
  });
503
554
  }
504
555
  }
505
- return admittedFetch(request, server);
556
+ return admittedFetch(normalized, server);
506
557
  };
507
558
  if (unixPath !== undefined) {
508
559
  reclaimStaleUnixSocket(unixPath);
@@ -538,6 +589,7 @@ function createServer(config) {
538
589
  });
539
590
  }
540
591
  const server = runtime;
592
+ proxyOrigin?.bind(server);
541
593
  return {
542
594
  url: server.url.toString().replace(/\/$/, ""),
543
595
  port: server.port ?? (unixPath !== undefined ? 0 : port),
@@ -74,7 +74,7 @@ import {
74
74
  WaitTimeoutError,
75
75
  runWaitOperation,
76
76
  createCli2
77
- } from "../index-2tazbwhv.js";
77
+ } from "../index-n7hrpngg.js";
78
78
  import {
79
79
  ManagedFilePathSchema2,
80
80
  ManagedFileRefSchema2
@@ -4,7 +4,7 @@ import {
4
4
  AgentSandboxRestrictionSchema2,
5
5
  AgentSandboxGradeSchema2,
6
6
  AGENT_CODING_TOOL_NAMES
7
- } from "./index-bm180f2d.js";
7
+ } from "./index-ey15wx6j.js";
8
8
  import {
9
9
  AgentRecordIdSchema2,
10
10
  AgentRecordVersionSchema2,
@@ -19,7 +19,7 @@ import {
19
19
  appendEventIn,
20
20
  ArchiveProjectionSchema,
21
21
  createAgentRuntimeStore2
22
- } from "./index-mpg1t7nv.js";
22
+ } from "./index-0z3kfphz.js";
23
23
  import {
24
24
  AgentConversationPageSchema2,
25
25
  AgentConversationMessagePageSchema2
@@ -23,6 +23,62 @@ import {
23
23
  assertPositiveSafeInteger
24
24
  } from "./index-0s4xebbg.js";
25
25
 
26
+ // src/process/group-diagnostics.ts
27
+ import { z } from "zod";
28
+ var ObservationSchema = z.object({
29
+ failure: z.enum(["deadline", "observation"]),
30
+ groupId: z.number().int().positive(),
31
+ observations: z.number().int().nonnegative(),
32
+ lastStates: z.array(z.string().max(32)).max(16),
33
+ elapsedMs: z.number().int().nonnegative()
34
+ });
35
+ var observations = new WeakMap;
36
+
37
+ class GroupSettlementError extends Error {
38
+ constructor(message, observation, cause = observation) {
39
+ super(`${message}: ${JSON.stringify(observation)}`, { cause });
40
+ observations.set(this, { ...observation, lastStates: [...observation.lastStates] });
41
+ }
42
+ }
43
+ function ownData(value, key) {
44
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
45
+ return descriptor && "value" in descriptor ? descriptor.value : undefined;
46
+ }
47
+ function groupSettlementDiagnostics(cause) {
48
+ const pending = [{ value: cause, depth: 0 }];
49
+ const seen = new Set;
50
+ const found = [];
51
+ for (let visited = 0;pending.length && visited < 32 && found.length < 4; visited++) {
52
+ const entry = pending.pop();
53
+ if (!entry || seen.has(entry.value))
54
+ continue;
55
+ seen.add(entry.value);
56
+ try {
57
+ if (entry.value instanceof Error) {
58
+ const observation = observations.get(entry.value);
59
+ if (observation)
60
+ found.push(observation);
61
+ }
62
+ if (!(entry.value instanceof Error) || entry.depth >= 8)
63
+ continue;
64
+ if (entry.value instanceof AggregateError) {
65
+ const errors = ownData(entry.value, "errors");
66
+ if (Array.isArray(errors)) {
67
+ for (let index = 0;index < 16; index++) {
68
+ const value = ownData(errors, String(index));
69
+ if (value !== undefined)
70
+ pending.push({ value, depth: entry.depth + 1 });
71
+ }
72
+ }
73
+ }
74
+ const nested = ownData(entry.value, "cause");
75
+ if (nested !== undefined)
76
+ pending.push({ value: nested, depth: entry.depth + 1 });
77
+ } catch {}
78
+ }
79
+ return found;
80
+ }
81
+
26
82
  // src/process/group-presence.ts
27
83
  function processGroupExists(pid) {
28
84
  try {
@@ -57,36 +113,49 @@ function processGroups(timeoutMs) {
57
113
  return new Promise((resolve, reject) => {
58
114
  execFile("ps", ["-axo", "pgid=,stat="], { encoding: "utf8", timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 1024 * 1024 }, (error, stdout) => {
59
115
  if (error)
60
- reject(new Error("Could not observe command process group settlement", { cause: error }));
116
+ reject(error);
61
117
  else
62
118
  resolve(stdout);
63
119
  });
64
120
  });
65
121
  }
66
- async function waitForProcessGroupExit(pid, deadline) {
122
+ async function waitForProcessGroupExit(pid, deadline, killLiveMembers) {
67
123
  if (pid === undefined)
68
124
  return;
69
125
  let observations = 0;
70
126
  let lastStates = [];
71
- for (;; ) {
72
- const remaining = Math.ceil(deadline - performance.now());
73
- if (remaining <= 0)
74
- throw new Error("Command process group settlement was not confirmed after SIGKILL", {
75
- cause: { groupId: pid, observations, lastStates }
76
- });
77
- if (!processGroupExists(pid))
78
- return;
79
- const table = await processGroups(remaining);
80
- observations++;
81
- if (!hasLiveGroupMember(table, pid))
82
- return;
83
- lastStates = table.split(/\r?\n/).flatMap((row) => {
84
- const fields = /^\s*(\d+)\s+(\S+)\s*$/.exec(row);
85
- return Number(fields?.[1]) === pid ? [fields?.[2] ?? "unknown"] : [];
86
- }).slice(0, 16);
87
- if (!processGroupExists(pid))
88
- return;
89
- await sleep(Math.min(5, Math.max(0, deadline - performance.now())));
127
+ const startedAt = performance.now();
128
+ const observation = () => ({
129
+ groupId: pid,
130
+ observations,
131
+ lastStates,
132
+ elapsedMs: Math.max(0, Math.ceil(performance.now() - startedAt))
133
+ });
134
+ try {
135
+ for (;; ) {
136
+ const remaining = Math.ceil(deadline - performance.now());
137
+ if (remaining <= 0)
138
+ throw new GroupSettlementError("Command process group settlement was not confirmed after SIGKILL", { ...observation(), failure: "deadline" });
139
+ if (!processGroupExists(pid))
140
+ return;
141
+ const table = await processGroups(remaining);
142
+ observations++;
143
+ if (!hasLiveGroupMember(table, pid))
144
+ return;
145
+ lastStates = table.split(/\r?\n/).flatMap((row) => {
146
+ const fields = /^\s*(\d+)\s+(\S+)\s*$/.exec(row);
147
+ return Number(fields?.[1]) === pid ? [(fields?.[2] ?? "unknown").slice(0, 32)] : [];
148
+ }).slice(0, 16);
149
+ if (!processGroupExists(pid))
150
+ return;
151
+ if (killLiveMembers && performance.now() < deadline && !await killLiveMembers())
152
+ return;
153
+ await sleep(Math.min(5, Math.max(0, deadline - performance.now())));
154
+ }
155
+ } catch (cause) {
156
+ if (cause instanceof GroupSettlementError)
157
+ throw cause;
158
+ throw new GroupSettlementError("Could not observe command process group settlement", { ...observation(), failure: "observation" }, cause);
90
159
  }
91
160
  }
92
161
 
@@ -151,7 +220,7 @@ async function killAndSettleGroup(pid, deadline, cleanupTimeoutMs) {
151
220
  const cleanupDeadline = Math.min(deadline, performance.now() + cleanupTimeoutMs);
152
221
  const signalled = await signalUntilSettled(pid, "SIGKILL", cleanupDeadline);
153
222
  if (signalled)
154
- await waitForProcessGroupExit(pid, cleanupDeadline);
223
+ await waitForProcessGroupExit(pid, cleanupDeadline, () => signalUntilSettled(pid, "SIGKILL", cleanupDeadline));
155
224
  return signalled;
156
225
  }
157
226
  async function stopCommandGroup(stop) {
@@ -235,7 +304,9 @@ async function stopLeaderAlone(stop) {
235
304
  return send("SIGKILL") || signalled;
236
305
  }
237
306
  function commandCleanupError(cause) {
238
- return new NativeCommandError2("COMMAND_CLEANUP", "Command cleanup did not complete", {
307
+ const observations = groupSettlementDiagnostics(cause);
308
+ const message = observations.length ? `Command cleanup did not complete: ${JSON.stringify(observations)}` : "Command cleanup did not complete";
309
+ return new NativeCommandError2("COMMAND_CLEANUP", message, {
239
310
  cause
240
311
  });
241
312
  }
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  CommandStopped,
9
9
  startNativeCommand
10
- } from "./index-e1sjcjfy.js";
10
+ } from "./index-7r4knwf8.js";
11
11
  import {
12
12
  NumericFileHandle,
13
13
  descriptorPath,
@@ -17,7 +17,7 @@ import {
17
17
  replaceMessage,
18
18
  ArchiveSpillSchema,
19
19
  createAgentRuntimeStore2
20
- } from "./index-mpg1t7nv.js";
20
+ } from "./index-0z3kfphz.js";
21
21
 
22
22
  // src/agent-runtime/store-memory.ts
23
23
  import { z as z2 } from "zod";