poe-code 3.0.183 → 3.0.185

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 (232) hide show
  1. package/dist/cli/commands/configure-payload.d.ts +2 -1
  2. package/dist/cli/commands/configure-payload.js +4 -2
  3. package/dist/cli/commands/configure-payload.js.map +1 -1
  4. package/dist/cli/commands/configure.d.ts +1 -0
  5. package/dist/cli/commands/configure.js +50 -11
  6. package/dist/cli/commands/configure.js.map +1 -1
  7. package/dist/cli/commands/ensure-isolated-config.js +24 -2
  8. package/dist/cli/commands/ensure-isolated-config.js.map +1 -1
  9. package/dist/cli/commands/experiment.js +15 -2
  10. package/dist/cli/commands/experiment.js.map +1 -1
  11. package/dist/cli/commands/login.js +8 -4
  12. package/dist/cli/commands/login.js.map +1 -1
  13. package/dist/cli/commands/memory.js +16 -7
  14. package/dist/cli/commands/memory.js.map +1 -1
  15. package/dist/cli/commands/pipeline-init.d.ts +0 -1
  16. package/dist/cli/commands/pipeline-init.js +32 -46
  17. package/dist/cli/commands/pipeline-init.js.map +1 -1
  18. package/dist/cli/commands/pipeline.js +97 -41
  19. package/dist/cli/commands/pipeline.js.map +1 -1
  20. package/dist/cli/commands/provider.d.ts +6 -0
  21. package/dist/cli/commands/provider.js +100 -0
  22. package/dist/cli/commands/provider.js.map +1 -0
  23. package/dist/cli/commands/shared.d.ts +7 -0
  24. package/dist/cli/commands/shared.js +3 -0
  25. package/dist/cli/commands/shared.js.map +1 -1
  26. package/dist/cli/commands/test.js +1 -1
  27. package/dist/cli/commands/test.js.map +1 -1
  28. package/dist/cli/commands/unconfigure.js +12 -3
  29. package/dist/cli/commands/unconfigure.js.map +1 -1
  30. package/dist/cli/container.d.ts +2 -0
  31. package/dist/cli/container.js +3 -0
  32. package/dist/cli/container.js.map +1 -1
  33. package/dist/cli/isolated-env-runner.js +2 -2
  34. package/dist/cli/isolated-env-runner.js.map +1 -1
  35. package/dist/cli/isolated-env.d.ts +3 -2
  36. package/dist/cli/isolated-env.js +31 -40
  37. package/dist/cli/isolated-env.js.map +1 -1
  38. package/dist/cli/poe-code-command-runner.js +9 -2
  39. package/dist/cli/poe-code-command-runner.js.map +1 -1
  40. package/dist/cli/program.js +5 -0
  41. package/dist/cli/program.js.map +1 -1
  42. package/dist/cli/service-registry.d.ts +7 -7
  43. package/dist/cli/service-registry.js.map +1 -1
  44. package/dist/index.js +2965 -1968
  45. package/dist/index.js.map +4 -4
  46. package/dist/providers/claude-code.d.ts +2 -1
  47. package/dist/providers/claude-code.js +5 -5
  48. package/dist/providers/claude-code.js.map +2 -2
  49. package/dist/providers/codex.d.ts +5 -1
  50. package/dist/providers/codex.js +39 -12
  51. package/dist/providers/codex.js.map +2 -2
  52. package/dist/providers/goose.d.ts +2 -1
  53. package/dist/providers/goose.js +24 -8
  54. package/dist/providers/goose.js.map +3 -3
  55. package/dist/providers/kimi.js +3 -3
  56. package/dist/providers/kimi.js.map +3 -3
  57. package/dist/providers/opencode.js +2 -2
  58. package/dist/providers/opencode.js.map +3 -3
  59. package/dist/providers/poe-agent.js +786 -653
  60. package/dist/providers/poe-agent.js.map +4 -4
  61. package/dist/sdk/container.js +3 -0
  62. package/dist/sdk/container.js.map +1 -1
  63. package/dist/sdk/pipeline.d.ts +1 -2
  64. package/dist/sdk/pipeline.js +58 -9
  65. package/dist/sdk/pipeline.js.map +1 -1
  66. package/dist/services/config.d.ts +1 -0
  67. package/dist/services/config.js +27 -2
  68. package/dist/services/config.js.map +1 -1
  69. package/dist/templates/pipeline/SKILL_plan.md +7 -20
  70. package/dist/templates/pipeline/steps.yaml.mustache +5 -2
  71. package/package.json +10 -1
  72. package/packages/agent-mcp-config/dist/apply.d.ts +6 -0
  73. package/packages/agent-mcp-config/dist/apply.js +175 -0
  74. package/packages/agent-mcp-config/dist/configs.d.ts +22 -0
  75. package/packages/agent-mcp-config/dist/configs.js +74 -0
  76. package/packages/agent-mcp-config/dist/index.d.ts +3 -0
  77. package/packages/agent-mcp-config/dist/index.js +2 -0
  78. package/packages/agent-mcp-config/dist/shapes.d.ts +31 -0
  79. package/packages/agent-mcp-config/dist/shapes.js +87 -0
  80. package/packages/agent-mcp-config/dist/types.d.ts +25 -0
  81. package/packages/agent-mcp-config/dist/types.js +1 -0
  82. package/packages/agent-skill-config/dist/apply.d.ts +25 -0
  83. package/packages/agent-skill-config/dist/apply.js +109 -0
  84. package/packages/agent-skill-config/dist/configs.d.ts +16 -0
  85. package/packages/agent-skill-config/dist/configs.js +66 -0
  86. package/packages/agent-skill-config/dist/exports.compile-check.d.ts +1 -0
  87. package/packages/agent-skill-config/dist/exports.compile-check.js +1 -0
  88. package/packages/agent-skill-config/dist/index.d.ts +5 -0
  89. package/packages/agent-skill-config/dist/index.js +2 -0
  90. package/packages/agent-skill-config/dist/templates/poe-generate.md +47 -0
  91. package/packages/agent-skill-config/dist/templates/terminal-pilot.md +45 -0
  92. package/packages/agent-skill-config/dist/templates.d.ts +3 -0
  93. package/packages/agent-skill-config/dist/templates.js +63 -0
  94. package/packages/agent-skill-config/dist/types.d.ts +16 -0
  95. package/packages/agent-skill-config/dist/types.js +1 -0
  96. package/packages/cmdkit/dist/cli.js +7 -2
  97. package/packages/cmdkit/dist/cli.js.map +2 -2
  98. package/packages/config-mutations/dist/execution/apply-mutation.d.ts +5 -0
  99. package/packages/config-mutations/dist/execution/apply-mutation.js +552 -0
  100. package/packages/config-mutations/dist/execution/path-utils.d.ts +17 -0
  101. package/packages/config-mutations/dist/execution/path-utils.js +58 -0
  102. package/packages/config-mutations/dist/execution/run-mutations.d.ts +7 -0
  103. package/packages/config-mutations/dist/execution/run-mutations.js +46 -0
  104. package/packages/config-mutations/dist/formats/index.d.ts +13 -0
  105. package/packages/config-mutations/dist/formats/index.js +49 -0
  106. package/packages/config-mutations/dist/formats/json.d.ts +31 -0
  107. package/packages/config-mutations/dist/formats/json.js +140 -0
  108. package/packages/config-mutations/dist/formats/toml.d.ts +2 -0
  109. package/packages/config-mutations/dist/formats/toml.js +72 -0
  110. package/packages/config-mutations/dist/formats/yaml.d.ts +2 -0
  111. package/packages/config-mutations/dist/formats/yaml.js +73 -0
  112. package/packages/config-mutations/dist/fs-utils.d.ts +18 -0
  113. package/packages/config-mutations/dist/fs-utils.js +45 -0
  114. package/packages/config-mutations/dist/index.d.ts +8 -0
  115. package/packages/config-mutations/dist/index.js +8 -0
  116. package/packages/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
  117. package/packages/config-mutations/dist/mutations/config-mutation.js +34 -0
  118. package/packages/config-mutations/dist/mutations/file-mutation.d.ts +52 -0
  119. package/packages/config-mutations/dist/mutations/file-mutation.js +46 -0
  120. package/packages/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
  121. package/packages/config-mutations/dist/mutations/template-mutation.js +32 -0
  122. package/packages/config-mutations/dist/template/render.d.ts +7 -0
  123. package/packages/config-mutations/dist/template/render.js +28 -0
  124. package/packages/config-mutations/dist/testing/format-utils.d.ts +7 -0
  125. package/packages/config-mutations/dist/testing/format-utils.js +21 -0
  126. package/packages/config-mutations/dist/testing/index.d.ts +3 -0
  127. package/packages/config-mutations/dist/testing/index.js +2 -0
  128. package/packages/config-mutations/dist/testing/mock-fs.d.ts +25 -0
  129. package/packages/config-mutations/dist/testing/mock-fs.js +170 -0
  130. package/packages/config-mutations/dist/types.d.ts +156 -0
  131. package/packages/config-mutations/dist/types.js +6 -0
  132. package/packages/design-system/dist/dashboard/components/stats-pane.js +2 -1
  133. package/packages/design-system/dist/dashboard/types.d.ts +1 -0
  134. package/packages/memory/dist/audit.d.ts +11 -0
  135. package/packages/memory/dist/audit.js +131 -0
  136. package/packages/memory/dist/cache.cli.d.ts +9 -0
  137. package/packages/memory/dist/cache.cli.js +24 -0
  138. package/packages/memory/dist/cache.d.ts +14 -0
  139. package/packages/memory/dist/cache.js +149 -0
  140. package/packages/memory/dist/confidence.d.ts +4 -0
  141. package/packages/memory/dist/confidence.js +201 -0
  142. package/packages/memory/dist/corpus/001-archaeoastronomy.md +479 -0
  143. package/packages/memory/dist/corpus/002-magnetohydrodynamics.md +475 -0
  144. package/packages/memory/dist/corpus/003-biosemiotics.md +483 -0
  145. package/packages/memory/dist/corpus/004-cryopedology.md +483 -0
  146. package/packages/memory/dist/corpus/005-geomicrobiology.md +479 -0
  147. package/packages/memory/dist/corpus/006-aeronomy.md +487 -0
  148. package/packages/memory/dist/corpus/007-paleoclimatology.md +479 -0
  149. package/packages/memory/dist/corpus/008-hydrogeophysics.md +479 -0
  150. package/packages/memory/dist/corpus/009-magnetostratigraphy.md +475 -0
  151. package/packages/memory/dist/corpus/010-isotope-hydrology.md +481 -0
  152. package/packages/memory/dist/corpus/011-speleothem-geochemistry.md +474 -0
  153. package/packages/memory/dist/corpus/012-astrobiogeochemistry.md +475 -0
  154. package/packages/memory/dist/corpus/013-neuroethology.md +483 -0
  155. package/packages/memory/dist/corpus/014-chronophysiology.md +483 -0
  156. package/packages/memory/dist/corpus/015-limnogeochemistry.md +475 -0
  157. package/packages/memory/dist/corpus/016-palynology.md +483 -0
  158. package/packages/memory/dist/corpus/017-volcanotectonics.md +473 -0
  159. package/packages/memory/dist/corpus/018-seismotectonics.md +473 -0
  160. package/packages/memory/dist/corpus/019-biogeomorphology.md +475 -0
  161. package/packages/memory/dist/corpus/020-geobiophysics.md +479 -0
  162. package/packages/memory/dist/corpus/021-phytolith-analysis.md +481 -0
  163. package/packages/memory/dist/corpus/022-archaeometallurgy.md +479 -0
  164. package/packages/memory/dist/corpus/023-paleomagnetism.md +479 -0
  165. package/packages/memory/dist/corpus/024-biocalorimetry.md +475 -0
  166. package/packages/memory/dist/corpus/025-atmospheric-chemiluminescence.md +473 -0
  167. package/packages/memory/dist/corpus/026-cryoseismology.md +479 -0
  168. package/packages/memory/dist/corpus/027-extremophile-radiobiology.md +475 -0
  169. package/packages/memory/dist/corpus/028-heliophysics.md +479 -0
  170. package/packages/memory/dist/corpus/029-astroparticle-geophysics.md +474 -0
  171. package/packages/memory/dist/corpus/030-glaciohydrology.md +479 -0
  172. package/packages/memory/dist/corpus/031-permafrost-microbiology.md +477 -0
  173. package/packages/memory/dist/corpus/032-ecoacoustics.md +479 -0
  174. package/packages/memory/dist/corpus/033-dendroclimatology.md +473 -0
  175. package/packages/memory/dist/corpus/034-ionospheric-tomography.md +477 -0
  176. package/packages/memory/dist/corpus/035-marine-geodesy.md +481 -0
  177. package/packages/memory/dist/corpus/036-sedimentary-ancient-dna.md +481 -0
  178. package/packages/memory/dist/corpus/037-myrmecochory-dynamics.md +474 -0
  179. package/packages/memory/dist/corpus/038-chemosensory-ecology.md +477 -0
  180. package/packages/memory/dist/corpus/039-spintronics-materials.md +479 -0
  181. package/packages/memory/dist/corpus/040-nanotoxicology.md +483 -0
  182. package/packages/memory/dist/corpus/041-cosmochemistry.md +483 -0
  183. package/packages/memory/dist/corpus/042-quaternary-geochronology.md +471 -0
  184. package/packages/memory/dist/corpus/043-biophotonics.md +479 -0
  185. package/packages/memory/dist/corpus/044-evolutionary-morphometrics.md +481 -0
  186. package/packages/memory/dist/corpus/045-cryovolcanology.md +475 -0
  187. package/packages/memory/dist/corpus/046-exoplanet-atmospheric-dynamics.md +479 -0
  188. package/packages/memory/dist/corpus/047-microbial-electrosynthesis.md +477 -0
  189. package/packages/memory/dist/corpus/048-paleoseismology.md +479 -0
  190. package/packages/memory/dist/corpus/049-actinide-geochemistry.md +477 -0
  191. package/packages/memory/dist/corpus/050-quantum-biology.md +489 -0
  192. package/packages/memory/dist/edit.d.ts +10 -0
  193. package/packages/memory/dist/edit.js +43 -0
  194. package/packages/memory/dist/explain.cli.d.ts +8 -0
  195. package/packages/memory/dist/explain.cli.js +9 -0
  196. package/packages/memory/dist/explain.d.ts +8 -0
  197. package/packages/memory/dist/explain.js +77 -0
  198. package/packages/memory/dist/frontmatter.d.ts +9 -0
  199. package/packages/memory/dist/frontmatter.js +217 -0
  200. package/packages/memory/dist/index.d.ts +21 -0
  201. package/packages/memory/dist/index.js +4807 -0
  202. package/packages/memory/dist/index.js.map +7 -0
  203. package/packages/memory/dist/ingest.d.ts +3 -0
  204. package/packages/memory/dist/ingest.js +118 -0
  205. package/packages/memory/dist/init.d.ts +2 -0
  206. package/packages/memory/dist/init.js +24 -0
  207. package/packages/memory/dist/install.d.ts +18 -0
  208. package/packages/memory/dist/install.js +50 -0
  209. package/packages/memory/dist/lock.d.ts +19 -0
  210. package/packages/memory/dist/lock.js +102 -0
  211. package/packages/memory/dist/mcp.d.ts +7 -0
  212. package/packages/memory/dist/mcp.js +58 -0
  213. package/packages/memory/dist/pages.d.ts +4 -0
  214. package/packages/memory/dist/pages.js +92 -0
  215. package/packages/memory/dist/paths.d.ts +12 -0
  216. package/packages/memory/dist/paths.js +34 -0
  217. package/packages/memory/dist/query.d.ts +10 -0
  218. package/packages/memory/dist/query.js +130 -0
  219. package/packages/memory/dist/reconcile.d.ts +9 -0
  220. package/packages/memory/dist/reconcile.js +138 -0
  221. package/packages/memory/dist/resolve-root.d.ts +11 -0
  222. package/packages/memory/dist/resolve-root.js +22 -0
  223. package/packages/memory/dist/search.d.ts +2 -0
  224. package/packages/memory/dist/search.js +29 -0
  225. package/packages/memory/dist/status.d.ts +7 -0
  226. package/packages/memory/dist/status.js +46 -0
  227. package/packages/memory/dist/tokens.d.ts +2 -0
  228. package/packages/memory/dist/tokens.js +71 -0
  229. package/packages/memory/dist/types.d.ts +155 -0
  230. package/packages/memory/dist/types.js +1 -0
  231. package/packages/memory/dist/write.d.ts +9 -0
  232. package/packages/memory/dist/write.js +76 -0
@@ -16,9 +16,9 @@ var __export = (target, all) => {
16
16
  };
17
17
  var __copyProps = (to, from, except, desc) => {
18
18
  if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ for (let key2 of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key2) && key2 !== except)
21
+ __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
22
22
  }
23
23
  return to;
24
24
  };
@@ -609,8 +609,8 @@ function resourceNotFound(resource) {
609
609
  `Resource not found: ${resource}`
610
610
  );
611
611
  }
612
- function assertAbsolutePath(path26) {
613
- if (!isAbsolute(path26)) {
612
+ function assertAbsolutePath(path28) {
613
+ if (!isAbsolute(path28)) {
614
614
  throw invalidParams('"path" must be an absolute path');
615
615
  }
616
616
  }
@@ -1411,8 +1411,8 @@ function cloneUnknown(value) {
1411
1411
  }
1412
1412
  if (typeof value === "object" && value !== null) {
1413
1413
  const cloned = {};
1414
- for (const [key, entry] of Object.entries(value)) {
1415
- cloned[key] = cloneUnknown(entry);
1414
+ for (const [key2, entry] of Object.entries(value)) {
1415
+ cloned[key2] = cloneUnknown(entry);
1416
1416
  }
1417
1417
  return cloned;
1418
1418
  }
@@ -1572,46 +1572,46 @@ function toOptionsObject(input) {
1572
1572
  return input;
1573
1573
  }
1574
1574
  function rejectUnknownKeys(input, allowedKeys) {
1575
- for (const key of Object.keys(input)) {
1576
- if (!allowedKeys.includes(key)) {
1577
- throw new Error(`${key}: unknown option`);
1575
+ for (const key2 of Object.keys(input)) {
1576
+ if (!allowedKeys.includes(key2)) {
1577
+ throw new Error(`${key2}: unknown option`);
1578
1578
  }
1579
1579
  }
1580
1580
  }
1581
- function readOptionalString(input, key) {
1582
- const value = input[key];
1581
+ function readOptionalString(input, key2) {
1582
+ const value = input[key2];
1583
1583
  if (value === void 0) {
1584
1584
  return void 0;
1585
1585
  }
1586
1586
  if (typeof value !== "string") {
1587
- throw new Error(`${key}: expected a string`);
1587
+ throw new Error(`${key2}: expected a string`);
1588
1588
  }
1589
1589
  return value;
1590
1590
  }
1591
- function readOptionalStringArray(input, key) {
1592
- const value = input[key];
1591
+ function readOptionalStringArray(input, key2) {
1592
+ const value = input[key2];
1593
1593
  if (value === void 0) {
1594
1594
  return void 0;
1595
1595
  }
1596
1596
  if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) {
1597
- throw new Error(`${key}: expected an array of strings`);
1597
+ throw new Error(`${key2}: expected an array of strings`);
1598
1598
  }
1599
1599
  return value;
1600
1600
  }
1601
- function readOptionalNonNegativeInteger(input, key) {
1602
- const value = input[key];
1601
+ function readOptionalNonNegativeInteger(input, key2) {
1602
+ const value = input[key2];
1603
1603
  if (value === void 0) {
1604
1604
  return void 0;
1605
1605
  }
1606
1606
  if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
1607
- throw new Error(`${key}: expected a non-negative integer`);
1607
+ throw new Error(`${key2}: expected a non-negative integer`);
1608
1608
  }
1609
1609
  return value;
1610
1610
  }
1611
- function readRequiredEnum(input, key, allowedValues) {
1612
- const value = input[key];
1611
+ function readRequiredEnum(input, key2, allowedValues) {
1612
+ const value = input[key2];
1613
1613
  if (typeof value !== "string" || !allowedValues.includes(value)) {
1614
- throw new Error(`${key}: expected one of ${allowedValues.join(", ")}`);
1614
+ throw new Error(`${key2}: expected one of ${allowedValues.join(", ")}`);
1615
1615
  }
1616
1616
  return value;
1617
1617
  }
@@ -1645,12 +1645,7 @@ var init_poe_agent_plugin_policy = __esm({
1645
1645
  },
1646
1646
  async preToolUse(ctx) {
1647
1647
  const mode = ctx.session.get(POLICY_MODE_SESSION_KEY);
1648
- if (mode === void 0) {
1649
- return {
1650
- reject: "Policy mode is unavailable for this session."
1651
- };
1652
- }
1653
- if (mode === "yolo") {
1648
+ if (mode === void 0 || mode === "yolo") {
1654
1649
  return;
1655
1650
  }
1656
1651
  const tool = getTool(ctx.tool);
@@ -2301,8 +2296,12 @@ async function runLoop(options) {
2301
2296
  if (collectedResponse.toolOutcomes.length === 0) {
2302
2297
  return {
2303
2298
  output: collectedResponse.content,
2299
+ stdout: collectedResponse.content,
2300
+ summary: collectedResponse.content,
2304
2301
  messages: [...options.runContext.messages],
2305
- toolCalls: [...options.toolCalls]
2302
+ toolCalls: [...options.toolCalls],
2303
+ exitCode: 0,
2304
+ stderr: ""
2306
2305
  };
2307
2306
  }
2308
2307
  }
@@ -2922,68 +2921,68 @@ import path7 from "node:path";
2922
2921
  function isObjectRecord4(value) {
2923
2922
  return typeof value === "object" && value !== null && !Array.isArray(value);
2924
2923
  }
2925
- function getRequiredString(args, key, allowEmptyString = false) {
2924
+ function getRequiredString(args, key2, allowEmptyString = false) {
2926
2925
  if (!isObjectRecord4(args)) {
2927
- throw new Error(`Tool argument "${key}" must be a string`);
2926
+ throw new Error(`Tool argument "${key2}" must be a string`);
2928
2927
  }
2929
- const value = args[key];
2928
+ const value = args[key2];
2930
2929
  if (typeof value !== "string") {
2931
- throw new Error(`Tool argument "${key}" must be a string`);
2930
+ throw new Error(`Tool argument "${key2}" must be a string`);
2932
2931
  }
2933
2932
  if (!allowEmptyString && value.trim().length === 0) {
2934
- throw new Error(`Tool argument "${key}" must not be empty`);
2933
+ throw new Error(`Tool argument "${key2}" must not be empty`);
2935
2934
  }
2936
2935
  return value;
2937
2936
  }
2938
- function getOptionalString(args, key) {
2937
+ function getOptionalString(args, key2) {
2939
2938
  if (!isObjectRecord4(args)) {
2940
- throw new Error(`Tool argument "${key}" must be a string`);
2939
+ throw new Error(`Tool argument "${key2}" must be a string`);
2941
2940
  }
2942
- const value = args[key];
2941
+ const value = args[key2];
2943
2942
  if (value === void 0) {
2944
2943
  return void 0;
2945
2944
  }
2946
2945
  if (typeof value !== "string") {
2947
- throw new Error(`Tool argument "${key}" must be a string`);
2946
+ throw new Error(`Tool argument "${key2}" must be a string`);
2948
2947
  }
2949
2948
  return value;
2950
2949
  }
2951
- function getOptionalBoolean(args, key) {
2950
+ function getOptionalBoolean(args, key2) {
2952
2951
  if (!isObjectRecord4(args)) {
2953
- throw new Error(`Tool argument "${key}" must be a boolean`);
2952
+ throw new Error(`Tool argument "${key2}" must be a boolean`);
2954
2953
  }
2955
- const value = args[key];
2954
+ const value = args[key2];
2956
2955
  if (value === void 0) {
2957
2956
  return void 0;
2958
2957
  }
2959
2958
  if (typeof value !== "boolean") {
2960
- throw new Error(`Tool argument "${key}" must be a boolean`);
2959
+ throw new Error(`Tool argument "${key2}" must be a boolean`);
2961
2960
  }
2962
2961
  return value;
2963
2962
  }
2964
- function getOptionalNumber(args, key) {
2963
+ function getOptionalNumber(args, key2) {
2965
2964
  if (!isObjectRecord4(args)) {
2966
- throw new Error(`Tool argument "${key}" must be a number`);
2965
+ throw new Error(`Tool argument "${key2}" must be a number`);
2967
2966
  }
2968
- const value = args[key];
2967
+ const value = args[key2];
2969
2968
  if (value === void 0) {
2970
2969
  return void 0;
2971
2970
  }
2972
2971
  if (typeof value !== "number" || !Number.isFinite(value)) {
2973
- throw new Error(`Tool argument "${key}" must be a finite number`);
2972
+ throw new Error(`Tool argument "${key2}" must be a finite number`);
2974
2973
  }
2975
2974
  return value;
2976
2975
  }
2977
- function getOptionalNonNegativeInteger(args, key) {
2976
+ function getOptionalNonNegativeInteger(args, key2) {
2978
2977
  if (!isObjectRecord4(args)) {
2979
- throw new Error(`Tool argument "${key}" must be a non-negative integer`);
2978
+ throw new Error(`Tool argument "${key2}" must be a non-negative integer`);
2980
2979
  }
2981
- const value = args[key];
2980
+ const value = args[key2];
2982
2981
  if (value === void 0) {
2983
2982
  return void 0;
2984
2983
  }
2985
2984
  if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
2986
- throw new Error(`Tool argument "${key}" must be a non-negative integer`);
2985
+ throw new Error(`Tool argument "${key2}" must be a non-negative integer`);
2987
2986
  }
2988
2987
  return value;
2989
2988
  }
@@ -3013,9 +3012,9 @@ import fsPromises2 from "node:fs/promises";
3013
3012
  import path8 from "node:path";
3014
3013
  import { promisify } from "node:util";
3015
3014
  import fastGlob from "fast-glob";
3016
- async function fileExists(fs3, filePath) {
3015
+ async function fileExists(fs4, filePath) {
3017
3016
  try {
3018
- await fs3.stat(filePath);
3017
+ await fs4.stat(filePath);
3019
3018
  return true;
3020
3019
  } catch {
3021
3020
  return false;
@@ -3033,13 +3032,13 @@ function countOccurrences(text4, search) {
3033
3032
  }
3034
3033
  return count;
3035
3034
  }
3036
- function getOptionalGrepOutputMode(args, key) {
3035
+ function getOptionalGrepOutputMode(args, key2) {
3037
3036
  if (!isObjectRecord4(args)) {
3038
3037
  throw new Error(
3039
- `Tool argument "${key}" must be one of "files_with_matches", "content", or "count"`
3038
+ `Tool argument "${key2}" must be one of "files_with_matches", "content", or "count"`
3040
3039
  );
3041
3040
  }
3042
- const value = args[key];
3041
+ const value = args[key2];
3043
3042
  if (value === void 0) {
3044
3043
  return void 0;
3045
3044
  }
@@ -3047,17 +3046,17 @@ function getOptionalGrepOutputMode(args, key) {
3047
3046
  return value;
3048
3047
  }
3049
3048
  throw new Error(
3050
- `Tool argument "${key}" must be one of "files_with_matches", "content", or "count"`
3049
+ `Tool argument "${key2}" must be one of "files_with_matches", "content", or "count"`
3051
3050
  );
3052
3051
  }
3053
3052
  function formatDisplayPath(cwd, filePath) {
3054
3053
  return path8.relative(cwd, filePath) || path8.basename(filePath);
3055
3054
  }
3056
- async function sortPathsByModifiedTime(matches2, fs3) {
3055
+ async function sortPathsByModifiedTime(matches2, fs4) {
3057
3056
  const entries = await Promise.all(
3058
3057
  matches2.map(async (match) => ({
3059
3058
  path: match,
3060
- mtimeMs: (await fs3.stat(match)).mtimeMs
3059
+ mtimeMs: (await fs4.stat(match)).mtimeMs
3061
3060
  }))
3062
3061
  );
3063
3062
  entries.sort((left, right) => {
@@ -3068,8 +3067,8 @@ async function sortPathsByModifiedTime(matches2, fs3) {
3068
3067
  });
3069
3068
  return entries.map((entry) => entry.path);
3070
3069
  }
3071
- async function defaultSearchContent(options, fs3) {
3072
- const targetStat = await fs3.stat(options.path);
3070
+ async function defaultSearchContent(options, fs4) {
3071
+ const targetStat = await fs4.stat(options.path);
3073
3072
  const searchCwd = targetStat.isDirectory() ? options.path : path8.dirname(options.path);
3074
3073
  const searchTarget = targetStat.isDirectory() ? "." : path8.basename(options.path);
3075
3074
  const args = ["--color", "never"];
@@ -3200,8 +3199,8 @@ var init_poe_agent_plugin_files = __esm({
3200
3199
  const allowedPaths = (options.allowedPaths ?? [cwd]).map(
3201
3200
  (allowedPath) => path8.resolve(cwd, allowedPath)
3202
3201
  );
3203
- const fs3 = options.fs ?? fsPromises2;
3204
- const searchContent = options.searchContent ?? ((searchOptions) => defaultSearchContent(searchOptions, fs3));
3202
+ const fs4 = options.fs ?? fsPromises2;
3203
+ const searchContent = options.searchContent ?? ((searchOptions) => defaultSearchContent(searchOptions, fs4));
3205
3204
  const globFiles = options.globFiles ?? defaultGlobFiles;
3206
3205
  const readFileTool = {
3207
3206
  name: "read_file",
@@ -3234,14 +3233,14 @@ var init_poe_agent_plugin_files = __esm({
3234
3233
  const filePath = resolveAllowedPath(cwd, allowedPaths, getRequiredString(args, "path"));
3235
3234
  const imageMimeType = detectImageMimeType(filePath);
3236
3235
  if (imageMimeType !== void 0) {
3237
- const content2 = await fs3.readFile(filePath);
3236
+ const content2 = await fs4.readFile(filePath);
3238
3237
  return {
3239
3238
  type: "image",
3240
3239
  mimeType: imageMimeType,
3241
3240
  data: Buffer.from(content2).toString("base64")
3242
3241
  };
3243
3242
  }
3244
- const content = await fs3.readFile(filePath, "utf8");
3243
+ const content = await fs4.readFile(filePath, "utf8");
3245
3244
  return sliceLines(
3246
3245
  content,
3247
3246
  getOptionalNonNegativeInteger(args, "offset") ?? 0,
@@ -3295,7 +3294,7 @@ var init_poe_agent_plugin_files = __esm({
3295
3294
  const oldStr = getRequiredString(args, "old_str", true);
3296
3295
  const newStr = getRequiredString(args, "new_str", true);
3297
3296
  const replaceAll = getOptionalBoolean(args, "replace_all") ?? false;
3298
- const content = await fs3.readFile(filePath, "utf8");
3297
+ const content = await fs4.readFile(filePath, "utf8");
3299
3298
  if (oldStr.length === 0) {
3300
3299
  throw new Error('Tool argument "old_str" must not be empty');
3301
3300
  }
@@ -3306,7 +3305,7 @@ var init_poe_agent_plugin_files = __esm({
3306
3305
  if (!replaceAll && count > 1) {
3307
3306
  throw new Error(`old_str appears ${count} times \u2014 must be unique`);
3308
3307
  }
3309
- await fs3.writeFile(
3308
+ await fs4.writeFile(
3310
3309
  filePath,
3311
3310
  replaceAll ? content.split(oldStr).join(newStr) : content.replace(oldStr, newStr),
3312
3311
  "utf8"
@@ -3315,17 +3314,17 @@ var init_poe_agent_plugin_files = __esm({
3315
3314
  }
3316
3315
  if (command === "create") {
3317
3316
  const fileText = getRequiredString(args, "file_text", true);
3318
- if (await fileExists(fs3, filePath)) {
3317
+ if (await fileExists(fs4, filePath)) {
3319
3318
  throw new Error("File already exists \u2014 use str_replace to edit");
3320
3319
  }
3321
- await fs3.mkdir(path8.dirname(filePath), { recursive: true });
3322
- await fs3.writeFile(filePath, fileText, "utf8");
3320
+ await fs4.mkdir(path8.dirname(filePath), { recursive: true });
3321
+ await fs4.writeFile(filePath, fileText, "utf8");
3323
3322
  return `Created file: ${displayedPath}`;
3324
3323
  }
3325
3324
  if (command === "overwrite") {
3326
3325
  const fileText = getRequiredString(args, "file_text", true);
3327
- await fs3.mkdir(path8.dirname(filePath), { recursive: true });
3328
- await fs3.writeFile(filePath, fileText, "utf8");
3326
+ await fs4.mkdir(path8.dirname(filePath), { recursive: true });
3327
+ await fs4.writeFile(filePath, fileText, "utf8");
3329
3328
  return `Overwrote file: ${displayedPath}`;
3330
3329
  }
3331
3330
  throw new Error(`Unknown edit_file command: ${command}`);
@@ -3350,7 +3349,7 @@ var init_poe_agent_plugin_files = __esm({
3350
3349
  async call(args) {
3351
3350
  const rawPath = getOptionalString(args, "path") ?? ".";
3352
3351
  const directoryPath = resolveAllowedPath(cwd, allowedPaths, rawPath);
3353
- const entries = await fs3.readdir(directoryPath);
3352
+ const entries = await fs4.readdir(directoryPath);
3354
3353
  const names = entries.sort((left, right) => left.localeCompare(right));
3355
3354
  if (names.length === 0) {
3356
3355
  return "(empty directory)";
@@ -3446,7 +3445,7 @@ var init_poe_agent_plugin_files = __esm({
3446
3445
  });
3447
3446
  const sortedMatches = await sortPathsByModifiedTime(
3448
3447
  matches2.map((match) => resolveAllowedPath(cwd, allowedPaths, match)),
3449
- fs3
3448
+ fs4
3450
3449
  );
3451
3450
  if (sortedMatches.length === 0) {
3452
3451
  return "(no matches)";
@@ -3609,7 +3608,7 @@ var init_encrypted_file_store = __esm({
3609
3608
  if (!document) {
3610
3609
  return null;
3611
3610
  }
3612
- const key = await this.getEncryptionKey();
3611
+ const key2 = await this.getEncryptionKey();
3613
3612
  try {
3614
3613
  const iv = Buffer.from(document.iv, "base64");
3615
3614
  const authTag = Buffer.from(document.authTag, "base64");
@@ -3617,7 +3616,7 @@ var init_encrypted_file_store = __esm({
3617
3616
  if (iv.byteLength !== ENCRYPTION_IV_BYTES || authTag.byteLength !== ENCRYPTION_AUTH_TAG_BYTES) {
3618
3617
  return null;
3619
3618
  }
3620
- const decipher = createDecipheriv(ENCRYPTION_ALGORITHM, key, iv);
3619
+ const decipher = createDecipheriv(ENCRYPTION_ALGORITHM, key2, iv);
3621
3620
  decipher.setAuthTag(authTag);
3622
3621
  const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
3623
3622
  return plaintext.toString("utf8");
@@ -3626,9 +3625,9 @@ var init_encrypted_file_store = __esm({
3626
3625
  }
3627
3626
  }
3628
3627
  async set(value) {
3629
- const key = await this.getEncryptionKey();
3628
+ const key2 = await this.getEncryptionKey();
3630
3629
  const iv = this.getRandomBytes(ENCRYPTION_IV_BYTES);
3631
- const cipher = createCipheriv(ENCRYPTION_ALGORITHM, key, iv);
3630
+ const cipher = createCipheriv(ENCRYPTION_ALGORITHM, key2, iv);
3632
3631
  const ciphertext = Buffer.concat([
3633
3632
  cipher.update(value, "utf8"),
3634
3633
  cipher.final()
@@ -3838,6 +3837,13 @@ var init_create_secret_store = __esm({
3838
3837
  }
3839
3838
  });
3840
3839
 
3840
+ // packages/auth-store/src/provider-store.ts
3841
+ var init_provider_store = __esm({
3842
+ "packages/auth-store/src/provider-store.ts"() {
3843
+ "use strict";
3844
+ }
3845
+ });
3846
+
3841
3847
  // packages/auth-store/src/index.ts
3842
3848
  var init_src2 = __esm({
3843
3849
  "packages/auth-store/src/index.ts"() {
@@ -3845,6 +3851,7 @@ var init_src2 = __esm({
3845
3851
  init_create_secret_store();
3846
3852
  init_encrypted_file_store();
3847
3853
  init_keychain_store();
3854
+ init_provider_store();
3848
3855
  }
3849
3856
  });
3850
3857
 
@@ -4204,19 +4211,19 @@ function resolveClientBaseUrl(baseUrl) {
4204
4211
  }
4205
4212
  return DEFAULT_BASE_URL;
4206
4213
  }
4207
- function readOptionalStringRecord(input, key) {
4208
- const value = input[key];
4214
+ function readOptionalStringRecord(input, key2) {
4215
+ const value = input[key2];
4209
4216
  if (value === void 0) {
4210
4217
  return void 0;
4211
4218
  }
4212
4219
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
4213
- throw new Error(`${key}: expected an object of string values`);
4220
+ throw new Error(`${key2}: expected an object of string values`);
4214
4221
  }
4215
4222
  const entries = Object.entries(value);
4216
4223
  const record = {};
4217
4224
  for (const [entryKey, entryValue] of entries) {
4218
4225
  if (typeof entryValue !== "string") {
4219
- throw new Error(`${key}: expected an object of string values`);
4226
+ throw new Error(`${key2}: expected an object of string values`);
4220
4227
  }
4221
4228
  record[entryKey] = entryValue;
4222
4229
  }
@@ -4745,28 +4752,28 @@ function resolveClientBaseUrl2(baseUrl) {
4745
4752
  }
4746
4753
  return DEFAULT_BASE_URL2;
4747
4754
  }
4748
- function readOptionalEnum(input, key, allowedValues) {
4749
- const value = input[key];
4755
+ function readOptionalEnum(input, key2, allowedValues) {
4756
+ const value = input[key2];
4750
4757
  if (value === void 0) {
4751
4758
  return void 0;
4752
4759
  }
4753
4760
  if (typeof value !== "string" || !allowedValues.includes(value)) {
4754
- throw new Error(`${key}: expected one of ${allowedValues.join(", ")}`);
4761
+ throw new Error(`${key2}: expected one of ${allowedValues.join(", ")}`);
4755
4762
  }
4756
4763
  return value;
4757
4764
  }
4758
- function readOptionalStringRecord2(input, key) {
4759
- const value = input[key];
4765
+ function readOptionalStringRecord2(input, key2) {
4766
+ const value = input[key2];
4760
4767
  if (value === void 0) {
4761
4768
  return void 0;
4762
4769
  }
4763
4770
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
4764
- throw new Error(`${key}: expected an object of string values`);
4771
+ throw new Error(`${key2}: expected an object of string values`);
4765
4772
  }
4766
4773
  const record = {};
4767
4774
  for (const [entryKey, entryValue] of Object.entries(value)) {
4768
4775
  if (typeof entryValue !== "string") {
4769
- throw new Error(`${key}: expected an object of string values`);
4776
+ throw new Error(`${key2}: expected an object of string values`);
4770
4777
  }
4771
4778
  record[entryKey] = entryValue;
4772
4779
  }
@@ -5990,11 +5997,11 @@ async function loadMemory(options) {
5990
5997
  }
5991
5998
  return sections.join("\n\n");
5992
5999
  }
5993
- async function findNearestAgentsFile(cwd, fs3) {
6000
+ async function findNearestAgentsFile(cwd, fs4) {
5994
6001
  let currentDirectory = cwd;
5995
6002
  while (true) {
5996
6003
  const filePath = path11.join(currentDirectory, AGENTS_FILE);
5997
- if (await readOptionalFile(filePath, fs3) !== void 0) {
6004
+ if (await readOptionalFile(filePath, fs4) !== void 0) {
5998
6005
  return filePath;
5999
6006
  }
6000
6007
  const parentDirectory = path11.dirname(currentDirectory);
@@ -6004,15 +6011,15 @@ async function findNearestAgentsFile(cwd, fs3) {
6004
6011
  currentDirectory = parentDirectory;
6005
6012
  }
6006
6013
  }
6007
- async function loadOptionalMemoryFile(filePath, fs3) {
6008
- const content = await readOptionalFile(filePath, fs3);
6014
+ async function loadOptionalMemoryFile(filePath, fs4) {
6015
+ const content = await readOptionalFile(filePath, fs4);
6009
6016
  if (content === void 0) {
6010
6017
  return void 0;
6011
6018
  }
6012
6019
  return await expandImports({
6013
6020
  filePath,
6014
6021
  content,
6015
- fs: fs3,
6022
+ fs: fs4,
6016
6023
  loading: /* @__PURE__ */ new Set()
6017
6024
  });
6018
6025
  }
@@ -6063,9 +6070,9 @@ ${content}`;
6063
6070
  function normalizeLineEndings(content) {
6064
6071
  return content.split("\r\n").join("\n");
6065
6072
  }
6066
- async function readOptionalFile(filePath, fs3) {
6073
+ async function readOptionalFile(filePath, fs4) {
6067
6074
  try {
6068
- return await fs3.readFile(filePath, "utf8");
6075
+ return await fs4.readFile(filePath, "utf8");
6069
6076
  } catch (error2) {
6070
6077
  if (isMissingFileError(error2)) {
6071
6078
  return void 0;
@@ -6073,8 +6080,8 @@ async function readOptionalFile(filePath, fs3) {
6073
6080
  throw error2;
6074
6081
  }
6075
6082
  }
6076
- async function readRequiredFile(filePath, fs3) {
6077
- const content = await readOptionalFile(filePath, fs3);
6083
+ async function readRequiredFile(filePath, fs4) {
6084
+ const content = await readOptionalFile(filePath, fs4);
6078
6085
  if (content !== void 0) {
6079
6086
  return content;
6080
6087
  }
@@ -6096,12 +6103,12 @@ var init_poe_agent_plugin_memory = __esm({
6096
6103
  memoryPlugin = (options = {}) => {
6097
6104
  const cwd = path11.resolve(options.cwd ?? process.cwd());
6098
6105
  const homeDir = path11.resolve(options.homeDir ?? os.homedir());
6099
- const fs3 = options.fs ?? fsPromises3;
6106
+ const fs4 = options.fs ?? fsPromises3;
6100
6107
  let memoryPromise;
6101
6108
  return {
6102
6109
  name: "poe-agent-plugin-memory",
6103
6110
  async prompt(ctx) {
6104
- memoryPromise ??= loadMemory({ cwd, homeDir, fs: fs3 });
6111
+ memoryPromise ??= loadMemory({ cwd, homeDir, fs: fs4 });
6105
6112
  const memory = await memoryPromise;
6106
6113
  if (!memory) {
6107
6114
  return ctx;
@@ -6168,9 +6175,9 @@ function parsePluginConfigEntry(input) {
6168
6175
  if (!isPlainObject2(input)) {
6169
6176
  throw new PluginConfigError("agent.plugins: must be an object.");
6170
6177
  }
6171
- for (const key of Object.keys(input)) {
6172
- if (key !== "name" && key !== "options") {
6173
- throw new PluginConfigError(`agent.plugins: unknown key "${key}".`);
6178
+ for (const key2 of Object.keys(input)) {
6179
+ if (key2 !== "name" && key2 !== "options") {
6180
+ throw new PluginConfigError(`agent.plugins: unknown key "${key2}".`);
6174
6181
  }
6175
6182
  }
6176
6183
  const name = input.name;
@@ -8487,7 +8494,115 @@ var init_resolve_provider = __esm({
8487
8494
  }
8488
8495
  });
8489
8496
 
8497
+ // packages/poe-agent/src/runtime/transcript.ts
8498
+ import path12 from "node:path";
8499
+ function mapAcpEventToSessionUpdates(event) {
8500
+ if (event.type === "message.delta") {
8501
+ if (event.content.length === 0) return [];
8502
+ return [{ sessionUpdate: "agent_message_chunk", content: { type: "text", text: event.content } }];
8503
+ }
8504
+ if (event.type === "tool.intent") {
8505
+ return [
8506
+ {
8507
+ sessionUpdate: "tool_call",
8508
+ toolCallId: event.intentId,
8509
+ title: event.tool,
8510
+ kind: "execute",
8511
+ status: "pending",
8512
+ rawInput: event.args
8513
+ },
8514
+ {
8515
+ sessionUpdate: "tool_call_update",
8516
+ toolCallId: event.intentId,
8517
+ kind: "execute",
8518
+ status: "in_progress"
8519
+ }
8520
+ ];
8521
+ }
8522
+ if (event.type === "tool.result") {
8523
+ return [
8524
+ {
8525
+ sessionUpdate: "tool_call_update",
8526
+ toolCallId: event.intentId,
8527
+ kind: "execute",
8528
+ status: "completed",
8529
+ rawOutput: event.result
8530
+ }
8531
+ ];
8532
+ }
8533
+ if (event.type === "tool.error") {
8534
+ return [
8535
+ {
8536
+ sessionUpdate: "tool_call_update",
8537
+ toolCallId: event.intentId,
8538
+ kind: "execute",
8539
+ status: "failed",
8540
+ rawOutput: event.error
8541
+ }
8542
+ ];
8543
+ }
8544
+ if (event.type === "usage") {
8545
+ const { inputTokens, outputTokens, cachedTokens, cacheCreationTokens } = event.usage;
8546
+ const nonCachedInput = Math.max(0, inputTokens - cachedTokens);
8547
+ return [
8548
+ {
8549
+ sessionUpdate: "usage_update",
8550
+ used: nonCachedInput,
8551
+ size: inputTokens,
8552
+ _meta: { inputTokens, outputTokens, cachedTokens, cacheCreationTokens }
8553
+ }
8554
+ ];
8555
+ }
8556
+ return [];
8557
+ }
8558
+ function createTranscriptWriter(options) {
8559
+ const join2 = options.pathJoin ?? path12.join;
8560
+ const filePath = resolveTranscriptFilePath(options, join2);
8561
+ let dirEnsured;
8562
+ let disabled = false;
8563
+ const logDir = path12.dirname(filePath);
8564
+ const ensureDir = () => {
8565
+ if (!dirEnsured) {
8566
+ dirEnsured = options.fs.mkdir(logDir, { recursive: true });
8567
+ }
8568
+ return dirEnsured;
8569
+ };
8570
+ return {
8571
+ filePath,
8572
+ async write(event) {
8573
+ if (disabled) return;
8574
+ const updates = mapAcpEventToSessionUpdates(event);
8575
+ if (updates.length === 0) return;
8576
+ try {
8577
+ await ensureDir();
8578
+ const payload = updates.map((update) => `${JSON.stringify(update)}
8579
+ `).join("");
8580
+ await options.fs.appendFile(filePath, payload);
8581
+ } catch {
8582
+ disabled = true;
8583
+ }
8584
+ },
8585
+ async close() {
8586
+ }
8587
+ };
8588
+ }
8589
+ function resolveTranscriptFilePath(options, join2) {
8590
+ if (options.logPath) {
8591
+ return options.logPath;
8592
+ }
8593
+ if (options.logDir && options.logFileName) {
8594
+ return join2(options.logDir, options.logFileName);
8595
+ }
8596
+ throw new Error("createTranscriptWriter requires logPath or logDir + logFileName.");
8597
+ }
8598
+ var init_transcript = __esm({
8599
+ "packages/poe-agent/src/runtime/transcript.ts"() {
8600
+ "use strict";
8601
+ }
8602
+ });
8603
+
8490
8604
  // packages/poe-agent/src/agent.ts
8605
+ import * as fsPromises4 from "node:fs/promises";
8491
8606
  function agent() {
8492
8607
  return new ImmutableAgentBuilder();
8493
8608
  }
@@ -8515,6 +8630,19 @@ function toSpawnMcpServers(mcpServers) {
8515
8630
  }
8516
8631
  return byName;
8517
8632
  }
8633
+ function normalizeMcpConfigs(configsOrMap) {
8634
+ const [first, ...rest] = configsOrMap;
8635
+ if (first === void 0) {
8636
+ return [];
8637
+ }
8638
+ if (rest.length > 0 || isNamedMcpServerConfig(first)) {
8639
+ return [first, ...rest];
8640
+ }
8641
+ return Object.entries(first).map(([name, server]) => ({ name, ...server }));
8642
+ }
8643
+ function isNamedMcpServerConfig(value) {
8644
+ return typeof value === "object" && value !== null && typeof value.name === "string" && typeof value.command === "string";
8645
+ }
8518
8646
  function resolveActiveSkills(options) {
8519
8647
  if (options.skills !== void 0) {
8520
8648
  return options.skills;
@@ -8572,7 +8700,7 @@ function toError4(value) {
8572
8700
  }
8573
8701
  return new Error(String(value));
8574
8702
  }
8575
- var ImmutableAgentBuilder, CallerAcpHost;
8703
+ var ImmutableAgentBuilder, defaultTranscriptFs, CallerAcpHost;
8576
8704
  var init_agent = __esm({
8577
8705
  "packages/poe-agent/src/agent.ts"() {
8578
8706
  "use strict";
@@ -8586,6 +8714,7 @@ var init_agent = __esm({
8586
8714
  init_plugin_setup();
8587
8715
  init_resolve_provider();
8588
8716
  init_run_context();
8717
+ init_transcript();
8589
8718
  init_tool_names();
8590
8719
  ImmutableAgentBuilder = class _ImmutableAgentBuilder {
8591
8720
  #config;
@@ -8617,7 +8746,8 @@ var init_agent = __esm({
8617
8746
  tools
8618
8747
  });
8619
8748
  }
8620
- mcp(...configs) {
8749
+ mcp(...configsOrMap) {
8750
+ const configs = normalizeMcpConfigs(configsOrMap);
8621
8751
  return new _ImmutableAgentBuilder(
8622
8752
  createResolvedAgentConfig({
8623
8753
  ...this.#config,
@@ -8661,32 +8791,124 @@ var init_agent = __esm({
8661
8791
  };
8662
8792
  }
8663
8793
  async run(prompt, options = {}) {
8664
- const events = await this.#startRun(prompt, options).catch((error2) => {
8794
+ const startedRun = await this.#startRun(prompt, options).catch((error2) => {
8665
8795
  throw toError4(error2);
8666
8796
  });
8797
+ const { events, runContext } = startedRun;
8667
8798
  let completed;
8668
- let failed = void 0;
8669
- for await (const event of events) {
8670
- if (event.type === "session.complete") {
8671
- completed = event.result;
8672
- continue;
8673
- }
8674
- if (event.type === "session.error") {
8675
- failed = event.error;
8799
+ let failed;
8800
+ let usage;
8801
+ let streamedOutput = "";
8802
+ const streamedToolCalls = /* @__PURE__ */ new Map();
8803
+ const transcript = options.logPath ? createTranscriptWriter({
8804
+ logPath: options.logPath,
8805
+ fs: defaultTranscriptFs
8806
+ }) : void 0;
8807
+ try {
8808
+ for await (const event of events) {
8809
+ await transcript?.write(event);
8810
+ if (event.type === "message.delta") {
8811
+ options.onStdout?.(event.content);
8812
+ streamedOutput += event.content;
8813
+ continue;
8814
+ }
8815
+ if (event.type === "usage") {
8816
+ usage = event.usage;
8817
+ continue;
8818
+ }
8819
+ if (event.type === "tool.intent") {
8820
+ streamedToolCalls.set(event.intentId, {
8821
+ intentId: event.intentId,
8822
+ tool: event.tool,
8823
+ args: event.args
8824
+ });
8825
+ continue;
8826
+ }
8827
+ if (event.type === "tool.result") {
8828
+ const toolCall = streamedToolCalls.get(event.intentId);
8829
+ if (toolCall) {
8830
+ toolCall.status = "success";
8831
+ toolCall.result = event.result;
8832
+ toolCall.error = void 0;
8833
+ }
8834
+ continue;
8835
+ }
8836
+ if (event.type === "tool.error") {
8837
+ const toolCall = streamedToolCalls.get(event.intentId);
8838
+ if (toolCall) {
8839
+ toolCall.status = "error";
8840
+ toolCall.error = event.error;
8841
+ toolCall.result = void 0;
8842
+ }
8843
+ continue;
8844
+ }
8845
+ if (event.type === "session.complete") {
8846
+ completed = event.result;
8847
+ continue;
8848
+ }
8849
+ if (event.type === "session.error") {
8850
+ failed = event.error;
8851
+ }
8676
8852
  }
8853
+ } finally {
8854
+ await transcript?.close();
8677
8855
  }
8856
+ const logFile = transcript?.filePath ?? completed?.logFile;
8857
+ const resultUsage = usage ?? completed?.usage;
8858
+ const resultMessages = completed?.messages ?? (runContext.messages.length === 1 && runContext.messages[0]?.role === "user" ? [] : [...runContext.messages]);
8859
+ const resultToolCalls = completed?.toolCalls ?? Array.from(streamedToolCalls.values()).map((toolCall) => {
8860
+ if (toolCall.status === "success") {
8861
+ return {
8862
+ intentId: toolCall.intentId,
8863
+ tool: toolCall.tool,
8864
+ args: toolCall.args,
8865
+ status: "success",
8866
+ result: toolCall.result
8867
+ };
8868
+ }
8869
+ return {
8870
+ intentId: toolCall.intentId,
8871
+ tool: toolCall.tool,
8872
+ args: toolCall.args,
8873
+ status: "error",
8874
+ error: toolCall.error ?? failed?.message ?? "Run ended before the tool completed."
8875
+ };
8876
+ });
8678
8877
  if (failed) {
8679
- throw failed;
8878
+ const fallback = completed ?? {
8879
+ output: streamedOutput,
8880
+ stdout: streamedOutput,
8881
+ messages: resultMessages,
8882
+ toolCalls: resultToolCalls,
8883
+ exitCode: 1,
8884
+ stderr: failed.message
8885
+ };
8886
+ return {
8887
+ ...fallback,
8888
+ ...resultUsage === void 0 ? {} : { usage: resultUsage },
8889
+ ...logFile === void 0 ? {} : { logFile },
8890
+ stdout: fallback.stdout ?? fallback.output,
8891
+ exitCode: 1,
8892
+ stderr: failed.message
8893
+ };
8680
8894
  }
8681
8895
  if (!completed) {
8682
8896
  throw new Error("Run ended without a terminal event.");
8683
8897
  }
8684
- return completed;
8898
+ return {
8899
+ ...completed,
8900
+ ...resultUsage === void 0 ? {} : { usage: resultUsage },
8901
+ ...logFile === void 0 ? {} : { logFile },
8902
+ stdout: completed.stdout ?? completed.output,
8903
+ summary: completed.summary ?? completed.output,
8904
+ exitCode: completed.exitCode ?? 0,
8905
+ stderr: completed.stderr ?? ""
8906
+ };
8685
8907
  }
8686
8908
  async *stream(prompt, options = {}) {
8687
8909
  try {
8688
- const events = await this.#startRun(prompt, options);
8689
- for await (const event of events) {
8910
+ const startedRun = await this.#startRun(prompt, options);
8911
+ for await (const event of startedRun.events) {
8690
8912
  yield event;
8691
8913
  }
8692
8914
  } catch (error2) {
@@ -8705,14 +8927,17 @@ var init_agent = __esm({
8705
8927
  maxIterations: prepared.maxIterations,
8706
8928
  createSpawnSession: prepared.createSpawnSession
8707
8929
  });
8708
- return runAcpCore({
8709
- prompt,
8710
- runContext: prepared.runContext,
8711
- host,
8712
- model: prepared.model,
8713
- baseSystemPrompt: prepared.baseSystemPrompt,
8714
- maxIterations: prepared.maxIterations
8715
- });
8930
+ return {
8931
+ ...prepared,
8932
+ events: runAcpCore({
8933
+ prompt,
8934
+ runContext: prepared.runContext,
8935
+ host,
8936
+ model: prepared.model,
8937
+ baseSystemPrompt: prepared.baseSystemPrompt,
8938
+ maxIterations: prepared.maxIterations
8939
+ })
8940
+ };
8716
8941
  }
8717
8942
  async #prepareRun(options) {
8718
8943
  const activeSkills = resolveActiveSkills(options);
@@ -8775,6 +9000,10 @@ var init_agent = __esm({
8775
9000
  }
8776
9001
  }
8777
9002
  };
9003
+ defaultTranscriptFs = {
9004
+ mkdir: (dir, options) => fsPromises4.mkdir(dir, options).then(() => void 0),
9005
+ appendFile: (filePath, contents) => fsPromises4.appendFile(filePath, contents, "utf8")
9006
+ };
8778
9007
  CallerAcpHost = class {
8779
9008
  #runContext;
8780
9009
  #delegate;
@@ -8834,7 +9063,7 @@ var init_agent = __esm({
8834
9063
  });
8835
9064
 
8836
9065
  // packages/poe-agent/src/plugins/poe-agent-plugin-audit-log.ts
8837
- import { appendFile } from "node:fs/promises";
9066
+ import { appendFile as appendFile2 } from "node:fs/promises";
8838
9067
  var auditLog, poe_agent_plugin_audit_log_default;
8839
9068
  var init_poe_agent_plugin_audit_log = __esm({
8840
9069
  "packages/poe-agent/src/plugins/poe-agent-plugin-audit-log.ts"() {
@@ -8843,11 +9072,11 @@ var init_poe_agent_plugin_audit_log = __esm({
8843
9072
  name: "audit-log",
8844
9073
  hooks: {
8845
9074
  async postToolUse(ctx) {
8846
- await appendFile(logPath, `${JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), tool: ctx.tool })}
9075
+ await appendFile2(logPath, `${JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), tool: ctx.tool })}
8847
9076
  `);
8848
9077
  },
8849
9078
  async postCompaction(ctx) {
8850
- await appendFile(
9079
+ await appendFile2(
8851
9080
  logPath,
8852
9081
  `${JSON.stringify({
8853
9082
  ts: (/* @__PURE__ */ new Date()).toISOString(),
@@ -9209,8 +9438,8 @@ function toTomlArray(values) {
9209
9438
  }
9210
9439
  function toTomlInlineTable(values) {
9211
9440
  const parts = [];
9212
- for (const [key, value] of Object.entries(values)) {
9213
- parts.push(`${JSON.stringify(key)}=${toTomlString(value)}`);
9441
+ for (const [key2, value] of Object.entries(values)) {
9442
+ parts.push(`${JSON.stringify(key2)}=${toTomlString(value)}`);
9214
9443
  }
9215
9444
  return `{${parts.join(", ")}}`;
9216
9445
  }
@@ -9572,7 +9801,7 @@ var init_model_utils = __esm({
9572
9801
  // packages/agent-spawn/src/spawn.ts
9573
9802
  import { spawn as spawnChildProcess2 } from "node:child_process";
9574
9803
  import { mkdirSync, openSync, writeSync, closeSync } from "node:fs";
9575
- import path12 from "node:path";
9804
+ import path13 from "node:path";
9576
9805
  function createAbortError() {
9577
9806
  const error2 = new Error("Agent spawn aborted");
9578
9807
  error2.name = "AbortError";
@@ -9751,14 +9980,17 @@ async function spawn5(agentId, options, context) {
9751
9980
  });
9752
9981
  }
9753
9982
  function resolveSpawnLogPath(options) {
9983
+ if (options.logPath) {
9984
+ return options.logPath;
9985
+ }
9754
9986
  if (!options.logDir || !options.logFileName) {
9755
9987
  return void 0;
9756
9988
  }
9757
- return path12.join(options.logDir, options.logFileName);
9989
+ return path13.join(options.logDir, options.logFileName);
9758
9990
  }
9759
9991
  function openSpawnLog(filePath) {
9760
9992
  try {
9761
- mkdirSync(path12.dirname(filePath), { recursive: true });
9993
+ mkdirSync(path13.dirname(filePath), { recursive: true });
9762
9994
  return openSync(filePath, "a");
9763
9995
  } catch {
9764
9996
  return void 0;
@@ -10449,12 +10681,12 @@ function parseKeyValue(content) {
10449
10681
  if (separator === -1) {
10450
10682
  return null;
10451
10683
  }
10452
- const key = trimAsciiWhitespace(content.slice(0, separator));
10453
- if (key.length === 0) {
10684
+ const key2 = trimAsciiWhitespace(content.slice(0, separator));
10685
+ if (key2.length === 0) {
10454
10686
  return null;
10455
10687
  }
10456
10688
  const rawValue = trimAsciiWhitespaceStart(content.slice(separator + 1));
10457
- return rawValue.length === 0 ? { key } : { key, value: rawValue };
10689
+ return rawValue.length === 0 ? { key: key2 } : { key: key2, value: rawValue };
10458
10690
  }
10459
10691
  function parseArrayItem(content) {
10460
10692
  if (!isArrayItem(content)) {
@@ -10667,8 +10899,8 @@ function trimAsciiWhitespaceEnd(value) {
10667
10899
  }
10668
10900
  return value.slice(0, end);
10669
10901
  }
10670
- function hasOwn3(record, key) {
10671
- return Object.prototype.hasOwnProperty.call(record, key);
10902
+ function hasOwn3(record, key2) {
10903
+ return Object.prototype.hasOwnProperty.call(record, key2);
10672
10904
  }
10673
10905
  function isHexadecimal(value) {
10674
10906
  for (let index = 0; index < value.length; index += 1) {
@@ -13777,7 +14009,7 @@ function renderFrontmatter(data, context) {
13777
14009
  return "";
13778
14010
  }
13779
14011
  const lines = entries.flatMap(
13780
- ([key, value]) => wrapText(`${key}: ${formatFrontmatterValue(value)}`, context.width).map(
14012
+ ([key2, value]) => wrapText(`${key2}: ${formatFrontmatterValue(value)}`, context.width).map(
13781
14013
  (line) => typography.dim(line)
13782
14014
  )
13783
14015
  );
@@ -15331,9 +15563,10 @@ function statsToLines(stats, width) {
15331
15563
  }
15332
15564
  const mutedStyle = getToneStyle("muted");
15333
15565
  const totalTokens = stats.tokensIn + stats.tokensOut;
15566
+ const iterationsLabel = stats.iterationsLabel ?? "Iteration";
15334
15567
  const lines = [
15335
15568
  createKeyValueLine("Status", formatStatus(stats.status), width, getStatusStyle(stats.status)),
15336
- createKeyValueLine("Iteration", formatNumber(stats.iterations), width),
15569
+ createKeyValueLine(iterationsLabel, formatNumber(stats.iterations), width),
15337
15570
  createKeyValueLine("Elapsed", formatElapsed(stats.elapsedMs), width),
15338
15571
  createBlankLine(),
15339
15572
  createKeyValueLine("Tokens In", formatNumber(stats.tokensIn), width),
@@ -15455,8 +15688,8 @@ function parseBinding(binding) {
15455
15688
  let ctrl = false;
15456
15689
  let meta = false;
15457
15690
  let shift = false;
15458
- const key = parts.at(-1);
15459
- if (key === void 0) {
15691
+ const key2 = parts.at(-1);
15692
+ if (key2 === void 0) {
15460
15693
  return void 0;
15461
15694
  }
15462
15695
  for (const modifier of parts.slice(0, -1)) {
@@ -15474,19 +15707,19 @@ function parseBinding(binding) {
15474
15707
  continue;
15475
15708
  }
15476
15709
  }
15477
- if (parts.length === 1 && isShiftedCharacter(key)) {
15710
+ if (parts.length === 1 && isShiftedCharacter(key2)) {
15478
15711
  shift = true;
15479
15712
  }
15480
- if (key.length === 1) {
15713
+ if (key2.length === 1) {
15481
15714
  return {
15482
- ch: normalizeBindingCharacter(key, shift),
15715
+ ch: normalizeBindingCharacter(key2, shift),
15483
15716
  ctrl,
15484
15717
  meta,
15485
15718
  shift
15486
15719
  };
15487
15720
  }
15488
15721
  return {
15489
- name: key.toLowerCase(),
15722
+ name: key2.toLowerCase(),
15490
15723
  ctrl,
15491
15724
  meta,
15492
15725
  shift
@@ -15795,8 +16028,8 @@ function createTerminalDriver(opts) {
15795
16028
  return () => {
15796
16029
  };
15797
16030
  }
15798
- const listener = (str, key) => {
15799
- const event = toKeypressEvent(str, key);
16031
+ const listener = (str, key2) => {
16032
+ const event = toKeypressEvent(str, key2);
15800
16033
  if (event !== void 0) {
15801
16034
  handler(event);
15802
16035
  }
@@ -15846,19 +16079,19 @@ function createTerminalDriver(opts) {
15846
16079
  destroy
15847
16080
  };
15848
16081
  }
15849
- function toKeypressEvent(str, key) {
15850
- const ctrl = key?.ctrl ?? false;
15851
- const meta = key?.meta ?? false;
15852
- const shift = key?.shift ?? false;
15853
- const ch = extractPrintableCharacter(str, key?.sequence);
16082
+ function toKeypressEvent(str, key2) {
16083
+ const ctrl = key2?.ctrl ?? false;
16084
+ const meta = key2?.meta ?? false;
16085
+ const shift = key2?.shift ?? false;
16086
+ const ch = extractPrintableCharacter(str, key2?.sequence);
15854
16087
  if (ch !== void 0) {
15855
16088
  return { ch, ctrl, meta, shift };
15856
16089
  }
15857
- if (key?.name === void 0) {
16090
+ if (key2?.name === void 0) {
15858
16091
  return void 0;
15859
16092
  }
15860
16093
  return {
15861
- name: key.name,
16094
+ name: key2.name,
15862
16095
  ctrl,
15863
16096
  meta,
15864
16097
  shift
@@ -16455,7 +16688,7 @@ var init_autonomous = __esm({
16455
16688
  });
16456
16689
 
16457
16690
  // packages/agent-spawn/src/acp/replay.ts
16458
- import path13 from "node:path";
16691
+ import path14 from "node:path";
16459
16692
  import { homedir as homedir3 } from "node:os";
16460
16693
  import { open, readdir } from "node:fs/promises";
16461
16694
  import { createInterface as createInterface2 } from "node:readline";
@@ -16493,8 +16726,8 @@ function extractTitle(name, input) {
16493
16726
  const keys = TITLE_KEYS[name];
16494
16727
  if (keys && input && typeof input === "object") {
16495
16728
  const obj = input;
16496
- for (const key of keys) {
16497
- const value = obj[key];
16729
+ for (const key2 of keys) {
16730
+ const value = obj[key2];
16498
16731
  if (typeof value === "string" && value.length > 0) {
16499
16732
  return truncate2(value, 80);
16500
16733
  }
@@ -16575,21 +16808,21 @@ async function* adaptClaude(lines) {
16575
16808
  if (blockType !== "tool_result") continue;
16576
16809
  const kind = toolKindsById.get(item.tool_use_id);
16577
16810
  toolKindsById.delete(item.tool_use_id);
16578
- let path26;
16811
+ let path28;
16579
16812
  if (typeof item.content === "string") {
16580
- path26 = item.content;
16813
+ path28 = item.content;
16581
16814
  } else {
16582
16815
  try {
16583
- path26 = JSON.stringify(item.content);
16816
+ path28 = JSON.stringify(item.content);
16584
16817
  } catch {
16585
- path26 = String(item.content);
16818
+ path28 = String(item.content);
16586
16819
  }
16587
16820
  }
16588
16821
  yield {
16589
16822
  event: "tool_complete",
16590
16823
  id: item.tool_use_id,
16591
16824
  kind,
16592
- path: path26
16825
+ path: path28
16593
16826
  };
16594
16827
  }
16595
16828
  }
@@ -16712,10 +16945,10 @@ async function* adaptCodex(lines) {
16712
16945
  const kindFromStart = toolKindById.get(item.id);
16713
16946
  const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
16714
16947
  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;
16715
- const path26 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
16948
+ const path28 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
16716
16949
  toolTitleById.delete(item.id);
16717
16950
  toolKindById.delete(item.id);
16718
- yield { event: "tool_complete", id: item.id, kind, path: path26 };
16951
+ yield { event: "tool_complete", id: item.id, kind, path: path28 };
16719
16952
  }
16720
16953
  }
16721
16954
  }
@@ -17239,7 +17472,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
17239
17472
  }
17240
17473
  const id = readString(event.id);
17241
17474
  const kind = readString(event.kind);
17242
- const path26 = readString(event.path);
17475
+ const path28 = readString(event.path);
17243
17476
  let toolCall = id ? toolCallsById.get(id) : void 0;
17244
17477
  if (!toolCall) {
17245
17478
  toolCall = {};
@@ -17254,8 +17487,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
17254
17487
  if (kind) {
17255
17488
  toolCall.kind = kind;
17256
17489
  }
17257
- if (path26) {
17258
- toolCall.path = path26;
17490
+ if (path28) {
17491
+ toolCall.path = path28;
17259
17492
  }
17260
17493
  }
17261
17494
  var sessionCapture;
@@ -17341,9 +17574,9 @@ var init_usage_capture = __esm({
17341
17574
  });
17342
17575
 
17343
17576
  // packages/agent-spawn/src/acp/middlewares/spawn-log.ts
17344
- import path14 from "node:path";
17577
+ import path15 from "node:path";
17345
17578
  import { homedir as homedir4 } from "node:os";
17346
- import { mkdir, open as open2 } from "node:fs/promises";
17579
+ import { mkdir as mkdir2, open as open2 } from "node:fs/promises";
17347
17580
  function pad(value, width) {
17348
17581
  return String(value).padStart(width, "0");
17349
17582
  }
@@ -17375,14 +17608,17 @@ function resolveStartedAt(value) {
17375
17608
  return value;
17376
17609
  }
17377
17610
  function resolveLogFilePath(ctx) {
17378
- const baseDir = ctx.logDir ?? path14.join(homedir4(), ".poe-code", "spawn-logs");
17611
+ if (ctx.logPath) {
17612
+ return ctx.logPath;
17613
+ }
17614
+ const baseDir = ctx.logDir ?? path15.join(homedir4(), ".poe-code", "spawn-logs");
17379
17615
  if (ctx.logFileName) {
17380
- return path14.join(baseDir, ctx.logFileName);
17616
+ return path15.join(baseDir, ctx.logFileName);
17381
17617
  }
17382
17618
  const startedAt = resolveStartedAt(ctx.startedAt);
17383
17619
  const { day, time, milliseconds } = formatTimestamp(startedAt);
17384
17620
  const fileName = `${day}-${time}-${milliseconds}-${normalizeAgent(ctx.agent)}.jsonl`;
17385
- return path14.join(baseDir, fileName);
17621
+ return path15.join(baseDir, fileName);
17386
17622
  }
17387
17623
  async function writePreloadedEvents(writer, events) {
17388
17624
  for (const event of events) {
@@ -17400,7 +17636,7 @@ var init_spawn_log = __esm({
17400
17636
  logDirPath;
17401
17637
  constructor(ctx) {
17402
17638
  this.filePath = resolveLogFilePath(ctx);
17403
- this.logDirPath = path14.dirname(this.filePath);
17639
+ this.logDirPath = path15.dirname(this.filePath);
17404
17640
  }
17405
17641
  async writeEvent(event) {
17406
17642
  if (this.isDisabled) {
@@ -17436,7 +17672,7 @@ var init_spawn_log = __esm({
17436
17672
  return;
17437
17673
  }
17438
17674
  try {
17439
- await mkdir(this.logDirPath, { recursive: true });
17675
+ await mkdir2(this.logDirPath, { recursive: true });
17440
17676
  this.fileHandle = await open2(this.filePath, "a");
17441
17677
  } catch {
17442
17678
  this.isDisabled = true;
@@ -17551,9 +17787,9 @@ var init_poe_agent_plugin_scratchpad = __esm({
17551
17787
  edit: true
17552
17788
  },
17553
17789
  call(args) {
17554
- const { key, value } = args;
17555
- notes.set(key, value);
17556
- return `Wrote '${key}'`;
17790
+ const { key: key2, value } = args;
17791
+ notes.set(key2, value);
17792
+ return `Wrote '${key2}'`;
17557
17793
  }
17558
17794
  },
17559
17795
  {
@@ -17713,9 +17949,11 @@ __export(src_exports, {
17713
17949
  collectProviders: () => collectProviders,
17714
17950
  compactionPlugin: () => poe_agent_plugin_compaction_default,
17715
17951
  createAgentSession: () => createAgentSession,
17952
+ createTranscriptWriter: () => createTranscriptWriter,
17716
17953
  environmentPlugin: () => poe_agent_plugin_environment_default,
17717
17954
  filesPlugin: () => poe_agent_plugin_files_default,
17718
17955
  gitContextPlugin: () => poe_agent_plugin_git_context_default,
17956
+ mapAcpEventToSessionUpdates: () => mapAcpEventToSessionUpdates,
17719
17957
  maxIterationsPlugin: () => poe_agent_plugin_max_iterations_default,
17720
17958
  mcpPlugin: () => mcpPlugin,
17721
17959
  memoryPlugin: () => poe_agent_plugin_memory_default,
@@ -17742,6 +17980,7 @@ var init_src7 = __esm({
17742
17980
  init_registry();
17743
17981
  init_resolve_plugins();
17744
17982
  init_resolve_provider();
17983
+ init_transcript();
17745
17984
  init_poe_agent_plugin_audit_log();
17746
17985
  init_poe_agent_plugin_compaction();
17747
17986
  init_poe_agent_plugin_environment();
@@ -17764,7 +18003,7 @@ var init_src7 = __esm({
17764
18003
  });
17765
18004
 
17766
18005
  // src/providers/poe-agent.ts
17767
- import fsPromises7 from "node:fs/promises";
18006
+ import fsPromises8 from "node:fs/promises";
17768
18007
  import os3 from "node:os";
17769
18008
 
17770
18009
  // src/cli/constants.ts
@@ -17821,7 +18060,7 @@ import path5 from "node:path";
17821
18060
 
17822
18061
  // packages/config-extends/src/discover.ts
17823
18062
  import path from "node:path";
17824
- async function findBase(name, bases, fs3) {
18063
+ async function findBase(name, bases, fs4) {
17825
18064
  const checkedPaths = [];
17826
18065
  for (const basePath of bases) {
17827
18066
  for (const extension of [".md", ".yaml", ".yml", ".json"]) {
@@ -17829,7 +18068,7 @@ async function findBase(name, bases, fs3) {
17829
18068
  checkedPaths.push(filePath);
17830
18069
  try {
17831
18070
  return {
17832
- content: await fs3.readFile(filePath, "utf8"),
18071
+ content: await fs4.readFile(filePath, "utf8"),
17833
18072
  filePath
17834
18073
  };
17835
18074
  } catch (error2) {
@@ -17909,15 +18148,15 @@ function stripBom(content) {
17909
18148
  function mergeLayers(layers) {
17910
18149
  return mergeObjectLayers(layers, []);
17911
18150
  }
17912
- function mergeObjectLayers(layers, path26) {
18151
+ function mergeObjectLayers(layers, path28) {
17913
18152
  const data = {};
17914
18153
  const sources = {};
17915
- for (const key of collectKeys(layers)) {
17916
- const resolved = resolveKey(layers, key, path26);
18154
+ for (const key2 of collectKeys(layers)) {
18155
+ const resolved = resolveKey(layers, key2, path28);
17917
18156
  if (resolved === void 0) {
17918
18157
  continue;
17919
18158
  }
17920
- data[key] = resolved.value;
18159
+ data[key2] = resolved.value;
17921
18160
  Object.assign(sources, resolved.sources);
17922
18161
  }
17923
18162
  return { data, sources };
@@ -17925,19 +18164,19 @@ function mergeObjectLayers(layers, path26) {
17925
18164
  function collectKeys(layers) {
17926
18165
  const keys = /* @__PURE__ */ new Set();
17927
18166
  for (const layer of layers) {
17928
- for (const key of Object.keys(layer.data)) {
17929
- keys.add(key);
18167
+ for (const key2 of Object.keys(layer.data)) {
18168
+ keys.add(key2);
17930
18169
  }
17931
18170
  }
17932
18171
  return [...keys];
17933
18172
  }
17934
- function resolveKey(layers, key, path26) {
18173
+ function resolveKey(layers, key2, path28) {
17935
18174
  let winningSource;
17936
18175
  let winningValue;
17937
18176
  const objectLayers = [];
17938
18177
  for (const layer of layers) {
17939
- const candidate = layer.data[key];
17940
- if (!isWinningCandidate(key, candidate)) {
18178
+ const candidate = layer.data[key2];
18179
+ if (!isWinningCandidate(key2, candidate)) {
17941
18180
  continue;
17942
18181
  }
17943
18182
  if (winningSource === void 0) {
@@ -17961,9 +18200,9 @@ function resolveKey(layers, key, path26) {
17961
18200
  if (winningSource === void 0) {
17962
18201
  return void 0;
17963
18202
  }
17964
- const fullPath = buildPath(path26, key);
18203
+ const fullPath = buildPath(path28, key2);
17965
18204
  if (isPlainObject(winningValue)) {
17966
- const merged = mergeObjectLayers(objectLayers, [...path26, key]);
18205
+ const merged = mergeObjectLayers(objectLayers, [...path28, key2]);
17967
18206
  return {
17968
18207
  value: merged.data,
17969
18208
  sources: {
@@ -17979,17 +18218,17 @@ function resolveKey(layers, key, path26) {
17979
18218
  }
17980
18219
  };
17981
18220
  }
17982
- function isWinningCandidate(key, value) {
18221
+ function isWinningCandidate(key2, value) {
17983
18222
  if (value === void 0) {
17984
18223
  return false;
17985
18224
  }
17986
- if (key === "prompt" && value === "") {
18225
+ if (key2 === "prompt" && value === "") {
17987
18226
  return false;
17988
18227
  }
17989
18228
  return true;
17990
18229
  }
17991
- function buildPath(path26, key) {
17992
- return [...path26, key].join(".");
18230
+ function buildPath(path28, key2) {
18231
+ return [...path28, key2].join(".");
17993
18232
  }
17994
18233
  function isPlainObject(value) {
17995
18234
  if (value === null || Array.isArray(value) || typeof value !== "object") {
@@ -18006,8 +18245,8 @@ function cloneValue(value) {
18006
18245
  return value;
18007
18246
  }
18008
18247
  const clone = Object.create(Object.getPrototypeOf(value));
18009
- for (const [key, entry] of Object.entries(value)) {
18010
- clone[key] = cloneValue(entry);
18248
+ for (const [key2, entry] of Object.entries(value)) {
18249
+ clone[key2] = cloneValue(entry);
18011
18250
  }
18012
18251
  return clone;
18013
18252
  }
@@ -18356,29 +18595,29 @@ function serialize(obj) {
18356
18595
  }
18357
18596
  function merge(base, patch) {
18358
18597
  const result = { ...base };
18359
- for (const [key, value] of Object.entries(patch)) {
18598
+ for (const [key2, value] of Object.entries(patch)) {
18360
18599
  if (value === void 0) {
18361
18600
  continue;
18362
18601
  }
18363
- const existing = result[key];
18602
+ const existing = result[key2];
18364
18603
  if (isConfigObject(existing) && isConfigObject(value)) {
18365
- result[key] = merge(existing, value);
18604
+ result[key2] = merge(existing, value);
18366
18605
  continue;
18367
18606
  }
18368
- result[key] = value;
18607
+ result[key2] = value;
18369
18608
  }
18370
18609
  return result;
18371
18610
  }
18372
18611
  function prune(obj, shape) {
18373
18612
  let changed = false;
18374
18613
  const result = { ...obj };
18375
- for (const [key, pattern] of Object.entries(shape)) {
18376
- if (!(key in result)) {
18614
+ for (const [key2, pattern] of Object.entries(shape)) {
18615
+ if (!(key2 in result)) {
18377
18616
  continue;
18378
18617
  }
18379
- const current = result[key];
18618
+ const current = result[key2];
18380
18619
  if (isConfigObject(pattern) && Object.keys(pattern).length === 0) {
18381
- delete result[key];
18620
+ delete result[key2];
18382
18621
  changed = true;
18383
18622
  continue;
18384
18623
  }
@@ -18391,13 +18630,13 @@ function prune(obj, shape) {
18391
18630
  changed = true;
18392
18631
  }
18393
18632
  if (Object.keys(childResult).length === 0) {
18394
- delete result[key];
18633
+ delete result[key2];
18395
18634
  } else {
18396
- result[key] = childResult;
18635
+ result[key2] = childResult;
18397
18636
  }
18398
18637
  continue;
18399
18638
  }
18400
- delete result[key];
18639
+ delete result[key2];
18401
18640
  changed = true;
18402
18641
  }
18403
18642
  return { changed, result };
@@ -18431,29 +18670,29 @@ function serialize2(obj) {
18431
18670
  }
18432
18671
  function merge2(base, patch) {
18433
18672
  const result = { ...base };
18434
- for (const [key, value] of Object.entries(patch)) {
18673
+ for (const [key2, value] of Object.entries(patch)) {
18435
18674
  if (value === void 0) {
18436
18675
  continue;
18437
18676
  }
18438
- const existing = result[key];
18677
+ const existing = result[key2];
18439
18678
  if (isConfigObject2(existing) && isConfigObject2(value)) {
18440
- result[key] = merge2(existing, value);
18679
+ result[key2] = merge2(existing, value);
18441
18680
  continue;
18442
18681
  }
18443
- result[key] = value;
18682
+ result[key2] = value;
18444
18683
  }
18445
18684
  return result;
18446
18685
  }
18447
18686
  function prune2(obj, shape) {
18448
18687
  let changed = false;
18449
18688
  const result = { ...obj };
18450
- for (const [key, pattern] of Object.entries(shape)) {
18451
- if (!(key in result)) {
18689
+ for (const [key2, pattern] of Object.entries(shape)) {
18690
+ if (!(key2 in result)) {
18452
18691
  continue;
18453
18692
  }
18454
- const current = result[key];
18693
+ const current = result[key2];
18455
18694
  if (isConfigObject2(pattern) && Object.keys(pattern).length === 0) {
18456
- delete result[key];
18695
+ delete result[key2];
18457
18696
  changed = true;
18458
18697
  continue;
18459
18698
  }
@@ -18466,13 +18705,13 @@ function prune2(obj, shape) {
18466
18705
  changed = true;
18467
18706
  }
18468
18707
  if (Object.keys(childResult).length === 0) {
18469
- delete result[key];
18708
+ delete result[key2];
18470
18709
  } else {
18471
- result[key] = childResult;
18710
+ result[key2] = childResult;
18472
18711
  }
18473
18712
  continue;
18474
18713
  }
18475
- delete result[key];
18714
+ delete result[key2];
18476
18715
  changed = true;
18477
18716
  }
18478
18717
  return { changed, result };
@@ -18509,29 +18748,29 @@ function serialize3(obj) {
18509
18748
  }
18510
18749
  function merge3(base, patch) {
18511
18750
  const result = { ...base };
18512
- for (const [key, value] of Object.entries(patch)) {
18751
+ for (const [key2, value] of Object.entries(patch)) {
18513
18752
  if (value === void 0) {
18514
18753
  continue;
18515
18754
  }
18516
- const existing = result[key];
18755
+ const existing = result[key2];
18517
18756
  if (isConfigObject3(existing) && isConfigObject3(value)) {
18518
- result[key] = merge3(existing, value);
18757
+ result[key2] = merge3(existing, value);
18519
18758
  continue;
18520
18759
  }
18521
- result[key] = value;
18760
+ result[key2] = value;
18522
18761
  }
18523
18762
  return result;
18524
18763
  }
18525
18764
  function prune3(obj, shape) {
18526
18765
  let changed = false;
18527
18766
  const result = { ...obj };
18528
- for (const [key, pattern] of Object.entries(shape)) {
18529
- if (!(key in result)) {
18767
+ for (const [key2, pattern] of Object.entries(shape)) {
18768
+ if (!(key2 in result)) {
18530
18769
  continue;
18531
18770
  }
18532
- const current = result[key];
18771
+ const current = result[key2];
18533
18772
  if (isConfigObject3(pattern) && Object.keys(pattern).length === 0) {
18534
- delete result[key];
18773
+ delete result[key2];
18535
18774
  changed = true;
18536
18775
  continue;
18537
18776
  }
@@ -18541,13 +18780,13 @@ function prune3(obj, shape) {
18541
18780
  changed = true;
18542
18781
  }
18543
18782
  if (Object.keys(childResult).length === 0) {
18544
- delete result[key];
18783
+ delete result[key2];
18545
18784
  } else {
18546
- result[key] = childResult;
18785
+ result[key2] = childResult;
18547
18786
  }
18548
18787
  continue;
18549
18788
  }
18550
- delete result[key];
18789
+ delete result[key2];
18551
18790
  changed = true;
18552
18791
  }
18553
18792
  return { changed, result };
@@ -18584,16 +18823,16 @@ function getConfigFormat(pathOrFormat) {
18584
18823
  }
18585
18824
  return formatRegistry[formatName];
18586
18825
  }
18587
- function detectFormat2(path26) {
18588
- const ext = getExtension(path26);
18826
+ function detectFormat2(path28) {
18827
+ const ext = getExtension(path28);
18589
18828
  return extensionMap[ext];
18590
18829
  }
18591
- function getExtension(path26) {
18592
- const lastDot = path26.lastIndexOf(".");
18830
+ function getExtension(path28) {
18831
+ const lastDot = path28.lastIndexOf(".");
18593
18832
  if (lastDot === -1) {
18594
18833
  return "";
18595
18834
  }
18596
- return path26.slice(lastDot).toLowerCase();
18835
+ return path28.slice(lastDot).toLowerCase();
18597
18836
  }
18598
18837
 
18599
18838
  // packages/config-mutations/src/execution/path-utils.ts
@@ -18644,9 +18883,9 @@ function resolvePath(rawPath, homeDir, pathMapper) {
18644
18883
  function isNotFound(error2) {
18645
18884
  return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
18646
18885
  }
18647
- async function readFileIfExists(fs3, target) {
18886
+ async function readFileIfExists(fs4, target) {
18648
18887
  try {
18649
- return await fs3.readFile(target, "utf8");
18888
+ return await fs4.readFile(target, "utf8");
18650
18889
  } catch (error2) {
18651
18890
  if (isNotFound(error2)) {
18652
18891
  return null;
@@ -18654,9 +18893,9 @@ async function readFileIfExists(fs3, target) {
18654
18893
  throw error2;
18655
18894
  }
18656
18895
  }
18657
- async function pathExists(fs3, target) {
18896
+ async function pathExists(fs4, target) {
18658
18897
  try {
18659
- await fs3.stat(target);
18898
+ await fs4.stat(target);
18660
18899
  return true;
18661
18900
  } catch (error2) {
18662
18901
  if (isNotFound(error2)) {
@@ -18680,9 +18919,9 @@ function createInvalidDocumentBackupPath(targetPath) {
18680
18919
  const ext = targetPath.includes(".") ? targetPath.split(".").pop() : "bak";
18681
18920
  return `${targetPath}.invalid-${createTimestamp()}.${ext}`;
18682
18921
  }
18683
- async function backupInvalidDocument(fs3, targetPath, content) {
18922
+ async function backupInvalidDocument(fs4, targetPath, content) {
18684
18923
  const backupPath = createInvalidDocumentBackupPath(targetPath);
18685
- await fs3.writeFile(backupPath, content, { encoding: "utf8" });
18924
+ await fs4.writeFile(backupPath, content, { encoding: "utf8" });
18686
18925
  }
18687
18926
  function describeMutation(kind, targetPath) {
18688
18927
  const displayPath2 = targetPath ?? "target";
@@ -18711,9 +18950,9 @@ function describeMutation(kind, targetPath) {
18711
18950
  }
18712
18951
  function pruneKeysByPrefix(table, prefix) {
18713
18952
  const result = {};
18714
- for (const [key, value] of Object.entries(table)) {
18715
- if (!key.startsWith(prefix)) {
18716
- result[key] = value;
18953
+ for (const [key2, value] of Object.entries(table)) {
18954
+ if (!key2.startsWith(prefix)) {
18955
+ result[key2] = value;
18717
18956
  }
18718
18957
  }
18719
18958
  return result;
@@ -18724,15 +18963,15 @@ function isConfigObject4(value) {
18724
18963
  function mergeWithPruneByPrefix(base, patch, pruneByPrefix) {
18725
18964
  const result = { ...base };
18726
18965
  const prefixMap = pruneByPrefix ?? {};
18727
- for (const [key, value] of Object.entries(patch)) {
18728
- const current = result[key];
18729
- const prefix = prefixMap[key];
18966
+ for (const [key2, value] of Object.entries(patch)) {
18967
+ const current = result[key2];
18968
+ const prefix = prefixMap[key2];
18730
18969
  if (isConfigObject4(current) && isConfigObject4(value)) {
18731
18970
  if (prefix) {
18732
18971
  const pruned = pruneKeysByPrefix(current, prefix);
18733
- result[key] = { ...pruned, ...value };
18972
+ result[key2] = { ...pruned, ...value };
18734
18973
  } else {
18735
- result[key] = mergeWithPruneByPrefix(
18974
+ result[key2] = mergeWithPruneByPrefix(
18736
18975
  current,
18737
18976
  value,
18738
18977
  prefixMap
@@ -18740,7 +18979,7 @@ function mergeWithPruneByPrefix(base, patch, pruneByPrefix) {
18740
18979
  }
18741
18980
  continue;
18742
18981
  }
18743
- result[key] = value;
18982
+ result[key2] = value;
18744
18983
  }
18745
18984
  return result;
18746
18985
  }
@@ -18895,8 +19134,8 @@ async function applyChmod(mutation, context, options) {
18895
19134
  };
18896
19135
  }
18897
19136
  try {
18898
- const stat6 = await context.fs.stat(targetPath);
18899
- const currentMode = typeof stat6.mode === "number" ? stat6.mode & 511 : null;
19137
+ const stat7 = await context.fs.stat(targetPath);
19138
+ const currentMode = typeof stat7.mode === "number" ? stat7.mode & 511 : null;
18900
19139
  if (currentMode === mutation.mode) {
18901
19140
  return {
18902
19141
  outcome: { changed: false, effect: "none", detail: "noop" },
@@ -19244,26 +19483,26 @@ import Mustache2 from "mustache";
19244
19483
  var originalEscape = Mustache2.escape;
19245
19484
 
19246
19485
  // packages/poe-code-config/src/store.ts
19247
- async function readDocument(fs3, filePath) {
19248
- const document = await readStoredDocument(fs3, filePath);
19486
+ async function readDocument(fs4, filePath) {
19487
+ const document = await readStoredDocument(fs4, filePath);
19249
19488
  return document.data;
19250
19489
  }
19251
- async function writeScope(fs3, filePath, scope, values) {
19252
- const document = await readDocument(fs3, filePath);
19490
+ async function writeScope(fs4, filePath, scope, values) {
19491
+ const document = await readDocument(fs4, filePath);
19253
19492
  const normalizedValues = normalizeScopeValues(values);
19254
19493
  if (Object.keys(normalizedValues).length === 0) {
19255
19494
  delete document[scope];
19256
19495
  } else {
19257
19496
  document[scope] = normalizedValues;
19258
19497
  }
19259
- await writeDocument(fs3, filePath, document);
19498
+ await writeDocument(fs4, filePath, document);
19260
19499
  }
19261
- async function readMergedDocument(fs3, globalPath, projectPath) {
19262
- const globalDocument = await readStoredDocument(fs3, globalPath);
19500
+ async function readMergedDocument(fs4, globalPath, projectPath) {
19501
+ const globalDocument = await readStoredDocument(fs4, globalPath);
19263
19502
  if (!projectPath) {
19264
19503
  return globalDocument.data;
19265
19504
  }
19266
- const projectDocument = await readStoredDocument(fs3, projectPath);
19505
+ const projectDocument = await readStoredDocument(fs4, projectPath);
19267
19506
  const resolved = await resolve(
19268
19507
  [
19269
19508
  {
@@ -19277,16 +19516,16 @@ async function readMergedDocument(fs3, globalPath, projectPath) {
19277
19516
  }
19278
19517
  ],
19279
19518
  {
19280
- fs: createResolvedConfigFs(fs3, globalPath, globalDocument.content),
19519
+ fs: createResolvedConfigFs(fs4, globalPath, globalDocument.content),
19281
19520
  autoExtend: true
19282
19521
  }
19283
19522
  );
19284
19523
  return normalizeDocument(resolved.data);
19285
19524
  }
19286
- async function readStoredDocument(fs3, filePath) {
19525
+ async function readStoredDocument(fs4, filePath) {
19287
19526
  try {
19288
- const raw = await fs3.readFile(filePath, "utf8");
19289
- return await parseStoredDocument(fs3, filePath, raw);
19527
+ const raw = await fs4.readFile(filePath, "utf8");
19528
+ return await parseStoredDocument(fs4, filePath, raw);
19290
19529
  } catch (error2) {
19291
19530
  if (isNotFound(error2)) {
19292
19531
  return {
@@ -19297,7 +19536,7 @@ async function readStoredDocument(fs3, filePath) {
19297
19536
  throw error2;
19298
19537
  }
19299
19538
  }
19300
- async function parseStoredDocument(fs3, filePath, raw) {
19539
+ async function parseStoredDocument(fs4, filePath, raw) {
19301
19540
  try {
19302
19541
  return {
19303
19542
  content: raw,
@@ -19305,7 +19544,7 @@ async function parseStoredDocument(fs3, filePath, raw) {
19305
19544
  };
19306
19545
  } catch (error2) {
19307
19546
  if (error2 instanceof SyntaxError) {
19308
- await recoverInvalidDocument(fs3, filePath, raw);
19547
+ await recoverInvalidDocument(fs4, filePath, raw);
19309
19548
  return {
19310
19549
  content: EMPTY_DOCUMENT,
19311
19550
  data: {}
@@ -19332,35 +19571,35 @@ function normalizeScopeValues(value) {
19332
19571
  return {};
19333
19572
  }
19334
19573
  const normalized = {};
19335
- for (const [key, entry] of Object.entries(value)) {
19574
+ for (const [key2, entry] of Object.entries(value)) {
19336
19575
  if (entry !== void 0) {
19337
- normalized[key] = entry;
19576
+ normalized[key2] = entry;
19338
19577
  }
19339
19578
  }
19340
19579
  return normalized;
19341
19580
  }
19342
- function createResolvedConfigFs(fs3, globalPath, globalContent) {
19581
+ function createResolvedConfigFs(fs4, globalPath, globalContent) {
19343
19582
  return {
19344
19583
  readFile(filePath, _encoding) {
19345
19584
  if (filePath === globalPath) {
19346
19585
  return Promise.resolve(globalContent);
19347
19586
  }
19348
- return fs3.readFile(filePath, "utf8");
19587
+ return fs4.readFile(filePath, "utf8");
19349
19588
  }
19350
19589
  };
19351
19590
  }
19352
- async function writeDocument(fs3, filePath, document) {
19353
- await fs3.mkdir(path5.dirname(filePath), { recursive: true });
19354
- await fs3.writeFile(filePath, `${JSON.stringify(document, null, 2)}
19591
+ async function writeDocument(fs4, filePath, document) {
19592
+ await fs4.mkdir(path5.dirname(filePath), { recursive: true });
19593
+ await fs4.writeFile(filePath, `${JSON.stringify(document, null, 2)}
19355
19594
  `, {
19356
19595
  encoding: "utf8"
19357
19596
  });
19358
19597
  }
19359
- async function recoverInvalidDocument(fs3, filePath, content) {
19360
- await fs3.mkdir(path5.dirname(filePath), { recursive: true });
19598
+ async function recoverInvalidDocument(fs4, filePath, content) {
19599
+ await fs4.mkdir(path5.dirname(filePath), { recursive: true });
19361
19600
  const backupPath = createInvalidBackupPath(filePath);
19362
- await fs3.writeFile(backupPath, content, { encoding: "utf8" });
19363
- await fs3.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
19601
+ await fs4.writeFile(backupPath, content, { encoding: "utf8" });
19602
+ await fs4.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
19364
19603
  }
19365
19604
  function createInvalidBackupPath(filePath) {
19366
19605
  const directory = path5.dirname(filePath);
@@ -19382,15 +19621,15 @@ var EMPTY_DOCUMENT = `${JSON.stringify({}, null, 2)}
19382
19621
  // packages/poe-code-config/src/resolve.ts
19383
19622
  function resolveScope(schema, fileValues, env = {}) {
19384
19623
  const resolved = {};
19385
- for (const key of Object.keys(schema)) {
19386
- const field = schema[key];
19387
- const envValue = resolveEnvValue(field, env, key);
19388
- const fileValue = resolveFileValue(field, fileValues?.[key], key);
19389
- resolved[key] = envValue ?? fileValue ?? field.default;
19624
+ for (const key2 of Object.keys(schema)) {
19625
+ const field = schema[key2];
19626
+ const envValue = resolveEnvValue(field, env, key2);
19627
+ const fileValue = resolveFileValue(field, fileValues?.[key2], key2);
19628
+ resolved[key2] = envValue ?? fileValue ?? field.default;
19390
19629
  }
19391
19630
  return resolved;
19392
19631
  }
19393
- function resolveEnvValue(field, env, key) {
19632
+ function resolveEnvValue(field, env, key2) {
19394
19633
  if (!field.env) {
19395
19634
  return void 0;
19396
19635
  }
@@ -19398,12 +19637,12 @@ function resolveEnvValue(field, env, key) {
19398
19637
  if (raw === void 0) {
19399
19638
  return void 0;
19400
19639
  }
19401
- return coerceValue(field, raw, key);
19640
+ return coerceValue(field, raw, key2);
19402
19641
  }
19403
- function resolveFileValue(field, value, key) {
19404
- return coerceValue(field, value, key);
19642
+ function resolveFileValue(field, value, key2) {
19643
+ return coerceValue(field, value, key2);
19405
19644
  }
19406
- function coerceValue(field, value, key) {
19645
+ function coerceValue(field, value, key2) {
19407
19646
  switch (field.type) {
19408
19647
  case "string":
19409
19648
  return typeof value === "string" ? value : void 0;
@@ -19412,7 +19651,7 @@ function coerceValue(field, value, key) {
19412
19651
  case "boolean":
19413
19652
  return coerceBoolean(value);
19414
19653
  case "json":
19415
- return coerceJson(field, value, key);
19654
+ return coerceJson(field, value, key2);
19416
19655
  }
19417
19656
  }
19418
19657
  function coerceNumber(value) {
@@ -19437,26 +19676,26 @@ function coerceBoolean(value) {
19437
19676
  }
19438
19677
  return void 0;
19439
19678
  }
19440
- function coerceJson(field, value, key) {
19679
+ function coerceJson(field, value, key2) {
19441
19680
  if (value === void 0) {
19442
19681
  return void 0;
19443
19682
  }
19444
- const parsedValue = parseJsonValue(value, key);
19683
+ const parsedValue = parseJsonValue(value, key2);
19445
19684
  try {
19446
19685
  return field.parse(parsedValue);
19447
19686
  } catch (error2) {
19448
19687
  const message2 = error2 instanceof Error ? error2.message : "Invalid JSON value.";
19449
- throw new Error(`Invalid config value for "${key}": ${message2}`);
19688
+ throw new Error(`Invalid config value for "${key2}": ${message2}`);
19450
19689
  }
19451
19690
  }
19452
- function parseJsonValue(value, key) {
19691
+ function parseJsonValue(value, key2) {
19453
19692
  if (typeof value !== "string") {
19454
19693
  return value;
19455
19694
  }
19456
19695
  try {
19457
19696
  return JSON.parse(value);
19458
19697
  } catch {
19459
- throw new Error(`Invalid config value for "${key}": expected valid JSON.`);
19698
+ throw new Error(`Invalid config value for "${key2}": expected valid JSON.`);
19460
19699
  }
19461
19700
  }
19462
19701
 
@@ -19466,19 +19705,19 @@ function createConfigStore(options) {
19466
19705
  return {
19467
19706
  scope(definition) {
19468
19707
  return {
19469
- async get(key) {
19708
+ async get(key2) {
19470
19709
  const resolved = await resolveScopedValues(options, definition, env);
19471
- return resolved[key];
19710
+ return resolved[key2];
19472
19711
  },
19473
19712
  async getAll() {
19474
19713
  return resolveScopedValues(options, definition, env);
19475
19714
  },
19476
- async set(key, value) {
19715
+ async set(key2, value) {
19477
19716
  const document = await readDocument(options.fs, options.filePath);
19478
19717
  const currentValues = document[definition.scope] ?? {};
19479
19718
  await writeScope(options.fs, options.filePath, definition.scope, {
19480
19719
  ...currentValues,
19481
- [key]: value
19720
+ [key2]: value
19482
19721
  });
19483
19722
  }
19484
19723
  };
@@ -19649,16 +19888,16 @@ function createInstallRunner(definition) {
19649
19888
  }
19650
19889
 
19651
19890
  // src/services/config.ts
19652
- import path25 from "node:path";
19891
+ import path27 from "node:path";
19653
19892
  init_src7();
19654
19893
 
19655
19894
  // packages/superintendent/src/document/parse.ts
19656
- import path15 from "node:path";
19895
+ import path16 from "node:path";
19657
19896
  import { parseDocument as parseDocument2 } from "yaml";
19658
19897
  var superintendentDocumentSchemaId = "https://poe-platform.github.io/poe-code/schemas/plans/superintendent.schema.json";
19659
19898
  var validStatusStates = /* @__PURE__ */ new Set(["in_progress", "review", "completed"]);
19660
19899
  function parseSuperintendentDoc(filePath, content) {
19661
- const resolvedFilePath = path15.resolve(filePath);
19900
+ const resolvedFilePath = path16.resolve(filePath);
19662
19901
  const { frontmatterText, body } = splitFrontmatter(resolvedFilePath, content);
19663
19902
  const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
19664
19903
  return {
@@ -19848,7 +20087,7 @@ function isRecord3(value) {
19848
20087
  }
19849
20088
 
19850
20089
  // packages/superintendent/src/document/write.ts
19851
- import path16 from "node:path";
20090
+ import path17 from "node:path";
19852
20091
  import { isMap, parseDocument as parseDocument3 } from "yaml";
19853
20092
  function updateStatus(filePath, content, status) {
19854
20093
  return updateFrontmatter(filePath, content, (frontmatterDocument) => {
@@ -19869,7 +20108,7 @@ function setStatusReason(filePath, content, reason) {
19869
20108
  });
19870
20109
  }
19871
20110
  function updateFrontmatter(filePath, content, mutate) {
19872
- const resolvedFilePath = path16.resolve(filePath);
20111
+ const resolvedFilePath = path17.resolve(filePath);
19873
20112
  const parts = splitDocument(resolvedFilePath, content);
19874
20113
  const frontmatterDocument = parseDocument3(parts.frontmatterText);
19875
20114
  if (frontmatterDocument.errors.length > 0) {
@@ -19896,8 +20135,8 @@ function getTopLevelMap(frontmatterDocument) {
19896
20135
  }
19897
20136
  function reorderTopLevelKeys(map, keys) {
19898
20137
  const remaining = [...map.items];
19899
- const ordered = keys.flatMap((key) => {
19900
- const index = remaining.findIndex((item) => item.key?.toString() === key);
20138
+ const ordered = keys.flatMap((key2) => {
20139
+ const index = remaining.findIndex((item) => item.key?.toString() === key2);
19901
20140
  return index === -1 ? [] : remaining.splice(index, 1);
19902
20141
  });
19903
20142
  map.items = [...ordered, ...remaining];
@@ -20094,27 +20333,55 @@ function extractText(node) {
20094
20333
  }
20095
20334
 
20096
20335
  // packages/superintendent/src/runtime/loop.ts
20097
- import * as fsPromises5 from "node:fs/promises";
20336
+ import path21 from "node:path";
20337
+ import * as fsPromises6 from "node:fs/promises";
20098
20338
 
20099
20339
  // packages/agent-kit/src/paths.ts
20100
- import path17 from "node:path";
20340
+ import path18 from "node:path";
20101
20341
  function resolveWorkflowPath(inputPath, cwd, homeDir) {
20102
20342
  if (inputPath.startsWith("~/")) {
20103
- return path17.join(homeDir, inputPath.slice(2));
20343
+ return path18.join(homeDir, inputPath.slice(2));
20104
20344
  }
20105
20345
  if (inputPath === "~") {
20106
20346
  return homeDir;
20107
20347
  }
20108
- return path17.isAbsolute(inputPath) ? inputPath : path17.resolve(cwd, inputPath);
20348
+ return path18.isAbsolute(inputPath) ? inputPath : path18.resolve(cwd, inputPath);
20109
20349
  }
20110
20350
 
20111
20351
  // packages/agent-kit/src/participant.ts
20112
20352
  init_src4();
20113
20353
 
20114
20354
  // packages/agent-kit/src/lock.ts
20115
- import * as fsPromises4 from "node:fs/promises";
20116
- function sleep(ms) {
20117
- return new Promise((resolve2) => setTimeout(resolve2, ms));
20355
+ import * as fsPromises5 from "node:fs/promises";
20356
+ function createAbortError3() {
20357
+ const error2 = new Error("The operation was aborted.");
20358
+ error2.name = "AbortError";
20359
+ return error2;
20360
+ }
20361
+ function throwIfAborted(signal) {
20362
+ if (signal?.aborted) {
20363
+ throw createAbortError3();
20364
+ }
20365
+ }
20366
+ function sleep(ms, signal) {
20367
+ if (!signal) {
20368
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
20369
+ }
20370
+ if (signal.aborted) {
20371
+ return Promise.reject(createAbortError3());
20372
+ }
20373
+ return new Promise((resolve2, reject) => {
20374
+ const timeoutId = setTimeout(() => {
20375
+ signal.removeEventListener("abort", onAbort);
20376
+ resolve2();
20377
+ }, ms);
20378
+ const onAbort = () => {
20379
+ clearTimeout(timeoutId);
20380
+ signal.removeEventListener("abort", onAbort);
20381
+ reject(createAbortError3());
20382
+ };
20383
+ signal.addEventListener("abort", onAbort, { once: true });
20384
+ });
20118
20385
  }
20119
20386
  function backoff(attempt, minTimeout, maxTimeout) {
20120
20387
  const delay = Math.min(maxTimeout, minTimeout * Math.pow(2, attempt));
@@ -20125,23 +20392,23 @@ function hasErrorCode(error2, code) {
20125
20392
  }
20126
20393
  function createDefaultFs() {
20127
20394
  return {
20128
- mkdir: async (path26, options) => {
20129
- await fsPromises4.mkdir(path26, options);
20395
+ mkdir: async (path28, options) => {
20396
+ await fsPromises5.mkdir(path28, options);
20130
20397
  },
20131
- rmdir: fsPromises4.rmdir,
20132
- stat: async (path26) => {
20133
- const stat6 = await fsPromises4.stat(path26);
20398
+ rmdir: fsPromises5.rmdir,
20399
+ stat: async (path28) => {
20400
+ const stat7 = await fsPromises5.stat(path28);
20134
20401
  return {
20135
- isFile: () => stat6.isFile(),
20136
- isDirectory: () => stat6.isDirectory(),
20137
- mtimeMs: stat6.mtimeMs
20402
+ isFile: () => stat7.isFile(),
20403
+ isDirectory: () => stat7.isDirectory(),
20404
+ mtimeMs: stat7.mtimeMs
20138
20405
  };
20139
20406
  }
20140
20407
  };
20141
20408
  }
20142
- async function removeLockDirectory(fs3, lockPath) {
20409
+ async function removeLockDirectory(fs4, lockPath) {
20143
20410
  try {
20144
- await fs3.rmdir(lockPath);
20411
+ await fs4.rmdir(lockPath);
20145
20412
  } catch (error2) {
20146
20413
  if (!hasErrorCode(error2, "ENOENT")) {
20147
20414
  throw error2;
@@ -20149,42 +20416,43 @@ async function removeLockDirectory(fs3, lockPath) {
20149
20416
  }
20150
20417
  }
20151
20418
  async function lockWorkflow(docPath, options = {}) {
20152
- const fs3 = options.fs ?? createDefaultFs();
20419
+ const fs4 = options.fs ?? createDefaultFs();
20153
20420
  const retries = options.retries ?? 20;
20154
20421
  const minTimeout = options.minTimeout ?? 25;
20155
20422
  const maxTimeout = options.maxTimeout ?? 250;
20156
20423
  const staleMs = options.staleMs ?? 3e4;
20157
20424
  const lockPath = `${docPath}.lock`;
20158
20425
  for (let attempt = 0; attempt <= retries; attempt += 1) {
20426
+ throwIfAborted(options.signal);
20159
20427
  try {
20160
- await fs3.mkdir(lockPath);
20428
+ await fs4.mkdir(lockPath);
20161
20429
  let released = false;
20162
20430
  return async () => {
20163
20431
  if (released) {
20164
20432
  return;
20165
20433
  }
20166
20434
  released = true;
20167
- await removeLockDirectory(fs3, lockPath);
20435
+ await removeLockDirectory(fs4, lockPath);
20168
20436
  };
20169
20437
  } catch (error2) {
20170
20438
  if (!hasErrorCode(error2, "EEXIST")) {
20171
20439
  throw error2;
20172
20440
  }
20173
- let stat6;
20441
+ let stat7;
20174
20442
  try {
20175
- stat6 = await fs3.stat(lockPath);
20443
+ stat7 = await fs4.stat(lockPath);
20176
20444
  } catch (statError) {
20177
20445
  if (hasErrorCode(statError, "ENOENT")) {
20178
20446
  continue;
20179
20447
  }
20180
20448
  throw statError;
20181
20449
  }
20182
- if (Date.now() - stat6.mtimeMs > staleMs) {
20183
- await removeLockDirectory(fs3, lockPath);
20450
+ if (Date.now() - stat7.mtimeMs > staleMs) {
20451
+ await removeLockDirectory(fs4, lockPath);
20184
20452
  continue;
20185
20453
  }
20186
20454
  if (attempt < retries) {
20187
- await sleep(backoff(attempt, minTimeout, maxTimeout));
20455
+ await sleep(backoff(attempt, minTimeout, maxTimeout), options.signal);
20188
20456
  }
20189
20457
  }
20190
20458
  }
@@ -20192,13 +20460,13 @@ async function lockWorkflow(docPath, options = {}) {
20192
20460
  }
20193
20461
 
20194
20462
  // packages/agent-kit/src/run-logs.ts
20195
- import path18 from "node:path";
20463
+ import path19 from "node:path";
20196
20464
  function resolveRunLogDir(options) {
20197
20465
  const slug = slugifyPlanPath(options.planPath);
20198
- return path18.join(options.homeDir, ".poe-code", "logs", options.runner, slug);
20466
+ return path19.join(options.homeDir, ".poe-code", "logs", options.runner, slug);
20199
20467
  }
20200
20468
  function slugifyPlanPath(planPath) {
20201
- const base = path18.basename(planPath);
20469
+ const base = path19.basename(planPath);
20202
20470
  const dot = base.lastIndexOf(".");
20203
20471
  const stem = dot > 0 ? base.slice(0, dot) : base;
20204
20472
  return slugifyLabel(stem);
@@ -20249,6 +20517,15 @@ function pad2(value, width) {
20249
20517
  return String(value).padStart(width, "0");
20250
20518
  }
20251
20519
 
20520
+ // packages/agent-kit/src/skill-config.ts
20521
+ function skillPlanConfigSection(subcommand) {
20522
+ return `## Plan Directory
20523
+
20524
+ Run \`poe-code ${subcommand} plan-path\` to get the resolved plan directory path.
20525
+
20526
+ Write the plan file to \`<plan-directory>/<name>.md\`.`;
20527
+ }
20528
+
20252
20529
  // packages/superintendent/src/runtime/loop.ts
20253
20530
  init_src6();
20254
20531
 
@@ -20269,15 +20546,15 @@ function createLoopState(doc) {
20269
20546
  init_src6();
20270
20547
 
20271
20548
  // packages/superintendent/src/runtime/resolve-cwd.ts
20272
- import path19 from "node:path";
20549
+ import path20 from "node:path";
20273
20550
  function resolveRoleCwd(role, docPath, defaultCwd) {
20274
20551
  if (role.cwd === void 0) {
20275
20552
  return defaultCwd;
20276
20553
  }
20277
- if (path19.isAbsolute(role.cwd)) {
20554
+ if (path20.isAbsolute(role.cwd)) {
20278
20555
  return role.cwd;
20279
20556
  }
20280
- return path19.resolve(path19.dirname(docPath), role.cwd);
20557
+ return path20.resolve(path20.dirname(docPath), role.cwd);
20281
20558
  }
20282
20559
 
20283
20560
  // packages/superintendent/src/runtime/templates.ts
@@ -20312,8 +20589,7 @@ async function runBuilder(doc, context, options) {
20312
20589
  prompt,
20313
20590
  cwd: resolveRoleCwd(doc.frontmatter.builder, doc.filePath, options.defaultCwd),
20314
20591
  mcpServers: buildMcpServers(doc),
20315
- ...options.logDir ? { logDir: options.logDir } : {},
20316
- ...options.logFileName ? { logFileName: options.logFileName } : {}
20592
+ ...options.logPath ? { logPath: options.logPath } : {}
20317
20593
  });
20318
20594
  const log2 = extractLog(result);
20319
20595
  return {
@@ -20357,8 +20633,7 @@ async function runAutonomous(input) {
20357
20633
  prompt: input.prompt,
20358
20634
  mode: input.mode,
20359
20635
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20360
- ...input.logDir ? { logDir: input.logDir } : {},
20361
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20636
+ ...input.logPath ? { logPath: input.logPath } : {}
20362
20637
  });
20363
20638
  }
20364
20639
  const result = await spawn5(input.agent, {
@@ -20366,8 +20641,7 @@ async function runAutonomous(input) {
20366
20641
  prompt: input.prompt,
20367
20642
  mode: input.mode,
20368
20643
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20369
- ...input.logDir ? { logDir: input.logDir } : {},
20370
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20644
+ ...input.logPath ? { logPath: input.logPath } : {}
20371
20645
  });
20372
20646
  return {
20373
20647
  stdout: result.stdout,
@@ -20387,10 +20661,7 @@ function extractLogPath(result, options) {
20387
20661
  return logFile;
20388
20662
  }
20389
20663
  }
20390
- if (options.logDir && options.logFileName) {
20391
- return `${options.logDir}/${options.logFileName}`;
20392
- }
20393
- return "";
20664
+ return options.logPath ?? "";
20394
20665
  }
20395
20666
  function extractSummary(result, log2) {
20396
20667
  if (typeof result !== "string") {
@@ -20496,8 +20767,7 @@ async function runInspector(name, config, doc, context, options) {
20496
20767
  prompt,
20497
20768
  cwd: resolveRoleCwd(config, doc.filePath, options.defaultCwd),
20498
20769
  mcpServers: buildMcpServers2(doc, config),
20499
- ...options.logDir ? { logDir: options.logDir } : {},
20500
- ...options.logFileName ? { logFileName: options.logFileName } : {}
20770
+ ...options.logPath ? { logPath: options.logPath } : {}
20501
20771
  });
20502
20772
  const logPath = extractLogPath2(output);
20503
20773
  return {
@@ -20564,8 +20834,7 @@ async function runAutonomous2(input) {
20564
20834
  prompt: input.prompt,
20565
20835
  mode: input.mode,
20566
20836
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20567
- ...input.logDir ? { logDir: input.logDir } : {},
20568
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20837
+ ...input.logPath ? { logPath: input.logPath } : {}
20569
20838
  });
20570
20839
  }
20571
20840
  const result = await spawn5(input.agent, {
@@ -20573,8 +20842,7 @@ async function runAutonomous2(input) {
20573
20842
  prompt: input.prompt,
20574
20843
  mode: input.mode,
20575
20844
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20576
- ...input.logDir ? { logDir: input.logDir } : {},
20577
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20845
+ ...input.logPath ? { logPath: input.logPath } : {}
20578
20846
  });
20579
20847
  return {
20580
20848
  stdout: result.stdout,
@@ -20706,8 +20974,7 @@ async function runOwnerReview(doc, context, options) {
20706
20974
  prompt,
20707
20975
  cwd: resolveRoleCwd(doc.frontmatter.owner, doc.filePath, options.defaultCwd),
20708
20976
  mcpServers: buildMcpServers3(doc),
20709
- ...options.logDir ? { logDir: options.logDir } : {},
20710
- ...options.logFileName ? { logFileName: options.logFileName } : {}
20977
+ ...options.logPath ? { logPath: options.logPath } : {}
20711
20978
  });
20712
20979
  const logPath = extractLogPath3(result);
20713
20980
  return {
@@ -20754,8 +21021,7 @@ async function runAutonomous3(input) {
20754
21021
  prompt: input.prompt,
20755
21022
  mode: input.mode,
20756
21023
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20757
- ...input.logDir ? { logDir: input.logDir } : {},
20758
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21024
+ ...input.logPath ? { logPath: input.logPath } : {}
20759
21025
  });
20760
21026
  }
20761
21027
  const result = await spawn5(input.agent, {
@@ -20763,8 +21029,7 @@ async function runAutonomous3(input) {
20763
21029
  prompt: input.prompt,
20764
21030
  mode: input.mode,
20765
21031
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20766
- ...input.logDir ? { logDir: input.logDir } : {},
20767
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21032
+ ...input.logPath ? { logPath: input.logPath } : {}
20768
21033
  });
20769
21034
  return {
20770
21035
  stdout: result.stdout,
@@ -20915,8 +21180,7 @@ async function runSuperintendent(doc, context, options) {
20915
21180
  prompt,
20916
21181
  cwd: resolveRoleCwd(doc.frontmatter.superintendent, doc.filePath, options.defaultCwd),
20917
21182
  mcpServers: buildMcpServers4(doc),
20918
- ...options.logDir ? { logDir: options.logDir } : {},
20919
- ...options.logFileName ? { logFileName: options.logFileName } : {}
21183
+ ...options.logPath ? { logPath: options.logPath } : {}
20920
21184
  });
20921
21185
  const transition = extractTransition2(result);
20922
21186
  const logPath = extractLogPath4(result);
@@ -20975,8 +21239,7 @@ async function runAutonomous4(input) {
20975
21239
  prompt: input.prompt,
20976
21240
  mode: input.mode,
20977
21241
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20978
- ...input.logDir ? { logDir: input.logDir } : {},
20979
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21242
+ ...input.logPath ? { logPath: input.logPath } : {}
20980
21243
  });
20981
21244
  }
20982
21245
  const result = await spawn5(input.agent, {
@@ -20984,8 +21247,7 @@ async function runAutonomous4(input) {
20984
21247
  prompt: input.prompt,
20985
21248
  mode: input.mode,
20986
21249
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20987
- ...input.logDir ? { logDir: input.logDir } : {},
20988
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21250
+ ...input.logPath ? { logPath: input.logPath } : {}
20989
21251
  });
20990
21252
  return {
20991
21253
  stdout: result.stdout,
@@ -21314,46 +21576,46 @@ function normalizeOptions(input, callbacks) {
21314
21576
  }
21315
21577
  function createDefaultFs2() {
21316
21578
  return {
21317
- readFile: fsPromises5.readFile,
21318
- writeFile: fsPromises5.writeFile,
21319
- readdir: fsPromises5.readdir,
21579
+ readFile: fsPromises6.readFile,
21580
+ writeFile: fsPromises6.writeFile,
21581
+ readdir: fsPromises6.readdir,
21320
21582
  stat: async (filePath) => {
21321
- const stat6 = await fsPromises5.stat(filePath);
21583
+ const stat7 = await fsPromises6.stat(filePath);
21322
21584
  return {
21323
- isFile: () => stat6.isFile(),
21324
- isDirectory: () => stat6.isDirectory(),
21325
- mtimeMs: stat6.mtimeMs
21585
+ isFile: () => stat7.isFile(),
21586
+ isDirectory: () => stat7.isDirectory(),
21587
+ mtimeMs: stat7.mtimeMs
21326
21588
  };
21327
21589
  },
21328
21590
  mkdir: async (filePath, options) => {
21329
- await fsPromises5.mkdir(filePath, options);
21591
+ await fsPromises6.mkdir(filePath, options);
21330
21592
  },
21331
21593
  rmdir: async (filePath) => {
21332
- await fsPromises5.rmdir(filePath);
21594
+ await fsPromises6.rmdir(filePath);
21333
21595
  },
21334
21596
  rename: async (oldPath, newPath) => {
21335
- await fsPromises5.rename(oldPath, newPath);
21597
+ await fsPromises6.rename(oldPath, newPath);
21336
21598
  }
21337
21599
  };
21338
21600
  }
21339
- async function readDocument2(fs3, docPath) {
21340
- const content = await readDocumentContent(fs3, docPath);
21601
+ async function readDocument2(fs4, docPath) {
21602
+ const content = await readDocumentContent(fs4, docPath);
21341
21603
  return parseSuperintendentDoc(docPath, content);
21342
21604
  }
21343
- async function readDocumentContent(fs3, docPath) {
21344
- return fs3.readFile(docPath, "utf8");
21605
+ async function readDocumentContent(fs4, docPath) {
21606
+ return fs4.readFile(docPath, "utf8");
21345
21607
  }
21346
- async function writeLoopState(fs3, docPath, state) {
21347
- const content = await fs3.readFile(docPath, "utf8");
21608
+ async function writeLoopState(fs4, docPath, state) {
21609
+ const content = await fs4.readFile(docPath, "utf8");
21348
21610
  const updatedContent = updateStatus(docPath, content, {
21349
21611
  state: state.state,
21350
21612
  round: state.round,
21351
21613
  review_turn: state.reviewTurn
21352
21614
  });
21353
- await fs3.writeFile(docPath, updatedContent, { encoding: "utf8" });
21615
+ await fs4.writeFile(docPath, updatedContent, { encoding: "utf8" });
21354
21616
  }
21355
- async function restoreDocument(fs3, docPath, content) {
21356
- await fs3.writeFile(docPath, content, { encoding: "utf8" });
21617
+ async function restoreDocument(fs4, docPath, content) {
21618
+ await fs4.writeFile(docPath, content, { encoding: "utf8" });
21357
21619
  }
21358
21620
  async function rollbackRoundStatus(options, state) {
21359
21621
  await writeLoopState(options.fs, options.docPath, state);
@@ -21420,14 +21682,10 @@ async function executeSuperintendent(options, context) {
21420
21682
  }
21421
21683
  }
21422
21684
  function buildRoleOptions(options, role) {
21423
- const base = {
21424
- defaultCwd: options.cwd
21685
+ return {
21686
+ defaultCwd: options.cwd,
21687
+ ...options.logDir ? { logPath: path21.join(options.logDir, makeRunLogFileName(role)) } : {}
21425
21688
  };
21426
- if (options.logDir) {
21427
- base.logDir = options.logDir;
21428
- base.logFileName = makeRunLogFileName(role);
21429
- }
21430
- return base;
21431
21689
  }
21432
21690
  function shouldContinueReview(doc) {
21433
21691
  return parseTaskBoard(doc.body).allDone;
@@ -21502,8 +21760,7 @@ async function withInjectedAgentRunner(options, operation) {
21502
21760
  cwd: input.cwd ?? process.cwd(),
21503
21761
  ...input.mode ? { mode: input.mode } : {},
21504
21762
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
21505
- ...input.logDir ? { logDir: input.logDir } : {},
21506
- ...input.logFileName ? { logFileName: input.logFileName } : {},
21763
+ ...input.logPath ? { logPath: input.logPath } : {},
21507
21764
  ...options.signal ? { signal: options.signal } : {}
21508
21765
  });
21509
21766
  if (!result) {
@@ -21610,7 +21867,7 @@ function cloneSecrets(secrets) {
21610
21867
  return {};
21611
21868
  }
21612
21869
  return Object.fromEntries(
21613
- Object.entries(secrets).map(([key, secret]) => [key, cloneSecretDefinition(secret)])
21870
+ Object.entries(secrets).map(([key2, secret]) => [key2, cloneSecretDefinition(secret)])
21614
21871
  );
21615
21872
  }
21616
21873
  function cloneRequires(requires) {
@@ -21875,8 +22132,8 @@ var builderRunCommand = defineCommand({
21875
22132
  positional: ["path"],
21876
22133
  params: builderRunParams,
21877
22134
  scope: ["cli", "mcp", "sdk"],
21878
- handler: async ({ params, fs: fs3 }) => {
21879
- const content = await readDocument3(params.path, fs3);
22135
+ handler: async ({ params, fs: fs4 }) => {
22136
+ const content = await readDocument3(params.path, fs4);
21880
22137
  const document = parseSuperintendentDoc(params.path, content);
21881
22138
  return runBuilder(document, {}, { defaultCwd: process.cwd() });
21882
22139
  },
@@ -21898,9 +22155,9 @@ var builderGroup = defineGroup({
21898
22155
  scope: ["cli", "mcp", "sdk"],
21899
22156
  children: [builderRunCommand]
21900
22157
  });
21901
- async function readDocument3(filePath, fs3) {
22158
+ async function readDocument3(filePath, fs4) {
21902
22159
  try {
21903
- return await fs3.readFile(filePath, "utf8");
22160
+ return await fs4.readFile(filePath, "utf8");
21904
22161
  } catch (error2) {
21905
22162
  if (hasCode2(error2, "ENOENT")) {
21906
22163
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -21929,14 +22186,14 @@ function hasCode2(error2, code) {
21929
22186
  }
21930
22187
 
21931
22188
  // packages/superintendent/src/commands/install.ts
21932
- import path22 from "node:path";
21933
- import { readFile as readFile4, stat as stat4, mkdir as mkdir4, writeFile as writeFile2, unlink, readdir as readdir3, chmod as chmod2 } from "node:fs/promises";
22189
+ import path24 from "node:path";
22190
+ import { readFile as readFile4, stat as stat4, mkdir as mkdir5, writeFile as writeFile2, unlink, readdir as readdir3, chmod as chmod2 } from "node:fs/promises";
21934
22191
  import { fileURLToPath as fileURLToPath4 } from "node:url";
21935
22192
 
21936
22193
  // packages/agent-skill-config/src/configs.ts
21937
22194
  init_src4();
21938
22195
  import os2 from "node:os";
21939
- import path20 from "node:path";
22196
+ import path22 from "node:path";
21940
22197
  var agentSkillConfigs = {
21941
22198
  "claude-code": {
21942
22199
  globalSkillDir: "~/.claude/skills",
@@ -21970,7 +22227,7 @@ function resolveAgentSupport(input, registry = agentSkillConfigs) {
21970
22227
 
21971
22228
  // packages/agent-skill-config/src/templates.ts
21972
22229
  import { readFile as readFile3, stat as stat3 } from "node:fs/promises";
21973
- import path21 from "node:path";
22230
+ import path23 from "node:path";
21974
22231
  import { fileURLToPath as fileURLToPath3 } from "node:url";
21975
22232
 
21976
22233
  // packages/agent-skill-config/src/apply.ts
@@ -22031,7 +22288,7 @@ async function installSkill(agentId, skill, options) {
22031
22288
  var fs2 = {
22032
22289
  readFile: (p, encoding) => readFile4(p, encoding),
22033
22290
  writeFile: (p, content) => writeFile2(p, content),
22034
- mkdir: (p, options) => mkdir4(p, options).then(() => void 0),
22291
+ mkdir: (p, options) => mkdir5(p, options).then(() => void 0),
22035
22292
  unlink: (p) => unlink(p),
22036
22293
  stat: (p) => stat4(p).then((s) => ({ mode: s.mode })),
22037
22294
  readdir: (p) => readdir3(p),
@@ -22066,7 +22323,7 @@ var installCommand = defineCommand({
22066
22323
  support.id,
22067
22324
  {
22068
22325
  name: "poe-code-superintendent-plan",
22069
- content: skillContent
22326
+ content: skillContent + "\n\n" + skillPlanConfigSection("superintendent")
22070
22327
  },
22071
22328
  {
22072
22329
  fs: fs2,
@@ -22079,7 +22336,7 @@ var installCommand = defineCommand({
22079
22336
  const absolutePlanDirectory = resolveAbsoluteDirectory(planDirectory, cwd, homeDir);
22080
22337
  let planDirectoryCreated = false;
22081
22338
  if (!await pathExists2(absolutePlanDirectory)) {
22082
- await mkdir4(absolutePlanDirectory, { recursive: true });
22339
+ await mkdir5(absolutePlanDirectory, { recursive: true });
22083
22340
  planDirectoryCreated = true;
22084
22341
  }
22085
22342
  return {
@@ -22124,9 +22381,9 @@ async function resolvePlanDirectory(cwd, homeDir, env) {
22124
22381
  }
22125
22382
  function resolveAbsoluteDirectory(dir, cwd, homeDir) {
22126
22383
  if (dir.startsWith("~/")) {
22127
- return path22.join(homeDir, dir.slice(2));
22384
+ return path24.join(homeDir, dir.slice(2));
22128
22385
  }
22129
- return path22.isAbsolute(dir) ? dir : path22.resolve(cwd, dir);
22386
+ return path24.isAbsolute(dir) ? dir : path24.resolve(cwd, dir);
22130
22387
  }
22131
22388
  async function pathExists2(targetPath) {
22132
22389
  try {
@@ -22146,15 +22403,15 @@ async function loadSkillTemplate() {
22146
22403
  }
22147
22404
  const packageRoot = await findPackageRoot(fileURLToPath4(import.meta.url));
22148
22405
  const templateRoots = [
22149
- path22.join(packageRoot, "src", "templates"),
22150
- path22.join(packageRoot, "dist", "templates")
22406
+ path24.join(packageRoot, "src", "templates"),
22407
+ path24.join(packageRoot, "dist", "templates")
22151
22408
  ];
22152
22409
  for (const templateRoot of templateRoots) {
22153
22410
  if (!await pathExists2(templateRoot)) {
22154
22411
  continue;
22155
22412
  }
22156
22413
  skillTemplateCache = await readFile4(
22157
- path22.join(templateRoot, "SKILL_superintendent.md"),
22414
+ path24.join(templateRoot, "SKILL_superintendent.md"),
22158
22415
  "utf8"
22159
22416
  );
22160
22417
  return skillTemplateCache;
@@ -22162,12 +22419,12 @@ async function loadSkillTemplate() {
22162
22419
  throw new Error("Unable to locate Superintendent skill template.");
22163
22420
  }
22164
22421
  async function findPackageRoot(entryFilePath) {
22165
- let currentPath = path22.dirname(entryFilePath);
22422
+ let currentPath = path24.dirname(entryFilePath);
22166
22423
  while (true) {
22167
- if (await pathExists2(path22.join(currentPath, "package.json"))) {
22424
+ if (await pathExists2(path24.join(currentPath, "package.json"))) {
22168
22425
  return currentPath;
22169
22426
  }
22170
- const parentPath = path22.dirname(currentPath);
22427
+ const parentPath = path24.dirname(currentPath);
22171
22428
  if (parentPath === currentPath) {
22172
22429
  throw new Error("Unable to locate package root for Superintendent templates.");
22173
22430
  }
@@ -22189,8 +22446,8 @@ var inspectorListCommand = defineCommand({
22189
22446
  positional: ["path"],
22190
22447
  params: inspectorListParams,
22191
22448
  scope: ["cli", "mcp", "sdk"],
22192
- handler: async ({ params, fs: fs3 }) => {
22193
- const content = await readDocument4(params.path, fs3);
22449
+ handler: async ({ params, fs: fs4 }) => {
22450
+ const content = await readDocument4(params.path, fs4);
22194
22451
  const document = parseSuperintendentDoc(params.path, content);
22195
22452
  return Object.entries(document.frontmatter.inspectors ?? {}).map(([name, config]) => ({
22196
22453
  name,
@@ -22230,8 +22487,8 @@ var inspectorRunCommand = defineCommand({
22230
22487
  positional: ["path", "name"],
22231
22488
  params: inspectorRunParams,
22232
22489
  scope: ["cli", "mcp", "sdk"],
22233
- handler: async ({ params, fs: fs3 }) => {
22234
- const content = await readDocument4(params.path, fs3);
22490
+ handler: async ({ params, fs: fs4 }) => {
22491
+ const content = await readDocument4(params.path, fs4);
22235
22492
  const document = parseSuperintendentDoc(params.path, content);
22236
22493
  const defaultCwd = process.cwd();
22237
22494
  if (params.name === void 0) {
@@ -22264,9 +22521,9 @@ var inspectorGroup = defineGroup({
22264
22521
  scope: ["cli", "mcp", "sdk"],
22265
22522
  children: [inspectorListCommand, inspectorRunCommand]
22266
22523
  });
22267
- async function readDocument4(filePath, fs3) {
22524
+ async function readDocument4(filePath, fs4) {
22268
22525
  try {
22269
- return await fs3.readFile(filePath, "utf8");
22526
+ return await fs4.readFile(filePath, "utf8");
22270
22527
  } catch (error2) {
22271
22528
  if (hasCode3(error2, "ENOENT")) {
22272
22529
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -22314,11 +22571,11 @@ var completeCommand = defineCommand({
22314
22571
  positional: ["path"],
22315
22572
  params: completeParams,
22316
22573
  scope: ["cli", "mcp", "sdk"],
22317
- handler: async ({ params, fs: fs3 }) => {
22318
- const content = await readDocument5(params.path, fs3);
22574
+ handler: async ({ params, fs: fs4 }) => {
22575
+ const content = await readDocument5(params.path, fs4);
22319
22576
  const completedContent = transitionState(params.path, content, "completed");
22320
22577
  const updatedContent = setStatusReason(params.path, completedContent, params.reason);
22321
- await fs3.writeFile(params.path, updatedContent);
22578
+ await fs4.writeFile(params.path, updatedContent);
22322
22579
  return {
22323
22580
  path: params.path,
22324
22581
  state: "completed",
@@ -22342,9 +22599,9 @@ var completeCommand = defineCommand({
22342
22599
  json: (result) => result
22343
22600
  }
22344
22601
  });
22345
- async function readDocument5(filePath, fs3) {
22602
+ async function readDocument5(filePath, fs4) {
22346
22603
  try {
22347
- return await fs3.readFile(filePath, "utf8");
22604
+ return await fs4.readFile(filePath, "utf8");
22348
22605
  } catch (error2) {
22349
22606
  if (hasCode4(error2, "ENOENT")) {
22350
22607
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -22356,9 +22613,50 @@ function hasCode4(error2, code) {
22356
22613
  return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === code;
22357
22614
  }
22358
22615
 
22616
+ // packages/superintendent/src/commands/plan-path.ts
22617
+ import path25 from "node:path";
22618
+ import { readFile as readFile5, writeFile as writeFile3, mkdir as mkdir6, unlink as unlink2, stat as stat5, readdir as readdir4 } from "node:fs/promises";
22619
+ var fs3 = {
22620
+ readFile: (p, encoding) => readFile5(p, encoding),
22621
+ writeFile: (p, content) => writeFile3(p, content),
22622
+ mkdir: (p, options) => mkdir6(p, options).then(() => void 0),
22623
+ unlink: (p) => unlink2(p),
22624
+ stat: (p) => stat5(p).then((s) => ({ mode: s.mode })),
22625
+ readdir: (p) => readdir4(p)
22626
+ };
22627
+ var planPathCommand = defineCommand({
22628
+ name: "plan-path",
22629
+ description: "Print the directory where superintendent plan files should be placed.",
22630
+ params: S.Object({}),
22631
+ scope: ["cli", "sdk"],
22632
+ handler: async () => {
22633
+ const cwd = process.cwd();
22634
+ const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? cwd;
22635
+ const configPath = resolveConfigPath(homeDir);
22636
+ const projectConfigPath = resolveProjectConfigPath(cwd);
22637
+ const document = await readMergedDocument(fs3, configPath, projectConfigPath);
22638
+ const planDirectory = resolveScope(planConfigScope.schema, document.plan, process.env).plan_directory;
22639
+ return { planDirectory: resolveAbsoluteDirectory2(planDirectory, cwd, homeDir) };
22640
+ },
22641
+ render: {
22642
+ rich: (result) => {
22643
+ process.stdout.write(`${result.planDirectory}
22644
+ `);
22645
+ },
22646
+ markdown: (result) => result.planDirectory,
22647
+ json: (result) => result
22648
+ }
22649
+ });
22650
+ function resolveAbsoluteDirectory2(dir, cwd, homeDir) {
22651
+ if (dir.startsWith("~/")) {
22652
+ return path25.join(homeDir, dir.slice(2));
22653
+ }
22654
+ return path25.isAbsolute(dir) ? dir : path25.resolve(cwd, dir);
22655
+ }
22656
+
22359
22657
  // packages/superintendent/src/commands/run.ts
22360
- import path24 from "node:path";
22361
- import * as fsPromises6 from "node:fs/promises";
22658
+ import path26 from "node:path";
22659
+ import * as fsPromises7 from "node:fs/promises";
22362
22660
  import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
22363
22661
  init_src6();
22364
22662
  init_src4();
@@ -22366,182 +22664,19 @@ init_src4();
22366
22664
  // packages/superintendent/src/commands/poe-agent-runner.ts
22367
22665
  init_src4();
22368
22666
  init_src7();
22369
- import { mkdir as mkdir5, appendFile as appendFile2 } from "node:fs/promises";
22370
-
22371
- // packages/superintendent/src/commands/poe-agent-transcript.ts
22372
- import path23 from "node:path";
22373
- function mapAcpEventToSessionUpdates(event) {
22374
- if (event.type === "message.delta") {
22375
- if (event.content.length === 0) return [];
22376
- return [{ sessionUpdate: "agent_message_chunk", content: { type: "text", text: event.content } }];
22377
- }
22378
- if (event.type === "tool.intent") {
22379
- return [
22380
- {
22381
- sessionUpdate: "tool_call",
22382
- toolCallId: event.intentId,
22383
- title: event.tool,
22384
- kind: "execute",
22385
- status: "pending",
22386
- rawInput: event.args
22387
- },
22388
- {
22389
- sessionUpdate: "tool_call_update",
22390
- toolCallId: event.intentId,
22391
- kind: "execute",
22392
- status: "in_progress"
22393
- }
22394
- ];
22395
- }
22396
- if (event.type === "tool.result") {
22397
- return [
22398
- {
22399
- sessionUpdate: "tool_call_update",
22400
- toolCallId: event.intentId,
22401
- kind: "execute",
22402
- status: "completed",
22403
- rawOutput: event.result
22404
- }
22405
- ];
22406
- }
22407
- if (event.type === "tool.error") {
22408
- return [
22409
- {
22410
- sessionUpdate: "tool_call_update",
22411
- toolCallId: event.intentId,
22412
- kind: "execute",
22413
- status: "failed",
22414
- rawOutput: event.error
22415
- }
22416
- ];
22417
- }
22418
- if (event.type === "usage") {
22419
- const { inputTokens, outputTokens, cachedTokens, cacheCreationTokens } = event.usage;
22420
- const nonCachedInput = Math.max(0, inputTokens - cachedTokens);
22421
- return [
22422
- {
22423
- sessionUpdate: "usage_update",
22424
- used: nonCachedInput,
22425
- size: inputTokens,
22426
- _meta: { inputTokens, outputTokens, cachedTokens, cacheCreationTokens }
22427
- }
22428
- ];
22429
- }
22430
- return [];
22431
- }
22432
- function createTranscriptWriter(options) {
22433
- const join2 = options.pathJoin ?? path23.join;
22434
- const filePath = join2(options.logDir, options.logFileName);
22435
- let dirEnsured;
22436
- let disabled = false;
22437
- const ensureDir = () => {
22438
- if (!dirEnsured) {
22439
- dirEnsured = options.fs.mkdir(options.logDir, { recursive: true });
22440
- }
22441
- return dirEnsured;
22442
- };
22443
- return {
22444
- filePath,
22445
- async write(event) {
22446
- if (disabled) return;
22447
- const updates = mapAcpEventToSessionUpdates(event);
22448
- if (updates.length === 0) return;
22449
- try {
22450
- await ensureDir();
22451
- const payload = updates.map((u) => `${JSON.stringify(u)}
22452
- `).join("");
22453
- await options.fs.appendFile(filePath, payload);
22454
- } catch {
22455
- disabled = true;
22456
- }
22457
- },
22458
- async close() {
22459
- }
22460
- };
22461
- }
22462
-
22463
- // packages/superintendent/src/commands/poe-agent-runner.ts
22464
- var defaultTranscriptFs = {
22465
- mkdir: (dir, options) => mkdir5(dir, options).then(() => void 0),
22466
- appendFile: (filePath, contents) => appendFile2(filePath, contents, "utf8")
22467
- };
22468
- async function executePoeAgent(agentSpec, input, createAgent = agent, transcriptFs = defaultTranscriptFs) {
22667
+ async function executePoeAgent(agentSpec, input, createAgent = agent) {
22469
22668
  const { model } = parseAgentSpecifier(agentSpec);
22470
22669
  if (!model) {
22471
22670
  throw new Error(
22472
22671
  `poe-agent requires a model in the agent specifier (e.g. "poe-agent:openai/gpt-5.4"); got "${agentSpec}".`
22473
22672
  );
22474
22673
  }
22475
- const mcpConfigs = toPoeMcpConfigs(input.mcpServers);
22476
- let builder = createAgent().model(model).use(openaiResponsesPlugin()).use(openaiChatCompletionsPlugin()).use(poe_agent_plugin_system_prompt_default()).use(poe_agent_plugin_environment_default(input.cwd)).use(poe_agent_plugin_files_default({ cwd: input.cwd })).use(poe_agent_plugin_shell_default({ cwd: input.cwd })).use(poe_agent_plugin_web_default()).use(poe_agent_plugin_compaction_default()).use(poe_agent_plugin_skills_default({ definitions: {} }));
22477
- if (input.mode) {
22478
- builder = builder.use(poe_agent_plugin_policy_default({ mode: input.mode }));
22479
- }
22480
- builder = builder.mcp(...mcpConfigs);
22481
- const streamOptions = {
22674
+ return createAgent().model(model).use(openaiResponsesPlugin()).use(openaiChatCompletionsPlugin()).use(poe_agent_plugin_system_prompt_default()).use(poe_agent_plugin_environment_default(input.cwd)).use(poe_agent_plugin_files_default({ cwd: input.cwd })).use(poe_agent_plugin_shell_default({ cwd: input.cwd })).use(poe_agent_plugin_web_default()).use(poe_agent_plugin_compaction_default()).use(poe_agent_plugin_skills_default({ definitions: {} })).use(poe_agent_plugin_policy_default({ mode: input.mode })).mcp(input.mcpServers ?? {}).run(input.prompt, {
22482
22675
  cwd: input.cwd,
22483
- ...input.signal ? { signal: input.signal } : {}
22484
- };
22485
- const transcript = input.logDir && input.logFileName ? createTranscriptWriter({
22486
- logDir: input.logDir,
22487
- logFileName: input.logFileName,
22488
- fs: transcriptFs
22489
- }) : void 0;
22490
- let completed = "";
22491
- let streamed = "";
22492
- let failure;
22493
- let usage;
22494
- const toolCalls = [];
22495
- try {
22496
- for await (const event of builder.stream(input.prompt, streamOptions)) {
22497
- if (transcript) {
22498
- await transcript.write(event);
22499
- }
22500
- if (event.type === "message.delta") {
22501
- input.onStdout?.(event.content);
22502
- streamed += event.content;
22503
- } else if (event.type === "tool.intent") {
22504
- toolCalls.push({ title: event.tool, input: event.args });
22505
- } else if (event.type === "usage") {
22506
- usage = {
22507
- inputTokens: event.usage.inputTokens,
22508
- outputTokens: event.usage.outputTokens,
22509
- cachedTokens: event.usage.cachedTokens
22510
- };
22511
- } else if (event.type === "session.complete") {
22512
- completed = event.result.output;
22513
- } else if (event.type === "session.error") {
22514
- failure = event.error;
22515
- }
22516
- }
22517
- } finally {
22518
- await transcript?.close();
22519
- }
22520
- if (failure) {
22521
- return {
22522
- stdout: streamed,
22523
- stderr: failure.message,
22524
- exitCode: 1,
22525
- ...transcript ? { logFile: transcript.filePath } : {},
22526
- ...usage ? { usage } : {}
22527
- };
22528
- }
22529
- const output = completed || streamed;
22530
- return {
22531
- stdout: output,
22532
- stderr: "",
22533
- exitCode: 0,
22534
- summary: output,
22535
- ...transcript ? { logFile: transcript.filePath } : {},
22536
- ...toolCalls.length > 0 ? { toolCalls } : {},
22537
- ...usage ? { usage } : {}
22538
- };
22539
- }
22540
- function toPoeMcpConfigs(servers) {
22541
- if (!servers) {
22542
- return [];
22543
- }
22544
- return Object.entries(servers).map(([name, server]) => ({ name, ...server }));
22676
+ signal: input.signal,
22677
+ onStdout: input.onStdout,
22678
+ logPath: input.logPath
22679
+ });
22545
22680
  }
22546
22681
 
22547
22682
  // packages/superintendent/src/commands/run.ts
@@ -22640,12 +22775,12 @@ var runMcpCommand = defineCommand({
22640
22775
  },
22641
22776
  render: runCommand2.render
22642
22777
  });
22643
- async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs3) {
22778
+ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs4) {
22644
22779
  const configPath = resolveConfigPath(homeDir);
22645
22780
  const projectConfigPath = resolveProjectConfigPath(cwd);
22646
22781
  try {
22647
22782
  const document = await readMergedDocument(
22648
- createConfigResolutionFs(fs3),
22783
+ createConfigResolutionFs(fs4),
22649
22784
  configPath,
22650
22785
  projectConfigPath
22651
22786
  );
@@ -22663,48 +22798,48 @@ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs3) {
22663
22798
  return { tui: false };
22664
22799
  }
22665
22800
  }
22666
- async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs3) {
22801
+ async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs4) {
22667
22802
  const configPath = resolveConfigPath(homeDir);
22668
22803
  const projectConfigPath = resolveProjectConfigPath(cwd);
22669
22804
  const document = await readMergedDocument(
22670
- createConfigResolutionFs(fs3),
22805
+ createConfigResolutionFs(fs4),
22671
22806
  configPath,
22672
22807
  projectConfigPath
22673
22808
  );
22674
22809
  return resolveScope(planConfigScope.schema, document.plan, env).plan_directory;
22675
22810
  }
22676
22811
  var configFs = {
22677
- readFile: (filePath, encoding) => fsPromises6.readFile(filePath, encoding),
22812
+ readFile: (filePath, encoding) => fsPromises7.readFile(filePath, encoding),
22678
22813
  writeFile: async (filePath, content, options) => {
22679
- await fsPromises6.writeFile(filePath, content, options ?? { encoding: "utf8" });
22814
+ await fsPromises7.writeFile(filePath, content, options ?? { encoding: "utf8" });
22680
22815
  },
22681
22816
  mkdir: async (filePath, options) => {
22682
- await fsPromises6.mkdir(filePath, options);
22817
+ await fsPromises7.mkdir(filePath, options);
22683
22818
  },
22684
- unlink: (filePath) => fsPromises6.unlink(filePath),
22819
+ unlink: (filePath) => fsPromises7.unlink(filePath),
22685
22820
  stat: async (filePath) => {
22686
- const stat6 = await fsPromises6.stat(filePath);
22687
- return { mode: stat6.mode };
22821
+ const stat7 = await fsPromises7.stat(filePath);
22822
+ return { mode: stat7.mode };
22688
22823
  },
22689
- readdir: (filePath) => fsPromises6.readdir(filePath)
22824
+ readdir: (filePath) => fsPromises7.readdir(filePath)
22690
22825
  };
22691
- function createConfigResolutionFs(fs3) {
22692
- if (!fs3) {
22826
+ function createConfigResolutionFs(fs4) {
22827
+ if (!fs4) {
22693
22828
  return configFs;
22694
22829
  }
22695
22830
  return {
22696
22831
  ...configFs,
22697
- readFile: (filePath, encoding) => fs3.readFile(filePath, encoding),
22832
+ readFile: (filePath, encoding) => fs4.readFile(filePath, encoding),
22698
22833
  writeFile: async (filePath, content, options) => {
22699
- await fs3.writeFile(filePath, content, options);
22834
+ await fs4.writeFile(filePath, content, options);
22700
22835
  },
22701
22836
  mkdir: async (filePath, options) => {
22702
- await fs3.mkdir(filePath, options);
22837
+ await fs4.mkdir(filePath, options);
22703
22838
  }
22704
22839
  };
22705
22840
  }
22706
22841
  async function runSuperintendentCommand(options) {
22707
- const fs3 = options.fs ?? createDefaultFs3();
22842
+ const fs4 = options.fs ?? createDefaultFs3();
22708
22843
  const now = options.now ?? Date.now;
22709
22844
  const selectPrompt = options.selectPrompt ?? select2;
22710
22845
  const dashboardFactory = options.createDashboard ?? createDashboard;
@@ -22725,7 +22860,7 @@ async function runSuperintendentCommand(options) {
22725
22860
  assumeYes,
22726
22861
  interactive,
22727
22862
  env,
22728
- fs: fs3,
22863
+ fs: fs4,
22729
22864
  selectPrompt
22730
22865
  });
22731
22866
  const runLogDir = resolveRunLogDir({
@@ -22733,7 +22868,7 @@ async function runSuperintendentCommand(options) {
22733
22868
  runner: "superintendent",
22734
22869
  homeDir: options.homeDir
22735
22870
  });
22736
- const document = parseSuperintendentDoc(selectedDocPath, await fs3.readFile(selectedDocPath, "utf8"));
22871
+ const document = parseSuperintendentDoc(selectedDocPath, await fs4.readFile(selectedDocPath, "utf8"));
22737
22872
  const builderAgent = options.builderAgent ?? document.frontmatter.builder.agent;
22738
22873
  const selectedBuilderAgent = resolveAgentId(builderAgent) ?? builderAgent;
22739
22874
  if (!useDashboard) {
@@ -22749,7 +22884,7 @@ async function runSuperintendentCommand(options) {
22749
22884
  docPath: selectedDocPath,
22750
22885
  cwd: options.cwd,
22751
22886
  homeDir: options.homeDir,
22752
- ...options.fs ? { fs: fs3 } : {},
22887
+ ...options.fs ? { fs: fs4 } : {},
22753
22888
  signal: headlessAbort.signal,
22754
22889
  logDir: runLogDir,
22755
22890
  callbacks: {
@@ -22999,7 +23134,7 @@ async function runSuperintendentCommand(options) {
22999
23134
  session.pauseRequested = true;
23000
23135
  }
23001
23136
  editPlan(session.dashboard, session.latestLogFile, env, options.openInEditor);
23002
- appendEvent("info", `Log opened: ${path24.basename(session.latestLogFile)}`);
23137
+ appendEvent("info", `Log opened: ${path26.basename(session.latestLogFile)}`);
23003
23138
  syncStats();
23004
23139
  }
23005
23140
  };
@@ -23019,7 +23154,7 @@ async function runSuperintendentCommand(options) {
23019
23154
  docPath: selectedDocPath,
23020
23155
  cwd: options.cwd,
23021
23156
  homeDir: options.homeDir,
23022
- ...options.fs ? { fs: fs3 } : {},
23157
+ ...options.fs ? { fs: fs4 } : {},
23023
23158
  callbacks,
23024
23159
  signal: abortController.signal,
23025
23160
  logDir: runLogDir,
@@ -23137,24 +23272,24 @@ async function discoverSuperintendentDocs(options) {
23137
23272
  }
23138
23273
  return matches2;
23139
23274
  }
23140
- async function listPlanDirectoryDocs(fs3, planDirectory, cwd, homeDir) {
23275
+ async function listPlanDirectoryDocs(fs4, planDirectory, cwd, homeDir) {
23141
23276
  const absoluteDir = resolveAbsolutePlanDirectory(planDirectory, cwd, homeDir);
23142
23277
  let entries;
23143
23278
  try {
23144
- entries = await fs3.readdir(absoluteDir);
23279
+ entries = await fs4.readdir(absoluteDir);
23145
23280
  } catch (error2) {
23146
23281
  if (isMissingDirectory(error2)) {
23147
23282
  return [];
23148
23283
  }
23149
23284
  throw error2;
23150
23285
  }
23151
- return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) => path24.join(absoluteDir, entry)).sort((left, right) => left.localeCompare(right));
23286
+ return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) => path26.join(absoluteDir, entry)).sort((left, right) => left.localeCompare(right));
23152
23287
  }
23153
23288
  function resolveAbsolutePlanDirectory(dir, cwd, homeDir) {
23154
23289
  if (dir.startsWith("~/")) {
23155
- return path24.join(homeDir, dir.slice(2));
23290
+ return path26.join(homeDir, dir.slice(2));
23156
23291
  }
23157
- return path24.isAbsolute(dir) ? dir : path24.resolve(cwd, dir);
23292
+ return path26.isAbsolute(dir) ? dir : path26.resolve(cwd, dir);
23158
23293
  }
23159
23294
  function isMissingDirectory(error2) {
23160
23295
  if (!error2 || typeof error2 !== "object" || !("code" in error2)) {
@@ -23251,8 +23386,7 @@ async function executeSpawnAgent(agent2, input) {
23251
23386
  ...input.mode ? { mode: input.mode } : {},
23252
23387
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
23253
23388
  ...input.signal ? { signal: input.signal } : {},
23254
- ...input.logDir ? { logDir: input.logDir } : {},
23255
- ...input.logFileName ? { logFileName: input.logFileName } : {},
23389
+ ...input.logPath ? { logPath: input.logPath } : {},
23256
23390
  ...tee ? { tee } : {}
23257
23391
  });
23258
23392
  return {
@@ -23291,8 +23425,7 @@ async function executeSpawnAgentStreaming(agent2, input) {
23291
23425
  prompt: input.prompt,
23292
23426
  cwd: input.cwd,
23293
23427
  startedAt: /* @__PURE__ */ new Date(),
23294
- ...input.logDir ? { logDir: input.logDir } : {},
23295
- ...input.logFileName ? { logFileName: input.logFileName } : {},
23428
+ ...input.logPath ? { logPath: input.logPath } : {},
23296
23429
  ...input.mode ? { mode: input.mode } : {}
23297
23430
  };
23298
23431
  await applyMiddlewares([spawnLog, usageCapture, sessionCapture], middlewareContext);
@@ -23386,7 +23519,7 @@ function resolveEditor(env) {
23386
23519
  const parts = raw.split(/\s+/);
23387
23520
  const command = parts[0] ?? "vi";
23388
23521
  const args = parts.slice(1);
23389
- const binary = path24.basename(command);
23522
+ const binary = path26.basename(command);
23390
23523
  const mode = GUI_EDITOR_BINARIES.has(binary) ? "gui" : "tty";
23391
23524
  return { command, args, mode };
23392
23525
  }
@@ -23413,35 +23546,35 @@ function stripStopReason(result) {
23413
23546
  };
23414
23547
  }
23415
23548
  function displayPath(filePath, cwd, homeDir) {
23416
- if (filePath.startsWith(`${cwd}${path24.sep}`)) {
23417
- return path24.relative(cwd, filePath);
23549
+ if (filePath.startsWith(`${cwd}${path26.sep}`)) {
23550
+ return path26.relative(cwd, filePath);
23418
23551
  }
23419
- if (filePath.startsWith(`${homeDir}${path24.sep}`)) {
23420
- return `~/${path24.relative(homeDir, filePath)}`;
23552
+ if (filePath.startsWith(`${homeDir}${path26.sep}`)) {
23553
+ return `~/${path26.relative(homeDir, filePath)}`;
23421
23554
  }
23422
23555
  return filePath;
23423
23556
  }
23424
23557
  function createDefaultFs3() {
23425
23558
  return {
23426
- readFile: fsPromises6.readFile,
23427
- writeFile: fsPromises6.writeFile,
23428
- readdir: fsPromises6.readdir,
23559
+ readFile: fsPromises7.readFile,
23560
+ writeFile: fsPromises7.writeFile,
23561
+ readdir: fsPromises7.readdir,
23429
23562
  stat: async (filePath) => {
23430
- const stat6 = await fsPromises6.stat(filePath);
23563
+ const stat7 = await fsPromises7.stat(filePath);
23431
23564
  return {
23432
- isFile: () => stat6.isFile(),
23433
- isDirectory: () => stat6.isDirectory(),
23434
- mtimeMs: stat6.mtimeMs
23565
+ isFile: () => stat7.isFile(),
23566
+ isDirectory: () => stat7.isDirectory(),
23567
+ mtimeMs: stat7.mtimeMs
23435
23568
  };
23436
23569
  },
23437
23570
  mkdir: async (filePath, mkdirOptions) => {
23438
- await fsPromises6.mkdir(filePath, mkdirOptions);
23571
+ await fsPromises7.mkdir(filePath, mkdirOptions);
23439
23572
  },
23440
23573
  rmdir: async (filePath) => {
23441
- await fsPromises6.rmdir(filePath);
23574
+ await fsPromises7.rmdir(filePath);
23442
23575
  },
23443
23576
  rename: async (oldPath, newPath) => {
23444
- await fsPromises6.rename(oldPath, newPath);
23577
+ await fsPromises7.rename(oldPath, newPath);
23445
23578
  }
23446
23579
  };
23447
23580
  }
@@ -23459,8 +23592,8 @@ var validateCommand = defineCommand({
23459
23592
  positional: ["path"],
23460
23593
  params: validateParams,
23461
23594
  scope: ["cli", "mcp", "sdk"],
23462
- handler: async ({ params, fs: fs3 }) => {
23463
- const content = await readDocument6(params.path, fs3);
23595
+ handler: async ({ params, fs: fs4 }) => {
23596
+ const content = await readDocument6(params.path, fs4);
23464
23597
  return validateSuperintendentDocument(params.path, content);
23465
23598
  },
23466
23599
  render: {
@@ -23493,7 +23626,7 @@ var superintendentGroup = defineGroup({
23493
23626
  name: "superintendent",
23494
23627
  description: "Superintendent workflow commands.",
23495
23628
  scope: ["cli", "mcp", "sdk"],
23496
- children: [runCommand2, validateCommand, completeCommand, installCommand, builderGroup, inspectorGroup]
23629
+ children: [runCommand2, validateCommand, completeCommand, installCommand, planPathCommand, builderGroup, inspectorGroup]
23497
23630
  });
23498
23631
  var superintendentMcpGroup = defineGroup({
23499
23632
  name: "superintendent",
@@ -23537,9 +23670,9 @@ function validateSuperintendentDocument(filePath, content) {
23537
23670
  problems.push(...validatePromptVariables(document));
23538
23671
  return toValidationResult(problems);
23539
23672
  }
23540
- async function readDocument6(filePath, fs3) {
23673
+ async function readDocument6(filePath, fs4) {
23541
23674
  try {
23542
- return await fs3.readFile(filePath, "utf8");
23675
+ return await fs4.readFile(filePath, "utf8");
23543
23676
  } catch (error2) {
23544
23677
  if (hasCode5(error2, "ENOENT")) {
23545
23678
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -24025,29 +24158,29 @@ function emitEvent(callback, event) {
24025
24158
  callback(event);
24026
24159
  }
24027
24160
  async function loadConfiguredPlugins(options) {
24028
- const fs3 = createConfigFileSystem(options.fs);
24161
+ const fs4 = createConfigFileSystem(options.fs);
24029
24162
  const homeDir = options.homeDir ?? os3.homedir();
24030
24163
  const store = createConfigStore({
24031
- fs: fs3,
24164
+ fs: fs4,
24032
24165
  filePath: options.configPath ?? resolveConfigPath(homeDir),
24033
24166
  projectFilePath: options.projectConfigPath ?? resolveProjectConfigPath(options.cwd)
24034
24167
  });
24035
24168
  const plugins = await store.scope(agentConfigScope).get("plugins");
24036
24169
  return plugins ?? void 0;
24037
24170
  }
24038
- function createConfigFileSystem(fs3) {
24039
- if (fs3) {
24040
- return fs3;
24171
+ function createConfigFileSystem(fs4) {
24172
+ if (fs4) {
24173
+ return fs4;
24041
24174
  }
24042
24175
  return {
24043
24176
  readFile(filePath, encoding) {
24044
- return encoding ? fsPromises7.readFile(filePath, encoding) : fsPromises7.readFile(filePath);
24177
+ return encoding ? fsPromises8.readFile(filePath, encoding) : fsPromises8.readFile(filePath);
24045
24178
  },
24046
24179
  async writeFile(filePath, data, options) {
24047
- await fsPromises7.writeFile(filePath, data, options);
24180
+ await fsPromises8.writeFile(filePath, data, options);
24048
24181
  },
24049
24182
  async mkdir(filePath, options) {
24050
- await fsPromises7.mkdir(filePath, options);
24183
+ await fsPromises8.mkdir(filePath, options);
24051
24184
  }
24052
24185
  };
24053
24186
  }