poe-code 3.0.223 → 3.0.225
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/dist/bin/poe-gemini.js +23 -0
- package/dist/cli/commands/configure-payload.js +100 -13
- package/dist/cli/commands/configure-payload.js.map +1 -1
- package/dist/cli/commands/configure.js +2 -2
- package/dist/cli/commands/configure.js.map +1 -1
- package/dist/cli/commands/pipeline.js +4 -2
- package/dist/cli/commands/pipeline.js.map +1 -1
- package/dist/cli/commands/provider.d.ts +1 -0
- package/dist/cli/commands/provider.js +94 -3
- package/dist/cli/commands/provider.js.map +1 -1
- package/dist/cli/commands/ralph.js +1 -0
- package/dist/cli/commands/ralph.js.map +1 -1
- package/dist/cli/commands/shared.d.ts +8 -1
- package/dist/cli/commands/shared.js +88 -7
- package/dist/cli/commands/shared.js.map +1 -1
- package/dist/cli/commands/spawn.js +20 -0
- package/dist/cli/commands/spawn.js.map +1 -1
- package/dist/cli/commands/test.d.ts +5 -1
- package/dist/cli/commands/test.js +58 -6
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/constants.d.ts +2 -2
- package/dist/cli/constants.js +3 -14
- package/dist/cli/constants.js.map +1 -1
- package/dist/cli/isolated-env.d.ts +2 -1
- package/dist/cli/isolated-env.js +20 -2
- package/dist/cli/isolated-env.js.map +1 -1
- package/dist/cli/options.d.ts +2 -5
- package/dist/cli/options.js +10 -1
- package/dist/cli/options.js.map +1 -1
- package/dist/cli/poe-code-command-runner.js +7 -2
- package/dist/cli/poe-code-command-runner.js.map +1 -1
- package/dist/cli/prompt-runner.js +4 -2
- package/dist/cli/prompt-runner.js.map +1 -1
- package/dist/cli/prompts.d.ts +23 -13
- package/dist/cli/prompts.js +13 -0
- package/dist/cli/prompts.js.map +1 -1
- package/dist/cli/service-registry.d.ts +12 -3
- package/dist/cli/service-registry.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4936 -2415
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code.js +924 -174
- package/dist/providers/claude-code.js.map +4 -4
- package/dist/providers/codex.js +916 -178
- package/dist/providers/codex.js.map +4 -4
- package/dist/providers/create-provider.d.ts +1 -0
- package/dist/providers/create-provider.js +1 -0
- package/dist/providers/create-provider.js.map +1 -1
- package/dist/providers/gemini-cli.d.ts +16 -0
- package/dist/providers/gemini-cli.js +11349 -0
- package/dist/providers/gemini-cli.js.map +7 -0
- package/dist/providers/goose.js +881 -183
- package/dist/providers/goose.js.map +4 -4
- package/dist/providers/kimi.js +905 -165
- package/dist/providers/kimi.js.map +4 -4
- package/dist/providers/opencode.js +905 -165
- package/dist/providers/opencode.js.map +4 -4
- package/dist/providers/poe-agent.js +1155 -357
- package/dist/providers/poe-agent.js.map +4 -4
- package/dist/providers/spawn-options.d.ts +3 -0
- package/dist/sdk/pipeline.d.ts +1 -1
- package/dist/sdk/pipeline.js +22 -19
- package/dist/sdk/pipeline.js.map +1 -1
- package/dist/sdk/ralph.js +5 -0
- package/dist/sdk/ralph.js.map +1 -1
- package/dist/sdk/spawn-core.d.ts +3 -0
- package/dist/sdk/spawn-core.js +6 -8
- package/dist/sdk/spawn-core.js.map +1 -1
- package/dist/sdk/spawn.d.ts +8 -8
- package/dist/sdk/spawn.js +26 -3
- package/dist/sdk/spawn.js.map +1 -1
- package/dist/sdk/types.d.ts +7 -0
- package/dist/utils/command-checks.d.ts +8 -0
- package/dist/utils/command-checks.js +35 -9
- package/dist/utils/command-checks.js.map +1 -1
- package/dist/utils/dry-run.js +7 -1
- package/dist/utils/dry-run.js.map +1 -1
- package/dist/workflow-templates/github-issue-opened.caller.yml +2 -1
- package/dist/workflow-templates/github-issue-opened.ejected.yml +2 -1
- package/package.json +2 -1
- package/packages/agent-skill-config/dist/configs.js +4 -0
- package/packages/agent-skill-config/dist/git-exclude.d.ts +6 -2
- package/packages/agent-skill-config/dist/git-exclude.js +12 -12
- package/packages/memory/dist/index.js +924 -200
- package/packages/memory/dist/index.js.map +4 -4
- package/packages/superintendent/dist/index.d.ts +2 -1
- package/packages/superintendent/dist/runtime/loop.d.ts +1 -0
- package/packages/superintendent/dist/runtime/loop.js +14 -2
|
@@ -609,8 +609,8 @@ function resourceNotFound(resource) {
|
|
|
609
609
|
`Resource not found: ${resource}`
|
|
610
610
|
);
|
|
611
611
|
}
|
|
612
|
-
function assertAbsolutePath(
|
|
613
|
-
if (!isAbsolute(
|
|
612
|
+
function assertAbsolutePath(path54) {
|
|
613
|
+
if (!isAbsolute(path54)) {
|
|
614
614
|
throw invalidParams('"path" must be an absolute path');
|
|
615
615
|
}
|
|
616
616
|
}
|
|
@@ -1867,7 +1867,7 @@ var init_plan_scope = __esm({
|
|
|
1867
1867
|
|
|
1868
1868
|
// packages/config-extends/src/discover.ts
|
|
1869
1869
|
import path2 from "node:path";
|
|
1870
|
-
async function findBase(name, bases,
|
|
1870
|
+
async function findBase(name, bases, fs7) {
|
|
1871
1871
|
const checkedPaths = [];
|
|
1872
1872
|
for (const basePath of bases) {
|
|
1873
1873
|
for (const extension of [".md", ".yaml", ".yml", ".json"]) {
|
|
@@ -1875,7 +1875,7 @@ async function findBase(name, bases, fs6) {
|
|
|
1875
1875
|
checkedPaths.push(filePath);
|
|
1876
1876
|
try {
|
|
1877
1877
|
return {
|
|
1878
|
-
content: await
|
|
1878
|
+
content: await fs7.readFile(filePath, "utf8"),
|
|
1879
1879
|
filePath
|
|
1880
1880
|
};
|
|
1881
1881
|
} catch (error2) {
|
|
@@ -1965,11 +1965,11 @@ var init_parse = __esm({
|
|
|
1965
1965
|
function mergeLayers(layers) {
|
|
1966
1966
|
return mergeObjectLayers(layers, []);
|
|
1967
1967
|
}
|
|
1968
|
-
function mergeObjectLayers(layers,
|
|
1968
|
+
function mergeObjectLayers(layers, path54) {
|
|
1969
1969
|
const data = {};
|
|
1970
1970
|
const sources = {};
|
|
1971
1971
|
for (const key2 of collectKeys(layers)) {
|
|
1972
|
-
const resolved = resolveKey(layers, key2,
|
|
1972
|
+
const resolved = resolveKey(layers, key2, path54);
|
|
1973
1973
|
if (resolved === void 0) {
|
|
1974
1974
|
continue;
|
|
1975
1975
|
}
|
|
@@ -1987,7 +1987,7 @@ function collectKeys(layers) {
|
|
|
1987
1987
|
}
|
|
1988
1988
|
return [...keys];
|
|
1989
1989
|
}
|
|
1990
|
-
function resolveKey(layers, key2,
|
|
1990
|
+
function resolveKey(layers, key2, path54) {
|
|
1991
1991
|
let winningSource;
|
|
1992
1992
|
let winningValue;
|
|
1993
1993
|
const objectLayers = [];
|
|
@@ -2017,9 +2017,9 @@ function resolveKey(layers, key2, path49) {
|
|
|
2017
2017
|
if (winningSource === void 0) {
|
|
2018
2018
|
return void 0;
|
|
2019
2019
|
}
|
|
2020
|
-
const fullPath = buildPath(
|
|
2020
|
+
const fullPath = buildPath(path54, key2);
|
|
2021
2021
|
if (isPlainObject(winningValue)) {
|
|
2022
|
-
const merged = mergeObjectLayers(objectLayers, [...
|
|
2022
|
+
const merged = mergeObjectLayers(objectLayers, [...path54, key2]);
|
|
2023
2023
|
return {
|
|
2024
2024
|
value: merged.data,
|
|
2025
2025
|
sources: {
|
|
@@ -2044,8 +2044,8 @@ function isWinningCandidate(key2, value) {
|
|
|
2044
2044
|
}
|
|
2045
2045
|
return true;
|
|
2046
2046
|
}
|
|
2047
|
-
function buildPath(
|
|
2048
|
-
return [...
|
|
2047
|
+
function buildPath(path54, key2) {
|
|
2048
|
+
return [...path54, key2].join(".");
|
|
2049
2049
|
}
|
|
2050
2050
|
function isPlainObject(value) {
|
|
2051
2051
|
if (value === null || Array.isArray(value) || typeof value !== "object") {
|
|
@@ -9888,16 +9888,16 @@ function getConfigFormat(pathOrFormat) {
|
|
|
9888
9888
|
}
|
|
9889
9889
|
return formatRegistry[formatName];
|
|
9890
9890
|
}
|
|
9891
|
-
function detectFormat2(
|
|
9892
|
-
const ext = getExtension(
|
|
9891
|
+
function detectFormat2(path54) {
|
|
9892
|
+
const ext = getExtension(path54);
|
|
9893
9893
|
return extensionMap[ext];
|
|
9894
9894
|
}
|
|
9895
|
-
function getExtension(
|
|
9896
|
-
const lastDot =
|
|
9895
|
+
function getExtension(path54) {
|
|
9896
|
+
const lastDot = path54.lastIndexOf(".");
|
|
9897
9897
|
if (lastDot === -1) {
|
|
9898
9898
|
return "";
|
|
9899
9899
|
}
|
|
9900
|
-
return
|
|
9900
|
+
return path54.slice(lastDot).toLowerCase();
|
|
9901
9901
|
}
|
|
9902
9902
|
var formatRegistry, extensionMap;
|
|
9903
9903
|
var init_formats = __esm({
|
|
@@ -9976,9 +9976,9 @@ var init_path_utils = __esm({
|
|
|
9976
9976
|
function isNotFound(error2) {
|
|
9977
9977
|
return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
|
|
9978
9978
|
}
|
|
9979
|
-
async function readFileIfExists(
|
|
9979
|
+
async function readFileIfExists(fs7, target) {
|
|
9980
9980
|
try {
|
|
9981
|
-
return await
|
|
9981
|
+
return await fs7.readFile(target, "utf8");
|
|
9982
9982
|
} catch (error2) {
|
|
9983
9983
|
if (isNotFound(error2)) {
|
|
9984
9984
|
return null;
|
|
@@ -9986,9 +9986,9 @@ async function readFileIfExists(fs6, target) {
|
|
|
9986
9986
|
throw error2;
|
|
9987
9987
|
}
|
|
9988
9988
|
}
|
|
9989
|
-
async function pathExists(
|
|
9989
|
+
async function pathExists(fs7, target) {
|
|
9990
9990
|
try {
|
|
9991
|
-
await
|
|
9991
|
+
await fs7.stat(target);
|
|
9992
9992
|
return true;
|
|
9993
9993
|
} catch (error2) {
|
|
9994
9994
|
if (isNotFound(error2)) {
|
|
@@ -10017,9 +10017,9 @@ function createInvalidDocumentBackupPath(targetPath) {
|
|
|
10017
10017
|
const ext = targetPath.includes(".") ? targetPath.split(".").pop() : "bak";
|
|
10018
10018
|
return `${targetPath}.invalid-${createTimestamp()}.${ext}`;
|
|
10019
10019
|
}
|
|
10020
|
-
async function backupInvalidDocument(
|
|
10020
|
+
async function backupInvalidDocument(fs7, targetPath, content) {
|
|
10021
10021
|
const backupPath = createInvalidDocumentBackupPath(targetPath);
|
|
10022
|
-
await
|
|
10022
|
+
await fs7.writeFile(backupPath, content, { encoding: "utf8" });
|
|
10023
10023
|
}
|
|
10024
10024
|
function describeMutation(kind, targetPath) {
|
|
10025
10025
|
const displayPath = targetPath ?? "target";
|
|
@@ -10622,26 +10622,26 @@ var init_src4 = __esm({
|
|
|
10622
10622
|
|
|
10623
10623
|
// packages/poe-code-config/src/store.ts
|
|
10624
10624
|
import path6 from "node:path";
|
|
10625
|
-
async function readDocument(
|
|
10626
|
-
const document = await readStoredDocument(
|
|
10625
|
+
async function readDocument(fs7, filePath) {
|
|
10626
|
+
const document = await readStoredDocument(fs7, filePath);
|
|
10627
10627
|
return document.data;
|
|
10628
10628
|
}
|
|
10629
|
-
async function writeScope(
|
|
10630
|
-
const document = await readDocument(
|
|
10629
|
+
async function writeScope(fs7, filePath, scope, values) {
|
|
10630
|
+
const document = await readDocument(fs7, filePath);
|
|
10631
10631
|
const normalizedValues = normalizeScopeValues(values);
|
|
10632
10632
|
if (Object.keys(normalizedValues).length === 0) {
|
|
10633
10633
|
delete document[scope];
|
|
10634
10634
|
} else {
|
|
10635
10635
|
document[scope] = normalizedValues;
|
|
10636
10636
|
}
|
|
10637
|
-
await writeDocument(
|
|
10637
|
+
await writeDocument(fs7, filePath, document);
|
|
10638
10638
|
}
|
|
10639
|
-
async function readMergedDocument(
|
|
10640
|
-
const globalDocument = await readStoredDocument(
|
|
10639
|
+
async function readMergedDocument(fs7, globalPath, projectPath) {
|
|
10640
|
+
const globalDocument = await readStoredDocument(fs7, globalPath);
|
|
10641
10641
|
if (!projectPath || projectPath === globalPath) {
|
|
10642
10642
|
return globalDocument.data;
|
|
10643
10643
|
}
|
|
10644
|
-
const projectDocument = await readStoredDocument(
|
|
10644
|
+
const projectDocument = await readStoredDocument(fs7, projectPath);
|
|
10645
10645
|
const resolved = await resolve(
|
|
10646
10646
|
[
|
|
10647
10647
|
{
|
|
@@ -10655,16 +10655,16 @@ async function readMergedDocument(fs6, globalPath, projectPath) {
|
|
|
10655
10655
|
}
|
|
10656
10656
|
],
|
|
10657
10657
|
{
|
|
10658
|
-
fs: createResolvedConfigFs(
|
|
10658
|
+
fs: createResolvedConfigFs(fs7, globalPath, globalDocument.content),
|
|
10659
10659
|
autoExtend: true
|
|
10660
10660
|
}
|
|
10661
10661
|
);
|
|
10662
10662
|
return normalizeDocument(resolved.data);
|
|
10663
10663
|
}
|
|
10664
|
-
async function readStoredDocument(
|
|
10664
|
+
async function readStoredDocument(fs7, filePath) {
|
|
10665
10665
|
try {
|
|
10666
|
-
const raw = await
|
|
10667
|
-
return await parseStoredDocument(
|
|
10666
|
+
const raw = await fs7.readFile(filePath, "utf8");
|
|
10667
|
+
return await parseStoredDocument(fs7, filePath, raw);
|
|
10668
10668
|
} catch (error2) {
|
|
10669
10669
|
if (isNotFound(error2)) {
|
|
10670
10670
|
return {
|
|
@@ -10675,7 +10675,7 @@ async function readStoredDocument(fs6, filePath) {
|
|
|
10675
10675
|
throw error2;
|
|
10676
10676
|
}
|
|
10677
10677
|
}
|
|
10678
|
-
async function parseStoredDocument(
|
|
10678
|
+
async function parseStoredDocument(fs7, filePath, raw) {
|
|
10679
10679
|
try {
|
|
10680
10680
|
return {
|
|
10681
10681
|
content: raw,
|
|
@@ -10683,7 +10683,7 @@ async function parseStoredDocument(fs6, filePath, raw) {
|
|
|
10683
10683
|
};
|
|
10684
10684
|
} catch (error2) {
|
|
10685
10685
|
if (error2 instanceof SyntaxError) {
|
|
10686
|
-
await recoverInvalidDocument(
|
|
10686
|
+
await recoverInvalidDocument(fs7, filePath, raw);
|
|
10687
10687
|
return {
|
|
10688
10688
|
content: EMPTY_DOCUMENT,
|
|
10689
10689
|
data: {}
|
|
@@ -10717,28 +10717,28 @@ function normalizeScopeValues(value) {
|
|
|
10717
10717
|
}
|
|
10718
10718
|
return normalized;
|
|
10719
10719
|
}
|
|
10720
|
-
function createResolvedConfigFs(
|
|
10720
|
+
function createResolvedConfigFs(fs7, globalPath, globalContent) {
|
|
10721
10721
|
return {
|
|
10722
10722
|
readFile(filePath, _encoding) {
|
|
10723
10723
|
if (filePath === globalPath) {
|
|
10724
10724
|
return Promise.resolve(globalContent);
|
|
10725
10725
|
}
|
|
10726
|
-
return
|
|
10726
|
+
return fs7.readFile(filePath, "utf8");
|
|
10727
10727
|
}
|
|
10728
10728
|
};
|
|
10729
10729
|
}
|
|
10730
|
-
async function writeDocument(
|
|
10731
|
-
await
|
|
10732
|
-
await
|
|
10730
|
+
async function writeDocument(fs7, filePath, document) {
|
|
10731
|
+
await fs7.mkdir(path6.dirname(filePath), { recursive: true });
|
|
10732
|
+
await fs7.writeFile(filePath, `${JSON.stringify(document, null, 2)}
|
|
10733
10733
|
`, {
|
|
10734
10734
|
encoding: "utf8"
|
|
10735
10735
|
});
|
|
10736
10736
|
}
|
|
10737
|
-
async function recoverInvalidDocument(
|
|
10738
|
-
await
|
|
10737
|
+
async function recoverInvalidDocument(fs7, filePath, content) {
|
|
10738
|
+
await fs7.mkdir(path6.dirname(filePath), { recursive: true });
|
|
10739
10739
|
const backupPath = createInvalidBackupPath(filePath);
|
|
10740
|
-
await
|
|
10741
|
-
await
|
|
10740
|
+
await fs7.writeFile(backupPath, content, { encoding: "utf8" });
|
|
10741
|
+
await fs7.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
|
|
10742
10742
|
}
|
|
10743
10743
|
function createInvalidBackupPath(filePath) {
|
|
10744
10744
|
const directory = path6.dirname(filePath);
|
|
@@ -10912,7 +10912,7 @@ function mergeScope(scope, baseScope, overrideScope) {
|
|
|
10912
10912
|
...Object.fromEntries(scopeEntries)
|
|
10913
10913
|
};
|
|
10914
10914
|
}
|
|
10915
|
-
function mergeRuntimeScope(baseScope, overrideScope,
|
|
10915
|
+
function mergeRuntimeScope(baseScope, overrideScope, path54 = []) {
|
|
10916
10916
|
const merged = {};
|
|
10917
10917
|
const keys = /* @__PURE__ */ new Set([...Object.keys(baseScope), ...Object.keys(overrideScope)]);
|
|
10918
10918
|
for (const key2 of keys) {
|
|
@@ -10924,20 +10924,20 @@ function mergeRuntimeScope(baseScope, overrideScope, path49 = []) {
|
|
|
10924
10924
|
}
|
|
10925
10925
|
continue;
|
|
10926
10926
|
}
|
|
10927
|
-
if (isRuntimeConcatenativeArray([...
|
|
10927
|
+
if (isRuntimeConcatenativeArray([...path54, key2]) && Array.isArray(baseValue) && Array.isArray(overrideValue)) {
|
|
10928
10928
|
merged[key2] = [...baseValue, ...overrideValue];
|
|
10929
10929
|
continue;
|
|
10930
10930
|
}
|
|
10931
10931
|
if (isRecord3(baseValue) && isRecord3(overrideValue)) {
|
|
10932
|
-
merged[key2] = mergeRuntimeScope(baseValue, overrideValue, [...
|
|
10932
|
+
merged[key2] = mergeRuntimeScope(baseValue, overrideValue, [...path54, key2]);
|
|
10933
10933
|
continue;
|
|
10934
10934
|
}
|
|
10935
10935
|
merged[key2] = overrideValue;
|
|
10936
10936
|
}
|
|
10937
10937
|
return merged;
|
|
10938
10938
|
}
|
|
10939
|
-
function isRuntimeConcatenativeArray(
|
|
10940
|
-
return
|
|
10939
|
+
function isRuntimeConcatenativeArray(path54) {
|
|
10940
|
+
return path54.join(".") === "mounts" || path54.join(".") === "runner.workspace.exclude";
|
|
10941
10941
|
}
|
|
10942
10942
|
function isRecord3(value) {
|
|
10943
10943
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -11092,6 +11092,30 @@ var init_codex = __esm({
|
|
|
11092
11092
|
}
|
|
11093
11093
|
});
|
|
11094
11094
|
|
|
11095
|
+
// packages/agent-defs/src/agents/gemini-cli.ts
|
|
11096
|
+
var geminiCliAgent;
|
|
11097
|
+
var init_gemini_cli = __esm({
|
|
11098
|
+
"packages/agent-defs/src/agents/gemini-cli.ts"() {
|
|
11099
|
+
"use strict";
|
|
11100
|
+
geminiCliAgent = {
|
|
11101
|
+
id: "gemini-cli",
|
|
11102
|
+
name: "gemini-cli",
|
|
11103
|
+
aliases: ["gemini"],
|
|
11104
|
+
label: "Gemini CLI",
|
|
11105
|
+
summary: "Configure Google's Gemini CLI to use a compatible Google generations API.",
|
|
11106
|
+
binaryName: "gemini",
|
|
11107
|
+
configPath: "~/.gemini/settings.json",
|
|
11108
|
+
apiShapes: ["google-generations"],
|
|
11109
|
+
branding: {
|
|
11110
|
+
colors: {
|
|
11111
|
+
dark: "#8AB4F8",
|
|
11112
|
+
light: "#1A73E8"
|
|
11113
|
+
}
|
|
11114
|
+
}
|
|
11115
|
+
};
|
|
11116
|
+
}
|
|
11117
|
+
});
|
|
11118
|
+
|
|
11095
11119
|
// packages/agent-defs/src/agents/opencode.ts
|
|
11096
11120
|
var openCodeAgent;
|
|
11097
11121
|
var init_opencode = __esm({
|
|
@@ -11191,6 +11215,7 @@ var init_agents = __esm({
|
|
|
11191
11215
|
init_claude_code();
|
|
11192
11216
|
init_claude_desktop();
|
|
11193
11217
|
init_codex();
|
|
11218
|
+
init_gemini_cli();
|
|
11194
11219
|
init_opencode();
|
|
11195
11220
|
init_kimi();
|
|
11196
11221
|
init_goose();
|
|
@@ -11214,6 +11239,7 @@ var init_registry = __esm({
|
|
|
11214
11239
|
claudeCodeAgent,
|
|
11215
11240
|
claudeDesktopAgent,
|
|
11216
11241
|
codexAgent,
|
|
11242
|
+
geminiCliAgent,
|
|
11217
11243
|
openCodeAgent,
|
|
11218
11244
|
kimiAgent,
|
|
11219
11245
|
gooseAgent,
|
|
@@ -11459,6 +11485,7 @@ var init_poe = __esm({
|
|
|
11459
11485
|
label: "Poe",
|
|
11460
11486
|
summary: "Route AI coding agents through Poe's API.",
|
|
11461
11487
|
baseUrl: "https://api.poe.com",
|
|
11488
|
+
agentBaseUrl: "https://api.poe.com",
|
|
11462
11489
|
auth: {
|
|
11463
11490
|
kind: "api-key",
|
|
11464
11491
|
envVar: "POE_API_KEY",
|
|
@@ -11466,6 +11493,12 @@ var init_poe = __esm({
|
|
|
11466
11493
|
prompt: { title: "Poe API key" },
|
|
11467
11494
|
preferredLogin: "oauth"
|
|
11468
11495
|
},
|
|
11496
|
+
env: {
|
|
11497
|
+
ANTHROPIC_CUSTOM_HEADERS: {
|
|
11498
|
+
kind: "providerCredential",
|
|
11499
|
+
prefix: "Authorization: Bearer "
|
|
11500
|
+
}
|
|
11501
|
+
},
|
|
11469
11502
|
apiShapes: [
|
|
11470
11503
|
{
|
|
11471
11504
|
id: "openai-chat-completions",
|
|
@@ -11500,6 +11533,9 @@ var init_anthropic = __esm({
|
|
|
11500
11533
|
storageKey: "provider:anthropic",
|
|
11501
11534
|
prompt: { title: "Anthropic API key" }
|
|
11502
11535
|
},
|
|
11536
|
+
env: {
|
|
11537
|
+
ANTHROPIC_API_KEY: { kind: "providerCredential" }
|
|
11538
|
+
},
|
|
11503
11539
|
apiShapes: [
|
|
11504
11540
|
{
|
|
11505
11541
|
id: "anthropic-messages",
|
|
@@ -11518,30 +11554,38 @@ var init_cloudflare = __esm({
|
|
|
11518
11554
|
cloudflareProvider = {
|
|
11519
11555
|
id: "cloudflare",
|
|
11520
11556
|
label: "Cloudflare AI Gateway",
|
|
11521
|
-
summary: "Route
|
|
11522
|
-
|
|
11557
|
+
summary: "Route coding agents through Cloudflare AI Gateway.",
|
|
11558
|
+
baseUrlEnvVar: "CF_AIG_BASE_URL",
|
|
11559
|
+
requiresBaseUrl: true,
|
|
11560
|
+
modelInput: { kind: "freeform" },
|
|
11523
11561
|
auth: {
|
|
11524
11562
|
kind: "api-key",
|
|
11525
|
-
envVar: "
|
|
11563
|
+
envVar: "CF_AIG_TOKEN",
|
|
11526
11564
|
storageKey: "provider:cloudflare",
|
|
11527
|
-
prompt: { title: "Cloudflare
|
|
11565
|
+
prompt: { title: "Cloudflare AI Gateway token" }
|
|
11566
|
+
},
|
|
11567
|
+
env: {
|
|
11568
|
+
ANTHROPIC_CUSTOM_HEADERS: {
|
|
11569
|
+
kind: "providerCredential",
|
|
11570
|
+
prefix: "Authorization: Bearer "
|
|
11571
|
+
}
|
|
11528
11572
|
},
|
|
11529
11573
|
apiShapes: [
|
|
11530
11574
|
{
|
|
11531
11575
|
id: "openai-chat-completions",
|
|
11532
|
-
|
|
11576
|
+
baseUrlPath: "compat"
|
|
11533
11577
|
},
|
|
11534
11578
|
{
|
|
11535
11579
|
id: "openai-responses",
|
|
11536
|
-
|
|
11580
|
+
baseUrlPath: "openai"
|
|
11537
11581
|
},
|
|
11538
11582
|
{
|
|
11539
11583
|
id: "anthropic-messages",
|
|
11540
|
-
|
|
11584
|
+
baseUrlPath: "anthropic"
|
|
11541
11585
|
},
|
|
11542
11586
|
{
|
|
11543
11587
|
id: "google-generations",
|
|
11544
|
-
|
|
11588
|
+
baseUrlPath: "google-ai-studio"
|
|
11545
11589
|
}
|
|
11546
11590
|
]
|
|
11547
11591
|
};
|
|
@@ -11635,17 +11679,17 @@ function isPidRunning(pid) {
|
|
|
11635
11679
|
}
|
|
11636
11680
|
function createDefaultFs() {
|
|
11637
11681
|
return {
|
|
11638
|
-
open: (
|
|
11639
|
-
readFile: (
|
|
11682
|
+
open: (path54, flags) => fsPromises2.open(path54, flags),
|
|
11683
|
+
readFile: (path54, encoding) => fsPromises2.readFile(path54, encoding),
|
|
11640
11684
|
stat: fsPromises2.stat,
|
|
11641
11685
|
unlink: fsPromises2.unlink
|
|
11642
11686
|
};
|
|
11643
11687
|
}
|
|
11644
|
-
async function removeLockFile(
|
|
11688
|
+
async function removeLockFile(fs7, lockPath, signal) {
|
|
11645
11689
|
for (let attempt = 0; attempt <= 4; attempt += 1) {
|
|
11646
11690
|
throwIfAborted(signal);
|
|
11647
11691
|
try {
|
|
11648
|
-
await
|
|
11692
|
+
await fs7.unlink(lockPath);
|
|
11649
11693
|
return;
|
|
11650
11694
|
} catch (error2) {
|
|
11651
11695
|
if (hasErrorCode(error2, "ENOENT")) {
|
|
@@ -11676,12 +11720,12 @@ function parseLockMetadata(content) {
|
|
|
11676
11720
|
}
|
|
11677
11721
|
return void 0;
|
|
11678
11722
|
}
|
|
11679
|
-
async function readLockMetadata(
|
|
11680
|
-
if (!
|
|
11723
|
+
async function readLockMetadata(fs7, lockPath) {
|
|
11724
|
+
if (!fs7.readFile) {
|
|
11681
11725
|
return void 0;
|
|
11682
11726
|
}
|
|
11683
11727
|
try {
|
|
11684
|
-
return parseLockMetadata(await
|
|
11728
|
+
return parseLockMetadata(await fs7.readFile(lockPath, "utf8"));
|
|
11685
11729
|
} catch (error2) {
|
|
11686
11730
|
if (hasErrorCode(error2, "ENOENT")) {
|
|
11687
11731
|
return null;
|
|
@@ -11715,7 +11759,7 @@ async function writeLockMetadata(handle) {
|
|
|
11715
11759
|
}
|
|
11716
11760
|
}
|
|
11717
11761
|
async function acquireFileLock(filePath, options = {}) {
|
|
11718
|
-
const
|
|
11762
|
+
const fs7 = options.fs ?? createDefaultFs();
|
|
11719
11763
|
const retries = options.retries ?? 20;
|
|
11720
11764
|
const minTimeout = options.minTimeout ?? 25;
|
|
11721
11765
|
const maxTimeout = options.maxTimeout ?? 250;
|
|
@@ -11726,7 +11770,7 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
11726
11770
|
while (attempt <= retries) {
|
|
11727
11771
|
throwIfAborted(options.signal);
|
|
11728
11772
|
try {
|
|
11729
|
-
const handle = await
|
|
11773
|
+
const handle = await fs7.open(lockPath, "wx");
|
|
11730
11774
|
await writeLockMetadata(handle);
|
|
11731
11775
|
let released = false;
|
|
11732
11776
|
return async () => {
|
|
@@ -11734,7 +11778,7 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
11734
11778
|
return;
|
|
11735
11779
|
}
|
|
11736
11780
|
released = true;
|
|
11737
|
-
await removeLockFile(
|
|
11781
|
+
await removeLockFile(fs7, lockPath, options.signal);
|
|
11738
11782
|
};
|
|
11739
11783
|
} catch (error2) {
|
|
11740
11784
|
if (!hasErrorCode(error2, "EEXIST")) {
|
|
@@ -11743,7 +11787,7 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
11743
11787
|
}
|
|
11744
11788
|
let stat7;
|
|
11745
11789
|
try {
|
|
11746
|
-
stat7 = await
|
|
11790
|
+
stat7 = await fs7.stat(lockPath);
|
|
11747
11791
|
} catch (statError) {
|
|
11748
11792
|
if (hasErrorCode(statError, "ENOENT")) {
|
|
11749
11793
|
continue;
|
|
@@ -11751,7 +11795,7 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
11751
11795
|
throw statError;
|
|
11752
11796
|
}
|
|
11753
11797
|
const reclaimLock = await shouldReclaimLock({
|
|
11754
|
-
fs:
|
|
11798
|
+
fs: fs7,
|
|
11755
11799
|
isPidRunning: pidIsRunning,
|
|
11756
11800
|
lockPath,
|
|
11757
11801
|
staleMs,
|
|
@@ -11761,7 +11805,7 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
11761
11805
|
continue;
|
|
11762
11806
|
}
|
|
11763
11807
|
if (reclaimLock) {
|
|
11764
|
-
await removeLockFile(
|
|
11808
|
+
await removeLockFile(fs7, lockPath, options.signal);
|
|
11765
11809
|
continue;
|
|
11766
11810
|
}
|
|
11767
11811
|
if (attempt >= retries) {
|
|
@@ -11808,7 +11852,7 @@ var init_fs = __esm({
|
|
|
11808
11852
|
|
|
11809
11853
|
// packages/poe-code-config/src/state/jobs.ts
|
|
11810
11854
|
import path9 from "node:path";
|
|
11811
|
-
function createJobRegistry(homeDir,
|
|
11855
|
+
function createJobRegistry(homeDir, fs7 = defaultStateFs) {
|
|
11812
11856
|
const jobsDir = path9.join(homeDir, ".poe-code", "state", "jobs");
|
|
11813
11857
|
function jobPath(id) {
|
|
11814
11858
|
assertSafeJobId(id);
|
|
@@ -11816,7 +11860,7 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11816
11860
|
}
|
|
11817
11861
|
async function get(id) {
|
|
11818
11862
|
try {
|
|
11819
|
-
return parseJobEntry(await
|
|
11863
|
+
return parseJobEntry(await fs7.readFile(jobPath(id), "utf8"));
|
|
11820
11864
|
} catch (error2) {
|
|
11821
11865
|
if (isNotFoundError(error2)) {
|
|
11822
11866
|
return null;
|
|
@@ -11827,8 +11871,8 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11827
11871
|
async function put(entry) {
|
|
11828
11872
|
assertJobEntry(entry);
|
|
11829
11873
|
const filePath = jobPath(entry.id);
|
|
11830
|
-
await
|
|
11831
|
-
const release = await acquireFileLock(filePath, { fs:
|
|
11874
|
+
await fs7.mkdir(jobsDir, { recursive: true });
|
|
11875
|
+
const release = await acquireFileLock(filePath, { fs: fs7 });
|
|
11832
11876
|
try {
|
|
11833
11877
|
await writeJobAtomically(filePath, entry);
|
|
11834
11878
|
} finally {
|
|
@@ -11837,8 +11881,8 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11837
11881
|
}
|
|
11838
11882
|
async function update(id, patch) {
|
|
11839
11883
|
const filePath = jobPath(id);
|
|
11840
|
-
await
|
|
11841
|
-
const release = await acquireFileLock(filePath, { fs:
|
|
11884
|
+
await fs7.mkdir(jobsDir, { recursive: true });
|
|
11885
|
+
const release = await acquireFileLock(filePath, { fs: fs7 });
|
|
11842
11886
|
try {
|
|
11843
11887
|
const current = await get(id);
|
|
11844
11888
|
if (current === null) {
|
|
@@ -11859,7 +11903,7 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11859
11903
|
async function list(filter = {}) {
|
|
11860
11904
|
let entries;
|
|
11861
11905
|
try {
|
|
11862
|
-
entries = await
|
|
11906
|
+
entries = await fs7.readdir(jobsDir);
|
|
11863
11907
|
} catch (error2) {
|
|
11864
11908
|
if (isNotFoundError(error2)) {
|
|
11865
11909
|
return [];
|
|
@@ -11872,11 +11916,11 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11872
11916
|
continue;
|
|
11873
11917
|
}
|
|
11874
11918
|
const filePath = path9.join(jobsDir, entry);
|
|
11875
|
-
const stat7 = await
|
|
11919
|
+
const stat7 = await fs7.stat(filePath);
|
|
11876
11920
|
if (!stat7.isFile()) {
|
|
11877
11921
|
continue;
|
|
11878
11922
|
}
|
|
11879
|
-
const job = parseJobEntry(await
|
|
11923
|
+
const job = parseJobEntry(await fs7.readFile(filePath, "utf8"));
|
|
11880
11924
|
if (matchesFilter(job, filter)) {
|
|
11881
11925
|
jobs.push(job);
|
|
11882
11926
|
}
|
|
@@ -11886,16 +11930,16 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11886
11930
|
async function remove2(id) {
|
|
11887
11931
|
const filePath = jobPath(id);
|
|
11888
11932
|
try {
|
|
11889
|
-
await
|
|
11933
|
+
await fs7.stat(jobsDir);
|
|
11890
11934
|
} catch (error2) {
|
|
11891
11935
|
if (isNotFoundError(error2)) {
|
|
11892
11936
|
return;
|
|
11893
11937
|
}
|
|
11894
11938
|
throw error2;
|
|
11895
11939
|
}
|
|
11896
|
-
const release = await acquireFileLock(filePath, { fs:
|
|
11940
|
+
const release = await acquireFileLock(filePath, { fs: fs7 });
|
|
11897
11941
|
try {
|
|
11898
|
-
await
|
|
11942
|
+
await fs7.unlink(filePath);
|
|
11899
11943
|
} catch (error2) {
|
|
11900
11944
|
if (!isNotFoundError(error2)) {
|
|
11901
11945
|
throw error2;
|
|
@@ -11905,14 +11949,14 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11905
11949
|
}
|
|
11906
11950
|
}
|
|
11907
11951
|
async function writeJobAtomically(filePath, entry) {
|
|
11908
|
-
await
|
|
11952
|
+
await fs7.mkdir(path9.dirname(filePath), { recursive: true });
|
|
11909
11953
|
const tempPath = `${filePath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
11910
11954
|
try {
|
|
11911
|
-
await
|
|
11955
|
+
await fs7.writeFile(tempPath, `${JSON.stringify(entry, null, 2)}
|
|
11912
11956
|
`, {
|
|
11913
11957
|
encoding: "utf8"
|
|
11914
11958
|
});
|
|
11915
|
-
await
|
|
11959
|
+
await fs7.rename(tempPath, filePath);
|
|
11916
11960
|
} catch (error2) {
|
|
11917
11961
|
await removeTempFile(tempPath);
|
|
11918
11962
|
throw error2;
|
|
@@ -11920,7 +11964,7 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11920
11964
|
}
|
|
11921
11965
|
async function removeTempFile(tempPath) {
|
|
11922
11966
|
try {
|
|
11923
|
-
await
|
|
11967
|
+
await fs7.unlink(tempPath);
|
|
11924
11968
|
} catch (error2) {
|
|
11925
11969
|
if (!isNotFoundError(error2)) {
|
|
11926
11970
|
throw error2;
|
|
@@ -11974,11 +12018,11 @@ var init_jobs2 = __esm({
|
|
|
11974
12018
|
|
|
11975
12019
|
// packages/poe-code-config/src/state/templates.ts
|
|
11976
12020
|
import path10 from "node:path";
|
|
11977
|
-
function createTemplateRegistry(homeDir,
|
|
12021
|
+
function createTemplateRegistry(homeDir, fs7 = defaultStateFs) {
|
|
11978
12022
|
const filePath = path10.join(homeDir, ".poe-code", "state", "templates.json");
|
|
11979
12023
|
async function readState() {
|
|
11980
12024
|
try {
|
|
11981
|
-
const raw = await
|
|
12025
|
+
const raw = await fs7.readFile(filePath, "utf8");
|
|
11982
12026
|
return normalizeTemplateState(JSON.parse(raw));
|
|
11983
12027
|
} catch (error2) {
|
|
11984
12028
|
if (isNotFoundError(error2)) {
|
|
@@ -11988,14 +12032,14 @@ function createTemplateRegistry(homeDir, fs6 = defaultStateFs) {
|
|
|
11988
12032
|
}
|
|
11989
12033
|
}
|
|
11990
12034
|
async function writeState(state) {
|
|
11991
|
-
await
|
|
12035
|
+
await fs7.writeFile(filePath, `${JSON.stringify(state, null, 2)}
|
|
11992
12036
|
`, {
|
|
11993
12037
|
encoding: "utf8"
|
|
11994
12038
|
});
|
|
11995
12039
|
}
|
|
11996
12040
|
async function updateState(mutator) {
|
|
11997
|
-
await
|
|
11998
|
-
const release = await acquireFileLock(filePath, { fs:
|
|
12041
|
+
await fs7.mkdir(path10.dirname(filePath), { recursive: true });
|
|
12042
|
+
const release = await acquireFileLock(filePath, { fs: fs7 });
|
|
11999
12043
|
try {
|
|
12000
12044
|
const state = await readState();
|
|
12001
12045
|
mutator(state);
|
|
@@ -12073,10 +12117,10 @@ var init_templates = __esm({
|
|
|
12073
12117
|
|
|
12074
12118
|
// packages/poe-code-config/src/state/index.ts
|
|
12075
12119
|
import os2 from "node:os";
|
|
12076
|
-
function createStateManager(homeDir,
|
|
12120
|
+
function createStateManager(homeDir, fs7) {
|
|
12077
12121
|
return {
|
|
12078
|
-
templates: createTemplateRegistry(homeDir,
|
|
12079
|
-
jobs: createJobRegistry(homeDir,
|
|
12122
|
+
templates: createTemplateRegistry(homeDir, fs7),
|
|
12123
|
+
jobs: createJobRegistry(homeDir, fs7)
|
|
12080
12124
|
};
|
|
12081
12125
|
}
|
|
12082
12126
|
var init_state2 = __esm({
|
|
@@ -12134,7 +12178,7 @@ var require_requirements_txt = __commonJS({
|
|
|
12134
12178
|
// src/templates/codex/config.toml.mustache
|
|
12135
12179
|
var require_config_toml = __commonJS({
|
|
12136
12180
|
"src/templates/codex/config.toml.mustache"(exports, module) {
|
|
12137
|
-
module.exports = 'model_provider = "{{providerId}}"\n\n[profiles."{{{profileName}}}"]\nmodel = "{{{model}}}"\nmodel_provider = "{{providerId}}"\nmodel_reasoning_effort = "{{reasoningEffort}}"\nmodel_verbosity = "medium"\n\n[model_providers.{{providerId}}]\nname = "{{providerId}}"\nbase_url = "{{{baseUrl}}}"\nwire_api = "responses"\nexperimental_bearer_token = "{{apiKey}}"\nrequires_openai_auth = false\nsupports_websockets = false\n';
|
|
12181
|
+
module.exports = 'model_provider = "{{providerId}}"\nmodel = "{{{model}}}"\nmodel_reasoning_effort = "{{reasoningEffort}}"\nmodel_verbosity = "medium"\n\n[profiles."{{{profileName}}}"]\nmodel = "{{{model}}}"\nmodel_provider = "{{providerId}}"\nmodel_reasoning_effort = "{{reasoningEffort}}"\nmodel_verbosity = "medium"\n\n[model_providers.{{providerId}}]\nname = "{{providerId}}"\nbase_url = "{{{baseUrl}}}"\nwire_api = "responses"\nexperimental_bearer_token = "{{apiKey}}"\nrequires_openai_auth = false\nsupports_websockets = false\n';
|
|
12138
12182
|
}
|
|
12139
12183
|
});
|
|
12140
12184
|
|
|
@@ -13758,9 +13802,9 @@ import fsPromises3 from "node:fs/promises";
|
|
|
13758
13802
|
import path12 from "node:path";
|
|
13759
13803
|
import { promisify } from "node:util";
|
|
13760
13804
|
import fastGlob from "fast-glob";
|
|
13761
|
-
async function fileExists(
|
|
13805
|
+
async function fileExists(fs7, filePath) {
|
|
13762
13806
|
try {
|
|
13763
|
-
await
|
|
13807
|
+
await fs7.stat(filePath);
|
|
13764
13808
|
return true;
|
|
13765
13809
|
} catch {
|
|
13766
13810
|
return false;
|
|
@@ -13798,11 +13842,11 @@ function getOptionalGrepOutputMode(args, key2) {
|
|
|
13798
13842
|
function formatDisplayPath(cwd, filePath) {
|
|
13799
13843
|
return path12.relative(cwd, filePath) || path12.basename(filePath);
|
|
13800
13844
|
}
|
|
13801
|
-
async function sortPathsByModifiedTime(matches,
|
|
13845
|
+
async function sortPathsByModifiedTime(matches, fs7) {
|
|
13802
13846
|
const entries = await Promise.all(
|
|
13803
13847
|
matches.map(async (match) => ({
|
|
13804
13848
|
path: match,
|
|
13805
|
-
mtimeMs: (await
|
|
13849
|
+
mtimeMs: (await fs7.stat(match)).mtimeMs
|
|
13806
13850
|
}))
|
|
13807
13851
|
);
|
|
13808
13852
|
entries.sort((left, right) => {
|
|
@@ -13813,8 +13857,8 @@ async function sortPathsByModifiedTime(matches, fs6) {
|
|
|
13813
13857
|
});
|
|
13814
13858
|
return entries.map((entry) => entry.path);
|
|
13815
13859
|
}
|
|
13816
|
-
async function defaultSearchContent(options,
|
|
13817
|
-
const targetStat = await
|
|
13860
|
+
async function defaultSearchContent(options, fs7) {
|
|
13861
|
+
const targetStat = await fs7.stat(options.path);
|
|
13818
13862
|
const searchCwd = targetStat.isDirectory() ? options.path : path12.dirname(options.path);
|
|
13819
13863
|
const searchTarget = targetStat.isDirectory() ? "." : path12.basename(options.path);
|
|
13820
13864
|
const args = ["--color", "never"];
|
|
@@ -13945,8 +13989,8 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
13945
13989
|
const allowedPaths = (options.allowedPaths ?? [cwd]).map(
|
|
13946
13990
|
(allowedPath) => path12.resolve(cwd, allowedPath)
|
|
13947
13991
|
);
|
|
13948
|
-
const
|
|
13949
|
-
const searchContent = options.searchContent ?? ((searchOptions) => defaultSearchContent(searchOptions,
|
|
13992
|
+
const fs7 = options.fs ?? fsPromises3;
|
|
13993
|
+
const searchContent = options.searchContent ?? ((searchOptions) => defaultSearchContent(searchOptions, fs7));
|
|
13950
13994
|
const globFiles = options.globFiles ?? defaultGlobFiles;
|
|
13951
13995
|
const readFileTool = {
|
|
13952
13996
|
name: "read_file",
|
|
@@ -13979,14 +14023,14 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
13979
14023
|
const filePath = resolveAllowedPath(cwd, allowedPaths, getRequiredString(args, "path"));
|
|
13980
14024
|
const imageMimeType = detectImageMimeType(filePath);
|
|
13981
14025
|
if (imageMimeType !== void 0) {
|
|
13982
|
-
const content2 = await
|
|
14026
|
+
const content2 = await fs7.readFile(filePath);
|
|
13983
14027
|
return {
|
|
13984
14028
|
type: "image",
|
|
13985
14029
|
mimeType: imageMimeType,
|
|
13986
14030
|
data: Buffer.from(content2).toString("base64")
|
|
13987
14031
|
};
|
|
13988
14032
|
}
|
|
13989
|
-
const content = await
|
|
14033
|
+
const content = await fs7.readFile(filePath, "utf8");
|
|
13990
14034
|
return sliceLines(
|
|
13991
14035
|
content,
|
|
13992
14036
|
getOptionalNonNegativeInteger(args, "offset") ?? 0,
|
|
@@ -14040,7 +14084,7 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
14040
14084
|
const oldStr = getRequiredString(args, "old_str", true);
|
|
14041
14085
|
const newStr = getRequiredString(args, "new_str", true);
|
|
14042
14086
|
const replaceAll2 = getOptionalBoolean(args, "replace_all") ?? false;
|
|
14043
|
-
const content = await
|
|
14087
|
+
const content = await fs7.readFile(filePath, "utf8");
|
|
14044
14088
|
if (oldStr.length === 0) {
|
|
14045
14089
|
throw new Error('Tool argument "old_str" must not be empty');
|
|
14046
14090
|
}
|
|
@@ -14051,7 +14095,7 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
14051
14095
|
if (!replaceAll2 && count > 1) {
|
|
14052
14096
|
throw new Error(`old_str appears ${count} times \u2014 must be unique`);
|
|
14053
14097
|
}
|
|
14054
|
-
await
|
|
14098
|
+
await fs7.writeFile(
|
|
14055
14099
|
filePath,
|
|
14056
14100
|
replaceAll2 ? content.split(oldStr).join(newStr) : content.replace(oldStr, newStr),
|
|
14057
14101
|
"utf8"
|
|
@@ -14060,17 +14104,17 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
14060
14104
|
}
|
|
14061
14105
|
if (command === "create") {
|
|
14062
14106
|
const fileText = getRequiredString(args, "file_text", true);
|
|
14063
|
-
if (await fileExists(
|
|
14107
|
+
if (await fileExists(fs7, filePath)) {
|
|
14064
14108
|
throw new Error("File already exists \u2014 use str_replace to edit");
|
|
14065
14109
|
}
|
|
14066
|
-
await
|
|
14067
|
-
await
|
|
14110
|
+
await fs7.mkdir(path12.dirname(filePath), { recursive: true });
|
|
14111
|
+
await fs7.writeFile(filePath, fileText, "utf8");
|
|
14068
14112
|
return `Created file: ${displayedPath}`;
|
|
14069
14113
|
}
|
|
14070
14114
|
if (command === "overwrite") {
|
|
14071
14115
|
const fileText = getRequiredString(args, "file_text", true);
|
|
14072
|
-
await
|
|
14073
|
-
await
|
|
14116
|
+
await fs7.mkdir(path12.dirname(filePath), { recursive: true });
|
|
14117
|
+
await fs7.writeFile(filePath, fileText, "utf8");
|
|
14074
14118
|
return `Overwrote file: ${displayedPath}`;
|
|
14075
14119
|
}
|
|
14076
14120
|
throw new Error(`Unknown edit_file command: ${command}`);
|
|
@@ -14095,7 +14139,7 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
14095
14139
|
async call(args) {
|
|
14096
14140
|
const rawPath = getOptionalString(args, "path") ?? ".";
|
|
14097
14141
|
const directoryPath = resolveAllowedPath(cwd, allowedPaths, rawPath);
|
|
14098
|
-
const entries = await
|
|
14142
|
+
const entries = await fs7.readdir(directoryPath);
|
|
14099
14143
|
const names = entries.sort((left, right) => left.localeCompare(right));
|
|
14100
14144
|
if (names.length === 0) {
|
|
14101
14145
|
return "(empty directory)";
|
|
@@ -14191,7 +14235,7 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
14191
14235
|
});
|
|
14192
14236
|
const sortedMatches = await sortPathsByModifiedTime(
|
|
14193
14237
|
matches.map((match) => resolveAllowedPath(cwd, allowedPaths, match)),
|
|
14194
|
-
|
|
14238
|
+
fs7
|
|
14195
14239
|
);
|
|
14196
14240
|
if (sortedMatches.length === 0) {
|
|
14197
14241
|
return "(no matches)";
|
|
@@ -16743,11 +16787,11 @@ async function loadMemory(options) {
|
|
|
16743
16787
|
}
|
|
16744
16788
|
return sections.join("\n\n");
|
|
16745
16789
|
}
|
|
16746
|
-
async function findNearestAgentsFile(cwd,
|
|
16790
|
+
async function findNearestAgentsFile(cwd, fs7) {
|
|
16747
16791
|
let currentDirectory = cwd;
|
|
16748
16792
|
while (true) {
|
|
16749
16793
|
const filePath = path15.join(currentDirectory, AGENTS_FILE);
|
|
16750
|
-
if (await readOptionalFile(filePath,
|
|
16794
|
+
if (await readOptionalFile(filePath, fs7) !== void 0) {
|
|
16751
16795
|
return filePath;
|
|
16752
16796
|
}
|
|
16753
16797
|
const parentDirectory = path15.dirname(currentDirectory);
|
|
@@ -16757,15 +16801,15 @@ async function findNearestAgentsFile(cwd, fs6) {
|
|
|
16757
16801
|
currentDirectory = parentDirectory;
|
|
16758
16802
|
}
|
|
16759
16803
|
}
|
|
16760
|
-
async function loadOptionalMemoryFile(filePath,
|
|
16761
|
-
const content = await readOptionalFile(filePath,
|
|
16804
|
+
async function loadOptionalMemoryFile(filePath, fs7) {
|
|
16805
|
+
const content = await readOptionalFile(filePath, fs7);
|
|
16762
16806
|
if (content === void 0) {
|
|
16763
16807
|
return void 0;
|
|
16764
16808
|
}
|
|
16765
16809
|
return await expandImports({
|
|
16766
16810
|
filePath,
|
|
16767
16811
|
content,
|
|
16768
|
-
fs:
|
|
16812
|
+
fs: fs7,
|
|
16769
16813
|
loading: /* @__PURE__ */ new Set()
|
|
16770
16814
|
});
|
|
16771
16815
|
}
|
|
@@ -16816,9 +16860,9 @@ ${content}`;
|
|
|
16816
16860
|
function normalizeLineEndings(content) {
|
|
16817
16861
|
return content.split("\r\n").join("\n");
|
|
16818
16862
|
}
|
|
16819
|
-
async function readOptionalFile(filePath,
|
|
16863
|
+
async function readOptionalFile(filePath, fs7) {
|
|
16820
16864
|
try {
|
|
16821
|
-
return await
|
|
16865
|
+
return await fs7.readFile(filePath, "utf8");
|
|
16822
16866
|
} catch (error2) {
|
|
16823
16867
|
if (isMissingFileError(error2)) {
|
|
16824
16868
|
return void 0;
|
|
@@ -16826,8 +16870,8 @@ async function readOptionalFile(filePath, fs6) {
|
|
|
16826
16870
|
throw error2;
|
|
16827
16871
|
}
|
|
16828
16872
|
}
|
|
16829
|
-
async function readRequiredFile(filePath,
|
|
16830
|
-
const content = await readOptionalFile(filePath,
|
|
16873
|
+
async function readRequiredFile(filePath, fs7) {
|
|
16874
|
+
const content = await readOptionalFile(filePath, fs7);
|
|
16831
16875
|
if (content !== void 0) {
|
|
16832
16876
|
return content;
|
|
16833
16877
|
}
|
|
@@ -16849,12 +16893,12 @@ var init_poe_agent_plugin_memory = __esm({
|
|
|
16849
16893
|
memoryPlugin = (options = {}) => {
|
|
16850
16894
|
const cwd = path15.resolve(options.cwd ?? process.cwd());
|
|
16851
16895
|
const homeDir = path15.resolve(options.homeDir ?? os3.homedir());
|
|
16852
|
-
const
|
|
16896
|
+
const fs7 = options.fs ?? fsPromises4;
|
|
16853
16897
|
let memoryPromise;
|
|
16854
16898
|
return {
|
|
16855
16899
|
name: "poe-agent-plugin-memory",
|
|
16856
16900
|
async prompt(ctx) {
|
|
16857
|
-
memoryPromise ??= loadMemory({ cwd, homeDir, fs:
|
|
16901
|
+
memoryPromise ??= loadMemory({ cwd, homeDir, fs: fs7 });
|
|
16858
16902
|
const memory = await memoryPromise;
|
|
16859
16903
|
if (!memory) {
|
|
16860
16904
|
return ctx;
|
|
@@ -20951,9 +20995,9 @@ function validateTaskId(id) {
|
|
|
20951
20995
|
}
|
|
20952
20996
|
return id;
|
|
20953
20997
|
}
|
|
20954
|
-
async function statIfExists(
|
|
20998
|
+
async function statIfExists(fs7, filePath) {
|
|
20955
20999
|
try {
|
|
20956
|
-
return await
|
|
21000
|
+
return await fs7.stat(filePath);
|
|
20957
21001
|
} catch (error2) {
|
|
20958
21002
|
if (hasErrorCode2(error2, "ENOENT")) {
|
|
20959
21003
|
return void 0;
|
|
@@ -20961,16 +21005,16 @@ async function statIfExists(fs6, filePath) {
|
|
|
20961
21005
|
throw error2;
|
|
20962
21006
|
}
|
|
20963
21007
|
}
|
|
20964
|
-
async function writeAtomically(
|
|
21008
|
+
async function writeAtomically(fs7, filePath, content) {
|
|
20965
21009
|
const tempPath = `${filePath}.tmp-${process.pid}-${tmpFileCounter}`;
|
|
20966
21010
|
tmpFileCounter += 1;
|
|
20967
|
-
await
|
|
21011
|
+
await fs7.mkdir(path21.dirname(filePath), { recursive: true });
|
|
20968
21012
|
try {
|
|
20969
|
-
await
|
|
20970
|
-
await
|
|
21013
|
+
await fs7.writeFile(tempPath, content, { encoding: "utf8", flag: "wx" });
|
|
21014
|
+
await fs7.rename(tempPath, filePath);
|
|
20971
21015
|
} catch (error2) {
|
|
20972
21016
|
try {
|
|
20973
|
-
await
|
|
21017
|
+
await fs7.unlink(tempPath);
|
|
20974
21018
|
} catch (unlinkError) {
|
|
20975
21019
|
if (!hasErrorCode2(unlinkError, "ENOENT")) {
|
|
20976
21020
|
throw unlinkError;
|
|
@@ -21907,9 +21951,9 @@ ${stringify(frontmatter)}---
|
|
|
21907
21951
|
|
|
21908
21952
|
${description}`;
|
|
21909
21953
|
}
|
|
21910
|
-
async function readDirectoryNames(
|
|
21954
|
+
async function readDirectoryNames(fs7, directoryPath) {
|
|
21911
21955
|
try {
|
|
21912
|
-
return sortStrings(await
|
|
21956
|
+
return sortStrings(await fs7.readdir(directoryPath));
|
|
21913
21957
|
} catch (error2) {
|
|
21914
21958
|
if (hasErrorCode2(error2, "ENOENT")) {
|
|
21915
21959
|
return [];
|
|
@@ -21924,8 +21968,8 @@ async function ensureRootPath(deps) {
|
|
|
21924
21968
|
}
|
|
21925
21969
|
await deps.fs.stat(deps.path);
|
|
21926
21970
|
}
|
|
21927
|
-
async function readTaskFile(
|
|
21928
|
-
const content = await
|
|
21971
|
+
async function readTaskFile(fs7, list, id, filePath, validStates, initialState, mode) {
|
|
21972
|
+
const content = await fs7.readFile(filePath, "utf8");
|
|
21929
21973
|
const document = splitTaskDocument(content, filePath, mode);
|
|
21930
21974
|
const frontmatter = mode === "passthrough" && document.frontmatter.trim().length === 0 ? {} : readFrontmatter(document.frontmatter, filePath);
|
|
21931
21975
|
if (mode !== "passthrough") {
|
|
@@ -21949,8 +21993,8 @@ async function readTaskFile(fs6, list, id, filePath, validStates, initialState,
|
|
|
21949
21993
|
task: createTask(list, id, effectiveFrontmatter, document.body, mode, filePath)
|
|
21950
21994
|
};
|
|
21951
21995
|
}
|
|
21952
|
-
async function findActiveTaskFilename(
|
|
21953
|
-
const entries = await readDirectoryNames(
|
|
21996
|
+
async function findActiveTaskFilename(fs7, listDirectoryPath, id) {
|
|
21997
|
+
const entries = await readDirectoryNames(fs7, listDirectoryPath);
|
|
21954
21998
|
for (const entryName of entries) {
|
|
21955
21999
|
if (isHiddenEntry(entryName) || isLockFile(entryName)) continue;
|
|
21956
22000
|
const parsed = parseActiveFilename(entryName);
|
|
@@ -21960,29 +22004,29 @@ async function findActiveTaskFilename(fs6, listDirectoryPath, id) {
|
|
|
21960
22004
|
}
|
|
21961
22005
|
return void 0;
|
|
21962
22006
|
}
|
|
21963
|
-
async function findTaskLocation(
|
|
22007
|
+
async function findTaskLocation(fs7, rootPath, layout, list, id) {
|
|
21964
22008
|
const listDirectoryPath = listPath(rootPath, layout, list);
|
|
21965
|
-
const activeName = await findActiveTaskFilename(
|
|
22009
|
+
const activeName = await findActiveTaskFilename(fs7, listDirectoryPath, id);
|
|
21966
22010
|
if (activeName) {
|
|
21967
22011
|
const activePath = path22.join(listDirectoryPath, activeName);
|
|
21968
|
-
const activeStat = await statIfExists(
|
|
22012
|
+
const activeStat = await statIfExists(fs7, activePath);
|
|
21969
22013
|
if (activeStat?.isFile()) {
|
|
21970
22014
|
return { archived: false, path: activePath };
|
|
21971
22015
|
}
|
|
21972
22016
|
}
|
|
21973
22017
|
const archivedPath = archivedTaskPath(rootPath, layout, list, id);
|
|
21974
|
-
const archivedStat = await statIfExists(
|
|
22018
|
+
const archivedStat = await statIfExists(fs7, archivedPath);
|
|
21975
22019
|
if (archivedStat?.isFile()) {
|
|
21976
22020
|
return { archived: true, path: archivedPath };
|
|
21977
22021
|
}
|
|
21978
22022
|
return void 0;
|
|
21979
22023
|
}
|
|
21980
|
-
async function readTaskAtLocation(
|
|
21981
|
-
const location = await findTaskLocation(
|
|
22024
|
+
async function readTaskAtLocation(fs7, rootPath, layout, list, id, validStates, initialState, mode) {
|
|
22025
|
+
const location = await findTaskLocation(fs7, rootPath, layout, list, id);
|
|
21982
22026
|
if (!location) {
|
|
21983
22027
|
throw new TaskNotFoundError(`Task "${list}/${id}" not found.`);
|
|
21984
22028
|
}
|
|
21985
|
-
return readTaskFile(
|
|
22029
|
+
return readTaskFile(fs7, list, id, location.path, validStates, initialState, mode);
|
|
21986
22030
|
}
|
|
21987
22031
|
function createdFrontmatter(defaults, input, initialState, mode) {
|
|
21988
22032
|
const frontmatter = mode !== "passthrough" ? {
|
|
@@ -22908,8 +22952,8 @@ function serializeDocument(document) {
|
|
|
22908
22952
|
return serialized.endsWith("\n") ? serialized : `${serialized}
|
|
22909
22953
|
`;
|
|
22910
22954
|
}
|
|
22911
|
-
async function readStore(
|
|
22912
|
-
const content = await
|
|
22955
|
+
async function readStore(fs7, filePath, validStates) {
|
|
22956
|
+
const content = await fs7.readFile(filePath, "utf8");
|
|
22913
22957
|
const document = parseStoreDocument(filePath, content);
|
|
22914
22958
|
const store = document.toJS();
|
|
22915
22959
|
assertValidStoreRecord(store, filePath);
|
|
@@ -23402,9 +23446,9 @@ function defaultFs() {
|
|
|
23402
23446
|
function hasErrorCode3(error2, code) {
|
|
23403
23447
|
return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
|
|
23404
23448
|
}
|
|
23405
|
-
async function directoryExists(
|
|
23449
|
+
async function directoryExists(fs7, directoryPath) {
|
|
23406
23450
|
try {
|
|
23407
|
-
return (await
|
|
23451
|
+
return (await fs7.stat(directoryPath)).isDirectory();
|
|
23408
23452
|
} catch (error2) {
|
|
23409
23453
|
if (hasErrorCode3(error2, "ENOENT") || hasErrorCode3(error2, "ENOTDIR")) {
|
|
23410
23454
|
return false;
|
|
@@ -23432,8 +23476,8 @@ function idFromPlanFileName(fileName) {
|
|
|
23432
23476
|
}
|
|
23433
23477
|
return stem;
|
|
23434
23478
|
}
|
|
23435
|
-
async function readPlanPaths(
|
|
23436
|
-
const fileNames = await
|
|
23479
|
+
async function readPlanPaths(fs7, directoryPath) {
|
|
23480
|
+
const fileNames = await fs7.readdir(directoryPath);
|
|
23437
23481
|
const pathsById = /* @__PURE__ */ new Map();
|
|
23438
23482
|
for (const fileName of fileNames) {
|
|
23439
23483
|
const id = idFromPlanFileName(fileName);
|
|
@@ -23441,7 +23485,7 @@ async function readPlanPaths(fs6, directoryPath) {
|
|
|
23441
23485
|
continue;
|
|
23442
23486
|
}
|
|
23443
23487
|
const absolutePath = path24.join(directoryPath, fileName);
|
|
23444
|
-
const stat7 = await
|
|
23488
|
+
const stat7 = await fs7.stat(absolutePath);
|
|
23445
23489
|
if (stat7.isFile()) {
|
|
23446
23490
|
pathsById.set(id, absolutePath);
|
|
23447
23491
|
}
|
|
@@ -23470,13 +23514,13 @@ function planKind(metadata) {
|
|
|
23470
23514
|
}
|
|
23471
23515
|
async function discoverPlans(options) {
|
|
23472
23516
|
const resolvedDirectory = resolvePlanDirectory(options);
|
|
23473
|
-
const
|
|
23474
|
-
if (!await directoryExists(
|
|
23517
|
+
const fs7 = options.fs ?? defaultFs();
|
|
23518
|
+
if (!await directoryExists(fs7, resolvedDirectory)) {
|
|
23475
23519
|
return [];
|
|
23476
23520
|
}
|
|
23477
23521
|
const [taskList, pathsById] = await Promise.all([
|
|
23478
23522
|
openPlanList(options),
|
|
23479
|
-
readPlanPaths(
|
|
23523
|
+
readPlanPaths(fs7, resolvedDirectory)
|
|
23480
23524
|
]);
|
|
23481
23525
|
const kindFilter = options.kinds === void 0 ? void 0 : new Set(options.kinds);
|
|
23482
23526
|
const tasks = await taskList.list(PLAN_LIST_NAME).all();
|
|
@@ -23693,29 +23737,29 @@ function wrapForLogTee(argv, jobId) {
|
|
|
23693
23737
|
return ["sh", "-c", script];
|
|
23694
23738
|
}
|
|
23695
23739
|
async function* streamLogFile(env, jobId, opts) {
|
|
23696
|
-
const
|
|
23740
|
+
const fs7 = env.fs ?? nodeFs2;
|
|
23697
23741
|
const file = jobLogPath(jobId);
|
|
23698
23742
|
let byteOffset = opts.sinceByte ?? 0;
|
|
23699
23743
|
while (true) {
|
|
23700
|
-
if (opts.since !== void 0 && !await wasModifiedSince(
|
|
23701
|
-
await waitForLogChange(
|
|
23744
|
+
if (opts.since !== void 0 && !await wasModifiedSince(fs7, file, opts.since)) {
|
|
23745
|
+
await waitForLogChange(fs7, file);
|
|
23702
23746
|
continue;
|
|
23703
23747
|
}
|
|
23704
|
-
const result = await readLogChunk(
|
|
23748
|
+
const result = await readLogChunk(fs7, file, byteOffset);
|
|
23705
23749
|
if (result !== null) {
|
|
23706
23750
|
byteOffset = result.nextByteOffset;
|
|
23707
23751
|
yield result.chunk;
|
|
23708
23752
|
continue;
|
|
23709
23753
|
}
|
|
23710
|
-
await waitForLogChange(
|
|
23754
|
+
await waitForLogChange(fs7, file);
|
|
23711
23755
|
}
|
|
23712
23756
|
}
|
|
23713
|
-
async function wasModifiedSince(
|
|
23714
|
-
if (
|
|
23757
|
+
async function wasModifiedSince(fs7, file, since) {
|
|
23758
|
+
if (fs7.promises.stat === void 0) {
|
|
23715
23759
|
return true;
|
|
23716
23760
|
}
|
|
23717
23761
|
try {
|
|
23718
|
-
const stat7 = await
|
|
23762
|
+
const stat7 = await fs7.promises.stat(file);
|
|
23719
23763
|
return stat7.mtimeMs >= since.getTime();
|
|
23720
23764
|
} catch (error2) {
|
|
23721
23765
|
if (isNodeError(error2) && error2.code === "ENOENT") {
|
|
@@ -23725,11 +23769,11 @@ async function wasModifiedSince(fs6, file, since) {
|
|
|
23725
23769
|
}
|
|
23726
23770
|
}
|
|
23727
23771
|
async function waitForExit(env, jobId, opts = {}) {
|
|
23728
|
-
const
|
|
23772
|
+
const fs7 = env.fs ?? nodeFs2;
|
|
23729
23773
|
const file = jobExitPath(jobId);
|
|
23730
23774
|
while (true) {
|
|
23731
23775
|
throwIfAborted2(opts.signal);
|
|
23732
|
-
const contents = await readTextFileIfExists(
|
|
23776
|
+
const contents = await readTextFileIfExists(fs7, file);
|
|
23733
23777
|
if (contents !== null) {
|
|
23734
23778
|
const text5 = contents.trim();
|
|
23735
23779
|
const exitCode = Number(text5);
|
|
@@ -23747,8 +23791,8 @@ function jobLogPath(jobId) {
|
|
|
23747
23791
|
function jobExitPath(jobId) {
|
|
23748
23792
|
return `${JOB_DIR}/${jobId}.exit`;
|
|
23749
23793
|
}
|
|
23750
|
-
async function readLogChunk(
|
|
23751
|
-
const contents = await readFileIfExists2(
|
|
23794
|
+
async function readLogChunk(fs7, file, byteOffset) {
|
|
23795
|
+
const contents = await readFileIfExists2(fs7, file);
|
|
23752
23796
|
if (contents === null || byteOffset >= contents.byteLength) {
|
|
23753
23797
|
return null;
|
|
23754
23798
|
}
|
|
@@ -23760,13 +23804,13 @@ async function readLogChunk(fs6, file, byteOffset) {
|
|
|
23760
23804
|
nextByteOffset: contents.byteLength
|
|
23761
23805
|
};
|
|
23762
23806
|
}
|
|
23763
|
-
async function readTextFileIfExists(
|
|
23764
|
-
const contents = await readFileIfExists2(
|
|
23807
|
+
async function readTextFileIfExists(fs7, file) {
|
|
23808
|
+
const contents = await readFileIfExists2(fs7, file);
|
|
23765
23809
|
return contents?.toString("utf8") ?? null;
|
|
23766
23810
|
}
|
|
23767
|
-
async function readFileIfExists2(
|
|
23811
|
+
async function readFileIfExists2(fs7, file) {
|
|
23768
23812
|
try {
|
|
23769
|
-
const contents = await
|
|
23813
|
+
const contents = await fs7.promises.readFile(file);
|
|
23770
23814
|
return Buffer.isBuffer(contents) ? contents : Buffer.from(contents);
|
|
23771
23815
|
} catch (error2) {
|
|
23772
23816
|
if (isNodeError(error2) && error2.code === "ENOENT") {
|
|
@@ -23775,8 +23819,8 @@ async function readFileIfExists2(fs6, file) {
|
|
|
23775
23819
|
throw error2;
|
|
23776
23820
|
}
|
|
23777
23821
|
}
|
|
23778
|
-
async function waitForLogChange(
|
|
23779
|
-
const watch =
|
|
23822
|
+
async function waitForLogChange(fs7, file) {
|
|
23823
|
+
const watch = fs7.watch;
|
|
23780
23824
|
if (typeof watch !== "function") {
|
|
23781
23825
|
await sleep2(POLL_INTERVAL_MS);
|
|
23782
23826
|
return;
|
|
@@ -24642,7 +24686,7 @@ var init_template_build = __esm({
|
|
|
24642
24686
|
// packages/runner-e2b/src/job-handle.ts
|
|
24643
24687
|
import path28 from "node:path";
|
|
24644
24688
|
function createE2bJobHandle(input) {
|
|
24645
|
-
const
|
|
24689
|
+
const fs7 = createE2bLogStreamFs(input.sandbox);
|
|
24646
24690
|
return {
|
|
24647
24691
|
id: input.jobId,
|
|
24648
24692
|
envId: input.envId,
|
|
@@ -24658,10 +24702,10 @@ function createE2bJobHandle(input) {
|
|
|
24658
24702
|
return isRunning ? "running" : "lost";
|
|
24659
24703
|
},
|
|
24660
24704
|
stream(opts = {}) {
|
|
24661
|
-
return streamLogFile({ fs:
|
|
24705
|
+
return streamLogFile({ fs: fs7 }, input.jobId, opts);
|
|
24662
24706
|
},
|
|
24663
24707
|
async wait() {
|
|
24664
|
-
const result = await waitForExit({ fs:
|
|
24708
|
+
const result = await waitForExit({ fs: fs7 }, input.jobId);
|
|
24665
24709
|
const preserveMs = input.preserveAfterExitHours * 60 * 60 * 1e3;
|
|
24666
24710
|
if (preserveMs > 0) {
|
|
24667
24711
|
await input.sandbox.setTimeout(preserveMs);
|
|
@@ -25172,10 +25216,10 @@ import os5 from "node:os";
|
|
|
25172
25216
|
import { promises as nodeFs4 } from "node:fs";
|
|
25173
25217
|
async function resolveE2bApiKey(input) {
|
|
25174
25218
|
const homeDir = input.homeDir ?? os5.homedir();
|
|
25175
|
-
const
|
|
25219
|
+
const fs7 = input.fs ?? nodeFs4;
|
|
25176
25220
|
const env = input.env ?? process.env;
|
|
25177
25221
|
const document = await readMergedDocument(
|
|
25178
|
-
|
|
25222
|
+
fs7,
|
|
25179
25223
|
resolveConfigPath(homeDir),
|
|
25180
25224
|
resolveProjectConfigPath(input.cwd)
|
|
25181
25225
|
);
|
|
@@ -25826,6 +25870,29 @@ var init_goose2 = __esm({
|
|
|
25826
25870
|
}
|
|
25827
25871
|
});
|
|
25828
25872
|
|
|
25873
|
+
// packages/agent-spawn/src/configs/gemini-cli.ts
|
|
25874
|
+
var geminiCliAcpSpawnConfig;
|
|
25875
|
+
var init_gemini_cli2 = __esm({
|
|
25876
|
+
"packages/agent-spawn/src/configs/gemini-cli.ts"() {
|
|
25877
|
+
"use strict";
|
|
25878
|
+
geminiCliAcpSpawnConfig = {
|
|
25879
|
+
kind: "acp",
|
|
25880
|
+
agentId: "gemini-cli",
|
|
25881
|
+
acpArgs: ({ model, mcpServers }) => [
|
|
25882
|
+
"--acp",
|
|
25883
|
+
...model ? ["--model", model] : [],
|
|
25884
|
+
...mcpServers ? ["--allowed-mcp-server-names", Object.keys(mcpServers).join(",")] : [],
|
|
25885
|
+
...mcpServers ? ["--skip-trust"] : [],
|
|
25886
|
+
"--yolo"
|
|
25887
|
+
],
|
|
25888
|
+
env: {
|
|
25889
|
+
GEMINI_SANDBOX: "false"
|
|
25890
|
+
},
|
|
25891
|
+
skipAuth: true
|
|
25892
|
+
};
|
|
25893
|
+
}
|
|
25894
|
+
});
|
|
25895
|
+
|
|
25829
25896
|
// packages/agent-spawn/src/configs/index.ts
|
|
25830
25897
|
function getSpawnConfig(input) {
|
|
25831
25898
|
const resolvedId = resolveAgentId(input);
|
|
@@ -25854,6 +25921,7 @@ var init_configs = __esm({
|
|
|
25854
25921
|
init_opencode2();
|
|
25855
25922
|
init_kimi2();
|
|
25856
25923
|
init_goose2();
|
|
25924
|
+
init_gemini_cli2();
|
|
25857
25925
|
allSpawnConfigs = [
|
|
25858
25926
|
claudeCodeSpawnConfig,
|
|
25859
25927
|
codexSpawnConfig,
|
|
@@ -25869,6 +25937,7 @@ var init_configs = __esm({
|
|
|
25869
25937
|
acpLookup.set(openCodeAcpSpawnConfig.agentId, openCodeAcpSpawnConfig);
|
|
25870
25938
|
acpLookup.set(kimiAcpSpawnConfig.agentId, kimiAcpSpawnConfig);
|
|
25871
25939
|
acpLookup.set(gooseAcpSpawnConfig.agentId, gooseAcpSpawnConfig);
|
|
25940
|
+
acpLookup.set(geminiCliAcpSpawnConfig.agentId, geminiCliAcpSpawnConfig);
|
|
25872
25941
|
}
|
|
25873
25942
|
});
|
|
25874
25943
|
|
|
@@ -26371,6 +26440,10 @@ var init_configs2 = __esm({
|
|
|
26371
26440
|
globalSkillDir: "~/.codex/skills",
|
|
26372
26441
|
localSkillDir: ".codex/skills"
|
|
26373
26442
|
},
|
|
26443
|
+
"gemini-cli": {
|
|
26444
|
+
globalSkillDir: "~/.gemini/skills",
|
|
26445
|
+
localSkillDir: ".gemini/skills"
|
|
26446
|
+
},
|
|
26374
26447
|
opencode: {
|
|
26375
26448
|
globalSkillDir: "~/.config/opencode/skills",
|
|
26376
26449
|
localSkillDir: ".opencode/skills"
|
|
@@ -26565,10 +26638,10 @@ function resolveExcludePath(cwd) {
|
|
|
26565
26638
|
}
|
|
26566
26639
|
return path34.join(path34.isAbsolute(gitDir) ? gitDir : path34.resolve(cwd, gitDir), "info/exclude");
|
|
26567
26640
|
}
|
|
26568
|
-
function markers(runId) {
|
|
26641
|
+
function markers(runId, markerPrefix) {
|
|
26569
26642
|
return {
|
|
26570
|
-
begin:
|
|
26571
|
-
end:
|
|
26643
|
+
begin: `# ${markerPrefix}:${runId} begin`,
|
|
26644
|
+
end: `# ${markerPrefix}:${runId} end`
|
|
26572
26645
|
};
|
|
26573
26646
|
}
|
|
26574
26647
|
function readExcludeFile(excludePath) {
|
|
@@ -26584,8 +26657,8 @@ function readExcludeFile(excludePath) {
|
|
|
26584
26657
|
function isNodeError2(error2) {
|
|
26585
26658
|
return error2 instanceof Error && "code" in error2;
|
|
26586
26659
|
}
|
|
26587
|
-
function removeBlock(content, runId) {
|
|
26588
|
-
const { begin, end } = markers(runId);
|
|
26660
|
+
function removeBlock(content, runId, markerPrefix) {
|
|
26661
|
+
const { begin, end } = markers(runId, markerPrefix);
|
|
26589
26662
|
const lines = content.split("\n");
|
|
26590
26663
|
const result = [];
|
|
26591
26664
|
for (let index = 0; index < lines.length; index += 1) {
|
|
@@ -26600,23 +26673,27 @@ function removeBlock(content, runId) {
|
|
|
26600
26673
|
}
|
|
26601
26674
|
return result.join("\n");
|
|
26602
26675
|
}
|
|
26603
|
-
function appendBlock(content, runId, entries) {
|
|
26604
|
-
const { begin, end } = markers(runId);
|
|
26676
|
+
function appendBlock(content, runId, entries, markerPrefix) {
|
|
26677
|
+
const { begin, end } = markers(runId, markerPrefix);
|
|
26605
26678
|
const existing = content ?? "";
|
|
26606
26679
|
const prefix = existing.length === 0 || existing.endsWith("\n") ? existing : `${existing}
|
|
26607
26680
|
`;
|
|
26608
26681
|
return `${prefix}${[begin, ...entries, end, ""].join("\n")}`;
|
|
26609
26682
|
}
|
|
26610
|
-
function appendExcludeBlock(cwd, runId, entries) {
|
|
26683
|
+
function appendExcludeBlock(cwd, runId, entries, opts) {
|
|
26611
26684
|
const excludePath = resolveExcludePath(cwd);
|
|
26612
26685
|
if (excludePath === void 0) {
|
|
26613
26686
|
return;
|
|
26614
26687
|
}
|
|
26615
26688
|
fs2.mkdirSync(path34.dirname(excludePath), { recursive: true });
|
|
26616
26689
|
const content = readExcludeFile(excludePath);
|
|
26617
|
-
fs2.writeFileSync(
|
|
26690
|
+
fs2.writeFileSync(
|
|
26691
|
+
excludePath,
|
|
26692
|
+
appendBlock(content, runId, entries, opts?.markerPrefix ?? defaultMarkerPrefix),
|
|
26693
|
+
"utf8"
|
|
26694
|
+
);
|
|
26618
26695
|
}
|
|
26619
|
-
function removeExcludeBlock(cwd, runId) {
|
|
26696
|
+
function removeExcludeBlock(cwd, runId, opts) {
|
|
26620
26697
|
const excludePath = resolveExcludePath(cwd);
|
|
26621
26698
|
if (excludePath === void 0) {
|
|
26622
26699
|
return;
|
|
@@ -26625,13 +26702,17 @@ function removeExcludeBlock(cwd, runId) {
|
|
|
26625
26702
|
if (content === void 0) {
|
|
26626
26703
|
return;
|
|
26627
26704
|
}
|
|
26628
|
-
fs2.writeFileSync(
|
|
26705
|
+
fs2.writeFileSync(
|
|
26706
|
+
excludePath,
|
|
26707
|
+
removeBlock(content, runId, opts?.markerPrefix ?? defaultMarkerPrefix),
|
|
26708
|
+
"utf8"
|
|
26709
|
+
);
|
|
26629
26710
|
}
|
|
26630
|
-
var
|
|
26711
|
+
var defaultMarkerPrefix, gitDirRunner;
|
|
26631
26712
|
var init_git_exclude = __esm({
|
|
26632
26713
|
"packages/agent-skill-config/src/git-exclude.ts"() {
|
|
26633
26714
|
"use strict";
|
|
26634
|
-
|
|
26715
|
+
defaultMarkerPrefix = "poe-code-spawn-skills";
|
|
26635
26716
|
gitDirRunner = defaultGitDirRunner;
|
|
26636
26717
|
}
|
|
26637
26718
|
});
|
|
@@ -26859,29 +26940,748 @@ var init_src15 = __esm({
|
|
|
26859
26940
|
}
|
|
26860
26941
|
});
|
|
26861
26942
|
|
|
26943
|
+
// packages/agent-hook-config/src/configs.ts
|
|
26944
|
+
import os7 from "node:os";
|
|
26945
|
+
import path36 from "node:path";
|
|
26946
|
+
function resolveAgentSupport2(input, registry = agentHookConfigs) {
|
|
26947
|
+
const resolvedId = resolveAgentId(input);
|
|
26948
|
+
if (!resolvedId) {
|
|
26949
|
+
return { status: "unknown", input };
|
|
26950
|
+
}
|
|
26951
|
+
const config = registry[resolvedId];
|
|
26952
|
+
if (!config) {
|
|
26953
|
+
return { status: "unsupported", input, id: resolvedId };
|
|
26954
|
+
}
|
|
26955
|
+
return { status: "supported", input, id: resolvedId, config };
|
|
26956
|
+
}
|
|
26957
|
+
function getAgentConfig2(agentId) {
|
|
26958
|
+
const support = resolveAgentSupport2(agentId);
|
|
26959
|
+
return support.status === "supported" ? support.config : void 0;
|
|
26960
|
+
}
|
|
26961
|
+
function expandHome3(targetPath, homeDir = os7.homedir()) {
|
|
26962
|
+
if (!targetPath?.startsWith("~")) {
|
|
26963
|
+
return targetPath;
|
|
26964
|
+
}
|
|
26965
|
+
if (targetPath === "~") {
|
|
26966
|
+
return homeDir;
|
|
26967
|
+
}
|
|
26968
|
+
if (targetPath.startsWith("~./")) {
|
|
26969
|
+
targetPath = `~/.${targetPath.slice(3)}`;
|
|
26970
|
+
}
|
|
26971
|
+
let remainder = targetPath.slice(1);
|
|
26972
|
+
if (remainder.startsWith("/") || remainder.startsWith("\\")) {
|
|
26973
|
+
remainder = remainder.slice(1);
|
|
26974
|
+
} else if (remainder.startsWith(".")) {
|
|
26975
|
+
remainder = remainder.slice(1);
|
|
26976
|
+
if (remainder.startsWith("/") || remainder.startsWith("\\")) {
|
|
26977
|
+
remainder = remainder.slice(1);
|
|
26978
|
+
}
|
|
26979
|
+
}
|
|
26980
|
+
return remainder.length === 0 ? homeDir : path36.join(homeDir, remainder);
|
|
26981
|
+
}
|
|
26982
|
+
function resolveHookPath(config, scope, cwd, homeDir) {
|
|
26983
|
+
if (scope === "global") {
|
|
26984
|
+
return path36.resolve(expandHome3(config.globalHookPath, homeDir));
|
|
26985
|
+
}
|
|
26986
|
+
return config.localHookPath ? path36.resolve(cwd, config.localHookPath) : void 0;
|
|
26987
|
+
}
|
|
26988
|
+
var agentHookConfigs, supportedHookAgents;
|
|
26989
|
+
var init_configs3 = __esm({
|
|
26990
|
+
"packages/agent-hook-config/src/configs.ts"() {
|
|
26991
|
+
"use strict";
|
|
26992
|
+
init_src5();
|
|
26993
|
+
agentHookConfigs = {
|
|
26994
|
+
"claude-code": {
|
|
26995
|
+
globalHookPath: "~/.claude/settings.json",
|
|
26996
|
+
localHookPath: ".claude/settings.json",
|
|
26997
|
+
format: "claude-settings-json",
|
|
26998
|
+
supportedEvents: [
|
|
26999
|
+
"SessionStart",
|
|
27000
|
+
"SessionEnd",
|
|
27001
|
+
"UserPromptSubmit",
|
|
27002
|
+
"PreToolUse",
|
|
27003
|
+
"PostToolUse",
|
|
27004
|
+
"PermissionRequest",
|
|
27005
|
+
"Stop",
|
|
27006
|
+
"StopFailure",
|
|
27007
|
+
"Notification",
|
|
27008
|
+
"PreCompact",
|
|
27009
|
+
"PostCompact",
|
|
27010
|
+
"SubagentStart",
|
|
27011
|
+
"SubagentStop"
|
|
27012
|
+
],
|
|
27013
|
+
supportedHandlerTypes: ["command", "http", "mcp_tool", "prompt", "agent"],
|
|
27014
|
+
placeholders: {
|
|
27015
|
+
projectDir: "${CLAUDE_PROJECT_DIR}",
|
|
27016
|
+
pluginRoot: "${CLAUDE_PLUGIN_ROOT}",
|
|
27017
|
+
pluginData: "${CLAUDE_PLUGIN_DATA}"
|
|
27018
|
+
}
|
|
27019
|
+
},
|
|
27020
|
+
codex: {
|
|
27021
|
+
globalHookPath: "~/.codex/hooks.json",
|
|
27022
|
+
localHookPath: ".codex/hooks.json",
|
|
27023
|
+
format: "codex-hooks-json",
|
|
27024
|
+
supportedEvents: [
|
|
27025
|
+
"SessionStart",
|
|
27026
|
+
"UserPromptSubmit",
|
|
27027
|
+
"PreToolUse",
|
|
27028
|
+
"PostToolUse",
|
|
27029
|
+
"PermissionRequest",
|
|
27030
|
+
"Stop"
|
|
27031
|
+
],
|
|
27032
|
+
supportedHandlerTypes: ["command"],
|
|
27033
|
+
placeholders: {
|
|
27034
|
+
projectDir: "$(git rev-parse --show-toplevel)",
|
|
27035
|
+
pluginRoot: "$PLUGIN_ROOT",
|
|
27036
|
+
pluginData: "$PLUGIN_DATA"
|
|
27037
|
+
}
|
|
27038
|
+
}
|
|
27039
|
+
};
|
|
27040
|
+
supportedHookAgents = Object.keys(agentHookConfigs);
|
|
27041
|
+
}
|
|
27042
|
+
});
|
|
27043
|
+
|
|
27044
|
+
// packages/agent-hook-config/src/read-hooks.ts
|
|
27045
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
27046
|
+
import path37 from "node:path";
|
|
27047
|
+
function readSettingsFile(filePath) {
|
|
27048
|
+
let content;
|
|
27049
|
+
try {
|
|
27050
|
+
content = readFileSync4(filePath, "utf8");
|
|
27051
|
+
} catch (error2) {
|
|
27052
|
+
if (error2.code === "ENOENT") {
|
|
27053
|
+
return void 0;
|
|
27054
|
+
}
|
|
27055
|
+
throw error2;
|
|
27056
|
+
}
|
|
27057
|
+
try {
|
|
27058
|
+
return JSON.parse(content);
|
|
27059
|
+
} catch (error2) {
|
|
27060
|
+
throw new Error(`Malformed JSON in ${filePath}`, { cause: error2 });
|
|
27061
|
+
}
|
|
27062
|
+
}
|
|
27063
|
+
function readClaudeHooks(cwd, homeDir, opts) {
|
|
27064
|
+
const projectPath = path37.resolve(cwd, ".claude/settings.json");
|
|
27065
|
+
const userPath = path37.resolve(homeDir, ".claude/settings.json");
|
|
27066
|
+
const scope = opts?.scope ?? "merged";
|
|
27067
|
+
const sourcePaths = scope === "project" ? [projectPath] : scope === "user" ? [userPath] : [userPath, projectPath];
|
|
27068
|
+
const result = { entries: [], readPaths: [] };
|
|
27069
|
+
for (const sourcePath of sourcePaths) {
|
|
27070
|
+
const settings = readSettingsFile(sourcePath);
|
|
27071
|
+
if (settings === void 0) {
|
|
27072
|
+
continue;
|
|
27073
|
+
}
|
|
27074
|
+
result.readPaths.push(sourcePath);
|
|
27075
|
+
for (const [event, groups] of Object.entries(settings.hooks ?? {})) {
|
|
27076
|
+
for (const group of groups) {
|
|
27077
|
+
for (const handler of group.hooks) {
|
|
27078
|
+
result.entries.push({ event, matcher: group.matcher, handler });
|
|
27079
|
+
}
|
|
27080
|
+
}
|
|
27081
|
+
}
|
|
27082
|
+
}
|
|
27083
|
+
return result;
|
|
27084
|
+
}
|
|
27085
|
+
var init_read_hooks = __esm({
|
|
27086
|
+
"packages/agent-hook-config/src/read-hooks.ts"() {
|
|
27087
|
+
"use strict";
|
|
27088
|
+
}
|
|
27089
|
+
});
|
|
27090
|
+
|
|
27091
|
+
// packages/agent-hook-config/src/event-mapping.ts
|
|
27092
|
+
function requireAgentConfig(agentId) {
|
|
27093
|
+
const config = getAgentConfig2(agentId);
|
|
27094
|
+
if (!config) {
|
|
27095
|
+
throw new Error(`Unknown hook agent "${agentId}"`);
|
|
27096
|
+
}
|
|
27097
|
+
return config;
|
|
27098
|
+
}
|
|
27099
|
+
function getEventMappings(sourceAgentId, targetAgentId) {
|
|
27100
|
+
const source = requireAgentConfig(sourceAgentId);
|
|
27101
|
+
const target = requireAgentConfig(targetAgentId);
|
|
27102
|
+
return source.supportedEvents.map((sourceEvent) => {
|
|
27103
|
+
if (target.supportedEvents.includes(sourceEvent)) {
|
|
27104
|
+
return { sourceEvent, targetEvent: sourceEvent };
|
|
27105
|
+
}
|
|
27106
|
+
return {
|
|
27107
|
+
sourceEvent,
|
|
27108
|
+
targetEvent: null,
|
|
27109
|
+
dropReason: `${targetAgentId} has no ${sourceEvent} hook`
|
|
27110
|
+
};
|
|
27111
|
+
});
|
|
27112
|
+
}
|
|
27113
|
+
function getHandlerTypeRules(targetAgentId) {
|
|
27114
|
+
const target = requireAgentConfig(targetAgentId);
|
|
27115
|
+
const registeredTypes = supportedHookAgents.flatMap(
|
|
27116
|
+
(agentId) => requireAgentConfig(agentId).supportedHandlerTypes
|
|
27117
|
+
);
|
|
27118
|
+
const sourceTypes = [...new Set(registeredTypes)];
|
|
27119
|
+
const supportedTypes = target.supportedHandlerTypes.map((handlerType) => `"${handlerType}"`).join(", ");
|
|
27120
|
+
return sourceTypes.map((sourceType) => {
|
|
27121
|
+
if (target.supportedHandlerTypes.includes(sourceType)) {
|
|
27122
|
+
return { sourceType, allowed: true };
|
|
27123
|
+
}
|
|
27124
|
+
return {
|
|
27125
|
+
sourceType,
|
|
27126
|
+
allowed: false,
|
|
27127
|
+
dropReason: `${targetAgentId} only honors handlers of type ${supportedTypes}`
|
|
27128
|
+
};
|
|
27129
|
+
});
|
|
27130
|
+
}
|
|
27131
|
+
function getPlaceholderRewrites(sourceAgentId, targetAgentId) {
|
|
27132
|
+
const source = requireAgentConfig(sourceAgentId);
|
|
27133
|
+
const target = requireAgentConfig(targetAgentId);
|
|
27134
|
+
return Object.keys(source.placeholders).flatMap((key2) => {
|
|
27135
|
+
const from = source.placeholders[key2];
|
|
27136
|
+
const to = target.placeholders[key2];
|
|
27137
|
+
if (!from || !to || from === to) {
|
|
27138
|
+
return [];
|
|
27139
|
+
}
|
|
27140
|
+
return [{ from, to }];
|
|
27141
|
+
});
|
|
27142
|
+
}
|
|
27143
|
+
var init_event_mapping = __esm({
|
|
27144
|
+
"packages/agent-hook-config/src/event-mapping.ts"() {
|
|
27145
|
+
"use strict";
|
|
27146
|
+
init_configs3();
|
|
27147
|
+
}
|
|
27148
|
+
});
|
|
27149
|
+
|
|
27150
|
+
// packages/agent-hook-config/src/transform-hooks.ts
|
|
27151
|
+
function applyPlaceholderRewrites(value, rewrites) {
|
|
27152
|
+
return rewrites.reduce((rewrittenValue, rewrite) => {
|
|
27153
|
+
return rewrittenValue.replaceAll(rewrite.from, rewrite.to);
|
|
27154
|
+
}, value);
|
|
27155
|
+
}
|
|
27156
|
+
function transformHooks(source, sourceAgentId, targetAgentId, opts) {
|
|
27157
|
+
const eventMappings = getEventMappings(sourceAgentId, targetAgentId);
|
|
27158
|
+
const handlerRules = getHandlerTypeRules(targetAgentId);
|
|
27159
|
+
const placeholderRewrites = getPlaceholderRewrites(sourceAgentId, targetAgentId);
|
|
27160
|
+
const result = { entries: [], drops: [] };
|
|
27161
|
+
for (const sourceEntry of source) {
|
|
27162
|
+
const eventMapping = eventMappings.find((mapping) => mapping.sourceEvent === sourceEntry.event);
|
|
27163
|
+
if (!eventMapping || eventMapping.targetEvent === null) {
|
|
27164
|
+
result.drops.push({
|
|
27165
|
+
reason: "unsupported-event",
|
|
27166
|
+
detail: eventMapping?.dropReason ?? `${targetAgentId} has no ${sourceEntry.event} hook`,
|
|
27167
|
+
source: sourceEntry
|
|
27168
|
+
});
|
|
27169
|
+
continue;
|
|
27170
|
+
}
|
|
27171
|
+
const handlerRule = handlerRules.find((rule) => rule.sourceType === sourceEntry.handler.type);
|
|
27172
|
+
if (!handlerRule?.allowed) {
|
|
27173
|
+
result.drops.push({
|
|
27174
|
+
reason: "unsupported-handler-type",
|
|
27175
|
+
detail: `Unsupported handler type "${sourceEntry.handler.type}": ${handlerRule?.dropReason ?? `${targetAgentId} does not honor it`}`,
|
|
27176
|
+
source: sourceEntry
|
|
27177
|
+
});
|
|
27178
|
+
continue;
|
|
27179
|
+
}
|
|
27180
|
+
const handler = {
|
|
27181
|
+
type: "command",
|
|
27182
|
+
command: applyPlaceholderRewrites(sourceEntry.handler.command ?? "", placeholderRewrites),
|
|
27183
|
+
statusMessage: `[generated:${opts.runId}] ${sourceEntry.handler.statusMessage ?? ""}`
|
|
27184
|
+
};
|
|
27185
|
+
if (sourceEntry.handler.args !== void 0) {
|
|
27186
|
+
handler.args = sourceEntry.handler.args.map(
|
|
27187
|
+
(arg) => applyPlaceholderRewrites(arg, placeholderRewrites)
|
|
27188
|
+
);
|
|
27189
|
+
}
|
|
27190
|
+
if (sourceEntry.handler.timeout !== void 0) {
|
|
27191
|
+
handler.timeout = sourceEntry.handler.timeout;
|
|
27192
|
+
}
|
|
27193
|
+
result.entries.push({
|
|
27194
|
+
event: eventMapping.targetEvent,
|
|
27195
|
+
matcher: sourceEntry.matcher,
|
|
27196
|
+
handler,
|
|
27197
|
+
generatedId: `generated-${opts.runId}-${result.entries.length}`
|
|
27198
|
+
});
|
|
27199
|
+
}
|
|
27200
|
+
return result;
|
|
27201
|
+
}
|
|
27202
|
+
var init_transform_hooks = __esm({
|
|
27203
|
+
"packages/agent-hook-config/src/transform-hooks.ts"() {
|
|
27204
|
+
"use strict";
|
|
27205
|
+
init_event_mapping();
|
|
27206
|
+
}
|
|
27207
|
+
});
|
|
27208
|
+
|
|
27209
|
+
// packages/agent-hook-config/src/write-hooks.ts
|
|
27210
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync5, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
27211
|
+
import path38 from "node:path";
|
|
27212
|
+
function isGeneratedHandler(handler) {
|
|
27213
|
+
return handler.statusMessage?.startsWith("[generated:") ?? false;
|
|
27214
|
+
}
|
|
27215
|
+
function parseHooksFile(targetPath) {
|
|
27216
|
+
let content;
|
|
27217
|
+
try {
|
|
27218
|
+
content = readFileSync5(targetPath, "utf8");
|
|
27219
|
+
} catch (error2) {
|
|
27220
|
+
if (error2.code === "ENOENT") {
|
|
27221
|
+
return { file: { hooks: {} }, fileCreated: true };
|
|
27222
|
+
}
|
|
27223
|
+
throw error2;
|
|
27224
|
+
}
|
|
27225
|
+
try {
|
|
27226
|
+
return { file: JSON.parse(content), fileCreated: false };
|
|
27227
|
+
} catch (error2) {
|
|
27228
|
+
throw new Error(`Malformed JSON in ${targetPath}`, { cause: error2 });
|
|
27229
|
+
}
|
|
27230
|
+
}
|
|
27231
|
+
function validateEntries(entries) {
|
|
27232
|
+
for (const entry of entries) {
|
|
27233
|
+
if (!isGeneratedHandler(entry.handler)) {
|
|
27234
|
+
throw new Error(
|
|
27235
|
+
`Generated hook entry "${entry.generatedId}" has statusMessage that must start with "[generated:"`
|
|
27236
|
+
);
|
|
27237
|
+
}
|
|
27238
|
+
}
|
|
27239
|
+
}
|
|
27240
|
+
function removeGeneratedHandlers(file) {
|
|
27241
|
+
let removed = 0;
|
|
27242
|
+
const hooks = file.hooks ?? (file.hooks = {});
|
|
27243
|
+
for (const [event, groups] of Object.entries(hooks)) {
|
|
27244
|
+
hooks[event] = groups.filter((group) => {
|
|
27245
|
+
const initialCount = group.hooks.length;
|
|
27246
|
+
const remainingHandlers = group.hooks.filter((handler) => {
|
|
27247
|
+
if (isGeneratedHandler(handler)) {
|
|
27248
|
+
removed += 1;
|
|
27249
|
+
return false;
|
|
27250
|
+
}
|
|
27251
|
+
return true;
|
|
27252
|
+
});
|
|
27253
|
+
group.hooks = remainingHandlers;
|
|
27254
|
+
return group.hooks.length > 0 || group.hooks.length === initialCount;
|
|
27255
|
+
});
|
|
27256
|
+
}
|
|
27257
|
+
return removed;
|
|
27258
|
+
}
|
|
27259
|
+
function appendEntries(file, entries) {
|
|
27260
|
+
const hooks = file.hooks ?? (file.hooks = {});
|
|
27261
|
+
for (const entry of entries) {
|
|
27262
|
+
const groups = hooks[entry.event] ?? (hooks[entry.event] = []);
|
|
27263
|
+
let group = groups.find((candidate) => candidate.matcher === entry.matcher);
|
|
27264
|
+
if (!group) {
|
|
27265
|
+
group = entry.matcher === void 0 ? { hooks: [] } : { matcher: entry.matcher, hooks: [] };
|
|
27266
|
+
groups.push(group);
|
|
27267
|
+
}
|
|
27268
|
+
group.hooks.push(entry.handler);
|
|
27269
|
+
}
|
|
27270
|
+
}
|
|
27271
|
+
function writeCodexHooks(targetPath, entries, _runId) {
|
|
27272
|
+
const { file, fileCreated } = parseHooksFile(targetPath);
|
|
27273
|
+
validateEntries(entries);
|
|
27274
|
+
const previousGeneratedRemoved = removeGeneratedHandlers(file);
|
|
27275
|
+
appendEntries(file, entries);
|
|
27276
|
+
mkdirSync3(path38.dirname(targetPath), { recursive: true });
|
|
27277
|
+
const temporaryPath = `${targetPath}.tmp`;
|
|
27278
|
+
writeFileSync2(temporaryPath, `${JSON.stringify(file, null, 2)}
|
|
27279
|
+
`);
|
|
27280
|
+
renameSync(temporaryPath, targetPath);
|
|
27281
|
+
return {
|
|
27282
|
+
path: targetPath,
|
|
27283
|
+
fileCreated,
|
|
27284
|
+
previousGeneratedRemoved,
|
|
27285
|
+
generatedWritten: entries.length
|
|
27286
|
+
};
|
|
27287
|
+
}
|
|
27288
|
+
var init_write_hooks = __esm({
|
|
27289
|
+
"packages/agent-hook-config/src/write-hooks.ts"() {
|
|
27290
|
+
"use strict";
|
|
27291
|
+
}
|
|
27292
|
+
});
|
|
27293
|
+
|
|
27294
|
+
// packages/agent-hook-config/src/symlink-hooks.ts
|
|
27295
|
+
import {
|
|
27296
|
+
closeSync,
|
|
27297
|
+
lstatSync,
|
|
27298
|
+
mkdirSync as mkdirSync4,
|
|
27299
|
+
openSync,
|
|
27300
|
+
readlinkSync,
|
|
27301
|
+
readSync,
|
|
27302
|
+
symlinkSync,
|
|
27303
|
+
unlinkSync
|
|
27304
|
+
} from "node:fs";
|
|
27305
|
+
import path39 from "node:path";
|
|
27306
|
+
function requireAgentConfig2(agentId) {
|
|
27307
|
+
const config = getAgentConfig2(agentId);
|
|
27308
|
+
if (!config) {
|
|
27309
|
+
throw new Error(`No hook configuration found for agent "${agentId}"`);
|
|
27310
|
+
}
|
|
27311
|
+
return config;
|
|
27312
|
+
}
|
|
27313
|
+
function resolveScopedPath(config, agentId, cwd, homeDir, scope) {
|
|
27314
|
+
const targetPath = resolveHookPath(
|
|
27315
|
+
config,
|
|
27316
|
+
scope === "project" ? "local" : "global",
|
|
27317
|
+
cwd,
|
|
27318
|
+
homeDir
|
|
27319
|
+
);
|
|
27320
|
+
if (!targetPath) {
|
|
27321
|
+
throw new Error(`Agent "${agentId}" has no ${scope} hook path`);
|
|
27322
|
+
}
|
|
27323
|
+
return targetPath;
|
|
27324
|
+
}
|
|
27325
|
+
function readFirstKilobyte(filePath) {
|
|
27326
|
+
const descriptor = openSync(filePath, "r");
|
|
27327
|
+
const buffer = Buffer.alloc(1024);
|
|
27328
|
+
try {
|
|
27329
|
+
const length = readSync(descriptor, buffer, 0, buffer.length, 0);
|
|
27330
|
+
return buffer.toString("utf8", 0, length);
|
|
27331
|
+
} finally {
|
|
27332
|
+
closeSync(descriptor);
|
|
27333
|
+
}
|
|
27334
|
+
}
|
|
27335
|
+
function isRecord10(value) {
|
|
27336
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27337
|
+
}
|
|
27338
|
+
function isFullyGeneratedFile(filePath) {
|
|
27339
|
+
let parsed;
|
|
27340
|
+
try {
|
|
27341
|
+
parsed = JSON.parse(readFirstKilobyte(filePath));
|
|
27342
|
+
} catch {
|
|
27343
|
+
return false;
|
|
27344
|
+
}
|
|
27345
|
+
if (!isRecord10(parsed)) {
|
|
27346
|
+
return false;
|
|
27347
|
+
}
|
|
27348
|
+
if (Object.keys(parsed).some((key2) => key2 !== "hooks")) {
|
|
27349
|
+
return false;
|
|
27350
|
+
}
|
|
27351
|
+
const hooks = parsed.hooks;
|
|
27352
|
+
if (!isRecord10(hooks)) {
|
|
27353
|
+
return false;
|
|
27354
|
+
}
|
|
27355
|
+
let handlerFound = false;
|
|
27356
|
+
for (const groups of Object.values(hooks)) {
|
|
27357
|
+
if (!Array.isArray(groups)) {
|
|
27358
|
+
return false;
|
|
27359
|
+
}
|
|
27360
|
+
for (const group of groups) {
|
|
27361
|
+
if (!isRecord10(group) || !Array.isArray(group.hooks)) {
|
|
27362
|
+
return false;
|
|
27363
|
+
}
|
|
27364
|
+
for (const handler of group.hooks) {
|
|
27365
|
+
if (!isRecord10(handler)) {
|
|
27366
|
+
return false;
|
|
27367
|
+
}
|
|
27368
|
+
handlerFound = true;
|
|
27369
|
+
const statusMessage = handler.statusMessage;
|
|
27370
|
+
if (typeof statusMessage !== "string" || !statusMessage.startsWith("[generated:")) {
|
|
27371
|
+
return false;
|
|
27372
|
+
}
|
|
27373
|
+
}
|
|
27374
|
+
}
|
|
27375
|
+
}
|
|
27376
|
+
return handlerFound;
|
|
27377
|
+
}
|
|
27378
|
+
function symlinkHooks(sourceAgentId, targetAgentId, cwd, homeDir, scope) {
|
|
27379
|
+
const source = requireAgentConfig2(sourceAgentId);
|
|
27380
|
+
const target = requireAgentConfig2(targetAgentId);
|
|
27381
|
+
if (source.format !== target.format) {
|
|
27382
|
+
throw new Error(
|
|
27383
|
+
`Cannot symlink hook formats "${source.format}" and "${target.format}"; use transformation instead`
|
|
27384
|
+
);
|
|
27385
|
+
}
|
|
27386
|
+
const targetPath = resolveScopedPath(source, sourceAgentId, cwd, homeDir, scope);
|
|
27387
|
+
const symlinkPath = resolveScopedPath(target, targetAgentId, cwd, homeDir, scope);
|
|
27388
|
+
let replaced = "none";
|
|
27389
|
+
try {
|
|
27390
|
+
const existing = lstatSync(symlinkPath);
|
|
27391
|
+
if (existing.isSymbolicLink()) {
|
|
27392
|
+
if (readlinkSync(symlinkPath) === targetPath) {
|
|
27393
|
+
return { symlinkPath, targetPath, replaced };
|
|
27394
|
+
}
|
|
27395
|
+
unlinkSync(symlinkPath);
|
|
27396
|
+
replaced = "stale-symlink";
|
|
27397
|
+
} else if (existing.isFile() && isFullyGeneratedFile(symlinkPath)) {
|
|
27398
|
+
unlinkSync(symlinkPath);
|
|
27399
|
+
replaced = "generated-file";
|
|
27400
|
+
} else {
|
|
27401
|
+
throw new Error(`Refuse to replace user-authored hook file at ${symlinkPath}`);
|
|
27402
|
+
}
|
|
27403
|
+
} catch (error2) {
|
|
27404
|
+
if (error2.code !== "ENOENT") {
|
|
27405
|
+
throw error2;
|
|
27406
|
+
}
|
|
27407
|
+
}
|
|
27408
|
+
mkdirSync4(path39.dirname(symlinkPath), { recursive: true });
|
|
27409
|
+
symlinkSync(targetPath, symlinkPath);
|
|
27410
|
+
return { symlinkPath, targetPath, replaced };
|
|
27411
|
+
}
|
|
27412
|
+
var init_symlink_hooks = __esm({
|
|
27413
|
+
"packages/agent-hook-config/src/symlink-hooks.ts"() {
|
|
27414
|
+
"use strict";
|
|
27415
|
+
init_configs3();
|
|
27416
|
+
}
|
|
27417
|
+
});
|
|
27418
|
+
|
|
27419
|
+
// packages/agent-hook-config/src/bridge-hooks.ts
|
|
27420
|
+
import * as fs4 from "node:fs";
|
|
27421
|
+
import path40 from "node:path";
|
|
27422
|
+
function isNodeError4(error2) {
|
|
27423
|
+
return error2 instanceof Error && "code" in error2;
|
|
27424
|
+
}
|
|
27425
|
+
function pathExists3(targetPath) {
|
|
27426
|
+
try {
|
|
27427
|
+
fs4.lstatSync(targetPath);
|
|
27428
|
+
return true;
|
|
27429
|
+
} catch (error2) {
|
|
27430
|
+
if (isNodeError4(error2) && error2.code === "ENOENT") {
|
|
27431
|
+
return false;
|
|
27432
|
+
}
|
|
27433
|
+
throw error2;
|
|
27434
|
+
}
|
|
27435
|
+
}
|
|
27436
|
+
function collectMissingParents2(targetPath) {
|
|
27437
|
+
const parents = [];
|
|
27438
|
+
let current = path40.dirname(targetPath);
|
|
27439
|
+
while (!pathExists3(current)) {
|
|
27440
|
+
parents.push(current);
|
|
27441
|
+
const parent = path40.dirname(current);
|
|
27442
|
+
if (parent === current) {
|
|
27443
|
+
break;
|
|
27444
|
+
}
|
|
27445
|
+
current = parent;
|
|
27446
|
+
}
|
|
27447
|
+
return parents.reverse();
|
|
27448
|
+
}
|
|
27449
|
+
function removeDirectoryIfEmpty2(targetPath) {
|
|
27450
|
+
try {
|
|
27451
|
+
fs4.rmdirSync(targetPath);
|
|
27452
|
+
} catch (error2) {
|
|
27453
|
+
if (isNodeError4(error2) && (error2.code === "ENOENT" || error2.code === "ENOTEMPTY" || error2.code === "EEXIST")) {
|
|
27454
|
+
return;
|
|
27455
|
+
}
|
|
27456
|
+
throw error2;
|
|
27457
|
+
}
|
|
27458
|
+
}
|
|
27459
|
+
function requireSupport(input, role) {
|
|
27460
|
+
const support = resolveAgentSupport2(input);
|
|
27461
|
+
if (support.status !== "supported" || !support.id || !support.config) {
|
|
27462
|
+
throw new Error(
|
|
27463
|
+
`Unsupported ${role} hook agent "${input}". Supported hook agents: ${supportedHookAgents.join(", ")}.`
|
|
27464
|
+
);
|
|
27465
|
+
}
|
|
27466
|
+
return { id: support.id, config: support.config };
|
|
27467
|
+
}
|
|
27468
|
+
function requireTargetPath(targetId, config, cwd, homeDir) {
|
|
27469
|
+
const targetPath = resolveHookPath(config, "local", cwd, homeDir);
|
|
27470
|
+
if (!targetPath) {
|
|
27471
|
+
throw new Error(`Agent "${targetId}" has no project hook path`);
|
|
27472
|
+
}
|
|
27473
|
+
return targetPath;
|
|
27474
|
+
}
|
|
27475
|
+
function readCodexFile(targetPath) {
|
|
27476
|
+
let content;
|
|
27477
|
+
try {
|
|
27478
|
+
content = fs4.readFileSync(targetPath, "utf8");
|
|
27479
|
+
} catch (error2) {
|
|
27480
|
+
if (isNodeError4(error2) && error2.code === "ENOENT") {
|
|
27481
|
+
return void 0;
|
|
27482
|
+
}
|
|
27483
|
+
throw error2;
|
|
27484
|
+
}
|
|
27485
|
+
try {
|
|
27486
|
+
return JSON.parse(content);
|
|
27487
|
+
} catch (error2) {
|
|
27488
|
+
throw new Error(`Malformed JSON in ${targetPath}`, { cause: error2 });
|
|
27489
|
+
}
|
|
27490
|
+
}
|
|
27491
|
+
function writeCodexFile(targetPath, file) {
|
|
27492
|
+
fs4.writeFileSync(targetPath, `${JSON.stringify(file, null, 2)}
|
|
27493
|
+
`, "utf8");
|
|
27494
|
+
}
|
|
27495
|
+
function hasOnlyEmptyHooks(file) {
|
|
27496
|
+
return Object.keys(file).every((key2) => key2 === "hooks") && Object.values(file.hooks ?? {}).every((groups) => groups.length === 0);
|
|
27497
|
+
}
|
|
27498
|
+
function relativeToCwd(cwd, targetPath) {
|
|
27499
|
+
return path40.relative(cwd, targetPath);
|
|
27500
|
+
}
|
|
27501
|
+
function matcherKey(event, matcher) {
|
|
27502
|
+
return `${event}\0${matcher === void 0 ? "<undefined>" : matcher}`;
|
|
27503
|
+
}
|
|
27504
|
+
function bridgeHooks(sourceAgentId, targetAgentId, cwd, homeDir, runId, opts) {
|
|
27505
|
+
const source = requireSupport(sourceAgentId, "source");
|
|
27506
|
+
const target = requireSupport(targetAgentId, "target");
|
|
27507
|
+
const strategy = opts?.strategy ?? (source.config.format === target.config.format ? "symlink" : "transform");
|
|
27508
|
+
const manifest = {
|
|
27509
|
+
sourceAgentId,
|
|
27510
|
+
targetAgentId,
|
|
27511
|
+
cwd,
|
|
27512
|
+
runId,
|
|
27513
|
+
strategy,
|
|
27514
|
+
drops: []
|
|
27515
|
+
};
|
|
27516
|
+
if (strategy === "symlink") {
|
|
27517
|
+
const symlinkPath = requireTargetPath(target.id, target.config, cwd, homeDir);
|
|
27518
|
+
manifest.createdParents = collectMissingParents2(symlinkPath);
|
|
27519
|
+
const result = symlinkHooks(source.id, target.id, cwd, homeDir, "project");
|
|
27520
|
+
manifest.symlinkPath = result.symlinkPath;
|
|
27521
|
+
manifest.symlinkTarget = result.targetPath;
|
|
27522
|
+
manifest.symlinkReplaced = result.replaced;
|
|
27523
|
+
appendExcludeBlock(cwd, runId, [relativeToCwd(cwd, result.symlinkPath)], {
|
|
27524
|
+
markerPrefix: hookExcludeMarkerPrefix
|
|
27525
|
+
});
|
|
27526
|
+
return manifest;
|
|
27527
|
+
}
|
|
27528
|
+
if (source.id !== "claude-code") {
|
|
27529
|
+
throw new Error(`Transforming hooks from "${source.id}" is not supported yet`);
|
|
27530
|
+
}
|
|
27531
|
+
if (target.config.format !== "codex-hooks-json") {
|
|
27532
|
+
throw new Error(
|
|
27533
|
+
`Transforming hooks to "${target.id}" is not supported yet; only codex-hook targets can be written`
|
|
27534
|
+
);
|
|
27535
|
+
}
|
|
27536
|
+
const targetPath = requireTargetPath(target.id, target.config, cwd, homeDir);
|
|
27537
|
+
const priorFile = readCodexFile(targetPath);
|
|
27538
|
+
const sourceHooks = readClaudeHooks(cwd, homeDir, { scope: opts?.scope ?? "merged" });
|
|
27539
|
+
const transformed = transformHooks(sourceHooks.entries, source.id, target.id, { runId });
|
|
27540
|
+
const createdParents = collectMissingParents2(targetPath);
|
|
27541
|
+
const writeResult = writeCodexHooks(targetPath, transformed.entries, runId);
|
|
27542
|
+
manifest.writtenPath = targetPath;
|
|
27543
|
+
manifest.generatedEntryIds = transformed.entries.map((entry) => entry.generatedId);
|
|
27544
|
+
manifest.drops = transformed.drops;
|
|
27545
|
+
manifest.createdParents = createdParents;
|
|
27546
|
+
manifest.fileCreated = writeResult.fileCreated;
|
|
27547
|
+
manifest.preExistingEvents = Object.keys(priorFile?.hooks ?? {});
|
|
27548
|
+
manifest.preExistingMatchers = Object.entries(priorFile?.hooks ?? {}).flatMap(
|
|
27549
|
+
([event, groups]) => groups.map((group) => ({
|
|
27550
|
+
event,
|
|
27551
|
+
...group.matcher === void 0 ? {} : { matcher: group.matcher }
|
|
27552
|
+
}))
|
|
27553
|
+
);
|
|
27554
|
+
appendExcludeBlock(cwd, runId, [relativeToCwd(cwd, targetPath)], {
|
|
27555
|
+
markerPrefix: hookExcludeMarkerPrefix
|
|
27556
|
+
});
|
|
27557
|
+
return manifest;
|
|
27558
|
+
}
|
|
27559
|
+
function cleanupBridgedHooks(manifest) {
|
|
27560
|
+
if (manifest.strategy === "symlink" && manifest.symlinkPath && manifest.symlinkTarget) {
|
|
27561
|
+
try {
|
|
27562
|
+
if (fs4.lstatSync(manifest.symlinkPath).isSymbolicLink() && fs4.readlinkSync(manifest.symlinkPath) === manifest.symlinkTarget) {
|
|
27563
|
+
fs4.unlinkSync(manifest.symlinkPath);
|
|
27564
|
+
}
|
|
27565
|
+
} catch (error2) {
|
|
27566
|
+
if (!isNodeError4(error2) || error2.code !== "ENOENT") {
|
|
27567
|
+
throw error2;
|
|
27568
|
+
}
|
|
27569
|
+
}
|
|
27570
|
+
for (const parent of [...manifest.createdParents ?? []].reverse()) {
|
|
27571
|
+
removeDirectoryIfEmpty2(parent);
|
|
27572
|
+
}
|
|
27573
|
+
}
|
|
27574
|
+
if (manifest.strategy === "transform" && manifest.writtenPath) {
|
|
27575
|
+
const file = readCodexFile(manifest.writtenPath);
|
|
27576
|
+
if (file) {
|
|
27577
|
+
const generatedPrefix = `[generated:${manifest.runId}]`;
|
|
27578
|
+
const preExistingEvents = new Set(manifest.preExistingEvents ?? []);
|
|
27579
|
+
const preExistingMatchers = new Set(
|
|
27580
|
+
(manifest.preExistingMatchers ?? []).map((group) => matcherKey(group.event, group.matcher))
|
|
27581
|
+
);
|
|
27582
|
+
const hooks = file.hooks ?? {};
|
|
27583
|
+
for (const [event, groups] of Object.entries(hooks)) {
|
|
27584
|
+
hooks[event] = groups.filter((group) => {
|
|
27585
|
+
const priorLength = group.hooks.length;
|
|
27586
|
+
group.hooks = group.hooks.filter(
|
|
27587
|
+
(handler) => !handler.statusMessage?.startsWith(generatedPrefix)
|
|
27588
|
+
);
|
|
27589
|
+
return group.hooks.length > 0 || group.hooks.length === priorLength || preExistingMatchers.has(matcherKey(event, group.matcher));
|
|
27590
|
+
});
|
|
27591
|
+
if (hooks[event].length === 0 && !preExistingEvents.has(event)) {
|
|
27592
|
+
delete hooks[event];
|
|
27593
|
+
}
|
|
27594
|
+
}
|
|
27595
|
+
file.hooks = hooks;
|
|
27596
|
+
if (manifest.fileCreated && hasOnlyEmptyHooks(file)) {
|
|
27597
|
+
fs4.unlinkSync(manifest.writtenPath);
|
|
27598
|
+
} else {
|
|
27599
|
+
writeCodexFile(manifest.writtenPath, file);
|
|
27600
|
+
}
|
|
27601
|
+
}
|
|
27602
|
+
for (const parent of [...manifest.createdParents ?? []].reverse()) {
|
|
27603
|
+
removeDirectoryIfEmpty2(parent);
|
|
27604
|
+
}
|
|
27605
|
+
}
|
|
27606
|
+
removeExcludeBlock(manifest.cwd, manifest.runId, { markerPrefix: hookExcludeMarkerPrefix });
|
|
27607
|
+
}
|
|
27608
|
+
var hookExcludeMarkerPrefix;
|
|
27609
|
+
var init_bridge_hooks = __esm({
|
|
27610
|
+
"packages/agent-hook-config/src/bridge-hooks.ts"() {
|
|
27611
|
+
"use strict";
|
|
27612
|
+
init_src15();
|
|
27613
|
+
init_configs3();
|
|
27614
|
+
init_read_hooks();
|
|
27615
|
+
init_symlink_hooks();
|
|
27616
|
+
init_transform_hooks();
|
|
27617
|
+
init_write_hooks();
|
|
27618
|
+
hookExcludeMarkerPrefix = "poe-code-spawn-hooks";
|
|
27619
|
+
}
|
|
27620
|
+
});
|
|
27621
|
+
|
|
27622
|
+
// packages/agent-hook-config/src/index.ts
|
|
27623
|
+
var init_src16 = __esm({
|
|
27624
|
+
"packages/agent-hook-config/src/index.ts"() {
|
|
27625
|
+
"use strict";
|
|
27626
|
+
init_configs3();
|
|
27627
|
+
init_read_hooks();
|
|
27628
|
+
init_event_mapping();
|
|
27629
|
+
init_transform_hooks();
|
|
27630
|
+
init_write_hooks();
|
|
27631
|
+
init_symlink_hooks();
|
|
27632
|
+
init_bridge_hooks();
|
|
27633
|
+
}
|
|
27634
|
+
});
|
|
27635
|
+
|
|
26862
27636
|
// packages/agent-spawn/src/skill-bridge.ts
|
|
26863
27637
|
import crypto4 from "node:crypto";
|
|
26864
|
-
import
|
|
26865
|
-
function
|
|
26866
|
-
if (!skills2 || skills2.length === 0) {
|
|
27638
|
+
import os8 from "node:os";
|
|
27639
|
+
function bridgeResourcesForRun(agentId, cwd, skills2, hooks) {
|
|
27640
|
+
if ((!skills2 || skills2.length === 0) && !hooks) {
|
|
26867
27641
|
return void 0;
|
|
26868
27642
|
}
|
|
26869
|
-
const
|
|
26870
|
-
|
|
26871
|
-
|
|
27643
|
+
const runId = crypto4.randomUUID();
|
|
27644
|
+
const manifests = {};
|
|
27645
|
+
try {
|
|
27646
|
+
if (skills2 && skills2.length > 0) {
|
|
27647
|
+
manifests.skills = bridgeActiveSkills(agentId, cwd, skills2, os8.homedir(), runId);
|
|
27648
|
+
for (const warning2 of manifests.skills.warnings) {
|
|
27649
|
+
logger.warn(warning2.message);
|
|
27650
|
+
}
|
|
27651
|
+
}
|
|
27652
|
+
if (hooks) {
|
|
27653
|
+
manifests.hooks = bridgeHooks(hooks.from, agentId, cwd, os8.homedir(), runId, {
|
|
27654
|
+
strategy: hooks.strategy === "auto" ? void 0 : hooks.strategy,
|
|
27655
|
+
scope: hooks.scope
|
|
27656
|
+
});
|
|
27657
|
+
for (const drop of manifests.hooks.drops) {
|
|
27658
|
+
logger.warn(
|
|
27659
|
+
`Dropped bridged hook event "${drop.source.event}" with handler type "${drop.source.handler.type}": ${drop.detail}`
|
|
27660
|
+
);
|
|
27661
|
+
}
|
|
27662
|
+
}
|
|
27663
|
+
} catch (error2) {
|
|
27664
|
+
cleanupResourcesForRun(manifests);
|
|
27665
|
+
throw error2;
|
|
26872
27666
|
}
|
|
26873
|
-
return
|
|
27667
|
+
return manifests;
|
|
26874
27668
|
}
|
|
26875
|
-
function
|
|
27669
|
+
function cleanupResourcesForRun(manifest) {
|
|
26876
27670
|
if (!manifest) {
|
|
26877
27671
|
return;
|
|
26878
27672
|
}
|
|
26879
|
-
|
|
27673
|
+
if (manifest.hooks) {
|
|
27674
|
+
cleanupBridgedHooks(manifest.hooks);
|
|
27675
|
+
}
|
|
27676
|
+
if (manifest.skills) {
|
|
27677
|
+
cleanupBridgedSkills(manifest.skills);
|
|
27678
|
+
}
|
|
26880
27679
|
}
|
|
26881
27680
|
var init_skill_bridge = __esm({
|
|
26882
27681
|
"packages/agent-spawn/src/skill-bridge.ts"() {
|
|
26883
27682
|
"use strict";
|
|
26884
27683
|
init_src15();
|
|
27684
|
+
init_src16();
|
|
26885
27685
|
init_src2();
|
|
26886
27686
|
}
|
|
26887
27687
|
});
|
|
@@ -26994,21 +27794,21 @@ async function* adaptClaude(lines) {
|
|
|
26994
27794
|
if (blockType !== "tool_result") continue;
|
|
26995
27795
|
const kind = toolKindsById.get(item.tool_use_id);
|
|
26996
27796
|
toolKindsById.delete(item.tool_use_id);
|
|
26997
|
-
let
|
|
27797
|
+
let path54;
|
|
26998
27798
|
if (typeof item.content === "string") {
|
|
26999
|
-
|
|
27799
|
+
path54 = item.content;
|
|
27000
27800
|
} else {
|
|
27001
27801
|
try {
|
|
27002
|
-
|
|
27802
|
+
path54 = JSON.stringify(item.content);
|
|
27003
27803
|
} catch {
|
|
27004
|
-
|
|
27804
|
+
path54 = String(item.content);
|
|
27005
27805
|
}
|
|
27006
27806
|
}
|
|
27007
27807
|
yield {
|
|
27008
27808
|
event: "tool_complete",
|
|
27009
27809
|
id: item.tool_use_id,
|
|
27010
27810
|
kind,
|
|
27011
|
-
path:
|
|
27811
|
+
path: path54
|
|
27012
27812
|
};
|
|
27013
27813
|
}
|
|
27014
27814
|
}
|
|
@@ -27131,10 +27931,10 @@ async function* adaptCodex(lines) {
|
|
|
27131
27931
|
const kindFromStart = toolKindById.get(item.id);
|
|
27132
27932
|
const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
|
|
27133
27933
|
const titleFromEvent = isNonEmptyString(item.path) ? item.path : itemType === "mcp_tool_call" ? `${isNonEmptyString(item.server) ? item.server : "unknown"}.${isNonEmptyString(item.tool) ? item.tool : "unknown"}` : void 0;
|
|
27134
|
-
const
|
|
27934
|
+
const path54 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
|
|
27135
27935
|
toolTitleById.delete(item.id);
|
|
27136
27936
|
toolKindById.delete(item.id);
|
|
27137
|
-
yield { event: "tool_complete", id: item.id, kind, path:
|
|
27937
|
+
yield { event: "tool_complete", id: item.id, kind, path: path54 };
|
|
27138
27938
|
}
|
|
27139
27939
|
}
|
|
27140
27940
|
}
|
|
@@ -27712,7 +28512,7 @@ function spawnStreaming(options) {
|
|
|
27712
28512
|
};
|
|
27713
28513
|
}
|
|
27714
28514
|
};
|
|
27715
|
-
const manifest =
|
|
28515
|
+
const manifest = bridgeResourcesForRun(options.agentId, cwd, options.skills, options.hooks);
|
|
27716
28516
|
void (async () => {
|
|
27717
28517
|
try {
|
|
27718
28518
|
for await (const output of adapter(queue.lines())) {
|
|
@@ -27763,7 +28563,7 @@ function spawnStreaming(options) {
|
|
|
27763
28563
|
...ctx.logFile && !result.logFile ? { logFile: ctx.logFile } : {}
|
|
27764
28564
|
};
|
|
27765
28565
|
} finally {
|
|
27766
|
-
|
|
28566
|
+
cleanupResourcesForRun(manifest);
|
|
27767
28567
|
}
|
|
27768
28568
|
})();
|
|
27769
28569
|
return {
|
|
@@ -27800,8 +28600,8 @@ var init_spawn = __esm({
|
|
|
27800
28600
|
});
|
|
27801
28601
|
|
|
27802
28602
|
// packages/agent-spawn/src/spawn.ts
|
|
27803
|
-
import { mkdirSync as
|
|
27804
|
-
import
|
|
28603
|
+
import { mkdirSync as mkdirSync5, openSync as openSync2, writeSync, closeSync as closeSync2 } from "node:fs";
|
|
28604
|
+
import path41 from "node:path";
|
|
27805
28605
|
function createAbortError6() {
|
|
27806
28606
|
const error2 = new Error("Agent spawn aborted");
|
|
27807
28607
|
error2.name = "AbortError";
|
|
@@ -27925,7 +28725,7 @@ async function runSpawn(agentId, options, context) {
|
|
|
27925
28725
|
return { stdout: "", stderr: "", exitCode: 0 };
|
|
27926
28726
|
}
|
|
27927
28727
|
const cwd = options.cwd ?? process.cwd();
|
|
27928
|
-
const manifest =
|
|
28728
|
+
const manifest = bridgeResourcesForRun(agentId, cwd, options.skills, options.hooks);
|
|
27929
28729
|
let logFd;
|
|
27930
28730
|
try {
|
|
27931
28731
|
const logFilePath = resolveSpawnLogPath(options);
|
|
@@ -27993,7 +28793,7 @@ async function runSpawn(agentId, options, context) {
|
|
|
27993
28793
|
};
|
|
27994
28794
|
} finally {
|
|
27995
28795
|
closeSpawnLog(logFd);
|
|
27996
|
-
|
|
28796
|
+
cleanupResourcesForRun(manifest);
|
|
27997
28797
|
}
|
|
27998
28798
|
}
|
|
27999
28799
|
function resolveSpawnLogPath(options) {
|
|
@@ -28003,12 +28803,12 @@ function resolveSpawnLogPath(options) {
|
|
|
28003
28803
|
if (!options.logDir || !options.logFileName) {
|
|
28004
28804
|
return void 0;
|
|
28005
28805
|
}
|
|
28006
|
-
return
|
|
28806
|
+
return path41.join(options.logDir, options.logFileName);
|
|
28007
28807
|
}
|
|
28008
28808
|
function openSpawnLog(filePath) {
|
|
28009
28809
|
try {
|
|
28010
|
-
|
|
28011
|
-
return
|
|
28810
|
+
mkdirSync5(path41.dirname(filePath), { recursive: true });
|
|
28811
|
+
return openSync2(filePath, "a");
|
|
28012
28812
|
} catch {
|
|
28013
28813
|
return void 0;
|
|
28014
28814
|
}
|
|
@@ -28023,7 +28823,7 @@ function appendSpawnLog(fd, chunk) {
|
|
|
28023
28823
|
function closeSpawnLog(fd) {
|
|
28024
28824
|
if (fd === void 0) return;
|
|
28025
28825
|
try {
|
|
28026
|
-
|
|
28826
|
+
closeSync2(fd);
|
|
28027
28827
|
} catch {
|
|
28028
28828
|
}
|
|
28029
28829
|
}
|
|
@@ -28185,7 +28985,7 @@ var init_autonomous = __esm({
|
|
|
28185
28985
|
});
|
|
28186
28986
|
|
|
28187
28987
|
// packages/agent-spawn/src/acp/replay.ts
|
|
28188
|
-
import
|
|
28988
|
+
import path42 from "node:path";
|
|
28189
28989
|
import { homedir as homedir3 } from "node:os";
|
|
28190
28990
|
import { open as open2, readdir as readdir2 } from "node:fs/promises";
|
|
28191
28991
|
import { createInterface } from "node:readline";
|
|
@@ -28276,7 +29076,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
|
|
|
28276
29076
|
}
|
|
28277
29077
|
const id = readString(event.id);
|
|
28278
29078
|
const kind = readString(event.kind);
|
|
28279
|
-
const
|
|
29079
|
+
const path54 = readString(event.path);
|
|
28280
29080
|
let toolCall = id ? toolCallsById.get(id) : void 0;
|
|
28281
29081
|
if (!toolCall) {
|
|
28282
29082
|
toolCall = {};
|
|
@@ -28291,8 +29091,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
|
|
|
28291
29091
|
if (kind) {
|
|
28292
29092
|
toolCall.kind = kind;
|
|
28293
29093
|
}
|
|
28294
|
-
if (
|
|
28295
|
-
toolCall.path =
|
|
29094
|
+
if (path54) {
|
|
29095
|
+
toolCall.path = path54;
|
|
28296
29096
|
}
|
|
28297
29097
|
}
|
|
28298
29098
|
var sessionCapture;
|
|
@@ -28378,7 +29178,7 @@ var init_usage_capture = __esm({
|
|
|
28378
29178
|
});
|
|
28379
29179
|
|
|
28380
29180
|
// packages/agent-spawn/src/acp/middlewares/spawn-log.ts
|
|
28381
|
-
import
|
|
29181
|
+
import path43 from "node:path";
|
|
28382
29182
|
import { homedir as homedir4 } from "node:os";
|
|
28383
29183
|
import { mkdir as mkdir2, open as open3 } from "node:fs/promises";
|
|
28384
29184
|
function pad2(value, width) {
|
|
@@ -28415,14 +29215,14 @@ function resolveLogFilePath(ctx) {
|
|
|
28415
29215
|
if (ctx.logPath) {
|
|
28416
29216
|
return ctx.logPath;
|
|
28417
29217
|
}
|
|
28418
|
-
const baseDir = ctx.logDir ??
|
|
29218
|
+
const baseDir = ctx.logDir ?? path43.join(homedir4(), ".poe-code", "spawn-logs");
|
|
28419
29219
|
if (ctx.logFileName) {
|
|
28420
|
-
return
|
|
29220
|
+
return path43.join(baseDir, ctx.logFileName);
|
|
28421
29221
|
}
|
|
28422
29222
|
const startedAt = resolveStartedAt(ctx.startedAt);
|
|
28423
29223
|
const { day, time, milliseconds } = formatTimestamp(startedAt);
|
|
28424
29224
|
const fileName = `${day}-${time}-${milliseconds}-${normalizeAgent(ctx.agent)}.jsonl`;
|
|
28425
|
-
return
|
|
29225
|
+
return path43.join(baseDir, fileName);
|
|
28426
29226
|
}
|
|
28427
29227
|
async function writePreloadedEvents(writer, events) {
|
|
28428
29228
|
for (const event of events) {
|
|
@@ -28440,7 +29240,7 @@ var init_spawn_log = __esm({
|
|
|
28440
29240
|
logDirPath;
|
|
28441
29241
|
constructor(ctx) {
|
|
28442
29242
|
this.filePath = resolveLogFilePath(ctx);
|
|
28443
|
-
this.logDirPath =
|
|
29243
|
+
this.logDirPath = path43.dirname(this.filePath);
|
|
28444
29244
|
}
|
|
28445
29245
|
async writeEvent(event) {
|
|
28446
29246
|
if (this.isDisabled) {
|
|
@@ -28508,7 +29308,7 @@ var init_spawn_log = __esm({
|
|
|
28508
29308
|
});
|
|
28509
29309
|
|
|
28510
29310
|
// packages/agent-spawn/src/index.ts
|
|
28511
|
-
var
|
|
29311
|
+
var init_src17 = __esm({
|
|
28512
29312
|
"packages/agent-spawn/src/index.ts"() {
|
|
28513
29313
|
"use strict";
|
|
28514
29314
|
init_register_factories();
|
|
@@ -28541,7 +29341,7 @@ var gitContext, poe_agent_plugin_git_context_default;
|
|
|
28541
29341
|
var init_poe_agent_plugin_git_context = __esm({
|
|
28542
29342
|
"packages/poe-agent/src/plugins/poe-agent-plugin-git-context.ts"() {
|
|
28543
29343
|
"use strict";
|
|
28544
|
-
|
|
29344
|
+
init_src17();
|
|
28545
29345
|
gitContext = (cwd) => ({
|
|
28546
29346
|
name: "git-context",
|
|
28547
29347
|
async prompt(ctx) {
|
|
@@ -28780,7 +29580,7 @@ __export(src_exports, {
|
|
|
28780
29580
|
systemPromptPlugin: () => poe_agent_plugin_system_prompt_default,
|
|
28781
29581
|
webPlugin: () => poe_agent_plugin_web_default
|
|
28782
29582
|
});
|
|
28783
|
-
var
|
|
29583
|
+
var init_src18 = __esm({
|
|
28784
29584
|
"packages/poe-agent/src/index.ts"() {
|
|
28785
29585
|
"use strict";
|
|
28786
29586
|
init_agent();
|
|
@@ -28812,7 +29612,7 @@ var init_src17 = __esm({
|
|
|
28812
29612
|
|
|
28813
29613
|
// src/providers/poe-agent.ts
|
|
28814
29614
|
import fsPromises10 from "node:fs/promises";
|
|
28815
|
-
import
|
|
29615
|
+
import os9 from "node:os";
|
|
28816
29616
|
|
|
28817
29617
|
// src/cli/constants.ts
|
|
28818
29618
|
var DEFAULT_FRONTIER_MODEL = "anthropic/claude-opus-4.7";
|
|
@@ -28822,19 +29622,6 @@ var CLAUDE_CODE_VARIANTS = {
|
|
|
28822
29622
|
opus: "anthropic/claude-opus-4.7"
|
|
28823
29623
|
};
|
|
28824
29624
|
var DEFAULT_CLAUDE_CODE_MODEL = CLAUDE_CODE_VARIANTS.sonnet;
|
|
28825
|
-
var CODEX_MODELS = [
|
|
28826
|
-
"openai/gpt-5.5",
|
|
28827
|
-
"openai/gpt-5.4",
|
|
28828
|
-
"openai/gpt-5.3-codex",
|
|
28829
|
-
"openai/gpt-5.2-codex",
|
|
28830
|
-
"openai/gpt-5.2",
|
|
28831
|
-
"openai/gpt-5.2-chat",
|
|
28832
|
-
"openai/gpt-5.2-pro",
|
|
28833
|
-
"openai/gpt-5.1",
|
|
28834
|
-
"openai/gpt-5.1-codex-mini",
|
|
28835
|
-
"anthropic/claude-opus-4.7"
|
|
28836
|
-
];
|
|
28837
|
-
var DEFAULT_CODEX_MODEL = CODEX_MODELS[0];
|
|
28838
29625
|
var KIMI_MODELS = [
|
|
28839
29626
|
"novitaai/kimi-k2.5",
|
|
28840
29627
|
"novitaai/kimi-k2-thinking",
|
|
@@ -28955,6 +29742,7 @@ function createProvider(opts) {
|
|
|
28955
29742
|
configurePrompts: opts.configurePrompts,
|
|
28956
29743
|
postConfigureMessages: opts.postConfigureMessages,
|
|
28957
29744
|
extendConfigurePayload: opts.extendConfigurePayload,
|
|
29745
|
+
runtimeEnv: opts.runtimeEnv,
|
|
28958
29746
|
isolatedEnv: opts.isolatedEnv,
|
|
28959
29747
|
async configure(context, runOptions) {
|
|
28960
29748
|
await runMutations(opts.manifest.configure, {
|
|
@@ -29006,16 +29794,16 @@ function createInstallRunner(definition) {
|
|
|
29006
29794
|
// src/services/config.ts
|
|
29007
29795
|
init_src4();
|
|
29008
29796
|
init_src8();
|
|
29009
|
-
|
|
29010
|
-
import
|
|
29797
|
+
init_src18();
|
|
29798
|
+
import path53 from "node:path";
|
|
29011
29799
|
|
|
29012
29800
|
// packages/superintendent/src/document/parse.ts
|
|
29013
|
-
import
|
|
29801
|
+
import path44 from "node:path";
|
|
29014
29802
|
import { parseDocument as parseDocument4 } from "yaml";
|
|
29015
29803
|
var superintendentDocumentSchemaId = "https://poe-platform.github.io/poe-code/schemas/plans/superintendent.schema.json";
|
|
29016
29804
|
var validStatusStates = /* @__PURE__ */ new Set(["in_progress", "review", "completed"]);
|
|
29017
29805
|
function parseSuperintendentDoc(filePath, content) {
|
|
29018
|
-
const resolvedFilePath =
|
|
29806
|
+
const resolvedFilePath = path44.resolve(filePath);
|
|
29019
29807
|
const { frontmatterText, body } = splitFrontmatter(resolvedFilePath, content);
|
|
29020
29808
|
const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
|
|
29021
29809
|
return {
|
|
@@ -29025,7 +29813,7 @@ function parseSuperintendentDoc(filePath, content) {
|
|
|
29025
29813
|
};
|
|
29026
29814
|
}
|
|
29027
29815
|
function readExplicitBuilderAgent(filePath, content) {
|
|
29028
|
-
const resolvedFilePath =
|
|
29816
|
+
const resolvedFilePath = path44.resolve(filePath);
|
|
29029
29817
|
const { frontmatterText } = splitFrontmatter(resolvedFilePath, content);
|
|
29030
29818
|
const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
|
|
29031
29819
|
const frontmatter = expectRecord(parsedFrontmatter, "frontmatter", resolvedFilePath);
|
|
@@ -29182,7 +29970,7 @@ function parseStatusBlock(value, filePath) {
|
|
|
29182
29970
|
};
|
|
29183
29971
|
}
|
|
29184
29972
|
function expectRecord(value, fieldName, filePath) {
|
|
29185
|
-
if (!
|
|
29973
|
+
if (!isRecord11(value)) {
|
|
29186
29974
|
throw new Error(`${filePath}: ${fieldName} must be a mapping`);
|
|
29187
29975
|
}
|
|
29188
29976
|
return value;
|
|
@@ -29211,12 +29999,12 @@ function expectStringArray(value, fieldName, filePath) {
|
|
|
29211
29999
|
}
|
|
29212
30000
|
return value;
|
|
29213
30001
|
}
|
|
29214
|
-
function
|
|
30002
|
+
function isRecord11(value) {
|
|
29215
30003
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29216
30004
|
}
|
|
29217
30005
|
|
|
29218
30006
|
// packages/superintendent/src/document/write.ts
|
|
29219
|
-
import
|
|
30007
|
+
import path45 from "node:path";
|
|
29220
30008
|
import { isMap as isMap2, parseDocument as parseDocument5 } from "yaml";
|
|
29221
30009
|
function updateStatus(filePath, content, status) {
|
|
29222
30010
|
return updateFrontmatter(filePath, content, (frontmatterDocument) => {
|
|
@@ -29237,7 +30025,7 @@ function setStatusReason(filePath, content, reason) {
|
|
|
29237
30025
|
});
|
|
29238
30026
|
}
|
|
29239
30027
|
function updateFrontmatter(filePath, content, mutate) {
|
|
29240
|
-
const resolvedFilePath =
|
|
30028
|
+
const resolvedFilePath = path45.resolve(filePath);
|
|
29241
30029
|
const parts = splitDocument(resolvedFilePath, content);
|
|
29242
30030
|
const frontmatterDocument = parseDocument5(parts.frontmatterText);
|
|
29243
30031
|
if (frontmatterDocument.errors.length > 0) {
|
|
@@ -29463,7 +30251,7 @@ function extractText(node) {
|
|
|
29463
30251
|
|
|
29464
30252
|
// packages/superintendent/src/runtime/loop.ts
|
|
29465
30253
|
init_src13();
|
|
29466
|
-
import
|
|
30254
|
+
import path48 from "node:path";
|
|
29467
30255
|
import * as fsPromises8 from "node:fs/promises";
|
|
29468
30256
|
|
|
29469
30257
|
// packages/superintendent/src/state/machine.ts
|
|
@@ -29482,9 +30270,9 @@ function createLoopState(doc) {
|
|
|
29482
30270
|
// packages/superintendent/src/runtime/agent-runner.ts
|
|
29483
30271
|
init_register_factories();
|
|
29484
30272
|
init_src13();
|
|
29485
|
-
|
|
29486
|
-
import { mkdirSync as
|
|
29487
|
-
import
|
|
30273
|
+
init_src17();
|
|
30274
|
+
import { mkdirSync as mkdirSync6, openSync as openSync3, writeSync as writeSync2, closeSync as closeSync3 } from "node:fs";
|
|
30275
|
+
import path46 from "node:path";
|
|
29488
30276
|
var injectedRunner;
|
|
29489
30277
|
async function withAutonomousAgentRunner(runner, operation) {
|
|
29490
30278
|
const previous = injectedRunner;
|
|
@@ -29572,8 +30360,8 @@ async function runAutonomousAgent(input) {
|
|
|
29572
30360
|
}
|
|
29573
30361
|
function openSpawnLog2(filePath) {
|
|
29574
30362
|
try {
|
|
29575
|
-
|
|
29576
|
-
return
|
|
30363
|
+
mkdirSync6(path46.dirname(filePath), { recursive: true });
|
|
30364
|
+
return openSync3(filePath, "a");
|
|
29577
30365
|
} catch {
|
|
29578
30366
|
return void 0;
|
|
29579
30367
|
}
|
|
@@ -29588,7 +30376,7 @@ function appendSpawnLog2(fd, chunk) {
|
|
|
29588
30376
|
function closeSpawnLog2(fd) {
|
|
29589
30377
|
if (fd === void 0) return;
|
|
29590
30378
|
try {
|
|
29591
|
-
|
|
30379
|
+
closeSync3(fd);
|
|
29592
30380
|
} catch {
|
|
29593
30381
|
}
|
|
29594
30382
|
}
|
|
@@ -29597,15 +30385,15 @@ function closeSpawnLog2(fd) {
|
|
|
29597
30385
|
init_register_factories();
|
|
29598
30386
|
|
|
29599
30387
|
// packages/superintendent/src/runtime/resolve-cwd.ts
|
|
29600
|
-
import
|
|
30388
|
+
import path47 from "node:path";
|
|
29601
30389
|
function resolveRoleCwd(role, docPath, defaultCwd) {
|
|
29602
30390
|
if (role.cwd === void 0) {
|
|
29603
30391
|
return defaultCwd;
|
|
29604
30392
|
}
|
|
29605
|
-
if (
|
|
30393
|
+
if (path47.isAbsolute(role.cwd)) {
|
|
29606
30394
|
return role.cwd;
|
|
29607
30395
|
}
|
|
29608
|
-
return
|
|
30396
|
+
return path47.resolve(path47.dirname(docPath), role.cwd);
|
|
29609
30397
|
}
|
|
29610
30398
|
|
|
29611
30399
|
// packages/superintendent/src/runtime/templates.ts
|
|
@@ -29625,9 +30413,9 @@ function collectReferencedInspectors(template) {
|
|
|
29625
30413
|
return names;
|
|
29626
30414
|
}
|
|
29627
30415
|
function readTemplateValue(context, variablePath) {
|
|
29628
|
-
return variablePath.split(".").reduce((value, segment) =>
|
|
30416
|
+
return variablePath.split(".").reduce((value, segment) => isRecord12(value) ? value[segment] : void 0, context);
|
|
29629
30417
|
}
|
|
29630
|
-
function
|
|
30418
|
+
function isRecord12(value) {
|
|
29631
30419
|
return typeof value === "object" && value !== null;
|
|
29632
30420
|
}
|
|
29633
30421
|
|
|
@@ -29886,7 +30674,7 @@ function createWorkflowTool(role, state) {
|
|
|
29886
30674
|
};
|
|
29887
30675
|
}
|
|
29888
30676
|
function parseWorkflowCall(input) {
|
|
29889
|
-
if (!
|
|
30677
|
+
if (!isRecord13(input)) {
|
|
29890
30678
|
throw invalidActionError();
|
|
29891
30679
|
}
|
|
29892
30680
|
const { action } = input;
|
|
@@ -29958,7 +30746,7 @@ function invalidActionError() {
|
|
|
29958
30746
|
'workflow_transition action must be one of "request_review", "approve_completion", or "request_changes"'
|
|
29959
30747
|
);
|
|
29960
30748
|
}
|
|
29961
|
-
function
|
|
30749
|
+
function isRecord13(value) {
|
|
29962
30750
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29963
30751
|
}
|
|
29964
30752
|
|
|
@@ -30048,7 +30836,7 @@ function collectToolNames(result) {
|
|
|
30048
30836
|
}
|
|
30049
30837
|
const names = [];
|
|
30050
30838
|
collectToolNamesFrom(result.toolCalls, names);
|
|
30051
|
-
if (
|
|
30839
|
+
if (isRecord14(result.sessionResult)) {
|
|
30052
30840
|
collectToolNamesFrom(result.sessionResult.toolCalls, names);
|
|
30053
30841
|
}
|
|
30054
30842
|
return names;
|
|
@@ -30093,13 +30881,13 @@ function readTransitionFromToolCalls(value) {
|
|
|
30093
30881
|
return void 0;
|
|
30094
30882
|
}
|
|
30095
30883
|
function readTransitionFromSessionResult(value) {
|
|
30096
|
-
if (!
|
|
30884
|
+
if (!isRecord14(value)) {
|
|
30097
30885
|
return void 0;
|
|
30098
30886
|
}
|
|
30099
30887
|
return readTransitionFromToolCalls(value.toolCalls);
|
|
30100
30888
|
}
|
|
30101
30889
|
function readToolCall(value) {
|
|
30102
|
-
return
|
|
30890
|
+
return isRecord14(value) ? value : void 0;
|
|
30103
30891
|
}
|
|
30104
30892
|
function readToolCallName(toolCall) {
|
|
30105
30893
|
return readString4(toolCall.name) ?? readString4(toolCall.tool) ?? readString4(toolCall.title) ?? readString4(toolCall.path);
|
|
@@ -30136,7 +30924,7 @@ function encodeJson(value) {
|
|
|
30136
30924
|
function readString4(value) {
|
|
30137
30925
|
return typeof value === "string" ? value : void 0;
|
|
30138
30926
|
}
|
|
30139
|
-
function
|
|
30927
|
+
function isRecord14(value) {
|
|
30140
30928
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30141
30929
|
}
|
|
30142
30930
|
|
|
@@ -30245,7 +31033,7 @@ function readTransitionFromToolCalls2(value) {
|
|
|
30245
31033
|
return void 0;
|
|
30246
31034
|
}
|
|
30247
31035
|
function readTransitionFromSessionResult2(value) {
|
|
30248
|
-
if (!
|
|
31036
|
+
if (!isRecord15(value)) {
|
|
30249
31037
|
return void 0;
|
|
30250
31038
|
}
|
|
30251
31039
|
return readTransitionFromToolCalls2(value.toolCalls);
|
|
@@ -30270,7 +31058,7 @@ function extractOutputText(result) {
|
|
|
30270
31058
|
return readString5(result.output) ?? readString5(result.stdout) ?? readString5(result.text) ?? "";
|
|
30271
31059
|
}
|
|
30272
31060
|
function readToolCall2(value) {
|
|
30273
|
-
return
|
|
31061
|
+
return isRecord15(value) ? value : void 0;
|
|
30274
31062
|
}
|
|
30275
31063
|
function readToolCallName2(toolCall) {
|
|
30276
31064
|
return readString5(toolCall.name) ?? readString5(toolCall.tool) ?? readString5(toolCall.title) ?? readString5(toolCall.path);
|
|
@@ -30310,7 +31098,7 @@ function splitLines(value) {
|
|
|
30310
31098
|
function readString5(value) {
|
|
30311
31099
|
return typeof value === "string" ? value : void 0;
|
|
30312
31100
|
}
|
|
30313
|
-
function
|
|
31101
|
+
function isRecord15(value) {
|
|
30314
31102
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30315
31103
|
}
|
|
30316
31104
|
|
|
@@ -30341,8 +31129,15 @@ async function runLoop2(input, callbacks) {
|
|
|
30341
31129
|
options.callbacks.onBuilderStart?.();
|
|
30342
31130
|
let builderResult;
|
|
30343
31131
|
try {
|
|
31132
|
+
const builderDoc = await readDocument2(options.fs, options.docPath);
|
|
30344
31133
|
builderResult = await options.runners.builder(
|
|
30345
|
-
|
|
31134
|
+
options.builderAgent ? {
|
|
31135
|
+
...builderDoc,
|
|
31136
|
+
frontmatter: {
|
|
31137
|
+
...builderDoc.frontmatter,
|
|
31138
|
+
builder: { ...builderDoc.frontmatter.builder, agent: options.builderAgent }
|
|
31139
|
+
}
|
|
31140
|
+
} : builderDoc,
|
|
30346
31141
|
createTemplateContext(context),
|
|
30347
31142
|
buildRoleOptions(options, "builder")
|
|
30348
31143
|
);
|
|
@@ -30444,7 +31239,9 @@ async function runLoop2(input, callbacks) {
|
|
|
30444
31239
|
if (context.ownerFeedback && shouldContinueReview(await readDocument2(options.fs, options.docPath))) {
|
|
30445
31240
|
const superintendentResult = await executeSuperintendent(options, context);
|
|
30446
31241
|
if (superintendentResult.transition?.action !== "request_review") {
|
|
30447
|
-
throw new Error(
|
|
31242
|
+
throw new Error(
|
|
31243
|
+
"Superintendent must call request_review to continue a review exchange"
|
|
31244
|
+
);
|
|
30448
31245
|
}
|
|
30449
31246
|
context = {
|
|
30450
31247
|
...context,
|
|
@@ -30522,6 +31319,7 @@ function normalizeOptions(input, callbacks) {
|
|
|
30522
31319
|
callbacks: input.callbacks ?? {},
|
|
30523
31320
|
runners: resolveRunners(input.runners),
|
|
30524
31321
|
...input.runAgent ? { runAgent: input.runAgent } : {},
|
|
31322
|
+
...input.builderAgent ? { builderAgent: input.builderAgent } : {},
|
|
30525
31323
|
...input.signal ? { signal: input.signal } : {},
|
|
30526
31324
|
...input.logDir ? { logDir: input.logDir } : {}
|
|
30527
31325
|
};
|
|
@@ -30546,7 +31344,7 @@ function resolveRunners(overrides) {
|
|
|
30546
31344
|
};
|
|
30547
31345
|
}
|
|
30548
31346
|
function createDefaultFs3() {
|
|
30549
|
-
const
|
|
31347
|
+
const fs7 = {
|
|
30550
31348
|
readFile: fsPromises8.readFile,
|
|
30551
31349
|
writeFile: fsPromises8.writeFile,
|
|
30552
31350
|
readdir: fsPromises8.readdir,
|
|
@@ -30572,26 +31370,26 @@ function createDefaultFs3() {
|
|
|
30572
31370
|
await fsPromises8.rename(oldPath, newPath);
|
|
30573
31371
|
}
|
|
30574
31372
|
};
|
|
30575
|
-
return
|
|
31373
|
+
return fs7;
|
|
30576
31374
|
}
|
|
30577
|
-
async function readDocument2(
|
|
30578
|
-
const content = await readDocumentContent(
|
|
31375
|
+
async function readDocument2(fs7, docPath) {
|
|
31376
|
+
const content = await readDocumentContent(fs7, docPath);
|
|
30579
31377
|
return parseSuperintendentDoc(docPath, content);
|
|
30580
31378
|
}
|
|
30581
|
-
async function readDocumentContent(
|
|
30582
|
-
return
|
|
31379
|
+
async function readDocumentContent(fs7, docPath) {
|
|
31380
|
+
return fs7.readFile(docPath, "utf8");
|
|
30583
31381
|
}
|
|
30584
|
-
async function writeLoopState(
|
|
30585
|
-
const content = await
|
|
31382
|
+
async function writeLoopState(fs7, docPath, state) {
|
|
31383
|
+
const content = await fs7.readFile(docPath, "utf8");
|
|
30586
31384
|
const updatedContent = updateStatus(docPath, content, {
|
|
30587
31385
|
state: state.state,
|
|
30588
31386
|
round: state.round,
|
|
30589
31387
|
review_turn: state.reviewTurn
|
|
30590
31388
|
});
|
|
30591
|
-
await
|
|
31389
|
+
await fs7.writeFile(docPath, updatedContent, { encoding: "utf8" });
|
|
30592
31390
|
}
|
|
30593
|
-
async function restoreDocument(
|
|
30594
|
-
await
|
|
31391
|
+
async function restoreDocument(fs7, docPath, content) {
|
|
31392
|
+
await fs7.writeFile(docPath, content, { encoding: "utf8" });
|
|
30595
31393
|
}
|
|
30596
31394
|
async function rollbackRoundStatus(options, state) {
|
|
30597
31395
|
await writeLoopState(options.fs, options.docPath, state);
|
|
@@ -30660,7 +31458,7 @@ async function executeSuperintendent(options, context) {
|
|
|
30660
31458
|
function buildRoleOptions(options, role) {
|
|
30661
31459
|
return {
|
|
30662
31460
|
defaultCwd: options.cwd,
|
|
30663
|
-
...options.logDir ? { logPath:
|
|
31461
|
+
...options.logDir ? { logPath: path48.join(options.logDir, makeRunLogFileName(role)) } : {}
|
|
30664
31462
|
};
|
|
30665
31463
|
}
|
|
30666
31464
|
function shouldContinueReview(doc) {
|
|
@@ -30923,8 +31721,8 @@ var S = {
|
|
|
30923
31721
|
};
|
|
30924
31722
|
|
|
30925
31723
|
// packages/toolcraft/src/package-metadata.ts
|
|
30926
|
-
import { existsSync as existsSync3, readFileSync as
|
|
30927
|
-
import
|
|
31724
|
+
import { existsSync as existsSync3, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
|
|
31725
|
+
import path49 from "node:path";
|
|
30928
31726
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
30929
31727
|
|
|
30930
31728
|
// packages/toolcraft/src/index.ts
|
|
@@ -31291,8 +32089,8 @@ function createBuilderRunCommand(runners) {
|
|
|
31291
32089
|
positional: ["path"],
|
|
31292
32090
|
params: builderRunParams,
|
|
31293
32091
|
scope: ["cli", "mcp", "sdk"],
|
|
31294
|
-
handler: async ({ params, fs:
|
|
31295
|
-
const content = await readDocument3(params.path,
|
|
32092
|
+
handler: async ({ params, fs: fs7 }) => {
|
|
32093
|
+
const content = await readDocument3(params.path, fs7);
|
|
31296
32094
|
const document = parseSuperintendentDoc(params.path, content);
|
|
31297
32095
|
return runBuilderImpl(document, {}, { defaultCwd: process.cwd() });
|
|
31298
32096
|
},
|
|
@@ -31319,9 +32117,9 @@ function createBuilderGroup(runners) {
|
|
|
31319
32117
|
});
|
|
31320
32118
|
}
|
|
31321
32119
|
var builderGroup = createBuilderGroup();
|
|
31322
|
-
async function readDocument3(filePath,
|
|
32120
|
+
async function readDocument3(filePath, fs7) {
|
|
31323
32121
|
try {
|
|
31324
|
-
return await
|
|
32122
|
+
return await fs7.readFile(filePath, "utf8");
|
|
31325
32123
|
} catch (error2) {
|
|
31326
32124
|
if (hasCode2(error2, "ENOENT")) {
|
|
31327
32125
|
throw new UserError(`Superintendent document not found: ${filePath}`);
|
|
@@ -31350,13 +32148,13 @@ function hasCode2(error2, code) {
|
|
|
31350
32148
|
}
|
|
31351
32149
|
|
|
31352
32150
|
// packages/superintendent/src/commands/install.ts
|
|
31353
|
-
import
|
|
32151
|
+
import path50 from "node:path";
|
|
31354
32152
|
import { readFile as readFile8, stat as stat4, mkdir as mkdir4, writeFile as writeFile3, unlink as unlink3, readdir as readdir4, chmod as chmod2 } from "node:fs/promises";
|
|
31355
32153
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
31356
32154
|
init_src8();
|
|
31357
32155
|
init_src15();
|
|
31358
32156
|
init_src13();
|
|
31359
|
-
var
|
|
32157
|
+
var fs5 = {
|
|
31360
32158
|
readFile: (p, encoding) => readFile8(p, encoding),
|
|
31361
32159
|
writeFile: (p, content) => writeFile3(p, content),
|
|
31362
32160
|
mkdir: (p, options) => mkdir4(p, options).then(() => void 0),
|
|
@@ -31397,7 +32195,7 @@ var installCommand = defineCommand({
|
|
|
31397
32195
|
content: skillContent + "\n\n" + skillPlanConfigSection("superintendent")
|
|
31398
32196
|
},
|
|
31399
32197
|
{
|
|
31400
|
-
fs:
|
|
32198
|
+
fs: fs5,
|
|
31401
32199
|
cwd,
|
|
31402
32200
|
homeDir,
|
|
31403
32201
|
scope
|
|
@@ -31406,7 +32204,7 @@ var installCommand = defineCommand({
|
|
|
31406
32204
|
const planDirectory = await resolvePlanDirectory2(cwd, homeDir, process.env);
|
|
31407
32205
|
const absolutePlanDirectory = resolveAbsoluteDirectory(planDirectory, cwd, homeDir);
|
|
31408
32206
|
let planDirectoryCreated = false;
|
|
31409
|
-
if (!await
|
|
32207
|
+
if (!await pathExists4(absolutePlanDirectory)) {
|
|
31410
32208
|
await mkdir4(absolutePlanDirectory, { recursive: true });
|
|
31411
32209
|
planDirectoryCreated = true;
|
|
31412
32210
|
}
|
|
@@ -31447,16 +32245,16 @@ var installCommand = defineCommand({
|
|
|
31447
32245
|
async function resolvePlanDirectory2(cwd, homeDir, env) {
|
|
31448
32246
|
const configPath = resolveConfigPath(homeDir);
|
|
31449
32247
|
const projectConfigPath = resolveProjectConfigPath(cwd);
|
|
31450
|
-
const document = await readMergedDocument(
|
|
32248
|
+
const document = await readMergedDocument(fs5, configPath, projectConfigPath);
|
|
31451
32249
|
return resolveScope(planConfigScope.schema, document.plan, env).plan_directory;
|
|
31452
32250
|
}
|
|
31453
32251
|
function resolveAbsoluteDirectory(dir, cwd, homeDir) {
|
|
31454
32252
|
if (dir.startsWith("~/")) {
|
|
31455
|
-
return
|
|
32253
|
+
return path50.join(homeDir, dir.slice(2));
|
|
31456
32254
|
}
|
|
31457
|
-
return
|
|
32255
|
+
return path50.isAbsolute(dir) ? dir : path50.resolve(cwd, dir);
|
|
31458
32256
|
}
|
|
31459
|
-
async function
|
|
32257
|
+
async function pathExists4(targetPath) {
|
|
31460
32258
|
try {
|
|
31461
32259
|
await stat4(targetPath);
|
|
31462
32260
|
return true;
|
|
@@ -31474,15 +32272,15 @@ async function loadSkillTemplate() {
|
|
|
31474
32272
|
}
|
|
31475
32273
|
const packageRoot = await findPackageRoot(fileURLToPath5(import.meta.url));
|
|
31476
32274
|
const templateRoots = [
|
|
31477
|
-
|
|
31478
|
-
|
|
32275
|
+
path50.join(packageRoot, "src", "templates"),
|
|
32276
|
+
path50.join(packageRoot, "dist", "templates")
|
|
31479
32277
|
];
|
|
31480
32278
|
for (const templateRoot of templateRoots) {
|
|
31481
|
-
if (!await
|
|
32279
|
+
if (!await pathExists4(templateRoot)) {
|
|
31482
32280
|
continue;
|
|
31483
32281
|
}
|
|
31484
32282
|
skillTemplateCache = await readFile8(
|
|
31485
|
-
|
|
32283
|
+
path50.join(templateRoot, "SKILL_superintendent.md"),
|
|
31486
32284
|
"utf8"
|
|
31487
32285
|
);
|
|
31488
32286
|
return skillTemplateCache;
|
|
@@ -31490,12 +32288,12 @@ async function loadSkillTemplate() {
|
|
|
31490
32288
|
throw new Error("Unable to locate Superintendent skill template.");
|
|
31491
32289
|
}
|
|
31492
32290
|
async function findPackageRoot(entryFilePath) {
|
|
31493
|
-
let currentPath =
|
|
32291
|
+
let currentPath = path50.dirname(entryFilePath);
|
|
31494
32292
|
while (true) {
|
|
31495
|
-
if (await
|
|
32293
|
+
if (await pathExists4(path50.join(currentPath, "package.json"))) {
|
|
31496
32294
|
return currentPath;
|
|
31497
32295
|
}
|
|
31498
|
-
const parentPath =
|
|
32296
|
+
const parentPath = path50.dirname(currentPath);
|
|
31499
32297
|
if (parentPath === currentPath) {
|
|
31500
32298
|
throw new Error("Unable to locate package root for Superintendent templates.");
|
|
31501
32299
|
}
|
|
@@ -31517,8 +32315,8 @@ var inspectorListCommand = defineCommand({
|
|
|
31517
32315
|
positional: ["path"],
|
|
31518
32316
|
params: inspectorListParams,
|
|
31519
32317
|
scope: ["cli", "mcp", "sdk"],
|
|
31520
|
-
handler: async ({ params, fs:
|
|
31521
|
-
const content = await readDocument4(params.path,
|
|
32318
|
+
handler: async ({ params, fs: fs7 }) => {
|
|
32319
|
+
const content = await readDocument4(params.path, fs7);
|
|
31522
32320
|
const document = parseSuperintendentDoc(params.path, content);
|
|
31523
32321
|
return Object.entries(document.frontmatter.inspectors ?? {}).map(([name, config]) => ({
|
|
31524
32322
|
name,
|
|
@@ -31561,8 +32359,8 @@ function createInspectorRunCommand(runners) {
|
|
|
31561
32359
|
positional: ["path", "name"],
|
|
31562
32360
|
params: inspectorRunParams,
|
|
31563
32361
|
scope: ["cli", "mcp", "sdk"],
|
|
31564
|
-
handler: async ({ params, fs:
|
|
31565
|
-
const content = await readDocument4(params.path,
|
|
32362
|
+
handler: async ({ params, fs: fs7 }) => {
|
|
32363
|
+
const content = await readDocument4(params.path, fs7);
|
|
31566
32364
|
const document = parseSuperintendentDoc(params.path, content);
|
|
31567
32365
|
const defaultCwd = process.cwd();
|
|
31568
32366
|
if (params.name === void 0) {
|
|
@@ -31600,9 +32398,9 @@ function createInspectorGroup(runners) {
|
|
|
31600
32398
|
});
|
|
31601
32399
|
}
|
|
31602
32400
|
var inspectorGroup = createInspectorGroup();
|
|
31603
|
-
async function readDocument4(filePath,
|
|
32401
|
+
async function readDocument4(filePath, fs7) {
|
|
31604
32402
|
try {
|
|
31605
|
-
return await
|
|
32403
|
+
return await fs7.readFile(filePath, "utf8");
|
|
31606
32404
|
} catch (error2) {
|
|
31607
32405
|
if (hasCode3(error2, "ENOENT")) {
|
|
31608
32406
|
throw new UserError(`Superintendent document not found: ${filePath}`);
|
|
@@ -31650,11 +32448,11 @@ var completeCommand = defineCommand({
|
|
|
31650
32448
|
positional: ["path"],
|
|
31651
32449
|
params: completeParams,
|
|
31652
32450
|
scope: ["cli", "mcp", "sdk"],
|
|
31653
|
-
handler: async ({ params, fs:
|
|
31654
|
-
const content = await readDocument5(params.path,
|
|
32451
|
+
handler: async ({ params, fs: fs7 }) => {
|
|
32452
|
+
const content = await readDocument5(params.path, fs7);
|
|
31655
32453
|
const completedContent = transitionState(params.path, content, "completed");
|
|
31656
32454
|
const updatedContent = setStatusReason(params.path, completedContent, params.reason);
|
|
31657
|
-
await
|
|
32455
|
+
await fs7.writeFile(params.path, updatedContent);
|
|
31658
32456
|
return {
|
|
31659
32457
|
path: params.path,
|
|
31660
32458
|
state: "completed",
|
|
@@ -31678,9 +32476,9 @@ var completeCommand = defineCommand({
|
|
|
31678
32476
|
json: (result) => result
|
|
31679
32477
|
}
|
|
31680
32478
|
});
|
|
31681
|
-
async function readDocument5(filePath,
|
|
32479
|
+
async function readDocument5(filePath, fs7) {
|
|
31682
32480
|
try {
|
|
31683
|
-
return await
|
|
32481
|
+
return await fs7.readFile(filePath, "utf8");
|
|
31684
32482
|
} catch (error2) {
|
|
31685
32483
|
if (hasCode4(error2, "ENOENT")) {
|
|
31686
32484
|
throw new UserError(`Superintendent document not found: ${filePath}`);
|
|
@@ -31693,10 +32491,10 @@ function hasCode4(error2, code) {
|
|
|
31693
32491
|
}
|
|
31694
32492
|
|
|
31695
32493
|
// packages/superintendent/src/commands/plan-path.ts
|
|
31696
|
-
import
|
|
32494
|
+
import path51 from "node:path";
|
|
31697
32495
|
import { readFile as readFile9, writeFile as writeFile4, mkdir as mkdir5, unlink as unlink4, stat as stat5, readdir as readdir5 } from "node:fs/promises";
|
|
31698
32496
|
init_src8();
|
|
31699
|
-
var
|
|
32497
|
+
var fs6 = {
|
|
31700
32498
|
readFile: (p, encoding) => readFile9(p, encoding),
|
|
31701
32499
|
writeFile: (p, content) => writeFile4(p, content),
|
|
31702
32500
|
mkdir: (p, options) => mkdir5(p, options).then(() => void 0),
|
|
@@ -31714,7 +32512,7 @@ var planPathCommand = defineCommand({
|
|
|
31714
32512
|
const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? cwd;
|
|
31715
32513
|
const configPath = resolveConfigPath(homeDir);
|
|
31716
32514
|
const projectConfigPath = resolveProjectConfigPath(cwd);
|
|
31717
|
-
const document = await readMergedDocument(
|
|
32515
|
+
const document = await readMergedDocument(fs6, configPath, projectConfigPath);
|
|
31718
32516
|
const planDirectory = resolveScope(planConfigScope.schema, document.plan, process.env).plan_directory;
|
|
31719
32517
|
return { planDirectory: resolveAbsoluteDirectory2(planDirectory, cwd, homeDir) };
|
|
31720
32518
|
},
|
|
@@ -31729,22 +32527,22 @@ var planPathCommand = defineCommand({
|
|
|
31729
32527
|
});
|
|
31730
32528
|
function resolveAbsoluteDirectory2(dir, cwd, homeDir) {
|
|
31731
32529
|
if (dir.startsWith("~/")) {
|
|
31732
|
-
return
|
|
32530
|
+
return path51.join(homeDir, dir.slice(2));
|
|
31733
32531
|
}
|
|
31734
|
-
return
|
|
32532
|
+
return path51.isAbsolute(dir) ? dir : path51.resolve(cwd, dir);
|
|
31735
32533
|
}
|
|
31736
32534
|
|
|
31737
32535
|
// packages/superintendent/src/commands/run.ts
|
|
31738
32536
|
init_src13();
|
|
31739
|
-
|
|
32537
|
+
init_src17();
|
|
31740
32538
|
init_src5();
|
|
31741
|
-
import
|
|
32539
|
+
import path52 from "node:path";
|
|
31742
32540
|
import * as fsPromises9 from "node:fs/promises";
|
|
31743
32541
|
import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
|
|
31744
32542
|
|
|
31745
32543
|
// packages/superintendent/src/commands/poe-agent-runner.ts
|
|
31746
32544
|
init_src5();
|
|
31747
|
-
|
|
32545
|
+
init_src18();
|
|
31748
32546
|
async function executePoeAgent(agentSpec, input, createAgent = agent) {
|
|
31749
32547
|
const { model } = parseAgentSpecifier(agentSpec);
|
|
31750
32548
|
if (!model) {
|
|
@@ -32828,12 +33626,12 @@ function createRunMcpCommand(runners) {
|
|
|
32828
33626
|
});
|
|
32829
33627
|
}
|
|
32830
33628
|
var runMcpCommand = createRunMcpCommand();
|
|
32831
|
-
async function resolveSuperintendentCommandConfig(cwd, homeDir, env,
|
|
33629
|
+
async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs7) {
|
|
32832
33630
|
const configPath = resolveConfigPath(homeDir);
|
|
32833
33631
|
const projectConfigPath = resolveProjectConfigPath(cwd);
|
|
32834
33632
|
try {
|
|
32835
33633
|
const document = await readMergedDocument(
|
|
32836
|
-
createConfigResolutionFs(
|
|
33634
|
+
createConfigResolutionFs(fs7),
|
|
32837
33635
|
configPath,
|
|
32838
33636
|
projectConfigPath
|
|
32839
33637
|
);
|
|
@@ -32854,11 +33652,11 @@ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs6) {
|
|
|
32854
33652
|
return { configDoc: {}, configuredDefaultAgent: null, tui: false };
|
|
32855
33653
|
}
|
|
32856
33654
|
}
|
|
32857
|
-
async function resolveSuperintendentPlanDirectory(cwd, homeDir, env,
|
|
33655
|
+
async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs7) {
|
|
32858
33656
|
const configPath = resolveConfigPath(homeDir);
|
|
32859
33657
|
const projectConfigPath = resolveProjectConfigPath(cwd);
|
|
32860
33658
|
const document = await readMergedDocument(
|
|
32861
|
-
createConfigResolutionFs(
|
|
33659
|
+
createConfigResolutionFs(fs7),
|
|
32862
33660
|
configPath,
|
|
32863
33661
|
projectConfigPath
|
|
32864
33662
|
);
|
|
@@ -32879,23 +33677,23 @@ var configFs = {
|
|
|
32879
33677
|
},
|
|
32880
33678
|
readdir: (filePath) => fsPromises9.readdir(filePath)
|
|
32881
33679
|
};
|
|
32882
|
-
function createConfigResolutionFs(
|
|
32883
|
-
if (!
|
|
33680
|
+
function createConfigResolutionFs(fs7) {
|
|
33681
|
+
if (!fs7) {
|
|
32884
33682
|
return configFs;
|
|
32885
33683
|
}
|
|
32886
33684
|
return {
|
|
32887
33685
|
...configFs,
|
|
32888
|
-
readFile: (filePath, encoding) =>
|
|
33686
|
+
readFile: (filePath, encoding) => fs7.readFile(filePath, encoding),
|
|
32889
33687
|
writeFile: async (filePath, content, options) => {
|
|
32890
|
-
await
|
|
33688
|
+
await fs7.writeFile(filePath, content, options);
|
|
32891
33689
|
},
|
|
32892
33690
|
mkdir: async (filePath, options) => {
|
|
32893
|
-
await
|
|
33691
|
+
await fs7.mkdir(filePath, options);
|
|
32894
33692
|
}
|
|
32895
33693
|
};
|
|
32896
33694
|
}
|
|
32897
33695
|
async function runSuperintendentCommand(options) {
|
|
32898
|
-
const
|
|
33696
|
+
const fs7 = options.fs ?? createDefaultFs4();
|
|
32899
33697
|
const now = options.now ?? Date.now;
|
|
32900
33698
|
const selectPrompt = options.selectPrompt ?? select2;
|
|
32901
33699
|
const dashboardFactory = options.createDashboard ?? createDashboard;
|
|
@@ -32926,7 +33724,7 @@ async function runSuperintendentCommand(options) {
|
|
|
32926
33724
|
assumeYes,
|
|
32927
33725
|
interactive,
|
|
32928
33726
|
env,
|
|
32929
|
-
fs:
|
|
33727
|
+
fs: fs7,
|
|
32930
33728
|
selectPrompt
|
|
32931
33729
|
});
|
|
32932
33730
|
const runLogDir = resolveRunLogDir({
|
|
@@ -32934,7 +33732,7 @@ async function runSuperintendentCommand(options) {
|
|
|
32934
33732
|
runner: "superintendent",
|
|
32935
33733
|
homeDir: options.homeDir
|
|
32936
33734
|
});
|
|
32937
|
-
const documentContent = await
|
|
33735
|
+
const documentContent = await fs7.readFile(selectedDocPath, "utf8");
|
|
32938
33736
|
const document = parseSuperintendentDoc(selectedDocPath, documentContent);
|
|
32939
33737
|
const selectedBuilder = await resolveLoopAgent({
|
|
32940
33738
|
providedAgent: normalizeAgentSelection(options.builderAgent),
|
|
@@ -32966,7 +33764,7 @@ async function runSuperintendentCommand(options) {
|
|
|
32966
33764
|
docPath: selectedDocPath,
|
|
32967
33765
|
cwd: options.cwd,
|
|
32968
33766
|
homeDir: options.homeDir,
|
|
32969
|
-
...options.fs ? { fs:
|
|
33767
|
+
...options.fs ? { fs: fs7 } : {},
|
|
32970
33768
|
signal: headlessAbort.signal,
|
|
32971
33769
|
logDir: runLogDir,
|
|
32972
33770
|
callbacks: mergeLoopCallbacks({
|
|
@@ -33225,7 +34023,7 @@ async function runSuperintendentCommand(options) {
|
|
|
33225
34023
|
session.pauseRequested = true;
|
|
33226
34024
|
}
|
|
33227
34025
|
editPlan(session.dashboard, session.latestLogFile, env, options.openInEditor);
|
|
33228
|
-
appendEvent("info", `Log opened: ${
|
|
34026
|
+
appendEvent("info", `Log opened: ${path52.basename(session.latestLogFile)}`);
|
|
33229
34027
|
syncStats();
|
|
33230
34028
|
}
|
|
33231
34029
|
};
|
|
@@ -33245,7 +34043,7 @@ async function runSuperintendentCommand(options) {
|
|
|
33245
34043
|
docPath: selectedDocPath,
|
|
33246
34044
|
cwd: options.cwd,
|
|
33247
34045
|
homeDir: options.homeDir,
|
|
33248
|
-
...options.fs ? { fs:
|
|
34046
|
+
...options.fs ? { fs: fs7 } : {},
|
|
33249
34047
|
callbacks: mergeLoopCallbacks(callbacks, integrations?.superintendentCallbacks),
|
|
33250
34048
|
signal: abortController.signal,
|
|
33251
34049
|
logDir: runLogDir,
|
|
@@ -33606,7 +34404,7 @@ function resolveEditor(env) {
|
|
|
33606
34404
|
const parts = raw.split(/\s+/);
|
|
33607
34405
|
const command = parts[0] ?? "vi";
|
|
33608
34406
|
const args = parts.slice(1);
|
|
33609
|
-
const binary =
|
|
34407
|
+
const binary = path52.basename(command);
|
|
33610
34408
|
const mode = GUI_EDITOR_BINARIES.has(binary) ? "gui" : "tty";
|
|
33611
34409
|
return { command, args, mode };
|
|
33612
34410
|
}
|
|
@@ -33633,7 +34431,7 @@ function stripStopReason(result) {
|
|
|
33633
34431
|
};
|
|
33634
34432
|
}
|
|
33635
34433
|
function createDefaultFs4() {
|
|
33636
|
-
const
|
|
34434
|
+
const fs7 = {
|
|
33637
34435
|
readFile: fsPromises9.readFile,
|
|
33638
34436
|
writeFile: fsPromises9.writeFile,
|
|
33639
34437
|
readdir: fsPromises9.readdir,
|
|
@@ -33659,7 +34457,7 @@ function createDefaultFs4() {
|
|
|
33659
34457
|
await fsPromises9.rename(oldPath, newPath);
|
|
33660
34458
|
}
|
|
33661
34459
|
};
|
|
33662
|
-
return
|
|
34460
|
+
return fs7;
|
|
33663
34461
|
}
|
|
33664
34462
|
function toError6(error2) {
|
|
33665
34463
|
return error2 instanceof Error ? error2 : new Error(String(error2));
|
|
@@ -33675,8 +34473,8 @@ var validateCommand = defineCommand({
|
|
|
33675
34473
|
positional: ["path"],
|
|
33676
34474
|
params: validateParams,
|
|
33677
34475
|
scope: ["cli", "mcp", "sdk"],
|
|
33678
|
-
handler: async ({ params, fs:
|
|
33679
|
-
const content = await readDocument6(params.path,
|
|
34476
|
+
handler: async ({ params, fs: fs7 }) => {
|
|
34477
|
+
const content = await readDocument6(params.path, fs7);
|
|
33680
34478
|
return validateSuperintendentDocument(params.path, content);
|
|
33681
34479
|
},
|
|
33682
34480
|
render: {
|
|
@@ -33762,9 +34560,9 @@ function validateSuperintendentDocument(filePath, content) {
|
|
|
33762
34560
|
problems.push(...validatePromptVariables(document));
|
|
33763
34561
|
return toValidationResult(problems);
|
|
33764
34562
|
}
|
|
33765
|
-
async function readDocument6(filePath,
|
|
34563
|
+
async function readDocument6(filePath, fs7) {
|
|
33766
34564
|
try {
|
|
33767
|
-
return await
|
|
34565
|
+
return await fs7.readFile(filePath, "utf8");
|
|
33768
34566
|
} catch (error2) {
|
|
33769
34567
|
if (hasCode5(error2, "ENOENT")) {
|
|
33770
34568
|
throw new UserError(`Superintendent document not found: ${filePath}`);
|
|
@@ -34250,19 +35048,19 @@ function emitEvent(callback, event) {
|
|
|
34250
35048
|
callback(event);
|
|
34251
35049
|
}
|
|
34252
35050
|
async function loadConfiguredPlugins(options) {
|
|
34253
|
-
const
|
|
34254
|
-
const homeDir = options.homeDir ??
|
|
35051
|
+
const fs7 = createConfigFileSystem(options.fs);
|
|
35052
|
+
const homeDir = options.homeDir ?? os9.homedir();
|
|
34255
35053
|
const store = createConfigStore({
|
|
34256
|
-
fs:
|
|
35054
|
+
fs: fs7,
|
|
34257
35055
|
filePath: options.configPath ?? resolveConfigPath(homeDir),
|
|
34258
35056
|
projectFilePath: options.projectConfigPath ?? resolveProjectConfigPath(options.cwd)
|
|
34259
35057
|
});
|
|
34260
35058
|
const plugins = await store.scope(agentConfigScope).get("plugins");
|
|
34261
35059
|
return plugins ?? void 0;
|
|
34262
35060
|
}
|
|
34263
|
-
function createConfigFileSystem(
|
|
34264
|
-
if (
|
|
34265
|
-
return
|
|
35061
|
+
function createConfigFileSystem(fs7) {
|
|
35062
|
+
if (fs7) {
|
|
35063
|
+
return fs7;
|
|
34266
35064
|
}
|
|
34267
35065
|
return {
|
|
34268
35066
|
readFile(filePath, encoding) {
|
|
@@ -34322,7 +35120,7 @@ function createInMemoryAcpTransport2(options) {
|
|
|
34322
35120
|
}
|
|
34323
35121
|
if (method === "session/new") {
|
|
34324
35122
|
const request = params;
|
|
34325
|
-
const { createAgentSession: createAgentSession2 } = await Promise.resolve().then(() => (
|
|
35123
|
+
const { createAgentSession: createAgentSession2 } = await Promise.resolve().then(() => (init_src18(), src_exports));
|
|
34326
35124
|
const session = await createAgentSession2({
|
|
34327
35125
|
model: options.model,
|
|
34328
35126
|
cwd: request.cwd || options.cwd,
|