stitchkit 0.123.0 → 0.123.2

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 (39) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/browser/client-bound.d.ts +19 -0
  3. package/dist/browser/client-bound.d.ts.map +1 -0
  4. package/dist/browser/client-url.d.ts +2 -0
  5. package/dist/browser/client-url.d.ts.map +1 -1
  6. package/dist/browser/client.d.ts +20 -10
  7. package/dist/browser/client.d.ts.map +1 -1
  8. package/dist/contract/client-types.d.ts +13 -8
  9. package/dist/contract/client-types.d.ts.map +1 -1
  10. package/dist/entrypoints/application/diagnostic-journal.js +2 -2
  11. package/dist/entrypoints/application/directory-inbox.js +4 -4
  12. package/dist/entrypoints/cli/publish.js +3 -3
  13. package/dist/entrypoints/files.js +3 -3
  14. package/dist/entrypoints/http.js +1 -1
  15. package/dist/entrypoints/index.js +1 -1
  16. package/dist/entrypoints/process.js +1 -1
  17. package/dist/entrypoints/remote.js +1 -1
  18. package/dist/entrypoints/server.js +4 -4
  19. package/dist/entrypoints/telegram.js +2 -2
  20. package/dist/entrypoints/testing.js +1 -1
  21. package/dist/{index-64b2dxqz.js → index-73dappvg.js} +1 -1
  22. package/dist/{index-n90tkkcv.js → index-bqzgaj57.js} +101 -14
  23. package/dist/{index-dv7pa9w6.js → index-chz7c830.js} +12 -8
  24. package/dist/{index-wzqd6pen.js → index-d9cg0gen.js} +1 -1
  25. package/dist/{index-mdyhr36s.js → index-zbzagr9k.js} +127 -61
  26. package/dist/internal/bun-command.d.ts +14 -0
  27. package/dist/internal/bun-command.d.ts.map +1 -0
  28. package/dist/internal/exclusive-lock-owner.d.ts +1 -1
  29. package/dist/internal/exclusive-lock-owner.d.ts.map +1 -1
  30. package/dist/internal/exclusive-lock.d.ts +1 -1
  31. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  32. package/dist/internal/process-identity.d.ts +24 -5
  33. package/dist/internal/process-identity.d.ts.map +1 -1
  34. package/llms/stitchkit.2.txt +36 -174
  35. package/llms/stitchkit.3.txt +186 -0
  36. package/llms/stitchkit.txt +3 -2
  37. package/llms-full.txt +33 -1
  38. package/llms.txt +1 -1
  39. package/package.json +1 -1
@@ -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";
@@ -37,56 +37,6 @@ function endpointHasArguments(endpoint) {
37
37
  return Boolean(endpoint.params || endpoint.input || endpoint.multipart);
38
38
  }
39
39
 
40
- // src/browser/client-multipart.ts
41
- function isFileDescriptor(value) {
42
- return typeof value === "object" && value !== null && !(value instanceof Blob) && "uri" in value && typeof value.uri === "string" && "name" in value && typeof value.name === "string" && "type" in value && typeof value.type === "string";
43
- }
44
- function isMultipartFile(value) {
45
- return value instanceof Blob || isFileDescriptor(value);
46
- }
47
- function appendMultipartFile(form, field, file) {
48
- const sink = form;
49
- sink.append(field, file);
50
- }
51
- function appendFormFields(formData, values, skipKeys) {
52
- for (const [key, value] of Object.entries(values)) {
53
- if (skipKeys.has(key) || value === undefined || value === null)
54
- continue;
55
- formData.append(key, typeof value === "string" ? value : JSON.stringify(value));
56
- }
57
- }
58
- function buildMultipartForm(descriptor, values) {
59
- const formData = new FormData;
60
- const fileFields = new Set(Object.keys(descriptor.files));
61
- for (const [field, policy] of Object.entries(descriptor.files)) {
62
- const value = values[field];
63
- if (value === undefined) {
64
- if (policy.required !== false) {
65
- throw refuseLocally(field, `Missing multipart file field: ${field}`);
66
- }
67
- continue;
68
- }
69
- if (policy.multiple === true) {
70
- if (!Array.isArray(value) || value.length === 0) {
71
- throw refuseLocally(field, `Multipart file field "${field}" must be a non-empty array`);
72
- }
73
- for (const file of value) {
74
- if (!isMultipartFile(file)) {
75
- throw refuseLocally(field, `Invalid multipart file field: ${field}`);
76
- }
77
- appendMultipartFile(formData, field, file);
78
- }
79
- continue;
80
- }
81
- if (!isMultipartFile(value)) {
82
- throw refuseLocally(field, `Invalid multipart file field: ${field}`);
83
- }
84
- appendMultipartFile(formData, field, value);
85
- }
86
- appendFormFields(formData, values, fileFields);
87
- return formData;
88
- }
89
-
90
40
  // src/browser/client-url.ts
91
41
  function isParamArray(value) {
92
42
  return Array.isArray(value) && value.every((item) => typeof item === "string" || typeof item === "number");
@@ -184,7 +134,7 @@ function compileSegmentTest(pattern, markers) {
184
134
  const expression = new RegExp(`^${source}$`);
185
135
  return (actual) => expression.test(actual);
186
136
  }
187
- function extractParamNames(path) {
137
+ function routeParamNames(path) {
188
138
  const matches = path.match(/:(\w+)/g);
189
139
  const names = matches ? matches.map((match) => match.slice(1)) : [];
190
140
  const wildcard = parseTrailingWildcard(path);
@@ -213,7 +163,7 @@ function fillPathParams(path, args) {
213
163
  }
214
164
  function stripConsumedArgs(args, path, scopeKeys) {
215
165
  const consumed = new Set(scopeKeys);
216
- for (const name of extractParamNames(path))
166
+ for (const name of routeParamNames(path))
217
167
  consumed.add(name);
218
168
  const remaining = {};
219
169
  for (const [key, value] of Object.entries(args)) {
@@ -258,6 +208,118 @@ function joinClientBaseUrl(baseUrl, relativeUrl) {
258
208
  return `${base}${path}`;
259
209
  }
260
210
 
211
+ // src/browser/client-bound.ts
212
+ var WRAPPERS = new Set([
213
+ "optional",
214
+ "nullable",
215
+ "default",
216
+ "prefault",
217
+ "nonoptional",
218
+ "readonly",
219
+ "catch"
220
+ ]);
221
+ function collectDeclaredFields(schema, into) {
222
+ if (!isRecord(schema))
223
+ return false;
224
+ const def = isRecord(schema.def) ? schema.def : {};
225
+ if (isRecord(schema.shape)) {
226
+ for (const key of Object.keys(schema.shape))
227
+ into.add(key);
228
+ return def.catchall === undefined;
229
+ }
230
+ if (def.type === "union" && Array.isArray(def.options)) {
231
+ let closed = true;
232
+ for (const option of def.options)
233
+ closed = collectDeclaredFields(option, into) && closed;
234
+ return closed;
235
+ }
236
+ if (def.type === "intersection") {
237
+ const left = collectDeclaredFields(def.left, into);
238
+ return collectDeclaredFields(def.right, into) && left;
239
+ }
240
+ if (def.type === "pipe")
241
+ return collectDeclaredFields(def.in, into);
242
+ if (typeof def.type === "string" && WRAPPERS.has(def.type))
243
+ return collectDeclaredFields(def.innerType, into);
244
+ return false;
245
+ }
246
+ function boundEndpointArguments(endpoint, contractPrefix, config, surface = "request") {
247
+ const scopeKeys = config?.stripPrefixKeys ?? [];
248
+ const declared = new Set(scopeKeys);
249
+ const staticPrefix = typeof config?.pathPrefix === "string" ? config.pathPrefix : "";
250
+ for (const name of routeParamNames(`${staticPrefix}/${contractPrefix}${endpoint.path}`))
251
+ declared.add(name);
252
+ let closed = true;
253
+ if (endpoint.params)
254
+ closed = collectDeclaredFields(endpoint.params, declared) && closed;
255
+ if (surface === "request" || inputIsQuery(endpoint.method)) {
256
+ if (endpoint.input)
257
+ closed = collectDeclaredFields(endpoint.input, declared) && closed;
258
+ }
259
+ if (surface === "request")
260
+ for (const name of Object.keys(endpoint.multipart?.files ?? {}))
261
+ declared.add(name);
262
+ const bound = config?.bound ?? {};
263
+ const values = {};
264
+ for (const [key, value] of Object.entries(bound)) {
265
+ if (value !== undefined && declared.has(key))
266
+ values[key] = value;
267
+ }
268
+ const takesArguments = endpointHasArguments(endpoint) || scopeKeys.length > 0;
269
+ const complete = !takesArguments || Object.keys(values).length > 0 && closed && [...declared].every((key) => Object.hasOwn(values, key));
270
+ return { values, complete };
271
+ }
272
+
273
+ // src/browser/client-multipart.ts
274
+ function isFileDescriptor(value) {
275
+ return typeof value === "object" && value !== null && !(value instanceof Blob) && "uri" in value && typeof value.uri === "string" && "name" in value && typeof value.name === "string" && "type" in value && typeof value.type === "string";
276
+ }
277
+ function isMultipartFile(value) {
278
+ return value instanceof Blob || isFileDescriptor(value);
279
+ }
280
+ function appendMultipartFile(form, field, file) {
281
+ const sink = form;
282
+ sink.append(field, file);
283
+ }
284
+ function appendFormFields(formData, values, skipKeys) {
285
+ for (const [key, value] of Object.entries(values)) {
286
+ if (skipKeys.has(key) || value === undefined || value === null)
287
+ continue;
288
+ formData.append(key, typeof value === "string" ? value : JSON.stringify(value));
289
+ }
290
+ }
291
+ function buildMultipartForm(descriptor, values) {
292
+ const formData = new FormData;
293
+ const fileFields = new Set(Object.keys(descriptor.files));
294
+ for (const [field, policy] of Object.entries(descriptor.files)) {
295
+ const value = values[field];
296
+ if (value === undefined) {
297
+ if (policy.required !== false) {
298
+ throw refuseLocally(field, `Missing multipart file field: ${field}`);
299
+ }
300
+ continue;
301
+ }
302
+ if (policy.multiple === true) {
303
+ if (!Array.isArray(value) || value.length === 0) {
304
+ throw refuseLocally(field, `Multipart file field "${field}" must be a non-empty array`);
305
+ }
306
+ for (const file of value) {
307
+ if (!isMultipartFile(file)) {
308
+ throw refuseLocally(field, `Invalid multipart file field: ${field}`);
309
+ }
310
+ appendMultipartFile(formData, field, file);
311
+ }
312
+ continue;
313
+ }
314
+ if (!isMultipartFile(value)) {
315
+ throw refuseLocally(field, `Invalid multipart file field: ${field}`);
316
+ }
317
+ appendMultipartFile(formData, field, value);
318
+ }
319
+ appendFormFields(formData, values, fileFields);
320
+ return formData;
321
+ }
322
+
261
323
  // src/browser/stream.ts
262
324
  function ndjsonLine(rawLine) {
263
325
  return (rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine).trim();
@@ -701,7 +763,7 @@ function createClient2(contract, configOrClient, contractConfig) {
701
763
  for (const [key, endpoint] of typedEntries(contract.endpoints)) {
702
764
  if (endpoint.expose && !endpoint.expose.includes("HTTP"))
703
765
  continue;
704
- setClientMethod(client, key, createEndpointMethod(endpoint, namedOperation(makeExecutor(endpoint), `${contract.meta.prefix}.${String(key)}`), contractConfig));
766
+ setClientMethod(client, key, createEndpointMethod(endpoint, namedOperation(makeExecutor(endpoint), `${contract.meta.prefix}.${String(key)}`), boundEndpointArguments(endpoint, contract.meta.prefix, contractConfig)));
705
767
  }
706
768
  return client;
707
769
  }
@@ -742,22 +804,25 @@ function isHttpAdapter(value) {
742
804
  function setClientMethod(target, key, method) {
743
805
  target[key] = method;
744
806
  }
745
- function createEndpointMethod(endpoint, execute, contractConfig) {
746
- const hasScopedArguments = (contractConfig?.stripPrefixKeys?.length ?? 0) > 0;
747
- if (endpointHasArguments(endpoint) || hasScopedArguments) {
748
- const method = (requestArgs) => settle(execute, readClientRequestArgs(requestArgs), undefined);
807
+ function createEndpointMethod(endpoint, execute, bound) {
808
+ if (!bound.complete) {
809
+ const readArgs = (requestArgs) => ({
810
+ ...readClientRequestArgs(requestArgs),
811
+ ...bound.values
812
+ });
813
+ const method = (requestArgs) => settle(execute, readArgs(requestArgs), undefined);
749
814
  return Object.assign(method, {
750
815
  withOptions: (...args) => {
751
816
  refuseExtraWithOptionsArguments(endpoint, args.length, 2);
752
- return settle(execute, readClientRequestArgs(args[0]), readClientRequestOptions(endpoint, args[1]));
817
+ return settle(execute, readArgs(args[0]), readClientRequestOptions(endpoint, args[1]));
753
818
  }
754
819
  });
755
820
  }
756
- const method = () => settle(execute, {}, undefined);
821
+ const method = () => settle(execute, { ...bound.values }, undefined);
757
822
  return Object.assign(method, {
758
823
  withOptions: (...args) => {
759
824
  refuseExtraWithOptionsArguments(endpoint, args.length, 1);
760
- return settle(execute, {}, readClientRequestOptions(endpoint, args[0]));
825
+ return settle(execute, { ...bound.values }, readClientRequestOptions(endpoint, args[0]));
761
826
  }
762
827
  });
763
828
  }
@@ -813,8 +878,9 @@ function createUrlBuilder2(contract, source, contractConfig) {
813
878
  for (const [key, endpoint] of typedEntries(contract.endpoints)) {
814
879
  if (endpoint.expose && !endpoint.expose.includes("HTTP"))
815
880
  continue;
881
+ const bound = boundEndpointArguments(endpoint, contract.meta.prefix, contractConfig, "url");
816
882
  setClientMethod(builder, key, (args) => {
817
- const plan = planClientRequest(endpoint, contract.meta.prefix, args ?? {}, contractConfig);
883
+ const plan = planClientRequest(endpoint, contract.meta.prefix, { ...args, ...bound.values }, contractConfig);
818
884
  if (endpoint.method !== "GET" && endpoint.method !== "DELETE" && Object.keys(plan.remainingArgs).length > 0) {
819
885
  const fields = Object.keys(plan.remainingArgs).join(", ");
820
886
  throw new Error(`URL builder for ${endpoint.method} ${endpoint.path} received non-URL fields: ${fields}`);
@@ -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;;;;;;;;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gD;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,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,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,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;CAC7C,CAAC;AA4SN;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,2BAA2B,EACpC,KAAK,SAAI,GACR,OAAO,CAAC,o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ACZ,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,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,OAAO,CAAC,OAAO,CAAC,CAsBlB"}
1
+ {"version":3,"file":"process-identity.d.ts","sourceRoot":"","sources":["../../src/internal/process-identity.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,eAAe,EAAuC,MAAM,eAAe,CAAC;AAyG1F,6FAA6F;AAC7F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CA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