stitchkit 0.123.0 → 0.123.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.
package/CHANGELOG.md CHANGED
@@ -15,6 +15,22 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.123.1] - 2026-11-12
19
+
20
+ ### Fixed
21
+
22
+ - `stitchkit/files`, `stitchkit/process`, `stitchkit/application`, `stitchkit/telegram` — **the first exclusive lock of a
23
+ process no longer waits on a child process whose end is never reported.** On macOS the first
24
+ acquisition reads the machine identity from `ioreg`, and a liveness probe may ask `ps`. Inside
25
+ `bun test`, Bun's `node:child_process` can lose a child's end under host load; `execFile` then
26
+ called back with neither the output nor its own timeout, and `withExclusiveLock` hung without
27
+ honouring `signal` or `timeoutMs`. Under Bun both commands now start through `Bun.spawn`, and on
28
+ every runtime the 2 s deadline ends the wait itself, whether or not the child's end arrives. A
29
+ `signal` that fires during the identity read ends the acquisition with `LOCK_ABORTED`; nothing is
30
+ published from a read that did not answer, and a cancelled read is asked again by the next
31
+ acquisition.
32
+ **Affects:** `stitchkit/files` behaviour; `stitchkit/process` behaviour; `stitchkit/application` behaviour; `stitchkit/telegram` behaviour
33
+
18
34
  ## [0.123.0] - 2026-11-11
19
35
 
20
36
  ### ⚠️ Breaking changes
@@ -18,10 +18,10 @@ import {
18
18
  createBoundedChannel2
19
19
  } from "../../index-w0eqdhyd.js";
20
20
  import"../../index-sqc6ezrb.js";
21
- import"../../index-n90tkkcv.js";
21
+ import"../../index-bqzgaj57.js";
22
22
  import {
23
23
  attemptExclusiveLock
24
- } from "../../index-dv7pa9w6.js";
24
+ } from "../../index-chz7c830.js";
25
25
  import {
26
26
  BoundedFileReadError,
27
27
  openRegularFile
@@ -14,15 +14,15 @@ import {
14
14
  backoffDelay
15
15
  } from "../../index-g6a3na27.js";
16
16
  import"../../index-sqc6ezrb.js";
17
- import"../../index-n90tkkcv.js";
18
- import"../../index-dv7pa9w6.js";
17
+ import"../../index-bqzgaj57.js";
18
+ import"../../index-chz7c830.js";
19
19
  import {
20
20
  defineManagedResource2
21
21
  } from "../../index-50ejfz75.js";
22
22
  import {
23
23
  createFileStateStore2
24
- } from "../../index-wzqd6pen.js";
25
- import"../../index-64b2dxqz.js";
24
+ } from "../../index-d9cg0gen.js";
25
+ import"../../index-73dappvg.js";
26
26
  import {
27
27
  isJsonData
28
28
  } from "../../index-m6w6jtda.js";
@@ -1,7 +1,7 @@
1
1
  import"../../index-xqhede6x.js";
2
2
  import"../../index-sqc6ezrb.js";
3
- import"../../index-n90tkkcv.js";
4
- import"../../index-dv7pa9w6.js";
3
+ import"../../index-bqzgaj57.js";
4
+ import"../../index-chz7c830.js";
5
5
  import {
6
6
  signCliManifest2,
7
7
  verifyCliManifest2,
@@ -18,7 +18,7 @@ import {
18
18
  } from "../../index-tt3ej8r3.js";
19
19
  import {
20
20
  withExclusiveLock2
21
- } from "../../index-64b2dxqz.js";
21
+ } from "../../index-73dappvg.js";
22
22
  import {
23
23
  ManagedFileError2,
24
24
  createManagedFileBoundary2
@@ -3,12 +3,12 @@ import {
3
3
  ManagedFileRefSchema2
4
4
  } from "../index-xqhede6x.js";
5
5
  import"../index-sqc6ezrb.js";
6
- import"../index-n90tkkcv.js";
7
- import"../index-dv7pa9w6.js";
6
+ import"../index-bqzgaj57.js";
7
+ import"../index-chz7c830.js";
8
8
  import {
9
9
  ExclusiveLockError2,
10
10
  withExclusiveLock2
11
- } from "../index-64b2dxqz.js";
11
+ } from "../index-73dappvg.js";
12
12
  import {
13
13
  ManagedFileError2,
14
14
  createManagedFileBoundary2
@@ -3,7 +3,7 @@ import {
3
3
  ProcessInstanceSchema2,
4
4
  observeProcessInstance2,
5
5
  probeProcessOwner2
6
- } from "../index-n90tkkcv.js";
6
+ } from "../index-bqzgaj57.js";
7
7
  import {
8
8
  NativeCommandError2
9
9
  } from "../index-0ndz5r8z.js";
@@ -1,6 +1,6 @@
1
1
  import"../index-sqc6ezrb.js";
2
- import"../index-n90tkkcv.js";
3
- import"../index-dv7pa9w6.js";
2
+ import"../index-bqzgaj57.js";
3
+ import"../index-chz7c830.js";
4
4
  import {
5
5
  errorCode2,
6
6
  normalizeError2
@@ -56,11 +56,11 @@ import {
56
56
  } from "../index-yfpt7sxr.js";
57
57
  import {
58
58
  createFileStateStore2
59
- } from "../index-wzqd6pen.js";
59
+ } from "../index-d9cg0gen.js";
60
60
  import {
61
61
  bindRealtimeServer2
62
62
  } from "../index-sqkttz7z.js";
63
- import"../index-64b2dxqz.js";
63
+ import"../index-73dappvg.js";
64
64
  import {
65
65
  withDeadline
66
66
  } from "../index-9tqbxv5p.js";
@@ -2,10 +2,10 @@ import {
2
2
  backoffDelay
3
3
  } from "../index-g6a3na27.js";
4
4
  import"../index-sqc6ezrb.js";
5
- import"../index-n90tkkcv.js";
5
+ import"../index-bqzgaj57.js";
6
6
  import {
7
7
  attemptExclusiveLock
8
- } from "../index-dv7pa9w6.js";
8
+ } from "../index-chz7c830.js";
9
9
  import {
10
10
  TELEGRAM_SEND_FAILURE_REASONS2,
11
11
  classifyTelegramSendFailure2
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attemptExclusiveLock
3
- } from "./index-dv7pa9w6.js";
3
+ } from "./index-chz7c830.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./index-eemvahkc.js";
@@ -12,6 +12,37 @@ import {
12
12
  import { execFile } from "node:child_process";
13
13
  import { readFile } from "node:fs/promises";
14
14
  import { platform } from "node:os";
15
+
16
+ // src/internal/bun-command.ts
17
+ var spawnWithBun = (file, args, maxBuffer) => {
18
+ const child = Bun.spawn([file, ...args], {
19
+ stdin: "ignore",
20
+ stdout: "pipe",
21
+ stderr: "ignore"
22
+ });
23
+ const read = async () => {
24
+ const decoder = new TextDecoder;
25
+ let text = "";
26
+ let bytes = 0;
27
+ for await (const chunk of child.stdout) {
28
+ bytes += chunk.byteLength;
29
+ if (bytes > maxBuffer) {
30
+ child.kill("SIGKILL");
31
+ throw new Error(`${file} wrote more than ${maxBuffer} bytes`);
32
+ }
33
+ text += decoder.decode(chunk, { stream: true });
34
+ }
35
+ text += decoder.decode();
36
+ const exitCode = await child.exited;
37
+ if (exitCode !== 0)
38
+ throw new Error(`${file} ended with ${exitCode}`);
39
+ return text;
40
+ };
41
+ return { stdout: read(), stop: () => child.kill("SIGKILL") };
42
+ };
43
+ var launchWithBun = typeof Bun === "undefined" ? undefined : spawnWithBun;
44
+
45
+ // src/internal/process-identity.ts
15
46
  var detectedIdentity;
16
47
  async function firstReadableLine(paths) {
17
48
  for (const path of paths) {
@@ -23,37 +54,92 @@ async function firstReadableLine(paths) {
23
54
  }
24
55
  return null;
25
56
  }
26
- function run(file, args, options) {
27
- return new Promise((resolve, reject) => {
28
- execFile(file, args, { ...options, encoding: "utf8" }, (error, stdout) => {
57
+ var launchWithNode = (file, args, maxBuffer) => {
58
+ let stop = () => {
59
+ return;
60
+ };
61
+ const stdout = new Promise((resolve, reject) => {
62
+ const child = execFile(file, args, { maxBuffer, encoding: "utf8" }, (error, text) => {
29
63
  if (error)
30
64
  reject(error);
31
65
  else
32
- resolve({ stdout });
66
+ resolve(text);
67
+ });
68
+ stop = () => {
69
+ child.kill("SIGKILL");
70
+ };
71
+ });
72
+ return { stdout, stop: () => stop() };
73
+ };
74
+ function run(file, args, limits) {
75
+ const { timeout, maxBuffer, signal } = limits;
76
+ const launch = limits.launch ?? launchWithBun ?? launchWithNode;
77
+ return new Promise((resolve, reject) => {
78
+ if (signal?.aborted) {
79
+ reject(signal.reason);
80
+ return;
81
+ }
82
+ let command;
83
+ try {
84
+ command = launch(file, args, maxBuffer);
85
+ } catch (error) {
86
+ reject(error);
87
+ return;
88
+ }
89
+ const abandon = (reason) => {
90
+ clearTimeout(timer);
91
+ signal?.removeEventListener("abort", onAbort);
92
+ command.stop();
93
+ reject(reason);
94
+ };
95
+ const onAbort = () => abandon(signal?.reason);
96
+ const timer = setTimeout(() => abandon(new Error(`${file} did not answer within ${timeout} ms`)), timeout);
97
+ signal?.addEventListener("abort", onAbort, { once: true });
98
+ command.stdout.then((text) => {
99
+ clearTimeout(timer);
100
+ signal?.removeEventListener("abort", onAbort);
101
+ resolve(text);
102
+ }, (error) => {
103
+ clearTimeout(timer);
104
+ signal?.removeEventListener("abort", onAbort);
105
+ reject(error);
33
106
  });
34
107
  });
35
108
  }
36
109
  function parsePlatformUuid(dump) {
37
110
  return /"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(dump)?.[1] ?? null;
38
111
  }
39
- async function readDarwinPlatformUuid(command = "ioreg") {
112
+ async function readDarwinPlatformUuid(command = "ioreg", signal, seam = {}) {
40
113
  try {
41
- const { stdout } = await run(command, ["-rd1", "-c", "IOPlatformExpertDevice"], {
42
- timeout: 2000,
43
- maxBuffer: 1 << 20
114
+ const stdout = await run(command, ["-rd1", "-c", "IOPlatformExpertDevice"], {
115
+ timeout: seam.timeoutMs ?? 2000,
116
+ maxBuffer: 1 << 20,
117
+ ...signal !== undefined && { signal },
118
+ ...seam.launch !== undefined && { launch: seam.launch }
44
119
  });
45
120
  return parsePlatformUuid(stdout);
46
121
  } catch {
47
122
  return null;
48
123
  }
49
124
  }
50
- async function machineIdentity(declared) {
125
+ var identitySource = {
126
+ detect(signal) {
127
+ return platform() === "darwin" ? readDarwinPlatformUuid("ioreg", signal) : firstReadableLine(["/etc/machine-id", "/var/lib/dbus/machine-id"]);
128
+ },
129
+ forget() {
130
+ detectedIdentity = undefined;
131
+ }
132
+ };
133
+ async function machineIdentity(declared, signal) {
51
134
  if (declared !== undefined)
52
135
  return declared;
53
136
  if (detectedIdentity !== undefined)
54
137
  return detectedIdentity;
55
- detectedIdentity = platform() === "darwin" ? await readDarwinPlatformUuid() : await firstReadableLine(["/etc/machine-id", "/var/lib/dbus/machine-id"]);
56
- return detectedIdentity;
138
+ const detected = await identitySource.detect(signal);
139
+ if (signal?.aborted)
140
+ return null;
141
+ detectedIdentity = detected;
142
+ return detected;
57
143
  }
58
144
  async function probeLiveness(pid, reach = (target) => process.kill(target, 0)) {
59
145
  try {
@@ -70,9 +156,10 @@ async function isZombieProcess(pid, seam = {}) {
70
156
  return stat.slice(stat.lastIndexOf(")") + 1).trimStart().startsWith("Z");
71
157
  } catch {}
72
158
  try {
73
- const { stdout } = await run(psCommand, ["-o", "state=", "-p", String(pid)], {
74
- timeout: 2000,
75
- maxBuffer: 1 << 16
159
+ const stdout = await run(psCommand, ["-o", "state=", "-p", String(pid)], {
160
+ timeout: seam.timeoutMs ?? 2000,
161
+ maxBuffer: 1 << 16,
162
+ ...seam.launch !== undefined && { launch: seam.launch }
76
163
  });
77
164
  return stdout.trim().startsWith("Z");
78
165
  } catch {
@@ -3,7 +3,7 @@ import {
3
3
  ProcessInstanceSchema2,
4
4
  readProcessInstance,
5
5
  probeProcessOwner2
6
- } from "./index-n90tkkcv.js";
6
+ } from "./index-bqzgaj57.js";
7
7
  import {
8
8
  BoundedFileReadError,
9
9
  readBoundedFile
@@ -92,11 +92,11 @@ function attribute(owner, identity) {
92
92
  }
93
93
  return owner.host === hostname() ? "this-machine" : "unattributable";
94
94
  }
95
- async function diagnose(lock, declaredIdentity) {
95
+ async function diagnose(lock, declaredIdentity, signal) {
96
96
  const owner = lock?.owner;
97
97
  if (!lock || !owner)
98
98
  return { attribution: "unattributable", liveness: "not-probed", owner: null };
99
- const attribution = attribute(owner, await machineIdentity(declaredIdentity));
99
+ const attribution = attribute(owner, await machineIdentity(declaredIdentity, signal));
100
100
  if (attribution !== "this-machine")
101
101
  return { attribution, liveness: "not-probed", owner };
102
102
  const evidence = await probeProcessOwner2(owner.pid, owner.process);
@@ -199,7 +199,7 @@ async function sweepStagedLocks(directory, machine, signal) {
199
199
  const state = await readLockFile(candidate, undefined, signal);
200
200
  if (!state?.owner)
201
201
  continue;
202
- if ((await diagnose(state, machine)).liveness !== "gone")
202
+ if ((await diagnose(state, machine, signal)).liveness !== "gone")
203
203
  continue;
204
204
  await unlinkIfSame(candidate, state.ino, state.dev, state.stagedName === undefined ? 1 : 2);
205
205
  }
@@ -216,7 +216,9 @@ async function unlinkIfSame(path, ino, dev, links = 1) {
216
216
  }
217
217
  }
218
218
  async function createOwned(path, options, reclaimed) {
219
- const identity = await machineIdentity(options.machineIdentity);
219
+ const identity = await machineIdentity(options.machineIdentity, options.signal);
220
+ if (options.signal?.aborted)
221
+ throw options.signal.reason;
220
222
  const instance = await readProcessInstance(process.pid);
221
223
  const owner = {
222
224
  pid: process.pid,
@@ -320,7 +322,7 @@ async function reclaimUnderGuard(path, options, depth) {
320
322
  if (readFailure !== undefined)
321
323
  return { refused: true, cause: readFailure };
322
324
  if (state) {
323
- const diagnosis = await diagnose(state, options.machineIdentity);
325
+ const diagnosis = await diagnose(state, options.machineIdentity, options.signal);
324
326
  if (options.signal?.aborted)
325
327
  return { refused: true };
326
328
  if (!reclaimable(state, diagnosis, options.ownerlessGraceMs))
@@ -334,7 +336,7 @@ async function reclaimUnderGuard(path, options, depth) {
334
336
  }
335
337
  await sweepStagedLocks(dirname(path), options.machineIdentity, options.signal);
336
338
  return await createOwned(path, options, state !== undefined).catch((error) => {
337
- if (isCode(error, "EEXIST"))
339
+ if (isCode(error, "EEXIST") || options.signal?.aborted)
338
340
  return { refused: true, cause: error };
339
341
  throw error;
340
342
  });
@@ -348,6 +350,8 @@ async function attemptExclusiveLock(path, options, depth = 0) {
348
350
  try {
349
351
  return { held: await createOwned(path, options, false) };
350
352
  } catch (error) {
353
+ if (options.signal?.aborted)
354
+ return { error };
351
355
  if (!isCode(error, "EEXIST"))
352
356
  throw error;
353
357
  if (!options.reclaim)
@@ -357,7 +361,7 @@ async function attemptExclusiveLock(path, options, depth = 0) {
357
361
  readFailure = cause;
358
362
  }, options.signal);
359
363
  const diagnosis = {
360
- ...await diagnose(state, options.machineIdentity),
364
+ ...await diagnose(state, options.machineIdentity, options.signal),
361
365
  ...readFailure !== undefined && { cause: readFailure }
362
366
  };
363
367
  if (options.signal?.aborted)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withExclusiveLock2
3
- } from "./index-64b2dxqz.js";
3
+ } from "./index-73dappvg.js";
4
4
  import {
5
5
  readBoundedFile
6
6
  } from "./index-m616f0yz.js";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The one place of this leaf that names the Bun global: a bounded command started through
3
+ * `Bun.spawn` when the host is Bun, and nothing when it is not.
4
+ */
5
+ /** A command that was started: its stdout once it has ended well, and a way to end it. */
6
+ export interface LaunchedCommand {
7
+ readonly stdout: Promise<string>;
8
+ stop(): void;
9
+ }
10
+ /** Starts a command. The tests replace it with a child whose end is never reported. */
11
+ export type CommandLauncher = (file: string, args: readonly string[], maxBuffer: number) => LaunchedCommand;
12
+ /** The Bun launcher, or `undefined` off Bun, where `node:child_process` reports a child's end. */
13
+ export declare const launchWithBun: CommandLauncher | undefined;
14
+ //# sourceMappingURL=bun-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-command.d.ts","sourceRoot":"","sources":["../../src/internal/bun-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,IAAI,IAAI,CAAC;CACd;AAED,uFAAuF;AACvF,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,EAAE,MAAM,KACd,eAAe,CAAC;AAiCrB,kGAAkG;AAClG,eAAO,MAAM,aAAa,EAAE,eAAe,GAAG,SACS,CAAC"}
@@ -48,6 +48,6 @@ export interface RecordedLock extends FileIdentity {
48
48
  * in place keeps its PID and start time but not that descriptor, so the lock it left is gone —
49
49
  * judged alive, it would stay held until the PID changed.
50
50
  */
51
- export declare function diagnose(lock: RecordedLock | undefined, declaredIdentity: string | undefined): Promise<ExclusiveLockDiagnosis>;
51
+ export declare function diagnose(lock: RecordedLock | undefined, declaredIdentity: string | undefined, signal?: AbortSignal): Promise<ExclusiveLockDiagnosis>;
52
52
  export {};
53
53
  //# sourceMappingURL=exclusive-lock-owner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exclusive-lock-owner.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock-owner.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AAE5E,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,oBAAoB,CAAC;AAG5B,gDAAgD;AAChD,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;iBAO5B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,+CAA+C;AAC/C,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,EAAE,cAAc,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,YAAY,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,mBAAmB,CAAC;IAC3E,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG;IACvC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACtC,SAAS,EAAE,OAAO,CAAC;CACpB,CAkBA;AAoBD,2FAA2F;AAC3F,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAA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,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,sBAAsB,CAAC,CAcjC"}
@@ -25,7 +25,7 @@ export interface ExclusiveLockAttemptOptions {
25
25
  export type ExclusiveLockAttempt = {
26
26
  readonly held: HeldExclusiveLock;
27
27
  } | {
28
- /** The `EEXIST` the exclusive create produced. */
28
+ /** The `EEXIST` the exclusive create produced, or what a cancelled attempt stopped on. */
29
29
  readonly error: unknown;
30
30
  /** Present when a reclaim was considered. */
31
31
  readonly diagnosis?: ExclusiveLockDiagnosis;
@@ -1 +1 @@
1
- {"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"AA6BA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAGxB,MAAM,wBAAwB,CAAC;AAMhC,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,uFAAuF;IACvF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE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AAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACpC;IACE,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;CAC7C,CAAC;AAgTN;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,2BAA2B,EACpC,KAAK,SAAI,GACR,OAAO,CAAC,oBAAoB,CAAC,CAkC/B;AAED,gFAAgF;AAChF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAEpC"}
@@ -1,3 +1,9 @@
1
+ import { type CommandLauncher } from './bun-command.js';
2
+ /** @internal What the tests replace in a command: who starts it and how long it may take. */
3
+ export interface CommandSeam {
4
+ readonly launch?: CommandLauncher;
5
+ readonly timeoutMs?: number;
6
+ }
1
7
  /**
2
8
  * `IOPlatformUUID` out of an `ioreg` dump, or `null` when the dump does not carry one.
3
9
  *
@@ -7,11 +13,24 @@
7
13
  */
8
14
  export declare function parsePlatformUuid(dump: string): string | null;
9
15
  /**
10
- * @internal `command` is a seam for the tests. macOS keeps no machine-id file, so the I/O cannot be
11
- * removed — but which executable answers can be, and that makes the branch provable off darwin.
16
+ * @internal `command` and `seam` are for the tests. macOS keeps no machine-id file, so the I/O
17
+ * cannot be removed — but which executable answers can be, and that makes the branch provable off
18
+ * darwin.
12
19
  */
13
- export declare function readDarwinPlatformUuid(command?: string): Promise<string | null>;
14
- export declare function machineIdentity(declared: string | undefined): Promise<string | null>;
20
+ export declare function readDarwinPlatformUuid(command?: string, signal?: AbortSignal, seam?: CommandSeam): Promise<string | null>;
21
+ /**
22
+ * @internal What an undeclared identity is read from. The tests replace `detect` with a read whose
23
+ * command never reports its end, and `forget` drops the memoized answer between cases.
24
+ */
25
+ export declare const identitySource: {
26
+ detect(signal?: AbortSignal): Promise<string | null>;
27
+ forget(): void;
28
+ };
29
+ /**
30
+ * A cancelled detection answers `null` and is not remembered: the caller that cancelled is leaving,
31
+ * and the next one asks the platform again.
32
+ */
33
+ export declare function machineIdentity(declared: string | undefined, signal?: AbortSignal): Promise<string | null>;
15
34
  /**
16
35
  * Whether the recorded owner is provably gone.
17
36
  *
@@ -43,5 +62,5 @@ export declare function probeLiveness(pid: number, reach?: (target: number) => t
43
62
  export declare function isZombieProcess(pid: number, seam?: {
44
63
  procRoot?: string;
45
64
  psCommand?: string;
46
- }): Promise<boolean>;
65
+ } & CommandSeam): Promise<boolean>;
47
66
  //# sourceMappingURL=process-identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-identity.d.ts","sourceRoot":"","sources":["../../src/internal/process-identity.ts"],"names":[],"mappings":"AA6DA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,SAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBtF;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAW1F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,KAAK,YAAY,MAAM,SAA4B,GAClD,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAY3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI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AAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,WAAgB,GACjE,OAAO,CAAC,OAAO,CAAC,CAuBlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.123.0",
3
+ "version": "0.123.1",
4
4
  "description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
5
5
  "keywords": [
6
6
  "bun",