poe-code 3.0.184 → 3.0.186

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 (258) 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.js +32 -48
  16. package/dist/cli/commands/pipeline-init.js.map +1 -1
  17. package/dist/cli/commands/pipeline.js +89 -77
  18. package/dist/cli/commands/pipeline.js.map +1 -1
  19. package/dist/cli/commands/provider.d.ts +6 -0
  20. package/dist/cli/commands/provider.js +100 -0
  21. package/dist/cli/commands/provider.js.map +1 -0
  22. package/dist/cli/commands/shared.d.ts +7 -0
  23. package/dist/cli/commands/shared.js +3 -0
  24. package/dist/cli/commands/shared.js.map +1 -1
  25. package/dist/cli/commands/test.js +1 -1
  26. package/dist/cli/commands/test.js.map +1 -1
  27. package/dist/cli/commands/unconfigure.js +12 -3
  28. package/dist/cli/commands/unconfigure.js.map +1 -1
  29. package/dist/cli/container.d.ts +2 -0
  30. package/dist/cli/container.js +3 -0
  31. package/dist/cli/container.js.map +1 -1
  32. package/dist/cli/isolated-env-runner.js +2 -2
  33. package/dist/cli/isolated-env-runner.js.map +1 -1
  34. package/dist/cli/isolated-env.d.ts +3 -2
  35. package/dist/cli/isolated-env.js +31 -40
  36. package/dist/cli/isolated-env.js.map +1 -1
  37. package/dist/cli/poe-code-command-runner.js +9 -2
  38. package/dist/cli/poe-code-command-runner.js.map +1 -1
  39. package/dist/cli/program.js +5 -0
  40. package/dist/cli/program.js.map +1 -1
  41. package/dist/cli/service-registry.d.ts +7 -7
  42. package/dist/cli/service-registry.js.map +1 -1
  43. package/dist/index.js +2496 -1911
  44. package/dist/index.js.map +4 -4
  45. package/dist/providers/claude-code.d.ts +2 -1
  46. package/dist/providers/claude-code.js +5 -5
  47. package/dist/providers/claude-code.js.map +2 -2
  48. package/dist/providers/codex.d.ts +5 -1
  49. package/dist/providers/codex.js +39 -12
  50. package/dist/providers/codex.js.map +2 -2
  51. package/dist/providers/goose.d.ts +2 -1
  52. package/dist/providers/goose.js +24 -8
  53. package/dist/providers/goose.js.map +3 -3
  54. package/dist/providers/kimi.js +3 -3
  55. package/dist/providers/kimi.js.map +3 -3
  56. package/dist/providers/opencode.js +2 -2
  57. package/dist/providers/opencode.js.map +3 -3
  58. package/dist/providers/poe-agent.js +753 -649
  59. package/dist/providers/poe-agent.js.map +4 -4
  60. package/dist/sdk/container.js +3 -0
  61. package/dist/sdk/container.js.map +1 -1
  62. package/dist/sdk/pipeline.d.ts +1 -2
  63. package/dist/sdk/pipeline.js +51 -119
  64. package/dist/sdk/pipeline.js.map +1 -1
  65. package/dist/services/config.d.ts +1 -0
  66. package/dist/services/config.js +27 -2
  67. package/dist/services/config.js.map +1 -1
  68. package/dist/templates/pipeline/SKILL_plan.md +16 -42
  69. package/package.json +15 -1
  70. package/packages/agent-mcp-config/dist/apply.d.ts +6 -0
  71. package/packages/agent-mcp-config/dist/apply.js +175 -0
  72. package/packages/agent-mcp-config/dist/configs.d.ts +22 -0
  73. package/packages/agent-mcp-config/dist/configs.js +74 -0
  74. package/packages/agent-mcp-config/dist/index.d.ts +3 -0
  75. package/packages/agent-mcp-config/dist/index.js +2 -0
  76. package/packages/agent-mcp-config/dist/shapes.d.ts +31 -0
  77. package/packages/agent-mcp-config/dist/shapes.js +87 -0
  78. package/packages/agent-mcp-config/dist/types.d.ts +25 -0
  79. package/packages/agent-mcp-config/dist/types.js +1 -0
  80. package/packages/agent-skill-config/dist/apply.d.ts +25 -0
  81. package/packages/agent-skill-config/dist/apply.js +109 -0
  82. package/packages/agent-skill-config/dist/configs.d.ts +16 -0
  83. package/packages/agent-skill-config/dist/configs.js +66 -0
  84. package/packages/agent-skill-config/dist/exports.compile-check.d.ts +1 -0
  85. package/packages/agent-skill-config/dist/exports.compile-check.js +1 -0
  86. package/packages/agent-skill-config/dist/index.d.ts +5 -0
  87. package/packages/agent-skill-config/dist/index.js +2 -0
  88. package/packages/agent-skill-config/dist/templates/poe-generate.md +47 -0
  89. package/packages/agent-skill-config/dist/templates/terminal-pilot.md +45 -0
  90. package/packages/agent-skill-config/dist/templates.d.ts +3 -0
  91. package/packages/agent-skill-config/dist/templates.js +63 -0
  92. package/packages/agent-skill-config/dist/types.d.ts +16 -0
  93. package/packages/agent-skill-config/dist/types.js +1 -0
  94. package/packages/cmdkit/dist/cli.js +7 -2
  95. package/packages/cmdkit/dist/cli.js.map +2 -2
  96. package/packages/cmdkit-openapi/dist/api-command.d.ts +7 -0
  97. package/packages/cmdkit-openapi/dist/api-command.js +4 -0
  98. package/packages/cmdkit-openapi/dist/auth/bearer-token-auth.d.ts +8 -0
  99. package/packages/cmdkit-openapi/dist/auth/bearer-token-auth.js +216 -0
  100. package/packages/cmdkit-openapi/dist/auth/types.d.ts +9 -0
  101. package/packages/cmdkit-openapi/dist/auth/types.js +1 -0
  102. package/packages/cmdkit-openapi/dist/bin/generate.d.ts +40 -0
  103. package/packages/cmdkit-openapi/dist/bin/generate.js +248 -0
  104. package/packages/cmdkit-openapi/dist/define-client.d.ts +20 -0
  105. package/packages/cmdkit-openapi/dist/define-client.js +148 -0
  106. package/packages/cmdkit-openapi/dist/generate.d.ts +210 -0
  107. package/packages/cmdkit-openapi/dist/generate.js +1091 -0
  108. package/packages/cmdkit-openapi/dist/group-by-noun.d.ts +6 -0
  109. package/packages/cmdkit-openapi/dist/group-by-noun.js +17 -0
  110. package/packages/cmdkit-openapi/dist/http.d.ts +26 -0
  111. package/packages/cmdkit-openapi/dist/http.js +123 -0
  112. package/packages/cmdkit-openapi/dist/index.d.ts +12 -0
  113. package/packages/cmdkit-openapi/dist/index.js +6 -0
  114. package/packages/cmdkit-openapi/dist/interpreter.d.ts +6 -0
  115. package/packages/cmdkit-openapi/dist/interpreter.js +289 -0
  116. package/packages/cmdkit-openapi/dist/lock.d.ts +14 -0
  117. package/packages/cmdkit-openapi/dist/lock.js +48 -0
  118. package/packages/cmdkit-openapi/dist/naming.d.ts +24 -0
  119. package/packages/cmdkit-openapi/dist/naming.js +218 -0
  120. package/packages/cmdkit-openapi/dist/request-shape.d.ts +15 -0
  121. package/packages/cmdkit-openapi/dist/request-shape.js +5 -0
  122. package/packages/cmdkit-openapi/dist/runtime.d.ts +13 -0
  123. package/packages/cmdkit-openapi/dist/runtime.js +94 -0
  124. package/packages/cmdkit-openapi/dist/spec-source.d.ts +11 -0
  125. package/packages/cmdkit-openapi/dist/spec-source.js +63 -0
  126. package/packages/config-mutations/dist/execution/apply-mutation.d.ts +5 -0
  127. package/packages/config-mutations/dist/execution/apply-mutation.js +552 -0
  128. package/packages/config-mutations/dist/execution/path-utils.d.ts +17 -0
  129. package/packages/config-mutations/dist/execution/path-utils.js +58 -0
  130. package/packages/config-mutations/dist/execution/run-mutations.d.ts +7 -0
  131. package/packages/config-mutations/dist/execution/run-mutations.js +46 -0
  132. package/packages/config-mutations/dist/formats/index.d.ts +13 -0
  133. package/packages/config-mutations/dist/formats/index.js +49 -0
  134. package/packages/config-mutations/dist/formats/json.d.ts +31 -0
  135. package/packages/config-mutations/dist/formats/json.js +140 -0
  136. package/packages/config-mutations/dist/formats/toml.d.ts +2 -0
  137. package/packages/config-mutations/dist/formats/toml.js +72 -0
  138. package/packages/config-mutations/dist/formats/yaml.d.ts +2 -0
  139. package/packages/config-mutations/dist/formats/yaml.js +73 -0
  140. package/packages/config-mutations/dist/fs-utils.d.ts +18 -0
  141. package/packages/config-mutations/dist/fs-utils.js +45 -0
  142. package/packages/config-mutations/dist/index.d.ts +8 -0
  143. package/packages/config-mutations/dist/index.js +8 -0
  144. package/packages/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
  145. package/packages/config-mutations/dist/mutations/config-mutation.js +34 -0
  146. package/packages/config-mutations/dist/mutations/file-mutation.d.ts +52 -0
  147. package/packages/config-mutations/dist/mutations/file-mutation.js +46 -0
  148. package/packages/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
  149. package/packages/config-mutations/dist/mutations/template-mutation.js +32 -0
  150. package/packages/config-mutations/dist/template/render.d.ts +7 -0
  151. package/packages/config-mutations/dist/template/render.js +28 -0
  152. package/packages/config-mutations/dist/testing/format-utils.d.ts +7 -0
  153. package/packages/config-mutations/dist/testing/format-utils.js +21 -0
  154. package/packages/config-mutations/dist/testing/index.d.ts +3 -0
  155. package/packages/config-mutations/dist/testing/index.js +2 -0
  156. package/packages/config-mutations/dist/testing/mock-fs.d.ts +25 -0
  157. package/packages/config-mutations/dist/testing/mock-fs.js +170 -0
  158. package/packages/config-mutations/dist/types.d.ts +156 -0
  159. package/packages/config-mutations/dist/types.js +6 -0
  160. package/packages/memory/dist/audit.d.ts +11 -0
  161. package/packages/memory/dist/audit.js +131 -0
  162. package/packages/memory/dist/cache.cli.d.ts +9 -0
  163. package/packages/memory/dist/cache.cli.js +24 -0
  164. package/packages/memory/dist/cache.d.ts +14 -0
  165. package/packages/memory/dist/cache.js +149 -0
  166. package/packages/memory/dist/confidence.d.ts +4 -0
  167. package/packages/memory/dist/confidence.js +201 -0
  168. package/packages/memory/dist/corpus/001-archaeoastronomy.md +479 -0
  169. package/packages/memory/dist/corpus/002-magnetohydrodynamics.md +475 -0
  170. package/packages/memory/dist/corpus/003-biosemiotics.md +483 -0
  171. package/packages/memory/dist/corpus/004-cryopedology.md +483 -0
  172. package/packages/memory/dist/corpus/005-geomicrobiology.md +479 -0
  173. package/packages/memory/dist/corpus/006-aeronomy.md +487 -0
  174. package/packages/memory/dist/corpus/007-paleoclimatology.md +479 -0
  175. package/packages/memory/dist/corpus/008-hydrogeophysics.md +479 -0
  176. package/packages/memory/dist/corpus/009-magnetostratigraphy.md +475 -0
  177. package/packages/memory/dist/corpus/010-isotope-hydrology.md +481 -0
  178. package/packages/memory/dist/corpus/011-speleothem-geochemistry.md +474 -0
  179. package/packages/memory/dist/corpus/012-astrobiogeochemistry.md +475 -0
  180. package/packages/memory/dist/corpus/013-neuroethology.md +483 -0
  181. package/packages/memory/dist/corpus/014-chronophysiology.md +483 -0
  182. package/packages/memory/dist/corpus/015-limnogeochemistry.md +475 -0
  183. package/packages/memory/dist/corpus/016-palynology.md +483 -0
  184. package/packages/memory/dist/corpus/017-volcanotectonics.md +473 -0
  185. package/packages/memory/dist/corpus/018-seismotectonics.md +473 -0
  186. package/packages/memory/dist/corpus/019-biogeomorphology.md +475 -0
  187. package/packages/memory/dist/corpus/020-geobiophysics.md +479 -0
  188. package/packages/memory/dist/corpus/021-phytolith-analysis.md +481 -0
  189. package/packages/memory/dist/corpus/022-archaeometallurgy.md +479 -0
  190. package/packages/memory/dist/corpus/023-paleomagnetism.md +479 -0
  191. package/packages/memory/dist/corpus/024-biocalorimetry.md +475 -0
  192. package/packages/memory/dist/corpus/025-atmospheric-chemiluminescence.md +473 -0
  193. package/packages/memory/dist/corpus/026-cryoseismology.md +479 -0
  194. package/packages/memory/dist/corpus/027-extremophile-radiobiology.md +475 -0
  195. package/packages/memory/dist/corpus/028-heliophysics.md +479 -0
  196. package/packages/memory/dist/corpus/029-astroparticle-geophysics.md +474 -0
  197. package/packages/memory/dist/corpus/030-glaciohydrology.md +479 -0
  198. package/packages/memory/dist/corpus/031-permafrost-microbiology.md +477 -0
  199. package/packages/memory/dist/corpus/032-ecoacoustics.md +479 -0
  200. package/packages/memory/dist/corpus/033-dendroclimatology.md +473 -0
  201. package/packages/memory/dist/corpus/034-ionospheric-tomography.md +477 -0
  202. package/packages/memory/dist/corpus/035-marine-geodesy.md +481 -0
  203. package/packages/memory/dist/corpus/036-sedimentary-ancient-dna.md +481 -0
  204. package/packages/memory/dist/corpus/037-myrmecochory-dynamics.md +474 -0
  205. package/packages/memory/dist/corpus/038-chemosensory-ecology.md +477 -0
  206. package/packages/memory/dist/corpus/039-spintronics-materials.md +479 -0
  207. package/packages/memory/dist/corpus/040-nanotoxicology.md +483 -0
  208. package/packages/memory/dist/corpus/041-cosmochemistry.md +483 -0
  209. package/packages/memory/dist/corpus/042-quaternary-geochronology.md +471 -0
  210. package/packages/memory/dist/corpus/043-biophotonics.md +479 -0
  211. package/packages/memory/dist/corpus/044-evolutionary-morphometrics.md +481 -0
  212. package/packages/memory/dist/corpus/045-cryovolcanology.md +475 -0
  213. package/packages/memory/dist/corpus/046-exoplanet-atmospheric-dynamics.md +479 -0
  214. package/packages/memory/dist/corpus/047-microbial-electrosynthesis.md +477 -0
  215. package/packages/memory/dist/corpus/048-paleoseismology.md +479 -0
  216. package/packages/memory/dist/corpus/049-actinide-geochemistry.md +477 -0
  217. package/packages/memory/dist/corpus/050-quantum-biology.md +489 -0
  218. package/packages/memory/dist/edit.d.ts +10 -0
  219. package/packages/memory/dist/edit.js +43 -0
  220. package/packages/memory/dist/explain.cli.d.ts +8 -0
  221. package/packages/memory/dist/explain.cli.js +9 -0
  222. package/packages/memory/dist/explain.d.ts +8 -0
  223. package/packages/memory/dist/explain.js +77 -0
  224. package/packages/memory/dist/frontmatter.d.ts +9 -0
  225. package/packages/memory/dist/frontmatter.js +217 -0
  226. package/packages/memory/dist/index.d.ts +21 -0
  227. package/packages/memory/dist/index.js +4807 -0
  228. package/packages/memory/dist/index.js.map +7 -0
  229. package/packages/memory/dist/ingest.d.ts +3 -0
  230. package/packages/memory/dist/ingest.js +118 -0
  231. package/packages/memory/dist/init.d.ts +2 -0
  232. package/packages/memory/dist/init.js +24 -0
  233. package/packages/memory/dist/install.d.ts +18 -0
  234. package/packages/memory/dist/install.js +50 -0
  235. package/packages/memory/dist/lock.d.ts +19 -0
  236. package/packages/memory/dist/lock.js +102 -0
  237. package/packages/memory/dist/mcp.d.ts +7 -0
  238. package/packages/memory/dist/mcp.js +58 -0
  239. package/packages/memory/dist/pages.d.ts +4 -0
  240. package/packages/memory/dist/pages.js +92 -0
  241. package/packages/memory/dist/paths.d.ts +12 -0
  242. package/packages/memory/dist/paths.js +34 -0
  243. package/packages/memory/dist/query.d.ts +10 -0
  244. package/packages/memory/dist/query.js +130 -0
  245. package/packages/memory/dist/reconcile.d.ts +9 -0
  246. package/packages/memory/dist/reconcile.js +138 -0
  247. package/packages/memory/dist/resolve-root.d.ts +11 -0
  248. package/packages/memory/dist/resolve-root.js +22 -0
  249. package/packages/memory/dist/search.d.ts +2 -0
  250. package/packages/memory/dist/search.js +29 -0
  251. package/packages/memory/dist/status.d.ts +7 -0
  252. package/packages/memory/dist/status.js +46 -0
  253. package/packages/memory/dist/tokens.d.ts +2 -0
  254. package/packages/memory/dist/tokens.js +71 -0
  255. package/packages/memory/dist/types.d.ts +155 -0
  256. package/packages/memory/dist/types.js +1 -0
  257. package/packages/memory/dist/write.d.ts +9 -0
  258. 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
  );
@@ -15456,8 +15688,8 @@ function parseBinding(binding) {
15456
15688
  let ctrl = false;
15457
15689
  let meta = false;
15458
15690
  let shift = false;
15459
- const key = parts.at(-1);
15460
- if (key === void 0) {
15691
+ const key2 = parts.at(-1);
15692
+ if (key2 === void 0) {
15461
15693
  return void 0;
15462
15694
  }
15463
15695
  for (const modifier of parts.slice(0, -1)) {
@@ -15475,19 +15707,19 @@ function parseBinding(binding) {
15475
15707
  continue;
15476
15708
  }
15477
15709
  }
15478
- if (parts.length === 1 && isShiftedCharacter(key)) {
15710
+ if (parts.length === 1 && isShiftedCharacter(key2)) {
15479
15711
  shift = true;
15480
15712
  }
15481
- if (key.length === 1) {
15713
+ if (key2.length === 1) {
15482
15714
  return {
15483
- ch: normalizeBindingCharacter(key, shift),
15715
+ ch: normalizeBindingCharacter(key2, shift),
15484
15716
  ctrl,
15485
15717
  meta,
15486
15718
  shift
15487
15719
  };
15488
15720
  }
15489
15721
  return {
15490
- name: key.toLowerCase(),
15722
+ name: key2.toLowerCase(),
15491
15723
  ctrl,
15492
15724
  meta,
15493
15725
  shift
@@ -15796,8 +16028,8 @@ function createTerminalDriver(opts) {
15796
16028
  return () => {
15797
16029
  };
15798
16030
  }
15799
- const listener = (str, key) => {
15800
- const event = toKeypressEvent(str, key);
16031
+ const listener = (str, key2) => {
16032
+ const event = toKeypressEvent(str, key2);
15801
16033
  if (event !== void 0) {
15802
16034
  handler(event);
15803
16035
  }
@@ -15847,19 +16079,19 @@ function createTerminalDriver(opts) {
15847
16079
  destroy
15848
16080
  };
15849
16081
  }
15850
- function toKeypressEvent(str, key) {
15851
- const ctrl = key?.ctrl ?? false;
15852
- const meta = key?.meta ?? false;
15853
- const shift = key?.shift ?? false;
15854
- 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);
15855
16087
  if (ch !== void 0) {
15856
16088
  return { ch, ctrl, meta, shift };
15857
16089
  }
15858
- if (key?.name === void 0) {
16090
+ if (key2?.name === void 0) {
15859
16091
  return void 0;
15860
16092
  }
15861
16093
  return {
15862
- name: key.name,
16094
+ name: key2.name,
15863
16095
  ctrl,
15864
16096
  meta,
15865
16097
  shift
@@ -16456,7 +16688,7 @@ var init_autonomous = __esm({
16456
16688
  });
16457
16689
 
16458
16690
  // packages/agent-spawn/src/acp/replay.ts
16459
- import path13 from "node:path";
16691
+ import path14 from "node:path";
16460
16692
  import { homedir as homedir3 } from "node:os";
16461
16693
  import { open, readdir } from "node:fs/promises";
16462
16694
  import { createInterface as createInterface2 } from "node:readline";
@@ -16494,8 +16726,8 @@ function extractTitle(name, input) {
16494
16726
  const keys = TITLE_KEYS[name];
16495
16727
  if (keys && input && typeof input === "object") {
16496
16728
  const obj = input;
16497
- for (const key of keys) {
16498
- const value = obj[key];
16729
+ for (const key2 of keys) {
16730
+ const value = obj[key2];
16499
16731
  if (typeof value === "string" && value.length > 0) {
16500
16732
  return truncate2(value, 80);
16501
16733
  }
@@ -16576,21 +16808,21 @@ async function* adaptClaude(lines) {
16576
16808
  if (blockType !== "tool_result") continue;
16577
16809
  const kind = toolKindsById.get(item.tool_use_id);
16578
16810
  toolKindsById.delete(item.tool_use_id);
16579
- let path26;
16811
+ let path28;
16580
16812
  if (typeof item.content === "string") {
16581
- path26 = item.content;
16813
+ path28 = item.content;
16582
16814
  } else {
16583
16815
  try {
16584
- path26 = JSON.stringify(item.content);
16816
+ path28 = JSON.stringify(item.content);
16585
16817
  } catch {
16586
- path26 = String(item.content);
16818
+ path28 = String(item.content);
16587
16819
  }
16588
16820
  }
16589
16821
  yield {
16590
16822
  event: "tool_complete",
16591
16823
  id: item.tool_use_id,
16592
16824
  kind,
16593
- path: path26
16825
+ path: path28
16594
16826
  };
16595
16827
  }
16596
16828
  }
@@ -16713,10 +16945,10 @@ async function* adaptCodex(lines) {
16713
16945
  const kindFromStart = toolKindById.get(item.id);
16714
16946
  const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
16715
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;
16716
- const path26 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
16948
+ const path28 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
16717
16949
  toolTitleById.delete(item.id);
16718
16950
  toolKindById.delete(item.id);
16719
- yield { event: "tool_complete", id: item.id, kind, path: path26 };
16951
+ yield { event: "tool_complete", id: item.id, kind, path: path28 };
16720
16952
  }
16721
16953
  }
16722
16954
  }
@@ -17240,7 +17472,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
17240
17472
  }
17241
17473
  const id = readString(event.id);
17242
17474
  const kind = readString(event.kind);
17243
- const path26 = readString(event.path);
17475
+ const path28 = readString(event.path);
17244
17476
  let toolCall = id ? toolCallsById.get(id) : void 0;
17245
17477
  if (!toolCall) {
17246
17478
  toolCall = {};
@@ -17255,8 +17487,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
17255
17487
  if (kind) {
17256
17488
  toolCall.kind = kind;
17257
17489
  }
17258
- if (path26) {
17259
- toolCall.path = path26;
17490
+ if (path28) {
17491
+ toolCall.path = path28;
17260
17492
  }
17261
17493
  }
17262
17494
  var sessionCapture;
@@ -17342,9 +17574,9 @@ var init_usage_capture = __esm({
17342
17574
  });
17343
17575
 
17344
17576
  // packages/agent-spawn/src/acp/middlewares/spawn-log.ts
17345
- import path14 from "node:path";
17577
+ import path15 from "node:path";
17346
17578
  import { homedir as homedir4 } from "node:os";
17347
- import { mkdir, open as open2 } from "node:fs/promises";
17579
+ import { mkdir as mkdir2, open as open2 } from "node:fs/promises";
17348
17580
  function pad(value, width) {
17349
17581
  return String(value).padStart(width, "0");
17350
17582
  }
@@ -17376,14 +17608,17 @@ function resolveStartedAt(value) {
17376
17608
  return value;
17377
17609
  }
17378
17610
  function resolveLogFilePath(ctx) {
17379
- 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");
17380
17615
  if (ctx.logFileName) {
17381
- return path14.join(baseDir, ctx.logFileName);
17616
+ return path15.join(baseDir, ctx.logFileName);
17382
17617
  }
17383
17618
  const startedAt = resolveStartedAt(ctx.startedAt);
17384
17619
  const { day, time, milliseconds } = formatTimestamp(startedAt);
17385
17620
  const fileName = `${day}-${time}-${milliseconds}-${normalizeAgent(ctx.agent)}.jsonl`;
17386
- return path14.join(baseDir, fileName);
17621
+ return path15.join(baseDir, fileName);
17387
17622
  }
17388
17623
  async function writePreloadedEvents(writer, events) {
17389
17624
  for (const event of events) {
@@ -17401,7 +17636,7 @@ var init_spawn_log = __esm({
17401
17636
  logDirPath;
17402
17637
  constructor(ctx) {
17403
17638
  this.filePath = resolveLogFilePath(ctx);
17404
- this.logDirPath = path14.dirname(this.filePath);
17639
+ this.logDirPath = path15.dirname(this.filePath);
17405
17640
  }
17406
17641
  async writeEvent(event) {
17407
17642
  if (this.isDisabled) {
@@ -17437,7 +17672,7 @@ var init_spawn_log = __esm({
17437
17672
  return;
17438
17673
  }
17439
17674
  try {
17440
- await mkdir(this.logDirPath, { recursive: true });
17675
+ await mkdir2(this.logDirPath, { recursive: true });
17441
17676
  this.fileHandle = await open2(this.filePath, "a");
17442
17677
  } catch {
17443
17678
  this.isDisabled = true;
@@ -17552,9 +17787,9 @@ var init_poe_agent_plugin_scratchpad = __esm({
17552
17787
  edit: true
17553
17788
  },
17554
17789
  call(args) {
17555
- const { key, value } = args;
17556
- notes.set(key, value);
17557
- return `Wrote '${key}'`;
17790
+ const { key: key2, value } = args;
17791
+ notes.set(key2, value);
17792
+ return `Wrote '${key2}'`;
17558
17793
  }
17559
17794
  },
17560
17795
  {
@@ -17714,9 +17949,11 @@ __export(src_exports, {
17714
17949
  collectProviders: () => collectProviders,
17715
17950
  compactionPlugin: () => poe_agent_plugin_compaction_default,
17716
17951
  createAgentSession: () => createAgentSession,
17952
+ createTranscriptWriter: () => createTranscriptWriter,
17717
17953
  environmentPlugin: () => poe_agent_plugin_environment_default,
17718
17954
  filesPlugin: () => poe_agent_plugin_files_default,
17719
17955
  gitContextPlugin: () => poe_agent_plugin_git_context_default,
17956
+ mapAcpEventToSessionUpdates: () => mapAcpEventToSessionUpdates,
17720
17957
  maxIterationsPlugin: () => poe_agent_plugin_max_iterations_default,
17721
17958
  mcpPlugin: () => mcpPlugin,
17722
17959
  memoryPlugin: () => poe_agent_plugin_memory_default,
@@ -17743,6 +17980,7 @@ var init_src7 = __esm({
17743
17980
  init_registry();
17744
17981
  init_resolve_plugins();
17745
17982
  init_resolve_provider();
17983
+ init_transcript();
17746
17984
  init_poe_agent_plugin_audit_log();
17747
17985
  init_poe_agent_plugin_compaction();
17748
17986
  init_poe_agent_plugin_environment();
@@ -17765,7 +18003,7 @@ var init_src7 = __esm({
17765
18003
  });
17766
18004
 
17767
18005
  // src/providers/poe-agent.ts
17768
- import fsPromises7 from "node:fs/promises";
18006
+ import fsPromises8 from "node:fs/promises";
17769
18007
  import os3 from "node:os";
17770
18008
 
17771
18009
  // src/cli/constants.ts
@@ -17822,7 +18060,7 @@ import path5 from "node:path";
17822
18060
 
17823
18061
  // packages/config-extends/src/discover.ts
17824
18062
  import path from "node:path";
17825
- async function findBase(name, bases, fs3) {
18063
+ async function findBase(name, bases, fs4) {
17826
18064
  const checkedPaths = [];
17827
18065
  for (const basePath of bases) {
17828
18066
  for (const extension of [".md", ".yaml", ".yml", ".json"]) {
@@ -17830,7 +18068,7 @@ async function findBase(name, bases, fs3) {
17830
18068
  checkedPaths.push(filePath);
17831
18069
  try {
17832
18070
  return {
17833
- content: await fs3.readFile(filePath, "utf8"),
18071
+ content: await fs4.readFile(filePath, "utf8"),
17834
18072
  filePath
17835
18073
  };
17836
18074
  } catch (error2) {
@@ -17910,15 +18148,15 @@ function stripBom(content) {
17910
18148
  function mergeLayers(layers) {
17911
18149
  return mergeObjectLayers(layers, []);
17912
18150
  }
17913
- function mergeObjectLayers(layers, path26) {
18151
+ function mergeObjectLayers(layers, path28) {
17914
18152
  const data = {};
17915
18153
  const sources = {};
17916
- for (const key of collectKeys(layers)) {
17917
- const resolved = resolveKey(layers, key, path26);
18154
+ for (const key2 of collectKeys(layers)) {
18155
+ const resolved = resolveKey(layers, key2, path28);
17918
18156
  if (resolved === void 0) {
17919
18157
  continue;
17920
18158
  }
17921
- data[key] = resolved.value;
18159
+ data[key2] = resolved.value;
17922
18160
  Object.assign(sources, resolved.sources);
17923
18161
  }
17924
18162
  return { data, sources };
@@ -17926,19 +18164,19 @@ function mergeObjectLayers(layers, path26) {
17926
18164
  function collectKeys(layers) {
17927
18165
  const keys = /* @__PURE__ */ new Set();
17928
18166
  for (const layer of layers) {
17929
- for (const key of Object.keys(layer.data)) {
17930
- keys.add(key);
18167
+ for (const key2 of Object.keys(layer.data)) {
18168
+ keys.add(key2);
17931
18169
  }
17932
18170
  }
17933
18171
  return [...keys];
17934
18172
  }
17935
- function resolveKey(layers, key, path26) {
18173
+ function resolveKey(layers, key2, path28) {
17936
18174
  let winningSource;
17937
18175
  let winningValue;
17938
18176
  const objectLayers = [];
17939
18177
  for (const layer of layers) {
17940
- const candidate = layer.data[key];
17941
- if (!isWinningCandidate(key, candidate)) {
18178
+ const candidate = layer.data[key2];
18179
+ if (!isWinningCandidate(key2, candidate)) {
17942
18180
  continue;
17943
18181
  }
17944
18182
  if (winningSource === void 0) {
@@ -17962,9 +18200,9 @@ function resolveKey(layers, key, path26) {
17962
18200
  if (winningSource === void 0) {
17963
18201
  return void 0;
17964
18202
  }
17965
- const fullPath = buildPath(path26, key);
18203
+ const fullPath = buildPath(path28, key2);
17966
18204
  if (isPlainObject(winningValue)) {
17967
- const merged = mergeObjectLayers(objectLayers, [...path26, key]);
18205
+ const merged = mergeObjectLayers(objectLayers, [...path28, key2]);
17968
18206
  return {
17969
18207
  value: merged.data,
17970
18208
  sources: {
@@ -17980,17 +18218,17 @@ function resolveKey(layers, key, path26) {
17980
18218
  }
17981
18219
  };
17982
18220
  }
17983
- function isWinningCandidate(key, value) {
18221
+ function isWinningCandidate(key2, value) {
17984
18222
  if (value === void 0) {
17985
18223
  return false;
17986
18224
  }
17987
- if (key === "prompt" && value === "") {
18225
+ if (key2 === "prompt" && value === "") {
17988
18226
  return false;
17989
18227
  }
17990
18228
  return true;
17991
18229
  }
17992
- function buildPath(path26, key) {
17993
- return [...path26, key].join(".");
18230
+ function buildPath(path28, key2) {
18231
+ return [...path28, key2].join(".");
17994
18232
  }
17995
18233
  function isPlainObject(value) {
17996
18234
  if (value === null || Array.isArray(value) || typeof value !== "object") {
@@ -18007,8 +18245,8 @@ function cloneValue(value) {
18007
18245
  return value;
18008
18246
  }
18009
18247
  const clone = Object.create(Object.getPrototypeOf(value));
18010
- for (const [key, entry] of Object.entries(value)) {
18011
- clone[key] = cloneValue(entry);
18248
+ for (const [key2, entry] of Object.entries(value)) {
18249
+ clone[key2] = cloneValue(entry);
18012
18250
  }
18013
18251
  return clone;
18014
18252
  }
@@ -18357,29 +18595,29 @@ function serialize(obj) {
18357
18595
  }
18358
18596
  function merge(base, patch) {
18359
18597
  const result = { ...base };
18360
- for (const [key, value] of Object.entries(patch)) {
18598
+ for (const [key2, value] of Object.entries(patch)) {
18361
18599
  if (value === void 0) {
18362
18600
  continue;
18363
18601
  }
18364
- const existing = result[key];
18602
+ const existing = result[key2];
18365
18603
  if (isConfigObject(existing) && isConfigObject(value)) {
18366
- result[key] = merge(existing, value);
18604
+ result[key2] = merge(existing, value);
18367
18605
  continue;
18368
18606
  }
18369
- result[key] = value;
18607
+ result[key2] = value;
18370
18608
  }
18371
18609
  return result;
18372
18610
  }
18373
18611
  function prune(obj, shape) {
18374
18612
  let changed = false;
18375
18613
  const result = { ...obj };
18376
- for (const [key, pattern] of Object.entries(shape)) {
18377
- if (!(key in result)) {
18614
+ for (const [key2, pattern] of Object.entries(shape)) {
18615
+ if (!(key2 in result)) {
18378
18616
  continue;
18379
18617
  }
18380
- const current = result[key];
18618
+ const current = result[key2];
18381
18619
  if (isConfigObject(pattern) && Object.keys(pattern).length === 0) {
18382
- delete result[key];
18620
+ delete result[key2];
18383
18621
  changed = true;
18384
18622
  continue;
18385
18623
  }
@@ -18392,13 +18630,13 @@ function prune(obj, shape) {
18392
18630
  changed = true;
18393
18631
  }
18394
18632
  if (Object.keys(childResult).length === 0) {
18395
- delete result[key];
18633
+ delete result[key2];
18396
18634
  } else {
18397
- result[key] = childResult;
18635
+ result[key2] = childResult;
18398
18636
  }
18399
18637
  continue;
18400
18638
  }
18401
- delete result[key];
18639
+ delete result[key2];
18402
18640
  changed = true;
18403
18641
  }
18404
18642
  return { changed, result };
@@ -18432,29 +18670,29 @@ function serialize2(obj) {
18432
18670
  }
18433
18671
  function merge2(base, patch) {
18434
18672
  const result = { ...base };
18435
- for (const [key, value] of Object.entries(patch)) {
18673
+ for (const [key2, value] of Object.entries(patch)) {
18436
18674
  if (value === void 0) {
18437
18675
  continue;
18438
18676
  }
18439
- const existing = result[key];
18677
+ const existing = result[key2];
18440
18678
  if (isConfigObject2(existing) && isConfigObject2(value)) {
18441
- result[key] = merge2(existing, value);
18679
+ result[key2] = merge2(existing, value);
18442
18680
  continue;
18443
18681
  }
18444
- result[key] = value;
18682
+ result[key2] = value;
18445
18683
  }
18446
18684
  return result;
18447
18685
  }
18448
18686
  function prune2(obj, shape) {
18449
18687
  let changed = false;
18450
18688
  const result = { ...obj };
18451
- for (const [key, pattern] of Object.entries(shape)) {
18452
- if (!(key in result)) {
18689
+ for (const [key2, pattern] of Object.entries(shape)) {
18690
+ if (!(key2 in result)) {
18453
18691
  continue;
18454
18692
  }
18455
- const current = result[key];
18693
+ const current = result[key2];
18456
18694
  if (isConfigObject2(pattern) && Object.keys(pattern).length === 0) {
18457
- delete result[key];
18695
+ delete result[key2];
18458
18696
  changed = true;
18459
18697
  continue;
18460
18698
  }
@@ -18467,13 +18705,13 @@ function prune2(obj, shape) {
18467
18705
  changed = true;
18468
18706
  }
18469
18707
  if (Object.keys(childResult).length === 0) {
18470
- delete result[key];
18708
+ delete result[key2];
18471
18709
  } else {
18472
- result[key] = childResult;
18710
+ result[key2] = childResult;
18473
18711
  }
18474
18712
  continue;
18475
18713
  }
18476
- delete result[key];
18714
+ delete result[key2];
18477
18715
  changed = true;
18478
18716
  }
18479
18717
  return { changed, result };
@@ -18510,29 +18748,29 @@ function serialize3(obj) {
18510
18748
  }
18511
18749
  function merge3(base, patch) {
18512
18750
  const result = { ...base };
18513
- for (const [key, value] of Object.entries(patch)) {
18751
+ for (const [key2, value] of Object.entries(patch)) {
18514
18752
  if (value === void 0) {
18515
18753
  continue;
18516
18754
  }
18517
- const existing = result[key];
18755
+ const existing = result[key2];
18518
18756
  if (isConfigObject3(existing) && isConfigObject3(value)) {
18519
- result[key] = merge3(existing, value);
18757
+ result[key2] = merge3(existing, value);
18520
18758
  continue;
18521
18759
  }
18522
- result[key] = value;
18760
+ result[key2] = value;
18523
18761
  }
18524
18762
  return result;
18525
18763
  }
18526
18764
  function prune3(obj, shape) {
18527
18765
  let changed = false;
18528
18766
  const result = { ...obj };
18529
- for (const [key, pattern] of Object.entries(shape)) {
18530
- if (!(key in result)) {
18767
+ for (const [key2, pattern] of Object.entries(shape)) {
18768
+ if (!(key2 in result)) {
18531
18769
  continue;
18532
18770
  }
18533
- const current = result[key];
18771
+ const current = result[key2];
18534
18772
  if (isConfigObject3(pattern) && Object.keys(pattern).length === 0) {
18535
- delete result[key];
18773
+ delete result[key2];
18536
18774
  changed = true;
18537
18775
  continue;
18538
18776
  }
@@ -18542,13 +18780,13 @@ function prune3(obj, shape) {
18542
18780
  changed = true;
18543
18781
  }
18544
18782
  if (Object.keys(childResult).length === 0) {
18545
- delete result[key];
18783
+ delete result[key2];
18546
18784
  } else {
18547
- result[key] = childResult;
18785
+ result[key2] = childResult;
18548
18786
  }
18549
18787
  continue;
18550
18788
  }
18551
- delete result[key];
18789
+ delete result[key2];
18552
18790
  changed = true;
18553
18791
  }
18554
18792
  return { changed, result };
@@ -18585,16 +18823,16 @@ function getConfigFormat(pathOrFormat) {
18585
18823
  }
18586
18824
  return formatRegistry[formatName];
18587
18825
  }
18588
- function detectFormat2(path26) {
18589
- const ext = getExtension(path26);
18826
+ function detectFormat2(path28) {
18827
+ const ext = getExtension(path28);
18590
18828
  return extensionMap[ext];
18591
18829
  }
18592
- function getExtension(path26) {
18593
- const lastDot = path26.lastIndexOf(".");
18830
+ function getExtension(path28) {
18831
+ const lastDot = path28.lastIndexOf(".");
18594
18832
  if (lastDot === -1) {
18595
18833
  return "";
18596
18834
  }
18597
- return path26.slice(lastDot).toLowerCase();
18835
+ return path28.slice(lastDot).toLowerCase();
18598
18836
  }
18599
18837
 
18600
18838
  // packages/config-mutations/src/execution/path-utils.ts
@@ -18645,9 +18883,9 @@ function resolvePath(rawPath, homeDir, pathMapper) {
18645
18883
  function isNotFound(error2) {
18646
18884
  return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
18647
18885
  }
18648
- async function readFileIfExists(fs3, target) {
18886
+ async function readFileIfExists(fs4, target) {
18649
18887
  try {
18650
- return await fs3.readFile(target, "utf8");
18888
+ return await fs4.readFile(target, "utf8");
18651
18889
  } catch (error2) {
18652
18890
  if (isNotFound(error2)) {
18653
18891
  return null;
@@ -18655,9 +18893,9 @@ async function readFileIfExists(fs3, target) {
18655
18893
  throw error2;
18656
18894
  }
18657
18895
  }
18658
- async function pathExists(fs3, target) {
18896
+ async function pathExists(fs4, target) {
18659
18897
  try {
18660
- await fs3.stat(target);
18898
+ await fs4.stat(target);
18661
18899
  return true;
18662
18900
  } catch (error2) {
18663
18901
  if (isNotFound(error2)) {
@@ -18681,9 +18919,9 @@ function createInvalidDocumentBackupPath(targetPath) {
18681
18919
  const ext = targetPath.includes(".") ? targetPath.split(".").pop() : "bak";
18682
18920
  return `${targetPath}.invalid-${createTimestamp()}.${ext}`;
18683
18921
  }
18684
- async function backupInvalidDocument(fs3, targetPath, content) {
18922
+ async function backupInvalidDocument(fs4, targetPath, content) {
18685
18923
  const backupPath = createInvalidDocumentBackupPath(targetPath);
18686
- await fs3.writeFile(backupPath, content, { encoding: "utf8" });
18924
+ await fs4.writeFile(backupPath, content, { encoding: "utf8" });
18687
18925
  }
18688
18926
  function describeMutation(kind, targetPath) {
18689
18927
  const displayPath2 = targetPath ?? "target";
@@ -18712,9 +18950,9 @@ function describeMutation(kind, targetPath) {
18712
18950
  }
18713
18951
  function pruneKeysByPrefix(table, prefix) {
18714
18952
  const result = {};
18715
- for (const [key, value] of Object.entries(table)) {
18716
- if (!key.startsWith(prefix)) {
18717
- result[key] = value;
18953
+ for (const [key2, value] of Object.entries(table)) {
18954
+ if (!key2.startsWith(prefix)) {
18955
+ result[key2] = value;
18718
18956
  }
18719
18957
  }
18720
18958
  return result;
@@ -18725,15 +18963,15 @@ function isConfigObject4(value) {
18725
18963
  function mergeWithPruneByPrefix(base, patch, pruneByPrefix) {
18726
18964
  const result = { ...base };
18727
18965
  const prefixMap = pruneByPrefix ?? {};
18728
- for (const [key, value] of Object.entries(patch)) {
18729
- const current = result[key];
18730
- const prefix = prefixMap[key];
18966
+ for (const [key2, value] of Object.entries(patch)) {
18967
+ const current = result[key2];
18968
+ const prefix = prefixMap[key2];
18731
18969
  if (isConfigObject4(current) && isConfigObject4(value)) {
18732
18970
  if (prefix) {
18733
18971
  const pruned = pruneKeysByPrefix(current, prefix);
18734
- result[key] = { ...pruned, ...value };
18972
+ result[key2] = { ...pruned, ...value };
18735
18973
  } else {
18736
- result[key] = mergeWithPruneByPrefix(
18974
+ result[key2] = mergeWithPruneByPrefix(
18737
18975
  current,
18738
18976
  value,
18739
18977
  prefixMap
@@ -18741,7 +18979,7 @@ function mergeWithPruneByPrefix(base, patch, pruneByPrefix) {
18741
18979
  }
18742
18980
  continue;
18743
18981
  }
18744
- result[key] = value;
18982
+ result[key2] = value;
18745
18983
  }
18746
18984
  return result;
18747
18985
  }
@@ -18896,8 +19134,8 @@ async function applyChmod(mutation, context, options) {
18896
19134
  };
18897
19135
  }
18898
19136
  try {
18899
- const stat6 = await context.fs.stat(targetPath);
18900
- 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;
18901
19139
  if (currentMode === mutation.mode) {
18902
19140
  return {
18903
19141
  outcome: { changed: false, effect: "none", detail: "noop" },
@@ -19245,26 +19483,26 @@ import Mustache2 from "mustache";
19245
19483
  var originalEscape = Mustache2.escape;
19246
19484
 
19247
19485
  // packages/poe-code-config/src/store.ts
19248
- async function readDocument(fs3, filePath) {
19249
- const document = await readStoredDocument(fs3, filePath);
19486
+ async function readDocument(fs4, filePath) {
19487
+ const document = await readStoredDocument(fs4, filePath);
19250
19488
  return document.data;
19251
19489
  }
19252
- async function writeScope(fs3, filePath, scope, values) {
19253
- const document = await readDocument(fs3, filePath);
19490
+ async function writeScope(fs4, filePath, scope, values) {
19491
+ const document = await readDocument(fs4, filePath);
19254
19492
  const normalizedValues = normalizeScopeValues(values);
19255
19493
  if (Object.keys(normalizedValues).length === 0) {
19256
19494
  delete document[scope];
19257
19495
  } else {
19258
19496
  document[scope] = normalizedValues;
19259
19497
  }
19260
- await writeDocument(fs3, filePath, document);
19498
+ await writeDocument(fs4, filePath, document);
19261
19499
  }
19262
- async function readMergedDocument(fs3, globalPath, projectPath) {
19263
- const globalDocument = await readStoredDocument(fs3, globalPath);
19500
+ async function readMergedDocument(fs4, globalPath, projectPath) {
19501
+ const globalDocument = await readStoredDocument(fs4, globalPath);
19264
19502
  if (!projectPath) {
19265
19503
  return globalDocument.data;
19266
19504
  }
19267
- const projectDocument = await readStoredDocument(fs3, projectPath);
19505
+ const projectDocument = await readStoredDocument(fs4, projectPath);
19268
19506
  const resolved = await resolve(
19269
19507
  [
19270
19508
  {
@@ -19278,16 +19516,16 @@ async function readMergedDocument(fs3, globalPath, projectPath) {
19278
19516
  }
19279
19517
  ],
19280
19518
  {
19281
- fs: createResolvedConfigFs(fs3, globalPath, globalDocument.content),
19519
+ fs: createResolvedConfigFs(fs4, globalPath, globalDocument.content),
19282
19520
  autoExtend: true
19283
19521
  }
19284
19522
  );
19285
19523
  return normalizeDocument(resolved.data);
19286
19524
  }
19287
- async function readStoredDocument(fs3, filePath) {
19525
+ async function readStoredDocument(fs4, filePath) {
19288
19526
  try {
19289
- const raw = await fs3.readFile(filePath, "utf8");
19290
- return await parseStoredDocument(fs3, filePath, raw);
19527
+ const raw = await fs4.readFile(filePath, "utf8");
19528
+ return await parseStoredDocument(fs4, filePath, raw);
19291
19529
  } catch (error2) {
19292
19530
  if (isNotFound(error2)) {
19293
19531
  return {
@@ -19298,7 +19536,7 @@ async function readStoredDocument(fs3, filePath) {
19298
19536
  throw error2;
19299
19537
  }
19300
19538
  }
19301
- async function parseStoredDocument(fs3, filePath, raw) {
19539
+ async function parseStoredDocument(fs4, filePath, raw) {
19302
19540
  try {
19303
19541
  return {
19304
19542
  content: raw,
@@ -19306,7 +19544,7 @@ async function parseStoredDocument(fs3, filePath, raw) {
19306
19544
  };
19307
19545
  } catch (error2) {
19308
19546
  if (error2 instanceof SyntaxError) {
19309
- await recoverInvalidDocument(fs3, filePath, raw);
19547
+ await recoverInvalidDocument(fs4, filePath, raw);
19310
19548
  return {
19311
19549
  content: EMPTY_DOCUMENT,
19312
19550
  data: {}
@@ -19333,35 +19571,35 @@ function normalizeScopeValues(value) {
19333
19571
  return {};
19334
19572
  }
19335
19573
  const normalized = {};
19336
- for (const [key, entry] of Object.entries(value)) {
19574
+ for (const [key2, entry] of Object.entries(value)) {
19337
19575
  if (entry !== void 0) {
19338
- normalized[key] = entry;
19576
+ normalized[key2] = entry;
19339
19577
  }
19340
19578
  }
19341
19579
  return normalized;
19342
19580
  }
19343
- function createResolvedConfigFs(fs3, globalPath, globalContent) {
19581
+ function createResolvedConfigFs(fs4, globalPath, globalContent) {
19344
19582
  return {
19345
19583
  readFile(filePath, _encoding) {
19346
19584
  if (filePath === globalPath) {
19347
19585
  return Promise.resolve(globalContent);
19348
19586
  }
19349
- return fs3.readFile(filePath, "utf8");
19587
+ return fs4.readFile(filePath, "utf8");
19350
19588
  }
19351
19589
  };
19352
19590
  }
19353
- async function writeDocument(fs3, filePath, document) {
19354
- await fs3.mkdir(path5.dirname(filePath), { recursive: true });
19355
- 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)}
19356
19594
  `, {
19357
19595
  encoding: "utf8"
19358
19596
  });
19359
19597
  }
19360
- async function recoverInvalidDocument(fs3, filePath, content) {
19361
- await fs3.mkdir(path5.dirname(filePath), { recursive: true });
19598
+ async function recoverInvalidDocument(fs4, filePath, content) {
19599
+ await fs4.mkdir(path5.dirname(filePath), { recursive: true });
19362
19600
  const backupPath = createInvalidBackupPath(filePath);
19363
- await fs3.writeFile(backupPath, content, { encoding: "utf8" });
19364
- 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" });
19365
19603
  }
19366
19604
  function createInvalidBackupPath(filePath) {
19367
19605
  const directory = path5.dirname(filePath);
@@ -19383,15 +19621,15 @@ var EMPTY_DOCUMENT = `${JSON.stringify({}, null, 2)}
19383
19621
  // packages/poe-code-config/src/resolve.ts
19384
19622
  function resolveScope(schema, fileValues, env = {}) {
19385
19623
  const resolved = {};
19386
- for (const key of Object.keys(schema)) {
19387
- const field = schema[key];
19388
- const envValue = resolveEnvValue(field, env, key);
19389
- const fileValue = resolveFileValue(field, fileValues?.[key], key);
19390
- 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;
19391
19629
  }
19392
19630
  return resolved;
19393
19631
  }
19394
- function resolveEnvValue(field, env, key) {
19632
+ function resolveEnvValue(field, env, key2) {
19395
19633
  if (!field.env) {
19396
19634
  return void 0;
19397
19635
  }
@@ -19399,12 +19637,12 @@ function resolveEnvValue(field, env, key) {
19399
19637
  if (raw === void 0) {
19400
19638
  return void 0;
19401
19639
  }
19402
- return coerceValue(field, raw, key);
19640
+ return coerceValue(field, raw, key2);
19403
19641
  }
19404
- function resolveFileValue(field, value, key) {
19405
- return coerceValue(field, value, key);
19642
+ function resolveFileValue(field, value, key2) {
19643
+ return coerceValue(field, value, key2);
19406
19644
  }
19407
- function coerceValue(field, value, key) {
19645
+ function coerceValue(field, value, key2) {
19408
19646
  switch (field.type) {
19409
19647
  case "string":
19410
19648
  return typeof value === "string" ? value : void 0;
@@ -19413,7 +19651,7 @@ function coerceValue(field, value, key) {
19413
19651
  case "boolean":
19414
19652
  return coerceBoolean(value);
19415
19653
  case "json":
19416
- return coerceJson(field, value, key);
19654
+ return coerceJson(field, value, key2);
19417
19655
  }
19418
19656
  }
19419
19657
  function coerceNumber(value) {
@@ -19438,26 +19676,26 @@ function coerceBoolean(value) {
19438
19676
  }
19439
19677
  return void 0;
19440
19678
  }
19441
- function coerceJson(field, value, key) {
19679
+ function coerceJson(field, value, key2) {
19442
19680
  if (value === void 0) {
19443
19681
  return void 0;
19444
19682
  }
19445
- const parsedValue = parseJsonValue(value, key);
19683
+ const parsedValue = parseJsonValue(value, key2);
19446
19684
  try {
19447
19685
  return field.parse(parsedValue);
19448
19686
  } catch (error2) {
19449
19687
  const message2 = error2 instanceof Error ? error2.message : "Invalid JSON value.";
19450
- throw new Error(`Invalid config value for "${key}": ${message2}`);
19688
+ throw new Error(`Invalid config value for "${key2}": ${message2}`);
19451
19689
  }
19452
19690
  }
19453
- function parseJsonValue(value, key) {
19691
+ function parseJsonValue(value, key2) {
19454
19692
  if (typeof value !== "string") {
19455
19693
  return value;
19456
19694
  }
19457
19695
  try {
19458
19696
  return JSON.parse(value);
19459
19697
  } catch {
19460
- throw new Error(`Invalid config value for "${key}": expected valid JSON.`);
19698
+ throw new Error(`Invalid config value for "${key2}": expected valid JSON.`);
19461
19699
  }
19462
19700
  }
19463
19701
 
@@ -19467,19 +19705,19 @@ function createConfigStore(options) {
19467
19705
  return {
19468
19706
  scope(definition) {
19469
19707
  return {
19470
- async get(key) {
19708
+ async get(key2) {
19471
19709
  const resolved = await resolveScopedValues(options, definition, env);
19472
- return resolved[key];
19710
+ return resolved[key2];
19473
19711
  },
19474
19712
  async getAll() {
19475
19713
  return resolveScopedValues(options, definition, env);
19476
19714
  },
19477
- async set(key, value) {
19715
+ async set(key2, value) {
19478
19716
  const document = await readDocument(options.fs, options.filePath);
19479
19717
  const currentValues = document[definition.scope] ?? {};
19480
19718
  await writeScope(options.fs, options.filePath, definition.scope, {
19481
19719
  ...currentValues,
19482
- [key]: value
19720
+ [key2]: value
19483
19721
  });
19484
19722
  }
19485
19723
  };
@@ -19650,16 +19888,16 @@ function createInstallRunner(definition) {
19650
19888
  }
19651
19889
 
19652
19890
  // src/services/config.ts
19653
- import path25 from "node:path";
19891
+ import path27 from "node:path";
19654
19892
  init_src7();
19655
19893
 
19656
19894
  // packages/superintendent/src/document/parse.ts
19657
- import path15 from "node:path";
19895
+ import path16 from "node:path";
19658
19896
  import { parseDocument as parseDocument2 } from "yaml";
19659
19897
  var superintendentDocumentSchemaId = "https://poe-platform.github.io/poe-code/schemas/plans/superintendent.schema.json";
19660
19898
  var validStatusStates = /* @__PURE__ */ new Set(["in_progress", "review", "completed"]);
19661
19899
  function parseSuperintendentDoc(filePath, content) {
19662
- const resolvedFilePath = path15.resolve(filePath);
19900
+ const resolvedFilePath = path16.resolve(filePath);
19663
19901
  const { frontmatterText, body } = splitFrontmatter(resolvedFilePath, content);
19664
19902
  const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
19665
19903
  return {
@@ -19849,7 +20087,7 @@ function isRecord3(value) {
19849
20087
  }
19850
20088
 
19851
20089
  // packages/superintendent/src/document/write.ts
19852
- import path16 from "node:path";
20090
+ import path17 from "node:path";
19853
20091
  import { isMap, parseDocument as parseDocument3 } from "yaml";
19854
20092
  function updateStatus(filePath, content, status) {
19855
20093
  return updateFrontmatter(filePath, content, (frontmatterDocument) => {
@@ -19870,7 +20108,7 @@ function setStatusReason(filePath, content, reason) {
19870
20108
  });
19871
20109
  }
19872
20110
  function updateFrontmatter(filePath, content, mutate) {
19873
- const resolvedFilePath = path16.resolve(filePath);
20111
+ const resolvedFilePath = path17.resolve(filePath);
19874
20112
  const parts = splitDocument(resolvedFilePath, content);
19875
20113
  const frontmatterDocument = parseDocument3(parts.frontmatterText);
19876
20114
  if (frontmatterDocument.errors.length > 0) {
@@ -19897,8 +20135,8 @@ function getTopLevelMap(frontmatterDocument) {
19897
20135
  }
19898
20136
  function reorderTopLevelKeys(map, keys) {
19899
20137
  const remaining = [...map.items];
19900
- const ordered = keys.flatMap((key) => {
19901
- 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);
19902
20140
  return index === -1 ? [] : remaining.splice(index, 1);
19903
20141
  });
19904
20142
  map.items = [...ordered, ...remaining];
@@ -20095,25 +20333,26 @@ function extractText(node) {
20095
20333
  }
20096
20334
 
20097
20335
  // packages/superintendent/src/runtime/loop.ts
20098
- import * as fsPromises5 from "node:fs/promises";
20336
+ import path21 from "node:path";
20337
+ import * as fsPromises6 from "node:fs/promises";
20099
20338
 
20100
20339
  // packages/agent-kit/src/paths.ts
20101
- import path17 from "node:path";
20340
+ import path18 from "node:path";
20102
20341
  function resolveWorkflowPath(inputPath, cwd, homeDir) {
20103
20342
  if (inputPath.startsWith("~/")) {
20104
- return path17.join(homeDir, inputPath.slice(2));
20343
+ return path18.join(homeDir, inputPath.slice(2));
20105
20344
  }
20106
20345
  if (inputPath === "~") {
20107
20346
  return homeDir;
20108
20347
  }
20109
- return path17.isAbsolute(inputPath) ? inputPath : path17.resolve(cwd, inputPath);
20348
+ return path18.isAbsolute(inputPath) ? inputPath : path18.resolve(cwd, inputPath);
20110
20349
  }
20111
20350
 
20112
20351
  // packages/agent-kit/src/participant.ts
20113
20352
  init_src4();
20114
20353
 
20115
20354
  // packages/agent-kit/src/lock.ts
20116
- import * as fsPromises4 from "node:fs/promises";
20355
+ import * as fsPromises5 from "node:fs/promises";
20117
20356
  function createAbortError3() {
20118
20357
  const error2 = new Error("The operation was aborted.");
20119
20358
  error2.name = "AbortError";
@@ -20153,23 +20392,23 @@ function hasErrorCode(error2, code) {
20153
20392
  }
20154
20393
  function createDefaultFs() {
20155
20394
  return {
20156
- mkdir: async (path26, options) => {
20157
- await fsPromises4.mkdir(path26, options);
20395
+ mkdir: async (path28, options) => {
20396
+ await fsPromises5.mkdir(path28, options);
20158
20397
  },
20159
- rmdir: fsPromises4.rmdir,
20160
- stat: async (path26) => {
20161
- const stat6 = await fsPromises4.stat(path26);
20398
+ rmdir: fsPromises5.rmdir,
20399
+ stat: async (path28) => {
20400
+ const stat7 = await fsPromises5.stat(path28);
20162
20401
  return {
20163
- isFile: () => stat6.isFile(),
20164
- isDirectory: () => stat6.isDirectory(),
20165
- mtimeMs: stat6.mtimeMs
20402
+ isFile: () => stat7.isFile(),
20403
+ isDirectory: () => stat7.isDirectory(),
20404
+ mtimeMs: stat7.mtimeMs
20166
20405
  };
20167
20406
  }
20168
20407
  };
20169
20408
  }
20170
- async function removeLockDirectory(fs3, lockPath) {
20409
+ async function removeLockDirectory(fs4, lockPath) {
20171
20410
  try {
20172
- await fs3.rmdir(lockPath);
20411
+ await fs4.rmdir(lockPath);
20173
20412
  } catch (error2) {
20174
20413
  if (!hasErrorCode(error2, "ENOENT")) {
20175
20414
  throw error2;
@@ -20177,7 +20416,7 @@ async function removeLockDirectory(fs3, lockPath) {
20177
20416
  }
20178
20417
  }
20179
20418
  async function lockWorkflow(docPath, options = {}) {
20180
- const fs3 = options.fs ?? createDefaultFs();
20419
+ const fs4 = options.fs ?? createDefaultFs();
20181
20420
  const retries = options.retries ?? 20;
20182
20421
  const minTimeout = options.minTimeout ?? 25;
20183
20422
  const maxTimeout = options.maxTimeout ?? 250;
@@ -20186,30 +20425,30 @@ async function lockWorkflow(docPath, options = {}) {
20186
20425
  for (let attempt = 0; attempt <= retries; attempt += 1) {
20187
20426
  throwIfAborted(options.signal);
20188
20427
  try {
20189
- await fs3.mkdir(lockPath);
20428
+ await fs4.mkdir(lockPath);
20190
20429
  let released = false;
20191
20430
  return async () => {
20192
20431
  if (released) {
20193
20432
  return;
20194
20433
  }
20195
20434
  released = true;
20196
- await removeLockDirectory(fs3, lockPath);
20435
+ await removeLockDirectory(fs4, lockPath);
20197
20436
  };
20198
20437
  } catch (error2) {
20199
20438
  if (!hasErrorCode(error2, "EEXIST")) {
20200
20439
  throw error2;
20201
20440
  }
20202
- let stat6;
20441
+ let stat7;
20203
20442
  try {
20204
- stat6 = await fs3.stat(lockPath);
20443
+ stat7 = await fs4.stat(lockPath);
20205
20444
  } catch (statError) {
20206
20445
  if (hasErrorCode(statError, "ENOENT")) {
20207
20446
  continue;
20208
20447
  }
20209
20448
  throw statError;
20210
20449
  }
20211
- if (Date.now() - stat6.mtimeMs > staleMs) {
20212
- await removeLockDirectory(fs3, lockPath);
20450
+ if (Date.now() - stat7.mtimeMs > staleMs) {
20451
+ await removeLockDirectory(fs4, lockPath);
20213
20452
  continue;
20214
20453
  }
20215
20454
  if (attempt < retries) {
@@ -20221,13 +20460,13 @@ async function lockWorkflow(docPath, options = {}) {
20221
20460
  }
20222
20461
 
20223
20462
  // packages/agent-kit/src/run-logs.ts
20224
- import path18 from "node:path";
20463
+ import path19 from "node:path";
20225
20464
  function resolveRunLogDir(options) {
20226
20465
  const slug = slugifyPlanPath(options.planPath);
20227
- return path18.join(options.homeDir, ".poe-code", "logs", options.runner, slug);
20466
+ return path19.join(options.homeDir, ".poe-code", "logs", options.runner, slug);
20228
20467
  }
20229
20468
  function slugifyPlanPath(planPath) {
20230
- const base = path18.basename(planPath);
20469
+ const base = path19.basename(planPath);
20231
20470
  const dot = base.lastIndexOf(".");
20232
20471
  const stem = dot > 0 ? base.slice(0, dot) : base;
20233
20472
  return slugifyLabel(stem);
@@ -20278,6 +20517,15 @@ function pad2(value, width) {
20278
20517
  return String(value).padStart(width, "0");
20279
20518
  }
20280
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
+
20281
20529
  // packages/superintendent/src/runtime/loop.ts
20282
20530
  init_src6();
20283
20531
 
@@ -20298,15 +20546,15 @@ function createLoopState(doc) {
20298
20546
  init_src6();
20299
20547
 
20300
20548
  // packages/superintendent/src/runtime/resolve-cwd.ts
20301
- import path19 from "node:path";
20549
+ import path20 from "node:path";
20302
20550
  function resolveRoleCwd(role, docPath, defaultCwd) {
20303
20551
  if (role.cwd === void 0) {
20304
20552
  return defaultCwd;
20305
20553
  }
20306
- if (path19.isAbsolute(role.cwd)) {
20554
+ if (path20.isAbsolute(role.cwd)) {
20307
20555
  return role.cwd;
20308
20556
  }
20309
- return path19.resolve(path19.dirname(docPath), role.cwd);
20557
+ return path20.resolve(path20.dirname(docPath), role.cwd);
20310
20558
  }
20311
20559
 
20312
20560
  // packages/superintendent/src/runtime/templates.ts
@@ -20341,8 +20589,7 @@ async function runBuilder(doc, context, options) {
20341
20589
  prompt,
20342
20590
  cwd: resolveRoleCwd(doc.frontmatter.builder, doc.filePath, options.defaultCwd),
20343
20591
  mcpServers: buildMcpServers(doc),
20344
- ...options.logDir ? { logDir: options.logDir } : {},
20345
- ...options.logFileName ? { logFileName: options.logFileName } : {}
20592
+ ...options.logPath ? { logPath: options.logPath } : {}
20346
20593
  });
20347
20594
  const log2 = extractLog(result);
20348
20595
  return {
@@ -20386,8 +20633,7 @@ async function runAutonomous(input) {
20386
20633
  prompt: input.prompt,
20387
20634
  mode: input.mode,
20388
20635
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20389
- ...input.logDir ? { logDir: input.logDir } : {},
20390
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20636
+ ...input.logPath ? { logPath: input.logPath } : {}
20391
20637
  });
20392
20638
  }
20393
20639
  const result = await spawn5(input.agent, {
@@ -20395,8 +20641,7 @@ async function runAutonomous(input) {
20395
20641
  prompt: input.prompt,
20396
20642
  mode: input.mode,
20397
20643
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20398
- ...input.logDir ? { logDir: input.logDir } : {},
20399
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20644
+ ...input.logPath ? { logPath: input.logPath } : {}
20400
20645
  });
20401
20646
  return {
20402
20647
  stdout: result.stdout,
@@ -20416,10 +20661,7 @@ function extractLogPath(result, options) {
20416
20661
  return logFile;
20417
20662
  }
20418
20663
  }
20419
- if (options.logDir && options.logFileName) {
20420
- return `${options.logDir}/${options.logFileName}`;
20421
- }
20422
- return "";
20664
+ return options.logPath ?? "";
20423
20665
  }
20424
20666
  function extractSummary(result, log2) {
20425
20667
  if (typeof result !== "string") {
@@ -20525,8 +20767,7 @@ async function runInspector(name, config, doc, context, options) {
20525
20767
  prompt,
20526
20768
  cwd: resolveRoleCwd(config, doc.filePath, options.defaultCwd),
20527
20769
  mcpServers: buildMcpServers2(doc, config),
20528
- ...options.logDir ? { logDir: options.logDir } : {},
20529
- ...options.logFileName ? { logFileName: options.logFileName } : {}
20770
+ ...options.logPath ? { logPath: options.logPath } : {}
20530
20771
  });
20531
20772
  const logPath = extractLogPath2(output);
20532
20773
  return {
@@ -20593,8 +20834,7 @@ async function runAutonomous2(input) {
20593
20834
  prompt: input.prompt,
20594
20835
  mode: input.mode,
20595
20836
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20596
- ...input.logDir ? { logDir: input.logDir } : {},
20597
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20837
+ ...input.logPath ? { logPath: input.logPath } : {}
20598
20838
  });
20599
20839
  }
20600
20840
  const result = await spawn5(input.agent, {
@@ -20602,8 +20842,7 @@ async function runAutonomous2(input) {
20602
20842
  prompt: input.prompt,
20603
20843
  mode: input.mode,
20604
20844
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20605
- ...input.logDir ? { logDir: input.logDir } : {},
20606
- ...input.logFileName ? { logFileName: input.logFileName } : {}
20845
+ ...input.logPath ? { logPath: input.logPath } : {}
20607
20846
  });
20608
20847
  return {
20609
20848
  stdout: result.stdout,
@@ -20735,8 +20974,7 @@ async function runOwnerReview(doc, context, options) {
20735
20974
  prompt,
20736
20975
  cwd: resolveRoleCwd(doc.frontmatter.owner, doc.filePath, options.defaultCwd),
20737
20976
  mcpServers: buildMcpServers3(doc),
20738
- ...options.logDir ? { logDir: options.logDir } : {},
20739
- ...options.logFileName ? { logFileName: options.logFileName } : {}
20977
+ ...options.logPath ? { logPath: options.logPath } : {}
20740
20978
  });
20741
20979
  const logPath = extractLogPath3(result);
20742
20980
  return {
@@ -20783,8 +21021,7 @@ async function runAutonomous3(input) {
20783
21021
  prompt: input.prompt,
20784
21022
  mode: input.mode,
20785
21023
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20786
- ...input.logDir ? { logDir: input.logDir } : {},
20787
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21024
+ ...input.logPath ? { logPath: input.logPath } : {}
20788
21025
  });
20789
21026
  }
20790
21027
  const result = await spawn5(input.agent, {
@@ -20792,8 +21029,7 @@ async function runAutonomous3(input) {
20792
21029
  prompt: input.prompt,
20793
21030
  mode: input.mode,
20794
21031
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
20795
- ...input.logDir ? { logDir: input.logDir } : {},
20796
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21032
+ ...input.logPath ? { logPath: input.logPath } : {}
20797
21033
  });
20798
21034
  return {
20799
21035
  stdout: result.stdout,
@@ -20944,8 +21180,7 @@ async function runSuperintendent(doc, context, options) {
20944
21180
  prompt,
20945
21181
  cwd: resolveRoleCwd(doc.frontmatter.superintendent, doc.filePath, options.defaultCwd),
20946
21182
  mcpServers: buildMcpServers4(doc),
20947
- ...options.logDir ? { logDir: options.logDir } : {},
20948
- ...options.logFileName ? { logFileName: options.logFileName } : {}
21183
+ ...options.logPath ? { logPath: options.logPath } : {}
20949
21184
  });
20950
21185
  const transition = extractTransition2(result);
20951
21186
  const logPath = extractLogPath4(result);
@@ -21004,8 +21239,7 @@ async function runAutonomous4(input) {
21004
21239
  prompt: input.prompt,
21005
21240
  mode: input.mode,
21006
21241
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
21007
- ...input.logDir ? { logDir: input.logDir } : {},
21008
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21242
+ ...input.logPath ? { logPath: input.logPath } : {}
21009
21243
  });
21010
21244
  }
21011
21245
  const result = await spawn5(input.agent, {
@@ -21013,8 +21247,7 @@ async function runAutonomous4(input) {
21013
21247
  prompt: input.prompt,
21014
21248
  mode: input.mode,
21015
21249
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
21016
- ...input.logDir ? { logDir: input.logDir } : {},
21017
- ...input.logFileName ? { logFileName: input.logFileName } : {}
21250
+ ...input.logPath ? { logPath: input.logPath } : {}
21018
21251
  });
21019
21252
  return {
21020
21253
  stdout: result.stdout,
@@ -21343,46 +21576,46 @@ function normalizeOptions(input, callbacks) {
21343
21576
  }
21344
21577
  function createDefaultFs2() {
21345
21578
  return {
21346
- readFile: fsPromises5.readFile,
21347
- writeFile: fsPromises5.writeFile,
21348
- readdir: fsPromises5.readdir,
21579
+ readFile: fsPromises6.readFile,
21580
+ writeFile: fsPromises6.writeFile,
21581
+ readdir: fsPromises6.readdir,
21349
21582
  stat: async (filePath) => {
21350
- const stat6 = await fsPromises5.stat(filePath);
21583
+ const stat7 = await fsPromises6.stat(filePath);
21351
21584
  return {
21352
- isFile: () => stat6.isFile(),
21353
- isDirectory: () => stat6.isDirectory(),
21354
- mtimeMs: stat6.mtimeMs
21585
+ isFile: () => stat7.isFile(),
21586
+ isDirectory: () => stat7.isDirectory(),
21587
+ mtimeMs: stat7.mtimeMs
21355
21588
  };
21356
21589
  },
21357
21590
  mkdir: async (filePath, options) => {
21358
- await fsPromises5.mkdir(filePath, options);
21591
+ await fsPromises6.mkdir(filePath, options);
21359
21592
  },
21360
21593
  rmdir: async (filePath) => {
21361
- await fsPromises5.rmdir(filePath);
21594
+ await fsPromises6.rmdir(filePath);
21362
21595
  },
21363
21596
  rename: async (oldPath, newPath) => {
21364
- await fsPromises5.rename(oldPath, newPath);
21597
+ await fsPromises6.rename(oldPath, newPath);
21365
21598
  }
21366
21599
  };
21367
21600
  }
21368
- async function readDocument2(fs3, docPath) {
21369
- const content = await readDocumentContent(fs3, docPath);
21601
+ async function readDocument2(fs4, docPath) {
21602
+ const content = await readDocumentContent(fs4, docPath);
21370
21603
  return parseSuperintendentDoc(docPath, content);
21371
21604
  }
21372
- async function readDocumentContent(fs3, docPath) {
21373
- return fs3.readFile(docPath, "utf8");
21605
+ async function readDocumentContent(fs4, docPath) {
21606
+ return fs4.readFile(docPath, "utf8");
21374
21607
  }
21375
- async function writeLoopState(fs3, docPath, state) {
21376
- const content = await fs3.readFile(docPath, "utf8");
21608
+ async function writeLoopState(fs4, docPath, state) {
21609
+ const content = await fs4.readFile(docPath, "utf8");
21377
21610
  const updatedContent = updateStatus(docPath, content, {
21378
21611
  state: state.state,
21379
21612
  round: state.round,
21380
21613
  review_turn: state.reviewTurn
21381
21614
  });
21382
- await fs3.writeFile(docPath, updatedContent, { encoding: "utf8" });
21615
+ await fs4.writeFile(docPath, updatedContent, { encoding: "utf8" });
21383
21616
  }
21384
- async function restoreDocument(fs3, docPath, content) {
21385
- await fs3.writeFile(docPath, content, { encoding: "utf8" });
21617
+ async function restoreDocument(fs4, docPath, content) {
21618
+ await fs4.writeFile(docPath, content, { encoding: "utf8" });
21386
21619
  }
21387
21620
  async function rollbackRoundStatus(options, state) {
21388
21621
  await writeLoopState(options.fs, options.docPath, state);
@@ -21449,14 +21682,10 @@ async function executeSuperintendent(options, context) {
21449
21682
  }
21450
21683
  }
21451
21684
  function buildRoleOptions(options, role) {
21452
- const base = {
21453
- defaultCwd: options.cwd
21685
+ return {
21686
+ defaultCwd: options.cwd,
21687
+ ...options.logDir ? { logPath: path21.join(options.logDir, makeRunLogFileName(role)) } : {}
21454
21688
  };
21455
- if (options.logDir) {
21456
- base.logDir = options.logDir;
21457
- base.logFileName = makeRunLogFileName(role);
21458
- }
21459
- return base;
21460
21689
  }
21461
21690
  function shouldContinueReview(doc) {
21462
21691
  return parseTaskBoard(doc.body).allDone;
@@ -21531,8 +21760,7 @@ async function withInjectedAgentRunner(options, operation) {
21531
21760
  cwd: input.cwd ?? process.cwd(),
21532
21761
  ...input.mode ? { mode: input.mode } : {},
21533
21762
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
21534
- ...input.logDir ? { logDir: input.logDir } : {},
21535
- ...input.logFileName ? { logFileName: input.logFileName } : {},
21763
+ ...input.logPath ? { logPath: input.logPath } : {},
21536
21764
  ...options.signal ? { signal: options.signal } : {}
21537
21765
  });
21538
21766
  if (!result) {
@@ -21639,7 +21867,7 @@ function cloneSecrets(secrets) {
21639
21867
  return {};
21640
21868
  }
21641
21869
  return Object.fromEntries(
21642
- Object.entries(secrets).map(([key, secret]) => [key, cloneSecretDefinition(secret)])
21870
+ Object.entries(secrets).map(([key2, secret]) => [key2, cloneSecretDefinition(secret)])
21643
21871
  );
21644
21872
  }
21645
21873
  function cloneRequires(requires) {
@@ -21904,8 +22132,8 @@ var builderRunCommand = defineCommand({
21904
22132
  positional: ["path"],
21905
22133
  params: builderRunParams,
21906
22134
  scope: ["cli", "mcp", "sdk"],
21907
- handler: async ({ params, fs: fs3 }) => {
21908
- const content = await readDocument3(params.path, fs3);
22135
+ handler: async ({ params, fs: fs4 }) => {
22136
+ const content = await readDocument3(params.path, fs4);
21909
22137
  const document = parseSuperintendentDoc(params.path, content);
21910
22138
  return runBuilder(document, {}, { defaultCwd: process.cwd() });
21911
22139
  },
@@ -21927,9 +22155,9 @@ var builderGroup = defineGroup({
21927
22155
  scope: ["cli", "mcp", "sdk"],
21928
22156
  children: [builderRunCommand]
21929
22157
  });
21930
- async function readDocument3(filePath, fs3) {
22158
+ async function readDocument3(filePath, fs4) {
21931
22159
  try {
21932
- return await fs3.readFile(filePath, "utf8");
22160
+ return await fs4.readFile(filePath, "utf8");
21933
22161
  } catch (error2) {
21934
22162
  if (hasCode2(error2, "ENOENT")) {
21935
22163
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -21958,14 +22186,14 @@ function hasCode2(error2, code) {
21958
22186
  }
21959
22187
 
21960
22188
  // packages/superintendent/src/commands/install.ts
21961
- import path22 from "node:path";
21962
- 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";
21963
22191
  import { fileURLToPath as fileURLToPath4 } from "node:url";
21964
22192
 
21965
22193
  // packages/agent-skill-config/src/configs.ts
21966
22194
  init_src4();
21967
22195
  import os2 from "node:os";
21968
- import path20 from "node:path";
22196
+ import path22 from "node:path";
21969
22197
  var agentSkillConfigs = {
21970
22198
  "claude-code": {
21971
22199
  globalSkillDir: "~/.claude/skills",
@@ -21999,7 +22227,7 @@ function resolveAgentSupport(input, registry = agentSkillConfigs) {
21999
22227
 
22000
22228
  // packages/agent-skill-config/src/templates.ts
22001
22229
  import { readFile as readFile3, stat as stat3 } from "node:fs/promises";
22002
- import path21 from "node:path";
22230
+ import path23 from "node:path";
22003
22231
  import { fileURLToPath as fileURLToPath3 } from "node:url";
22004
22232
 
22005
22233
  // packages/agent-skill-config/src/apply.ts
@@ -22060,7 +22288,7 @@ async function installSkill(agentId, skill, options) {
22060
22288
  var fs2 = {
22061
22289
  readFile: (p, encoding) => readFile4(p, encoding),
22062
22290
  writeFile: (p, content) => writeFile2(p, content),
22063
- mkdir: (p, options) => mkdir4(p, options).then(() => void 0),
22291
+ mkdir: (p, options) => mkdir5(p, options).then(() => void 0),
22064
22292
  unlink: (p) => unlink(p),
22065
22293
  stat: (p) => stat4(p).then((s) => ({ mode: s.mode })),
22066
22294
  readdir: (p) => readdir3(p),
@@ -22095,7 +22323,7 @@ var installCommand = defineCommand({
22095
22323
  support.id,
22096
22324
  {
22097
22325
  name: "poe-code-superintendent-plan",
22098
- content: skillContent
22326
+ content: skillContent + "\n\n" + skillPlanConfigSection("superintendent")
22099
22327
  },
22100
22328
  {
22101
22329
  fs: fs2,
@@ -22108,7 +22336,7 @@ var installCommand = defineCommand({
22108
22336
  const absolutePlanDirectory = resolveAbsoluteDirectory(planDirectory, cwd, homeDir);
22109
22337
  let planDirectoryCreated = false;
22110
22338
  if (!await pathExists2(absolutePlanDirectory)) {
22111
- await mkdir4(absolutePlanDirectory, { recursive: true });
22339
+ await mkdir5(absolutePlanDirectory, { recursive: true });
22112
22340
  planDirectoryCreated = true;
22113
22341
  }
22114
22342
  return {
@@ -22153,9 +22381,9 @@ async function resolvePlanDirectory(cwd, homeDir, env) {
22153
22381
  }
22154
22382
  function resolveAbsoluteDirectory(dir, cwd, homeDir) {
22155
22383
  if (dir.startsWith("~/")) {
22156
- return path22.join(homeDir, dir.slice(2));
22384
+ return path24.join(homeDir, dir.slice(2));
22157
22385
  }
22158
- return path22.isAbsolute(dir) ? dir : path22.resolve(cwd, dir);
22386
+ return path24.isAbsolute(dir) ? dir : path24.resolve(cwd, dir);
22159
22387
  }
22160
22388
  async function pathExists2(targetPath) {
22161
22389
  try {
@@ -22175,15 +22403,15 @@ async function loadSkillTemplate() {
22175
22403
  }
22176
22404
  const packageRoot = await findPackageRoot(fileURLToPath4(import.meta.url));
22177
22405
  const templateRoots = [
22178
- path22.join(packageRoot, "src", "templates"),
22179
- path22.join(packageRoot, "dist", "templates")
22406
+ path24.join(packageRoot, "src", "templates"),
22407
+ path24.join(packageRoot, "dist", "templates")
22180
22408
  ];
22181
22409
  for (const templateRoot of templateRoots) {
22182
22410
  if (!await pathExists2(templateRoot)) {
22183
22411
  continue;
22184
22412
  }
22185
22413
  skillTemplateCache = await readFile4(
22186
- path22.join(templateRoot, "SKILL_superintendent.md"),
22414
+ path24.join(templateRoot, "SKILL_superintendent.md"),
22187
22415
  "utf8"
22188
22416
  );
22189
22417
  return skillTemplateCache;
@@ -22191,12 +22419,12 @@ async function loadSkillTemplate() {
22191
22419
  throw new Error("Unable to locate Superintendent skill template.");
22192
22420
  }
22193
22421
  async function findPackageRoot(entryFilePath) {
22194
- let currentPath = path22.dirname(entryFilePath);
22422
+ let currentPath = path24.dirname(entryFilePath);
22195
22423
  while (true) {
22196
- if (await pathExists2(path22.join(currentPath, "package.json"))) {
22424
+ if (await pathExists2(path24.join(currentPath, "package.json"))) {
22197
22425
  return currentPath;
22198
22426
  }
22199
- const parentPath = path22.dirname(currentPath);
22427
+ const parentPath = path24.dirname(currentPath);
22200
22428
  if (parentPath === currentPath) {
22201
22429
  throw new Error("Unable to locate package root for Superintendent templates.");
22202
22430
  }
@@ -22218,8 +22446,8 @@ var inspectorListCommand = defineCommand({
22218
22446
  positional: ["path"],
22219
22447
  params: inspectorListParams,
22220
22448
  scope: ["cli", "mcp", "sdk"],
22221
- handler: async ({ params, fs: fs3 }) => {
22222
- const content = await readDocument4(params.path, fs3);
22449
+ handler: async ({ params, fs: fs4 }) => {
22450
+ const content = await readDocument4(params.path, fs4);
22223
22451
  const document = parseSuperintendentDoc(params.path, content);
22224
22452
  return Object.entries(document.frontmatter.inspectors ?? {}).map(([name, config]) => ({
22225
22453
  name,
@@ -22259,8 +22487,8 @@ var inspectorRunCommand = defineCommand({
22259
22487
  positional: ["path", "name"],
22260
22488
  params: inspectorRunParams,
22261
22489
  scope: ["cli", "mcp", "sdk"],
22262
- handler: async ({ params, fs: fs3 }) => {
22263
- const content = await readDocument4(params.path, fs3);
22490
+ handler: async ({ params, fs: fs4 }) => {
22491
+ const content = await readDocument4(params.path, fs4);
22264
22492
  const document = parseSuperintendentDoc(params.path, content);
22265
22493
  const defaultCwd = process.cwd();
22266
22494
  if (params.name === void 0) {
@@ -22293,9 +22521,9 @@ var inspectorGroup = defineGroup({
22293
22521
  scope: ["cli", "mcp", "sdk"],
22294
22522
  children: [inspectorListCommand, inspectorRunCommand]
22295
22523
  });
22296
- async function readDocument4(filePath, fs3) {
22524
+ async function readDocument4(filePath, fs4) {
22297
22525
  try {
22298
- return await fs3.readFile(filePath, "utf8");
22526
+ return await fs4.readFile(filePath, "utf8");
22299
22527
  } catch (error2) {
22300
22528
  if (hasCode3(error2, "ENOENT")) {
22301
22529
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -22343,11 +22571,11 @@ var completeCommand = defineCommand({
22343
22571
  positional: ["path"],
22344
22572
  params: completeParams,
22345
22573
  scope: ["cli", "mcp", "sdk"],
22346
- handler: async ({ params, fs: fs3 }) => {
22347
- const content = await readDocument5(params.path, fs3);
22574
+ handler: async ({ params, fs: fs4 }) => {
22575
+ const content = await readDocument5(params.path, fs4);
22348
22576
  const completedContent = transitionState(params.path, content, "completed");
22349
22577
  const updatedContent = setStatusReason(params.path, completedContent, params.reason);
22350
- await fs3.writeFile(params.path, updatedContent);
22578
+ await fs4.writeFile(params.path, updatedContent);
22351
22579
  return {
22352
22580
  path: params.path,
22353
22581
  state: "completed",
@@ -22371,9 +22599,9 @@ var completeCommand = defineCommand({
22371
22599
  json: (result) => result
22372
22600
  }
22373
22601
  });
22374
- async function readDocument5(filePath, fs3) {
22602
+ async function readDocument5(filePath, fs4) {
22375
22603
  try {
22376
- return await fs3.readFile(filePath, "utf8");
22604
+ return await fs4.readFile(filePath, "utf8");
22377
22605
  } catch (error2) {
22378
22606
  if (hasCode4(error2, "ENOENT")) {
22379
22607
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -22385,9 +22613,50 @@ function hasCode4(error2, code) {
22385
22613
  return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === code;
22386
22614
  }
22387
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
+
22388
22657
  // packages/superintendent/src/commands/run.ts
22389
- import path24 from "node:path";
22390
- import * as fsPromises6 from "node:fs/promises";
22658
+ import path26 from "node:path";
22659
+ import * as fsPromises7 from "node:fs/promises";
22391
22660
  import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
22392
22661
  init_src6();
22393
22662
  init_src4();
@@ -22395,182 +22664,19 @@ init_src4();
22395
22664
  // packages/superintendent/src/commands/poe-agent-runner.ts
22396
22665
  init_src4();
22397
22666
  init_src7();
22398
- import { mkdir as mkdir5, appendFile as appendFile2 } from "node:fs/promises";
22399
-
22400
- // packages/superintendent/src/commands/poe-agent-transcript.ts
22401
- import path23 from "node:path";
22402
- function mapAcpEventToSessionUpdates(event) {
22403
- if (event.type === "message.delta") {
22404
- if (event.content.length === 0) return [];
22405
- return [{ sessionUpdate: "agent_message_chunk", content: { type: "text", text: event.content } }];
22406
- }
22407
- if (event.type === "tool.intent") {
22408
- return [
22409
- {
22410
- sessionUpdate: "tool_call",
22411
- toolCallId: event.intentId,
22412
- title: event.tool,
22413
- kind: "execute",
22414
- status: "pending",
22415
- rawInput: event.args
22416
- },
22417
- {
22418
- sessionUpdate: "tool_call_update",
22419
- toolCallId: event.intentId,
22420
- kind: "execute",
22421
- status: "in_progress"
22422
- }
22423
- ];
22424
- }
22425
- if (event.type === "tool.result") {
22426
- return [
22427
- {
22428
- sessionUpdate: "tool_call_update",
22429
- toolCallId: event.intentId,
22430
- kind: "execute",
22431
- status: "completed",
22432
- rawOutput: event.result
22433
- }
22434
- ];
22435
- }
22436
- if (event.type === "tool.error") {
22437
- return [
22438
- {
22439
- sessionUpdate: "tool_call_update",
22440
- toolCallId: event.intentId,
22441
- kind: "execute",
22442
- status: "failed",
22443
- rawOutput: event.error
22444
- }
22445
- ];
22446
- }
22447
- if (event.type === "usage") {
22448
- const { inputTokens, outputTokens, cachedTokens, cacheCreationTokens } = event.usage;
22449
- const nonCachedInput = Math.max(0, inputTokens - cachedTokens);
22450
- return [
22451
- {
22452
- sessionUpdate: "usage_update",
22453
- used: nonCachedInput,
22454
- size: inputTokens,
22455
- _meta: { inputTokens, outputTokens, cachedTokens, cacheCreationTokens }
22456
- }
22457
- ];
22458
- }
22459
- return [];
22460
- }
22461
- function createTranscriptWriter(options) {
22462
- const join2 = options.pathJoin ?? path23.join;
22463
- const filePath = join2(options.logDir, options.logFileName);
22464
- let dirEnsured;
22465
- let disabled = false;
22466
- const ensureDir = () => {
22467
- if (!dirEnsured) {
22468
- dirEnsured = options.fs.mkdir(options.logDir, { recursive: true });
22469
- }
22470
- return dirEnsured;
22471
- };
22472
- return {
22473
- filePath,
22474
- async write(event) {
22475
- if (disabled) return;
22476
- const updates = mapAcpEventToSessionUpdates(event);
22477
- if (updates.length === 0) return;
22478
- try {
22479
- await ensureDir();
22480
- const payload = updates.map((u) => `${JSON.stringify(u)}
22481
- `).join("");
22482
- await options.fs.appendFile(filePath, payload);
22483
- } catch {
22484
- disabled = true;
22485
- }
22486
- },
22487
- async close() {
22488
- }
22489
- };
22490
- }
22491
-
22492
- // packages/superintendent/src/commands/poe-agent-runner.ts
22493
- var defaultTranscriptFs = {
22494
- mkdir: (dir, options) => mkdir5(dir, options).then(() => void 0),
22495
- appendFile: (filePath, contents) => appendFile2(filePath, contents, "utf8")
22496
- };
22497
- async function executePoeAgent(agentSpec, input, createAgent = agent, transcriptFs = defaultTranscriptFs) {
22667
+ async function executePoeAgent(agentSpec, input, createAgent = agent) {
22498
22668
  const { model } = parseAgentSpecifier(agentSpec);
22499
22669
  if (!model) {
22500
22670
  throw new Error(
22501
22671
  `poe-agent requires a model in the agent specifier (e.g. "poe-agent:openai/gpt-5.4"); got "${agentSpec}".`
22502
22672
  );
22503
22673
  }
22504
- const mcpConfigs = toPoeMcpConfigs(input.mcpServers);
22505
- 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: {} }));
22506
- if (input.mode) {
22507
- builder = builder.use(poe_agent_plugin_policy_default({ mode: input.mode }));
22508
- }
22509
- builder = builder.mcp(...mcpConfigs);
22510
- 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, {
22511
22675
  cwd: input.cwd,
22512
- ...input.signal ? { signal: input.signal } : {}
22513
- };
22514
- const transcript = input.logDir && input.logFileName ? createTranscriptWriter({
22515
- logDir: input.logDir,
22516
- logFileName: input.logFileName,
22517
- fs: transcriptFs
22518
- }) : void 0;
22519
- let completed = "";
22520
- let streamed = "";
22521
- let failure;
22522
- let usage;
22523
- const toolCalls = [];
22524
- try {
22525
- for await (const event of builder.stream(input.prompt, streamOptions)) {
22526
- if (transcript) {
22527
- await transcript.write(event);
22528
- }
22529
- if (event.type === "message.delta") {
22530
- input.onStdout?.(event.content);
22531
- streamed += event.content;
22532
- } else if (event.type === "tool.intent") {
22533
- toolCalls.push({ title: event.tool, input: event.args });
22534
- } else if (event.type === "usage") {
22535
- usage = {
22536
- inputTokens: event.usage.inputTokens,
22537
- outputTokens: event.usage.outputTokens,
22538
- cachedTokens: event.usage.cachedTokens
22539
- };
22540
- } else if (event.type === "session.complete") {
22541
- completed = event.result.output;
22542
- } else if (event.type === "session.error") {
22543
- failure = event.error;
22544
- }
22545
- }
22546
- } finally {
22547
- await transcript?.close();
22548
- }
22549
- if (failure) {
22550
- return {
22551
- stdout: streamed,
22552
- stderr: failure.message,
22553
- exitCode: 1,
22554
- ...transcript ? { logFile: transcript.filePath } : {},
22555
- ...usage ? { usage } : {}
22556
- };
22557
- }
22558
- const output = completed || streamed;
22559
- return {
22560
- stdout: output,
22561
- stderr: "",
22562
- exitCode: 0,
22563
- summary: output,
22564
- ...transcript ? { logFile: transcript.filePath } : {},
22565
- ...toolCalls.length > 0 ? { toolCalls } : {},
22566
- ...usage ? { usage } : {}
22567
- };
22568
- }
22569
- function toPoeMcpConfigs(servers) {
22570
- if (!servers) {
22571
- return [];
22572
- }
22573
- return Object.entries(servers).map(([name, server]) => ({ name, ...server }));
22676
+ signal: input.signal,
22677
+ onStdout: input.onStdout,
22678
+ logPath: input.logPath
22679
+ });
22574
22680
  }
22575
22681
 
22576
22682
  // packages/superintendent/src/commands/run.ts
@@ -22669,12 +22775,12 @@ var runMcpCommand = defineCommand({
22669
22775
  },
22670
22776
  render: runCommand2.render
22671
22777
  });
22672
- async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs3) {
22778
+ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs4) {
22673
22779
  const configPath = resolveConfigPath(homeDir);
22674
22780
  const projectConfigPath = resolveProjectConfigPath(cwd);
22675
22781
  try {
22676
22782
  const document = await readMergedDocument(
22677
- createConfigResolutionFs(fs3),
22783
+ createConfigResolutionFs(fs4),
22678
22784
  configPath,
22679
22785
  projectConfigPath
22680
22786
  );
@@ -22692,48 +22798,48 @@ async function resolveSuperintendentCommandConfig(cwd, homeDir, env, fs3) {
22692
22798
  return { tui: false };
22693
22799
  }
22694
22800
  }
22695
- async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs3) {
22801
+ async function resolveSuperintendentPlanDirectory(cwd, homeDir, env, fs4) {
22696
22802
  const configPath = resolveConfigPath(homeDir);
22697
22803
  const projectConfigPath = resolveProjectConfigPath(cwd);
22698
22804
  const document = await readMergedDocument(
22699
- createConfigResolutionFs(fs3),
22805
+ createConfigResolutionFs(fs4),
22700
22806
  configPath,
22701
22807
  projectConfigPath
22702
22808
  );
22703
22809
  return resolveScope(planConfigScope.schema, document.plan, env).plan_directory;
22704
22810
  }
22705
22811
  var configFs = {
22706
- readFile: (filePath, encoding) => fsPromises6.readFile(filePath, encoding),
22812
+ readFile: (filePath, encoding) => fsPromises7.readFile(filePath, encoding),
22707
22813
  writeFile: async (filePath, content, options) => {
22708
- await fsPromises6.writeFile(filePath, content, options ?? { encoding: "utf8" });
22814
+ await fsPromises7.writeFile(filePath, content, options ?? { encoding: "utf8" });
22709
22815
  },
22710
22816
  mkdir: async (filePath, options) => {
22711
- await fsPromises6.mkdir(filePath, options);
22817
+ await fsPromises7.mkdir(filePath, options);
22712
22818
  },
22713
- unlink: (filePath) => fsPromises6.unlink(filePath),
22819
+ unlink: (filePath) => fsPromises7.unlink(filePath),
22714
22820
  stat: async (filePath) => {
22715
- const stat6 = await fsPromises6.stat(filePath);
22716
- return { mode: stat6.mode };
22821
+ const stat7 = await fsPromises7.stat(filePath);
22822
+ return { mode: stat7.mode };
22717
22823
  },
22718
- readdir: (filePath) => fsPromises6.readdir(filePath)
22824
+ readdir: (filePath) => fsPromises7.readdir(filePath)
22719
22825
  };
22720
- function createConfigResolutionFs(fs3) {
22721
- if (!fs3) {
22826
+ function createConfigResolutionFs(fs4) {
22827
+ if (!fs4) {
22722
22828
  return configFs;
22723
22829
  }
22724
22830
  return {
22725
22831
  ...configFs,
22726
- readFile: (filePath, encoding) => fs3.readFile(filePath, encoding),
22832
+ readFile: (filePath, encoding) => fs4.readFile(filePath, encoding),
22727
22833
  writeFile: async (filePath, content, options) => {
22728
- await fs3.writeFile(filePath, content, options);
22834
+ await fs4.writeFile(filePath, content, options);
22729
22835
  },
22730
22836
  mkdir: async (filePath, options) => {
22731
- await fs3.mkdir(filePath, options);
22837
+ await fs4.mkdir(filePath, options);
22732
22838
  }
22733
22839
  };
22734
22840
  }
22735
22841
  async function runSuperintendentCommand(options) {
22736
- const fs3 = options.fs ?? createDefaultFs3();
22842
+ const fs4 = options.fs ?? createDefaultFs3();
22737
22843
  const now = options.now ?? Date.now;
22738
22844
  const selectPrompt = options.selectPrompt ?? select2;
22739
22845
  const dashboardFactory = options.createDashboard ?? createDashboard;
@@ -22754,7 +22860,7 @@ async function runSuperintendentCommand(options) {
22754
22860
  assumeYes,
22755
22861
  interactive,
22756
22862
  env,
22757
- fs: fs3,
22863
+ fs: fs4,
22758
22864
  selectPrompt
22759
22865
  });
22760
22866
  const runLogDir = resolveRunLogDir({
@@ -22762,7 +22868,7 @@ async function runSuperintendentCommand(options) {
22762
22868
  runner: "superintendent",
22763
22869
  homeDir: options.homeDir
22764
22870
  });
22765
- const document = parseSuperintendentDoc(selectedDocPath, await fs3.readFile(selectedDocPath, "utf8"));
22871
+ const document = parseSuperintendentDoc(selectedDocPath, await fs4.readFile(selectedDocPath, "utf8"));
22766
22872
  const builderAgent = options.builderAgent ?? document.frontmatter.builder.agent;
22767
22873
  const selectedBuilderAgent = resolveAgentId(builderAgent) ?? builderAgent;
22768
22874
  if (!useDashboard) {
@@ -22778,7 +22884,7 @@ async function runSuperintendentCommand(options) {
22778
22884
  docPath: selectedDocPath,
22779
22885
  cwd: options.cwd,
22780
22886
  homeDir: options.homeDir,
22781
- ...options.fs ? { fs: fs3 } : {},
22887
+ ...options.fs ? { fs: fs4 } : {},
22782
22888
  signal: headlessAbort.signal,
22783
22889
  logDir: runLogDir,
22784
22890
  callbacks: {
@@ -23028,7 +23134,7 @@ async function runSuperintendentCommand(options) {
23028
23134
  session.pauseRequested = true;
23029
23135
  }
23030
23136
  editPlan(session.dashboard, session.latestLogFile, env, options.openInEditor);
23031
- appendEvent("info", `Log opened: ${path24.basename(session.latestLogFile)}`);
23137
+ appendEvent("info", `Log opened: ${path26.basename(session.latestLogFile)}`);
23032
23138
  syncStats();
23033
23139
  }
23034
23140
  };
@@ -23048,7 +23154,7 @@ async function runSuperintendentCommand(options) {
23048
23154
  docPath: selectedDocPath,
23049
23155
  cwd: options.cwd,
23050
23156
  homeDir: options.homeDir,
23051
- ...options.fs ? { fs: fs3 } : {},
23157
+ ...options.fs ? { fs: fs4 } : {},
23052
23158
  callbacks,
23053
23159
  signal: abortController.signal,
23054
23160
  logDir: runLogDir,
@@ -23166,24 +23272,24 @@ async function discoverSuperintendentDocs(options) {
23166
23272
  }
23167
23273
  return matches2;
23168
23274
  }
23169
- async function listPlanDirectoryDocs(fs3, planDirectory, cwd, homeDir) {
23275
+ async function listPlanDirectoryDocs(fs4, planDirectory, cwd, homeDir) {
23170
23276
  const absoluteDir = resolveAbsolutePlanDirectory(planDirectory, cwd, homeDir);
23171
23277
  let entries;
23172
23278
  try {
23173
- entries = await fs3.readdir(absoluteDir);
23279
+ entries = await fs4.readdir(absoluteDir);
23174
23280
  } catch (error2) {
23175
23281
  if (isMissingDirectory(error2)) {
23176
23282
  return [];
23177
23283
  }
23178
23284
  throw error2;
23179
23285
  }
23180
- 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));
23181
23287
  }
23182
23288
  function resolveAbsolutePlanDirectory(dir, cwd, homeDir) {
23183
23289
  if (dir.startsWith("~/")) {
23184
- return path24.join(homeDir, dir.slice(2));
23290
+ return path26.join(homeDir, dir.slice(2));
23185
23291
  }
23186
- return path24.isAbsolute(dir) ? dir : path24.resolve(cwd, dir);
23292
+ return path26.isAbsolute(dir) ? dir : path26.resolve(cwd, dir);
23187
23293
  }
23188
23294
  function isMissingDirectory(error2) {
23189
23295
  if (!error2 || typeof error2 !== "object" || !("code" in error2)) {
@@ -23280,8 +23386,7 @@ async function executeSpawnAgent(agent2, input) {
23280
23386
  ...input.mode ? { mode: input.mode } : {},
23281
23387
  ...input.mcpServers ? { mcpServers: input.mcpServers } : {},
23282
23388
  ...input.signal ? { signal: input.signal } : {},
23283
- ...input.logDir ? { logDir: input.logDir } : {},
23284
- ...input.logFileName ? { logFileName: input.logFileName } : {},
23389
+ ...input.logPath ? { logPath: input.logPath } : {},
23285
23390
  ...tee ? { tee } : {}
23286
23391
  });
23287
23392
  return {
@@ -23320,8 +23425,7 @@ async function executeSpawnAgentStreaming(agent2, input) {
23320
23425
  prompt: input.prompt,
23321
23426
  cwd: input.cwd,
23322
23427
  startedAt: /* @__PURE__ */ new Date(),
23323
- ...input.logDir ? { logDir: input.logDir } : {},
23324
- ...input.logFileName ? { logFileName: input.logFileName } : {},
23428
+ ...input.logPath ? { logPath: input.logPath } : {},
23325
23429
  ...input.mode ? { mode: input.mode } : {}
23326
23430
  };
23327
23431
  await applyMiddlewares([spawnLog, usageCapture, sessionCapture], middlewareContext);
@@ -23415,7 +23519,7 @@ function resolveEditor(env) {
23415
23519
  const parts = raw.split(/\s+/);
23416
23520
  const command = parts[0] ?? "vi";
23417
23521
  const args = parts.slice(1);
23418
- const binary = path24.basename(command);
23522
+ const binary = path26.basename(command);
23419
23523
  const mode = GUI_EDITOR_BINARIES.has(binary) ? "gui" : "tty";
23420
23524
  return { command, args, mode };
23421
23525
  }
@@ -23442,35 +23546,35 @@ function stripStopReason(result) {
23442
23546
  };
23443
23547
  }
23444
23548
  function displayPath(filePath, cwd, homeDir) {
23445
- if (filePath.startsWith(`${cwd}${path24.sep}`)) {
23446
- return path24.relative(cwd, filePath);
23549
+ if (filePath.startsWith(`${cwd}${path26.sep}`)) {
23550
+ return path26.relative(cwd, filePath);
23447
23551
  }
23448
- if (filePath.startsWith(`${homeDir}${path24.sep}`)) {
23449
- return `~/${path24.relative(homeDir, filePath)}`;
23552
+ if (filePath.startsWith(`${homeDir}${path26.sep}`)) {
23553
+ return `~/${path26.relative(homeDir, filePath)}`;
23450
23554
  }
23451
23555
  return filePath;
23452
23556
  }
23453
23557
  function createDefaultFs3() {
23454
23558
  return {
23455
- readFile: fsPromises6.readFile,
23456
- writeFile: fsPromises6.writeFile,
23457
- readdir: fsPromises6.readdir,
23559
+ readFile: fsPromises7.readFile,
23560
+ writeFile: fsPromises7.writeFile,
23561
+ readdir: fsPromises7.readdir,
23458
23562
  stat: async (filePath) => {
23459
- const stat6 = await fsPromises6.stat(filePath);
23563
+ const stat7 = await fsPromises7.stat(filePath);
23460
23564
  return {
23461
- isFile: () => stat6.isFile(),
23462
- isDirectory: () => stat6.isDirectory(),
23463
- mtimeMs: stat6.mtimeMs
23565
+ isFile: () => stat7.isFile(),
23566
+ isDirectory: () => stat7.isDirectory(),
23567
+ mtimeMs: stat7.mtimeMs
23464
23568
  };
23465
23569
  },
23466
23570
  mkdir: async (filePath, mkdirOptions) => {
23467
- await fsPromises6.mkdir(filePath, mkdirOptions);
23571
+ await fsPromises7.mkdir(filePath, mkdirOptions);
23468
23572
  },
23469
23573
  rmdir: async (filePath) => {
23470
- await fsPromises6.rmdir(filePath);
23574
+ await fsPromises7.rmdir(filePath);
23471
23575
  },
23472
23576
  rename: async (oldPath, newPath) => {
23473
- await fsPromises6.rename(oldPath, newPath);
23577
+ await fsPromises7.rename(oldPath, newPath);
23474
23578
  }
23475
23579
  };
23476
23580
  }
@@ -23488,8 +23592,8 @@ var validateCommand = defineCommand({
23488
23592
  positional: ["path"],
23489
23593
  params: validateParams,
23490
23594
  scope: ["cli", "mcp", "sdk"],
23491
- handler: async ({ params, fs: fs3 }) => {
23492
- const content = await readDocument6(params.path, fs3);
23595
+ handler: async ({ params, fs: fs4 }) => {
23596
+ const content = await readDocument6(params.path, fs4);
23493
23597
  return validateSuperintendentDocument(params.path, content);
23494
23598
  },
23495
23599
  render: {
@@ -23522,7 +23626,7 @@ var superintendentGroup = defineGroup({
23522
23626
  name: "superintendent",
23523
23627
  description: "Superintendent workflow commands.",
23524
23628
  scope: ["cli", "mcp", "sdk"],
23525
- children: [runCommand2, validateCommand, completeCommand, installCommand, builderGroup, inspectorGroup]
23629
+ children: [runCommand2, validateCommand, completeCommand, installCommand, planPathCommand, builderGroup, inspectorGroup]
23526
23630
  });
23527
23631
  var superintendentMcpGroup = defineGroup({
23528
23632
  name: "superintendent",
@@ -23566,9 +23670,9 @@ function validateSuperintendentDocument(filePath, content) {
23566
23670
  problems.push(...validatePromptVariables(document));
23567
23671
  return toValidationResult(problems);
23568
23672
  }
23569
- async function readDocument6(filePath, fs3) {
23673
+ async function readDocument6(filePath, fs4) {
23570
23674
  try {
23571
- return await fs3.readFile(filePath, "utf8");
23675
+ return await fs4.readFile(filePath, "utf8");
23572
23676
  } catch (error2) {
23573
23677
  if (hasCode5(error2, "ENOENT")) {
23574
23678
  throw new UserError(`Superintendent document not found: ${filePath}`);
@@ -24054,29 +24158,29 @@ function emitEvent(callback, event) {
24054
24158
  callback(event);
24055
24159
  }
24056
24160
  async function loadConfiguredPlugins(options) {
24057
- const fs3 = createConfigFileSystem(options.fs);
24161
+ const fs4 = createConfigFileSystem(options.fs);
24058
24162
  const homeDir = options.homeDir ?? os3.homedir();
24059
24163
  const store = createConfigStore({
24060
- fs: fs3,
24164
+ fs: fs4,
24061
24165
  filePath: options.configPath ?? resolveConfigPath(homeDir),
24062
24166
  projectFilePath: options.projectConfigPath ?? resolveProjectConfigPath(options.cwd)
24063
24167
  });
24064
24168
  const plugins = await store.scope(agentConfigScope).get("plugins");
24065
24169
  return plugins ?? void 0;
24066
24170
  }
24067
- function createConfigFileSystem(fs3) {
24068
- if (fs3) {
24069
- return fs3;
24171
+ function createConfigFileSystem(fs4) {
24172
+ if (fs4) {
24173
+ return fs4;
24070
24174
  }
24071
24175
  return {
24072
24176
  readFile(filePath, encoding) {
24073
- return encoding ? fsPromises7.readFile(filePath, encoding) : fsPromises7.readFile(filePath);
24177
+ return encoding ? fsPromises8.readFile(filePath, encoding) : fsPromises8.readFile(filePath);
24074
24178
  },
24075
24179
  async writeFile(filePath, data, options) {
24076
- await fsPromises7.writeFile(filePath, data, options);
24180
+ await fsPromises8.writeFile(filePath, data, options);
24077
24181
  },
24078
24182
  async mkdir(filePath, options) {
24079
- await fsPromises7.mkdir(filePath, options);
24183
+ await fsPromises8.mkdir(filePath, options);
24080
24184
  }
24081
24185
  };
24082
24186
  }