hiveagents-runtime 0.0.0-stage → 0.1.0-beta.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/LICENSE +202 -0
- package/README.md +85 -2
- package/dist/adapter-kit.d.ts +37 -0
- package/dist/adapter-kit.js +33 -0
- package/dist/adapter-kit.js.map +1 -0
- package/dist/agent-D0HS38G3.d.ts +169 -0
- package/dist/agent-OLSXNGNN.js +23 -0
- package/dist/agent-OLSXNGNN.js.map +1 -0
- package/dist/agent-readiness-V36OJME4.js +19 -0
- package/dist/agent-readiness-V36OJME4.js.map +1 -0
- package/dist/capture-runtime-GP6NZ2ee.d.ts +54 -0
- package/dist/chunk-2RUEC63U.js +1217 -0
- package/dist/chunk-2RUEC63U.js.map +1 -0
- package/dist/chunk-3B3JW4U3.js +291 -0
- package/dist/chunk-3B3JW4U3.js.map +1 -0
- package/dist/chunk-3TIYA3K5.js +55 -0
- package/dist/chunk-3TIYA3K5.js.map +1 -0
- package/dist/chunk-6XIJW65Q.js +52 -0
- package/dist/chunk-6XIJW65Q.js.map +1 -0
- package/dist/chunk-7LDQKJKI.js +248 -0
- package/dist/chunk-7LDQKJKI.js.map +1 -0
- package/dist/chunk-ALLOMOUN.js +810 -0
- package/dist/chunk-ALLOMOUN.js.map +1 -0
- package/dist/chunk-C2DN6KL4.js +853 -0
- package/dist/chunk-C2DN6KL4.js.map +1 -0
- package/dist/chunk-COKYQUTK.js +581 -0
- package/dist/chunk-COKYQUTK.js.map +1 -0
- package/dist/chunk-CPN4DOXH.js +115 -0
- package/dist/chunk-CPN4DOXH.js.map +1 -0
- package/dist/chunk-DBFXFWQZ.js +385 -0
- package/dist/chunk-DBFXFWQZ.js.map +1 -0
- package/dist/chunk-DZFFGUIA.js +81 -0
- package/dist/chunk-DZFFGUIA.js.map +1 -0
- package/dist/chunk-EEUYQFCP.js +106 -0
- package/dist/chunk-EEUYQFCP.js.map +1 -0
- package/dist/chunk-GFVYNPLS.js +118 -0
- package/dist/chunk-GFVYNPLS.js.map +1 -0
- package/dist/chunk-GJ4FTDBJ.js +2910 -0
- package/dist/chunk-GJ4FTDBJ.js.map +1 -0
- package/dist/chunk-GS5U3KUN.js +201 -0
- package/dist/chunk-GS5U3KUN.js.map +1 -0
- package/dist/chunk-HB7FBSH2.js +960 -0
- package/dist/chunk-HB7FBSH2.js.map +1 -0
- package/dist/chunk-HZFZX5A3.js +21 -0
- package/dist/chunk-HZFZX5A3.js.map +1 -0
- package/dist/chunk-J7VAYJKM.js +595 -0
- package/dist/chunk-J7VAYJKM.js.map +1 -0
- package/dist/chunk-NCNSHOF7.js +52 -0
- package/dist/chunk-NCNSHOF7.js.map +1 -0
- package/dist/chunk-RXU2Q2HF.js +49 -0
- package/dist/chunk-RXU2Q2HF.js.map +1 -0
- package/dist/chunk-SRJUZJKV.js +521 -0
- package/dist/chunk-SRJUZJKV.js.map +1 -0
- package/dist/chunk-TG7NTMTR.js +208 -0
- package/dist/chunk-TG7NTMTR.js.map +1 -0
- package/dist/chunk-TIZKGD4R.js +202 -0
- package/dist/chunk-TIZKGD4R.js.map +1 -0
- package/dist/chunk-WMKO5XOE.js +601 -0
- package/dist/chunk-WMKO5XOE.js.map +1 -0
- package/dist/chunk-WOQBVJH5.js +175 -0
- package/dist/chunk-WOQBVJH5.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors-DgehLwqI.d.ts +98 -0
- package/dist/execution-halt-CW0Oi9s9.d.ts +12 -0
- package/dist/execution-types-UJ6gAF48.d.ts +239 -0
- package/dist/host-ledger-VPRWVVOS.js +25 -0
- package/dist/host-ledger-VPRWVVOS.js.map +1 -0
- package/dist/hosted-runtime.d.ts +168 -0
- package/dist/hosted-runtime.js +857 -0
- package/dist/hosted-runtime.js.map +1 -0
- package/dist/index-B86C6VAD.d.ts +41 -0
- package/dist/index.d.ts +327 -0
- package/dist/index.js +8818 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-items-BSTC0_R0.d.ts +28 -0
- package/dist/memory-tools.d.ts +222 -0
- package/dist/memory-tools.js +923 -0
- package/dist/memory-tools.js.map +1 -0
- package/dist/orchestration/dynamic.d.ts +854 -0
- package/dist/orchestration/dynamic.js +3150 -0
- package/dist/orchestration/dynamic.js.map +1 -0
- package/dist/orchestration/graph.d.ts +11 -0
- package/dist/orchestration/graph.js +9 -0
- package/dist/orchestration/graph.js.map +1 -0
- package/dist/orchestration/index.d.ts +2385 -0
- package/dist/orchestration/index.js +6403 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/log.d.ts +301 -0
- package/dist/orchestration/log.js +3058 -0
- package/dist/orchestration/log.js.map +1 -0
- package/dist/orchestration/memory.d.ts +711 -0
- package/dist/orchestration/memory.js +27 -0
- package/dist/orchestration/memory.js.map +1 -0
- package/dist/provider-XCpWjJ6a.d.ts +151 -0
- package/dist/routing/index.d.ts +29 -0
- package/dist/routing/index.js +385 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/learning/index.d.ts +433 -0
- package/dist/routing/learning/index.js +2501 -0
- package/dist/routing/learning/index.js.map +1 -0
- package/dist/runtime-C6Cu2fvw.d.ts +283 -0
- package/dist/runtime-Y72XJFFO.js +18 -0
- package/dist/runtime-Y72XJFFO.js.map +1 -0
- package/dist/store-types-2YdceOMy.d.ts +78 -0
- package/dist/types-BB7KqceP.d.ts +52 -0
- package/dist/types-BBRKjIc7.d.ts +86 -0
- package/dist/types-DTFc1qO6.d.ts +1065 -0
- package/dist/types-DYex3p7_.d.ts +88 -0
- package/docs/licenses/ruflo-memory-MIT.txt +21 -0
- package/docs/releases/0.1.0-beta.1.md +13 -0
- package/package.json +114 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/environment.ts"],"sourcesContent":["import type { EnvironmentPolicy } from '../public/types.js';\n\nconst MINIMAL_KEYS = [\n 'PATH',\n 'HOME',\n 'USER',\n 'LOGNAME',\n 'USERPROFILE',\n 'APPDATA',\n 'LOCALAPPDATA',\n 'XDG_CONFIG_HOME',\n 'XDG_DATA_HOME',\n 'XDG_CACHE_HOME',\n 'LANG',\n 'LC_ALL',\n 'TMPDIR',\n 'TEMP',\n 'TMP',\n 'SHELL',\n 'SystemRoot',\n 'ComSpec',\n] as const;\n\nconst BOOTSTRAP_KEYS = [\n 'PATH',\n 'HOME',\n 'USER',\n 'LOGNAME',\n 'USERPROFILE',\n 'APPDATA',\n 'LOCALAPPDATA',\n 'SystemRoot',\n 'ComSpec',\n] as const;\n\nfunction copyKeys(\n target: NodeJS.ProcessEnv,\n source: NodeJS.ProcessEnv,\n keys: readonly string[],\n): void {\n for (const key of keys) {\n const value = source[key];\n if (value !== undefined) target[key] = value;\n }\n}\n\nexport function buildEnvironment(\n policy: EnvironmentPolicy,\n base: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n const result: NodeJS.ProcessEnv = policy.mode === 'inherit' ? { ...base } : {};\n\n if (policy.mode === 'minimal') copyKeys(result, base, MINIMAL_KEYS);\n if (policy.mode === 'explicit') copyKeys(result, base, BOOTSTRAP_KEYS);\n copyKeys(result, base, policy.passthrough ?? []);\n\n for (const [key, value] of Object.entries(policy.variables ?? {})) {\n result[key] = value;\n }\n\n result.NO_COLOR = '1';\n result.FORCE_COLOR = '0';\n return result;\n}\n"],"mappings":";AAEA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,SACP,QACA,QACA,MACM;AACN,aAAW,OAAO,MAAM;AACtB,UAAM,QAAQ,OAAO,GAAG;AACxB,QAAI,UAAU,OAAW,QAAO,GAAG,IAAI;AAAA,EACzC;AACF;AAEO,SAAS,iBACd,QACA,OAA0B,QAAQ,KACf;AACnB,QAAM,SAA4B,OAAO,SAAS,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;AAE7E,MAAI,OAAO,SAAS,UAAW,UAAS,QAAQ,MAAM,YAAY;AAClE,MAAI,OAAO,SAAS,WAAY,UAAS,QAAQ,MAAM,cAAc;AACrE,WAAS,QAAQ,MAAM,OAAO,eAAe,CAAC,CAAC;AAE/C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,aAAa,CAAC,CAAC,GAAG;AACjE,WAAO,GAAG,IAAI;AAAA,EAChB;AAEA,SAAO,WAAW;AAClB,SAAO,cAAc;AACrB,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/public/memory-items.ts
|
|
2
|
+
var MEMORY_LABEL_MAX = 256;
|
|
3
|
+
var MEMORY_OBSERVED_AT_MAX = 64;
|
|
4
|
+
var UNSAFE_LABEL = new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]|\\p{Cs}|\\p{Cf}", "u");
|
|
5
|
+
var TAGS = /[\u{E0000}-\u{E007F}]/gu;
|
|
6
|
+
var BRACKETS = /[\p{Ps}\p{Pe}\u23A1-\u23A6\u23B4\u23B5]/u;
|
|
7
|
+
var ISO_8601 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:\d{2})$/;
|
|
8
|
+
function isMemoryLabel(value, max = MEMORY_LABEL_MAX) {
|
|
9
|
+
return typeof value === "string" && value.trim().length > 0 && value.length <= max && !UNSAFE_LABEL.test(value);
|
|
10
|
+
}
|
|
11
|
+
function bracketed(value) {
|
|
12
|
+
return BRACKETS.test(value.normalize("NFKC"));
|
|
13
|
+
}
|
|
14
|
+
function isMemoryHeaderLabel(value, max = MEMORY_LABEL_MAX) {
|
|
15
|
+
return isMemoryLabel(value, max) && !bracketed(value);
|
|
16
|
+
}
|
|
17
|
+
function instant(value) {
|
|
18
|
+
if (!ISO_8601.test(value)) return void 0;
|
|
19
|
+
const time = Date.parse(value);
|
|
20
|
+
return Number.isNaN(time) ? void 0 : new Date(time).toISOString();
|
|
21
|
+
}
|
|
22
|
+
function profileText(value) {
|
|
23
|
+
if (typeof value !== "string" || value.includes("\0")) return void 0;
|
|
24
|
+
const visible = value.replace(TAGS, "");
|
|
25
|
+
return visible.trim().length === 0 ? void 0 : visible;
|
|
26
|
+
}
|
|
27
|
+
function recallableMemory(value) {
|
|
28
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
29
|
+
const { id, text, title, source, observedAt } = value;
|
|
30
|
+
if (!isMemoryHeaderLabel(id) || !isMemoryHeaderLabel(source)) return void 0;
|
|
31
|
+
const observed = typeof observedAt === "string" && observedAt.length <= MEMORY_OBSERVED_AT_MAX ? instant(observedAt) : void 0;
|
|
32
|
+
if (observedAt !== void 0 && observed === void 0) return void 0;
|
|
33
|
+
const visible = profileText(text);
|
|
34
|
+
if (visible === void 0) return void 0;
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
text: visible,
|
|
38
|
+
source,
|
|
39
|
+
...isMemoryLabel(title) ? { title } : {},
|
|
40
|
+
...observed === void 0 ? {} : { observedAt: observed }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
MEMORY_LABEL_MAX,
|
|
46
|
+
MEMORY_OBSERVED_AT_MAX,
|
|
47
|
+
isMemoryLabel,
|
|
48
|
+
isMemoryHeaderLabel,
|
|
49
|
+
profileText,
|
|
50
|
+
recallableMemory
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-6XIJW65Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/public/memory-items.ts"],"sourcesContent":["import type { RecalledMemory } from './memory-types.js';\n\n/**\n * The rules a recalled item must meet before the SDK carries it to a model. Pure and\n * dependency-free, so a memory adapter can apply the same rules before it counts an item\n * against its limit, instead of returning something the SDK would then drop.\n */\n\n/** Longest id, source or title the SDK carries. */\nexport const MEMORY_LABEL_MAX = 256;\n/** Longest `observedAt` the SDK carries. */\nexport const MEMORY_OBSERVED_AT_MAX = 64;\n\n// C0 and C1 controls (every line break among them), the Unicode line and paragraph separators,\n// lone surrogates, and format characters: zero-width, bidi overrides and the tag block that\n// can carry text a model reads but a person reviewing the memory cannot see.\nconst UNSAFE_LABEL = /[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]|\\p{Cs}|\\p{Cf}/u;\n// Tag characters (U+E0000 to U+E007F) have no visible rendering anywhere; they are removed from text.\nconst TAGS = /[\\u{E0000}-\\u{E007F}]/gu;\n// id and source sit between square brackets on the SDK-owned item header. Any opening or closing\n// punctuation (ASCII brackets, parentheses and braces, and look-alikes such as fullwidth, white,\n// lenticular or tortoise-shell brackets), checked after NFKC folds compatibility forms, could\n// pass for the end of a field or the start of another one, so it drops the item.\n// Opening and closing punctuation, plus the bracket pieces of the math symbols block (⎡⎢⎣⎤⎥⎦⎴⎵),\n// which are Sm and survive NFKC but read as square brackets.\nconst BRACKETS = /[\\p{Ps}\\p{Pe}\\u23A1-\\u23A6\\u23B4\\u23B5]/u;\n// Strict ISO-8601 date and time with an explicit offset; the lenient Date.parse forms (with\n// \"(comments)\", or text before the date) never reach the header.\nconst ISO_8601 = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,9})?)?(Z|[+-]\\d{2}:\\d{2})$/;\n\n/** A non-empty single-line label of at most `max` characters with no control or invisible format character. */\nexport function isMemoryLabel(value: unknown, max = MEMORY_LABEL_MAX): value is string {\n return typeof value === 'string' && value.trim().length > 0 && value.length <= max && !UNSAFE_LABEL.test(value);\n}\n\nfunction bracketed(value: string): boolean { return BRACKETS.test(value.normalize('NFKC')); }\n\n/**\n * A label that may sit between square brackets on an SDK-owned header (an item's id and source,\n * the profile's source, which is the provider's id): a memory label with no opening or closing\n * punctuation after NFKC.\n */\nexport function isMemoryHeaderLabel(value: unknown, max = MEMORY_LABEL_MAX): value is string {\n return isMemoryLabel(value, max) && !bracketed(value);\n}\n\n/** `observedAt` as the header carries it (`Date.prototype.toISOString`), or undefined when it is not strict ISO-8601. */\nfunction instant(value: string): string | undefined {\n if (!ISO_8601.test(value)) return undefined;\n const time = Date.parse(value);\n return Number.isNaN(time) ? undefined : new Date(time).toISOString();\n}\n\n/**\n * A scope profile as the SDK will carry it, or undefined when it is unusable: not a string,\n * containing NUL, or empty or only whitespace once tag characters are removed. Tag characters\n * are removed; nothing else changes (every line is indented under the profile header when rendered).\n */\nexport function profileText(value: unknown): string | undefined {\n if (typeof value !== 'string' || value.includes('\\0')) return undefined;\n const visible = value.replace(TAGS, '');\n return visible.trim().length === 0 ? undefined : visible;\n}\n\n/**\n * The item as the SDK will carry it, or undefined when it must be dropped. An unusable title is\n * left out rather than dropping the item; an unusable id, source, observedAt or text drops it.\n * Tag characters are removed from the text; the text must still have something visible.\n * `observedAt` is carried normalized to `toISOString()` (UTC, milliseconds).\n */\nexport function recallableMemory(value: unknown): RecalledMemory | undefined {\n if (typeof value !== 'object' || value === null) return undefined;\n const { id, text, title, source, observedAt } = value as Partial<Record<keyof RecalledMemory, unknown>>;\n // id and source sit on the SDK-owned header between brackets: a bracket in them could forge a field.\n if (!isMemoryHeaderLabel(id) || !isMemoryHeaderLabel(source)) return undefined;\n const observed = typeof observedAt === 'string' && observedAt.length <= MEMORY_OBSERVED_AT_MAX ? instant(observedAt) : undefined;\n if (observedAt !== undefined && observed === undefined) return undefined;\n // The text follows the profile's rules: a string without NUL, with something visible once tags are removed.\n const visible = profileText(text);\n if (visible === undefined) return undefined;\n return {\n id, text: visible, source,\n ...(isMemoryLabel(title) ? { title } : {}),\n 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U,YAAY,IAAI;AAChC,MAAI,YAAY,OAAW,QAAO;AAClC,SAAO;AAAA,IACL;AAAA,IAAI,MAAM;AAAA,IAAS;AAAA,IACnB,GAAI,cAAc,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC;AAAA,IACxC,GAAI,aAAa,SAAY,CAAC,IAAI,EAAE,YAAY,SAAS;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbortError,
|
|
3
|
+
AgentRuntimeError,
|
|
4
|
+
OutputLimitError,
|
|
5
|
+
ProtocolError,
|
|
6
|
+
ProviderUnavailableError,
|
|
7
|
+
TimeoutError
|
|
8
|
+
} from "./chunk-TG7NTMTR.js";
|
|
9
|
+
|
|
10
|
+
// src/process/run-process.ts
|
|
11
|
+
import { spawn } from "node:child_process";
|
|
12
|
+
function signalProcessTree(child, signal, parentClosed = false) {
|
|
13
|
+
if (parentClosed || child.exitCode !== null || child.signalCode !== null) return;
|
|
14
|
+
if (process.platform !== "win32" && child.pid !== void 0) {
|
|
15
|
+
try {
|
|
16
|
+
process.kill(-child.pid, signal);
|
|
17
|
+
return;
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
child.kill(signal);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function forceKillWindowsTree(child) {
|
|
27
|
+
if (process.platform !== "win32" || child.pid === void 0 || child.exitCode !== null || child.signalCode !== null) return;
|
|
28
|
+
const killer = spawn("taskkill.exe", ["/pid", String(child.pid), "/t", "/f"], {
|
|
29
|
+
shell: false,
|
|
30
|
+
windowsHide: true,
|
|
31
|
+
stdio: "ignore"
|
|
32
|
+
});
|
|
33
|
+
killer.unref();
|
|
34
|
+
}
|
|
35
|
+
var MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
36
|
+
function validateTimeoutMs(timeoutMs) {
|
|
37
|
+
const value = timeoutMs ?? 6e5;
|
|
38
|
+
if (!Number.isInteger(value) || value < 1 || value > MAX_TIMEOUT_MS) {
|
|
39
|
+
throw new RangeError(`timeoutMs must be an integer between 1 and ${MAX_TIMEOUT_MS}`);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
async function runProcess(request) {
|
|
44
|
+
validateTimeoutMs(request.timeoutMs);
|
|
45
|
+
if (request.signal?.aborted) {
|
|
46
|
+
throw new AbortError({ retryable: true }, "Turn aborted before process start");
|
|
47
|
+
}
|
|
48
|
+
const startedAt = Date.now();
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
let stdoutBytes = 0;
|
|
51
|
+
let stderrBytes = 0;
|
|
52
|
+
const stdout = request.captureStdout === false ? void 0 : [];
|
|
53
|
+
const stderr = [];
|
|
54
|
+
let terminalError;
|
|
55
|
+
let settled = false;
|
|
56
|
+
let parentClosed = false;
|
|
57
|
+
let closeOutcome;
|
|
58
|
+
let pendingDelivery;
|
|
59
|
+
let deferredStdout;
|
|
60
|
+
const deliveryController = new AbortController();
|
|
61
|
+
let escalationTimer;
|
|
62
|
+
const child = spawn(request.command, request.args, {
|
|
63
|
+
cwd: request.cwd,
|
|
64
|
+
env: request.env,
|
|
65
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
66
|
+
shell: false,
|
|
67
|
+
windowsHide: true,
|
|
68
|
+
detached: process.platform !== "win32"
|
|
69
|
+
});
|
|
70
|
+
const startTermination = () => {
|
|
71
|
+
if (parentClosed || settled || child.exitCode !== null || child.signalCode !== null) return;
|
|
72
|
+
signalProcessTree(child, "SIGTERM", parentClosed);
|
|
73
|
+
if (escalationTimer !== void 0) clearTimeout(escalationTimer);
|
|
74
|
+
escalationTimer = setTimeout(() => {
|
|
75
|
+
escalationTimer = void 0;
|
|
76
|
+
if (process.platform === "win32") {
|
|
77
|
+
if (!parentClosed) forceKillWindowsTree(child);
|
|
78
|
+
} else signalProcessTree(child, "SIGKILL", parentClosed);
|
|
79
|
+
finishProcess();
|
|
80
|
+
}, request.killGraceMs ?? 100);
|
|
81
|
+
escalationTimer.unref();
|
|
82
|
+
};
|
|
83
|
+
const notifyFailure = (error) => {
|
|
84
|
+
try {
|
|
85
|
+
void Promise.resolve(request.onFailure?.(error)).catch(() => void 0);
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const terminate = () => {
|
|
90
|
+
if (parentClosed || settled) return;
|
|
91
|
+
startTermination();
|
|
92
|
+
};
|
|
93
|
+
const fail = (error) => {
|
|
94
|
+
if (terminalError) return;
|
|
95
|
+
terminalError = error;
|
|
96
|
+
notifyFailure(error);
|
|
97
|
+
deferredStdout = void 0;
|
|
98
|
+
deliveryController.abort(error);
|
|
99
|
+
child.stdout?.resume();
|
|
100
|
+
terminate();
|
|
101
|
+
finishProcess();
|
|
102
|
+
};
|
|
103
|
+
const exceedLimit = () => {
|
|
104
|
+
fail(new OutputLimitError(
|
|
105
|
+
{
|
|
106
|
+
retryable: false,
|
|
107
|
+
sanitizedDiagnostics: {
|
|
108
|
+
maxOutputBytes: request.maxOutputBytes,
|
|
109
|
+
observedOutputBytes: stdoutBytes + stderrBytes
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
));
|
|
113
|
+
};
|
|
114
|
+
const deliver = (sink, callback, value) => {
|
|
115
|
+
if (terminalError) return;
|
|
116
|
+
if (stdoutBytes + stderrBytes > request.maxOutputBytes) {
|
|
117
|
+
exceedLimit();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
sink?.push(value);
|
|
121
|
+
try {
|
|
122
|
+
callback?.(value);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
fail(error instanceof AgentRuntimeError ? error : new ProtocolError(
|
|
125
|
+
{
|
|
126
|
+
retryable: false,
|
|
127
|
+
sanitizedDiagnostics: { message: error instanceof Error ? error.message : String(error) }
|
|
128
|
+
},
|
|
129
|
+
"Provider output consumer failed"
|
|
130
|
+
));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const deliverAsync = (value) => {
|
|
134
|
+
deliver(stdout, void 0, value);
|
|
135
|
+
if (terminalError) {
|
|
136
|
+
child.stdout.resume();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
timeoutTimer.ref();
|
|
140
|
+
pendingDelivery = Promise.resolve().then(async () => {
|
|
141
|
+
if (!terminalError) await request.onStdoutAsync(value, deliveryController.signal);
|
|
142
|
+
});
|
|
143
|
+
void pendingDelivery.then(() => {
|
|
144
|
+
pendingDelivery = void 0;
|
|
145
|
+
const deferred = deferredStdout;
|
|
146
|
+
deferredStdout = void 0;
|
|
147
|
+
if (!terminalError && !settled) {
|
|
148
|
+
if (deferred) deliverAsync(deferred);
|
|
149
|
+
else child.stdout.resume();
|
|
150
|
+
}
|
|
151
|
+
finishProcess();
|
|
152
|
+
}, (error) => {
|
|
153
|
+
pendingDelivery = void 0;
|
|
154
|
+
fail(error instanceof AgentRuntimeError ? error : new ProtocolError(
|
|
155
|
+
{ retryable: false, sanitizedDiagnostics: { message: error instanceof Error ? error.message : String(error) } },
|
|
156
|
+
"Provider output consumer failed"
|
|
157
|
+
));
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
child.stdout?.on("data", (value) => {
|
|
161
|
+
stdoutBytes += value.byteLength;
|
|
162
|
+
if (!request.onStdoutAsync) {
|
|
163
|
+
deliver(stdout, request.onStdout, value);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (terminalError) return;
|
|
167
|
+
if (stdoutBytes + stderrBytes > request.maxOutputBytes) {
|
|
168
|
+
exceedLimit();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
child.stdout.pause();
|
|
172
|
+
if (pendingDelivery !== void 0) {
|
|
173
|
+
if (deferredStdout !== void 0) {
|
|
174
|
+
fail(new OutputLimitError({ retryable: false }, "Provider stdout exceeded its pending delivery buffer"));
|
|
175
|
+
} else deferredStdout = value;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
deliverAsync(value);
|
|
179
|
+
});
|
|
180
|
+
child.stderr?.on("data", (value) => {
|
|
181
|
+
stderrBytes += value.byteLength;
|
|
182
|
+
deliver(stderr, request.onStderr, value);
|
|
183
|
+
});
|
|
184
|
+
const timeoutTimer = setTimeout(() => fail(new TimeoutError(
|
|
185
|
+
{ retryable: true, sanitizedDiagnostics: { timeoutMs: request.timeoutMs } }
|
|
186
|
+
)), request.timeoutMs);
|
|
187
|
+
timeoutTimer.unref();
|
|
188
|
+
const onAbort = () => fail(new AbortError({ retryable: true }));
|
|
189
|
+
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
190
|
+
const cleanup = () => {
|
|
191
|
+
clearTimeout(timeoutTimer);
|
|
192
|
+
if (escalationTimer !== void 0) clearTimeout(escalationTimer);
|
|
193
|
+
request.signal?.removeEventListener("abort", onAbort);
|
|
194
|
+
};
|
|
195
|
+
child.once("error", (cause) => {
|
|
196
|
+
if (settled) return;
|
|
197
|
+
settled = true;
|
|
198
|
+
const hadFailure = terminalError !== void 0;
|
|
199
|
+
const failure = terminalError ?? new ProviderUnavailableError(
|
|
200
|
+
{ retryable: true, sanitizedDiagnostics: { command: request.command } },
|
|
201
|
+
`Unable to start provider process: ${cause.message}`
|
|
202
|
+
);
|
|
203
|
+
terminalError = failure;
|
|
204
|
+
if (!hadFailure) notifyFailure(failure);
|
|
205
|
+
deliveryController.abort(cause);
|
|
206
|
+
cleanup();
|
|
207
|
+
reject(failure);
|
|
208
|
+
});
|
|
209
|
+
function finishProcess() {
|
|
210
|
+
if (settled || closeOutcome === void 0) return;
|
|
211
|
+
if (!terminalError && pendingDelivery !== void 0) {
|
|
212
|
+
timeoutTimer.ref();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (terminalError && escalationTimer !== void 0) {
|
|
216
|
+
escalationTimer.ref();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
settled = true;
|
|
220
|
+
cleanup();
|
|
221
|
+
if (terminalError) {
|
|
222
|
+
reject(terminalError);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
resolve({
|
|
226
|
+
...closeOutcome,
|
|
227
|
+
stdout: stdout === void 0 ? "" : Buffer.concat(stdout).toString("utf8"),
|
|
228
|
+
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
229
|
+
durationMs: Date.now() - startedAt
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
child.once("close", (code, signal) => {
|
|
233
|
+
if (settled) return;
|
|
234
|
+
parentClosed = true;
|
|
235
|
+
closeOutcome = { code, signal };
|
|
236
|
+
finishProcess();
|
|
237
|
+
});
|
|
238
|
+
child.stdin?.once("error", () => {
|
|
239
|
+
});
|
|
240
|
+
child.stdin?.end(request.stdin);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export {
|
|
245
|
+
validateTimeoutMs,
|
|
246
|
+
runProcess
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=chunk-7LDQKJKI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/process/run-process.ts"],"sourcesContent":["import { spawn, type ChildProcess } from 'node:child_process';\n\nimport {\n AbortError as RuntimeAbortError,\n AgentRuntimeError,\n OutputLimitError,\n ProtocolError,\n ProviderUnavailableError,\n TimeoutError,\n} from '../public/errors.js';\n\nexport interface ProcessRequest {\n command: string;\n args: string[];\n cwd: string;\n env: NodeJS.ProcessEnv;\n stdin: string | Uint8Array;\n timeoutMs: number;\n maxOutputBytes: number;\n /** Defaults to true. False returns empty stdout without changing delivery or byte limits. */\n captureStdout?: boolean;\n signal?: AbortSignal;\n onStdout?: (chunk: Uint8Array) => void;\n /** Cooperative bounded delivery; preferred over onStdout when supplied. */\n onStdoutAsync?: (chunk: Uint8Array, deliverySignal: AbortSignal) => Promise<void>;\n onStderr?: (chunk: Uint8Array) => void;\n /** Synchronous notification of the first native failure, before bounded cleanup. */\n onFailure?: (error: AgentRuntimeError) => void | Promise<void>;\n killGraceMs?: number;\n}\n\nexport interface ProcessOutcome {\n code: number | null;\n signal: NodeJS.Signals | null;\n stdout: string;\n stderr: string;\n durationMs: number;\n}\n\nfunction signalProcessTree(child: ChildProcess, signal: NodeJS.Signals, parentClosed = false): void {\n // A saved PID/PGID loses its identity when the leader exits. Inherited\n // pipes do not establish ownership; only a surviving guardian can do that.\n if (parentClosed || child.exitCode !== null || child.signalCode !== null) return;\n if (process.platform !== 'win32' && child.pid !== undefined) {\n try {\n process.kill(-child.pid, signal);\n return;\n } catch {\n // The group can already be gone; fall through to the direct child.\n }\n }\n try {\n child.kill(signal);\n } catch {\n // The process already exited.\n }\n}\n\nfunction forceKillWindowsTree(child: ChildProcess): void {\n if (process.platform !== 'win32' || child.pid === undefined\n || child.exitCode !== null || child.signalCode !== null) return;\n const killer = spawn('taskkill.exe', ['/pid', String(child.pid), '/t', '/f'], {\n shell: false,\n windowsHide: true,\n stdio: 'ignore',\n });\n killer.unref();\n}\n\n/** Node timers silently clamp anything outside this range to 1 ms. */\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\n\nexport function validateTimeoutMs(timeoutMs: number | undefined): number {\n const value = timeoutMs ?? 600_000;\n if (!Number.isInteger(value) || value < 1 || value > MAX_TIMEOUT_MS) {\n throw new RangeError(`timeoutMs must be an integer between 1 and ${MAX_TIMEOUT_MS}`);\n }\n return value;\n}\n\nexport async function runProcess(request: ProcessRequest): Promise<ProcessOutcome> {\n validateTimeoutMs(request.timeoutMs);\n if (request.signal?.aborted) {\n throw new RuntimeAbortError({ retryable: true }, 'Turn aborted before process start');\n }\n\n const startedAt = Date.now();\n return new Promise<ProcessOutcome>((resolve, reject) => {\n let stdoutBytes = 0;\n let stderrBytes = 0;\n const stdout: Buffer[] | undefined = request.captureStdout === false ? undefined : [];\n const stderr: Buffer[] = [];\n let terminalError: AgentRuntimeError | undefined;\n let settled = false;\n let parentClosed = false;\n let closeOutcome: { code: number | null; signal: NodeJS.Signals | null } | undefined;\n let pendingDelivery: Promise<void> | undefined;\n let deferredStdout: Buffer | undefined;\n const deliveryController = new AbortController();\n let escalationTimer: NodeJS.Timeout | undefined;\n\n const child = spawn(request.command, request.args, {\n cwd: request.cwd,\n env: request.env,\n stdio: ['pipe', 'pipe', 'pipe'],\n shell: false,\n windowsHide: true,\n detached: process.platform !== 'win32',\n });\n\n const startTermination = (): void => {\n if (parentClosed || settled || child.exitCode !== null || child.signalCode !== null) return;\n signalProcessTree(child, 'SIGTERM', parentClosed);\n if (escalationTimer !== undefined) clearTimeout(escalationTimer);\n escalationTimer = setTimeout(() => {\n escalationTimer = undefined;\n if (process.platform === 'win32') {\n if (!parentClosed) forceKillWindowsTree(child);\n }\n else signalProcessTree(child, 'SIGKILL', parentClosed);\n finishProcess();\n }, request.killGraceMs ?? 100);\n escalationTimer.unref();\n };\n\n const notifyFailure = (error: AgentRuntimeError): void => {\n try { void Promise.resolve(request.onFailure?.(error)).catch(() => undefined); }\n catch { /* Observation cannot replace the native first cause. */ }\n };\n const terminate = (): void => {\n if (parentClosed || settled) return;\n // If the leader has exited, keep observing actual pipe settlement.\n // Do not guess ownership of its numeric group or destroy pipes as proof.\n startTermination();\n };\n\n const fail = (error: AgentRuntimeError): void => {\n if (terminalError) return;\n terminalError = error;\n notifyFailure(error);\n deferredStdout = undefined;\n deliveryController.abort(error);\n // Stop waiting for an abandoned/noncooperative sink. Drain the pipe so\n // child close and group cleanup remain observable; discard later bytes.\n child.stdout?.resume();\n terminate();\n finishProcess();\n };\n\n const exceedLimit = (): void => {\n fail(new OutputLimitError(\n {\n retryable: false,\n sanitizedDiagnostics: {\n maxOutputBytes: request.maxOutputBytes,\n observedOutputBytes: stdoutBytes + stderrBytes,\n },\n },\n ));\n };\n\n // A consumer callback runs inside the stream 'data' handler: anything it\n // throws would otherwise escape as an uncaughtException in the host while\n // the child keeps running. Its failure is terminal for the turn instead.\n const deliver = (\n sink: Buffer[] | undefined,\n callback: ((chunk: Uint8Array) => void) | undefined,\n value: Buffer,\n ): void => {\n if (terminalError) return;\n if (stdoutBytes + stderrBytes > request.maxOutputBytes) {\n exceedLimit();\n return;\n }\n sink?.push(value);\n try {\n callback?.(value);\n } catch (error) {\n fail(error instanceof AgentRuntimeError ? error : new ProtocolError(\n {\n retryable: false,\n sanitizedDiagnostics: { message: error instanceof Error ? error.message : String(error) },\n },\n 'Provider output consumer failed',\n ));\n }\n };\n\n const deliverAsync = (value: Buffer): void => {\n deliver(stdout, undefined, value);\n if (terminalError) { child.stdout.resume(); return; }\n // Pausing before invoking the sink leaves exactly one outstanding\n // delivery, with Node/OS pipe buffers providing bounded upstream storage.\n timeoutTimer.ref();\n pendingDelivery = Promise.resolve().then(async () => {\n if (!terminalError) await request.onStdoutAsync!(value, deliveryController.signal);\n });\n void pendingDelivery.then(() => {\n pendingDelivery = undefined;\n const deferred = deferredStdout; deferredStdout = undefined;\n if (!terminalError && !settled) {\n if (deferred) deliverAsync(deferred);\n else child.stdout.resume();\n }\n finishProcess();\n }, (error: unknown) => {\n pendingDelivery = undefined;\n fail(error instanceof AgentRuntimeError ? error : new ProtocolError(\n { retryable: false, sanitizedDiagnostics: { message: error instanceof Error ? error.message : String(error) } },\n 'Provider output consumer failed',\n ));\n });\n };\n child.stdout?.on('data', (value: Buffer) => {\n stdoutBytes += value.byteLength;\n if (!request.onStdoutAsync) { deliver(stdout, request.onStdout, value); return; }\n if (terminalError) return;\n if (stdoutBytes + stderrBytes > request.maxOutputBytes) { exceedLimit(); return; }\n child.stdout.pause();\n if (pendingDelivery !== undefined) {\n // Node's child-exit flush resumes stdio independently of our pause.\n // Retain at most that one read chunk, counted by the output fuse now,\n // and deliver it only after the current sink acknowledges.\n if (deferredStdout !== undefined) {\n fail(new OutputLimitError({ retryable: false }, 'Provider stdout exceeded its pending delivery buffer'));\n } else deferredStdout = value;\n return;\n }\n deliverAsync(value);\n });\n child.stderr?.on('data', (value: Buffer) => {\n stderrBytes += value.byteLength;\n deliver(stderr, request.onStderr, value);\n });\n\n // Both go through fail(): the first terminal error wins. A timer or abort\n // landing while the child is still closing after an OUTPUT_LIMIT must not\n // relabel it as a retryable TIMEOUT/ABORTED.\n const timeoutTimer = setTimeout(() => fail(new TimeoutError(\n { retryable: true, sanitizedDiagnostics: { timeoutMs: request.timeoutMs } },\n )), request.timeoutMs);\n timeoutTimer.unref();\n\n const onAbort = (): void => fail(new RuntimeAbortError({ retryable: true }));\n request.signal?.addEventListener('abort', onAbort, { once: true });\n\n const cleanup = (): void => {\n clearTimeout(timeoutTimer);\n if (escalationTimer !== undefined) clearTimeout(escalationTimer);\n request.signal?.removeEventListener('abort', onAbort);\n };\n\n child.once('error', (cause) => {\n if (settled) return;\n settled = true;\n const hadFailure = terminalError !== undefined;\n const failure = terminalError ?? new ProviderUnavailableError(\n { retryable: true, sanitizedDiagnostics: { command: request.command } },\n `Unable to start provider process: ${cause.message}`,\n );\n terminalError = failure;\n if (!hadFailure) notifyFailure(failure);\n deliveryController.abort(cause);\n cleanup();\n reject(failure);\n });\n\n function finishProcess(): void {\n if (settled || closeOutcome === undefined) return;\n // A clean close never cancels delivery. Keep the deadline alive until\n // every read byte is acknowledged, even after the child has exited.\n if (!terminalError && pendingDelivery !== undefined) { timeoutTimer.ref(); return; }\n if (terminalError && escalationTimer !== undefined) { escalationTimer.ref(); return; }\n settled = true;\n cleanup();\n if (terminalError) { reject(terminalError); return; }\n resolve({ ...closeOutcome, stdout: stdout === undefined ? '' : Buffer.concat(stdout).toString('utf8'),\n stderr: Buffer.concat(stderr).toString('utf8'), durationMs: Date.now() - startedAt });\n }\n\n child.once('close', (code, signal) => {\n if (settled) return;\n parentClosed = true;\n closeOutcome = { code, signal };\n // Escalation rechecks the live leader before every native signal.\n finishProcess();\n });\n\n child.stdin?.once('error', () => {\n // A provider may exit before consuming stdin; close/exit classification is authoritative.\n });\n child.stdin?.end(request.stdin);\n });\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,aAAgC;AAuCzC,SAAS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