@modootoday/pmcp 0.11.0 → 0.12.0

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.
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,118 @@
1
+ // src/harness/adapters/process/pane-runner.ts
2
+ import { spawn } from "child_process";
3
+ import { dirname as dirname2, join as join2 } from "path";
4
+
5
+ // src/harness/groups/store.ts
6
+ import { randomUUID } from "crypto";
7
+ import {
8
+ closeSync,
9
+ constants,
10
+ fstatSync,
11
+ fsyncSync,
12
+ openSync,
13
+ readFileSync,
14
+ realpathSync,
15
+ renameSync,
16
+ writeFileSync
17
+ } from "fs";
18
+ import { dirname, join } from "path";
19
+
20
+ // src/harness/validation.ts
21
+ function object(value) {
22
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
23
+ throw new Error("invalid_object");
24
+ }
25
+ return value;
26
+ }
27
+ function text(value, name) {
28
+ if (typeof value !== "string" || value.length === 0 || value.includes("\0")) {
29
+ throw new Error(`invalid_${name}`);
30
+ }
31
+ return value;
32
+ }
33
+ function strings(value, name) {
34
+ if (!Array.isArray(value) || value.length === 0 || value.length > 64) {
35
+ throw new Error(`invalid_${name}`);
36
+ }
37
+ return value.map((entry) => text(entry, name));
38
+ }
39
+
40
+ // src/harness/runtimes/docker-policy.ts
41
+ import { isAbsolute as isAbsolute3, posix as posix3 } from "path";
42
+
43
+ // src/harness/runtimes/egress-policy.ts
44
+ import { isAbsolute, posix } from "path";
45
+
46
+ // src/harness/runtimes/private-profiles.ts
47
+ import { isAbsolute as isAbsolute2, posix as posix2 } from "path";
48
+
49
+ // src/harness/groups/store.ts
50
+ function privateJson(path2, value) {
51
+ const temporary = `${path2}.${randomUUID()}.new`;
52
+ const descriptor = openSync(temporary, "wx", 384);
53
+ try {
54
+ writeFileSync(descriptor, `${JSON.stringify(value, null, 2)}
55
+ `);
56
+ fsyncSync(descriptor);
57
+ } finally {
58
+ closeSync(descriptor);
59
+ }
60
+ renameSync(temporary, path2);
61
+ const directory = openSync(dirname(path2), "r");
62
+ try {
63
+ fsyncSync(directory);
64
+ } finally {
65
+ closeSync(directory);
66
+ }
67
+ }
68
+ function readPrivateJson(path2) {
69
+ const descriptor = openSync(path2, constants.O_RDONLY | constants.O_NOFOLLOW);
70
+ try {
71
+ const stat = fstatSync(descriptor);
72
+ if (!stat.isFile() || (stat.mode & 63) !== 0 || stat.size > 2097152)
73
+ throw new Error("unsafe_state_file");
74
+ if (stat.uid !== process.getuid?.()) throw new Error("foreign_state_file");
75
+ return JSON.parse(readFileSync(descriptor, "utf8"));
76
+ } finally {
77
+ closeSync(descriptor);
78
+ }
79
+ }
80
+
81
+ // src/harness/adapters/process/pane-runner.ts
82
+ var path = text(process.argv[2], "launch_path");
83
+ var spec = object(readPrivateJson(path));
84
+ var argv = strings(spec.argv, "argv");
85
+ var witness = join2(
86
+ dirname2(path),
87
+ `${text(spec.id, "session_id")}.process.json`
88
+ );
89
+ var startedAt = (/* @__PURE__ */ new Date()).toISOString();
90
+ privateJson(witness, { id: spec.id, pid: process.pid, startedAt });
91
+ var child = spawn(text(argv[0], "runtime_executable"), argv.slice(1), {
92
+ cwd: text(spec.cwd, "cwd"),
93
+ stdio: "inherit",
94
+ env: process.env
95
+ });
96
+ process.on("SIGTERM", () => child.kill("SIGTERM"));
97
+ process.on("SIGINT", () => {
98
+ });
99
+ child.on("error", (error) => {
100
+ privateJson(witness, {
101
+ id: spec.id,
102
+ startedAt,
103
+ exitedAt: (/* @__PURE__ */ new Date()).toISOString(),
104
+ error: error.code
105
+ });
106
+ process.exitCode = 1;
107
+ });
108
+ child.on("exit", (code, signal) => {
109
+ privateJson(witness, {
110
+ id: spec.id,
111
+ startedAt,
112
+ exitedAt: (/* @__PURE__ */ new Date()).toISOString(),
113
+ code,
114
+ signal
115
+ });
116
+ process.exitCode = code ?? 1;
117
+ });
118
+ //# sourceMappingURL=harness-pane-runner.js.map
@@ -0,0 +1,2 @@
1
+
2
+ export { }