stitchkit 0.103.10 → 0.103.12
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 +32 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-owner.d.ts +1 -1
- package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
- package/dist/durability/json.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -1
- package/dist/entrypoints/agent-runtime/harness.js +2 -2
- package/dist/entrypoints/agent-runtime/sandbox.js +37 -19
- package/dist/entrypoints/agent-runtime.js +2 -2
- package/dist/entrypoints/application/diagnostic-journal.js +2 -2
- package/dist/entrypoints/files.js +8 -2
- package/dist/entrypoints/primitives.js +4 -3
- package/dist/entrypoints/process.js +1 -1
- package/dist/entrypoints/tools.js +1 -1
- package/dist/{index-ary5s7k0.js → index-69nvze1q.js} +1 -2
- package/dist/{index-a4ajxwmb.js → index-806d5phm.js} +114 -131
- package/dist/index-f330qqyg.js +653 -0
- package/dist/index-fm1c1a08.js +138 -0
- package/dist/index-xvdd2rbb.js +265 -0
- package/dist/{index-9jb61j5a.js → index-zp4jpkp0.js} +1 -1
- package/dist/internal/exclusive-lock-read.d.ts +20 -0
- package/dist/internal/exclusive-lock-read.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +2 -1
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/json-data.d.ts +8 -2
- package/dist/internal/json-data.d.ts.map +1 -1
- package/dist/internal/json-string-size.d.ts +3 -0
- package/dist/internal/json-string-size.d.ts.map +1 -0
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
- package/dist/primitives/canonical-json.d.ts.map +1 -1
- package/dist/process/cleanup.d.ts +12 -0
- package/dist/process/cleanup.d.ts.map +1 -0
- package/dist/process/command-lifetime.d.ts +19 -0
- package/dist/process/command-lifetime.d.ts.map +1 -0
- package/dist/process/command-owner.d.ts +4 -2
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/contract.d.ts +12 -1
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group.d.ts +6 -1
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/launch.d.ts +74 -0
- package/dist/process/launch.d.ts.map +1 -0
- package/dist/process/leader-settlement.d.ts +2 -0
- package/dist/process/leader-settlement.d.ts.map +1 -1
- package/dist/process/owned-child.d.ts +10 -0
- package/dist/process/owned-child.d.ts.map +1 -0
- package/dist/process/start-failure.d.ts +4 -0
- package/dist/process/start-failure.d.ts.map +1 -0
- package/dist/process/transport.d.ts +30 -0
- package/dist/process/transport.d.ts.map +1 -0
- package/llms/agent-runtime-sandbox.txt +9 -1
- package/llms/agent-runtime.txt +7 -1
- package/llms/process.txt +70 -7
- package/llms-full.txt +86 -9
- package/llms.txt +3 -3
- package/package.json +2 -2
- package/dist/index-6m6a9ty4.js +0 -285
- package/dist/index-c1jmtxa0.js +0 -74
- package/dist/index-ga597cvy.js +0 -184
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// src/internal/json-string-size.ts
|
|
2
|
+
function jsonStringSize(text, budget) {
|
|
3
|
+
if (text.length + 2 > budget)
|
|
4
|
+
return budget + 1;
|
|
5
|
+
let bytes = 2;
|
|
6
|
+
for (let index = 0;index < text.length && bytes <= budget; index++) {
|
|
7
|
+
const unit = text.charCodeAt(index);
|
|
8
|
+
if (unit === 34 || unit === 92)
|
|
9
|
+
bytes += 2;
|
|
10
|
+
else if (unit < 32)
|
|
11
|
+
bytes += unit === 8 || unit === 9 || unit === 10 || unit === 12 || unit === 13 ? 2 : 6;
|
|
12
|
+
else if (unit < 128)
|
|
13
|
+
bytes++;
|
|
14
|
+
else if (unit < 2048)
|
|
15
|
+
bytes += 2;
|
|
16
|
+
else if (unit >= 55296 && unit <= 56319) {
|
|
17
|
+
const next = text.charCodeAt(index + 1);
|
|
18
|
+
if (next >= 56320 && next <= 57343) {
|
|
19
|
+
bytes += 4;
|
|
20
|
+
index++;
|
|
21
|
+
} else
|
|
22
|
+
bytes += 6;
|
|
23
|
+
} else if (unit >= 56320 && unit <= 57343)
|
|
24
|
+
bytes += 6;
|
|
25
|
+
else
|
|
26
|
+
bytes += 3;
|
|
27
|
+
}
|
|
28
|
+
return bytes;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/internal/json-data.ts
|
|
32
|
+
function isJsonData(value, limits, snapshot) {
|
|
33
|
+
const ancestors = new Set;
|
|
34
|
+
let nodes = 0;
|
|
35
|
+
let bytes = 0;
|
|
36
|
+
const byteLimit = limits.maxBytes;
|
|
37
|
+
const charge = (amount) => {
|
|
38
|
+
if (byteLimit === undefined)
|
|
39
|
+
return true;
|
|
40
|
+
bytes += amount;
|
|
41
|
+
return bytes <= byteLimit;
|
|
42
|
+
};
|
|
43
|
+
const chargeText = (text) => byteLimit === undefined || charge(jsonStringSize(text, byteLimit - bytes));
|
|
44
|
+
const visit = (item, depth, target, key) => {
|
|
45
|
+
if (++nodes > limits.maxNodes || depth > limits.maxDepth)
|
|
46
|
+
return false;
|
|
47
|
+
let captured = item;
|
|
48
|
+
if (item === null) {
|
|
49
|
+
if (!charge(4))
|
|
50
|
+
return false;
|
|
51
|
+
} else if (typeof item === "string") {
|
|
52
|
+
if (!chargeText(item))
|
|
53
|
+
return false;
|
|
54
|
+
} else if (typeof item === "boolean") {
|
|
55
|
+
if (!charge(item ? 4 : 5))
|
|
56
|
+
return false;
|
|
57
|
+
} else if (typeof item === "number") {
|
|
58
|
+
if (!Number.isFinite(item) || Object.is(item, -0))
|
|
59
|
+
return false;
|
|
60
|
+
if (byteLimit !== undefined && !charge(String(item).length))
|
|
61
|
+
return false;
|
|
62
|
+
} else {
|
|
63
|
+
if (typeof item !== "object" || ancestors.has(item))
|
|
64
|
+
return false;
|
|
65
|
+
const array = Array.isArray(item);
|
|
66
|
+
const prototype = Object.getPrototypeOf(item);
|
|
67
|
+
if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null)
|
|
68
|
+
return false;
|
|
69
|
+
let length = 0;
|
|
70
|
+
if (array) {
|
|
71
|
+
const descriptor = Object.getOwnPropertyDescriptor(item, "length");
|
|
72
|
+
if (!descriptor || !("value" in descriptor))
|
|
73
|
+
return false;
|
|
74
|
+
const capturedLength = descriptor.value;
|
|
75
|
+
if (typeof capturedLength !== "number" || !Number.isInteger(capturedLength) || capturedLength < 0 || capturedLength > 2 ** 32 - 1)
|
|
76
|
+
return false;
|
|
77
|
+
length = capturedLength;
|
|
78
|
+
if (length > limits.maxNodes - nodes)
|
|
79
|
+
return false;
|
|
80
|
+
if (byteLimit !== undefined && Math.max(2, length * 2 + 1) > byteLimit - bytes)
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const keys = Reflect.ownKeys(item);
|
|
84
|
+
if (keys.length > limits.maxNodes - nodes + (array ? 1 : 0))
|
|
85
|
+
return false;
|
|
86
|
+
if (array && keys.length !== length + 1)
|
|
87
|
+
return false;
|
|
88
|
+
if (!charge(2))
|
|
89
|
+
return false;
|
|
90
|
+
const copy = target ? array ? [] : {} : undefined;
|
|
91
|
+
ancestors.add(item);
|
|
92
|
+
try {
|
|
93
|
+
let members = 0;
|
|
94
|
+
for (const memberKey of keys) {
|
|
95
|
+
if (array && memberKey === "length")
|
|
96
|
+
continue;
|
|
97
|
+
if (typeof memberKey !== "string")
|
|
98
|
+
return false;
|
|
99
|
+
if (array && (!/^(0|[1-9][0-9]*)$/.test(memberKey) || Number(memberKey) >= length))
|
|
100
|
+
return false;
|
|
101
|
+
const descriptor = Object.getOwnPropertyDescriptor(item, memberKey);
|
|
102
|
+
if (!descriptor?.enumerable || !("value" in descriptor))
|
|
103
|
+
return false;
|
|
104
|
+
const memberValue = descriptor.value;
|
|
105
|
+
if (!array && limits.omitObjectUndefined && memberValue === undefined) {
|
|
106
|
+
if (++nodes > limits.maxNodes)
|
|
107
|
+
return false;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (members++ > 0 && !charge(1))
|
|
111
|
+
return false;
|
|
112
|
+
if (!array && (!chargeText(memberKey) || !charge(1)))
|
|
113
|
+
return false;
|
|
114
|
+
if (!visit(memberValue, depth + 1, copy, memberKey))
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
captured = copy;
|
|
118
|
+
} finally {
|
|
119
|
+
ancestors.delete(item);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (target && key !== undefined)
|
|
123
|
+
Object.defineProperty(target, key, {
|
|
124
|
+
value: captured,
|
|
125
|
+
enumerable: true,
|
|
126
|
+
configurable: true,
|
|
127
|
+
writable: true
|
|
128
|
+
});
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
try {
|
|
132
|
+
return visit(value, 0, snapshot, "value");
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { isJsonData };
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import {
|
|
2
|
+
machineIdentity,
|
|
3
|
+
ProcessInstanceSchema2,
|
|
4
|
+
readProcessInstance,
|
|
5
|
+
probeProcessOwner2
|
|
6
|
+
} from "./index-nybn2err.js";
|
|
7
|
+
import {
|
|
8
|
+
isRecord
|
|
9
|
+
} from "./index-9jfdm5tg.js";
|
|
10
|
+
|
|
11
|
+
// src/internal/exclusive-lock.ts
|
|
12
|
+
import { lstat, open as open2, unlink } from "node:fs/promises";
|
|
13
|
+
import { hostname } from "node:os";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
|
|
16
|
+
// src/internal/exclusive-lock-read.ts
|
|
17
|
+
import { constants } from "node:fs";
|
|
18
|
+
import { open } from "node:fs/promises";
|
|
19
|
+
var OWNER_RECORD_BYTES = 16 * 1024;
|
|
20
|
+
|
|
21
|
+
class LockRecordError extends Error {
|
|
22
|
+
code;
|
|
23
|
+
name = "LockRecordError";
|
|
24
|
+
constructor(code, message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.code = code;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function readLockRecord(path, openDescriptor = open, signal) {
|
|
30
|
+
signal?.throwIfAborted();
|
|
31
|
+
if (!constants.O_NOFOLLOW || !constants.O_NONBLOCK) {
|
|
32
|
+
throw new LockRecordError("LOCK_UNSAFE_RECORD", "Safe lock descriptor flags are unavailable");
|
|
33
|
+
}
|
|
34
|
+
const handle = await openDescriptor(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
35
|
+
try {
|
|
36
|
+
signal?.throwIfAborted();
|
|
37
|
+
const before = await handle.stat();
|
|
38
|
+
signal?.throwIfAborted();
|
|
39
|
+
if (!before.isFile() || before.nlink !== 1) {
|
|
40
|
+
throw new LockRecordError("LOCK_UNSAFE_RECORD", "Lock record must be a regular file with one link");
|
|
41
|
+
}
|
|
42
|
+
if (before.size > OWNER_RECORD_BYTES) {
|
|
43
|
+
throw new LockRecordError("LOCK_RECORD_TOO_LARGE", "Lock owner record exceeds its byte cap");
|
|
44
|
+
}
|
|
45
|
+
const bytes = Buffer.alloc(OWNER_RECORD_BYTES + 1);
|
|
46
|
+
let length = 0;
|
|
47
|
+
while (length < bytes.length) {
|
|
48
|
+
signal?.throwIfAborted();
|
|
49
|
+
const read = await handle.read(bytes, length, bytes.length - length, length);
|
|
50
|
+
if (read.bytesRead === 0)
|
|
51
|
+
break;
|
|
52
|
+
length += read.bytesRead;
|
|
53
|
+
}
|
|
54
|
+
if (length > OWNER_RECORD_BYTES) {
|
|
55
|
+
throw new LockRecordError("LOCK_RECORD_TOO_LARGE", "Lock owner record grew beyond its byte cap");
|
|
56
|
+
}
|
|
57
|
+
const after = await handle.stat();
|
|
58
|
+
signal?.throwIfAborted();
|
|
59
|
+
if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs || before.nlink !== after.nlink || length !== after.size) {
|
|
60
|
+
throw new LockRecordError("LOCK_RECORD_CHANGED", "Lock owner record changed during its read");
|
|
61
|
+
}
|
|
62
|
+
return { text: bytes.subarray(0, length).toString("utf8"), info: after };
|
|
63
|
+
} finally {
|
|
64
|
+
await handle.close();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/internal/exclusive-lock.ts
|
|
69
|
+
var ExclusiveLockOwnerSchema = z.object({
|
|
70
|
+
pid: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
71
|
+
host: z.string().min(1),
|
|
72
|
+
acquiredAt: z.string(),
|
|
73
|
+
machine: z.string().min(1).optional().catch(undefined),
|
|
74
|
+
process: ProcessInstanceSchema2.nullable().optional().catch(null)
|
|
75
|
+
});
|
|
76
|
+
function isCode(error, code) {
|
|
77
|
+
return isRecord(error) && error.code === code;
|
|
78
|
+
}
|
|
79
|
+
function readOwner(text) {
|
|
80
|
+
let parsed;
|
|
81
|
+
try {
|
|
82
|
+
parsed = JSON.parse(text);
|
|
83
|
+
} catch {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const owner = ExclusiveLockOwnerSchema.safeParse(parsed);
|
|
87
|
+
return owner.success ? owner.data : undefined;
|
|
88
|
+
}
|
|
89
|
+
function attribute(owner, identity) {
|
|
90
|
+
if (identity !== null && owner.machine !== undefined) {
|
|
91
|
+
return owner.machine === identity ? "this-machine" : "another-machine";
|
|
92
|
+
}
|
|
93
|
+
return owner.host === hostname() ? "this-machine" : "unattributable";
|
|
94
|
+
}
|
|
95
|
+
async function diagnose(owner, declaredIdentity) {
|
|
96
|
+
if (!owner)
|
|
97
|
+
return { attribution: "unattributable", liveness: "not-probed", owner: null };
|
|
98
|
+
const attribution = attribute(owner, await machineIdentity(declaredIdentity));
|
|
99
|
+
if (attribution !== "this-machine")
|
|
100
|
+
return { attribution, liveness: "not-probed", owner };
|
|
101
|
+
return { attribution, ...await probeProcessOwner2(owner.pid, owner.process), owner };
|
|
102
|
+
}
|
|
103
|
+
var MAX_RECLAIM_DEPTH = 16;
|
|
104
|
+
async function readLockFile(path, onFailure, signal) {
|
|
105
|
+
try {
|
|
106
|
+
const record = await readLockRecord(path, undefined, signal);
|
|
107
|
+
return {
|
|
108
|
+
owner: readOwner(record.text),
|
|
109
|
+
ino: record.info.ino,
|
|
110
|
+
dev: record.info.dev,
|
|
111
|
+
mtimeMs: record.info.mtimeMs
|
|
112
|
+
};
|
|
113
|
+
} catch (cause) {
|
|
114
|
+
if (!isCode(cause, "ENOENT"))
|
|
115
|
+
onFailure?.(cause);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function unlinkIfSame(path, ino, dev) {
|
|
120
|
+
try {
|
|
121
|
+
const current = await lstat(path);
|
|
122
|
+
if (current.ino !== ino || current.dev !== dev || !current.isFile() || current.nlink !== 1)
|
|
123
|
+
return;
|
|
124
|
+
await unlink(path);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (!isCode(error, "ENOENT"))
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function createOwned(path, options, reclaimed) {
|
|
131
|
+
const identity = await machineIdentity(options.machineIdentity);
|
|
132
|
+
const instance = await readProcessInstance(process.pid);
|
|
133
|
+
const handle = await open2(path, "wx", options.mode);
|
|
134
|
+
const owner = {
|
|
135
|
+
pid: process.pid,
|
|
136
|
+
process: instance,
|
|
137
|
+
host: hostname(),
|
|
138
|
+
acquiredAt: new Date().toISOString(),
|
|
139
|
+
...identity !== null && { machine: identity }
|
|
140
|
+
};
|
|
141
|
+
let ino;
|
|
142
|
+
let dev;
|
|
143
|
+
try {
|
|
144
|
+
const info = await handle.stat();
|
|
145
|
+
ino = info.ino;
|
|
146
|
+
dev = info.dev;
|
|
147
|
+
await handle.chmod(options.mode);
|
|
148
|
+
await handle.writeFile(`${JSON.stringify(owner)}
|
|
149
|
+
`, "utf8");
|
|
150
|
+
} catch (error) {
|
|
151
|
+
await handle.close().catch(() => {
|
|
152
|
+
return;
|
|
153
|
+
});
|
|
154
|
+
if (ino !== undefined && dev !== undefined)
|
|
155
|
+
await unlinkIfSame(path, ino, dev).catch(() => {
|
|
156
|
+
return;
|
|
157
|
+
});
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
const ownedInode = ino;
|
|
161
|
+
const ownedDevice = dev;
|
|
162
|
+
let released = false;
|
|
163
|
+
return {
|
|
164
|
+
path,
|
|
165
|
+
owner,
|
|
166
|
+
reclaimed,
|
|
167
|
+
async release() {
|
|
168
|
+
if (released)
|
|
169
|
+
return;
|
|
170
|
+
released = true;
|
|
171
|
+
try {
|
|
172
|
+
await handle.close();
|
|
173
|
+
} finally {
|
|
174
|
+
await unlinkIfSame(path, ownedInode, ownedDevice);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function reclaimable(state, diagnosis, graceMs) {
|
|
180
|
+
if (state.owner)
|
|
181
|
+
return diagnosis.liveness === "gone";
|
|
182
|
+
return typeof graceMs === "number" && Date.now() - state.mtimeMs >= graceMs;
|
|
183
|
+
}
|
|
184
|
+
async function reclaimUnderGuard(path, options, depth) {
|
|
185
|
+
const guardPath = `${path}.reclaim`;
|
|
186
|
+
if (depth >= MAX_RECLAIM_DEPTH)
|
|
187
|
+
return {
|
|
188
|
+
refused: true,
|
|
189
|
+
cause: new Error(`Exclusive lock reclaim guard recovery depth exceeds ${MAX_RECLAIM_DEPTH}`)
|
|
190
|
+
};
|
|
191
|
+
let acquired;
|
|
192
|
+
try {
|
|
193
|
+
acquired = await attemptExclusiveLock(guardPath, {
|
|
194
|
+
...options,
|
|
195
|
+
ownerlessGraceMs: options.ownerlessGraceMs === undefined ? 5000 : options.ownerlessGraceMs
|
|
196
|
+
}, depth + 1);
|
|
197
|
+
} catch (cause) {
|
|
198
|
+
if (!isCode(cause, "ENAMETOOLONG"))
|
|
199
|
+
throw cause;
|
|
200
|
+
return { refused: true, cause };
|
|
201
|
+
}
|
|
202
|
+
if (!("held" in acquired))
|
|
203
|
+
return { refused: true, cause: acquired.diagnosis?.cause ?? acquired.error };
|
|
204
|
+
const guard = acquired.held;
|
|
205
|
+
try {
|
|
206
|
+
let readFailure;
|
|
207
|
+
const state = await readLockFile(path, (cause) => {
|
|
208
|
+
readFailure = cause;
|
|
209
|
+
}, options.signal);
|
|
210
|
+
if (readFailure !== undefined)
|
|
211
|
+
return { refused: true, cause: readFailure };
|
|
212
|
+
if (state) {
|
|
213
|
+
const diagnosis = await diagnose(state.owner, options.machineIdentity);
|
|
214
|
+
if (options.signal?.aborted)
|
|
215
|
+
return { refused: true };
|
|
216
|
+
if (!reclaimable(state, diagnosis, options.ownerlessGraceMs))
|
|
217
|
+
return { refused: true, cause: diagnosis.cause };
|
|
218
|
+
await unlinkIfSame(path, state.ino, state.dev);
|
|
219
|
+
}
|
|
220
|
+
return await createOwned(path, options, state !== undefined).catch((error) => {
|
|
221
|
+
if (isCode(error, "EEXIST"))
|
|
222
|
+
return { refused: true, cause: error };
|
|
223
|
+
throw error;
|
|
224
|
+
});
|
|
225
|
+
} finally {
|
|
226
|
+
await guard.release().catch(() => {
|
|
227
|
+
return;
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function attemptExclusiveLock(path, options, depth = 0) {
|
|
232
|
+
try {
|
|
233
|
+
return { held: await createOwned(path, options, false) };
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if (!isCode(error, "EEXIST"))
|
|
236
|
+
throw error;
|
|
237
|
+
if (!options.reclaim)
|
|
238
|
+
return { error };
|
|
239
|
+
let readFailure;
|
|
240
|
+
const state = await readLockFile(path, (cause) => {
|
|
241
|
+
readFailure = cause;
|
|
242
|
+
}, options.signal);
|
|
243
|
+
const diagnosis = {
|
|
244
|
+
...await diagnose(state?.owner, options.machineIdentity),
|
|
245
|
+
...readFailure !== undefined && { cause: readFailure }
|
|
246
|
+
};
|
|
247
|
+
if (options.signal?.aborted)
|
|
248
|
+
return { error, diagnosis };
|
|
249
|
+
if (!state || !reclaimable(state, diagnosis, options.ownerlessGraceMs)) {
|
|
250
|
+
return { error, diagnosis };
|
|
251
|
+
}
|
|
252
|
+
const reclaimed = await reclaimUnderGuard(path, options, depth);
|
|
253
|
+
if (!("refused" in reclaimed))
|
|
254
|
+
return { held: reclaimed };
|
|
255
|
+
return {
|
|
256
|
+
error,
|
|
257
|
+
diagnosis: {
|
|
258
|
+
...diagnosis,
|
|
259
|
+
...reclaimed.cause !== undefined && { cause: reclaimed.cause }
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { attemptExclusiveLock };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Stats } from 'node:fs';
|
|
2
|
+
interface LockRecordDescriptor {
|
|
3
|
+
stat(): Promise<Stats>;
|
|
4
|
+
read(buffer: Buffer, offset: number, length: number, position: number): Promise<{
|
|
5
|
+
bytesRead: number;
|
|
6
|
+
}>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare class LockRecordError extends Error {
|
|
10
|
+
readonly code: 'LOCK_UNSAFE_RECORD' | 'LOCK_RECORD_CHANGED' | 'LOCK_RECORD_TOO_LARGE';
|
|
11
|
+
name: string;
|
|
12
|
+
constructor(code: 'LOCK_UNSAFE_RECORD' | 'LOCK_RECORD_CHANGED' | 'LOCK_RECORD_TOO_LARGE', message: string);
|
|
13
|
+
}
|
|
14
|
+
/** A descriptor-bound observation, never a pathname stat followed by an unbounded read. */
|
|
15
|
+
export declare function readLockRecord(path: string, openDescriptor?: (path: string, flags: number) => Promise<LockRecordDescriptor>, signal?: AbortSignal): Promise<{
|
|
16
|
+
text: string;
|
|
17
|
+
info: Stats;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=exclusive-lock-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclusive-lock-read.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAMhD,UAAU,oBAAoB;IAC5B,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IACvB,IAAI,CACF,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,uBAAuB;IAF9E,IAAI,SAAqB;IAClC,YACW,IAAI,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,uBAAuB,EACrF,OAAO,EAAE,MAAM,EAGhB;CACF;AAED,2FAA2F;AAC3F,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAQ,EACrF,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC,CA8DxC"}
|
|
@@ -35,6 +35,7 @@ export interface HeldExclusiveLock {
|
|
|
35
35
|
release(): Promise<void>;
|
|
36
36
|
}
|
|
37
37
|
export interface ExclusiveLockAttemptOptions {
|
|
38
|
+
readonly signal?: AbortSignal;
|
|
38
39
|
readonly mode: number;
|
|
39
40
|
/** Take a lock whose owner is provably gone. `false` refuses every present lock. */
|
|
40
41
|
readonly reclaim: boolean;
|
|
@@ -58,7 +59,7 @@ export type ExclusiveLockAttempt = {
|
|
|
58
59
|
* its owner is provably gone. A refusal returns the create's own `EEXIST`, so a
|
|
59
60
|
* caller that surfaced that error keeps surfacing the identical one.
|
|
60
61
|
*/
|
|
61
|
-
export declare function attemptExclusiveLock(path: string, options: ExclusiveLockAttemptOptions): Promise<ExclusiveLockAttempt>;
|
|
62
|
+
export declare function attemptExclusiveLock(path: string, options: ExclusiveLockAttemptOptions, depth?: number): Promise<ExclusiveLockAttempt>;
|
|
62
63
|
/** Read the owner a present lock records, for a refusal that has to name it. */
|
|
63
64
|
export declare function readExclusiveLockOwner(path: string): Promise<ExclusiveLockOwner | null>;
|
|
64
65
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAEL,KAAK,oBAAoB,EAG1B,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,wCAAwC;AACxC,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,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAA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ereading the caller;
|
|
3
|
+
* predicate-only validation allocates no payload copy and skips absent byte accounting.
|
|
4
|
+
* Limits bound admitted data, not arbitrary JavaScript executed inside Proxy traps.
|
|
5
|
+
*/
|
|
2
6
|
export declare function isJsonData(value: unknown, limits: {
|
|
3
7
|
maxDepth: number;
|
|
4
8
|
maxNodes: number;
|
|
5
|
-
maxBytes
|
|
9
|
+
maxBytes?: number;
|
|
6
10
|
omitObjectUndefined: boolean;
|
|
11
|
+
}, snapshot?: {
|
|
12
|
+
value?: unknown;
|
|
7
13
|
}): boolean;
|
|
8
14
|
//# sourceMappingURL=json-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-data.d.ts","sourceRoot":"","sources":["../../src/internal/json-data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-data.d.ts","sourceRoot":"","sources":["../../src/internal/json-data.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,EACD,QAAQ,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7B,OAAO,CAgGT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-string-size.d.ts","sourceRoot":"","sources":["../../src/internal/json-string-size.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAoBnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/with-exclusive-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAC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AI,EAC1C,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAG9B;CACF;AAyCD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC5C,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,CAAC,CAAC,CAuEZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-json.d.ts","sourceRoot":"","sources":["../../src/primitives/canonical-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,0BAA0B;;;;kBAQ9B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"canonical-json.d.ts","sourceRoot":"","sources":["../../src/primitives/canonical-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,0BAA0B;;;;kBAQ9B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAQxF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NativeCommandSettlement } from './contract.js';
|
|
2
|
+
import type { NativeCommandTransport } from './transport.js';
|
|
3
|
+
/** One failure barrier, including a child whose transport setup never completed. */
|
|
4
|
+
export declare function cleanupNativeCommand(input: {
|
|
5
|
+
error: unknown;
|
|
6
|
+
transport?: NativeCommandTransport;
|
|
7
|
+
settle: (event: NativeCommandSettlement) => Promise<void>;
|
|
8
|
+
event?: NativeCommandSettlement;
|
|
9
|
+
signal: () => Promise<void>;
|
|
10
|
+
timeoutMs: number;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=cleanup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/process/cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,oFAAoF;AACpF,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,KAAK,CAAC,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type NativeCommandResult } from './contract.js';
|
|
2
|
+
/** Admission sees the same owner before transport setup and through terminal cleanup. */
|
|
3
|
+
export declare function createCommandLifetime(input: {
|
|
4
|
+
result: Promise<NativeCommandResult>;
|
|
5
|
+
controller: AbortController;
|
|
6
|
+
finished: () => boolean;
|
|
7
|
+
signal: () => Promise<void>;
|
|
8
|
+
cleanupTimeoutMs: number;
|
|
9
|
+
}): {
|
|
10
|
+
result: Promise<{
|
|
11
|
+
exitCode: number | null;
|
|
12
|
+
signal: string | null;
|
|
13
|
+
stdout: Uint8Array<ArrayBuffer>;
|
|
14
|
+
stderr: Uint8Array<ArrayBuffer>;
|
|
15
|
+
}>;
|
|
16
|
+
terminate(): Promise<void>;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=command-lifetime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-lifetime.d.ts","sourceRoot":"","sources":["../../src/process/command-lifetime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAG1E,yFAAyF;AACzF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrC,UAAU,EAAE,eAAe,CAAC;IAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;IAKG,MAAM;;;;;;IACA,SAAS;IAoBT,IAAI;EAMb"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
2
|
import { type NativeCommandOptions } from './contract.js';
|
|
3
|
+
import { type NativeCommandLaunchDriver } from './launch.js';
|
|
3
4
|
/** One-shot native execution; sandbox policy/admission is composed above this owner. */
|
|
4
|
-
export declare function startNativeCommand(input: NativeCommandOptions, onSpawn?: (child: ChildProcessWithoutNullStreams) => void): {
|
|
5
|
+
export declare function startNativeCommand(input: NativeCommandOptions, onSpawn?: (child: ChildProcessWithoutNullStreams) => void, driver?: NativeCommandLaunchDriver): {
|
|
5
6
|
result: Promise<{
|
|
6
7
|
exitCode: number | null;
|
|
7
8
|
signal: string | null;
|
|
8
9
|
stdout: Uint8Array<ArrayBuffer>;
|
|
9
10
|
stderr: Uint8Array<ArrayBuffer>;
|
|
10
11
|
}>;
|
|
12
|
+
terminate(): Promise<void>;
|
|
11
13
|
stop(): Promise<void>;
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=command-owner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-owner.d.ts","sourceRoot":"","sources":["../../src/process/command-owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"command-owner.d.ts","sourceRoot":"","sources":["../../src/process/command-owner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAIzE,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,KAAK,yBAAyB,EAG/B,MAAM,UAAU,CAAC;AAMlB,wFAAwF;AACxF,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,oBAAoB,EAC3B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,EACzD,MAAM,CAAC,EAAE,yBAAyB;;;;;;;;;EA4JnC"}
|
|
@@ -37,9 +37,20 @@ declare const NativeCommandResultSchema: z.ZodObject<{
|
|
|
37
37
|
stderr: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
|
|
38
38
|
}, z.core.$strip>;
|
|
39
39
|
export type NativeCommandResult = z.infer<typeof NativeCommandResultSchema>;
|
|
40
|
+
declare const NativeCommandLimitReasonSchema: z.ZodEnum<{
|
|
41
|
+
deadline: "deadline";
|
|
42
|
+
"output-budget": "output-budget";
|
|
43
|
+
}>;
|
|
40
44
|
export declare class NativeCommandError extends Error {
|
|
41
45
|
readonly code: 'COMMAND_LIMIT' | 'COMMAND_UNAVAILABLE' | 'COMMAND_CLEANUP';
|
|
42
|
-
|
|
46
|
+
/** Observed owner limit; absent on non-limit and caller-constructed errors without evidence. */
|
|
47
|
+
readonly reason: z.infer<typeof NativeCommandLimitReasonSchema> | undefined;
|
|
48
|
+
constructor(code: 'COMMAND_LIMIT', message: string, options?: ErrorOptions & {
|
|
49
|
+
reason?: z.infer<typeof NativeCommandLimitReasonSchema>;
|
|
50
|
+
});
|
|
51
|
+
constructor(code: 'COMMAND_LIMIT' | 'COMMAND_UNAVAILABLE' | 'COMMAND_CLEANUP', message: string, options?: ErrorOptions & {
|
|
52
|
+
reason?: never;
|
|
53
|
+
});
|
|
43
54
|
}
|
|
44
55
|
export {};
|
|
45
56
|
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/process/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,6BAA6B;;;;;;;2BAOjC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;gDAoBtB,UAAU,WACR,QAAQ,GAAG,QAAQ,UACpB,WAAW,KAChB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;uDAKX,uBAAuB,UAAU,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;;;kBAiBvF,CAAC;AACL,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACrF,QAAA,MAAM,yBAAyB;;;;;iBAK7B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,qBAAa,kBAAmB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/process/contract.ts"],"names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AAG;QAAE,MAAM,CAAC,EAAE,KAAK,CAAA;KAAE,EAC3C;CAeH"}
|
package/dist/process/group.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { NativeCommandError } from './contract.js';
|
|
2
|
+
/** Chain native-sized timers; internal callers retain their declared safe-integer deadline. */
|
|
3
|
+
export declare function createCommandDeadline(timeoutMs: number, reason: unknown): {
|
|
4
|
+
signal: AbortSignal;
|
|
5
|
+
cancel(): void;
|
|
6
|
+
};
|
|
2
7
|
export declare function signalGroup(pid: number | undefined, signal: NodeJS.Signals): void;
|
|
3
|
-
export declare function stopCommandGroup(pid: number | undefined, graceMs: number, cleanupTimeoutMs?: number): Promise<void>;
|
|
8
|
+
export declare function stopCommandGroup(pid: number | undefined, graceMs: number, cleanupTimeoutMs?: number, force?: boolean): Promise<void>;
|
|
4
9
|
export declare function commandCleanupError(cause: unknown): NativeCommandError;
|
|
5
10
|
export declare function waitForCommandClose<T>(closed: Promise<T>, timeoutMs: number): Promise<T>;
|
|
6
11
|
//# sourceMappingURL=group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/process/group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/process/group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,+FAA+F;AAC/F,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAapE,MAAM;IACN,MAAM;EAIT;AAWD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAOjF;AAmCD,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,MAAM,EACf,gBAAgB,SAAO,EACvB,KAAK,UAAQ,GACZ,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAItE;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAMxF"}
|