poe-code 3.0.224 → 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.
Files changed (78) hide show
  1. package/dist/bin/poe-gemini.js +23 -0
  2. package/dist/cli/commands/configure-payload.js +50 -3
  3. package/dist/cli/commands/configure-payload.js.map +1 -1
  4. package/dist/cli/commands/pipeline.js +4 -2
  5. package/dist/cli/commands/pipeline.js.map +1 -1
  6. package/dist/cli/commands/ralph.js +1 -0
  7. package/dist/cli/commands/ralph.js.map +1 -1
  8. package/dist/cli/commands/shared.d.ts +4 -0
  9. package/dist/cli/commands/shared.js +33 -2
  10. package/dist/cli/commands/shared.js.map +1 -1
  11. package/dist/cli/commands/spawn.js +20 -0
  12. package/dist/cli/commands/spawn.js.map +1 -1
  13. package/dist/cli/commands/test.d.ts +5 -1
  14. package/dist/cli/commands/test.js +58 -6
  15. package/dist/cli/commands/test.js.map +1 -1
  16. package/dist/cli/constants.d.ts +1 -0
  17. package/dist/cli/constants.js +2 -1
  18. package/dist/cli/constants.js.map +1 -1
  19. package/dist/cli/isolated-env.d.ts +2 -1
  20. package/dist/cli/isolated-env.js +20 -2
  21. package/dist/cli/isolated-env.js.map +1 -1
  22. package/dist/cli/options.d.ts +2 -5
  23. package/dist/cli/poe-code-command-runner.js +7 -2
  24. package/dist/cli/poe-code-command-runner.js.map +1 -1
  25. package/dist/cli/prompts.d.ts +21 -13
  26. package/dist/cli/prompts.js.map +1 -1
  27. package/dist/cli/service-registry.d.ts +12 -3
  28. package/dist/cli/service-registry.js.map +1 -1
  29. package/dist/index.d.ts +3 -1
  30. package/dist/index.js +4694 -2378
  31. package/dist/index.js.map +4 -4
  32. package/dist/providers/claude-code.js +913 -152
  33. package/dist/providers/claude-code.js.map +4 -4
  34. package/dist/providers/codex.js +897 -149
  35. package/dist/providers/codex.js.map +4 -4
  36. package/dist/providers/create-provider.d.ts +1 -0
  37. package/dist/providers/create-provider.js +1 -0
  38. package/dist/providers/create-provider.js.map +1 -1
  39. package/dist/providers/gemini-cli.d.ts +16 -0
  40. package/dist/providers/gemini-cli.js +11349 -0
  41. package/dist/providers/gemini-cli.js.map +7 -0
  42. package/dist/providers/goose.js +870 -161
  43. package/dist/providers/goose.js.map +4 -4
  44. package/dist/providers/kimi.js +894 -143
  45. package/dist/providers/kimi.js.map +4 -4
  46. package/dist/providers/opencode.js +894 -143
  47. package/dist/providers/opencode.js.map +4 -4
  48. package/dist/providers/poe-agent.js +1144 -335
  49. package/dist/providers/poe-agent.js.map +4 -4
  50. package/dist/providers/spawn-options.d.ts +3 -0
  51. package/dist/sdk/pipeline.d.ts +1 -1
  52. package/dist/sdk/pipeline.js +22 -19
  53. package/dist/sdk/pipeline.js.map +1 -1
  54. package/dist/sdk/ralph.js +5 -0
  55. package/dist/sdk/ralph.js.map +1 -1
  56. package/dist/sdk/spawn-core.d.ts +3 -0
  57. package/dist/sdk/spawn-core.js +6 -8
  58. package/dist/sdk/spawn-core.js.map +1 -1
  59. package/dist/sdk/spawn.d.ts +8 -8
  60. package/dist/sdk/spawn.js +26 -3
  61. package/dist/sdk/spawn.js.map +1 -1
  62. package/dist/sdk/types.d.ts +7 -0
  63. package/dist/utils/command-checks.d.ts +8 -0
  64. package/dist/utils/command-checks.js +35 -9
  65. package/dist/utils/command-checks.js.map +1 -1
  66. package/dist/utils/dry-run.js +7 -1
  67. package/dist/utils/dry-run.js.map +1 -1
  68. package/dist/workflow-templates/github-issue-opened.caller.yml +2 -1
  69. package/dist/workflow-templates/github-issue-opened.ejected.yml +2 -1
  70. package/package.json +2 -1
  71. package/packages/agent-skill-config/dist/configs.js +4 -0
  72. package/packages/agent-skill-config/dist/git-exclude.d.ts +6 -2
  73. package/packages/agent-skill-config/dist/git-exclude.js +12 -12
  74. package/packages/memory/dist/index.js +914 -192
  75. package/packages/memory/dist/index.js.map +4 -4
  76. package/packages/superintendent/dist/index.d.ts +2 -1
  77. package/packages/superintendent/dist/runtime/loop.d.ts +1 -0
  78. 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(path49) {
613
- if (!isAbsolute(path49)) {
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, fs6) {
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 fs6.readFile(filePath, "utf8"),
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, path49) {
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, path49);
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, path49) {
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(path49, key2);
2020
+ const fullPath = buildPath(path54, key2);
2021
2021
  if (isPlainObject(winningValue)) {
2022
- const merged = mergeObjectLayers(objectLayers, [...path49, key2]);
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(path49, key2) {
2048
- return [...path49, key2].join(".");
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(path49) {
9892
- const ext = getExtension(path49);
9891
+ function detectFormat2(path54) {
9892
+ const ext = getExtension(path54);
9893
9893
  return extensionMap[ext];
9894
9894
  }
9895
- function getExtension(path49) {
9896
- const lastDot = path49.lastIndexOf(".");
9895
+ function getExtension(path54) {
9896
+ const lastDot = path54.lastIndexOf(".");
9897
9897
  if (lastDot === -1) {
9898
9898
  return "";
9899
9899
  }
9900
- return path49.slice(lastDot).toLowerCase();
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(fs6, target) {
9979
+ async function readFileIfExists(fs7, target) {
9980
9980
  try {
9981
- return await fs6.readFile(target, "utf8");
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(fs6, target) {
9989
+ async function pathExists(fs7, target) {
9990
9990
  try {
9991
- await fs6.stat(target);
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(fs6, targetPath, content) {
10020
+ async function backupInvalidDocument(fs7, targetPath, content) {
10021
10021
  const backupPath = createInvalidDocumentBackupPath(targetPath);
10022
- await fs6.writeFile(backupPath, content, { encoding: "utf8" });
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(fs6, filePath) {
10626
- const document = await readStoredDocument(fs6, filePath);
10625
+ async function readDocument(fs7, filePath) {
10626
+ const document = await readStoredDocument(fs7, filePath);
10627
10627
  return document.data;
10628
10628
  }
10629
- async function writeScope(fs6, filePath, scope, values) {
10630
- const document = await readDocument(fs6, filePath);
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(fs6, filePath, document);
10637
+ await writeDocument(fs7, filePath, document);
10638
10638
  }
10639
- async function readMergedDocument(fs6, globalPath, projectPath) {
10640
- const globalDocument = await readStoredDocument(fs6, globalPath);
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(fs6, projectPath);
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(fs6, globalPath, globalDocument.content),
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(fs6, filePath) {
10664
+ async function readStoredDocument(fs7, filePath) {
10665
10665
  try {
10666
- const raw = await fs6.readFile(filePath, "utf8");
10667
- return await parseStoredDocument(fs6, filePath, raw);
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(fs6, filePath, raw) {
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(fs6, filePath, raw);
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(fs6, globalPath, globalContent) {
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 fs6.readFile(filePath, "utf8");
10726
+ return fs7.readFile(filePath, "utf8");
10727
10727
  }
10728
10728
  };
10729
10729
  }
10730
- async function writeDocument(fs6, filePath, document) {
10731
- await fs6.mkdir(path6.dirname(filePath), { recursive: true });
10732
- await fs6.writeFile(filePath, `${JSON.stringify(document, null, 2)}
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(fs6, filePath, content) {
10738
- await fs6.mkdir(path6.dirname(filePath), { recursive: true });
10737
+ async function recoverInvalidDocument(fs7, filePath, content) {
10738
+ await fs7.mkdir(path6.dirname(filePath), { recursive: true });
10739
10739
  const backupPath = createInvalidBackupPath(filePath);
10740
- await fs6.writeFile(backupPath, content, { encoding: "utf8" });
10741
- await fs6.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
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, path49 = []) {
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([...path49, key2]) && Array.isArray(baseValue) && Array.isArray(overrideValue)) {
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, [...path49, key2]);
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(path49) {
10940
- return path49.join(".") === "mounts" || path49.join(".") === "runner.workspace.exclude";
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",
@@ -11528,6 +11564,12 @@ var init_cloudflare = __esm({
11528
11564
  storageKey: "provider:cloudflare",
11529
11565
  prompt: { title: "Cloudflare AI Gateway token" }
11530
11566
  },
11567
+ env: {
11568
+ ANTHROPIC_CUSTOM_HEADERS: {
11569
+ kind: "providerCredential",
11570
+ prefix: "Authorization: Bearer "
11571
+ }
11572
+ },
11531
11573
  apiShapes: [
11532
11574
  {
11533
11575
  id: "openai-chat-completions",
@@ -11637,17 +11679,17 @@ function isPidRunning(pid) {
11637
11679
  }
11638
11680
  function createDefaultFs() {
11639
11681
  return {
11640
- open: (path49, flags) => fsPromises2.open(path49, flags),
11641
- readFile: (path49, encoding) => fsPromises2.readFile(path49, encoding),
11682
+ open: (path54, flags) => fsPromises2.open(path54, flags),
11683
+ readFile: (path54, encoding) => fsPromises2.readFile(path54, encoding),
11642
11684
  stat: fsPromises2.stat,
11643
11685
  unlink: fsPromises2.unlink
11644
11686
  };
11645
11687
  }
11646
- async function removeLockFile(fs6, lockPath, signal) {
11688
+ async function removeLockFile(fs7, lockPath, signal) {
11647
11689
  for (let attempt = 0; attempt <= 4; attempt += 1) {
11648
11690
  throwIfAborted(signal);
11649
11691
  try {
11650
- await fs6.unlink(lockPath);
11692
+ await fs7.unlink(lockPath);
11651
11693
  return;
11652
11694
  } catch (error2) {
11653
11695
  if (hasErrorCode(error2, "ENOENT")) {
@@ -11678,12 +11720,12 @@ function parseLockMetadata(content) {
11678
11720
  }
11679
11721
  return void 0;
11680
11722
  }
11681
- async function readLockMetadata(fs6, lockPath) {
11682
- if (!fs6.readFile) {
11723
+ async function readLockMetadata(fs7, lockPath) {
11724
+ if (!fs7.readFile) {
11683
11725
  return void 0;
11684
11726
  }
11685
11727
  try {
11686
- return parseLockMetadata(await fs6.readFile(lockPath, "utf8"));
11728
+ return parseLockMetadata(await fs7.readFile(lockPath, "utf8"));
11687
11729
  } catch (error2) {
11688
11730
  if (hasErrorCode(error2, "ENOENT")) {
11689
11731
  return null;
@@ -11717,7 +11759,7 @@ async function writeLockMetadata(handle) {
11717
11759
  }
11718
11760
  }
11719
11761
  async function acquireFileLock(filePath, options = {}) {
11720
- const fs6 = options.fs ?? createDefaultFs();
11762
+ const fs7 = options.fs ?? createDefaultFs();
11721
11763
  const retries = options.retries ?? 20;
11722
11764
  const minTimeout = options.minTimeout ?? 25;
11723
11765
  const maxTimeout = options.maxTimeout ?? 250;
@@ -11728,7 +11770,7 @@ async function acquireFileLock(filePath, options = {}) {
11728
11770
  while (attempt <= retries) {
11729
11771
  throwIfAborted(options.signal);
11730
11772
  try {
11731
- const handle = await fs6.open(lockPath, "wx");
11773
+ const handle = await fs7.open(lockPath, "wx");
11732
11774
  await writeLockMetadata(handle);
11733
11775
  let released = false;
11734
11776
  return async () => {
@@ -11736,7 +11778,7 @@ async function acquireFileLock(filePath, options = {}) {
11736
11778
  return;
11737
11779
  }
11738
11780
  released = true;
11739
- await removeLockFile(fs6, lockPath, options.signal);
11781
+ await removeLockFile(fs7, lockPath, options.signal);
11740
11782
  };
11741
11783
  } catch (error2) {
11742
11784
  if (!hasErrorCode(error2, "EEXIST")) {
@@ -11745,7 +11787,7 @@ async function acquireFileLock(filePath, options = {}) {
11745
11787
  }
11746
11788
  let stat7;
11747
11789
  try {
11748
- stat7 = await fs6.stat(lockPath);
11790
+ stat7 = await fs7.stat(lockPath);
11749
11791
  } catch (statError) {
11750
11792
  if (hasErrorCode(statError, "ENOENT")) {
11751
11793
  continue;
@@ -11753,7 +11795,7 @@ async function acquireFileLock(filePath, options = {}) {
11753
11795
  throw statError;
11754
11796
  }
11755
11797
  const reclaimLock = await shouldReclaimLock({
11756
- fs: fs6,
11798
+ fs: fs7,
11757
11799
  isPidRunning: pidIsRunning,
11758
11800
  lockPath,
11759
11801
  staleMs,
@@ -11763,7 +11805,7 @@ async function acquireFileLock(filePath, options = {}) {
11763
11805
  continue;
11764
11806
  }
11765
11807
  if (reclaimLock) {
11766
- await removeLockFile(fs6, lockPath, options.signal);
11808
+ await removeLockFile(fs7, lockPath, options.signal);
11767
11809
  continue;
11768
11810
  }
11769
11811
  if (attempt >= retries) {
@@ -11810,7 +11852,7 @@ var init_fs = __esm({
11810
11852
 
11811
11853
  // packages/poe-code-config/src/state/jobs.ts
11812
11854
  import path9 from "node:path";
11813
- function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11855
+ function createJobRegistry(homeDir, fs7 = defaultStateFs) {
11814
11856
  const jobsDir = path9.join(homeDir, ".poe-code", "state", "jobs");
11815
11857
  function jobPath(id) {
11816
11858
  assertSafeJobId(id);
@@ -11818,7 +11860,7 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11818
11860
  }
11819
11861
  async function get(id) {
11820
11862
  try {
11821
- return parseJobEntry(await fs6.readFile(jobPath(id), "utf8"));
11863
+ return parseJobEntry(await fs7.readFile(jobPath(id), "utf8"));
11822
11864
  } catch (error2) {
11823
11865
  if (isNotFoundError(error2)) {
11824
11866
  return null;
@@ -11829,8 +11871,8 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11829
11871
  async function put(entry) {
11830
11872
  assertJobEntry(entry);
11831
11873
  const filePath = jobPath(entry.id);
11832
- await fs6.mkdir(jobsDir, { recursive: true });
11833
- const release = await acquireFileLock(filePath, { fs: fs6 });
11874
+ await fs7.mkdir(jobsDir, { recursive: true });
11875
+ const release = await acquireFileLock(filePath, { fs: fs7 });
11834
11876
  try {
11835
11877
  await writeJobAtomically(filePath, entry);
11836
11878
  } finally {
@@ -11839,8 +11881,8 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11839
11881
  }
11840
11882
  async function update(id, patch) {
11841
11883
  const filePath = jobPath(id);
11842
- await fs6.mkdir(jobsDir, { recursive: true });
11843
- const release = await acquireFileLock(filePath, { fs: fs6 });
11884
+ await fs7.mkdir(jobsDir, { recursive: true });
11885
+ const release = await acquireFileLock(filePath, { fs: fs7 });
11844
11886
  try {
11845
11887
  const current = await get(id);
11846
11888
  if (current === null) {
@@ -11861,7 +11903,7 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11861
11903
  async function list(filter = {}) {
11862
11904
  let entries;
11863
11905
  try {
11864
- entries = await fs6.readdir(jobsDir);
11906
+ entries = await fs7.readdir(jobsDir);
11865
11907
  } catch (error2) {
11866
11908
  if (isNotFoundError(error2)) {
11867
11909
  return [];
@@ -11874,11 +11916,11 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11874
11916
  continue;
11875
11917
  }
11876
11918
  const filePath = path9.join(jobsDir, entry);
11877
- const stat7 = await fs6.stat(filePath);
11919
+ const stat7 = await fs7.stat(filePath);
11878
11920
  if (!stat7.isFile()) {
11879
11921
  continue;
11880
11922
  }
11881
- const job = parseJobEntry(await fs6.readFile(filePath, "utf8"));
11923
+ const job = parseJobEntry(await fs7.readFile(filePath, "utf8"));
11882
11924
  if (matchesFilter(job, filter)) {
11883
11925
  jobs.push(job);
11884
11926
  }
@@ -11888,16 +11930,16 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11888
11930
  async function remove2(id) {
11889
11931
  const filePath = jobPath(id);
11890
11932
  try {
11891
- await fs6.stat(jobsDir);
11933
+ await fs7.stat(jobsDir);
11892
11934
  } catch (error2) {
11893
11935
  if (isNotFoundError(error2)) {
11894
11936
  return;
11895
11937
  }
11896
11938
  throw error2;
11897
11939
  }
11898
- const release = await acquireFileLock(filePath, { fs: fs6 });
11940
+ const release = await acquireFileLock(filePath, { fs: fs7 });
11899
11941
  try {
11900
- await fs6.unlink(filePath);
11942
+ await fs7.unlink(filePath);
11901
11943
  } catch (error2) {
11902
11944
  if (!isNotFoundError(error2)) {
11903
11945
  throw error2;
@@ -11907,14 +11949,14 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11907
11949
  }
11908
11950
  }
11909
11951
  async function writeJobAtomically(filePath, entry) {
11910
- await fs6.mkdir(path9.dirname(filePath), { recursive: true });
11952
+ await fs7.mkdir(path9.dirname(filePath), { recursive: true });
11911
11953
  const tempPath = `${filePath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
11912
11954
  try {
11913
- await fs6.writeFile(tempPath, `${JSON.stringify(entry, null, 2)}
11955
+ await fs7.writeFile(tempPath, `${JSON.stringify(entry, null, 2)}
11914
11956
  `, {
11915
11957
  encoding: "utf8"
11916
11958
  });
11917
- await fs6.rename(tempPath, filePath);
11959
+ await fs7.rename(tempPath, filePath);
11918
11960
  } catch (error2) {
11919
11961
  await removeTempFile(tempPath);
11920
11962
  throw error2;
@@ -11922,7 +11964,7 @@ function createJobRegistry(homeDir, fs6 = defaultStateFs) {
11922
11964
  }
11923
11965
  async function removeTempFile(tempPath) {
11924
11966
  try {
11925
- await fs6.unlink(tempPath);
11967
+ await fs7.unlink(tempPath);
11926
11968
  } catch (error2) {
11927
11969
  if (!isNotFoundError(error2)) {
11928
11970
  throw error2;
@@ -11976,11 +12018,11 @@ var init_jobs2 = __esm({
11976
12018
 
11977
12019
  // packages/poe-code-config/src/state/templates.ts
11978
12020
  import path10 from "node:path";
11979
- function createTemplateRegistry(homeDir, fs6 = defaultStateFs) {
12021
+ function createTemplateRegistry(homeDir, fs7 = defaultStateFs) {
11980
12022
  const filePath = path10.join(homeDir, ".poe-code", "state", "templates.json");
11981
12023
  async function readState() {
11982
12024
  try {
11983
- const raw = await fs6.readFile(filePath, "utf8");
12025
+ const raw = await fs7.readFile(filePath, "utf8");
11984
12026
  return normalizeTemplateState(JSON.parse(raw));
11985
12027
  } catch (error2) {
11986
12028
  if (isNotFoundError(error2)) {
@@ -11990,14 +12032,14 @@ function createTemplateRegistry(homeDir, fs6 = defaultStateFs) {
11990
12032
  }
11991
12033
  }
11992
12034
  async function writeState(state) {
11993
- await fs6.writeFile(filePath, `${JSON.stringify(state, null, 2)}
12035
+ await fs7.writeFile(filePath, `${JSON.stringify(state, null, 2)}
11994
12036
  `, {
11995
12037
  encoding: "utf8"
11996
12038
  });
11997
12039
  }
11998
12040
  async function updateState(mutator) {
11999
- await fs6.mkdir(path10.dirname(filePath), { recursive: true });
12000
- const release = await acquireFileLock(filePath, { fs: fs6 });
12041
+ await fs7.mkdir(path10.dirname(filePath), { recursive: true });
12042
+ const release = await acquireFileLock(filePath, { fs: fs7 });
12001
12043
  try {
12002
12044
  const state = await readState();
12003
12045
  mutator(state);
@@ -12075,10 +12117,10 @@ var init_templates = __esm({
12075
12117
 
12076
12118
  // packages/poe-code-config/src/state/index.ts
12077
12119
  import os2 from "node:os";
12078
- function createStateManager(homeDir, fs6) {
12120
+ function createStateManager(homeDir, fs7) {
12079
12121
  return {
12080
- templates: createTemplateRegistry(homeDir, fs6),
12081
- jobs: createJobRegistry(homeDir, fs6)
12122
+ templates: createTemplateRegistry(homeDir, fs7),
12123
+ jobs: createJobRegistry(homeDir, fs7)
12082
12124
  };
12083
12125
  }
12084
12126
  var init_state2 = __esm({
@@ -13760,9 +13802,9 @@ import fsPromises3 from "node:fs/promises";
13760
13802
  import path12 from "node:path";
13761
13803
  import { promisify } from "node:util";
13762
13804
  import fastGlob from "fast-glob";
13763
- async function fileExists(fs6, filePath) {
13805
+ async function fileExists(fs7, filePath) {
13764
13806
  try {
13765
- await fs6.stat(filePath);
13807
+ await fs7.stat(filePath);
13766
13808
  return true;
13767
13809
  } catch {
13768
13810
  return false;
@@ -13800,11 +13842,11 @@ function getOptionalGrepOutputMode(args, key2) {
13800
13842
  function formatDisplayPath(cwd, filePath) {
13801
13843
  return path12.relative(cwd, filePath) || path12.basename(filePath);
13802
13844
  }
13803
- async function sortPathsByModifiedTime(matches, fs6) {
13845
+ async function sortPathsByModifiedTime(matches, fs7) {
13804
13846
  const entries = await Promise.all(
13805
13847
  matches.map(async (match) => ({
13806
13848
  path: match,
13807
- mtimeMs: (await fs6.stat(match)).mtimeMs
13849
+ mtimeMs: (await fs7.stat(match)).mtimeMs
13808
13850
  }))
13809
13851
  );
13810
13852
  entries.sort((left, right) => {
@@ -13815,8 +13857,8 @@ async function sortPathsByModifiedTime(matches, fs6) {
13815
13857
  });
13816
13858
  return entries.map((entry) => entry.path);
13817
13859
  }
13818
- async function defaultSearchContent(options, fs6) {
13819
- const targetStat = await fs6.stat(options.path);
13860
+ async function defaultSearchContent(options, fs7) {
13861
+ const targetStat = await fs7.stat(options.path);
13820
13862
  const searchCwd = targetStat.isDirectory() ? options.path : path12.dirname(options.path);
13821
13863
  const searchTarget = targetStat.isDirectory() ? "." : path12.basename(options.path);
13822
13864
  const args = ["--color", "never"];
@@ -13947,8 +13989,8 @@ var init_poe_agent_plugin_files = __esm({
13947
13989
  const allowedPaths = (options.allowedPaths ?? [cwd]).map(
13948
13990
  (allowedPath) => path12.resolve(cwd, allowedPath)
13949
13991
  );
13950
- const fs6 = options.fs ?? fsPromises3;
13951
- const searchContent = options.searchContent ?? ((searchOptions) => defaultSearchContent(searchOptions, fs6));
13992
+ const fs7 = options.fs ?? fsPromises3;
13993
+ const searchContent = options.searchContent ?? ((searchOptions) => defaultSearchContent(searchOptions, fs7));
13952
13994
  const globFiles = options.globFiles ?? defaultGlobFiles;
13953
13995
  const readFileTool = {
13954
13996
  name: "read_file",
@@ -13981,14 +14023,14 @@ var init_poe_agent_plugin_files = __esm({
13981
14023
  const filePath = resolveAllowedPath(cwd, allowedPaths, getRequiredString(args, "path"));
13982
14024
  const imageMimeType = detectImageMimeType(filePath);
13983
14025
  if (imageMimeType !== void 0) {
13984
- const content2 = await fs6.readFile(filePath);
14026
+ const content2 = await fs7.readFile(filePath);
13985
14027
  return {
13986
14028
  type: "image",
13987
14029
  mimeType: imageMimeType,
13988
14030
  data: Buffer.from(content2).toString("base64")
13989
14031
  };
13990
14032
  }
13991
- const content = await fs6.readFile(filePath, "utf8");
14033
+ const content = await fs7.readFile(filePath, "utf8");
13992
14034
  return sliceLines(
13993
14035
  content,
13994
14036
  getOptionalNonNegativeInteger(args, "offset") ?? 0,
@@ -14042,7 +14084,7 @@ var init_poe_agent_plugin_files = __esm({
14042
14084
  const oldStr = getRequiredString(args, "old_str", true);
14043
14085
  const newStr = getRequiredString(args, "new_str", true);
14044
14086
  const replaceAll2 = getOptionalBoolean(args, "replace_all") ?? false;
14045
- const content = await fs6.readFile(filePath, "utf8");
14087
+ const content = await fs7.readFile(filePath, "utf8");
14046
14088
  if (oldStr.length === 0) {
14047
14089
  throw new Error('Tool argument "old_str" must not be empty');
14048
14090
  }
@@ -14053,7 +14095,7 @@ var init_poe_agent_plugin_files = __esm({
14053
14095
  if (!replaceAll2 && count > 1) {
14054
14096
  throw new Error(`old_str appears ${count} times \u2014 must be unique`);
14055
14097
  }
14056
- await fs6.writeFile(
14098
+ await fs7.writeFile(
14057
14099
  filePath,
14058
14100
  replaceAll2 ? content.split(oldStr).join(newStr) : content.replace(oldStr, newStr),
14059
14101
  "utf8"
@@ -14062,17 +14104,17 @@ var init_poe_agent_plugin_files = __esm({
14062
14104
  }
14063
14105
  if (command === "create") {
14064
14106
  const fileText = getRequiredString(args, "file_text", true);
14065
- if (await fileExists(fs6, filePath)) {
14107
+ if (await fileExists(fs7, filePath)) {
14066
14108
  throw new Error("File already exists \u2014 use str_replace to edit");
14067
14109
  }
14068
- await fs6.mkdir(path12.dirname(filePath), { recursive: true });
14069
- await fs6.writeFile(filePath, fileText, "utf8");
14110
+ await fs7.mkdir(path12.dirname(filePath), { recursive: true });
14111
+ await fs7.writeFile(filePath, fileText, "utf8");
14070
14112
  return `Created file: ${displayedPath}`;
14071
14113
  }
14072
14114
  if (command === "overwrite") {
14073
14115
  const fileText = getRequiredString(args, "file_text", true);
14074
- await fs6.mkdir(path12.dirname(filePath), { recursive: true });
14075
- await fs6.writeFile(filePath, fileText, "utf8");
14116
+ await fs7.mkdir(path12.dirname(filePath), { recursive: true });
14117
+ await fs7.writeFile(filePath, fileText, "utf8");
14076
14118
  return `Overwrote file: ${displayedPath}`;
14077
14119
  }
14078
14120
  throw new Error(`Unknown edit_file command: ${command}`);
@@ -14097,7 +14139,7 @@ var init_poe_agent_plugin_files = __esm({
14097
14139
  async call(args) {
14098
14140
  const rawPath = getOptionalString(args, "path") ?? ".";
14099
14141
  const directoryPath = resolveAllowedPath(cwd, allowedPaths, rawPath);
14100
- const entries = await fs6.readdir(directoryPath);
14142
+ const entries = await fs7.readdir(directoryPath);
14101
14143
  const names = entries.sort((left, right) => left.localeCompare(right));
14102
14144
  if (names.length === 0) {
14103
14145
  return "(empty directory)";
@@ -14193,7 +14235,7 @@ var init_poe_agent_plugin_files = __esm({
14193
14235
  });
14194
14236
  const sortedMatches = await sortPathsByModifiedTime(
14195
14237
  matches.map((match) => resolveAllowedPath(cwd, allowedPaths, match)),
14196
- fs6
14238
+ fs7
14197
14239
  );
14198
14240
  if (sortedMatches.length === 0) {
14199
14241
  return "(no matches)";
@@ -16745,11 +16787,11 @@ async function loadMemory(options) {
16745
16787
  }
16746
16788
  return sections.join("\n\n");
16747
16789
  }
16748
- async function findNearestAgentsFile(cwd, fs6) {
16790
+ async function findNearestAgentsFile(cwd, fs7) {
16749
16791
  let currentDirectory = cwd;
16750
16792
  while (true) {
16751
16793
  const filePath = path15.join(currentDirectory, AGENTS_FILE);
16752
- if (await readOptionalFile(filePath, fs6) !== void 0) {
16794
+ if (await readOptionalFile(filePath, fs7) !== void 0) {
16753
16795
  return filePath;
16754
16796
  }
16755
16797
  const parentDirectory = path15.dirname(currentDirectory);
@@ -16759,15 +16801,15 @@ async function findNearestAgentsFile(cwd, fs6) {
16759
16801
  currentDirectory = parentDirectory;
16760
16802
  }
16761
16803
  }
16762
- async function loadOptionalMemoryFile(filePath, fs6) {
16763
- const content = await readOptionalFile(filePath, fs6);
16804
+ async function loadOptionalMemoryFile(filePath, fs7) {
16805
+ const content = await readOptionalFile(filePath, fs7);
16764
16806
  if (content === void 0) {
16765
16807
  return void 0;
16766
16808
  }
16767
16809
  return await expandImports({
16768
16810
  filePath,
16769
16811
  content,
16770
- fs: fs6,
16812
+ fs: fs7,
16771
16813
  loading: /* @__PURE__ */ new Set()
16772
16814
  });
16773
16815
  }
@@ -16818,9 +16860,9 @@ ${content}`;
16818
16860
  function normalizeLineEndings(content) {
16819
16861
  return content.split("\r\n").join("\n");
16820
16862
  }
16821
- async function readOptionalFile(filePath, fs6) {
16863
+ async function readOptionalFile(filePath, fs7) {
16822
16864
  try {
16823
- return await fs6.readFile(filePath, "utf8");
16865
+ return await fs7.readFile(filePath, "utf8");
16824
16866
  } catch (error2) {
16825
16867
  if (isMissingFileError(error2)) {
16826
16868
  return void 0;
@@ -16828,8 +16870,8 @@ async function readOptionalFile(filePath, fs6) {
16828
16870
  throw error2;
16829
16871
  }
16830
16872
  }
16831
- async function readRequiredFile(filePath, fs6) {
16832
- const content = await readOptionalFile(filePath, fs6);
16873
+ async function readRequiredFile(filePath, fs7) {
16874
+ const content = await readOptionalFile(filePath, fs7);
16833
16875
  if (content !== void 0) {
16834
16876
  return content;
16835
16877
  }
@@ -16851,12 +16893,12 @@ var init_poe_agent_plugin_memory = __esm({
16851
16893
  memoryPlugin = (options = {}) => {
16852
16894
  const cwd = path15.resolve(options.cwd ?? process.cwd());
16853
16895
  const homeDir = path15.resolve(options.homeDir ?? os3.homedir());
16854
- const fs6 = options.fs ?? fsPromises4;
16896
+ const fs7 = options.fs ?? fsPromises4;
16855
16897
  let memoryPromise;
16856
16898
  return {
16857
16899
  name: "poe-agent-plugin-memory",
16858
16900
  async prompt(ctx) {
16859
- memoryPromise ??= loadMemory({ cwd, homeDir, fs: fs6 });
16901
+ memoryPromise ??= loadMemory({ cwd, homeDir, fs: fs7 });
16860
16902
  const memory = await memoryPromise;
16861
16903
  if (!memory) {
16862
16904
  return ctx;
@@ -20953,9 +20995,9 @@ function validateTaskId(id) {
20953
20995
  }
20954
20996
  return id;
20955
20997
  }
20956
- async function statIfExists(fs6, filePath) {
20998
+ async function statIfExists(fs7, filePath) {
20957
20999
  try {
20958
- return await fs6.stat(filePath);
21000
+ return await fs7.stat(filePath);
20959
21001
  } catch (error2) {
20960
21002
  if (hasErrorCode2(error2, "ENOENT")) {
20961
21003
  return void 0;
@@ -20963,16 +21005,16 @@ async function statIfExists(fs6, filePath) {
20963
21005
  throw error2;
20964
21006
  }
20965
21007
  }
20966
- async function writeAtomically(fs6, filePath, content) {
21008
+ async function writeAtomically(fs7, filePath, content) {
20967
21009
  const tempPath = `${filePath}.tmp-${process.pid}-${tmpFileCounter}`;
20968
21010
  tmpFileCounter += 1;
20969
- await fs6.mkdir(path21.dirname(filePath), { recursive: true });
21011
+ await fs7.mkdir(path21.dirname(filePath), { recursive: true });
20970
21012
  try {
20971
- await fs6.writeFile(tempPath, content, { encoding: "utf8", flag: "wx" });
20972
- await fs6.rename(tempPath, filePath);
21013
+ await fs7.writeFile(tempPath, content, { encoding: "utf8", flag: "wx" });
21014
+ await fs7.rename(tempPath, filePath);
20973
21015
  } catch (error2) {
20974
21016
  try {
20975
- await fs6.unlink(tempPath);
21017
+ await fs7.unlink(tempPath);
20976
21018
  } catch (unlinkError) {
20977
21019
  if (!hasErrorCode2(unlinkError, "ENOENT")) {
20978
21020
  throw unlinkError;
@@ -21909,9 +21951,9 @@ ${stringify(frontmatter)}---
21909
21951
 
21910
21952
  ${description}`;
21911
21953
  }
21912
- async function readDirectoryNames(fs6, directoryPath) {
21954
+ async function readDirectoryNames(fs7, directoryPath) {
21913
21955
  try {
21914
- return sortStrings(await fs6.readdir(directoryPath));
21956
+ return sortStrings(await fs7.readdir(directoryPath));
21915
21957
  } catch (error2) {
21916
21958
  if (hasErrorCode2(error2, "ENOENT")) {
21917
21959
  return [];
@@ -21926,8 +21968,8 @@ async function ensureRootPath(deps) {
21926
21968
  }
21927
21969
  await deps.fs.stat(deps.path);
21928
21970
  }
21929
- async function readTaskFile(fs6, list, id, filePath, validStates, initialState, mode) {
21930
- const content = await fs6.readFile(filePath, "utf8");
21971
+ async function readTaskFile(fs7, list, id, filePath, validStates, initialState, mode) {
21972
+ const content = await fs7.readFile(filePath, "utf8");
21931
21973
  const document = splitTaskDocument(content, filePath, mode);
21932
21974
  const frontmatter = mode === "passthrough" && document.frontmatter.trim().length === 0 ? {} : readFrontmatter(document.frontmatter, filePath);
21933
21975
  if (mode !== "passthrough") {
@@ -21951,8 +21993,8 @@ async function readTaskFile(fs6, list, id, filePath, validStates, initialState,
21951
21993
  task: createTask(list, id, effectiveFrontmatter, document.body, mode, filePath)
21952
21994
  };
21953
21995
  }
21954
- async function findActiveTaskFilename(fs6, listDirectoryPath, id) {
21955
- const entries = await readDirectoryNames(fs6, listDirectoryPath);
21996
+ async function findActiveTaskFilename(fs7, listDirectoryPath, id) {
21997
+ const entries = await readDirectoryNames(fs7, listDirectoryPath);
21956
21998
  for (const entryName of entries) {
21957
21999
  if (isHiddenEntry(entryName) || isLockFile(entryName)) continue;
21958
22000
  const parsed = parseActiveFilename(entryName);
@@ -21962,29 +22004,29 @@ async function findActiveTaskFilename(fs6, listDirectoryPath, id) {
21962
22004
  }
21963
22005
  return void 0;
21964
22006
  }
21965
- async function findTaskLocation(fs6, rootPath, layout, list, id) {
22007
+ async function findTaskLocation(fs7, rootPath, layout, list, id) {
21966
22008
  const listDirectoryPath = listPath(rootPath, layout, list);
21967
- const activeName = await findActiveTaskFilename(fs6, listDirectoryPath, id);
22009
+ const activeName = await findActiveTaskFilename(fs7, listDirectoryPath, id);
21968
22010
  if (activeName) {
21969
22011
  const activePath = path22.join(listDirectoryPath, activeName);
21970
- const activeStat = await statIfExists(fs6, activePath);
22012
+ const activeStat = await statIfExists(fs7, activePath);
21971
22013
  if (activeStat?.isFile()) {
21972
22014
  return { archived: false, path: activePath };
21973
22015
  }
21974
22016
  }
21975
22017
  const archivedPath = archivedTaskPath(rootPath, layout, list, id);
21976
- const archivedStat = await statIfExists(fs6, archivedPath);
22018
+ const archivedStat = await statIfExists(fs7, archivedPath);
21977
22019
  if (archivedStat?.isFile()) {
21978
22020
  return { archived: true, path: archivedPath };
21979
22021
  }
21980
22022
  return void 0;
21981
22023
  }
21982
- async function readTaskAtLocation(fs6, rootPath, layout, list, id, validStates, initialState, mode) {
21983
- const location = await findTaskLocation(fs6, rootPath, layout, list, id);
22024
+ async function readTaskAtLocation(fs7, rootPath, layout, list, id, validStates, initialState, mode) {
22025
+ const location = await findTaskLocation(fs7, rootPath, layout, list, id);
21984
22026
  if (!location) {
21985
22027
  throw new TaskNotFoundError(`Task "${list}/${id}" not found.`);
21986
22028
  }
21987
- return readTaskFile(fs6, list, id, location.path, validStates, initialState, mode);
22029
+ return readTaskFile(fs7, list, id, location.path, validStates, initialState, mode);
21988
22030
  }
21989
22031
  function createdFrontmatter(defaults, input, initialState, mode) {
21990
22032
  const frontmatter = mode !== "passthrough" ? {
@@ -22910,8 +22952,8 @@ function serializeDocument(document) {
22910
22952
  return serialized.endsWith("\n") ? serialized : `${serialized}
22911
22953
  `;
22912
22954
  }
22913
- async function readStore(fs6, filePath, validStates) {
22914
- const content = await fs6.readFile(filePath, "utf8");
22955
+ async function readStore(fs7, filePath, validStates) {
22956
+ const content = await fs7.readFile(filePath, "utf8");
22915
22957
  const document = parseStoreDocument(filePath, content);
22916
22958
  const store = document.toJS();
22917
22959
  assertValidStoreRecord(store, filePath);
@@ -23404,9 +23446,9 @@ function defaultFs() {
23404
23446
  function hasErrorCode3(error2, code) {
23405
23447
  return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
23406
23448
  }
23407
- async function directoryExists(fs6, directoryPath) {
23449
+ async function directoryExists(fs7, directoryPath) {
23408
23450
  try {
23409
- return (await fs6.stat(directoryPath)).isDirectory();
23451
+ return (await fs7.stat(directoryPath)).isDirectory();
23410
23452
  } catch (error2) {
23411
23453
  if (hasErrorCode3(error2, "ENOENT") || hasErrorCode3(error2, "ENOTDIR")) {
23412
23454
  return false;
@@ -23434,8 +23476,8 @@ function idFromPlanFileName(fileName) {
23434
23476
  }
23435
23477
  return stem;
23436
23478
  }
23437
- async function readPlanPaths(fs6, directoryPath) {
23438
- const fileNames = await fs6.readdir(directoryPath);
23479
+ async function readPlanPaths(fs7, directoryPath) {
23480
+ const fileNames = await fs7.readdir(directoryPath);
23439
23481
  const pathsById = /* @__PURE__ */ new Map();
23440
23482
  for (const fileName of fileNames) {
23441
23483
  const id = idFromPlanFileName(fileName);
@@ -23443,7 +23485,7 @@ async function readPlanPaths(fs6, directoryPath) {
23443
23485
  continue;
23444
23486
  }
23445
23487
  const absolutePath = path24.join(directoryPath, fileName);
23446
- const stat7 = await fs6.stat(absolutePath);
23488
+ const stat7 = await fs7.stat(absolutePath);
23447
23489
  if (stat7.isFile()) {
23448
23490
  pathsById.set(id, absolutePath);
23449
23491
  }
@@ -23472,13 +23514,13 @@ function planKind(metadata) {
23472
23514
  }
23473
23515
  async function discoverPlans(options) {
23474
23516
  const resolvedDirectory = resolvePlanDirectory(options);
23475
- const fs6 = options.fs ?? defaultFs();
23476
- if (!await directoryExists(fs6, resolvedDirectory)) {
23517
+ const fs7 = options.fs ?? defaultFs();
23518
+ if (!await directoryExists(fs7, resolvedDirectory)) {
23477
23519
  return [];
23478
23520
  }
23479
23521
  const [taskList, pathsById] = await Promise.all([
23480
23522
  openPlanList(options),
23481
- readPlanPaths(fs6, resolvedDirectory)
23523
+ readPlanPaths(fs7, resolvedDirectory)
23482
23524
  ]);
23483
23525
  const kindFilter = options.kinds === void 0 ? void 0 : new Set(options.kinds);
23484
23526
  const tasks = await taskList.list(PLAN_LIST_NAME).all();
@@ -23695,29 +23737,29 @@ function wrapForLogTee(argv, jobId) {
23695
23737
  return ["sh", "-c", script];
23696
23738
  }
23697
23739
  async function* streamLogFile(env, jobId, opts) {
23698
- const fs6 = env.fs ?? nodeFs2;
23740
+ const fs7 = env.fs ?? nodeFs2;
23699
23741
  const file = jobLogPath(jobId);
23700
23742
  let byteOffset = opts.sinceByte ?? 0;
23701
23743
  while (true) {
23702
- if (opts.since !== void 0 && !await wasModifiedSince(fs6, file, opts.since)) {
23703
- await waitForLogChange(fs6, file);
23744
+ if (opts.since !== void 0 && !await wasModifiedSince(fs7, file, opts.since)) {
23745
+ await waitForLogChange(fs7, file);
23704
23746
  continue;
23705
23747
  }
23706
- const result = await readLogChunk(fs6, file, byteOffset);
23748
+ const result = await readLogChunk(fs7, file, byteOffset);
23707
23749
  if (result !== null) {
23708
23750
  byteOffset = result.nextByteOffset;
23709
23751
  yield result.chunk;
23710
23752
  continue;
23711
23753
  }
23712
- await waitForLogChange(fs6, file);
23754
+ await waitForLogChange(fs7, file);
23713
23755
  }
23714
23756
  }
23715
- async function wasModifiedSince(fs6, file, since) {
23716
- if (fs6.promises.stat === void 0) {
23757
+ async function wasModifiedSince(fs7, file, since) {
23758
+ if (fs7.promises.stat === void 0) {
23717
23759
  return true;
23718
23760
  }
23719
23761
  try {
23720
- const stat7 = await fs6.promises.stat(file);
23762
+ const stat7 = await fs7.promises.stat(file);
23721
23763
  return stat7.mtimeMs >= since.getTime();
23722
23764
  } catch (error2) {
23723
23765
  if (isNodeError(error2) && error2.code === "ENOENT") {
@@ -23727,11 +23769,11 @@ async function wasModifiedSince(fs6, file, since) {
23727
23769
  }
23728
23770
  }
23729
23771
  async function waitForExit(env, jobId, opts = {}) {
23730
- const fs6 = env.fs ?? nodeFs2;
23772
+ const fs7 = env.fs ?? nodeFs2;
23731
23773
  const file = jobExitPath(jobId);
23732
23774
  while (true) {
23733
23775
  throwIfAborted2(opts.signal);
23734
- const contents = await readTextFileIfExists(fs6, file);
23776
+ const contents = await readTextFileIfExists(fs7, file);
23735
23777
  if (contents !== null) {
23736
23778
  const text5 = contents.trim();
23737
23779
  const exitCode = Number(text5);
@@ -23749,8 +23791,8 @@ function jobLogPath(jobId) {
23749
23791
  function jobExitPath(jobId) {
23750
23792
  return `${JOB_DIR}/${jobId}.exit`;
23751
23793
  }
23752
- async function readLogChunk(fs6, file, byteOffset) {
23753
- const contents = await readFileIfExists2(fs6, file);
23794
+ async function readLogChunk(fs7, file, byteOffset) {
23795
+ const contents = await readFileIfExists2(fs7, file);
23754
23796
  if (contents === null || byteOffset >= contents.byteLength) {
23755
23797
  return null;
23756
23798
  }
@@ -23762,13 +23804,13 @@ async function readLogChunk(fs6, file, byteOffset) {
23762
23804
  nextByteOffset: contents.byteLength
23763
23805
  };
23764
23806
  }
23765
- async function readTextFileIfExists(fs6, file) {
23766
- const contents = await readFileIfExists2(fs6, file);
23807
+ async function readTextFileIfExists(fs7, file) {
23808
+ const contents = await readFileIfExists2(fs7, file);
23767
23809
  return contents?.toString("utf8") ?? null;
23768
23810
  }
23769
- async function readFileIfExists2(fs6, file) {
23811
+ async function readFileIfExists2(fs7, file) {
23770
23812
  try {
23771
- const contents = await fs6.promises.readFile(file);
23813
+ const contents = await fs7.promises.readFile(file);
23772
23814
  return Buffer.isBuffer(contents) ? contents : Buffer.from(contents);
23773
23815
  } catch (error2) {
23774
23816
  if (isNodeError(error2) && error2.code === "ENOENT") {
@@ -23777,8 +23819,8 @@ async function readFileIfExists2(fs6, file) {
23777
23819
  throw error2;
23778
23820
  }
23779
23821
  }
23780
- async function waitForLogChange(fs6, file) {
23781
- const watch = fs6.watch;
23822
+ async function waitForLogChange(fs7, file) {
23823
+ const watch = fs7.watch;
23782
23824
  if (typeof watch !== "function") {
23783
23825
  await sleep2(POLL_INTERVAL_MS);
23784
23826
  return;
@@ -24644,7 +24686,7 @@ var init_template_build = __esm({
24644
24686
  // packages/runner-e2b/src/job-handle.ts
24645
24687
  import path28 from "node:path";
24646
24688
  function createE2bJobHandle(input) {
24647
- const fs6 = createE2bLogStreamFs(input.sandbox);
24689
+ const fs7 = createE2bLogStreamFs(input.sandbox);
24648
24690
  return {
24649
24691
  id: input.jobId,
24650
24692
  envId: input.envId,
@@ -24660,10 +24702,10 @@ function createE2bJobHandle(input) {
24660
24702
  return isRunning ? "running" : "lost";
24661
24703
  },
24662
24704
  stream(opts = {}) {
24663
- return streamLogFile({ fs: fs6 }, input.jobId, opts);
24705
+ return streamLogFile({ fs: fs7 }, input.jobId, opts);
24664
24706
  },
24665
24707
  async wait() {
24666
- const result = await waitForExit({ fs: fs6 }, input.jobId);
24708
+ const result = await waitForExit({ fs: fs7 }, input.jobId);
24667
24709
  const preserveMs = input.preserveAfterExitHours * 60 * 60 * 1e3;
24668
24710
  if (preserveMs > 0) {
24669
24711
  await input.sandbox.setTimeout(preserveMs);
@@ -25174,10 +25216,10 @@ import os5 from "node:os";
25174
25216
  import { promises as nodeFs4 } from "node:fs";
25175
25217
  async function resolveE2bApiKey(input) {
25176
25218
  const homeDir = input.homeDir ?? os5.homedir();
25177
- const fs6 = input.fs ?? nodeFs4;
25219
+ const fs7 = input.fs ?? nodeFs4;
25178
25220
  const env = input.env ?? process.env;
25179
25221
  const document = await readMergedDocument(
25180
- fs6,
25222
+ fs7,
25181
25223
  resolveConfigPath(homeDir),
25182
25224
  resolveProjectConfigPath(input.cwd)
25183
25225
  );
@@ -25828,6 +25870,29 @@ var init_goose2 = __esm({
25828
25870
  }
25829
25871
  });
25830
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
+
25831
25896
  // packages/agent-spawn/src/configs/index.ts
25832
25897
  function getSpawnConfig(input) {
25833
25898
  const resolvedId = resolveAgentId(input);
@@ -25856,6 +25921,7 @@ var init_configs = __esm({
25856
25921
  init_opencode2();
25857
25922
  init_kimi2();
25858
25923
  init_goose2();
25924
+ init_gemini_cli2();
25859
25925
  allSpawnConfigs = [
25860
25926
  claudeCodeSpawnConfig,
25861
25927
  codexSpawnConfig,
@@ -25871,6 +25937,7 @@ var init_configs = __esm({
25871
25937
  acpLookup.set(openCodeAcpSpawnConfig.agentId, openCodeAcpSpawnConfig);
25872
25938
  acpLookup.set(kimiAcpSpawnConfig.agentId, kimiAcpSpawnConfig);
25873
25939
  acpLookup.set(gooseAcpSpawnConfig.agentId, gooseAcpSpawnConfig);
25940
+ acpLookup.set(geminiCliAcpSpawnConfig.agentId, geminiCliAcpSpawnConfig);
25874
25941
  }
25875
25942
  });
25876
25943
 
@@ -26373,6 +26440,10 @@ var init_configs2 = __esm({
26373
26440
  globalSkillDir: "~/.codex/skills",
26374
26441
  localSkillDir: ".codex/skills"
26375
26442
  },
26443
+ "gemini-cli": {
26444
+ globalSkillDir: "~/.gemini/skills",
26445
+ localSkillDir: ".gemini/skills"
26446
+ },
26376
26447
  opencode: {
26377
26448
  globalSkillDir: "~/.config/opencode/skills",
26378
26449
  localSkillDir: ".opencode/skills"
@@ -26567,10 +26638,10 @@ function resolveExcludePath(cwd) {
26567
26638
  }
26568
26639
  return path34.join(path34.isAbsolute(gitDir) ? gitDir : path34.resolve(cwd, gitDir), "info/exclude");
26569
26640
  }
26570
- function markers(runId) {
26641
+ function markers(runId, markerPrefix) {
26571
26642
  return {
26572
- begin: `${markerPrefix}${runId} begin`,
26573
- end: `${markerPrefix}${runId} end`
26643
+ begin: `# ${markerPrefix}:${runId} begin`,
26644
+ end: `# ${markerPrefix}:${runId} end`
26574
26645
  };
26575
26646
  }
26576
26647
  function readExcludeFile(excludePath) {
@@ -26586,8 +26657,8 @@ function readExcludeFile(excludePath) {
26586
26657
  function isNodeError2(error2) {
26587
26658
  return error2 instanceof Error && "code" in error2;
26588
26659
  }
26589
- function removeBlock(content, runId) {
26590
- const { begin, end } = markers(runId);
26660
+ function removeBlock(content, runId, markerPrefix) {
26661
+ const { begin, end } = markers(runId, markerPrefix);
26591
26662
  const lines = content.split("\n");
26592
26663
  const result = [];
26593
26664
  for (let index = 0; index < lines.length; index += 1) {
@@ -26602,23 +26673,27 @@ function removeBlock(content, runId) {
26602
26673
  }
26603
26674
  return result.join("\n");
26604
26675
  }
26605
- function appendBlock(content, runId, entries) {
26606
- const { begin, end } = markers(runId);
26676
+ function appendBlock(content, runId, entries, markerPrefix) {
26677
+ const { begin, end } = markers(runId, markerPrefix);
26607
26678
  const existing = content ?? "";
26608
26679
  const prefix = existing.length === 0 || existing.endsWith("\n") ? existing : `${existing}
26609
26680
  `;
26610
26681
  return `${prefix}${[begin, ...entries, end, ""].join("\n")}`;
26611
26682
  }
26612
- function appendExcludeBlock(cwd, runId, entries) {
26683
+ function appendExcludeBlock(cwd, runId, entries, opts) {
26613
26684
  const excludePath = resolveExcludePath(cwd);
26614
26685
  if (excludePath === void 0) {
26615
26686
  return;
26616
26687
  }
26617
26688
  fs2.mkdirSync(path34.dirname(excludePath), { recursive: true });
26618
26689
  const content = readExcludeFile(excludePath);
26619
- fs2.writeFileSync(excludePath, appendBlock(content, runId, entries), "utf8");
26690
+ fs2.writeFileSync(
26691
+ excludePath,
26692
+ appendBlock(content, runId, entries, opts?.markerPrefix ?? defaultMarkerPrefix),
26693
+ "utf8"
26694
+ );
26620
26695
  }
26621
- function removeExcludeBlock(cwd, runId) {
26696
+ function removeExcludeBlock(cwd, runId, opts) {
26622
26697
  const excludePath = resolveExcludePath(cwd);
26623
26698
  if (excludePath === void 0) {
26624
26699
  return;
@@ -26627,13 +26702,17 @@ function removeExcludeBlock(cwd, runId) {
26627
26702
  if (content === void 0) {
26628
26703
  return;
26629
26704
  }
26630
- fs2.writeFileSync(excludePath, removeBlock(content, runId), "utf8");
26705
+ fs2.writeFileSync(
26706
+ excludePath,
26707
+ removeBlock(content, runId, opts?.markerPrefix ?? defaultMarkerPrefix),
26708
+ "utf8"
26709
+ );
26631
26710
  }
26632
- var markerPrefix, gitDirRunner;
26711
+ var defaultMarkerPrefix, gitDirRunner;
26633
26712
  var init_git_exclude = __esm({
26634
26713
  "packages/agent-skill-config/src/git-exclude.ts"() {
26635
26714
  "use strict";
26636
- markerPrefix = "# poe-code-spawn-skills:";
26715
+ defaultMarkerPrefix = "poe-code-spawn-skills";
26637
26716
  gitDirRunner = defaultGitDirRunner;
26638
26717
  }
26639
26718
  });
@@ -26861,29 +26940,748 @@ var init_src15 = __esm({
26861
26940
  }
26862
26941
  });
26863
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
+
26864
27636
  // packages/agent-spawn/src/skill-bridge.ts
26865
27637
  import crypto4 from "node:crypto";
26866
- import os7 from "node:os";
26867
- function bridgeSkillsForRun(agentId, cwd, skills2) {
26868
- 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) {
26869
27641
  return void 0;
26870
27642
  }
26871
- const manifest = bridgeActiveSkills(agentId, cwd, skills2, os7.homedir(), crypto4.randomUUID());
26872
- for (const warning2 of manifest.warnings) {
26873
- logger.warn(warning2.message);
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;
26874
27666
  }
26875
- return manifest;
27667
+ return manifests;
26876
27668
  }
26877
- function cleanupSkillsForRun(manifest) {
27669
+ function cleanupResourcesForRun(manifest) {
26878
27670
  if (!manifest) {
26879
27671
  return;
26880
27672
  }
26881
- cleanupBridgedSkills(manifest);
27673
+ if (manifest.hooks) {
27674
+ cleanupBridgedHooks(manifest.hooks);
27675
+ }
27676
+ if (manifest.skills) {
27677
+ cleanupBridgedSkills(manifest.skills);
27678
+ }
26882
27679
  }
26883
27680
  var init_skill_bridge = __esm({
26884
27681
  "packages/agent-spawn/src/skill-bridge.ts"() {
26885
27682
  "use strict";
26886
27683
  init_src15();
27684
+ init_src16();
26887
27685
  init_src2();
26888
27686
  }
26889
27687
  });
@@ -26996,21 +27794,21 @@ async function* adaptClaude(lines) {
26996
27794
  if (blockType !== "tool_result") continue;
26997
27795
  const kind = toolKindsById.get(item.tool_use_id);
26998
27796
  toolKindsById.delete(item.tool_use_id);
26999
- let path49;
27797
+ let path54;
27000
27798
  if (typeof item.content === "string") {
27001
- path49 = item.content;
27799
+ path54 = item.content;
27002
27800
  } else {
27003
27801
  try {
27004
- path49 = JSON.stringify(item.content);
27802
+ path54 = JSON.stringify(item.content);
27005
27803
  } catch {
27006
- path49 = String(item.content);
27804
+ path54 = String(item.content);
27007
27805
  }
27008
27806
  }
27009
27807
  yield {
27010
27808
  event: "tool_complete",
27011
27809
  id: item.tool_use_id,
27012
27810
  kind,
27013
- path: path49
27811
+ path: path54
27014
27812
  };
27015
27813
  }
27016
27814
  }
@@ -27133,10 +27931,10 @@ async function* adaptCodex(lines) {
27133
27931
  const kindFromStart = toolKindById.get(item.id);
27134
27932
  const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
27135
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;
27136
- const path49 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
27934
+ const path54 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
27137
27935
  toolTitleById.delete(item.id);
27138
27936
  toolKindById.delete(item.id);
27139
- yield { event: "tool_complete", id: item.id, kind, path: path49 };
27937
+ yield { event: "tool_complete", id: item.id, kind, path: path54 };
27140
27938
  }
27141
27939
  }
27142
27940
  }
@@ -27714,7 +28512,7 @@ function spawnStreaming(options) {
27714
28512
  };
27715
28513
  }
27716
28514
  };
27717
- const manifest = bridgeSkillsForRun(options.agentId, cwd, options.skills);
28515
+ const manifest = bridgeResourcesForRun(options.agentId, cwd, options.skills, options.hooks);
27718
28516
  void (async () => {
27719
28517
  try {
27720
28518
  for await (const output of adapter(queue.lines())) {
@@ -27765,7 +28563,7 @@ function spawnStreaming(options) {
27765
28563
  ...ctx.logFile && !result.logFile ? { logFile: ctx.logFile } : {}
27766
28564
  };
27767
28565
  } finally {
27768
- cleanupSkillsForRun(manifest);
28566
+ cleanupResourcesForRun(manifest);
27769
28567
  }
27770
28568
  })();
27771
28569
  return {
@@ -27802,8 +28600,8 @@ var init_spawn = __esm({
27802
28600
  });
27803
28601
 
27804
28602
  // packages/agent-spawn/src/spawn.ts
27805
- import { mkdirSync as mkdirSync3, openSync, writeSync, closeSync } from "node:fs";
27806
- import path36 from "node:path";
28603
+ import { mkdirSync as mkdirSync5, openSync as openSync2, writeSync, closeSync as closeSync2 } from "node:fs";
28604
+ import path41 from "node:path";
27807
28605
  function createAbortError6() {
27808
28606
  const error2 = new Error("Agent spawn aborted");
27809
28607
  error2.name = "AbortError";
@@ -27927,7 +28725,7 @@ async function runSpawn(agentId, options, context) {
27927
28725
  return { stdout: "", stderr: "", exitCode: 0 };
27928
28726
  }
27929
28727
  const cwd = options.cwd ?? process.cwd();
27930
- const manifest = bridgeSkillsForRun(agentId, cwd, options.skills);
28728
+ const manifest = bridgeResourcesForRun(agentId, cwd, options.skills, options.hooks);
27931
28729
  let logFd;
27932
28730
  try {
27933
28731
  const logFilePath = resolveSpawnLogPath(options);
@@ -27995,7 +28793,7 @@ async function runSpawn(agentId, options, context) {
27995
28793
  };
27996
28794
  } finally {
27997
28795
  closeSpawnLog(logFd);
27998
- cleanupSkillsForRun(manifest);
28796
+ cleanupResourcesForRun(manifest);
27999
28797
  }
28000
28798
  }
28001
28799
  function resolveSpawnLogPath(options) {
@@ -28005,12 +28803,12 @@ function resolveSpawnLogPath(options) {
28005
28803
  if (!options.logDir || !options.logFileName) {
28006
28804
  return void 0;
28007
28805
  }
28008
- return path36.join(options.logDir, options.logFileName);
28806
+ return path41.join(options.logDir, options.logFileName);
28009
28807
  }
28010
28808
  function openSpawnLog(filePath) {
28011
28809
  try {
28012
- mkdirSync3(path36.dirname(filePath), { recursive: true });
28013
- return openSync(filePath, "a");
28810
+ mkdirSync5(path41.dirname(filePath), { recursive: true });
28811
+ return openSync2(filePath, "a");
28014
28812
  } catch {
28015
28813
  return void 0;
28016
28814
  }
@@ -28025,7 +28823,7 @@ function appendSpawnLog(fd, chunk) {
28025
28823
  function closeSpawnLog(fd) {
28026
28824
  if (fd === void 0) return;
28027
28825
  try {
28028
- closeSync(fd);
28826
+ closeSync2(fd);
28029
28827
  } catch {
28030
28828
  }
28031
28829
  }
@@ -28187,7 +28985,7 @@ var init_autonomous = __esm({
28187
28985
  });
28188
28986
 
28189
28987
  // packages/agent-spawn/src/acp/replay.ts
28190
- import path37 from "node:path";
28988
+ import path42 from "node:path";
28191
28989
  import { homedir as homedir3 } from "node:os";
28192
28990
  import { open as open2, readdir as readdir2 } from "node:fs/promises";
28193
28991
  import { createInterface } from "node:readline";
@@ -28278,7 +29076,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
28278
29076
  }
28279
29077
  const id = readString(event.id);
28280
29078
  const kind = readString(event.kind);
28281
- const path49 = readString(event.path);
29079
+ const path54 = readString(event.path);
28282
29080
  let toolCall = id ? toolCallsById.get(id) : void 0;
28283
29081
  if (!toolCall) {
28284
29082
  toolCall = {};
@@ -28293,8 +29091,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
28293
29091
  if (kind) {
28294
29092
  toolCall.kind = kind;
28295
29093
  }
28296
- if (path49) {
28297
- toolCall.path = path49;
29094
+ if (path54) {
29095
+ toolCall.path = path54;
28298
29096
  }
28299
29097
  }
28300
29098
  var sessionCapture;
@@ -28380,7 +29178,7 @@ var init_usage_capture = __esm({
28380
29178
  });
28381
29179
 
28382
29180
  // packages/agent-spawn/src/acp/middlewares/spawn-log.ts
28383
- import path38 from "node:path";
29181
+ import path43 from "node:path";
28384
29182
  import { homedir as homedir4 } from "node:os";
28385
29183
  import { mkdir as mkdir2, open as open3 } from "node:fs/promises";
28386
29184
  function pad2(value, width) {
@@ -28417,14 +29215,14 @@ function resolveLogFilePath(ctx) {
28417
29215
  if (ctx.logPath) {
28418
29216
  return ctx.logPath;
28419
29217
  }
28420
- const baseDir = ctx.logDir ?? path38.join(homedir4(), ".poe-code", "spawn-logs");
29218
+ const baseDir = ctx.logDir ?? path43.join(homedir4(), ".poe-code", "spawn-logs");
28421
29219
  if (ctx.logFileName) {
28422
- return path38.join(baseDir, ctx.logFileName);
29220
+ return path43.join(baseDir, ctx.logFileName);
28423
29221
  }
28424
29222
  const startedAt = resolveStartedAt(ctx.startedAt);
28425
29223
  const { day, time, milliseconds } = formatTimestamp(startedAt);
28426
29224
  const fileName = `${day}-${time}-${milliseconds}-${normalizeAgent(ctx.agent)}.jsonl`;
28427
- return path38.join(baseDir, fileName);
29225
+ return path43.join(baseDir, fileName);
28428
29226
  }
28429
29227
  async function writePreloadedEvents(writer, events) {
28430
29228
  for (const event of events) {
@@ -28442,7 +29240,7 @@ var init_spawn_log = __esm({
28442
29240
  logDirPath;
28443
29241
  constructor(ctx) {
28444
29242
  this.filePath = resolveLogFilePath(ctx);
28445
- this.logDirPath = path38.dirname(this.filePath);
29243
+ this.logDirPath = path43.dirname(this.filePath);
28446
29244
  }
28447
29245
  async writeEvent(event) {
28448
29246
  if (this.isDisabled) {
@@ -28510,7 +29308,7 @@ var init_spawn_log = __esm({
28510
29308
  });
28511
29309
 
28512
29310
  // packages/agent-spawn/src/index.ts
28513
- var init_src16 = __esm({
29311
+ var init_src17 = __esm({
28514
29312
  "packages/agent-spawn/src/index.ts"() {
28515
29313
  "use strict";
28516
29314
  init_register_factories();
@@ -28543,7 +29341,7 @@ var gitContext, poe_agent_plugin_git_context_default;
28543
29341
  var init_poe_agent_plugin_git_context = __esm({
28544
29342
  "packages/poe-agent/src/plugins/poe-agent-plugin-git-context.ts"() {
28545
29343
  "use strict";
28546
- init_src16();
29344
+ init_src17();
28547
29345
  gitContext = (cwd) => ({
28548
29346
  name: "git-context",
28549
29347
  async prompt(ctx) {
@@ -28782,7 +29580,7 @@ __export(src_exports, {
28782
29580
  systemPromptPlugin: () => poe_agent_plugin_system_prompt_default,
28783
29581
  webPlugin: () => poe_agent_plugin_web_default
28784
29582
  });
28785
- var init_src17 = __esm({
29583
+ var init_src18 = __esm({
28786
29584
  "packages/poe-agent/src/index.ts"() {
28787
29585
  "use strict";
28788
29586
  init_agent();
@@ -28814,7 +29612,7 @@ var init_src17 = __esm({
28814
29612
 
28815
29613
  // src/providers/poe-agent.ts
28816
29614
  import fsPromises10 from "node:fs/promises";
28817
- import os8 from "node:os";
29615
+ import os9 from "node:os";
28818
29616
 
28819
29617
  // src/cli/constants.ts
28820
29618
  var DEFAULT_FRONTIER_MODEL = "anthropic/claude-opus-4.7";
@@ -28944,6 +29742,7 @@ function createProvider(opts) {
28944
29742
  configurePrompts: opts.configurePrompts,
28945
29743
  postConfigureMessages: opts.postConfigureMessages,
28946
29744
  extendConfigurePayload: opts.extendConfigurePayload,
29745
+ runtimeEnv: opts.runtimeEnv,
28947
29746
  isolatedEnv: opts.isolatedEnv,
28948
29747
  async configure(context, runOptions) {
28949
29748
  await runMutations(opts.manifest.configure, {
@@ -28995,16 +29794,16 @@ function createInstallRunner(definition) {
28995
29794
  // src/services/config.ts
28996
29795
  init_src4();
28997
29796
  init_src8();
28998
- init_src17();
28999
- import path48 from "node:path";
29797
+ init_src18();
29798
+ import path53 from "node:path";
29000
29799
 
29001
29800
  // packages/superintendent/src/document/parse.ts
29002
- import path39 from "node:path";
29801
+ import path44 from "node:path";
29003
29802
  import { parseDocument as parseDocument4 } from "yaml";
29004
29803
  var superintendentDocumentSchemaId = "https://poe-platform.github.io/poe-code/schemas/plans/superintendent.schema.json";
29005
29804
  var validStatusStates = /* @__PURE__ */ new Set(["in_progress", "review", "completed"]);
29006
29805
  function parseSuperintendentDoc(filePath, content) {
29007
- const resolvedFilePath = path39.resolve(filePath);
29806
+ const resolvedFilePath = path44.resolve(filePath);
29008
29807
  const { frontmatterText, body } = splitFrontmatter(resolvedFilePath, content);
29009
29808
  const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
29010
29809
  return {
@@ -29014,7 +29813,7 @@ function parseSuperintendentDoc(filePath, content) {
29014
29813
  };
29015
29814
  }
29016
29815
  function readExplicitBuilderAgent(filePath, content) {
29017
- const resolvedFilePath = path39.resolve(filePath);
29816
+ const resolvedFilePath = path44.resolve(filePath);
29018
29817
  const { frontmatterText } = splitFrontmatter(resolvedFilePath, content);
29019
29818
  const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
29020
29819
  const frontmatter = expectRecord(parsedFrontmatter, "frontmatter", resolvedFilePath);
@@ -29171,7 +29970,7 @@ function parseStatusBlock(value, filePath) {
29171
29970
  };
29172
29971
  }
29173
29972
  function expectRecord(value, fieldName, filePath) {
29174
- if (!isRecord10(value)) {
29973
+ if (!isRecord11(value)) {
29175
29974
  throw new Error(`${filePath}: ${fieldName} must be a mapping`);
29176
29975
  }
29177
29976
  return value;
@@ -29200,12 +29999,12 @@ function expectStringArray(value, fieldName, filePath) {
29200
29999
  }
29201
30000
  return value;
29202
30001
  }
29203
- function isRecord10(value) {
30002
+ function isRecord11(value) {
29204
30003
  return typeof value === "object" && value !== null && !Array.isArray(value);
29205
30004
  }
29206
30005
 
29207
30006
  // packages/superintendent/src/document/write.ts
29208
- import path40 from "node:path";
30007
+ import path45 from "node:path";
29209
30008
  import { isMap as isMap2, parseDocument as parseDocument5 } from "yaml";
29210
30009
  function updateStatus(filePath, content, status) {
29211
30010
  return updateFrontmatter(filePath, content, (frontmatterDocument) => {
@@ -29226,7 +30025,7 @@ function setStatusReason(filePath, content, reason) {
29226
30025
  });
29227
30026
  }
29228
30027
  function updateFrontmatter(filePath, content, mutate) {
29229
- const resolvedFilePath = path40.resolve(filePath);
30028
+ const resolvedFilePath = path45.resolve(filePath);
29230
30029
  const parts = splitDocument(resolvedFilePath, content);
29231
30030
  const frontmatterDocument = parseDocument5(parts.frontmatterText);
29232
30031
  if (frontmatterDocument.errors.length > 0) {
@@ -29452,7 +30251,7 @@ function extractText(node) {
29452
30251
 
29453
30252
  // packages/superintendent/src/runtime/loop.ts
29454
30253
  init_src13();
29455
- import path43 from "node:path";
30254
+ import path48 from "node:path";
29456
30255
  import * as fsPromises8 from "node:fs/promises";
29457
30256
 
29458
30257
  // packages/superintendent/src/state/machine.ts
@@ -29471,9 +30270,9 @@ function createLoopState(doc) {
29471
30270
  // packages/superintendent/src/runtime/agent-runner.ts
29472
30271
  init_register_factories();
29473
30272
  init_src13();
29474
- init_src16();
29475
- import { mkdirSync as mkdirSync4, openSync as openSync2, writeSync as writeSync2, closeSync as closeSync2 } from "node:fs";
29476
- import path41 from "node:path";
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";
29477
30276
  var injectedRunner;
29478
30277
  async function withAutonomousAgentRunner(runner, operation) {
29479
30278
  const previous = injectedRunner;
@@ -29561,8 +30360,8 @@ async function runAutonomousAgent(input) {
29561
30360
  }
29562
30361
  function openSpawnLog2(filePath) {
29563
30362
  try {
29564
- mkdirSync4(path41.dirname(filePath), { recursive: true });
29565
- return openSync2(filePath, "a");
30363
+ mkdirSync6(path46.dirname(filePath), { recursive: true });
30364
+ return openSync3(filePath, "a");
29566
30365
  } catch {
29567
30366
  return void 0;
29568
30367
  }
@@ -29577,7 +30376,7 @@ function appendSpawnLog2(fd, chunk) {
29577
30376
  function closeSpawnLog2(fd) {
29578
30377
  if (fd === void 0) return;
29579
30378
  try {
29580
- closeSync2(fd);
30379
+ closeSync3(fd);
29581
30380
  } catch {
29582
30381
  }
29583
30382
  }
@@ -29586,15 +30385,15 @@ function closeSpawnLog2(fd) {
29586
30385
  init_register_factories();
29587
30386
 
29588
30387
  // packages/superintendent/src/runtime/resolve-cwd.ts
29589
- import path42 from "node:path";
30388
+ import path47 from "node:path";
29590
30389
  function resolveRoleCwd(role, docPath, defaultCwd) {
29591
30390
  if (role.cwd === void 0) {
29592
30391
  return defaultCwd;
29593
30392
  }
29594
- if (path42.isAbsolute(role.cwd)) {
30393
+ if (path47.isAbsolute(role.cwd)) {
29595
30394
  return role.cwd;
29596
30395
  }
29597
- return path42.resolve(path42.dirname(docPath), role.cwd);
30396
+ return path47.resolve(path47.dirname(docPath), role.cwd);
29598
30397
  }
29599
30398
 
29600
30399
  // packages/superintendent/src/runtime/templates.ts
@@ -29614,9 +30413,9 @@ function collectReferencedInspectors(template) {
29614
30413
  return names;
29615
30414
  }
29616
30415
  function readTemplateValue(context, variablePath) {
29617
- return variablePath.split(".").reduce((value, segment) => isRecord11(value) ? value[segment] : void 0, context);
30416
+ return variablePath.split(".").reduce((value, segment) => isRecord12(value) ? value[segment] : void 0, context);
29618
30417
  }
29619
- function isRecord11(value) {
30418
+ function isRecord12(value) {
29620
30419
  return typeof value === "object" && value !== null;
29621
30420
  }
29622
30421
 
@@ -29875,7 +30674,7 @@ function createWorkflowTool(role, state) {
29875
30674
  };
29876
30675
  }
29877
30676
  function parseWorkflowCall(input) {
29878
- if (!isRecord12(input)) {
30677
+ if (!isRecord13(input)) {
29879
30678
  throw invalidActionError();
29880
30679
  }
29881
30680
  const { action } = input;
@@ -29947,7 +30746,7 @@ function invalidActionError() {
29947
30746
  'workflow_transition action must be one of "request_review", "approve_completion", or "request_changes"'
29948
30747
  );
29949
30748
  }
29950
- function isRecord12(value) {
30749
+ function isRecord13(value) {
29951
30750
  return typeof value === "object" && value !== null && !Array.isArray(value);
29952
30751
  }
29953
30752
 
@@ -30037,7 +30836,7 @@ function collectToolNames(result) {
30037
30836
  }
30038
30837
  const names = [];
30039
30838
  collectToolNamesFrom(result.toolCalls, names);
30040
- if (isRecord13(result.sessionResult)) {
30839
+ if (isRecord14(result.sessionResult)) {
30041
30840
  collectToolNamesFrom(result.sessionResult.toolCalls, names);
30042
30841
  }
30043
30842
  return names;
@@ -30082,13 +30881,13 @@ function readTransitionFromToolCalls(value) {
30082
30881
  return void 0;
30083
30882
  }
30084
30883
  function readTransitionFromSessionResult(value) {
30085
- if (!isRecord13(value)) {
30884
+ if (!isRecord14(value)) {
30086
30885
  return void 0;
30087
30886
  }
30088
30887
  return readTransitionFromToolCalls(value.toolCalls);
30089
30888
  }
30090
30889
  function readToolCall(value) {
30091
- return isRecord13(value) ? value : void 0;
30890
+ return isRecord14(value) ? value : void 0;
30092
30891
  }
30093
30892
  function readToolCallName(toolCall) {
30094
30893
  return readString4(toolCall.name) ?? readString4(toolCall.tool) ?? readString4(toolCall.title) ?? readString4(toolCall.path);
@@ -30125,7 +30924,7 @@ function encodeJson(value) {
30125
30924
  function readString4(value) {
30126
30925
  return typeof value === "string" ? value : void 0;
30127
30926
  }
30128
- function isRecord13(value) {
30927
+ function isRecord14(value) {
30129
30928
  return typeof value === "object" && value !== null && !Array.isArray(value);
30130
30929
  }
30131
30930
 
@@ -30234,7 +31033,7 @@ function readTransitionFromToolCalls2(value) {
30234
31033
  return void 0;
30235
31034
  }
30236
31035
  function readTransitionFromSessionResult2(value) {
30237
- if (!isRecord14(value)) {
31036
+ if (!isRecord15(value)) {
30238
31037
  return void 0;
30239
31038
  }
30240
31039
  return readTransitionFromToolCalls2(value.toolCalls);
@@ -30259,7 +31058,7 @@ function extractOutputText(result) {
30259
31058
  return readString5(result.output) ?? readString5(result.stdout) ?? readString5(result.text) ?? "";
30260
31059
  }
30261
31060
  function readToolCall2(value) {
30262
- return isRecord14(value) ? value : void 0;
31061
+ return isRecord15(value) ? value : void 0;
30263
31062
  }
30264
31063
  function readToolCallName2(toolCall) {
30265
31064
  return readString5(toolCall.name) ?? readString5(toolCall.tool) ?? readString5(toolCall.title) ?? readString5(toolCall.path);
@@ -30299,7 +31098,7 @@ function splitLines(value) {
30299
31098
  function readString5(value) {
30300
31099
  return typeof value === "string" ? value : void 0;
30301
31100
  }
30302
- function isRecord14(value) {
31101
+ function isRecord15(value) {
30303
31102
  return typeof value === "object" && value !== null && !Array.isArray(value);
30304
31103
  }
30305
31104
 
@@ -30330,8 +31129,15 @@ async function runLoop2(input, callbacks) {
30330
31129
  options.callbacks.onBuilderStart?.();
30331
31130
  let builderResult;
30332
31131
  try {
31132
+ const builderDoc = await readDocument2(options.fs, options.docPath);
30333
31133
  builderResult = await options.runners.builder(
30334
- await readDocument2(options.fs, options.docPath),
31134
+ options.builderAgent ? {
31135
+ ...builderDoc,
31136
+ frontmatter: {
31137
+ ...builderDoc.frontmatter,
31138
+ builder: { ...builderDoc.frontmatter.builder, agent: options.builderAgent }
31139
+ }
31140
+ } : builderDoc,
30335
31141
  createTemplateContext(context),
30336
31142
  buildRoleOptions(options, "builder")
30337
31143
  );
@@ -30433,7 +31239,9 @@ async function runLoop2(input, callbacks) {
30433
31239
  if (context.ownerFeedback && shouldContinueReview(await readDocument2(options.fs, options.docPath))) {
30434
31240
  const superintendentResult = await executeSuperintendent(options, context);
30435
31241
  if (superintendentResult.transition?.action !== "request_review") {
30436
- throw new Error("Superintendent must call request_review to continue a review exchange");
31242
+ throw new Error(
31243
+ "Superintendent must call request_review to continue a review exchange"
31244
+ );
30437
31245
  }
30438
31246
  context = {
30439
31247
  ...context,
@@ -30511,6 +31319,7 @@ function normalizeOptions(input, callbacks) {
30511
31319
  callbacks: input.callbacks ?? {},
30512
31320
  runners: resolveRunners(input.runners),
30513
31321
  ...input.runAgent ? { runAgent: input.runAgent } : {},
31322
+ ...input.builderAgent ? { builderAgent: input.builderAgent } : {},
30514
31323
  ...input.signal ? { signal: input.signal } : {},
30515
31324
  ...input.logDir ? { logDir: input.logDir } : {}
30516
31325
  };
@@ -30535,7 +31344,7 @@ function resolveRunners(overrides) {
30535
31344
  };
30536
31345
  }
30537
31346
  function createDefaultFs3() {
30538
- const fs6 = {
31347
+ const fs7 = {
30539
31348
  readFile: fsPromises8.readFile,
30540
31349
  writeFile: fsPromises8.writeFile,
30541
31350
  readdir: fsPromises8.readdir,
@@ -30561,26 +31370,26 @@ function createDefaultFs3() {
30561
31370
  await fsPromises8.rename(oldPath, newPath);
30562
31371
  }
30563
31372
  };
30564
- return fs6;
31373
+ return fs7;
30565
31374
  }
30566
- async function readDocument2(fs6, docPath) {
30567
- const content = await readDocumentContent(fs6, docPath);
31375
+ async function readDocument2(fs7, docPath) {
31376
+ const content = await readDocumentContent(fs7, docPath);
30568
31377
  return parseSuperintendentDoc(docPath, content);
30569
31378
  }
30570
- async function readDocumentContent(fs6, docPath) {
30571
- return fs6.readFile(docPath, "utf8");
31379
+ async function readDocumentContent(fs7, docPath) {
31380
+ return fs7.readFile(docPath, "utf8");
30572
31381
  }
30573
- async function writeLoopState(fs6, docPath, state) {
30574
- const content = await fs6.readFile(docPath, "utf8");
31382
+ async function writeLoopState(fs7, docPath, state) {
31383
+ const content = await fs7.readFile(docPath, "utf8");
30575
31384
  const updatedContent = updateStatus(docPath, content, {
30576
31385
  state: state.state,
30577
31386
  round: state.round,
30578
31387
  review_turn: state.reviewTurn
30579
31388
  });
30580
- await fs6.writeFile(docPath, updatedContent, { encoding: "utf8" });
31389
+ await fs7.writeFile(docPath, updatedContent, { encoding: "utf8" });
30581
31390
  }
30582
- async function restoreDocument(fs6, docPath, content) {
30583
- await fs6.writeFile(docPath, content, { encoding: "utf8" });
31391
+ async function restoreDocument(fs7, docPath, content) {
31392
+ await fs7.writeFile(docPath, content, { encoding: "utf8" });
30584
31393
  }
30585
31394
  async function rollbackRoundStatus(options, state) {
30586
31395
  await writeLoopState(options.fs, options.docPath, state);
@@ -30649,7 +31458,7 @@ async function executeSuperintendent(options, context) {
30649
31458
  function buildRoleOptions(options, role) {
30650
31459
  return {
30651
31460
  defaultCwd: options.cwd,
30652
- ...options.logDir ? { logPath: path43.join(options.logDir, makeRunLogFileName(role)) } : {}
31461
+ ...options.logDir ? { logPath: path48.join(options.logDir, makeRunLogFileName(role)) } : {}
30653
31462
  };
30654
31463
  }
30655
31464
  function shouldContinueReview(doc) {
@@ -30912,8 +31721,8 @@ var S = {
30912
31721
  };
30913
31722
 
30914
31723
  // packages/toolcraft/src/package-metadata.ts
30915
- import { existsSync as existsSync3, readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
30916
- import path44 from "node:path";
31724
+ import { existsSync as existsSync3, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
31725
+ import path49 from "node:path";
30917
31726
  import { fileURLToPath as fileURLToPath3 } from "node:url";
30918
31727
 
30919
31728
  // packages/toolcraft/src/index.ts
@@ -31280,8 +32089,8 @@ function createBuilderRunCommand(runners) {
31280
32089
  positional: ["path"],
31281
32090
  params: builderRunParams,
31282
32091
  scope: ["cli", "mcp", "sdk"],
31283
- handler: async ({ params, fs: fs6 }) => {
31284
- const content = await readDocument3(params.path, fs6);
32092
+ handler: async ({ params, fs: fs7 }) => {
32093
+ const content = await readDocument3(params.path, fs7);
31285
32094
  const document = parseSuperintendentDoc(params.path, content);
31286
32095
  return runBuilderImpl(document, {}, { defaultCwd: process.cwd() });
31287
32096
  },
@@ -31308,9 +32117,9 @@ function createBuilderGroup(runners) {
31308
32117
  });
31309
32118
  }
31310
32119
  var builderGroup = createBuilderGroup();
31311
- async function readDocument3(filePath, fs6) {
32120
+ async function readDocument3(filePath, fs7) {
31312
32121
  try {
31313
- return await fs6.readFile(filePath, "utf8");
32122
+ return await fs7.readFile(filePath, "utf8");
31314
32123
  } catch (error2) {
31315
32124
  if (hasCode2(error2, "ENOENT")) {
31316
32125
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -31339,13 +32148,13 @@ function hasCode2(error2, code) {
31339
32148
  }
31340
32149
 
31341
32150
  // packages/superintendent/src/commands/install.ts
31342
- import path45 from "node:path";
32151
+ import path50 from "node:path";
31343
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";
31344
32153
  import { fileURLToPath as fileURLToPath5 } from "node:url";
31345
32154
  init_src8();
31346
32155
  init_src15();
31347
32156
  init_src13();
31348
- var fs4 = {
32157
+ var fs5 = {
31349
32158
  readFile: (p, encoding) => readFile8(p, encoding),
31350
32159
  writeFile: (p, content) => writeFile3(p, content),
31351
32160
  mkdir: (p, options) => mkdir4(p, options).then(() => void 0),
@@ -31386,7 +32195,7 @@ var installCommand = defineCommand({
31386
32195
  content: skillContent + "\n\n" + skillPlanConfigSection("superintendent")
31387
32196
  },
31388
32197
  {
31389
- fs: fs4,
32198
+ fs: fs5,
31390
32199
  cwd,
31391
32200
  homeDir,
31392
32201
  scope
@@ -31395,7 +32204,7 @@ var installCommand = defineCommand({
31395
32204
  const planDirectory = await resolvePlanDirectory2(cwd, homeDir, process.env);
31396
32205
  const absolutePlanDirectory = resolveAbsoluteDirectory(planDirectory, cwd, homeDir);
31397
32206
  let planDirectoryCreated = false;
31398
- if (!await pathExists3(absolutePlanDirectory)) {
32207
+ if (!await pathExists4(absolutePlanDirectory)) {
31399
32208
  await mkdir4(absolutePlanDirectory, { recursive: true });
31400
32209
  planDirectoryCreated = true;
31401
32210
  }
@@ -31436,16 +32245,16 @@ var installCommand = defineCommand({
31436
32245
  async function resolvePlanDirectory2(cwd, homeDir, env) {
31437
32246
  const configPath = resolveConfigPath(homeDir);
31438
32247
  const projectConfigPath = resolveProjectConfigPath(cwd);
31439
- const document = await readMergedDocument(fs4, configPath, projectConfigPath);
32248
+ const document = await readMergedDocument(fs5, configPath, projectConfigPath);
31440
32249
  return resolveScope(planConfigScope.schema, document.plan, env).plan_directory;
31441
32250
  }
31442
32251
  function resolveAbsoluteDirectory(dir, cwd, homeDir) {
31443
32252
  if (dir.startsWith("~/")) {
31444
- return path45.join(homeDir, dir.slice(2));
32253
+ return path50.join(homeDir, dir.slice(2));
31445
32254
  }
31446
- return path45.isAbsolute(dir) ? dir : path45.resolve(cwd, dir);
32255
+ return path50.isAbsolute(dir) ? dir : path50.resolve(cwd, dir);
31447
32256
  }
31448
- async function pathExists3(targetPath) {
32257
+ async function pathExists4(targetPath) {
31449
32258
  try {
31450
32259
  await stat4(targetPath);
31451
32260
  return true;
@@ -31463,15 +32272,15 @@ async function loadSkillTemplate() {
31463
32272
  }
31464
32273
  const packageRoot = await findPackageRoot(fileURLToPath5(import.meta.url));
31465
32274
  const templateRoots = [
31466
- path45.join(packageRoot, "src", "templates"),
31467
- path45.join(packageRoot, "dist", "templates")
32275
+ path50.join(packageRoot, "src", "templates"),
32276
+ path50.join(packageRoot, "dist", "templates")
31468
32277
  ];
31469
32278
  for (const templateRoot of templateRoots) {
31470
- if (!await pathExists3(templateRoot)) {
32279
+ if (!await pathExists4(templateRoot)) {
31471
32280
  continue;
31472
32281
  }
31473
32282
  skillTemplateCache = await readFile8(
31474
- path45.join(templateRoot, "SKILL_superintendent.md"),
32283
+ path50.join(templateRoot, "SKILL_superintendent.md"),
31475
32284
  "utf8"
31476
32285
  );
31477
32286
  return skillTemplateCache;
@@ -31479,12 +32288,12 @@ async function loadSkillTemplate() {
31479
32288
  throw new Error("Unable to locate Superintendent skill template.");
31480
32289
  }
31481
32290
  async function findPackageRoot(entryFilePath) {
31482
- let currentPath = path45.dirname(entryFilePath);
32291
+ let currentPath = path50.dirname(entryFilePath);
31483
32292
  while (true) {
31484
- if (await pathExists3(path45.join(currentPath, "package.json"))) {
32293
+ if (await pathExists4(path50.join(currentPath, "package.json"))) {
31485
32294
  return currentPath;
31486
32295
  }
31487
- const parentPath = path45.dirname(currentPath);
32296
+ const parentPath = path50.dirname(currentPath);
31488
32297
  if (parentPath === currentPath) {
31489
32298
  throw new Error("Unable to locate package root for Superintendent templates.");
31490
32299
  }
@@ -31506,8 +32315,8 @@ var inspectorListCommand = defineCommand({
31506
32315
  positional: ["path"],
31507
32316
  params: inspectorListParams,
31508
32317
  scope: ["cli", "mcp", "sdk"],
31509
- handler: async ({ params, fs: fs6 }) => {
31510
- const content = await readDocument4(params.path, fs6);
32318
+ handler: async ({ params, fs: fs7 }) => {
32319
+ const content = await readDocument4(params.path, fs7);
31511
32320
  const document = parseSuperintendentDoc(params.path, content);
31512
32321
  return Object.entries(document.frontmatter.inspectors ?? {}).map(([name, config]) => ({
31513
32322
  name,
@@ -31550,8 +32359,8 @@ function createInspectorRunCommand(runners) {
31550
32359
  positional: ["path", "name"],
31551
32360
  params: inspectorRunParams,
31552
32361
  scope: ["cli", "mcp", "sdk"],
31553
- handler: async ({ params, fs: fs6 }) => {
31554
- const content = await readDocument4(params.path, fs6);
32362
+ handler: async ({ params, fs: fs7 }) => {
32363
+ const content = await readDocument4(params.path, fs7);
31555
32364
  const document = parseSuperintendentDoc(params.path, content);
31556
32365
  const defaultCwd = process.cwd();
31557
32366
  if (params.name === void 0) {
@@ -31589,9 +32398,9 @@ function createInspectorGroup(runners) {
31589
32398
  });
31590
32399
  }
31591
32400
  var inspectorGroup = createInspectorGroup();
31592
- async function readDocument4(filePath, fs6) {
32401
+ async function readDocument4(filePath, fs7) {
31593
32402
  try {
31594
- return await fs6.readFile(filePath, "utf8");
32403
+ return await fs7.readFile(filePath, "utf8");
31595
32404
  } catch (error2) {
31596
32405
  if (hasCode3(error2, "ENOENT")) {
31597
32406
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -31639,11 +32448,11 @@ var completeCommand = defineCommand({
31639
32448
  positional: ["path"],
31640
32449
  params: completeParams,
31641
32450
  scope: ["cli", "mcp", "sdk"],
31642
- handler: async ({ params, fs: fs6 }) => {
31643
- const content = await readDocument5(params.path, fs6);
32451
+ handler: async ({ params, fs: fs7 }) => {
32452
+ const content = await readDocument5(params.path, fs7);
31644
32453
  const completedContent = transitionState(params.path, content, "completed");
31645
32454
  const updatedContent = setStatusReason(params.path, completedContent, params.reason);
31646
- await fs6.writeFile(params.path, updatedContent);
32455
+ await fs7.writeFile(params.path, updatedContent);
31647
32456
  return {
31648
32457
  path: params.path,
31649
32458
  state: "completed",
@@ -31667,9 +32476,9 @@ var completeCommand = defineCommand({
31667
32476
  json: (result) => result
31668
32477
  }
31669
32478
  });
31670
- async function readDocument5(filePath, fs6) {
32479
+ async function readDocument5(filePath, fs7) {
31671
32480
  try {
31672
- return await fs6.readFile(filePath, "utf8");
32481
+ return await fs7.readFile(filePath, "utf8");
31673
32482
  } catch (error2) {
31674
32483
  if (hasCode4(error2, "ENOENT")) {
31675
32484
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -31682,10 +32491,10 @@ function hasCode4(error2, code) {
31682
32491
  }
31683
32492
 
31684
32493
  // packages/superintendent/src/commands/plan-path.ts
31685
- import path46 from "node:path";
32494
+ import path51 from "node:path";
31686
32495
  import { readFile as readFile9, writeFile as writeFile4, mkdir as mkdir5, unlink as unlink4, stat as stat5, readdir as readdir5 } from "node:fs/promises";
31687
32496
  init_src8();
31688
- var fs5 = {
32497
+ var fs6 = {
31689
32498
  readFile: (p, encoding) => readFile9(p, encoding),
31690
32499
  writeFile: (p, content) => writeFile4(p, content),
31691
32500
  mkdir: (p, options) => mkdir5(p, options).then(() => void 0),
@@ -31703,7 +32512,7 @@ var planPathCommand = defineCommand({
31703
32512
  const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? cwd;
31704
32513
  const configPath = resolveConfigPath(homeDir);
31705
32514
  const projectConfigPath = resolveProjectConfigPath(cwd);
31706
- const document = await readMergedDocument(fs5, configPath, projectConfigPath);
32515
+ const document = await readMergedDocument(fs6, configPath, projectConfigPath);
31707
32516
  const planDirectory = resolveScope(planConfigScope.schema, document.plan, process.env).plan_directory;
31708
32517
  return { planDirectory: resolveAbsoluteDirectory2(planDirectory, cwd, homeDir) };
31709
32518
  },
@@ -31718,22 +32527,22 @@ var planPathCommand = defineCommand({
31718
32527
  });
31719
32528
  function resolveAbsoluteDirectory2(dir, cwd, homeDir) {
31720
32529
  if (dir.startsWith("~/")) {
31721
- return path46.join(homeDir, dir.slice(2));
32530
+ return path51.join(homeDir, dir.slice(2));
31722
32531
  }
31723
- return path46.isAbsolute(dir) ? dir : path46.resolve(cwd, dir);
32532
+ return path51.isAbsolute(dir) ? dir : path51.resolve(cwd, dir);
31724
32533
  }
31725
32534
 
31726
32535
  // packages/superintendent/src/commands/run.ts
31727
32536
  init_src13();
31728
- init_src16();
32537
+ init_src17();
31729
32538
  init_src5();
31730
- import path47 from "node:path";
32539
+ import path52 from "node:path";
31731
32540
  import * as fsPromises9 from "node:fs/promises";
31732
32541
  import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
31733
32542
 
31734
32543
  // packages/superintendent/src/commands/poe-agent-runner.ts
31735
32544
  init_src5();
31736
- init_src17();
32545
+ init_src18();
31737
32546
  async function executePoeAgent(agentSpec, input, createAgent = agent) {
31738
32547
  const { model } = parseAgentSpecifier(agentSpec);
31739
32548
  if (!model) {
@@ -32817,12 +33626,12 @@ function createRunMcpCommand(runners) {
32817
33626
  });
32818
33627
  }
32819
33628
  var runMcpCommand = createRunMcpCommand();
32820
- async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs6) {
33629
+ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs7) {
32821
33630
  const configPath = resolveConfigPath(homeDir);
32822
33631
  const projectConfigPath = resolveProjectConfigPath(cwd);
32823
33632
  try {
32824
33633
  const document = await readMergedDocument(
32825
- createConfigResolutionFs(fs6),
33634
+ createConfigResolutionFs(fs7),
32826
33635
  configPath,
32827
33636
  projectConfigPath
32828
33637
  );
@@ -32843,11 +33652,11 @@ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs6) {
32843
33652
  return { configDoc: {}, configuredDefaultAgent: null, tui: false };
32844
33653
  }
32845
33654
  }
32846
- async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs6) {
33655
+ async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs7) {
32847
33656
  const configPath = resolveConfigPath(homeDir);
32848
33657
  const projectConfigPath = resolveProjectConfigPath(cwd);
32849
33658
  const document = await readMergedDocument(
32850
- createConfigResolutionFs(fs6),
33659
+ createConfigResolutionFs(fs7),
32851
33660
  configPath,
32852
33661
  projectConfigPath
32853
33662
  );
@@ -32868,23 +33677,23 @@ var configFs = {
32868
33677
  },
32869
33678
  readdir: (filePath) => fsPromises9.readdir(filePath)
32870
33679
  };
32871
- function createConfigResolutionFs(fs6) {
32872
- if (!fs6) {
33680
+ function createConfigResolutionFs(fs7) {
33681
+ if (!fs7) {
32873
33682
  return configFs;
32874
33683
  }
32875
33684
  return {
32876
33685
  ...configFs,
32877
- readFile: (filePath, encoding) => fs6.readFile(filePath, encoding),
33686
+ readFile: (filePath, encoding) => fs7.readFile(filePath, encoding),
32878
33687
  writeFile: async (filePath, content, options) => {
32879
- await fs6.writeFile(filePath, content, options);
33688
+ await fs7.writeFile(filePath, content, options);
32880
33689
  },
32881
33690
  mkdir: async (filePath, options) => {
32882
- await fs6.mkdir(filePath, options);
33691
+ await fs7.mkdir(filePath, options);
32883
33692
  }
32884
33693
  };
32885
33694
  }
32886
33695
  async function runSuperintendentCommand(options) {
32887
- const fs6 = options.fs ?? createDefaultFs4();
33696
+ const fs7 = options.fs ?? createDefaultFs4();
32888
33697
  const now = options.now ?? Date.now;
32889
33698
  const selectPrompt = options.selectPrompt ?? select2;
32890
33699
  const dashboardFactory = options.createDashboard ?? createDashboard;
@@ -32915,7 +33724,7 @@ async function runSuperintendentCommand(options) {
32915
33724
  assumeYes,
32916
33725
  interactive,
32917
33726
  env,
32918
- fs: fs6,
33727
+ fs: fs7,
32919
33728
  selectPrompt
32920
33729
  });
32921
33730
  const runLogDir = resolveRunLogDir({
@@ -32923,7 +33732,7 @@ async function runSuperintendentCommand(options) {
32923
33732
  runner: "superintendent",
32924
33733
  homeDir: options.homeDir
32925
33734
  });
32926
- const documentContent = await fs6.readFile(selectedDocPath, "utf8");
33735
+ const documentContent = await fs7.readFile(selectedDocPath, "utf8");
32927
33736
  const document = parseSuperintendentDoc(selectedDocPath, documentContent);
32928
33737
  const selectedBuilder = await resolveLoopAgent({
32929
33738
  providedAgent: normalizeAgentSelection(options.builderAgent),
@@ -32955,7 +33764,7 @@ async function runSuperintendentCommand(options) {
32955
33764
  docPath: selectedDocPath,
32956
33765
  cwd: options.cwd,
32957
33766
  homeDir: options.homeDir,
32958
- ...options.fs ? { fs: fs6 } : {},
33767
+ ...options.fs ? { fs: fs7 } : {},
32959
33768
  signal: headlessAbort.signal,
32960
33769
  logDir: runLogDir,
32961
33770
  callbacks: mergeLoopCallbacks({
@@ -33214,7 +34023,7 @@ async function runSuperintendentCommand(options) {
33214
34023
  session.pauseRequested = true;
33215
34024
  }
33216
34025
  editPlan(session.dashboard, session.latestLogFile, env, options.openInEditor);
33217
- appendEvent("info", `Log opened: ${path47.basename(session.latestLogFile)}`);
34026
+ appendEvent("info", `Log opened: ${path52.basename(session.latestLogFile)}`);
33218
34027
  syncStats();
33219
34028
  }
33220
34029
  };
@@ -33234,7 +34043,7 @@ async function runSuperintendentCommand(options) {
33234
34043
  docPath: selectedDocPath,
33235
34044
  cwd: options.cwd,
33236
34045
  homeDir: options.homeDir,
33237
- ...options.fs ? { fs: fs6 } : {},
34046
+ ...options.fs ? { fs: fs7 } : {},
33238
34047
  callbacks: mergeLoopCallbacks(callbacks, integrations?.superintendentCallbacks),
33239
34048
  signal: abortController.signal,
33240
34049
  logDir: runLogDir,
@@ -33595,7 +34404,7 @@ function resolveEditor(env) {
33595
34404
  const parts = raw.split(/\s+/);
33596
34405
  const command = parts[0] ?? "vi";
33597
34406
  const args = parts.slice(1);
33598
- const binary = path47.basename(command);
34407
+ const binary = path52.basename(command);
33599
34408
  const mode = GUI_EDITOR_BINARIES.has(binary) ? "gui" : "tty";
33600
34409
  return { command, args, mode };
33601
34410
  }
@@ -33622,7 +34431,7 @@ function stripStopReason(result) {
33622
34431
  };
33623
34432
  }
33624
34433
  function createDefaultFs4() {
33625
- const fs6 = {
34434
+ const fs7 = {
33626
34435
  readFile: fsPromises9.readFile,
33627
34436
  writeFile: fsPromises9.writeFile,
33628
34437
  readdir: fsPromises9.readdir,
@@ -33648,7 +34457,7 @@ function createDefaultFs4() {
33648
34457
  await fsPromises9.rename(oldPath, newPath);
33649
34458
  }
33650
34459
  };
33651
- return fs6;
34460
+ return fs7;
33652
34461
  }
33653
34462
  function toError6(error2) {
33654
34463
  return error2 instanceof Error ? error2 : new Error(String(error2));
@@ -33664,8 +34473,8 @@ var validateCommand = defineCommand({
33664
34473
  positional: ["path"],
33665
34474
  params: validateParams,
33666
34475
  scope: ["cli", "mcp", "sdk"],
33667
- handler: async ({ params, fs: fs6 }) => {
33668
- const content = await readDocument6(params.path, fs6);
34476
+ handler: async ({ params, fs: fs7 }) => {
34477
+ const content = await readDocument6(params.path, fs7);
33669
34478
  return validateSuperintendentDocument(params.path, content);
33670
34479
  },
33671
34480
  render: {
@@ -33751,9 +34560,9 @@ function validateSuperintendentDocument(filePath, content) {
33751
34560
  problems.push(...validatePromptVariables(document));
33752
34561
  return toValidationResult(problems);
33753
34562
  }
33754
- async function readDocument6(filePath, fs6) {
34563
+ async function readDocument6(filePath, fs7) {
33755
34564
  try {
33756
- return await fs6.readFile(filePath, "utf8");
34565
+ return await fs7.readFile(filePath, "utf8");
33757
34566
  } catch (error2) {
33758
34567
  if (hasCode5(error2, "ENOENT")) {
33759
34568
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -34239,19 +35048,19 @@ function emitEvent(callback, event) {
34239
35048
  callback(event);
34240
35049
  }
34241
35050
  async function loadConfiguredPlugins(options) {
34242
- const fs6 = createConfigFileSystem(options.fs);
34243
- const homeDir = options.homeDir ?? os8.homedir();
35051
+ const fs7 = createConfigFileSystem(options.fs);
35052
+ const homeDir = options.homeDir ?? os9.homedir();
34244
35053
  const store = createConfigStore({
34245
- fs: fs6,
35054
+ fs: fs7,
34246
35055
  filePath: options.configPath ?? resolveConfigPath(homeDir),
34247
35056
  projectFilePath: options.projectConfigPath ?? resolveProjectConfigPath(options.cwd)
34248
35057
  });
34249
35058
  const plugins = await store.scope(agentConfigScope).get("plugins");
34250
35059
  return plugins ?? void 0;
34251
35060
  }
34252
- function createConfigFileSystem(fs6) {
34253
- if (fs6) {
34254
- return fs6;
35061
+ function createConfigFileSystem(fs7) {
35062
+ if (fs7) {
35063
+ return fs7;
34255
35064
  }
34256
35065
  return {
34257
35066
  readFile(filePath, encoding) {
@@ -34311,7 +35120,7 @@ function createInMemoryAcpTransport2(options) {
34311
35120
  }
34312
35121
  if (method === "session/new") {
34313
35122
  const request = params;
34314
- const { createAgentSession: createAgentSession2 } = await Promise.resolve().then(() => (init_src17(), src_exports));
35123
+ const { createAgentSession: createAgentSession2 } = await Promise.resolve().then(() => (init_src18(), src_exports));
34315
35124
  const session = await createAgentSession2({
34316
35125
  model: options.model,
34317
35126
  cwd: request.cwd || options.cwd,