@vicary/pi-subagents 0.84.0-1 → 0.85.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.
- package/CHANGELOG.md +62 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-F4ASL6OV.js → chunk-7MAE3DJV.js} +1 -1
- package/bundle/{chunk-4MDR6V46.js → chunk-A7VJ5XXE.js} +190 -1177
- package/bundle/{chunk-LGLEH7B6.js → chunk-B3OOJJA6.js} +231 -182
- package/bundle/{chunk-4E7BKDTX.js → chunk-CS4O36CZ.js} +11 -156
- package/bundle/{chunk-G2Z6ZH26.js → chunk-GCSLVFCX.js} +1 -1
- package/bundle/{chunk-2S4K53MV.js → chunk-H2NLFTC5.js} +1 -1
- package/bundle/{chunk-T44HVL5U.js → chunk-HFTBF7SG.js} +2 -1
- package/bundle/{chunk-F4AMYP5N.js → chunk-HS4WPO6B.js} +15 -6
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-4NIY3BE6.js → chunk-JHBQ7N2L.js} +2 -2
- package/bundle/{chunk-HKJLSMXV.js → chunk-JO67XSKD.js} +59 -27
- package/bundle/{chunk-C5P5CHYK.js → chunk-KDMFBYFM.js} +1 -1
- package/bundle/{chunk-V2BZYLEP.js → chunk-KEY3UQMQ.js} +7 -2
- package/bundle/{chunk-NENDSQUY.js → chunk-KZ34KQQH.js} +9 -6
- package/bundle/{chunk-AKOIVLA5.js → chunk-L2ENOFVZ.js} +76 -58
- package/bundle/{chunk-CGN2TVE7.js → chunk-LGMILZNE.js} +322 -18
- package/bundle/{chunk-L3WFKBEI.js → chunk-LTPH2DXH.js} +247 -153
- package/bundle/{chunk-2D52JFLF.js → chunk-N7B2KD74.js} +41 -117
- package/bundle/{chunk-PV63UFUR.js → chunk-O7CPL6H4.js} +183 -28
- package/bundle/{chunk-D3JAFGMO.js → chunk-PHZP3KHB.js} +1 -1
- package/bundle/{chunk-2DHZTCOL.js → chunk-PVIVCDG2.js} +2 -2
- package/bundle/{chunk-LFDBD4PW.js → chunk-QO75KJBT.js} +2 -2
- package/bundle/{chunk-67ENPDDA.js → chunk-QZL2ZZPM.js} +22 -11
- package/bundle/{chunk-PALJGGYC.js → chunk-RV5OGHLO.js} +6 -3
- package/bundle/chunk-T5V5BRCL.js +1067 -0
- package/bundle/{chunk-LNRJCP2Y.js → chunk-UX4SCV5N.js} +337 -207
- package/bundle/{chunk-TE4LHYHN.js → chunk-VEZMZDTW.js} +209 -93
- package/bundle/{chunk-X2MXCSA5.js → chunk-YZBCREP5.js} +310 -101
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +17 -2
- package/docs/configuration.md +2 -2
- package/docs/extension-api.md +16 -1
- package/docs/workflows.md +30 -2
- package/package.json +2 -2
- package/src/agents/agent-management.js +27 -11
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agents.d.ts +1 -3
- package/src/agents/agents.js +7 -6
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/extension/config.js +7 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +43 -32
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +8 -3
- package/src/extension/schemas.js +5 -3
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +25 -11
- package/src/extension/tool-description.js +6 -0
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +5 -9
- package/src/runs/background/async-execution.js +62 -27
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +112 -39
- package/src/runs/background/async-retention.js +6 -1
- package/src/runs/background/auto-drain.js +2 -1
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +1 -1
- package/src/runs/background/run-status.js +4 -3
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/subagent-runner.d.ts +2 -4
- package/src/runs/background/subagent-runner.js +9 -6
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +17 -9
- package/src/runs/foreground/subagent-executor.d.ts +3 -2
- package/src/runs/foreground/subagent-executor.js +107 -26
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +21 -2
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +48 -22
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +2 -2
- package/src/runs/shared/model-resolution.js +7 -1
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +30 -2
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +4 -2
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +51 -0
- package/src/shared/fleet-transcript-reader.js +333 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/types.d.ts +28 -11
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +0 -14
- package/src/shared/utils.js +0 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -44
- package/src/tui/fleet-transcript.js +1 -327
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +81 -47
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.js +241 -20
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-resume-claim.js +2 -2
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +11 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +79 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
|
@@ -12,6 +12,11 @@ import {
|
|
|
12
12
|
normalizeCapabilityCeilingAllowedAgents
|
|
13
13
|
} from "./chunk-QXASAHIA.js";
|
|
14
14
|
|
|
15
|
+
// src/shared/atomic-json.ts
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import * as fs from "node:fs";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
|
|
15
20
|
// src/shared/file-system-retry.ts
|
|
16
21
|
var WAIT_BUFFER = typeof SharedArrayBuffer !== "undefined" ? new SharedArrayBuffer(4) : void 0;
|
|
17
22
|
var WAIT_VIEW = WAIT_BUFFER ? new Int32Array(WAIT_BUFFER) : void 0;
|
|
@@ -70,9 +75,6 @@ function runFileSystemOperationWithRetry(operation, options = {}) {
|
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
// src/shared/atomic-json.ts
|
|
73
|
-
import { createHash } from "node:crypto";
|
|
74
|
-
import * as fs from "node:fs";
|
|
75
|
-
import * as path from "node:path";
|
|
76
78
|
var MAX_PATH_COMPONENT_BYTES = 255;
|
|
77
79
|
function renameWithRetry(fsImpl, sourcePath, targetPath, retryDelaysMs, wait) {
|
|
78
80
|
runFileSystemOperationWithRetry(() => {
|
|
@@ -263,9 +265,9 @@ function externalCliReceiptMetadata(input) {
|
|
|
263
265
|
|
|
264
266
|
// src/agents/skills.ts
|
|
265
267
|
import { execSync as execSync2 } from "node:child_process";
|
|
266
|
-
import * as
|
|
267
|
-
import * as
|
|
268
|
-
import * as
|
|
268
|
+
import * as fs16 from "node:fs";
|
|
269
|
+
import * as os7 from "node:os";
|
|
270
|
+
import * as path17 from "node:path";
|
|
269
271
|
import { parse as parseYaml2 } from "yaml";
|
|
270
272
|
|
|
271
273
|
// src/agents/frontmatter.ts
|
|
@@ -278,12 +280,12 @@ function foldBlock(block) {
|
|
|
278
280
|
let previousIsMoreIndented = false;
|
|
279
281
|
let blankLines = 0;
|
|
280
282
|
for (const line of block.split("\n")) {
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
+
const current2 = line.trimEnd();
|
|
284
|
+
if (current2.trim() === "") {
|
|
283
285
|
if (hasContent) blankLines++;
|
|
284
286
|
continue;
|
|
285
287
|
}
|
|
286
|
-
const currentIsMoreIndented =
|
|
288
|
+
const currentIsMoreIndented = current2.length > current2.trimStart().length;
|
|
287
289
|
if (hasContent) {
|
|
288
290
|
if (blankLines > 0) {
|
|
289
291
|
folded += "\n".repeat(blankLines + (previousIsMoreIndented || currentIsMoreIndented ? 1 : 0));
|
|
@@ -291,7 +293,7 @@ function foldBlock(block) {
|
|
|
291
293
|
folded += previousIsMoreIndented || currentIsMoreIndented ? "\n" : " ";
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
|
-
folded +=
|
|
296
|
+
folded += current2;
|
|
295
297
|
hasContent = true;
|
|
296
298
|
previousIsMoreIndented = currentIsMoreIndented;
|
|
297
299
|
blankLines = 0;
|
|
@@ -392,15 +394,15 @@ function flushBlockLines(blockLines, folded, literal) {
|
|
|
392
394
|
}
|
|
393
395
|
|
|
394
396
|
// src/shared/utils.ts
|
|
397
|
+
import * as fs15 from "node:fs";
|
|
398
|
+
import * as os6 from "node:os";
|
|
399
|
+
import * as path16 from "node:path";
|
|
400
|
+
|
|
401
|
+
// src/shared/settings.ts
|
|
395
402
|
import * as fs14 from "node:fs";
|
|
396
403
|
import * as os5 from "node:os";
|
|
397
404
|
import * as path15 from "node:path";
|
|
398
405
|
|
|
399
|
-
// src/shared/settings.ts
|
|
400
|
-
import * as fs13 from "node:fs";
|
|
401
|
-
import * as os4 from "node:os";
|
|
402
|
-
import * as path14 from "node:path";
|
|
403
|
-
|
|
404
406
|
// src/agents/agents.ts
|
|
405
407
|
import { execSync } from "node:child_process";
|
|
406
408
|
import * as fs11 from "node:fs";
|
|
@@ -444,8 +446,8 @@ function deadOwner(owner) {
|
|
|
444
446
|
} catch (error) {
|
|
445
447
|
return error.code === "ESRCH";
|
|
446
448
|
}
|
|
447
|
-
const
|
|
448
|
-
return owner.processStart !== void 0 &&
|
|
449
|
+
const current2 = startIdentity(owner.pid);
|
|
450
|
+
return owner.processStart !== void 0 && current2 !== void 0 && owner.processStart !== current2;
|
|
449
451
|
}
|
|
450
452
|
function tryLease(lockPath) {
|
|
451
453
|
const owner = { token: randomUUID(), pid: process.pid, hostname: os.hostname(), processStart: startIdentity(process.pid) };
|
|
@@ -579,7 +581,7 @@ async function waitUntilGroupTerminal(processGroupId, timeoutMs) {
|
|
|
579
581
|
if (!Array.isArray(members)) return { state: "enumeration-failed", diagnostic: members.diagnostic };
|
|
580
582
|
return { state: "still-active", diagnostic: `Process group ${processGroupId} still has active members: ${members.join(", ")}.` };
|
|
581
583
|
}
|
|
582
|
-
await new Promise((
|
|
584
|
+
await new Promise((resolve12) => setTimeout(resolve12, Math.min(VERIFY_INTERVAL_MS, remaining)));
|
|
583
585
|
}
|
|
584
586
|
}
|
|
585
587
|
function observed(processGroupId) {
|
|
@@ -636,36 +638,36 @@ var MAX_EXTENSION_BINDINGS_BYTES = 16 * 1024;
|
|
|
636
638
|
var MAX_EXTENSION_BINDINGS_DEPTH = 16;
|
|
637
639
|
var MAX_EXTENSION_BINDINGS_PROPERTIES = 256;
|
|
638
640
|
var EXTENSION_BINDING_NAMESPACE = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,62})\/[1-9][0-9]{0,8}$/;
|
|
639
|
-
function canonicalizeJson(value,
|
|
641
|
+
function canonicalizeJson(value, path18, depth, seen, propertyCount) {
|
|
640
642
|
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
641
643
|
if (typeof value === "number") {
|
|
642
|
-
if (!Number.isFinite(value)) throw new Error(`${
|
|
644
|
+
if (!Number.isFinite(value)) throw new Error(`${path18} must contain only finite JSON numbers.`);
|
|
643
645
|
return value;
|
|
644
646
|
}
|
|
645
|
-
if (typeof value !== "object") throw new Error(`${
|
|
646
|
-
if (depth > MAX_EXTENSION_BINDINGS_DEPTH) throw new Error(`${
|
|
647
|
-
if (seen.has(value)) throw new Error(`${
|
|
647
|
+
if (typeof value !== "object") throw new Error(`${path18} must contain only plain JSON values.`);
|
|
648
|
+
if (depth > MAX_EXTENSION_BINDINGS_DEPTH) throw new Error(`${path18} exceeds the maximum nesting depth of ${MAX_EXTENSION_BINDINGS_DEPTH}.`);
|
|
649
|
+
if (seen.has(value)) throw new Error(`${path18} must not contain cycles.`);
|
|
648
650
|
seen.add(value);
|
|
649
651
|
try {
|
|
650
652
|
if (Array.isArray(value)) {
|
|
651
653
|
const output2 = [];
|
|
652
654
|
for (let index = 0; index < value.length; index++) {
|
|
653
|
-
if (!Object.prototype.hasOwnProperty.call(value, index)) throw new Error(`${
|
|
654
|
-
output2.push(canonicalizeJson(value[index], `${
|
|
655
|
+
if (!Object.prototype.hasOwnProperty.call(value, index)) throw new Error(`${path18} must not contain sparse arrays.`);
|
|
656
|
+
output2.push(canonicalizeJson(value[index], `${path18}[${index}]`, depth + 1, seen, propertyCount));
|
|
655
657
|
}
|
|
656
658
|
return Object.freeze(output2);
|
|
657
659
|
}
|
|
658
660
|
const prototype = Object.getPrototypeOf(value);
|
|
659
|
-
if (prototype !== Object.prototype && prototype !== null) throw new Error(`${
|
|
660
|
-
if (Object.getOwnPropertySymbols(value).length > 0) throw new Error(`${
|
|
661
|
+
if (prototype !== Object.prototype && prototype !== null) throw new Error(`${path18} must contain only plain JSON objects.`);
|
|
662
|
+
if (Object.getOwnPropertySymbols(value).length > 0) throw new Error(`${path18} must not contain symbol keys.`);
|
|
661
663
|
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
662
664
|
const output = {};
|
|
663
665
|
for (const key of Object.keys(descriptors).sort()) {
|
|
664
666
|
const descriptor = descriptors[key];
|
|
665
|
-
if (!descriptor.enumerable || !("value" in descriptor)) throw new Error(`${
|
|
667
|
+
if (!descriptor.enumerable || !("value" in descriptor)) throw new Error(`${path18}.${key} must be an enumerable data property.`);
|
|
666
668
|
propertyCount.value += 1;
|
|
667
669
|
if (propertyCount.value > MAX_EXTENSION_BINDINGS_PROPERTIES) throw new Error(`extensionBindings exceeds ${MAX_EXTENSION_BINDINGS_PROPERTIES} total properties.`);
|
|
668
|
-
Object.defineProperty(output, key, { value: canonicalizeJson(descriptor.value, `${
|
|
670
|
+
Object.defineProperty(output, key, { value: canonicalizeJson(descriptor.value, `${path18}.${key}`, depth + 1, seen, propertyCount), enumerable: true, writable: false, configurable: false });
|
|
669
671
|
}
|
|
670
672
|
return Object.freeze(output);
|
|
671
673
|
} finally {
|
|
@@ -792,7 +794,7 @@ var MAX_RAW_LOG_BYTES = 8 * 1024 * 1024;
|
|
|
792
794
|
var MAX_PARSER_LINE_BYTES = 256 * 1024;
|
|
793
795
|
var MAX_PARSER_STREAM_BYTES = 32 * 1024 * 1024;
|
|
794
796
|
var MAX_PARSER_OUTPUT_BYTES = 1024 * 1024;
|
|
795
|
-
var MAX_SKIPPABLE_LINE_BYTES = 1024 * 1024;
|
|
797
|
+
var MAX_SKIPPABLE_LINE_BYTES = 8 * 1024 * 1024;
|
|
796
798
|
|
|
797
799
|
// src/shared/model-info.ts
|
|
798
800
|
var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
@@ -1400,14 +1402,14 @@ function readPiPackageJson(packageJsonPath, readFileSync11 = (filePath, encoding
|
|
|
1400
1402
|
}
|
|
1401
1403
|
function selectPiPackage(deps) {
|
|
1402
1404
|
const existsSync10 = deps.existsSync ?? fs6.existsSync;
|
|
1403
|
-
const
|
|
1405
|
+
const realpathSync12 = deps.realpathSync ?? fs6.realpathSync;
|
|
1404
1406
|
const argv1 = deps.argv1 ?? process.argv[1];
|
|
1405
1407
|
const env = deps.env ?? process.env;
|
|
1406
1408
|
if (argv1) {
|
|
1407
1409
|
const argvPath = normalizePath(argv1);
|
|
1408
1410
|
if (isRunnableNodeScript(argvPath, existsSync10)) {
|
|
1409
1411
|
try {
|
|
1410
|
-
const canonicalArgvPath =
|
|
1412
|
+
const canonicalArgvPath = realpathSync12(argvPath);
|
|
1411
1413
|
const root2 = isRunnableNodeScript(canonicalArgvPath, existsSync10) ? findPiPackageRootFromEntry(canonicalArgvPath) : void 0;
|
|
1412
1414
|
if (root2) return { root: root2, cliScript: canonicalArgvPath };
|
|
1413
1415
|
} catch {
|
|
@@ -1589,6 +1591,8 @@ function createStructuredOutputToolParameters(schema, options = {}) {
|
|
|
1589
1591
|
};
|
|
1590
1592
|
}
|
|
1591
1593
|
var cachedCompile;
|
|
1594
|
+
var loadedCompile;
|
|
1595
|
+
var compileLoadError;
|
|
1592
1596
|
async function resolveCompileFromPackageRoot(packageRoot) {
|
|
1593
1597
|
const requireFromRoot = createRequire(path7.join(packageRoot, "package.json"));
|
|
1594
1598
|
const resolved = requireFromRoot.resolve("typebox/compile");
|
|
@@ -1624,23 +1628,30 @@ async function importCompile() {
|
|
|
1624
1628
|
}
|
|
1625
1629
|
function loadCompile() {
|
|
1626
1630
|
if (!cachedCompile) {
|
|
1627
|
-
cachedCompile = importCompile().
|
|
1631
|
+
cachedCompile = importCompile().then((compile) => {
|
|
1632
|
+
loadedCompile = compile;
|
|
1633
|
+
return compile;
|
|
1634
|
+
}, (error) => {
|
|
1628
1635
|
cachedCompile = void 0;
|
|
1636
|
+
compileLoadError = error;
|
|
1629
1637
|
throw error;
|
|
1630
1638
|
});
|
|
1631
1639
|
}
|
|
1632
1640
|
return cachedCompile;
|
|
1633
1641
|
}
|
|
1642
|
+
function structuredOutputValidatorReady() {
|
|
1643
|
+
return loadCompile().then(() => void 0, () => void 0);
|
|
1644
|
+
}
|
|
1634
1645
|
function jsonPointerTarget(root, pointer) {
|
|
1635
1646
|
if (pointer === "#") return root;
|
|
1636
1647
|
if (!pointer.startsWith("#/")) return void 0;
|
|
1637
|
-
let
|
|
1648
|
+
let current2 = root;
|
|
1638
1649
|
for (const encoded of pointer.slice(2).split("/")) {
|
|
1639
|
-
if (!
|
|
1650
|
+
if (!current2 || typeof current2 !== "object") return void 0;
|
|
1640
1651
|
const key = encoded.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1641
|
-
|
|
1652
|
+
current2 = current2[key];
|
|
1642
1653
|
}
|
|
1643
|
-
return
|
|
1654
|
+
return current2;
|
|
1644
1655
|
}
|
|
1645
1656
|
function resolveLocalRefs(root, node) {
|
|
1646
1657
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1785,7 +1796,16 @@ function createStructuredOutputRuntime(schema, baseDir, options = {}) {
|
|
|
1785
1796
|
};
|
|
1786
1797
|
}
|
|
1787
1798
|
async function validateStructuredOutputValue(schema, value) {
|
|
1788
|
-
|
|
1799
|
+
return validateWithCompile(await loadCompile(), schema, value);
|
|
1800
|
+
}
|
|
1801
|
+
function prepareStructuredOutputArguments(schema, args) {
|
|
1802
|
+
if (!args || typeof args !== "object" || !("value" in args)) return args;
|
|
1803
|
+
if (!loadedCompile) throw compileLoadError ?? new Error("Structured output validator is still loading; call structured_output again.");
|
|
1804
|
+
const validation = validateWithCompile(loadedCompile, schema, args.value);
|
|
1805
|
+
if (validation.status === "invalid") throw new Error(`Structured output validation failed: ${validation.message}`);
|
|
1806
|
+
return args;
|
|
1807
|
+
}
|
|
1808
|
+
function validateWithCompile(compile, schema, value) {
|
|
1789
1809
|
let validator;
|
|
1790
1810
|
try {
|
|
1791
1811
|
validator = compile(schema);
|
|
@@ -2173,9 +2193,9 @@ function acceptChildWatchdogEvent(input) {
|
|
|
2173
2193
|
...warnings?.length ? { warnings } : {}
|
|
2174
2194
|
};
|
|
2175
2195
|
}
|
|
2176
|
-
function applyChildWatchdogMessage(
|
|
2177
|
-
if (message?.role !== "assistant" || !
|
|
2178
|
-
return { ...
|
|
2196
|
+
function applyChildWatchdogMessage(current2, message) {
|
|
2197
|
+
if (message?.role !== "assistant" || !current2?.warnings?.some((entry) => !entry.addressed)) return void 0;
|
|
2198
|
+
return { ...current2, warnings: current2.warnings.map((entry) => entry.addressed ? entry : { ...entry, addressed: true }) };
|
|
2179
2199
|
}
|
|
2180
2200
|
function unresolvedChildWatchdogBlockers(progress) {
|
|
2181
2201
|
return (progress?.warnings ?? []).filter((warning) => warning.severity === "blocker" && (!warning.addressed || warning.stalemate));
|
|
@@ -3301,11 +3321,11 @@ function quoteExecutableForShell(command, platform = process.platform) {
|
|
|
3301
3321
|
const firstToken = trimmed.match(/^\S+/)?.[0];
|
|
3302
3322
|
if (/\.(?:exe|bat|cmd|com|ps1)$/i.test(firstToken ?? "")) return command;
|
|
3303
3323
|
const match = trimmed.match(/^([A-Za-z]:\\[^"<>|&*?\r\n]*?\s[^"<>|&*?\r\n]*?\\[^"<>|&*?\r\n]*?\.(?:exe|bat|cmd|com|ps1))(?=\s|$)/i);
|
|
3304
|
-
const
|
|
3305
|
-
if (
|
|
3306
|
-
const rest = trimmed.slice(
|
|
3324
|
+
const executable2 = match?.[1];
|
|
3325
|
+
if (executable2 && /\s/.test(executable2) && !/[A-Za-z]:\\/.test(executable2.slice(3))) {
|
|
3326
|
+
const rest = trimmed.slice(executable2.length);
|
|
3307
3327
|
const leading = command.slice(0, command.length - trimmed.length);
|
|
3308
|
-
return `${leading}"${
|
|
3328
|
+
return `${leading}"${executable2}"${rest}`;
|
|
3309
3329
|
}
|
|
3310
3330
|
const extensionlessSpacedFilenameMatch = trimmed.match(/^([A-Za-z]:\\[^"<>|&*?\r\n]*?\s[^"<>|&*?\r\n]*?)(?=\s+--|$)/i);
|
|
3311
3331
|
const extensionlessSpacedFilename = extensionlessSpacedFilenameMatch?.[1];
|
|
@@ -3324,7 +3344,7 @@ function quoteExecutableForShell(command, platform = process.platform) {
|
|
|
3324
3344
|
return command;
|
|
3325
3345
|
}
|
|
3326
3346
|
function runVerifyCommand(command, defaultCwd, options = {}) {
|
|
3327
|
-
return new Promise((
|
|
3347
|
+
return new Promise((resolve12) => {
|
|
3328
3348
|
const startedAt = Date.now();
|
|
3329
3349
|
const cwd = command.cwd ? path8.resolve(defaultCwd, command.cwd) : defaultCwd;
|
|
3330
3350
|
let stdout = "";
|
|
@@ -3345,7 +3365,7 @@ function runVerifyCommand(command, defaultCwd, options = {}) {
|
|
|
3345
3365
|
clearTimeout(timeout);
|
|
3346
3366
|
if (hardKill) clearTimeout(hardKill);
|
|
3347
3367
|
options.signal?.removeEventListener("abort", abortVerification);
|
|
3348
|
-
|
|
3368
|
+
resolve12({
|
|
3349
3369
|
id: command.id,
|
|
3350
3370
|
command: command.command,
|
|
3351
3371
|
cwd,
|
|
@@ -4030,11 +4050,11 @@ function resolveMemoryDir(rootDir, scopedPath) {
|
|
|
4030
4050
|
return { error: "memory root must not be a symlink" };
|
|
4031
4051
|
}
|
|
4032
4052
|
const rootReal = fs9.existsSync(rootDir) ? fs9.realpathSync(rootDir) : path9.resolve(rootDir);
|
|
4033
|
-
let
|
|
4053
|
+
let current2 = rootDir;
|
|
4034
4054
|
for (const segment of segments) {
|
|
4035
|
-
|
|
4036
|
-
if (!fs9.existsSync(
|
|
4037
|
-
const currentReal = fs9.realpathSync(
|
|
4055
|
+
current2 = path9.join(current2, segment);
|
|
4056
|
+
if (!fs9.existsSync(current2)) break;
|
|
4057
|
+
const currentReal = fs9.realpathSync(current2);
|
|
4038
4058
|
if (!isWithin(currentReal, rootReal)) {
|
|
4039
4059
|
return { error: "memory path resolves outside the memory root" };
|
|
4040
4060
|
}
|
|
@@ -4152,7 +4172,20 @@ function buildAgentMemoryInjection(agent, cwd) {
|
|
|
4152
4172
|
// src/runs/shared/permissions.ts
|
|
4153
4173
|
import * as fs10 from "node:fs";
|
|
4154
4174
|
import * as path10 from "node:path";
|
|
4155
|
-
|
|
4175
|
+
|
|
4176
|
+
// src/shared/wait-tool-name.ts
|
|
4177
|
+
var DEFAULT_WAIT_TOOL_NAME = "bg_wait";
|
|
4178
|
+
var current = DEFAULT_WAIT_TOOL_NAME;
|
|
4179
|
+
function waitToolName() {
|
|
4180
|
+
return current;
|
|
4181
|
+
}
|
|
4182
|
+
function setWaitToolName(name) {
|
|
4183
|
+
current = name;
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
// src/runs/shared/permissions.ts
|
|
4187
|
+
var COORDINATION_TOOLS = /* @__PURE__ */ new Set(["contact_supervisor", "intercom", "structured_output"]);
|
|
4188
|
+
var isInternalTool = (tool) => COORDINATION_TOOLS.has(tool) || tool === waitToolName();
|
|
4156
4189
|
var DECISIONS = /* @__PURE__ */ new Set(["allow", "ask", "deny"]);
|
|
4157
4190
|
var MAX_POLICY_BYTES = 16 * 1024;
|
|
4158
4191
|
var MAX_PREVIEW_BYTES = 2048;
|
|
@@ -4168,7 +4201,7 @@ function validatePermissionRules(value, label) {
|
|
|
4168
4201
|
for (const [tool, decision] of Object.entries(value)) {
|
|
4169
4202
|
if (!tool.trim()) throw new Error(`${label} contains an empty tool name.`);
|
|
4170
4203
|
if (tool === "bash") throw new Error(`${label}.bash is unsupported; pi-subagents leaves bash policy to pi-guard.`);
|
|
4171
|
-
if (
|
|
4204
|
+
if (isInternalTool(tool) || tool === DEFAULT_WAIT_TOOL_NAME) throw new Error(`${label}.${tool} is reserved for child coordination and cannot be gated.`);
|
|
4172
4205
|
if (!DECISIONS.has(decision)) throw new Error(`${label}.${tool} must be allow, ask, or deny.`);
|
|
4173
4206
|
result[tool] = decision;
|
|
4174
4207
|
}
|
|
@@ -4188,7 +4221,7 @@ function resolvePermissionRules(globalConfig, agentRules) {
|
|
|
4188
4221
|
return Object.keys(merged).length ? merged : void 0;
|
|
4189
4222
|
}
|
|
4190
4223
|
function permissionDecision(rules, toolName) {
|
|
4191
|
-
if (toolName === "bash" ||
|
|
4224
|
+
if (toolName === "bash" || isInternalTool(toolName)) return "allow";
|
|
4192
4225
|
return rules?.[toolName] ?? "allow";
|
|
4193
4226
|
}
|
|
4194
4227
|
function redact(value, key = "", depth = 0) {
|
|
@@ -5232,7 +5265,8 @@ function applyBuiltinOverride(agent, override, meta) {
|
|
|
5232
5265
|
...meta,
|
|
5233
5266
|
base: agent.override?.base ?? cloneOverrideBase(agent),
|
|
5234
5267
|
fields: [.../* @__PURE__ */ new Set([...agent.override?.fields ?? [], ...Object.keys(override)])].sort(),
|
|
5235
|
-
fieldScopes: Object.fromEntries(Object.entries({ ...agent.override?.fieldScopes ?? {} }).map(([field, scopes]) => [field, [...scopes]]))
|
|
5268
|
+
fieldScopes: Object.fromEntries(Object.entries({ ...agent.override?.fieldScopes ?? {} }).map(([field, scopes]) => [field, [...scopes]])),
|
|
5269
|
+
paths: { ...agent.override?.paths, [meta.scope]: meta.path }
|
|
5236
5270
|
};
|
|
5237
5271
|
for (const field of Object.keys(override)) {
|
|
5238
5272
|
const scopes = overrideInfo.fieldScopes[field] ?? [];
|
|
@@ -5334,10 +5368,12 @@ function applyBuiltinOverrides(builtinAgents, userSettings, projectSettings, use
|
|
|
5334
5368
|
};
|
|
5335
5369
|
return builtinAgents.map((agent) => {
|
|
5336
5370
|
const projectOverride = projectSettings.overrides[agent.name];
|
|
5371
|
+
const userOverride = userSettings.overrides[agent.name];
|
|
5337
5372
|
if (projectOverride && projectSettingsPath) {
|
|
5373
|
+
const withUserOverride = userOverride ? applyBuiltinOverride(agent, userOverride, { scope: "user", path: userSettingsPath }) : agent;
|
|
5338
5374
|
return applyGlobalThinking(
|
|
5339
|
-
applyBuiltinOverride(
|
|
5340
|
-
projectOverride.thinking !== void 0
|
|
5375
|
+
applyBuiltinOverride(withUserOverride, projectOverride, { scope: "project", path: projectSettingsPath }),
|
|
5376
|
+
projectOverride.thinking !== void 0 || !projectThinkingConfigured && userOverride?.thinking !== void 0
|
|
5341
5377
|
);
|
|
5342
5378
|
}
|
|
5343
5379
|
if (projectBulkDisabled && projectSettingsPath) {
|
|
@@ -5346,7 +5382,6 @@ function applyBuiltinOverrides(builtinAgents, userSettings, projectSettings, use
|
|
|
5346
5382
|
false
|
|
5347
5383
|
);
|
|
5348
5384
|
}
|
|
5349
|
-
const userOverride = userSettings.overrides[agent.name];
|
|
5350
5385
|
if (userOverride) {
|
|
5351
5386
|
return applyGlobalThinking(
|
|
5352
5387
|
applyBuiltinOverride(agent, userOverride, { scope: "user", path: userSettingsPath }),
|
|
@@ -5413,9 +5448,9 @@ function removeBuiltinAgentOverride(cwd, name, scope, options) {
|
|
|
5413
5448
|
const agentOverrides = nextSubagents.agentOverrides;
|
|
5414
5449
|
if (!agentOverrides || typeof agentOverrides !== "object" || Array.isArray(agentOverrides)) return { path: filePath, removed: false, machinePreserved: false };
|
|
5415
5450
|
const nextOverrides = { ...agentOverrides };
|
|
5416
|
-
const
|
|
5451
|
+
const current2 = nextOverrides[name];
|
|
5417
5452
|
if (!Object.prototype.hasOwnProperty.call(nextOverrides, name)) return { path: filePath, removed: false, machinePreserved: false };
|
|
5418
|
-
const configuredMachine =
|
|
5453
|
+
const configuredMachine = current2 && typeof current2 === "object" && !Array.isArray(current2) ? current2.machine : void 0;
|
|
5419
5454
|
const machine = configuredMachine === false || typeof configuredMachine === "string" && configuredMachine.trim() ? configuredMachine : void 0;
|
|
5420
5455
|
if (options?.preserveMachine && machine !== void 0) nextOverrides[name] = { machine };
|
|
5421
5456
|
else delete nextOverrides[name];
|
|
@@ -5555,11 +5590,11 @@ function inspectAgentDefinitionDirectory(dir, operations = DEFAULT_AGENT_DEFINIT
|
|
|
5555
5590
|
let unreadable = false;
|
|
5556
5591
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
5557
5592
|
const inspectedDirectories = /* @__PURE__ */ new Set();
|
|
5558
|
-
const visit = (
|
|
5559
|
-
inspectedDirectories.add(path11.resolve(
|
|
5593
|
+
const visit = (current2) => {
|
|
5594
|
+
inspectedDirectories.add(path11.resolve(current2));
|
|
5560
5595
|
let realDir;
|
|
5561
5596
|
try {
|
|
5562
|
-
realDir = operations.realpathSync?.(
|
|
5597
|
+
realDir = operations.realpathSync?.(current2) ?? path11.resolve(current2);
|
|
5563
5598
|
} catch {
|
|
5564
5599
|
unreadable = true;
|
|
5565
5600
|
return;
|
|
@@ -5568,13 +5603,13 @@ function inspectAgentDefinitionDirectory(dir, operations = DEFAULT_AGENT_DEFINIT
|
|
|
5568
5603
|
visitedDirectories.add(realDir);
|
|
5569
5604
|
let entries;
|
|
5570
5605
|
try {
|
|
5571
|
-
entries = operations.readdirSync(
|
|
5606
|
+
entries = operations.readdirSync(current2).sort((a, b) => a.name.localeCompare(b.name));
|
|
5572
5607
|
} catch {
|
|
5573
5608
|
unreadable = true;
|
|
5574
5609
|
return;
|
|
5575
5610
|
}
|
|
5576
5611
|
for (const entry of entries) {
|
|
5577
|
-
const filePath = path11.join(
|
|
5612
|
+
const filePath = path11.join(current2, entry.name);
|
|
5578
5613
|
if (isExcluded(filePath)) continue;
|
|
5579
5614
|
let isDirectory2 = entry.isDirectory();
|
|
5580
5615
|
if (entry.isSymbolicLink()) {
|
|
@@ -6058,11 +6093,11 @@ function addDirectoryWatchPaths(paths, root, files, directories = []) {
|
|
|
6058
6093
|
}
|
|
6059
6094
|
for (const file of files) {
|
|
6060
6095
|
paths.add(path11.resolve(file));
|
|
6061
|
-
let
|
|
6062
|
-
while (isPathWithin(resolvedRoot,
|
|
6063
|
-
paths.add(
|
|
6064
|
-
if (
|
|
6065
|
-
|
|
6096
|
+
let current2 = path11.resolve(path11.dirname(file));
|
|
6097
|
+
while (isPathWithin(resolvedRoot, current2)) {
|
|
6098
|
+
paths.add(current2);
|
|
6099
|
+
if (current2 === resolvedRoot) break;
|
|
6100
|
+
current2 = path11.dirname(current2);
|
|
6066
6101
|
}
|
|
6067
6102
|
}
|
|
6068
6103
|
}
|
|
@@ -6103,12 +6138,12 @@ function discoveryCacheKey(cwd, preferredModelProvider, globalNpmRoot, projectTr
|
|
|
6103
6138
|
}
|
|
6104
6139
|
function projectDiscoveryWatchPaths(cwd) {
|
|
6105
6140
|
const paths = [];
|
|
6106
|
-
let
|
|
6141
|
+
let current2 = path11.resolve(cwd);
|
|
6107
6142
|
while (true) {
|
|
6108
|
-
paths.push(getProjectConfigDir(
|
|
6109
|
-
const parent = path11.dirname(
|
|
6110
|
-
if (parent ===
|
|
6111
|
-
|
|
6143
|
+
paths.push(getProjectConfigDir(current2), path11.join(current2, ".agents"), path11.join(current2, ".git"));
|
|
6144
|
+
const parent = path11.dirname(current2);
|
|
6145
|
+
if (parent === current2) break;
|
|
6146
|
+
current2 = parent;
|
|
6112
6147
|
}
|
|
6113
6148
|
return paths;
|
|
6114
6149
|
}
|
|
@@ -6212,7 +6247,7 @@ function getAgentDiscoverySources(cwd, preferredModelProvider, includeChains = f
|
|
|
6212
6247
|
const key = discoveryCacheKey(cwd, preferredModelProvider, globalNpmRoot, projectTrusted);
|
|
6213
6248
|
const cached = agentDiscoveryCache.get(key);
|
|
6214
6249
|
if (cached && cached.fingerprint === discoveryFingerprint(cached.sources)) {
|
|
6215
|
-
if (includeChains) {
|
|
6250
|
+
if (includeChains && !cached.sources.userChains) {
|
|
6216
6251
|
ensureDiscoveryChains(cached.sources);
|
|
6217
6252
|
cached.fingerprint = discoveryFingerprint(cached.sources);
|
|
6218
6253
|
}
|
|
@@ -6446,11 +6481,82 @@ function discoverAgentsAll(cwd, preferredModelProvider, options = {}) {
|
|
|
6446
6481
|
}
|
|
6447
6482
|
|
|
6448
6483
|
// src/runs/shared/child-launch-plan.ts
|
|
6449
|
-
import * as
|
|
6484
|
+
import * as path14 from "node:path";
|
|
6450
6485
|
|
|
6451
6486
|
// src/runs/shared/single-output.ts
|
|
6487
|
+
import * as fs13 from "node:fs";
|
|
6488
|
+
import * as path13 from "node:path";
|
|
6489
|
+
|
|
6490
|
+
// src/runs/shared/rex-machine.ts
|
|
6491
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
6452
6492
|
import * as fs12 from "node:fs";
|
|
6493
|
+
import * as os4 from "node:os";
|
|
6453
6494
|
import * as path12 from "node:path";
|
|
6495
|
+
var REX_LOCAL_MACHINE = "local";
|
|
6496
|
+
var REX_EXIT_GONE = 3;
|
|
6497
|
+
var REX_EXIT_UNREACHABLE = 4;
|
|
6498
|
+
function isRexLocalMachine(machine) {
|
|
6499
|
+
return machine?.provider === "rex" && !("target" in machine);
|
|
6500
|
+
}
|
|
6501
|
+
var REX_BUNDLE_BIN = "Library/Application Support/com.superlogical.rex/RexServer/Versions/Current/Rex Server.app/Contents/MacOS/rex";
|
|
6502
|
+
var REX_CALL_TIMEOUT_MS = 15e3;
|
|
6503
|
+
var REX_MAX_OUTPUT = 1024 * 1024;
|
|
6504
|
+
function rexGlobalArgs(server) {
|
|
6505
|
+
return server ? ["--autostart=false", "-S", server] : ["--autostart=false"];
|
|
6506
|
+
}
|
|
6507
|
+
function executable(file) {
|
|
6508
|
+
try {
|
|
6509
|
+
fs12.accessSync(file, fs12.constants.X_OK);
|
|
6510
|
+
return fs12.statSync(file).isFile();
|
|
6511
|
+
} catch {
|
|
6512
|
+
return false;
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
function resolveRexBinary(env = process.env) {
|
|
6516
|
+
const fromDir = env.REX_BIN_DIR ? [path12.join(env.REX_BIN_DIR, "rex")] : [];
|
|
6517
|
+
const fromPath = (env.PATH ?? "").split(path12.delimiter).filter((dir) => path12.isAbsolute(dir)).map((dir) => path12.join(dir, "rex"));
|
|
6518
|
+
const found = [...fromDir, ...fromPath, path12.join(os4.homedir(), REX_BUNDLE_BIN)].find(executable);
|
|
6519
|
+
if (!found) throw new Error("The Rex CLI was not found: set REX_BIN_DIR, put rex on PATH, or install Rex.");
|
|
6520
|
+
return found;
|
|
6521
|
+
}
|
|
6522
|
+
function rexCommandEnv(source = process.env) {
|
|
6523
|
+
const { REX_SESSION: _session, REX_BLOCK: _block, REX_SERVER: _server, ...env } = source;
|
|
6524
|
+
return env;
|
|
6525
|
+
}
|
|
6526
|
+
function sessionConfirmed(stdout, session) {
|
|
6527
|
+
try {
|
|
6528
|
+
const parsed = JSON.parse(stdout);
|
|
6529
|
+
return parsed?.session_id === session;
|
|
6530
|
+
} catch {
|
|
6531
|
+
return false;
|
|
6532
|
+
}
|
|
6533
|
+
}
|
|
6534
|
+
function resolveRexLocalPlacement(input) {
|
|
6535
|
+
if (process.platform === "win32") throw new Error("Machine 'local' runs the child in a Rex pane, which is not supported on Windows.");
|
|
6536
|
+
const env = input.env ?? process.env, session = env.REX_SESSION?.trim(), server = env.REX_SERVER?.trim();
|
|
6537
|
+
if (!session) throw new Error("Machine 'local' opens the child in a new tab of this Rex session, but this Pi is not running inside Rex (REX_SESSION is not set).");
|
|
6538
|
+
const result = spawnSync4(resolveRexBinary(env), [...rexGlobalArgs(server), "session", "inspect", session, "--json"], { encoding: "utf8", env: rexCommandEnv(env), timeout: REX_CALL_TIMEOUT_MS, maxBuffer: REX_MAX_OUTPUT, windowsHide: true });
|
|
6539
|
+
if (result.error) throw new Error(`Could not ask Rex about this session: ${result.error.message}`, { cause: result.error });
|
|
6540
|
+
if (result.status === REX_EXIT_GONE) throw new Error(`Machine 'local' needs this Pi's Rex session, but the Rex server does not know session ${session}.`);
|
|
6541
|
+
if (result.status === REX_EXIT_UNREACHABLE) throw new Error("Machine 'local' needs the Rex server, but it is unreachable.");
|
|
6542
|
+
if (result.status !== 0) throw new Error(`rex session inspect exited with code ${result.status}: ${(result.stderr || result.stdout).trim().slice(0, 512)}`);
|
|
6543
|
+
if (!sessionConfirmed(result.stdout, session)) throw new Error(`The Rex server did not confirm session ${session}.`);
|
|
6544
|
+
const stepCwd = input.stepCwd?.trim();
|
|
6545
|
+
const home = stepCwd === "~" || stepCwd?.startsWith("~/") ? path12.join(os4.homedir(), stepCwd.slice(1)) : void 0;
|
|
6546
|
+
const requested = home ?? (stepCwd ? path12.resolve(input.cwd, stepCwd) : input.cwd);
|
|
6547
|
+
let cwd;
|
|
6548
|
+
try {
|
|
6549
|
+
cwd = fs12.realpathSync(requested);
|
|
6550
|
+
} catch (error) {
|
|
6551
|
+
throw new Error(`Machine 'local' cwd does not exist: ${requested}.`, { cause: error });
|
|
6552
|
+
}
|
|
6553
|
+
if (!fs12.statSync(cwd).isDirectory()) throw new Error(`Machine 'local' cwd is not a directory: ${requested}.`);
|
|
6554
|
+
const machine = { provider: "rex", id: REX_LOCAL_MACHINE, session, cwd };
|
|
6555
|
+
if (server) machine.server = server;
|
|
6556
|
+
return machine;
|
|
6557
|
+
}
|
|
6558
|
+
|
|
6559
|
+
// src/runs/shared/single-output.ts
|
|
6454
6560
|
var READ_ONLY_OUTPUT_TOOLS = /* @__PURE__ */ new Set([
|
|
6455
6561
|
"read",
|
|
6456
6562
|
"grep",
|
|
@@ -6479,7 +6585,7 @@ function snapshotFromStatError(error) {
|
|
|
6479
6585
|
}
|
|
6480
6586
|
function extractChildWrittenOutput(messages, outputPath, cwd) {
|
|
6481
6587
|
if (!messages?.length || !outputPath) return void 0;
|
|
6482
|
-
const resolvedTarget =
|
|
6588
|
+
const resolvedTarget = path13.resolve(cwd ?? ".", outputPath);
|
|
6483
6589
|
const comparableTarget = process.platform === "win32" ? resolvedTarget.toLowerCase() : resolvedTarget;
|
|
6484
6590
|
const successfulCallIds = /* @__PURE__ */ new Set();
|
|
6485
6591
|
for (const message of messages) {
|
|
@@ -6494,7 +6600,7 @@ function extractChildWrittenOutput(messages, outputPath, cwd) {
|
|
|
6494
6600
|
if (part.type !== "toolCall" || part.name !== "write" || !successfulCallIds.has(part.id)) continue;
|
|
6495
6601
|
const args = typeof part.arguments === "object" && part.arguments !== null && !Array.isArray(part.arguments) ? part.arguments : {};
|
|
6496
6602
|
if (typeof args.path !== "string" || typeof args.content !== "string") continue;
|
|
6497
|
-
const resolvedWritePath =
|
|
6603
|
+
const resolvedWritePath = path13.resolve(cwd ?? ".", args.path);
|
|
6498
6604
|
const comparableWritePath = process.platform === "win32" ? resolvedWritePath.toLowerCase() : resolvedWritePath;
|
|
6499
6605
|
if (comparableWritePath !== comparableTarget) continue;
|
|
6500
6606
|
content = args.content;
|
|
@@ -6510,10 +6616,10 @@ function normalizeSingleOutputOverride(output, defaultOutput) {
|
|
|
6510
6616
|
}
|
|
6511
6617
|
function resolveSingleOutputPath(output, runtimeCwd, requestedCwd, relativeBaseDir) {
|
|
6512
6618
|
if (typeof output !== "string" || !output || output === "false" || output === "true") return void 0;
|
|
6513
|
-
if (
|
|
6514
|
-
if (relativeBaseDir) return
|
|
6515
|
-
const baseCwd = requestedCwd ?
|
|
6516
|
-
return
|
|
6619
|
+
if (path13.isAbsolute(output)) return output;
|
|
6620
|
+
if (relativeBaseDir) return path13.resolve(relativeBaseDir, output);
|
|
6621
|
+
const baseCwd = requestedCwd ? path13.isAbsolute(requestedCwd) ? requestedCwd : path13.resolve(runtimeCwd, requestedCwd) : runtimeCwd;
|
|
6622
|
+
return path13.resolve(baseCwd, output);
|
|
6517
6623
|
}
|
|
6518
6624
|
function requestedOutputPathFromTask(task) {
|
|
6519
6625
|
for (const line of task.split(/\r?\n/).reverse()) {
|
|
@@ -6527,12 +6633,13 @@ function requestedOutputPathFromTask(task) {
|
|
|
6527
6633
|
function outputPathMappingFromTask(task, savedPath) {
|
|
6528
6634
|
const requestedPath = requestedOutputPathFromTask(task);
|
|
6529
6635
|
if (!requestedPath || !savedPath) return void 0;
|
|
6530
|
-
if (
|
|
6636
|
+
if (path13.isAbsolute(requestedPath) && path13.normalize(requestedPath) === path13.normalize(savedPath)) return void 0;
|
|
6531
6637
|
return { requestedPath, savedPath };
|
|
6532
6638
|
}
|
|
6533
|
-
function injectSingleOutputInstruction(task, outputPath, capabilities) {
|
|
6639
|
+
function injectSingleOutputInstruction(task, outputPath, capabilities, machine) {
|
|
6534
6640
|
if (!outputPath) return task;
|
|
6535
|
-
const
|
|
6641
|
+
const remote = machine !== void 0 && !isRexLocalMachine(machine);
|
|
6642
|
+
const delivery = !remote && (!capabilities || hasOutputWriteCapability(capabilities.tools, capabilities.mcpDirectTools)) ? `Write your findings to exactly this path: ${outputPath}` : [
|
|
6536
6643
|
"Return the complete artifact in your final response.",
|
|
6537
6644
|
`The runtime will persist it to exactly this path: ${outputPath}`,
|
|
6538
6645
|
"Do not call contact_supervisor merely because no write-capable tool is available."
|
|
@@ -6564,7 +6671,7 @@ function formatByteSize(bytes) {
|
|
|
6564
6671
|
return `${value.toFixed(1)} ${units[unitIndex]}`;
|
|
6565
6672
|
}
|
|
6566
6673
|
function formatSavedOutputReference(savedPath, fullOutput) {
|
|
6567
|
-
const absolutePath =
|
|
6674
|
+
const absolutePath = path13.resolve(savedPath);
|
|
6568
6675
|
const bytes = Buffer.byteLength(fullOutput, "utf-8");
|
|
6569
6676
|
const lines = countLines(fullOutput);
|
|
6570
6677
|
return {
|
|
@@ -6580,9 +6687,9 @@ var SAVED_OUTPUT_LINE = /\n\nOutput saved to: (.+) \([^()\n]*\)\. Read this file
|
|
|
6580
6687
|
var MAX_UNFILED_TRAILING_BLOCKS = 8;
|
|
6581
6688
|
function readFullOutputFile(filePath) {
|
|
6582
6689
|
try {
|
|
6583
|
-
const stat =
|
|
6690
|
+
const stat = fs13.statSync(filePath);
|
|
6584
6691
|
if (!stat.isFile() || stat.size > MAX_FULL_OUTPUT_FILE_BYTES) return void 0;
|
|
6585
|
-
return
|
|
6692
|
+
return fs13.readFileSync(filePath, "utf-8");
|
|
6586
6693
|
} catch {
|
|
6587
6694
|
return void 0;
|
|
6588
6695
|
}
|
|
@@ -6600,7 +6707,7 @@ function fileBackedHead(output, fullOutput, maxTrailingBlocks) {
|
|
|
6600
6707
|
}
|
|
6601
6708
|
function capInlineOutput(output, files) {
|
|
6602
6709
|
const match = files.savedPath ? output.match(SAVED_OUTPUT_LINE) : null;
|
|
6603
|
-
const savedLine = match && files.savedPath && match[1] ===
|
|
6710
|
+
const savedLine = match && files.savedPath && match[1] === path13.resolve(files.savedPath) ? match : void 0;
|
|
6604
6711
|
const body = savedLine ? output.slice(0, savedLine.index) : output;
|
|
6605
6712
|
const filePath = savedLine ? files.savedPath : files.artifactPath;
|
|
6606
6713
|
if (body.length <= INLINE_OUTPUT_HEAD_CHARS || !filePath) return output;
|
|
@@ -6640,15 +6747,15 @@ function validateFileOnlyOutputMode(outputMode, outputPath, context) {
|
|
|
6640
6747
|
return void 0;
|
|
6641
6748
|
}
|
|
6642
6749
|
function resolveSingleOutputClaimPath(outputPath) {
|
|
6643
|
-
let existing =
|
|
6750
|
+
let existing = path13.resolve(outputPath);
|
|
6644
6751
|
const missingSegments = [];
|
|
6645
|
-
while (!
|
|
6646
|
-
missingSegments.unshift(
|
|
6647
|
-
const parent =
|
|
6752
|
+
while (!fs13.existsSync(existing)) {
|
|
6753
|
+
missingSegments.unshift(path13.basename(existing));
|
|
6754
|
+
const parent = path13.dirname(existing);
|
|
6648
6755
|
if (parent === existing) break;
|
|
6649
6756
|
existing = parent;
|
|
6650
6757
|
}
|
|
6651
|
-
return
|
|
6758
|
+
return path13.join(fs13.realpathSync(existing), ...missingSegments);
|
|
6652
6759
|
}
|
|
6653
6760
|
function outputClaimError(outputPath, expectedClaimPath) {
|
|
6654
6761
|
if (expectedClaimPath && resolveSingleOutputClaimPath(outputPath) !== expectedClaimPath) return "Output path changed after it was claimed.";
|
|
@@ -6657,7 +6764,7 @@ function outputClaimError(outputPath, expectedClaimPath) {
|
|
|
6657
6764
|
function captureSingleOutputSnapshot(outputPath) {
|
|
6658
6765
|
if (!outputPath) return void 0;
|
|
6659
6766
|
try {
|
|
6660
|
-
const stat =
|
|
6767
|
+
const stat = fs13.statSync(outputPath);
|
|
6661
6768
|
return { exists: true, mtimeMs: stat.mtimeMs, size: stat.size };
|
|
6662
6769
|
} catch (error) {
|
|
6663
6770
|
return snapshotFromStatError(error);
|
|
@@ -6666,7 +6773,7 @@ function captureSingleOutputSnapshot(outputPath) {
|
|
|
6666
6773
|
function inspectSingleOutputChange(outputPath, beforeRun) {
|
|
6667
6774
|
if (beforeRun?.error) return { changed: false, error: beforeRun.error };
|
|
6668
6775
|
try {
|
|
6669
|
-
const stat =
|
|
6776
|
+
const stat = fs13.statSync(outputPath);
|
|
6670
6777
|
return {
|
|
6671
6778
|
changed: !beforeRun?.exists || stat.mtimeMs !== beforeRun.mtimeMs || stat.size !== beforeRun.size
|
|
6672
6779
|
};
|
|
@@ -6685,8 +6792,8 @@ function persistSingleOutput(outputPath, fullOutput, expectedClaimPath) {
|
|
|
6685
6792
|
try {
|
|
6686
6793
|
const claimError = outputClaimError(outputPath, expectedClaimPath);
|
|
6687
6794
|
if (claimError) return { error: claimError, fatalError: true };
|
|
6688
|
-
|
|
6689
|
-
|
|
6795
|
+
fs13.mkdirSync(path13.dirname(outputPath), { recursive: true });
|
|
6796
|
+
fs13.writeFileSync(outputPath, fullOutput, "utf-8");
|
|
6690
6797
|
return { savedPath: outputPath };
|
|
6691
6798
|
} catch (err) {
|
|
6692
6799
|
return { error: err instanceof Error ? err.message : String(err) };
|
|
@@ -6705,7 +6812,7 @@ function resolveSingleOutput(outputPath, fallbackOutput, beforeRun, expectedClai
|
|
|
6705
6812
|
}
|
|
6706
6813
|
if (changedSinceStart.changed) {
|
|
6707
6814
|
try {
|
|
6708
|
-
return { fullOutput:
|
|
6815
|
+
return { fullOutput: fs13.readFileSync(outputPath, "utf-8"), savedPath: outputPath };
|
|
6709
6816
|
} catch (error) {
|
|
6710
6817
|
return {
|
|
6711
6818
|
fullOutput: fallbackOutput,
|
|
@@ -6809,12 +6916,12 @@ function planChildLaunch(input) {
|
|
|
6809
6916
|
input.originalTask
|
|
6810
6917
|
);
|
|
6811
6918
|
const inheritedRelativeParallelOutput = Boolean(
|
|
6812
|
-
input.parallelOutputNamespace && input.stepOverrides.output === void 0 && typeof behavior.output === "string" && !
|
|
6919
|
+
input.parallelOutputNamespace && input.stepOverrides.output === void 0 && typeof behavior.output === "string" && !path14.isAbsolute(behavior.output)
|
|
6813
6920
|
);
|
|
6814
6921
|
if (inheritedRelativeParallelOutput && input.parallelOutputNamespace?.taskIndex !== void 0) {
|
|
6815
6922
|
behavior = {
|
|
6816
6923
|
...behavior,
|
|
6817
|
-
output:
|
|
6924
|
+
output: path14.join(
|
|
6818
6925
|
`parallel-${input.parallelOutputNamespace.stepIndex}`,
|
|
6819
6926
|
`${input.parallelOutputNamespace.taskIndex}-${input.agentConfig.name}`,
|
|
6820
6927
|
behavior.output
|
|
@@ -6846,8 +6953,8 @@ var Semaphore = class {
|
|
|
6846
6953
|
this.available--;
|
|
6847
6954
|
return Promise.resolve();
|
|
6848
6955
|
}
|
|
6849
|
-
return new Promise((
|
|
6850
|
-
this.queue.push(
|
|
6956
|
+
return new Promise((resolve12) => {
|
|
6957
|
+
this.queue.push(resolve12);
|
|
6851
6958
|
});
|
|
6852
6959
|
}
|
|
6853
6960
|
release() {
|
|
@@ -6879,47 +6986,47 @@ function getStepAgents(step) {
|
|
|
6879
6986
|
return [step.agent];
|
|
6880
6987
|
}
|
|
6881
6988
|
function cleanupOldChainDirs() {
|
|
6882
|
-
if (!
|
|
6989
|
+
if (!fs14.existsSync(CHAIN_RUNS_DIR)) return;
|
|
6883
6990
|
const now = Date.now();
|
|
6884
6991
|
let dirs;
|
|
6885
6992
|
try {
|
|
6886
|
-
dirs =
|
|
6993
|
+
dirs = fs14.readdirSync(CHAIN_RUNS_DIR);
|
|
6887
6994
|
} catch {
|
|
6888
6995
|
return;
|
|
6889
6996
|
}
|
|
6890
6997
|
for (const dir of dirs) {
|
|
6891
6998
|
try {
|
|
6892
|
-
const dirPath =
|
|
6893
|
-
const stat =
|
|
6999
|
+
const dirPath = path15.join(CHAIN_RUNS_DIR, dir);
|
|
7000
|
+
const stat = fs14.statSync(dirPath);
|
|
6894
7001
|
if (stat.isDirectory() && now - stat.mtimeMs > CHAIN_DIR_MAX_AGE_MS) {
|
|
6895
|
-
|
|
7002
|
+
fs14.rmSync(dirPath, { recursive: true });
|
|
6896
7003
|
}
|
|
6897
7004
|
} catch {
|
|
6898
7005
|
}
|
|
6899
7006
|
}
|
|
6900
7007
|
}
|
|
6901
7008
|
function expandHomePath(filePath) {
|
|
6902
|
-
if (filePath === "~") return
|
|
6903
|
-
if (filePath.startsWith("~/")) return
|
|
7009
|
+
if (filePath === "~") return os5.homedir();
|
|
7010
|
+
if (filePath.startsWith("~/")) return path15.join(os5.homedir(), filePath.slice(2));
|
|
6904
7011
|
return filePath;
|
|
6905
7012
|
}
|
|
6906
7013
|
function resolveChainPath(filePath, chainDir) {
|
|
6907
7014
|
const expanded = expandHomePath(filePath);
|
|
6908
|
-
return
|
|
7015
|
+
return path15.isAbsolute(expanded) ? expanded : path15.join(chainDir, expanded);
|
|
6909
7016
|
}
|
|
6910
7017
|
function resolveExistingReadInstructionPaths(reads, instructionCwd, existenceCwd = instructionCwd) {
|
|
6911
7018
|
return reads.flatMap((filePath) => {
|
|
6912
7019
|
const instructionPath = resolveChainPath(filePath, instructionCwd);
|
|
6913
7020
|
const existencePath = resolveChainPath(filePath, existenceCwd);
|
|
6914
|
-
return
|
|
7021
|
+
return fs14.existsSync(existencePath) ? [instructionPath] : [];
|
|
6915
7022
|
});
|
|
6916
7023
|
}
|
|
6917
7024
|
function resolveExistingReadPaths(reads, cwd) {
|
|
6918
7025
|
return resolveExistingReadInstructionPaths(reads, cwd);
|
|
6919
7026
|
}
|
|
6920
7027
|
function writeInitialProgressFile(progressDir) {
|
|
6921
|
-
|
|
6922
|
-
|
|
7028
|
+
fs14.mkdirSync(progressDir, { recursive: true });
|
|
7029
|
+
fs14.writeFileSync(path15.join(progressDir, "progress.md"), INITIAL_PROGRESS_CONTENT);
|
|
6923
7030
|
}
|
|
6924
7031
|
function buildChainInstructions(behavior, chainDir, isFirstProgressAgent, previousSummary, readExistenceDir = chainDir) {
|
|
6925
7032
|
const prefixParts = [];
|
|
@@ -6933,7 +7040,7 @@ function buildChainInstructions(behavior, chainDir, isFirstProgressAgent, previo
|
|
|
6933
7040
|
prefixParts.push(`[Write to: ${outputPath}]`);
|
|
6934
7041
|
}
|
|
6935
7042
|
if (behavior.progress) {
|
|
6936
|
-
const progressPath =
|
|
7043
|
+
const progressPath = path15.join(chainDir, "progress.md");
|
|
6937
7044
|
if (isFirstProgressAgent) {
|
|
6938
7045
|
suffixParts.push(`Create and maintain progress at: ${progressPath}`);
|
|
6939
7046
|
} else {
|
|
@@ -7286,6 +7393,11 @@ function closestModelCandidates(model, availableModels) {
|
|
|
7286
7393
|
};
|
|
7287
7394
|
}).filter((entry) => entry.sameId || entry.close).sort((left, right) => Number(right.sameId) - Number(left.sameId) || left.distance - right.distance || Number(right.sameProvider) - Number(left.sameProvider) || left.fullId.localeCompare(right.fullId)).slice(0, MAX_MODEL_CANDIDATES).map((entry) => `${entry.fullId}${thinkingSuffix}`);
|
|
7288
7395
|
}
|
|
7396
|
+
function isUnavailableSubagentModel(model, availableModels, preferredProvider) {
|
|
7397
|
+
const trimmed = model?.trim();
|
|
7398
|
+
if (!trimmed || trimmed === INHERIT_MODEL || !availableModels?.length) return false;
|
|
7399
|
+
return resolveSubagentModelCandidate(trimmed, availableModels, preferredProvider) === void 0;
|
|
7400
|
+
}
|
|
7289
7401
|
function resolveRequiredSubagentModelCandidate(model, availableModels, preferredProvider) {
|
|
7290
7402
|
const resolved = resolveSubagentModelCandidate(model, availableModels, preferredProvider);
|
|
7291
7403
|
if (resolved) return resolved;
|
|
@@ -7417,7 +7529,7 @@ var PI_CODING_AGENT_PACKAGE_ROOT_ENV = "PI_SUBAGENTS_PI_CODING_AGENT_PACKAGE_ROO
|
|
|
7417
7529
|
var PROMPT_REDACTED = "[prompt redacted]";
|
|
7418
7530
|
var SUBAGENT_STOPPED_MESSAGE = "Subagent stopped.";
|
|
7419
7531
|
var SUBAGENT_TIMED_OUT_MESSAGE = "Subagent timed out.";
|
|
7420
|
-
function resolveWatchPath(watchPath, nativeRealpath =
|
|
7532
|
+
function resolveWatchPath(watchPath, nativeRealpath = fs15.realpathSync.native) {
|
|
7421
7533
|
try {
|
|
7422
7534
|
return nativeRealpath(watchPath);
|
|
7423
7535
|
} catch {
|
|
@@ -7430,7 +7542,7 @@ function validConfigDirName(value) {
|
|
|
7430
7542
|
function readConfigDirNameFromPackageRoot(packageRoot) {
|
|
7431
7543
|
if (!packageRoot) return void 0;
|
|
7432
7544
|
try {
|
|
7433
|
-
const pkg = JSON.parse(
|
|
7545
|
+
const pkg = JSON.parse(fs15.readFileSync(path16.join(packageRoot, "package.json"), "utf-8"));
|
|
7434
7546
|
if (pkg.name !== PI_CODING_AGENT_PACKAGE_NAME) return void 0;
|
|
7435
7547
|
return validConfigDirName(pkg.piConfig?.configDir);
|
|
7436
7548
|
} catch {
|
|
@@ -7442,11 +7554,11 @@ function resolveConfigDirNameFromPackageJson(entryPoint = process.argv[1], packa
|
|
|
7442
7554
|
if (packageRootValue) return packageRootValue;
|
|
7443
7555
|
if (!entryPoint) return void 0;
|
|
7444
7556
|
try {
|
|
7445
|
-
let dir =
|
|
7446
|
-
while (dir !==
|
|
7557
|
+
let dir = path16.dirname(fs15.realpathSync(entryPoint));
|
|
7558
|
+
while (dir !== path16.dirname(dir)) {
|
|
7447
7559
|
const value = readConfigDirNameFromPackageRoot(dir);
|
|
7448
7560
|
if (value) return value;
|
|
7449
|
-
dir =
|
|
7561
|
+
dir = path16.dirname(dir);
|
|
7450
7562
|
}
|
|
7451
7563
|
} catch {
|
|
7452
7564
|
}
|
|
@@ -7468,14 +7580,14 @@ function getConfigDirName() {
|
|
|
7468
7580
|
return value;
|
|
7469
7581
|
}
|
|
7470
7582
|
function getProjectConfigDir(projectRoot) {
|
|
7471
|
-
return
|
|
7583
|
+
return path16.join(projectRoot, getConfigDirName());
|
|
7472
7584
|
}
|
|
7473
7585
|
function getAgentDir() {
|
|
7474
7586
|
const configured = process.env.PI_CODING_AGENT_DIR;
|
|
7475
|
-
const home = process.env.HOME || process.env.USERPROFILE ||
|
|
7587
|
+
const home = process.env.HOME || process.env.USERPROFILE || os6.homedir();
|
|
7476
7588
|
if (configured === "~") return home;
|
|
7477
|
-
if (configured?.startsWith("~/") || configured?.startsWith("~\\")) return
|
|
7478
|
-
return configured ||
|
|
7589
|
+
if (configured?.startsWith("~/") || configured?.startsWith("~\\")) return path16.join(home, configured.slice(2));
|
|
7590
|
+
return configured || path16.join(home, getConfigDirName(), "agent");
|
|
7479
7591
|
}
|
|
7480
7592
|
var statusCache = /* @__PURE__ */ new Map();
|
|
7481
7593
|
var MAX_STATUS_CACHE_ENTRIES = 512;
|
|
@@ -7484,19 +7596,19 @@ function getErrorMessage(error) {
|
|
|
7484
7596
|
}
|
|
7485
7597
|
function resolveChildCwd(baseCwd, childCwd) {
|
|
7486
7598
|
if (!childCwd) return baseCwd;
|
|
7487
|
-
return
|
|
7599
|
+
return path16.isAbsolute(childCwd) ? childCwd : path16.resolve(baseCwd, childCwd);
|
|
7488
7600
|
}
|
|
7489
7601
|
function isNotFoundError(error) {
|
|
7490
7602
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
7491
7603
|
}
|
|
7492
7604
|
function readStatus(asyncDir) {
|
|
7493
|
-
if (Buffer.byteLength(
|
|
7605
|
+
if (Buffer.byteLength(path16.basename(asyncDir), "utf-8") > 255) {
|
|
7494
7606
|
return null;
|
|
7495
7607
|
}
|
|
7496
|
-
const statusPath =
|
|
7608
|
+
const statusPath = path16.join(asyncDir, "status.json");
|
|
7497
7609
|
let stat;
|
|
7498
7610
|
try {
|
|
7499
|
-
stat =
|
|
7611
|
+
stat = fs15.statSync(statusPath);
|
|
7500
7612
|
} catch (error) {
|
|
7501
7613
|
if (isNotFoundError(error)) {
|
|
7502
7614
|
statusCache.delete(statusPath);
|
|
@@ -7514,7 +7626,7 @@ function readStatus(asyncDir) {
|
|
|
7514
7626
|
}
|
|
7515
7627
|
let content;
|
|
7516
7628
|
try {
|
|
7517
|
-
content =
|
|
7629
|
+
content = fs15.readFileSync(statusPath, "utf-8");
|
|
7518
7630
|
} catch (error) {
|
|
7519
7631
|
if (isNotFoundError(error)) {
|
|
7520
7632
|
statusCache.delete(statusPath);
|
|
@@ -7554,12 +7666,12 @@ function readStatus(asyncDir) {
|
|
|
7554
7666
|
return status;
|
|
7555
7667
|
}
|
|
7556
7668
|
function findLatestSessionFile(sessionDir) {
|
|
7557
|
-
if (!
|
|
7558
|
-
const files =
|
|
7559
|
-
const filePath =
|
|
7669
|
+
if (!fs15.existsSync(sessionDir)) return null;
|
|
7670
|
+
const files = fs15.readdirSync(sessionDir).filter((f) => f.endsWith(".jsonl")).map((f) => {
|
|
7671
|
+
const filePath = path16.join(sessionDir, f);
|
|
7560
7672
|
return {
|
|
7561
7673
|
path: filePath,
|
|
7562
|
-
mtime:
|
|
7674
|
+
mtime: fs15.statSync(filePath).mtimeMs
|
|
7563
7675
|
};
|
|
7564
7676
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
7565
7677
|
const latest = files[0];
|
|
@@ -7865,12 +7977,12 @@ function stripSkillFrontmatter(content) {
|
|
|
7865
7977
|
return normalized.slice(endIndex + 4).trim();
|
|
7866
7978
|
}
|
|
7867
7979
|
function isWithinPath(filePath, dir) {
|
|
7868
|
-
const relative6 =
|
|
7869
|
-
return relative6 === "" || !relative6.startsWith("..") && !
|
|
7980
|
+
const relative6 = path17.relative(dir, filePath);
|
|
7981
|
+
return relative6 === "" || !relative6.startsWith("..") && !path17.isAbsolute(relative6);
|
|
7870
7982
|
}
|
|
7871
7983
|
function readOptionalJsonFile(filePath, label) {
|
|
7872
7984
|
try {
|
|
7873
|
-
return JSON.parse(
|
|
7985
|
+
return JSON.parse(fs16.readFileSync(filePath, "utf-8"));
|
|
7874
7986
|
} catch (error) {
|
|
7875
7987
|
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
7876
7988
|
if (code === "ENOENT" || code === "ENOTDIR") return null;
|
|
@@ -7882,38 +7994,38 @@ function readOptionalJsonFile(filePath, label) {
|
|
|
7882
7994
|
}
|
|
7883
7995
|
function readJsonFileBestEffort2(filePath) {
|
|
7884
7996
|
try {
|
|
7885
|
-
return JSON.parse(
|
|
7997
|
+
return JSON.parse(fs16.readFileSync(filePath, "utf-8"));
|
|
7886
7998
|
} catch {
|
|
7887
7999
|
return null;
|
|
7888
8000
|
}
|
|
7889
8001
|
}
|
|
7890
8002
|
function extractSkillPathsFromPackageRoot(packageRoot, source, bestEffort = false) {
|
|
7891
|
-
const packageJsonPath =
|
|
8003
|
+
const packageJsonPath = path17.join(packageRoot, "package.json");
|
|
7892
8004
|
const pkg = bestEffort ? readJsonFileBestEffort2(packageJsonPath) : readOptionalJsonFile(packageJsonPath, "package manifest");
|
|
7893
8005
|
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) return [];
|
|
7894
8006
|
const pi = pkg.pi;
|
|
7895
8007
|
if (!pi || typeof pi !== "object" || Array.isArray(pi)) return [];
|
|
7896
8008
|
const skills = pi.skills;
|
|
7897
8009
|
if (!Array.isArray(skills)) return [];
|
|
7898
|
-
return skills.filter((entry) => typeof entry === "string").map((entry) => ({ path:
|
|
8010
|
+
return skills.filter((entry) => typeof entry === "string").map((entry) => ({ path: path17.resolve(packageRoot, entry), source }));
|
|
7899
8011
|
}
|
|
7900
8012
|
var cachedGlobalNpmRoot2 = null;
|
|
7901
8013
|
function getGlobalNpmRoot2() {
|
|
7902
8014
|
const offline = process.env.PI_OFFLINE?.toLowerCase();
|
|
7903
8015
|
if (offline === "1" || offline === "true" || offline === "yes") return null;
|
|
7904
8016
|
if (cachedGlobalNpmRoot2 !== null) return cachedGlobalNpmRoot2;
|
|
7905
|
-
const windowsGlobalRoot = process.platform === "win32" && process.env.APPDATA ?
|
|
8017
|
+
const windowsGlobalRoot = process.platform === "win32" && process.env.APPDATA ? path17.join(process.env.APPDATA, "npm", "node_modules") : void 0;
|
|
7906
8018
|
if (windowsGlobalRoot) {
|
|
7907
8019
|
try {
|
|
7908
|
-
if (
|
|
7909
|
-
cachedGlobalNpmRoot2 =
|
|
8020
|
+
if (fs16.statSync(windowsGlobalRoot).isDirectory()) {
|
|
8021
|
+
cachedGlobalNpmRoot2 = fs16.realpathSync(windowsGlobalRoot);
|
|
7910
8022
|
return cachedGlobalNpmRoot2;
|
|
7911
8023
|
}
|
|
7912
8024
|
} catch {
|
|
7913
8025
|
}
|
|
7914
8026
|
}
|
|
7915
8027
|
try {
|
|
7916
|
-
cachedGlobalNpmRoot2 =
|
|
8028
|
+
cachedGlobalNpmRoot2 = fs16.realpathSync(execSync2("npm root -g", { encoding: "utf-8", timeout: 5e3, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }).trim());
|
|
7917
8029
|
return cachedGlobalNpmRoot2;
|
|
7918
8030
|
} catch {
|
|
7919
8031
|
cachedGlobalNpmRoot2 = "";
|
|
@@ -7923,8 +8035,8 @@ function getGlobalNpmRoot2() {
|
|
|
7923
8035
|
function collectInstalledPackageSkillPaths(cwd, agentDir) {
|
|
7924
8036
|
const projectConfigDir = getProjectConfigDir(cwd);
|
|
7925
8037
|
const dirs = [
|
|
7926
|
-
{ path:
|
|
7927
|
-
{ path:
|
|
8038
|
+
{ path: path17.join(projectConfigDir, "npm", "node_modules"), source: "project-package" },
|
|
8039
|
+
{ path: path17.join(agentDir, "npm", "node_modules"), source: "user-package" }
|
|
7928
8040
|
];
|
|
7929
8041
|
const globalRoot = getGlobalNpmRoot2();
|
|
7930
8042
|
if (globalRoot) {
|
|
@@ -7932,10 +8044,10 @@ function collectInstalledPackageSkillPaths(cwd, agentDir) {
|
|
|
7932
8044
|
}
|
|
7933
8045
|
const results = [];
|
|
7934
8046
|
for (const dir of dirs) {
|
|
7935
|
-
if (!
|
|
8047
|
+
if (!fs16.existsSync(dir.path)) continue;
|
|
7936
8048
|
let entries;
|
|
7937
8049
|
try {
|
|
7938
|
-
entries =
|
|
8050
|
+
entries = fs16.readdirSync(dir.path, { withFileTypes: true });
|
|
7939
8051
|
} catch {
|
|
7940
8052
|
continue;
|
|
7941
8053
|
}
|
|
@@ -7943,22 +8055,22 @@ function collectInstalledPackageSkillPaths(cwd, agentDir) {
|
|
|
7943
8055
|
if (entry.name.startsWith(".")) continue;
|
|
7944
8056
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
7945
8057
|
if (entry.name.startsWith("@")) {
|
|
7946
|
-
const scopeDir =
|
|
8058
|
+
const scopeDir = path17.join(dir.path, entry.name);
|
|
7947
8059
|
let scopeEntries;
|
|
7948
8060
|
try {
|
|
7949
|
-
scopeEntries =
|
|
8061
|
+
scopeEntries = fs16.readdirSync(scopeDir, { withFileTypes: true });
|
|
7950
8062
|
} catch {
|
|
7951
8063
|
continue;
|
|
7952
8064
|
}
|
|
7953
8065
|
for (const scopeEntry of scopeEntries) {
|
|
7954
8066
|
if (scopeEntry.name.startsWith(".")) continue;
|
|
7955
8067
|
if (!scopeEntry.isDirectory() && !scopeEntry.isSymbolicLink()) continue;
|
|
7956
|
-
const pkgRoot2 =
|
|
8068
|
+
const pkgRoot2 = path17.join(scopeDir, scopeEntry.name);
|
|
7957
8069
|
results.push(...extractSkillPathsFromPackageRoot(pkgRoot2, dir.source, true));
|
|
7958
8070
|
}
|
|
7959
8071
|
continue;
|
|
7960
8072
|
}
|
|
7961
|
-
const pkgRoot =
|
|
8073
|
+
const pkgRoot = path17.join(dir.path, entry.name);
|
|
7962
8074
|
results.push(...extractSkillPathsFromPackageRoot(pkgRoot, dir.source, true));
|
|
7963
8075
|
}
|
|
7964
8076
|
}
|
|
@@ -7968,8 +8080,8 @@ function collectSettingsSkillPaths(cwd, agentDir) {
|
|
|
7968
8080
|
const results = [];
|
|
7969
8081
|
const projectConfigDir = getProjectConfigDir(cwd);
|
|
7970
8082
|
const settingsFiles = [
|
|
7971
|
-
{ file:
|
|
7972
|
-
{ file:
|
|
8083
|
+
{ file: path17.join(projectConfigDir, "settings.json"), base: projectConfigDir, source: "project-settings" },
|
|
8084
|
+
{ file: path17.join(agentDir, "settings.json"), base: agentDir, source: "user-settings" }
|
|
7973
8085
|
];
|
|
7974
8086
|
for (const { file, base, source } of settingsFiles) {
|
|
7975
8087
|
const settings = readOptionalJsonFile(file, "skills settings file");
|
|
@@ -7980,9 +8092,9 @@ function collectSettingsSkillPaths(cwd, agentDir) {
|
|
|
7980
8092
|
if (typeof entry !== "string") continue;
|
|
7981
8093
|
let resolved = entry;
|
|
7982
8094
|
if (resolved.startsWith("~/")) {
|
|
7983
|
-
resolved =
|
|
7984
|
-
} else if (!
|
|
7985
|
-
resolved =
|
|
8095
|
+
resolved = path17.join(os7.homedir(), resolved.slice(2));
|
|
8096
|
+
} else if (!path17.isAbsolute(resolved)) {
|
|
8097
|
+
resolved = path17.resolve(base, resolved);
|
|
7986
8098
|
}
|
|
7987
8099
|
results.push({ path: resolved, source });
|
|
7988
8100
|
}
|
|
@@ -7990,7 +8102,7 @@ function collectSettingsSkillPaths(cwd, agentDir) {
|
|
|
7990
8102
|
return results;
|
|
7991
8103
|
}
|
|
7992
8104
|
function isSafePackagePath2(value) {
|
|
7993
|
-
return value.length > 0 && !
|
|
8105
|
+
return value.length > 0 && !path17.isAbsolute(value) && value.split(/[\\/]/).every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
7994
8106
|
}
|
|
7995
8107
|
function parseNpmPackageName2(source) {
|
|
7996
8108
|
const spec = source.slice(4).trim();
|
|
@@ -8039,26 +8151,26 @@ function resolveSettingsPackageRoot2(source, baseDir) {
|
|
|
8039
8151
|
if (!trimmed) return void 0;
|
|
8040
8152
|
if (trimmed.startsWith("git:")) {
|
|
8041
8153
|
const parsed = parseGitPackagePath2(trimmed);
|
|
8042
|
-
return parsed ?
|
|
8154
|
+
return parsed ? path17.join(baseDir, "git", parsed.host, parsed.repoPath) : void 0;
|
|
8043
8155
|
}
|
|
8044
8156
|
if (trimmed.startsWith("npm:")) {
|
|
8045
8157
|
const packageName = parseNpmPackageName2(trimmed);
|
|
8046
|
-
return packageName ?
|
|
8158
|
+
return packageName ? path17.join(baseDir, "npm", "node_modules", packageName) : void 0;
|
|
8047
8159
|
}
|
|
8048
8160
|
const normalized = trimmed.startsWith("file:") ? trimmed.slice(5) : trimmed;
|
|
8049
|
-
if (normalized === "~") return
|
|
8050
|
-
if (normalized.startsWith("~/")) return
|
|
8051
|
-
if (
|
|
8161
|
+
if (normalized === "~") return os7.homedir();
|
|
8162
|
+
if (normalized.startsWith("~/")) return path17.join(os7.homedir(), normalized.slice(2));
|
|
8163
|
+
if (path17.isAbsolute(normalized)) return normalized;
|
|
8052
8164
|
if (normalized === "." || normalized === ".." || normalized.startsWith("./") || normalized.startsWith("../")) {
|
|
8053
|
-
return
|
|
8165
|
+
return path17.resolve(baseDir, normalized);
|
|
8054
8166
|
}
|
|
8055
8167
|
return void 0;
|
|
8056
8168
|
}
|
|
8057
8169
|
function collectSettingsPackageSkillPaths(cwd, agentDir) {
|
|
8058
8170
|
const projectConfigDir = getProjectConfigDir(cwd);
|
|
8059
8171
|
const settingsFiles = [
|
|
8060
|
-
{ file:
|
|
8061
|
-
{ file:
|
|
8172
|
+
{ file: path17.join(projectConfigDir, "settings.json"), base: projectConfigDir, source: "project-package" },
|
|
8173
|
+
{ file: path17.join(agentDir, "settings.json"), base: agentDir, source: "user-package" }
|
|
8062
8174
|
];
|
|
8063
8175
|
const results = [];
|
|
8064
8176
|
for (const { file, base, source } of settingsFiles) {
|
|
@@ -8079,10 +8191,10 @@ function collectSettingsPackageSkillPaths(cwd, agentDir) {
|
|
|
8079
8191
|
function buildSkillPaths(cwd, agentDir) {
|
|
8080
8192
|
const projectConfigDir = getProjectConfigDir(cwd);
|
|
8081
8193
|
const skillPaths = [
|
|
8082
|
-
{ path:
|
|
8083
|
-
{ path:
|
|
8084
|
-
{ path:
|
|
8085
|
-
{ path:
|
|
8194
|
+
{ path: path17.join(projectConfigDir, "skills"), source: "project" },
|
|
8195
|
+
{ path: path17.join(cwd, ".agents", "skills"), source: "project" },
|
|
8196
|
+
{ path: path17.join(agentDir, "skills"), source: "user" },
|
|
8197
|
+
{ path: path17.join(os7.homedir(), ".agents", "skills"), source: "user" },
|
|
8086
8198
|
...collectInstalledPackageSkillPaths(cwd, agentDir),
|
|
8087
8199
|
...collectSettingsPackageSkillPaths(cwd, agentDir),
|
|
8088
8200
|
...extractSkillPathsFromPackageRoot(cwd, "project-package"),
|
|
@@ -8090,7 +8202,7 @@ function buildSkillPaths(cwd, agentDir) {
|
|
|
8090
8202
|
];
|
|
8091
8203
|
const deduped = /* @__PURE__ */ new Map();
|
|
8092
8204
|
for (const entry of skillPaths) {
|
|
8093
|
-
const resolvedPath =
|
|
8205
|
+
const resolvedPath = path17.resolve(entry.path);
|
|
8094
8206
|
const existing = deduped.get(resolvedPath);
|
|
8095
8207
|
if (!existing || (SOURCE_PRIORITY[entry.source] ?? 0) > (SOURCE_PRIORITY[existing.source] ?? 0)) {
|
|
8096
8208
|
deduped.set(resolvedPath, { path: resolvedPath, source: entry.source });
|
|
@@ -8100,14 +8212,14 @@ function buildSkillPaths(cwd, agentDir) {
|
|
|
8100
8212
|
}
|
|
8101
8213
|
function inferSkillSource(filePath, cwd, agentDir, sourceHint) {
|
|
8102
8214
|
if (sourceHint) return sourceHint;
|
|
8103
|
-
const projectConfigRoot =
|
|
8104
|
-
const projectSkillsRoot =
|
|
8105
|
-
const projectPackagesRoot =
|
|
8106
|
-
const projectAgentsRoot =
|
|
8107
|
-
const userSkillsRoot =
|
|
8108
|
-
const userPackagesRoot =
|
|
8109
|
-
const userAgentRoot =
|
|
8110
|
-
const userAgentsRoot =
|
|
8215
|
+
const projectConfigRoot = path17.resolve(getProjectConfigDir(cwd));
|
|
8216
|
+
const projectSkillsRoot = path17.resolve(projectConfigRoot, "skills");
|
|
8217
|
+
const projectPackagesRoot = path17.resolve(projectConfigRoot, "npm", "node_modules");
|
|
8218
|
+
const projectAgentsRoot = path17.resolve(cwd, ".agents");
|
|
8219
|
+
const userSkillsRoot = path17.resolve(agentDir, "skills");
|
|
8220
|
+
const userPackagesRoot = path17.resolve(agentDir, "npm", "node_modules");
|
|
8221
|
+
const userAgentRoot = path17.resolve(agentDir);
|
|
8222
|
+
const userAgentsRoot = path17.resolve(os7.homedir(), ".agents");
|
|
8111
8223
|
if (isWithinPath(filePath, projectPackagesRoot)) return "project-package";
|
|
8112
8224
|
if (isWithinPath(filePath, projectSkillsRoot) || isWithinPath(filePath, projectAgentsRoot)) return "project";
|
|
8113
8225
|
if (isWithinPath(filePath, projectConfigRoot)) return "project-settings";
|
|
@@ -8131,7 +8243,7 @@ function parseSkillDescription(content) {
|
|
|
8131
8243
|
}
|
|
8132
8244
|
function maybeReadSkillMetadata(filePath) {
|
|
8133
8245
|
try {
|
|
8134
|
-
const content =
|
|
8246
|
+
const content = fs16.readFileSync(filePath, "utf-8");
|
|
8135
8247
|
return { description: parseSkillDescription(content), disableModelInvocation: maybeReadSkillDisableModelInvocation(content) };
|
|
8136
8248
|
} catch {
|
|
8137
8249
|
return {};
|
|
@@ -8156,8 +8268,8 @@ function collectFilesystemSkills(cwd, agentDir, skillPaths) {
|
|
|
8156
8268
|
const visitedDirectories = /* @__PURE__ */ new Map();
|
|
8157
8269
|
let order = 0;
|
|
8158
8270
|
const pushEntry = (name, filePath, sourceHint) => {
|
|
8159
|
-
const resolvedFile =
|
|
8160
|
-
if (!
|
|
8271
|
+
const resolvedFile = path17.resolve(filePath);
|
|
8272
|
+
if (!fs16.existsSync(resolvedFile)) return;
|
|
8161
8273
|
const source = inferSkillSource(resolvedFile, cwd, agentDir, sourceHint);
|
|
8162
8274
|
const { description, disableModelInvocation } = maybeReadSkillMetadata(resolvedFile);
|
|
8163
8275
|
const existingIndex = seen.get(resolvedFile);
|
|
@@ -8189,9 +8301,9 @@ function collectFilesystemSkills(cwd, agentDir, skillPaths) {
|
|
|
8189
8301
|
const markDirectoryVisited = (dirPath, sourceHint) => {
|
|
8190
8302
|
let resolvedDir;
|
|
8191
8303
|
try {
|
|
8192
|
-
resolvedDir =
|
|
8304
|
+
resolvedDir = fs16.realpathSync(dirPath);
|
|
8193
8305
|
} catch {
|
|
8194
|
-
resolvedDir =
|
|
8306
|
+
resolvedDir = path17.resolve(dirPath);
|
|
8195
8307
|
}
|
|
8196
8308
|
const priority = sourceHint ? SOURCE_PRIORITY[sourceHint] ?? 0 : SOURCE_PRIORITY.unknown;
|
|
8197
8309
|
const previousPriority = visitedDirectories.get(resolvedDir);
|
|
@@ -8201,24 +8313,24 @@ function collectFilesystemSkills(cwd, agentDir, skillPaths) {
|
|
|
8201
8313
|
};
|
|
8202
8314
|
const walkSkillDirectories = (dirPath, sourceHint) => {
|
|
8203
8315
|
if (!markDirectoryVisited(dirPath, sourceHint)) return;
|
|
8204
|
-
const skillFile =
|
|
8205
|
-
if (
|
|
8206
|
-
pushEntry(
|
|
8316
|
+
const skillFile = path17.join(dirPath, "SKILL.md");
|
|
8317
|
+
if (fs16.existsSync(skillFile)) {
|
|
8318
|
+
pushEntry(path17.basename(dirPath), skillFile, sourceHint);
|
|
8207
8319
|
return;
|
|
8208
8320
|
}
|
|
8209
8321
|
let entriesInDir;
|
|
8210
8322
|
try {
|
|
8211
|
-
entriesInDir =
|
|
8323
|
+
entriesInDir = fs16.readdirSync(dirPath, { withFileTypes: true });
|
|
8212
8324
|
} catch {
|
|
8213
8325
|
return;
|
|
8214
8326
|
}
|
|
8215
8327
|
for (const entry of entriesInDir) {
|
|
8216
8328
|
if (shouldSkipDirectory(entry.name)) continue;
|
|
8217
8329
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
8218
|
-
const entryPath =
|
|
8330
|
+
const entryPath = path17.join(dirPath, entry.name);
|
|
8219
8331
|
let stat;
|
|
8220
8332
|
try {
|
|
8221
|
-
stat =
|
|
8333
|
+
stat = fs16.statSync(entryPath);
|
|
8222
8334
|
} catch {
|
|
8223
8335
|
continue;
|
|
8224
8336
|
}
|
|
@@ -8228,41 +8340,41 @@ function collectFilesystemSkills(cwd, agentDir, skillPaths) {
|
|
|
8228
8340
|
}
|
|
8229
8341
|
};
|
|
8230
8342
|
for (const skillPath of skillPaths) {
|
|
8231
|
-
if (!
|
|
8343
|
+
if (!fs16.existsSync(skillPath.path)) continue;
|
|
8232
8344
|
let stat;
|
|
8233
8345
|
try {
|
|
8234
|
-
stat =
|
|
8346
|
+
stat = fs16.statSync(skillPath.path);
|
|
8235
8347
|
} catch {
|
|
8236
8348
|
continue;
|
|
8237
8349
|
}
|
|
8238
8350
|
if (stat.isFile()) {
|
|
8239
|
-
const fileName =
|
|
8351
|
+
const fileName = path17.basename(skillPath.path);
|
|
8240
8352
|
if (!fileName.toLowerCase().endsWith(".md")) continue;
|
|
8241
|
-
const skillName = fileName.toLowerCase() === "skill.md" ?
|
|
8353
|
+
const skillName = fileName.toLowerCase() === "skill.md" ? path17.basename(path17.dirname(skillPath.path)) : path17.basename(fileName, path17.extname(fileName));
|
|
8242
8354
|
pushEntry(skillName, skillPath.path, skillPath.source);
|
|
8243
8355
|
continue;
|
|
8244
8356
|
}
|
|
8245
8357
|
if (!stat.isDirectory()) continue;
|
|
8246
|
-
const rootSkillFile =
|
|
8247
|
-
if (
|
|
8248
|
-
pushEntry(
|
|
8358
|
+
const rootSkillFile = path17.join(skillPath.path, "SKILL.md");
|
|
8359
|
+
if (fs16.existsSync(rootSkillFile)) {
|
|
8360
|
+
pushEntry(path17.basename(skillPath.path), rootSkillFile, skillPath.source);
|
|
8249
8361
|
continue;
|
|
8250
8362
|
}
|
|
8251
8363
|
markDirectoryVisited(skillPath.path, skillPath.source);
|
|
8252
8364
|
let childEntries;
|
|
8253
8365
|
try {
|
|
8254
|
-
childEntries =
|
|
8366
|
+
childEntries = fs16.readdirSync(skillPath.path, { withFileTypes: true });
|
|
8255
8367
|
} catch {
|
|
8256
8368
|
continue;
|
|
8257
8369
|
}
|
|
8258
8370
|
for (const child of childEntries) {
|
|
8259
8371
|
if (child.name.startsWith(".")) continue;
|
|
8260
|
-
const childPath =
|
|
8372
|
+
const childPath = path17.join(skillPath.path, child.name);
|
|
8261
8373
|
if (child.isDirectory() || child.isSymbolicLink()) {
|
|
8262
8374
|
if (shouldSkipDirectory(child.name)) continue;
|
|
8263
8375
|
let childStat;
|
|
8264
8376
|
try {
|
|
8265
|
-
childStat =
|
|
8377
|
+
childStat = fs16.statSync(childPath);
|
|
8266
8378
|
} catch {
|
|
8267
8379
|
continue;
|
|
8268
8380
|
}
|
|
@@ -8270,7 +8382,7 @@ function collectFilesystemSkills(cwd, agentDir, skillPaths) {
|
|
|
8270
8382
|
continue;
|
|
8271
8383
|
}
|
|
8272
8384
|
if (child.isFile() && child.name.toLowerCase().endsWith(".md")) {
|
|
8273
|
-
pushEntry(
|
|
8385
|
+
pushEntry(path17.basename(child.name, path17.extname(child.name)), childPath, skillPath.source);
|
|
8274
8386
|
}
|
|
8275
8387
|
}
|
|
8276
8388
|
}
|
|
@@ -8286,8 +8398,8 @@ function getCachedSkills(cwd) {
|
|
|
8286
8398
|
const loaded = collectFilesystemSkills(cwd, agentDir, skillPaths);
|
|
8287
8399
|
const dedupedByName = /* @__PURE__ */ new Map();
|
|
8288
8400
|
for (const entry of loaded) {
|
|
8289
|
-
const
|
|
8290
|
-
dedupedByName.set(entry.name, chooseHigherPrioritySkill(
|
|
8401
|
+
const current2 = dedupedByName.get(entry.name);
|
|
8402
|
+
dedupedByName.set(entry.name, chooseHigherPrioritySkill(current2, entry));
|
|
8291
8403
|
}
|
|
8292
8404
|
const skills = [...dedupedByName.values()].sort((a, b) => a.order - b.order);
|
|
8293
8405
|
loadSkillsCache = { cwd, agentDir, skills, timestamp: now };
|
|
@@ -8301,12 +8413,12 @@ function resolveSkillPath(skillName, cwd) {
|
|
|
8301
8413
|
}
|
|
8302
8414
|
function readSkill(skillName, skillPath, source) {
|
|
8303
8415
|
try {
|
|
8304
|
-
const stat =
|
|
8416
|
+
const stat = fs16.statSync(skillPath);
|
|
8305
8417
|
const cached = skillCache.get(skillPath);
|
|
8306
8418
|
if (cached && cached.mtime === stat.mtimeMs) {
|
|
8307
8419
|
return cached.skill;
|
|
8308
8420
|
}
|
|
8309
|
-
const raw =
|
|
8421
|
+
const raw = fs16.readFileSync(skillPath, "utf-8");
|
|
8310
8422
|
const content = stripSkillFrontmatter(raw);
|
|
8311
8423
|
const description = parseSkillDescription(raw);
|
|
8312
8424
|
const disableModelInvocation = maybeReadSkillDisableModelInvocation(raw);
|
|
@@ -8335,7 +8447,7 @@ function resolveSkills(skillNames, cwd, localSkillPaths, localBaseDir) {
|
|
|
8335
8447
|
if (localSkillPaths?.length) {
|
|
8336
8448
|
const agentDir = getAgentDir();
|
|
8337
8449
|
const localEntries = collectFilesystemSkills(cwd, agentDir, localSkillPaths.map((entry) => ({
|
|
8338
|
-
path:
|
|
8450
|
+
path: path17.resolve(localBaseDir ?? cwd, entry),
|
|
8339
8451
|
source: "unknown"
|
|
8340
8452
|
})));
|
|
8341
8453
|
for (const entry of localEntries) {
|
|
@@ -8363,7 +8475,7 @@ function resolveSkills(skillNames, cwd, localSkillPaths, localBaseDir) {
|
|
|
8363
8475
|
function resolveSkillsWithFallback(skillNames, primaryCwd, fallbackCwd, localSkillPaths, localBaseDir) {
|
|
8364
8476
|
const primary = resolveSkills(skillNames, primaryCwd, localSkillPaths, localBaseDir);
|
|
8365
8477
|
if (!fallbackCwd || primary.missing.length === 0) return primary;
|
|
8366
|
-
if (
|
|
8478
|
+
if (path17.resolve(primaryCwd) === path17.resolve(fallbackCwd)) return primary;
|
|
8367
8479
|
const fallback = resolveSkills(primary.missing, fallbackCwd);
|
|
8368
8480
|
return {
|
|
8369
8481
|
resolved: [...primary.resolved, ...fallback.resolved],
|
|
@@ -8449,6 +8561,17 @@ export {
|
|
|
8449
8561
|
buildSkillInjection,
|
|
8450
8562
|
normalizeSkillInput,
|
|
8451
8563
|
discoverAvailableSkills,
|
|
8564
|
+
REX_LOCAL_MACHINE,
|
|
8565
|
+
REX_EXIT_GONE,
|
|
8566
|
+
REX_EXIT_UNREACHABLE,
|
|
8567
|
+
isRexLocalMachine,
|
|
8568
|
+
REX_BUNDLE_BIN,
|
|
8569
|
+
REX_CALL_TIMEOUT_MS,
|
|
8570
|
+
REX_MAX_OUTPUT,
|
|
8571
|
+
rexGlobalArgs,
|
|
8572
|
+
resolveRexBinary,
|
|
8573
|
+
rexCommandEnv,
|
|
8574
|
+
resolveRexLocalPlacement,
|
|
8452
8575
|
extractChildWrittenOutput,
|
|
8453
8576
|
normalizeSingleOutputOverride,
|
|
8454
8577
|
resolveSingleOutputPath,
|
|
@@ -8509,6 +8632,7 @@ export {
|
|
|
8509
8632
|
scopedModelIdsFromContext,
|
|
8510
8633
|
normalizeModelSegment,
|
|
8511
8634
|
resolveModelCandidate,
|
|
8635
|
+
isUnavailableSubagentModel,
|
|
8512
8636
|
resolveSubagentModelOverride,
|
|
8513
8637
|
resolveEffectiveSubagentModel,
|
|
8514
8638
|
resolveModelOrigin,
|
|
@@ -8571,9 +8695,11 @@ export {
|
|
|
8571
8695
|
MISSING_STRUCTURED_ACCEPTANCE_REPORT_ERROR,
|
|
8572
8696
|
formatStructuredOutputRejectionError,
|
|
8573
8697
|
createStructuredOutputToolParameters,
|
|
8698
|
+
structuredOutputValidatorReady,
|
|
8574
8699
|
assertJsonSchemaObject,
|
|
8575
8700
|
createStructuredOutputRuntime,
|
|
8576
8701
|
validateStructuredOutputValue,
|
|
8702
|
+
prepareStructuredOutputArguments,
|
|
8577
8703
|
cleanupStructuredOutputRuntime,
|
|
8578
8704
|
ChainOutputValidationError,
|
|
8579
8705
|
validateChainOutputBindings,
|
|
@@ -8593,6 +8719,7 @@ export {
|
|
|
8593
8719
|
childWatchdogProgressForModel,
|
|
8594
8720
|
isAgentContract,
|
|
8595
8721
|
attachContractProjections,
|
|
8722
|
+
normalizeAcceptanceInput,
|
|
8596
8723
|
resolveAcceptanceReportMode,
|
|
8597
8724
|
parseGateInput,
|
|
8598
8725
|
acceptanceHasTypedVerify,
|
|
@@ -8625,6 +8752,9 @@ export {
|
|
|
8625
8752
|
projectScopeRequiresTrustMessage,
|
|
8626
8753
|
BUILTIN_AGENT_NAMES,
|
|
8627
8754
|
buildAgentMemoryInjection,
|
|
8755
|
+
DEFAULT_WAIT_TOOL_NAME,
|
|
8756
|
+
waitToolName,
|
|
8757
|
+
setWaitToolName,
|
|
8628
8758
|
redactSecretValues,
|
|
8629
8759
|
validatePermissionRules,
|
|
8630
8760
|
validatePermissionConfig,
|