stitchkit 0.103.9 → 0.103.11

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 +21 -0
  2. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
  3. package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
  4. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -1
  5. package/dist/entrypoints/agent-runtime/sandbox.js +28 -14
  6. package/dist/entrypoints/application/diagnostic-journal.js +2 -1
  7. package/dist/entrypoints/files.js +14 -4
  8. package/dist/entrypoints/process.d.ts +2 -1
  9. package/dist/entrypoints/process.d.ts.map +1 -1
  10. package/dist/entrypoints/process.js +9 -2
  11. package/dist/index-32jkwkdm.js +565 -0
  12. package/dist/{index-a4ajxwmb.js → index-g4jxe7ve.js} +113 -131
  13. package/dist/index-nybn2err.js +213 -0
  14. package/dist/index-ttf0y7b8.js +246 -0
  15. package/dist/internal/exclusive-lock-read.d.ts +20 -0
  16. package/dist/internal/exclusive-lock-read.d.ts.map +1 -0
  17. package/dist/internal/exclusive-lock.d.ts +3 -1
  18. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  19. package/dist/internal/process-instance.d.ts +46 -9
  20. package/dist/internal/process-instance.d.ts.map +1 -1
  21. package/dist/internal/with-exclusive-lock.d.ts +4 -3
  22. package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
  23. package/dist/process/command-owner.d.ts +7 -2
  24. package/dist/process/command-owner.d.ts.map +1 -1
  25. package/dist/process/contract.d.ts +22 -1
  26. package/dist/process/contract.d.ts.map +1 -1
  27. package/dist/process/group.d.ts +6 -1
  28. package/dist/process/group.d.ts.map +1 -1
  29. package/dist/process/launch.d.ts +65 -0
  30. package/dist/process/launch.d.ts.map +1 -0
  31. package/dist/process/leader-settlement.d.ts +6 -0
  32. package/dist/process/leader-settlement.d.ts.map +1 -0
  33. package/dist/process/start-failure.d.ts +7 -0
  34. package/dist/process/start-failure.d.ts.map +1 -0
  35. package/llms/agent-runtime.txt +7 -1
  36. package/llms/files.txt +1 -1
  37. package/llms/process.txt +115 -2
  38. package/llms-full.txt +123 -4
  39. package/llms.txt +3 -3
  40. package/native/darwin-arm64.node +0 -0
  41. package/native/darwin-x64.node +0 -0
  42. package/package.json +2 -2
  43. package/dist/index-7kxw1awn.js +0 -328
  44. package/dist/index-eeqmg7qm.js +0 -202
@@ -2,6 +2,11 @@ import {
2
2
  forbidden2,
3
3
  conflict2
4
4
  } from "./index-n53mswt3.js";
5
+ import {
6
+ NativeCommandError2,
7
+ stopCommandGroup,
8
+ startNativeCommand
9
+ } from "./index-32jkwkdm.js";
5
10
  import {
6
11
  probeAgentProcessSandbox2,
7
12
  missingSandboxRestrictions2,
@@ -981,7 +986,6 @@ function createSearchAndPatchCodingTools(config, limits) {
981
986
  import { realpath as realpath5, stat } from "node:fs/promises";
982
987
 
983
988
  // src/agent-runtime/coding-shell-process.ts
984
- import { spawn } from "node:child_process";
985
989
  function preview(data, budget) {
986
990
  if (data.byteLength <= budget) {
987
991
  return { data, headBytes: data.byteLength, tailBytes: 0, omittedBytes: 0 };
@@ -1024,140 +1028,118 @@ async function runCodingShell(input) {
1024
1028
  outcome: "cancelled"
1025
1029
  });
1026
1030
  }
1027
- return await new Promise((resolve, reject) => {
1028
- const ownsProcessGroup = process.platform !== "win32";
1029
- const child = input.spawn ? input.spawn() : spawn(input.executable, input.args, {
1030
- cwd: input.cwd,
1031
- env: input.environment,
1032
- stdio: ["ignore", "pipe", "pipe"],
1033
- detached: ownsProcessGroup
1034
- });
1035
- const stdout = [];
1036
- const stderr = [];
1037
- const artifactStdout = [];
1038
- const artifactStderr = [];
1039
- let retained = 0;
1040
- let artifactBytes = 0;
1041
- let outcome = "exited";
1042
- let settled = false;
1043
- let settlementTimer;
1044
- const cancel = () => terminate("cancelled");
1045
- const cleanup = () => {
1046
- clearTimeout(timer);
1047
- if (settlementTimer)
1048
- clearTimeout(settlementTimer);
1049
- input.signal?.removeEventListener("abort", cancel);
1050
- };
1051
- const persistAndResolve = async (exitCode, signal) => {
1052
- if (settled)
1053
- return;
1054
- settled = true;
1055
- cleanup();
1056
- try {
1057
- const hasArtifact = input.artifacts && artifactBytes > input.maxOutputBytes;
1058
- const completeStdout = Buffer.concat(artifactStdout);
1059
- const completeStderr = Buffer.concat(artifactStderr);
1060
- const artifactData = hasArtifact ? Buffer.concat([stdoutHeader, completeStdout, stderrHeader, completeStderr]) : undefined;
1061
- const stdoutBudget = completeStderr.byteLength === 0 ? input.maxOutputBytes : Math.ceil(input.maxOutputBytes / 2);
1062
- const stderrBudget = completeStdout.byteLength === 0 ? input.maxOutputBytes : Math.floor(input.maxOutputBytes / 2);
1063
- const stdoutPreview = hasArtifact ? preview(completeStdout, stdoutBudget) : retainedPreview(Buffer.concat(stdout));
1064
- const stderrPreview = hasArtifact ? preview(completeStderr, stderrBudget) : retainedPreview(Buffer.concat(stderr));
1065
- const persisted = hasArtifact ? await input.artifacts?.write({
1066
- mediaType: "text/plain; charset=utf-8",
1067
- data: artifactData ?? new Uint8Array,
1068
- ...input.authorization && { authorization: input.authorization }
1069
- }) : undefined;
1070
- resolve(ShellOutputSchema.parse({
1071
- executable: input.executableName,
1072
- exitCode,
1073
- signal,
1074
- stdout: stdoutPreview.data.toString("utf8"),
1075
- stderr: stderrPreview.data.toString("utf8"),
1076
- outcome,
1077
- ...persisted && {
1078
- artifact: {
1079
- reference: persisted.reference,
1080
- bytes: artifactData?.byteLength ?? 0,
1081
- truncated: outcome === "output-limit",
1082
- headBytes: stdoutPreview.headBytes + stderrPreview.headBytes,
1083
- tailBytes: stdoutPreview.tailBytes + stderrPreview.tailBytes,
1084
- omittedBytes: stdoutPreview.omittedBytes + stderrPreview.omittedBytes
1085
- }
1086
- }
1087
- }));
1088
- } catch (error) {
1089
- reject(error);
1090
- }
1091
- };
1092
- const killOwnedProcessGroup = () => {
1093
- if (!ownsProcessGroup || child.pid === undefined)
1094
- return false;
1095
- try {
1096
- process.kill(-child.pid, "SIGKILL");
1097
- return true;
1098
- } catch {
1099
- return false;
1031
+ const stdout = [];
1032
+ const stderr = [];
1033
+ const artifactStdout = [];
1034
+ const artifactStderr = [];
1035
+ let retained = 0;
1036
+ let artifactBytes = 0;
1037
+ let outcome = "exited";
1038
+ let child;
1039
+ let exitCode = null;
1040
+ let signal = null;
1041
+ const outputLimit = new Error("Coding command output retention budget exceeded");
1042
+ const launch = input.spawn;
1043
+ const retain = (target, artifactTarget, chunk) => {
1044
+ const remaining = Math.max(0, input.maxOutputBytes - retained);
1045
+ if (remaining > 0) {
1046
+ const kept = Buffer.from(chunk.subarray(0, remaining));
1047
+ target.push(kept);
1048
+ retained += kept.byteLength;
1049
+ }
1050
+ if (input.artifacts) {
1051
+ const artifactRemaining = Math.max(0, artifactPayloadLimit - artifactBytes);
1052
+ if (artifactRemaining > 0) {
1053
+ const kept = Buffer.from(chunk.subarray(0, artifactRemaining));
1054
+ artifactTarget.push(kept);
1055
+ artifactBytes += kept.byteLength;
1100
1056
  }
1101
- };
1102
- const boundStreamSettlement = () => {
1103
- if (settlementTimer)
1104
- return;
1105
- settlementTimer = setTimeout(() => {
1106
- child.stdout.destroy();
1107
- child.stderr.destroy();
1108
- persistAndResolve(child.exitCode, child.signalCode);
1109
- }, input.terminationGraceMs);
1110
- };
1111
- const terminate = (reason) => {
1112
- if (settled || outcome !== "exited")
1057
+ if (chunk.byteLength > artifactRemaining)
1058
+ throw outputLimit;
1059
+ } else if (chunk.byteLength > remaining)
1060
+ throw outputLimit;
1061
+ };
1062
+ const command = startNativeCommand({
1063
+ executable: input.executable,
1064
+ args: [...input.args],
1065
+ cwd: input.cwd,
1066
+ env: { ...input.environment },
1067
+ envPolicy: "declared-only",
1068
+ signal: input.signal ?? new AbortController().signal,
1069
+ killGraceMs: 0,
1070
+ onOutput: (bytes, channel) => retain(channel === "stdout" ? stdout : stderr, channel === "stdout" ? artifactStdout : artifactStderr, bytes),
1071
+ onLeaderSettled: async (event) => {
1072
+ if (event.kind !== "exit")
1113
1073
  return;
1114
- outcome = reason;
1115
- if (!killOwnedProcessGroup())
1116
- child.kill("SIGKILL");
1117
- boundStreamSettlement();
1118
- };
1119
- const timer = setTimeout(() => terminate("timeout"), input.timeoutMs);
1120
- timer.unref();
1121
- const retain = (target, artifactTarget, chunk) => {
1122
- const remaining = Math.max(0, input.maxOutputBytes - retained);
1123
- if (remaining > 0) {
1124
- const kept = chunk.subarray(0, remaining);
1125
- target.push(kept);
1126
- retained += kept.byteLength;
1074
+ exitCode = event.exitCode;
1075
+ signal = event.signal;
1076
+ if (process.platform !== "win32")
1077
+ await stopCommandGroup(child?.pid, 0, input.terminationGraceMs, true);
1078
+ }
1079
+ }, (started) => {
1080
+ child = started;
1081
+ }, {
1082
+ group: process.platform !== "win32",
1083
+ force: true,
1084
+ timeoutMs: input.timeoutMs,
1085
+ cleanupTimeoutMs: input.terminationGraceMs,
1086
+ closeTimeoutMs: input.terminationGraceMs,
1087
+ ...launch ? {
1088
+ launch: () => {
1089
+ child = launch();
1090
+ return child;
1127
1091
  }
1128
- if (input.artifacts) {
1129
- const artifactRemaining = Math.max(0, artifactPayloadLimit - artifactBytes);
1130
- if (artifactRemaining > 0) {
1131
- const kept = chunk.subarray(0, artifactRemaining);
1132
- artifactTarget.push(kept);
1133
- artifactBytes += kept.byteLength;
1134
- }
1135
- if (chunk.byteLength > artifactRemaining)
1136
- terminate("output-limit");
1137
- } else if (chunk.byteLength > remaining)
1138
- terminate("output-limit");
1139
- };
1140
- child.stdout.on("data", (chunk) => retain(stdout, artifactStdout, Buffer.from(chunk)));
1141
- child.stderr.on("data", (chunk) => retain(stderr, artifactStderr, Buffer.from(chunk)));
1142
- child.on("error", (error) => {
1143
- if (settled)
1144
- return;
1145
- settled = true;
1146
- cleanup();
1147
- reject(error);
1148
- });
1149
- child.on("exit", (exitCode, signal) => {
1150
- if (outcome === "exited")
1151
- killOwnedProcessGroup();
1152
- boundStreamSettlement();
1153
- if (child.stdout.destroyed && child.stderr.destroyed) {
1154
- persistAndResolve(exitCode, signal);
1092
+ } : {},
1093
+ maxBufferedBytes: Math.max(64 * 1024, input.maxOutputBytes, input.artifacts ? artifactPayloadLimit : 0)
1094
+ });
1095
+ try {
1096
+ const result = await command.result;
1097
+ exitCode = result.exitCode;
1098
+ signal = result.signal;
1099
+ } catch (error) {
1100
+ if (error === outputLimit)
1101
+ outcome = "output-limit";
1102
+ else if (input.signal?.aborted && error === input.signal.reason)
1103
+ outcome = "cancelled";
1104
+ else if (error instanceof NativeCommandError2 && error.code === "COMMAND_LIMIT" && (error.reason === "deadline" || error.reason === "output-budget"))
1105
+ outcome = error.reason === "deadline" ? "timeout" : "output-limit";
1106
+ else if (error instanceof DOMException && error.name === "AbortError" && error.message === "Command stopped")
1107
+ outcome = "cancelled";
1108
+ else
1109
+ throw error;
1110
+ exitCode = child?.exitCode ?? exitCode;
1111
+ signal = child?.signalCode ?? signal;
1112
+ }
1113
+ const hasArtifact = input.artifacts && artifactBytes > input.maxOutputBytes;
1114
+ const completeStdout = Buffer.concat(artifactStdout);
1115
+ const completeStderr = Buffer.concat(artifactStderr);
1116
+ const artifactData = hasArtifact ? Buffer.concat([stdoutHeader, completeStdout, stderrHeader, completeStderr]) : undefined;
1117
+ const stdoutBudget = completeStderr.byteLength === 0 ? input.maxOutputBytes : Math.ceil(input.maxOutputBytes / 2);
1118
+ const stderrBudget = completeStdout.byteLength === 0 ? input.maxOutputBytes : Math.floor(input.maxOutputBytes / 2);
1119
+ const stdoutPreview = hasArtifact ? preview(completeStdout, stdoutBudget) : retainedPreview(Buffer.concat(stdout));
1120
+ const stderrPreview = hasArtifact ? preview(completeStderr, stderrBudget) : retainedPreview(Buffer.concat(stderr));
1121
+ const persisted = hasArtifact ? await input.artifacts?.write({
1122
+ mediaType: "text/plain; charset=utf-8",
1123
+ data: artifactData ?? new Uint8Array,
1124
+ ...input.authorization && { authorization: input.authorization }
1125
+ }) : undefined;
1126
+ return ShellOutputSchema.parse({
1127
+ executable: input.executableName,
1128
+ exitCode,
1129
+ signal,
1130
+ stdout: stdoutPreview.data.toString("utf8"),
1131
+ stderr: stderrPreview.data.toString("utf8"),
1132
+ outcome,
1133
+ ...persisted && {
1134
+ artifact: {
1135
+ reference: persisted.reference,
1136
+ bytes: artifactData?.byteLength ?? 0,
1137
+ truncated: outcome === "output-limit",
1138
+ headBytes: stdoutPreview.headBytes + stderrPreview.headBytes,
1139
+ tailBytes: stdoutPreview.tailBytes + stderrPreview.tailBytes,
1140
+ omittedBytes: stdoutPreview.omittedBytes + stderrPreview.omittedBytes
1155
1141
  }
1156
- });
1157
- child.on("close", (exitCode, signal) => void persistAndResolve(exitCode, signal));
1158
- input.signal?.addEventListener("abort", cancel, { once: true });
1159
- if (input.signal?.aborted)
1160
- cancel();
1142
+ }
1161
1143
  });
1162
1144
  }
1163
1145
 
@@ -0,0 +1,213 @@
1
+ import {
2
+ loadDarwinBinding
3
+ } from "./index-d4pa2bgs.js";
4
+ import {
5
+ isRecord
6
+ } from "./index-9jfdm5tg.js";
7
+
8
+ // src/internal/process-instance.ts
9
+ import { readFile as readFile2, readlink } from "node:fs/promises";
10
+ import { platform as platform2 } from "node:os";
11
+ import { z } from "zod";
12
+
13
+ // src/internal/process-identity.ts
14
+ import { execFile } from "node:child_process";
15
+ import { readFile } from "node:fs/promises";
16
+ import { platform } from "node:os";
17
+ import { promisify } from "node:util";
18
+ var detectedIdentity;
19
+ async function firstReadableLine(paths) {
20
+ for (const path of paths) {
21
+ try {
22
+ const text = (await readFile(path, "utf8")).trim();
23
+ if (text.length > 0)
24
+ return text;
25
+ } catch {}
26
+ }
27
+ return null;
28
+ }
29
+ var run = promisify(execFile);
30
+ function parsePlatformUuid(dump) {
31
+ return /"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(dump)?.[1] ?? null;
32
+ }
33
+ async function readDarwinPlatformUuid(command = "ioreg") {
34
+ try {
35
+ const { stdout } = await run(command, ["-rd1", "-c", "IOPlatformExpertDevice"], {
36
+ timeout: 2000,
37
+ maxBuffer: 1 << 20,
38
+ encoding: "utf8"
39
+ });
40
+ return parsePlatformUuid(stdout);
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+ async function machineIdentity(declared) {
46
+ if (declared !== undefined)
47
+ return declared;
48
+ if (detectedIdentity !== undefined)
49
+ return detectedIdentity;
50
+ detectedIdentity = platform() === "darwin" ? await readDarwinPlatformUuid() : await firstReadableLine(["/etc/machine-id", "/var/lib/dbus/machine-id"]);
51
+ return detectedIdentity;
52
+ }
53
+ async function probeLiveness(pid, reach = (target) => process.kill(target, 0)) {
54
+ try {
55
+ reach(pid);
56
+ } catch (error) {
57
+ return isRecord(error) && error.code === "ESRCH" ? "gone" : "alive";
58
+ }
59
+ return await isZombieProcess(pid) ? "gone" : "alive";
60
+ }
61
+ async function isZombieProcess(pid, seam = {}) {
62
+ const { procRoot = "/proc", psCommand = "ps" } = seam;
63
+ try {
64
+ const stat = await readFile(`${procRoot}/${pid}/stat`, "utf8");
65
+ return stat.slice(stat.lastIndexOf(")") + 1).trimStart().startsWith("Z");
66
+ } catch {}
67
+ try {
68
+ const { stdout } = await run(psCommand, ["-o", "state=", "-p", String(pid)], {
69
+ timeout: 2000,
70
+ maxBuffer: 1 << 16,
71
+ encoding: "utf8"
72
+ });
73
+ return stdout.trim().startsWith("Z");
74
+ } catch {
75
+ return false;
76
+ }
77
+ }
78
+
79
+ // src/internal/process-instance.ts
80
+ var ProcessInstanceSchema2 = z.object({
81
+ platform: z.enum(["linux", "darwin"]),
82
+ bootId: z.string().min(1),
83
+ namespace: z.string().min(1),
84
+ startId: z.string().regex(/^\d+$/)
85
+ }).strict();
86
+ var ProcessInstanceObservationSchema = z.discriminatedUnion("state", [
87
+ z.object({ state: z.literal("observed"), instance: ProcessInstanceSchema2 }),
88
+ z.object({ state: z.literal("unavailable"), cause: z.unknown() })
89
+ ]);
90
+ async function observeProcessInstance2(pid) {
91
+ z.number().int().positive().max(2147483647).parse(pid);
92
+ return observeProcessInstanceAt(pid, "/proc");
93
+ }
94
+ function linuxProcessStart(stat, pid) {
95
+ if (!stat.startsWith(`${pid} (`))
96
+ return null;
97
+ const end = stat.lastIndexOf(")");
98
+ if (end < 0)
99
+ return null;
100
+ const start = stat.slice(end + 1).trim().split(/\s+/)[19];
101
+ return start !== undefined && /^\d+$/.test(start) ? start : null;
102
+ }
103
+ async function readProcessInstance(pid, procRoot = "/proc") {
104
+ const result = await observeProcessInstanceAt(pid, procRoot);
105
+ return result.state === "observed" ? result.instance : null;
106
+ }
107
+ async function observeProcessInstanceAt(pid, procRoot) {
108
+ try {
109
+ if (platform2() === "darwin") {
110
+ return {
111
+ state: "observed",
112
+ instance: ProcessInstanceSchema2.parse(loadDarwinBinding().processIdentity(pid))
113
+ };
114
+ }
115
+ if (platform2() !== "linux")
116
+ throw new Error("Process lifetime observation requires Linux or Darwin");
117
+ const [bootId, namespace, ownStatus, timeNamespace, ownStat, stat] = await Promise.all([
118
+ readFile2(`${procRoot}/sys/kernel/random/boot_id`, "utf8"),
119
+ readlink(`${procRoot}/self/ns/pid`),
120
+ readFile2(`${procRoot}/self/status`, "utf8"),
121
+ readlink(`${procRoot}/self/ns/time`).catch((error) => {
122
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
123
+ return "";
124
+ throw error;
125
+ }),
126
+ readFile2(`${procRoot}/self/stat`, "utf8"),
127
+ readFile2(`${procRoot}/${pid}/stat`, "utf8")
128
+ ]);
129
+ const namespacePids = ownStatus.match(/^NStgid:[ \t]*(.*)$/m)?.[1]?.trim().split(/\s+/);
130
+ if (namespacePids?.length !== 1 || namespacePids[0] !== String(process.pid) || linuxProcessStart(ownStat, process.pid) === null)
131
+ throw new Error("Process namespace evidence is partial or belongs to a foreign proc mount");
132
+ const startId = linuxProcessStart(stat, pid);
133
+ if (startId === null || !bootId.trim())
134
+ throw new Error("Process boot/start evidence is incomplete");
135
+ return {
136
+ state: "observed",
137
+ instance: {
138
+ platform: "linux",
139
+ bootId: bootId.trim(),
140
+ namespace: `${namespace};${timeNamespace}`,
141
+ startId
142
+ }
143
+ };
144
+ } catch (cause) {
145
+ return { state: "unavailable", cause };
146
+ }
147
+ }
148
+ var ProcessOwnerEvidenceSchema = z.object({
149
+ liveness: z.enum(["alive", "gone", "not-probed"]),
150
+ identity: z.enum([
151
+ "matched",
152
+ "different-boot",
153
+ "reused-pid",
154
+ "pid-gone",
155
+ "legacy",
156
+ "unavailable"
157
+ ]),
158
+ cause: z.unknown().optional()
159
+ });
160
+ async function probeProcessOwner2(pid, recorded) {
161
+ z.number().int().positive().max(2147483647).parse(pid);
162
+ if (recorded != null)
163
+ ProcessInstanceSchema2.parse(recorded);
164
+ return probeProcessOwnerWith(pid, recorded, {
165
+ read: readProcessInstance,
166
+ observe: observeProcessInstance2,
167
+ liveness: probeLiveness
168
+ });
169
+ }
170
+ async function probeProcessOwnerWith(pid, recorded, probes = { read: readProcessInstance, liveness: probeLiveness }) {
171
+ if (recorded === undefined)
172
+ return { liveness: await probes.liveness(pid), identity: "legacy" };
173
+ const unavailable = (cause) => ({
174
+ liveness: "not-probed",
175
+ identity: "unavailable",
176
+ cause
177
+ });
178
+ if (recorded === null)
179
+ return unavailable(new Error("Recorded process lifetime is unavailable"));
180
+ const observe = async (target) => {
181
+ if (probes.observe)
182
+ return probes.observe(target);
183
+ const instance = await probes.read(target);
184
+ return instance ? { state: "observed", instance } : {
185
+ state: "unavailable",
186
+ cause: new Error("Process lifetime reader returned no evidence")
187
+ };
188
+ };
189
+ const own = await observe(process.pid);
190
+ if (own.state === "unavailable")
191
+ return unavailable(own.cause);
192
+ const current = own.instance;
193
+ if (recorded.platform !== current.platform)
194
+ return unavailable(new Error("Process platforms differ"));
195
+ if (recorded.bootId !== current.bootId)
196
+ return { liveness: "gone", identity: "different-boot" };
197
+ if (recorded.namespace !== current.namespace)
198
+ return unavailable(new Error("Process namespaces differ"));
199
+ const liveness = await probes.liveness(pid);
200
+ if (liveness === "gone")
201
+ return { liveness, identity: "pid-gone" };
202
+ const observation = await observe(pid);
203
+ if (observation.state === "unavailable")
204
+ return unavailable(observation.cause);
205
+ const observed = observation.instance;
206
+ if (!observed || observed.bootId !== current.bootId || observed.namespace !== current.namespace)
207
+ return unavailable(new Error("Observed boot or namespace changed during probe"));
208
+ if (recorded.startId !== observed.startId)
209
+ return { liveness: "gone", identity: "reused-pid" };
210
+ return { liveness: "alive", identity: "matched" };
211
+ }
212
+
213
+ export { machineIdentity, ProcessInstanceSchema2, observeProcessInstance2, readProcessInstance, probeProcessOwner2 };