@astralyn/pi 0.82.5 → 0.82.6

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 (94) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cli/project-trust.d.ts.map +1 -1
  3. package/dist/cli/project-trust.js +4 -1
  4. package/dist/cli/project-trust.js.map +1 -1
  5. package/dist/core/bash-executor.d.ts.map +1 -1
  6. package/dist/core/bash-executor.js +4 -22
  7. package/dist/core/bash-executor.js.map +1 -1
  8. package/dist/core/extensions/index.d.ts +1 -1
  9. package/dist/core/extensions/index.d.ts.map +1 -1
  10. package/dist/core/extensions/index.js.map +1 -1
  11. package/dist/core/extensions/types.d.ts +28 -5
  12. package/dist/core/extensions/types.d.ts.map +1 -1
  13. package/dist/core/extensions/types.js.map +1 -1
  14. package/dist/core/tools/output-accumulator.d.ts +3 -13
  15. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  16. package/dist/core/tools/output-accumulator.js +6 -36
  17. package/dist/core/tools/output-accumulator.js.map +1 -1
  18. package/dist/extensions/plan/constants.d.ts +11 -2
  19. package/dist/extensions/plan/constants.d.ts.map +1 -1
  20. package/dist/extensions/plan/constants.js +14 -2
  21. package/dist/extensions/plan/constants.js.map +1 -1
  22. package/dist/extensions/plan/index.d.ts +0 -18
  23. package/dist/extensions/plan/index.d.ts.map +1 -1
  24. package/dist/extensions/plan/index.js +35 -3
  25. package/dist/extensions/plan/index.js.map +1 -1
  26. package/dist/extensions/plan/view.d.ts +36 -0
  27. package/dist/extensions/plan/view.d.ts.map +1 -0
  28. package/dist/extensions/plan/view.js +74 -0
  29. package/dist/extensions/plan/view.js.map +1 -0
  30. package/dist/extensions/router/stream.d.ts.map +1 -1
  31. package/dist/extensions/router/stream.js +44 -0
  32. package/dist/extensions/router/stream.js.map +1 -1
  33. package/dist/extensions/subagent/activity.d.ts.map +1 -1
  34. package/dist/extensions/subagent/activity.js +25 -4
  35. package/dist/extensions/subagent/activity.js.map +1 -1
  36. package/dist/extensions/subagent/index.d.ts.map +1 -1
  37. package/dist/extensions/subagent/index.js +14 -0
  38. package/dist/extensions/subagent/index.js.map +1 -1
  39. package/dist/extensions/subagent/render.d.ts.map +1 -1
  40. package/dist/extensions/subagent/render.js +243 -116
  41. package/dist/extensions/subagent/render.js.map +1 -1
  42. package/dist/extensions/subagent/resolve.d.ts.map +1 -1
  43. package/dist/extensions/subagent/resolve.js +13 -9
  44. package/dist/extensions/subagent/resolve.js.map +1 -1
  45. package/dist/extensions/subagent/runner.d.ts.map +1 -1
  46. package/dist/extensions/subagent/runner.js +4 -2
  47. package/dist/extensions/subagent/runner.js.map +1 -1
  48. package/dist/extensions/subagent/schema.d.ts.map +1 -1
  49. package/dist/extensions/subagent/schema.js +2 -2
  50. package/dist/extensions/subagent/schema.js.map +1 -1
  51. package/dist/extensions/todo/constants.d.ts +17 -6
  52. package/dist/extensions/todo/constants.d.ts.map +1 -1
  53. package/dist/extensions/todo/constants.js +22 -9
  54. package/dist/extensions/todo/constants.js.map +1 -1
  55. package/dist/extensions/todo/index.d.ts +0 -14
  56. package/dist/extensions/todo/index.d.ts.map +1 -1
  57. package/dist/extensions/todo/index.js +13 -1
  58. package/dist/extensions/todo/index.js.map +1 -1
  59. package/dist/extensions/todo/schema.d.ts +53 -2
  60. package/dist/extensions/todo/schema.d.ts.map +1 -1
  61. package/dist/extensions/todo/schema.js +57 -8
  62. package/dist/extensions/todo/schema.js.map +1 -1
  63. package/dist/extensions/todo/state.d.ts +16 -5
  64. package/dist/extensions/todo/state.d.ts.map +1 -1
  65. package/dist/extensions/todo/state.js +866 -130
  66. package/dist/extensions/todo/state.js.map +1 -1
  67. package/dist/extensions/todo/view.d.ts +16 -1
  68. package/dist/extensions/todo/view.d.ts.map +1 -1
  69. package/dist/extensions/todo/view.js +283 -1
  70. package/dist/extensions/todo/view.js.map +1 -1
  71. package/dist/modes/interactive/components/extension-selector.d.ts +6 -1
  72. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  73. package/dist/modes/interactive/components/extension-selector.js +14 -6
  74. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  75. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  76. package/dist/modes/interactive/components/tool-execution.js +6 -0
  77. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  78. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  79. package/dist/modes/interactive/interactive-mode.js +7 -1
  80. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  81. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  82. package/dist/modes/rpc/rpc-mode.js +8 -1
  83. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  84. package/docs/bundled/extensions/plan.md +6 -4
  85. package/docs/bundled/extensions/subagent.md +2 -2
  86. package/docs/bundled/extensions/todo.md +8 -6
  87. package/docs/bundled/tool-presentation.md +1 -1
  88. package/docs/extensions.md +14 -0
  89. package/npm-shrinkwrap.json +2 -2
  90. package/package.json +1 -1
  91. package/dist/utils/output-decoder.d.ts +0 -52
  92. package/dist/utils/output-decoder.d.ts.map +0 -1
  93. package/dist/utils/output-decoder.js +0 -134
  94. package/dist/utils/output-decoder.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.82.6] - 2026-07-27
6
+
7
+ ### Added
8
+
9
+ - The bundled `todo` tool now supports atomic `create_many` planning batches (up to 20 tasks) with stable batch keys and intra-batch dependencies, paged/searchable/unblocked `list` queries, and bounded nested JSON metadata. Task snapshots are schema-versioned and defensively replayed, so malformed latest history falls back to the last valid snapshot. `clear` now requires `confirm: true` plus the current `expectedCount`; an active task that gains an unresolved dependency automatically returns to `pending`.
10
+
11
+ - Select dialogs can now carry a second layer of information: `ctx.ui.select()` accepts `{ label, description }` options, rendering the description as a muted line under the label so the action and its trade-off can be scanned separately, and takes `subtitle` (a muted line under the title, for context that is not itself a choice) and `cancelHint` (wording for the dismiss hint, for dialogs where `Esc` is not destructive). Plain `string[]` options still work, and `select()` still resolves to the chosen label. RPC clients receive labels only, so the wire protocol is unchanged. See [extensions](docs/extensions.md).
12
+
13
+ ### Changed
14
+
15
+ - Returned bash output decoding to the reviewed upstream UTF-8-only streaming `TextDecoder`, removing the distribution-specific OEM-code-page fallback and per-line buffering. Legacy Windows console programs that emit non-UTF-8 bytes now follow upstream behavior and may render replacement characters.
16
+
17
+ - Collapsed `todo` groups now summarize completed operations — created IDs, status updates, list counts, deletion, and clearing — instead of hiding their results; failed rows include a sanitized 120-character reason, and `ctrl+o` still reveals full calls and results. See [todo](docs/bundled/extensions/todo.md).
18
+
19
+ - Redesigned the `exit_plan` approval dialog and tool row. The three choices now separate the decision from its trade-off (`Start executing` / *keep full context*) instead of burying it in a parenthetical, the dialog subtitle reports current context usage — the fact the compact-or-not decision actually turns on — and the dismiss hint reads "keep planning" rather than "cancel", matching what `Esc` has always done. The tool row no longer echoes the plan: a collapsed call shows `exit_plan <title>` (plan body on `ctrl+o`) instead of the whole markdown document escaped onto one line, and the result shows where the plan landed plus what happens next, instead of the mode-precedence text written for the model. See [plan](docs/bundled/extensions/plan.md).
20
+ - The plan-mode footer marker now reads `Plan Mode` in the theme's accent color rather than a `plan` tag in warning yellow — plan mode is a working mode, not a warning state.
21
+ - Consecutive `todo` calls now collapse into one grouped run like `read`/`find`'s `explore` group, and each call renders as a single headline (`todo create <subject>`, `todo update #2 in_progress`) instead of a raw argument dump. `ctrl+o` expands the group back to full calls, where the headline is followed by the parameters the result never echoes (`description`, `activeForm`, dependency edges). See [tool presentation](docs/bundled/tool-presentation.md).
22
+ - Redesigned the subagent transcript around a deep-trimmed collapsed card and a report-cover-sheet expanded view. Collapsed: a running single delegation folds to at most three lines — the intent line now carries tool uses, the `ctx:` watermark, cost, and elapsed time — and a settled card ends with one `tok · tool uses · ctx · $ · duration` metrics line; parallel batches drop the cross-run activity digest, gain stable dim ordinals on run rows (matching the expanded section numbers, immune to active-first reordering), and settle to a `tok · $ · duration` footer. Live lines never quote token totals, which are cache-inflated mid-run. Expanded (`ctrl+o`): each run renders a status line (`✓ Completed · model · thinking`), a metrics line, a fixed two-line `Prompt` preview with honest continuation notes (`… continues, N more lines · capped at 1KB`), an `Activity · last n of N` digest whose successful rows are quiet one-liners (glyphs only for failures and the in-flight row, durations only at ten seconds or longer), a `Working` tail of the last three live lines while streaming, and the full `Report` (or `Error`, with `Report · partial` for salvaged output) rendered as Markdown — replacing the full prompt echo, the glyphed activity dump, and the trailing metadata line. See [subagent](docs/bundled/extensions/subagent.md).
23
+ - The subagent tool now accepts an absolute task `cwd` that stays inside the parent working directory — models routinely echo the parent cwd back verbatim — instead of failing the task over path style; escapes are still rejected.
24
+
25
+ ### Fixed
26
+
27
+ - Fixed the `router` relay rejecting multi-turn GPT conversations on Codex-adapted gateways with `input[i].status: unknown_parameter`. pi-ai replays history per the OpenAI Platform schema — assistant messages carry a hardcoded `status: "completed"`, reasoning items are replayed verbatim from `output_item.done` (which includes `status`), and `output_text` blocks carry `annotations: []` — but Codex CLI's `ResponseItem` serialization emits none of these, so gateways that validate against the Codex schema 400. The relay payload reshape now strips `status` from exactly the item types whose Codex serialization has no such field (`message`, `reasoning`, `function_call`, `function_call_output`, `custom_tool_call_output` — it is required on `local_shell_call`/`tool_search_output` and optional elsewhere, so those keep it), drops `annotations` from `output_text` content, and deletes the pi-specific `prompt_cache_options` request field alongside the other Platform-only fields.
28
+ - Fixed the subagent live tail freezing into a lone `…` once a worker streamed more than 1KB of text: bounded details now keep the newest `liveText` via tail-bounding instead of head-bounding, and the renderer skips truncation-notice lines outright, in both the collapsed tail line and the expanded `Working` section.
29
+ - Fixed the expanded parallel batch trailer quoting the cache-inflated aggregate token total while runs were still in flight; the trailer now omits `tok` until the batch settles, matching every other live line.
30
+ - Fixed the subagent card sitting empty while first-use model-runtime creation or task resolution stalled: the tool now paints `Initializing…` before its first await.
31
+ - Transcript excerpt scrubbing now also covers `boundText`'s minimal `[Output truncated.]` notice, and a worker running with `thinking: off` no longer renders a bare `off` segment in expanded batch metrics.
32
+
5
33
  ## [0.82.5] - 2026-07-26
6
34
 
7
35
  ### Added
@@ -1 +1 @@
1
- {"version":3,"file":"project-trust.d.ts","sourceRoot":"","sources":["../../src/cli/project-trust.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,EAAE,OAAO,CAAC;CACf,GAAG,mBAAmB,CAkDtB","sourcesContent":["import chalk from \"chalk\";\nimport type { ProjectTrustContext } from \"../core/extensions/types.ts\";\nimport type { AppMode } from \"../core/project-trust.ts\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { showStartupInput, showStartupSelector } from \"./startup-ui.ts\";\n\nexport function createProjectTrustContext(options: {\n\tcwd: string;\n\tmode: AppMode;\n\tsettingsManager: SettingsManager;\n\thasUI: boolean;\n}): ProjectTrustContext {\n\treturn {\n\t\tcwd: options.cwd,\n\t\tmode: options.mode === \"interactive\" ? \"tui\" : options.mode,\n\t\thasUI: options.hasUI,\n\t\tui: {\n\t\t\tselect: async (title, selectOptions) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupSelector(\n\t\t\t\t\toptions.settingsManager,\n\t\t\t\t\ttitle,\n\t\t\t\t\tselectOptions.map((option) => ({ label: option, value: option })),\n\t\t\t\t);\n\t\t\t},\n\t\t\tconfirm: async (title, message) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t(await showStartupSelector(options.settingsManager, `${title}\\n${message}`, [\n\t\t\t\t\t\t{ label: \"Yes\", value: true },\n\t\t\t\t\t\t{ label: \"No\", value: false },\n\t\t\t\t\t])) ?? false\n\t\t\t\t);\n\t\t\t},\n\t\t\tinput: async (title, placeholder) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupInput(options.settingsManager, title, placeholder);\n\t\t\t},\n\t\t\tnotify: (message, type = \"info\") => {\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\tconst color = type === \"error\" ? chalk.red : type === \"warning\" ? chalk.yellow : chalk.cyan;\n\t\t\t\t\tconsole.error(color(message));\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"project-trust.d.ts","sourceRoot":"","sources":["../../src/cli/project-trust.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,EAAE,OAAO,CAAC;CACf,GAAG,mBAAmB,CAqDtB","sourcesContent":["import chalk from \"chalk\";\nimport type { ProjectTrustContext } from \"../core/extensions/types.ts\";\nimport type { AppMode } from \"../core/project-trust.ts\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { showStartupInput, showStartupSelector } from \"./startup-ui.ts\";\n\nexport function createProjectTrustContext(options: {\n\tcwd: string;\n\tmode: AppMode;\n\tsettingsManager: SettingsManager;\n\thasUI: boolean;\n}): ProjectTrustContext {\n\treturn {\n\t\tcwd: options.cwd,\n\t\tmode: options.mode === \"interactive\" ? \"tui\" : options.mode,\n\t\thasUI: options.hasUI,\n\t\tui: {\n\t\t\tselect: async (title, selectOptions) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupSelector(\n\t\t\t\t\toptions.settingsManager,\n\t\t\t\t\ttitle,\n\t\t\t\t\tselectOptions.map((option) => {\n\t\t\t\t\t\tconst label = typeof option === \"string\" ? option : option.label;\n\t\t\t\t\t\treturn { label, value: label };\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\tconfirm: async (title, message) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t(await showStartupSelector(options.settingsManager, `${title}\\n${message}`, [\n\t\t\t\t\t\t{ label: \"Yes\", value: true },\n\t\t\t\t\t\t{ label: \"No\", value: false },\n\t\t\t\t\t])) ?? false\n\t\t\t\t);\n\t\t\t},\n\t\t\tinput: async (title, placeholder) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupInput(options.settingsManager, title, placeholder);\n\t\t\t},\n\t\t\tnotify: (message, type = \"info\") => {\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\tconst color = type === \"error\" ? chalk.red : type === \"warning\" ? chalk.yellow : chalk.cyan;\n\t\t\t\t\tconsole.error(color(message));\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
@@ -13,7 +13,10 @@ export function createProjectTrustContext(options) {
13
13
  if (options.mode !== "interactive") {
14
14
  return undefined;
15
15
  }
16
- return showStartupSelector(options.settingsManager, title, selectOptions.map((option) => ({ label: option, value: option })));
16
+ return showStartupSelector(options.settingsManager, title, selectOptions.map((option) => {
17
+ const label = typeof option === "string" ? option : option.label;
18
+ return { label, value: label };
19
+ }));
17
20
  },
18
21
  confirm: async (title, message) => {
19
22
  if (!options.hasUI) {
@@ -1 +1 @@
1
- {"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/cli/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAExE,MAAM,UAAU,yBAAyB,CAAC,OAKzC,EAAuB;IACvB,OAAO;QACN,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;QAC3D,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,EAAE,EAAE;YACH,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,CAAC;gBACvC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;oBACpB,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;oBACpC,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,OAAO,mBAAmB,CACzB,OAAO,CAAC,eAAe,EACvB,KAAK,EACL,aAAa,CAAC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,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;oBAC5F,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC/B,CAAC;YAAA,CACD;SACD;KACD,CAAC;AAAA,CACF","sourcesContent":["import chalk from \"chalk\";\nimport type { ProjectTrustContext } from \"../core/extensions/types.ts\";\nimport type { AppMode } from \"../core/project-trust.ts\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { showStartupInput, showStartupSelector } from \"./startup-ui.ts\";\n\nexport function createProjectTrustContext(options: {\n\tcwd: string;\n\tmode: AppMode;\n\tsettingsManager: SettingsManager;\n\thasUI: boolean;\n}): ProjectTrustContext {\n\treturn {\n\t\tcwd: options.cwd,\n\t\tmode: options.mode === \"interactive\" ? \"tui\" : options.mode,\n\t\thasUI: options.hasUI,\n\t\tui: {\n\t\t\tselect: async (title, selectOptions) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupSelector(\n\t\t\t\t\toptions.settingsManager,\n\t\t\t\t\ttitle,\n\t\t\t\t\tselectOptions.map((option) => ({ label: option, value: option })),\n\t\t\t\t);\n\t\t\t},\n\t\t\tconfirm: async (title, message) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t(await showStartupSelector(options.settingsManager, `${title}\\n${message}`, [\n\t\t\t\t\t\t{ label: \"Yes\", value: true },\n\t\t\t\t\t\t{ label: \"No\", value: false },\n\t\t\t\t\t])) ?? false\n\t\t\t\t);\n\t\t\t},\n\t\t\tinput: async (title, placeholder) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupInput(options.settingsManager, title, placeholder);\n\t\t\t},\n\t\t\tnotify: (message, type = \"info\") => {\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\tconst color = type === \"error\" ? chalk.red : type === \"warning\" ? chalk.yellow : chalk.cyan;\n\t\t\t\t\tconsole.error(color(message));\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/cli/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAExE,MAAM,UAAU,yBAAyB,CAAC,OAKzC,EAAuB;IACvB,OAAO;QACN,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;QAC3D,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,EAAE,EAAE;YACH,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,CAAC;gBACvC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;oBACpB,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;oBACpC,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,OAAO,mBAAmB,CACzB,OAAO,CAAC,eAAe,EACvB,KAAK,EACL,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBAC7B,MAAM,KAAK,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC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AG,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;oBAC5F,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC/B,CAAC;YAAA,CACD;SACD;KACD,CAAC;AAAA,CACF","sourcesContent":["import chalk from \"chalk\";\nimport type { ProjectTrustContext } from \"../core/extensions/types.ts\";\nimport type { AppMode } from \"../core/project-trust.ts\";\nimport type { SettingsManager } from \"../core/settings-manager.ts\";\nimport { showStartupInput, showStartupSelector } from \"./startup-ui.ts\";\n\nexport function createProjectTrustContext(options: {\n\tcwd: string;\n\tmode: AppMode;\n\tsettingsManager: SettingsManager;\n\thasUI: boolean;\n}): ProjectTrustContext {\n\treturn {\n\t\tcwd: options.cwd,\n\t\tmode: options.mode === \"interactive\" ? \"tui\" : options.mode,\n\t\thasUI: options.hasUI,\n\t\tui: {\n\t\t\tselect: async (title, selectOptions) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupSelector(\n\t\t\t\t\toptions.settingsManager,\n\t\t\t\t\ttitle,\n\t\t\t\t\tselectOptions.map((option) => {\n\t\t\t\t\t\tconst label = typeof option === \"string\" ? option : option.label;\n\t\t\t\t\t\treturn { label, value: label };\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t},\n\t\t\tconfirm: async (title, message) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t(await showStartupSelector(options.settingsManager, `${title}\\n${message}`, [\n\t\t\t\t\t\t{ label: \"Yes\", value: true },\n\t\t\t\t\t\t{ label: \"No\", value: false },\n\t\t\t\t\t])) ?? false\n\t\t\t\t);\n\t\t\t},\n\t\t\tinput: async (title, placeholder) => {\n\t\t\t\tif (!options.hasUI) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\treturn showStartupInput(options.settingsManager, title, placeholder);\n\t\t\t},\n\t\t\tnotify: (message, type = \"info\") => {\n\t\t\t\tif (options.mode !== \"interactive\") {\n\t\t\t\t\tconst color = type === \"error\" ? chalk.red : type === \"warning\" ? chalk.yellow : chalk.cyan;\n\t\t\t\t\tconsole.error(color(message));\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bash-executor.d.ts","sourceRoot":"","sources":["../../src/core/bash-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOtD,MAAM,WAAW,mBAAmB;IACnC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,mCAAmC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IAC1B,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,SAAS,EAAE,OAAO,CAAC;IACnB,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD;;;GAGG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,cAAc,EAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,UAAU,CAAC,CAwHrB","sourcesContent":["/**\n * Bash command execution with streaming support and cancellation.\n *\n * This module provides a unified bash execution implementation used by:\n * - AgentSession.executeBash() for interactive and RPC modes\n * - Direct calls from modes that need bash execution\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { createWriteStream, type WriteStream } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { stripAnsi } from \"../utils/ansi.ts\";\nimport { type DecodedChunk, OutputDecoder } from \"../utils/output-decoder.ts\";\nimport { sanitizeBinaryOutput } from \"../utils/shell.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport { DEFAULT_MAX_BYTES, truncateTail } from \"./tools/truncate.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BashExecutorOptions {\n\t/** Callback for streaming output chunks (already sanitized) */\n\tonChunk?: (chunk: string) => void;\n\t/** AbortSignal for cancellation */\n\tsignal?: AbortSignal;\n}\n\nexport interface BashResult {\n\t/** Combined stdout + stderr output (sanitized, possibly truncated) */\n\toutput: string;\n\t/** Process exit code (undefined if killed/cancelled) */\n\texitCode: number | undefined;\n\t/** Whether the command was cancelled via signal */\n\tcancelled: boolean;\n\t/** Whether the output was truncated */\n\ttruncated: boolean;\n\t/** Path to temp file containing full output (if output exceeded truncation threshold) */\n\tfullOutputPath?: string;\n}\n\n// ============================================================================\n// Implementation\n// ============================================================================\n\n/**\n * Execute a bash command using custom BashOperations.\n * Used for remote execution (SSH, containers, etc.).\n */\nexport async function executeBashWithOperations(\n\tcommand: string,\n\tcwd: string,\n\toperations: BashOperations,\n\toptions?: BashExecutorOptions,\n): Promise<BashResult> {\n\tconst outputChunks: string[] = [];\n\tlet outputBytes = 0;\n\tconst maxOutputBytes = DEFAULT_MAX_BYTES * 2;\n\n\tlet tempFilePath: string | undefined;\n\tlet tempFileStream: WriteStream | undefined;\n\tlet totalBytes = 0;\n\n\tconst ensureTempFile = () => {\n\t\tif (tempFilePath) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = randomBytes(8).toString(\"hex\");\n\t\ttempFilePath = join(tmpdir(), `pi-bash-${id}.log`);\n\t\ttempFileStream = createWriteStream(tempFilePath);\n\t\tfor (const chunk of outputChunks) {\n\t\t\ttempFileStream.write(chunk);\n\t\t}\n\t};\n\n\tconst decoder = new OutputDecoder();\n\n\tconst handleDecoded = (decoded: DecodedChunk) => {\n\t\tif (!decoded.text && !decoded.rewound) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Sanitize: strip ANSI, replace binary garbage, normalize newlines\n\t\tconst text = sanitizeBinaryOutput(stripAnsi(decoded.text)).replace(/\\r/g, \"\");\n\n\t\tif (decoded.rewound) {\n\t\t\t// The decoder switched to the system console encoding and re-decoded\n\t\t\t// the entire stream: rebuild the rolling buffer from the corrected\n\t\t\t// transcript. Chunks already streamed to onChunk cannot be recalled,\n\t\t\t// and an already-open temp file keeps its earlier mojibake prefix —\n\t\t\t// both only affect the rare case where the switch happens late.\n\t\t\toutputChunks.length = 0;\n\t\t\toutputBytes = 0;\n\t\t}\n\n\t\t// Start writing to temp file if exceeds threshold\n\t\tif (totalBytes > DEFAULT_MAX_BYTES) {\n\t\t\tensureTempFile();\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.write(text);\n\t\t}\n\n\t\t// Keep rolling buffer\n\t\toutputChunks.push(text);\n\t\toutputBytes += text.length;\n\t\twhile (outputBytes > maxOutputBytes && outputChunks.length > 1) {\n\t\t\tconst removed = outputChunks.shift()!;\n\t\t\toutputBytes -= removed.length;\n\t\t}\n\n\t\t// Stream to callback\n\t\tif (options?.onChunk) {\n\t\t\toptions.onChunk(text);\n\t\t}\n\t};\n\n\tconst onData = (data: Buffer) => {\n\t\ttotalBytes += data.length;\n\t\thandleDecoded(decoder.push(data));\n\t};\n\n\ttry {\n\t\tconst result = await operations.exec(command, cwd, {\n\t\t\tonData,\n\t\t\tsignal: options?.signal,\n\t\t});\n\t\thandleDecoded(decoder.flush());\n\n\t\tconst fullOutput = outputChunks.join(\"\");\n\t\tconst truncationResult = truncateTail(fullOutput);\n\t\tif (truncationResult.truncated) {\n\t\t\tensureTempFile();\n\t\t}\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\t\tconst cancelled = options?.signal?.aborted ?? false;\n\n\t\treturn {\n\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\texitCode: cancelled ? undefined : (result.exitCode ?? undefined),\n\t\t\tcancelled,\n\t\t\ttruncated: truncationResult.truncated,\n\t\t\tfullOutputPath: tempFilePath,\n\t\t};\n\t} catch (err) {\n\t\t// Check if it was an abort\n\t\tif (options?.signal?.aborted) {\n\t\t\thandleDecoded(decoder.flush());\n\t\t\tconst fullOutput = outputChunks.join(\"\");\n\t\t\tconst truncationResult = truncateTail(fullOutput);\n\t\t\tif (truncationResult.truncated) {\n\t\t\t\tensureTempFile();\n\t\t\t}\n\t\t\tif (tempFileStream) {\n\t\t\t\ttempFileStream.end();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\t\texitCode: undefined,\n\t\t\t\tcancelled: true,\n\t\t\t\ttruncated: truncationResult.truncated,\n\t\t\t\tfullOutputPath: tempFilePath,\n\t\t\t};\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\n\t\tthrow err;\n\t}\n}\n"]}
1
+ {"version":3,"file":"bash-executor.d.ts","sourceRoot":"","sources":["../../src/core/bash-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOtD,MAAM,WAAW,mBAAmB;IACnC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,mCAAmC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IAC1B,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,SAAS,EAAE,OAAO,CAAC;IACnB,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD;;;GAGG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,cAAc,EAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,UAAU,CAAC,CAqGrB","sourcesContent":["/**\n * Bash command execution with streaming support and cancellation.\n *\n * This module provides a unified bash execution implementation used by:\n * - AgentSession.executeBash() for interactive and RPC modes\n * - Direct calls from modes that need bash execution\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { createWriteStream, type WriteStream } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { stripAnsi } from \"../utils/ansi.ts\";\nimport { sanitizeBinaryOutput } from \"../utils/shell.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport { DEFAULT_MAX_BYTES, truncateTail } from \"./tools/truncate.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BashExecutorOptions {\n\t/** Callback for streaming output chunks (already sanitized) */\n\tonChunk?: (chunk: string) => void;\n\t/** AbortSignal for cancellation */\n\tsignal?: AbortSignal;\n}\n\nexport interface BashResult {\n\t/** Combined stdout + stderr output (sanitized, possibly truncated) */\n\toutput: string;\n\t/** Process exit code (undefined if killed/cancelled) */\n\texitCode: number | undefined;\n\t/** Whether the command was cancelled via signal */\n\tcancelled: boolean;\n\t/** Whether the output was truncated */\n\ttruncated: boolean;\n\t/** Path to temp file containing full output (if output exceeded truncation threshold) */\n\tfullOutputPath?: string;\n}\n\n// ============================================================================\n// Implementation\n// ============================================================================\n\n/**\n * Execute a bash command using custom BashOperations.\n * Used for remote execution (SSH, containers, etc.).\n */\nexport async function executeBashWithOperations(\n\tcommand: string,\n\tcwd: string,\n\toperations: BashOperations,\n\toptions?: BashExecutorOptions,\n): Promise<BashResult> {\n\tconst outputChunks: string[] = [];\n\tlet outputBytes = 0;\n\tconst maxOutputBytes = DEFAULT_MAX_BYTES * 2;\n\n\tlet tempFilePath: string | undefined;\n\tlet tempFileStream: WriteStream | undefined;\n\tlet totalBytes = 0;\n\n\tconst ensureTempFile = () => {\n\t\tif (tempFilePath) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = randomBytes(8).toString(\"hex\");\n\t\ttempFilePath = join(tmpdir(), `pi-bash-${id}.log`);\n\t\ttempFileStream = createWriteStream(tempFilePath);\n\t\tfor (const chunk of outputChunks) {\n\t\t\ttempFileStream.write(chunk);\n\t\t}\n\t};\n\n\tconst decoder = new TextDecoder();\n\n\tconst onData = (data: Buffer) => {\n\t\ttotalBytes += data.length;\n\n\t\t// Sanitize: strip ANSI, replace binary garbage, normalize newlines\n\t\tconst text = sanitizeBinaryOutput(stripAnsi(decoder.decode(data, { stream: true }))).replace(/\\r/g, \"\");\n\n\t\t// Start writing to temp file if exceeds threshold\n\t\tif (totalBytes > DEFAULT_MAX_BYTES) {\n\t\t\tensureTempFile();\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.write(text);\n\t\t}\n\n\t\t// Keep rolling buffer\n\t\toutputChunks.push(text);\n\t\toutputBytes += text.length;\n\t\twhile (outputBytes > maxOutputBytes && outputChunks.length > 1) {\n\t\t\tconst removed = outputChunks.shift()!;\n\t\t\toutputBytes -= removed.length;\n\t\t}\n\n\t\t// Stream to callback\n\t\tif (options?.onChunk) {\n\t\t\toptions.onChunk(text);\n\t\t}\n\t};\n\n\ttry {\n\t\tconst result = await operations.exec(command, cwd, {\n\t\t\tonData,\n\t\t\tsignal: options?.signal,\n\t\t});\n\n\t\tconst fullOutput = outputChunks.join(\"\");\n\t\tconst truncationResult = truncateTail(fullOutput);\n\t\tif (truncationResult.truncated) {\n\t\t\tensureTempFile();\n\t\t}\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\t\tconst cancelled = options?.signal?.aborted ?? false;\n\n\t\treturn {\n\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\texitCode: cancelled ? undefined : (result.exitCode ?? undefined),\n\t\t\tcancelled,\n\t\t\ttruncated: truncationResult.truncated,\n\t\t\tfullOutputPath: tempFilePath,\n\t\t};\n\t} catch (err) {\n\t\t// Check if it was an abort\n\t\tif (options?.signal?.aborted) {\n\t\t\tconst fullOutput = outputChunks.join(\"\");\n\t\t\tconst truncationResult = truncateTail(fullOutput);\n\t\t\tif (truncationResult.truncated) {\n\t\t\t\tensureTempFile();\n\t\t\t}\n\t\t\tif (tempFileStream) {\n\t\t\t\ttempFileStream.end();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\t\texitCode: undefined,\n\t\t\t\tcancelled: true,\n\t\t\t\ttruncated: truncationResult.truncated,\n\t\t\t\tfullOutputPath: tempFilePath,\n\t\t\t};\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\n\t\tthrow err;\n\t}\n}\n"]}
@@ -10,7 +10,6 @@ import { createWriteStream } from "node:fs";
10
10
  import { tmpdir } from "node:os";
11
11
  import { join } from "node:path";
12
12
  import { stripAnsi } from "../utils/ansi.js";
13
- import { OutputDecoder } from "../utils/output-decoder.js";
14
13
  import { sanitizeBinaryOutput } from "../utils/shell.js";
15
14
  import { DEFAULT_MAX_BYTES, truncateTail } from "./tools/truncate.js";
16
15
  // ============================================================================
@@ -38,22 +37,11 @@ export async function executeBashWithOperations(command, cwd, operations, option
38
37
  tempFileStream.write(chunk);
39
38
  }
40
39
  };
41
- const decoder = new OutputDecoder();
42
- const handleDecoded = (decoded) => {
43
- if (!decoded.text && !decoded.rewound) {
44
- return;
45
- }
40
+ const decoder = new TextDecoder();
41
+ const onData = (data) => {
42
+ totalBytes += data.length;
46
43
  // Sanitize: strip ANSI, replace binary garbage, normalize newlines
47
- const text = sanitizeBinaryOutput(stripAnsi(decoded.text)).replace(/\r/g, "");
48
- if (decoded.rewound) {
49
- // The decoder switched to the system console encoding and re-decoded
50
- // the entire stream: rebuild the rolling buffer from the corrected
51
- // transcript. Chunks already streamed to onChunk cannot be recalled,
52
- // and an already-open temp file keeps its earlier mojibake prefix —
53
- // both only affect the rare case where the switch happens late.
54
- outputChunks.length = 0;
55
- outputBytes = 0;
56
- }
44
+ const text = sanitizeBinaryOutput(stripAnsi(decoder.decode(data, { stream: true }))).replace(/\r/g, "");
57
45
  // Start writing to temp file if exceeds threshold
58
46
  if (totalBytes > DEFAULT_MAX_BYTES) {
59
47
  ensureTempFile();
@@ -73,16 +61,11 @@ export async function executeBashWithOperations(command, cwd, operations, option
73
61
  options.onChunk(text);
74
62
  }
75
63
  };
76
- const onData = (data) => {
77
- totalBytes += data.length;
78
- handleDecoded(decoder.push(data));
79
- };
80
64
  try {
81
65
  const result = await operations.exec(command, cwd, {
82
66
  onData,
83
67
  signal: options?.signal,
84
68
  });
85
- handleDecoded(decoder.flush());
86
69
  const fullOutput = outputChunks.join("");
87
70
  const truncationResult = truncateTail(fullOutput);
88
71
  if (truncationResult.truncated) {
@@ -103,7 +86,6 @@ export async function executeBashWithOperations(command, cwd, operations, option
103
86
  catch (err) {
104
87
  // Check if it was an abort
105
88
  if (options?.signal?.aborted) {
106
- handleDecoded(decoder.flush());
107
89
  const fullOutput = outputChunks.join("");
108
90
  const truncationResult = truncateTail(fullOutput);
109
91
  if (truncationResult.truncated) {
@@ -1 +1 @@
1
- {"version":3,"file":"bash-executor.js","sourceRoot":"","sources":["../../src/core/bash-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,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YAClD,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;gBAChC,cAAc,EAAE,CAAC;YAClB,CAAC;YACD,IAAI,cAAc,EAAE,CAAC;gBACpB,cAAc,CAAC,GAAG,EAAE,CAAC;YACtB,CAAC;YACD,OAAO;gBACN,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU;gBAC1E,QAAQ,EAAE,SAAS;gBACnB,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,cAAc,EAAE,YAAY;aAC5B,CAAC;QACH,CAAC;QAED,IAAI,cAAc,EAAE,CAAC;YACpB,cAAc,CAAC,GAAG,EAAE,CAAC;QACtB,CAAC;QAED,MAAM,GAAG,CAAC;IACX,CAAC;AAAA,CACD","sourcesContent":["/**\n * Bash command execution with streaming support and cancellation.\n *\n * This module provides a unified bash execution implementation used by:\n * - AgentSession.executeBash() for interactive and RPC modes\n * - Direct calls from modes that need bash execution\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { createWriteStream, type WriteStream } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { stripAnsi } from \"../utils/ansi.ts\";\nimport { type DecodedChunk, OutputDecoder } from \"../utils/output-decoder.ts\";\nimport { sanitizeBinaryOutput } from \"../utils/shell.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport { DEFAULT_MAX_BYTES, truncateTail } from \"./tools/truncate.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BashExecutorOptions {\n\t/** Callback for streaming output chunks (already sanitized) */\n\tonChunk?: (chunk: string) => void;\n\t/** AbortSignal for cancellation */\n\tsignal?: AbortSignal;\n}\n\nexport interface BashResult {\n\t/** Combined stdout + stderr output (sanitized, possibly truncated) */\n\toutput: string;\n\t/** Process exit code (undefined if killed/cancelled) */\n\texitCode: number | undefined;\n\t/** Whether the command was cancelled via signal */\n\tcancelled: boolean;\n\t/** Whether the output was truncated */\n\ttruncated: boolean;\n\t/** Path to temp file containing full output (if output exceeded truncation threshold) */\n\tfullOutputPath?: string;\n}\n\n// ============================================================================\n// Implementation\n// ============================================================================\n\n/**\n * Execute a bash command using custom BashOperations.\n * Used for remote execution (SSH, containers, etc.).\n */\nexport async function executeBashWithOperations(\n\tcommand: string,\n\tcwd: string,\n\toperations: BashOperations,\n\toptions?: BashExecutorOptions,\n): Promise<BashResult> {\n\tconst outputChunks: string[] = [];\n\tlet outputBytes = 0;\n\tconst maxOutputBytes = DEFAULT_MAX_BYTES * 2;\n\n\tlet tempFilePath: string | undefined;\n\tlet tempFileStream: WriteStream | undefined;\n\tlet totalBytes = 0;\n\n\tconst ensureTempFile = () => {\n\t\tif (tempFilePath) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = randomBytes(8).toString(\"hex\");\n\t\ttempFilePath = join(tmpdir(), `pi-bash-${id}.log`);\n\t\ttempFileStream = createWriteStream(tempFilePath);\n\t\tfor (const chunk of outputChunks) {\n\t\t\ttempFileStream.write(chunk);\n\t\t}\n\t};\n\n\tconst decoder = new OutputDecoder();\n\n\tconst handleDecoded = (decoded: DecodedChunk) => {\n\t\tif (!decoded.text && !decoded.rewound) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Sanitize: strip ANSI, replace binary garbage, normalize newlines\n\t\tconst text = sanitizeBinaryOutput(stripAnsi(decoded.text)).replace(/\\r/g, \"\");\n\n\t\tif (decoded.rewound) {\n\t\t\t// The decoder switched to the system console encoding and re-decoded\n\t\t\t// the entire stream: rebuild the rolling buffer from the corrected\n\t\t\t// transcript. Chunks already streamed to onChunk cannot be recalled,\n\t\t\t// and an already-open temp file keeps its earlier mojibake prefix —\n\t\t\t// both only affect the rare case where the switch happens late.\n\t\t\toutputChunks.length = 0;\n\t\t\toutputBytes = 0;\n\t\t}\n\n\t\t// Start writing to temp file if exceeds threshold\n\t\tif (totalBytes > DEFAULT_MAX_BYTES) {\n\t\t\tensureTempFile();\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.write(text);\n\t\t}\n\n\t\t// Keep rolling buffer\n\t\toutputChunks.push(text);\n\t\toutputBytes += text.length;\n\t\twhile (outputBytes > maxOutputBytes && outputChunks.length > 1) {\n\t\t\tconst removed = outputChunks.shift()!;\n\t\t\toutputBytes -= removed.length;\n\t\t}\n\n\t\t// Stream to callback\n\t\tif (options?.onChunk) {\n\t\t\toptions.onChunk(text);\n\t\t}\n\t};\n\n\tconst onData = (data: Buffer) => {\n\t\ttotalBytes += data.length;\n\t\thandleDecoded(decoder.push(data));\n\t};\n\n\ttry {\n\t\tconst result = await operations.exec(command, cwd, {\n\t\t\tonData,\n\t\t\tsignal: options?.signal,\n\t\t});\n\t\thandleDecoded(decoder.flush());\n\n\t\tconst fullOutput = outputChunks.join(\"\");\n\t\tconst truncationResult = truncateTail(fullOutput);\n\t\tif (truncationResult.truncated) {\n\t\t\tensureTempFile();\n\t\t}\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\t\tconst cancelled = options?.signal?.aborted ?? false;\n\n\t\treturn {\n\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\texitCode: cancelled ? undefined : (result.exitCode ?? undefined),\n\t\t\tcancelled,\n\t\t\ttruncated: truncationResult.truncated,\n\t\t\tfullOutputPath: tempFilePath,\n\t\t};\n\t} catch (err) {\n\t\t// Check if it was an abort\n\t\tif (options?.signal?.aborted) {\n\t\t\thandleDecoded(decoder.flush());\n\t\t\tconst fullOutput = outputChunks.join(\"\");\n\t\t\tconst truncationResult = truncateTail(fullOutput);\n\t\t\tif (truncationResult.truncated) {\n\t\t\t\tensureTempFile();\n\t\t\t}\n\t\t\tif (tempFileStream) {\n\t\t\t\ttempFileStream.end();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\t\texitCode: undefined,\n\t\t\t\tcancelled: true,\n\t\t\t\ttruncated: truncationResult.truncated,\n\t\t\t\tfullOutputPath: tempFilePath,\n\t\t\t};\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\n\t\tthrow err;\n\t}\n}\n"]}
1
+ {"version":3,"file":"bash-executor.js","sourceRoot":"","sources":["../../src/core/bash-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA0BtE,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,OAAe,EACf,GAAW,EACX,UAA0B,EAC1B,OAA6B,EACP;IACtB,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,cAAc,GAAG,iBAAiB,GAAG,CAAC,CAAC;IAE7C,IAAI,YAAgC,CAAC;IACrC,IAAI,cAAuC,CAAC;IAC5C,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC;QAC5B,IAAI,YAAY,EAAE,CAAC;YAClB,OAAO;QACR,CAAC;QACD,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1C,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,EAA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AO,CAAC,CAAC,CAAC,UAAU;gBAC1E,QAAQ,EAAE,SAAS;gBACnB,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,gBAAgB,CAAC,SAAS;gBACrC,cAAc,EAAE,YAAY;aAC5B,CAAC;QACH,CAAC;QAED,IAAI,cAAc,EAAE,CAAC;YACpB,cAAc,CAAC,GAAG,EAAE,CAAC;QACtB,CAAC;QAED,MAAM,GAAG,CAAC;IACX,CAAC;AAAA,CACD","sourcesContent":["/**\n * Bash command execution with streaming support and cancellation.\n *\n * This module provides a unified bash execution implementation used by:\n * - AgentSession.executeBash() for interactive and RPC modes\n * - Direct calls from modes that need bash execution\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { createWriteStream, type WriteStream } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { stripAnsi } from \"../utils/ansi.ts\";\nimport { sanitizeBinaryOutput } from \"../utils/shell.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport { DEFAULT_MAX_BYTES, truncateTail } from \"./tools/truncate.ts\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface BashExecutorOptions {\n\t/** Callback for streaming output chunks (already sanitized) */\n\tonChunk?: (chunk: string) => void;\n\t/** AbortSignal for cancellation */\n\tsignal?: AbortSignal;\n}\n\nexport interface BashResult {\n\t/** Combined stdout + stderr output (sanitized, possibly truncated) */\n\toutput: string;\n\t/** Process exit code (undefined if killed/cancelled) */\n\texitCode: number | undefined;\n\t/** Whether the command was cancelled via signal */\n\tcancelled: boolean;\n\t/** Whether the output was truncated */\n\ttruncated: boolean;\n\t/** Path to temp file containing full output (if output exceeded truncation threshold) */\n\tfullOutputPath?: string;\n}\n\n// ============================================================================\n// Implementation\n// ============================================================================\n\n/**\n * Execute a bash command using custom BashOperations.\n * Used for remote execution (SSH, containers, etc.).\n */\nexport async function executeBashWithOperations(\n\tcommand: string,\n\tcwd: string,\n\toperations: BashOperations,\n\toptions?: BashExecutorOptions,\n): Promise<BashResult> {\n\tconst outputChunks: string[] = [];\n\tlet outputBytes = 0;\n\tconst maxOutputBytes = DEFAULT_MAX_BYTES * 2;\n\n\tlet tempFilePath: string | undefined;\n\tlet tempFileStream: WriteStream | undefined;\n\tlet totalBytes = 0;\n\n\tconst ensureTempFile = () => {\n\t\tif (tempFilePath) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = randomBytes(8).toString(\"hex\");\n\t\ttempFilePath = join(tmpdir(), `pi-bash-${id}.log`);\n\t\ttempFileStream = createWriteStream(tempFilePath);\n\t\tfor (const chunk of outputChunks) {\n\t\t\ttempFileStream.write(chunk);\n\t\t}\n\t};\n\n\tconst decoder = new TextDecoder();\n\n\tconst onData = (data: Buffer) => {\n\t\ttotalBytes += data.length;\n\n\t\t// Sanitize: strip ANSI, replace binary garbage, normalize newlines\n\t\tconst text = sanitizeBinaryOutput(stripAnsi(decoder.decode(data, { stream: true }))).replace(/\\r/g, \"\");\n\n\t\t// Start writing to temp file if exceeds threshold\n\t\tif (totalBytes > DEFAULT_MAX_BYTES) {\n\t\t\tensureTempFile();\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.write(text);\n\t\t}\n\n\t\t// Keep rolling buffer\n\t\toutputChunks.push(text);\n\t\toutputBytes += text.length;\n\t\twhile (outputBytes > maxOutputBytes && outputChunks.length > 1) {\n\t\t\tconst removed = outputChunks.shift()!;\n\t\t\toutputBytes -= removed.length;\n\t\t}\n\n\t\t// Stream to callback\n\t\tif (options?.onChunk) {\n\t\t\toptions.onChunk(text);\n\t\t}\n\t};\n\n\ttry {\n\t\tconst result = await operations.exec(command, cwd, {\n\t\t\tonData,\n\t\t\tsignal: options?.signal,\n\t\t});\n\n\t\tconst fullOutput = outputChunks.join(\"\");\n\t\tconst truncationResult = truncateTail(fullOutput);\n\t\tif (truncationResult.truncated) {\n\t\t\tensureTempFile();\n\t\t}\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\t\tconst cancelled = options?.signal?.aborted ?? false;\n\n\t\treturn {\n\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\texitCode: cancelled ? undefined : (result.exitCode ?? undefined),\n\t\t\tcancelled,\n\t\t\ttruncated: truncationResult.truncated,\n\t\t\tfullOutputPath: tempFilePath,\n\t\t};\n\t} catch (err) {\n\t\t// Check if it was an abort\n\t\tif (options?.signal?.aborted) {\n\t\t\tconst fullOutput = outputChunks.join(\"\");\n\t\t\tconst truncationResult = truncateTail(fullOutput);\n\t\t\tif (truncationResult.truncated) {\n\t\t\t\tensureTempFile();\n\t\t\t}\n\t\t\tif (tempFileStream) {\n\t\t\t\ttempFileStream.end();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\toutput: truncationResult.truncated ? truncationResult.content : fullOutput,\n\t\t\t\texitCode: undefined,\n\t\t\t\tcancelled: true,\n\t\t\t\ttruncated: truncationResult.truncated,\n\t\t\t\tfullOutputPath: tempFilePath,\n\t\t\t};\n\t\t}\n\n\t\tif (tempFileStream) {\n\t\t\ttempFileStream.end();\n\t\t}\n\n\t\tthrow err;\n\t}\n}\n"]}
@@ -6,7 +6,7 @@ export type { SourceInfo } from "../source-info.ts";
6
6
  export { createExtensionRuntime, discoverAndLoadExtensions, loadExtensionFromFactory, loadExtensions, } from "./loader.ts";
7
7
  export type { ExtensionErrorListener, ForkHandler, NavigateTreeHandler, NewSessionHandler, ShutdownHandler, SwitchSessionHandler, } from "./runner.ts";
8
8
  export { ExtensionRunner } from "./runner.ts";
9
- export type { AfterProviderResponseEvent, AgentEndEvent, AgentSettledEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppendEntryHandler, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BashToolResultEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderHeadersEvent, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactionTiming, CompactOptions, ContextEvent, ContextEventResult, ContextUsage, CustomToolCallEvent, CustomToolResultEvent, EditorFactory, EditToolCallEvent, EditToolResultEvent, EntryRenderer, EntryRenderOptions, ExecOptions, ExecResult, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionMode, ExtensionRuntime, ExtensionShortcut, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetOptions, FindToolCallEvent, FindToolResultEvent, GetActiveToolsHandler, GetAllToolsHandler, GetCommandsHandler, GetThinkingLevelHandler, GrepToolCallEvent, GrepToolResultEvent, InlineExtension, InputEvent, InputEventResult, InputSource, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, LsToolResultEvent, MessageEndEvent, MessageRenderer, MessageRenderOptions, MessageStartEvent, MessageUpdateEvent, ModelSelectEvent, ModelSelectSource, ProjectTrustContext, ProjectTrustEvent, ProjectTrustEventDecision, ProjectTrustEventResult, ProjectTrustHandler, ProviderConfig, ProviderModelConfig, ReadToolCallEvent, ReadToolResultEvent, RegisteredCommand, RegisteredTool, ReplacedSessionContext, ResolvedCommand, ResourcesDiscoverEvent, ResourcesDiscoverResult, SendMessageHandler, SendUserMessageHandler, SessionBeforeCompactEvent, SessionBeforeCompactResult, SessionBeforeForkEvent, SessionBeforeForkResult, SessionBeforeSwitchEvent, SessionBeforeSwitchResult, SessionBeforeTreeEvent, SessionBeforeTreeResult, SessionCompactEvent, SessionEvent, SessionInfoChangedEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SetActiveToolsHandler, SetLabelHandler, SetModelHandler, SetThinkingLevelHandler, TerminalInputHandler, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionEndEvent, ToolExecutionMode, ToolExecutionStartEvent, ToolExecutionUpdateEvent, ToolInfo, ToolRenderResultOptions, ToolResultEvent, ToolResultEventResult, TreePreparation, TurnEndEvent, TurnStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, WriteToolResultEvent, } from "./types.ts";
9
+ export type { AfterProviderResponseEvent, AgentEndEvent, AgentSettledEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppendEntryHandler, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BashToolResultEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderHeadersEvent, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactionTiming, CompactOptions, ContextEvent, ContextEventResult, ContextUsage, CustomToolCallEvent, CustomToolResultEvent, EditorFactory, EditToolCallEvent, EditToolResultEvent, EntryRenderer, EntryRenderOptions, ExecOptions, ExecResult, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionMode, ExtensionRuntime, ExtensionSelectDialogOptions, ExtensionShortcut, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetOptions, FindToolCallEvent, FindToolResultEvent, GetActiveToolsHandler, GetAllToolsHandler, GetCommandsHandler, GetThinkingLevelHandler, GrepToolCallEvent, GrepToolResultEvent, InlineExtension, InputEvent, InputEventResult, InputSource, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, LsToolResultEvent, MessageEndEvent, MessageRenderer, MessageRenderOptions, MessageStartEvent, MessageUpdateEvent, ModelSelectEvent, ModelSelectSource, ProjectTrustContext, ProjectTrustEvent, ProjectTrustEventDecision, ProjectTrustEventResult, ProjectTrustHandler, ProviderConfig, ProviderModelConfig, ReadToolCallEvent, ReadToolResultEvent, RegisteredCommand, RegisteredTool, ReplacedSessionContext, ResolvedCommand, ResourcesDiscoverEvent, ResourcesDiscoverResult, SelectOption, SendMessageHandler, SendUserMessageHandler, SessionBeforeCompactEvent, SessionBeforeCompactResult, SessionBeforeForkEvent, SessionBeforeForkResult, SessionBeforeSwitchEvent, SessionBeforeSwitchResult, SessionBeforeTreeEvent, SessionBeforeTreeResult, SessionCompactEvent, SessionEvent, SessionInfoChangedEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SetActiveToolsHandler, SetLabelHandler, SetModelHandler, SetThinkingLevelHandler, TerminalInputHandler, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionEndEvent, ToolExecutionMode, ToolExecutionStartEvent, ToolExecutionUpdateEvent, ToolInfo, ToolRenderResultOptions, ToolResultEvent, ToolResultEventResult, TreePreparation, TurnEndEvent, TurnStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, WriteToolResultEvent, } from "./types.ts";
10
10
  export { defineTool, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isStaleExtensionContextError, isToolCallEventType, isWriteToolResult, STALE_EXTENSION_CONTEXT_MESSAGE, } from "./types.ts";
11
11
  export { wrapRegisteredTool, wrapRegisteredTools } from "./wrapper.ts";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACN,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACX,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,eAAe,EAEf,eAA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,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EAEpB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EAEpB,aAAa,EACb,mBAAmB,EAEnB,cAAc,EAEd,qBAAqB,EAErB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,QAAQ,EACR,uBAAuB,EACvB,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EAEd,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,iBAAiB,EACjB,+BAA+B,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * Extension system for lifecycle events and custom tools.\n */\n\nexport type { SlashCommandInfo, SlashCommandSource } from \"../slash-commands.ts\";\nexport type { SourceInfo } from \"../source-info.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdiscoverAndLoadExtensions,\n\tloadExtensionFromFactory,\n\tloadExtensions,\n} from \"./loader.ts\";\nexport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner.ts\";\nexport { ExtensionRunner } from \"./runner.ts\";\nexport type {\n\tAfterProviderResponseEvent,\n\tAgentEndEvent,\n\tAgentSettledEvent,\n\tAgentStartEvent,\n\t// Re-exports\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppendEntryHandler,\n\t// App keybindings (for custom editors)\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\t// Events - Tool (ToolCallEvent types)\n\tBashToolCallEvent,\n\tBashToolResultEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderHeadersEvent,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\t// Context\n\tCompactionTiming,\n\tCompactOptions,\n\t// Events - Agent\n\tContextEvent,\n\t// Event Results\n\tContextEventResult,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tCustomToolResultEvent,\n\tEditorFactory,\n\tEditToolCallEvent,\n\tEditToolResultEvent,\n\t// Message and Entry Rendering\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\t// API\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\t// Errors\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionMode,\n\t// Runtime\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tFindToolResultEvent,\n\tGetActiveToolsHandler,\n\tGetAllToolsHandler,\n\tGetCommandsHandler,\n\tGetThinkingLevelHandler,\n\tGrepToolCallEvent,\n\tGrepToolResultEvent,\n\tInlineExtension,\n\t// Events - Input\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tLsToolResultEvent,\n\t// Events - Message\n\tMessageEndEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tModelSelectEvent,\n\tModelSelectSource,\n\tProjectTrustContext,\n\tProjectTrustEvent,\n\tProjectTrustEventDecision,\n\tProjectTrustEventResult,\n\tProjectTrustHandler,\n\t// Provider Registration\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tReadToolResultEvent,\n\t// Commands\n\tRegisteredCommand,\n\tRegisteredTool,\n\tReplacedSessionContext,\n\tResolvedCommand,\n\t// Events - Resources\n\tResourcesDiscoverEvent,\n\tResourcesDiscoverResult,\n\tSendMessageHandler,\n\tSendUserMessageHandler,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeCompactResult,\n\tSessionBeforeForkEvent,\n\tSessionBeforeForkResult,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeSwitchResult,\n\tSessionBeforeTreeEvent,\n\tSessionBeforeTreeResult,\n\tSessionCompactEvent,\n\tSessionEvent,\n\tSessionInfoChangedEvent,\n\tSessionShutdownEvent,\n\t// Events - Session\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSetActiveToolsHandler,\n\tSetLabelHandler,\n\tSetModelHandler,\n\tSetThinkingLevelHandler,\n\tTerminalInputHandler,\n\t// Events - Tool\n\tToolCallEvent,\n\tToolCallEventResult,\n\t// Tools\n\tToolDefinition,\n\t// Events - Tool Execution\n\tToolExecutionEndEvent,\n\t// Tool execution mode\n\tToolExecutionMode,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tToolResultEventResult,\n\tTreePreparation,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\t// Events - User Bash\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n\tWriteToolResultEvent,\n} from \"./types.ts\";\n// Type guards\nexport {\n\tdefineTool,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisStaleExtensionContextError,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\tSTALE_EXTENSION_CONTEXT_MESSAGE,\n} from \"./types.ts\";\nexport { wrapRegisteredTool, wrapRegisteredTools } from \"./wrapper.ts\";\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACN,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACX,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,eAAe,EAEf,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAElB,aAAa,EACb,2BAA2B,EAE3B,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,gCAAgC,EAChC,wBAAwB,EAExB,gBAAgB,EAChB,cAAc,EAEd,YAAY,EAEZ,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EAEnB,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAEhB,YAAY,EACZ,uBAAuB,EACvB,8BAA8B,EAC9B,gBAAgB,EAChB,uBAAuB,EAEvB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,aAAa,EAEb,gBAAgB,EAChB,4BAA4B,EAC5B,iBAAiB,EACjB,kBAAkB,EAClB,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,EACd,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,iBAAiB,EACjB,+BAA+B,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * Extension system for lifecycle events and custom tools.\n */\n\nexport type { SlashCommandInfo, SlashCommandSource } from \"../slash-commands.ts\";\nexport type { SourceInfo } from \"../source-info.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdiscoverAndLoadExtensions,\n\tloadExtensionFromFactory,\n\tloadExtensions,\n} from \"./loader.ts\";\nexport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner.ts\";\nexport { ExtensionRunner } from \"./runner.ts\";\nexport type {\n\tAfterProviderResponseEvent,\n\tAgentEndEvent,\n\tAgentSettledEvent,\n\tAgentStartEvent,\n\t// Re-exports\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppendEntryHandler,\n\t// App keybindings (for custom editors)\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\t// Events - Tool (ToolCallEvent types)\n\tBashToolCallEvent,\n\tBashToolResultEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderHeadersEvent,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\t// Context\n\tCompactionTiming,\n\tCompactOptions,\n\t// Events - Agent\n\tContextEvent,\n\t// Event Results\n\tContextEventResult,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tCustomToolResultEvent,\n\tEditorFactory,\n\tEditToolCallEvent,\n\tEditToolResultEvent,\n\t// Message and Entry Rendering\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\t// API\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\t// Errors\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionMode,\n\t// Runtime\n\tExtensionRuntime,\n\tExtensionSelectDialogOptions,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tFindToolResultEvent,\n\tGetActiveToolsHandler,\n\tGetAllToolsHandler,\n\tGetCommandsHandler,\n\tGetThinkingLevelHandler,\n\tGrepToolCallEvent,\n\tGrepToolResultEvent,\n\tInlineExtension,\n\t// Events - Input\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tLsToolResultEvent,\n\t// Events - Message\n\tMessageEndEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tModelSelectEvent,\n\tModelSelectSource,\n\tProjectTrustContext,\n\tProjectTrustEvent,\n\tProjectTrustEventDecision,\n\tProjectTrustEventResult,\n\tProjectTrustHandler,\n\t// Provider Registration\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tReadToolResultEvent,\n\t// Commands\n\tRegisteredCommand,\n\tRegisteredTool,\n\tReplacedSessionContext,\n\tResolvedCommand,\n\t// Events - Resources\n\tResourcesDiscoverEvent,\n\tResourcesDiscoverResult,\n\tSelectOption,\n\tSendMessageHandler,\n\tSendUserMessageHandler,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeCompactResult,\n\tSessionBeforeForkEvent,\n\tSessionBeforeForkResult,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeSwitchResult,\n\tSessionBeforeTreeEvent,\n\tSessionBeforeTreeResult,\n\tSessionCompactEvent,\n\tSessionEvent,\n\tSessionInfoChangedEvent,\n\tSessionShutdownEvent,\n\t// Events - Session\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSetActiveToolsHandler,\n\tSetLabelHandler,\n\tSetModelHandler,\n\tSetThinkingLevelHandler,\n\tTerminalInputHandler,\n\t// Events - Tool\n\tToolCallEvent,\n\tToolCallEventResult,\n\t// Tools\n\tToolDefinition,\n\t// Events - Tool Execution\n\tToolExecutionEndEvent,\n\t// Tool execution mode\n\tToolExecutionMode,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tToolResultEventResult,\n\tTreePreparation,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\t// Events - User Bash\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n\tWriteToolResultEvent,\n} from \"./types.ts\";\n// Type guards\nexport {\n\tdefineTool,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisStaleExtensionContextError,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\tSTALE_EXTENSION_CONTEXT_MESSAGE,\n} from \"./types.ts\";\nexport { wrapRegisteredTool, wrapRegisteredTools } from \"./wrapper.ts\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/extensions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACN,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACd,MAAM,aAAa,CAAC;AASrB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwJ9C,cAAc;AACd,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,iBAAiB,EACjB,+BAA+B,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * Extension system for lifecycle events and custom tools.\n */\n\nexport type { SlashCommandInfo, SlashCommandSource } from \"../slash-commands.ts\";\nexport type { SourceInfo } from \"../source-info.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdiscoverAndLoadExtensions,\n\tloadExtensionFromFactory,\n\tloadExtensions,\n} from \"./loader.ts\";\nexport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner.ts\";\nexport { ExtensionRunner } from \"./runner.ts\";\nexport type {\n\tAfterProviderResponseEvent,\n\tAgentEndEvent,\n\tAgentSettledEvent,\n\tAgentStartEvent,\n\t// Re-exports\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppendEntryHandler,\n\t// App keybindings (for custom editors)\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\t// Events - Tool (ToolCallEvent types)\n\tBashToolCallEvent,\n\tBashToolResultEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderHeadersEvent,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\t// Context\n\tCompactionTiming,\n\tCompactOptions,\n\t// Events - Agent\n\tContextEvent,\n\t// Event Results\n\tContextEventResult,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tCustomToolResultEvent,\n\tEditorFactory,\n\tEditToolCallEvent,\n\tEditToolResultEvent,\n\t// Message and Entry Rendering\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\t// API\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\t// Errors\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionMode,\n\t// Runtime\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tFindToolResultEvent,\n\tGetActiveToolsHandler,\n\tGetAllToolsHandler,\n\tGetCommandsHandler,\n\tGetThinkingLevelHandler,\n\tGrepToolCallEvent,\n\tGrepToolResultEvent,\n\tInlineExtension,\n\t// Events - Input\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tLsToolResultEvent,\n\t// Events - Message\n\tMessageEndEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tModelSelectEvent,\n\tModelSelectSource,\n\tProjectTrustContext,\n\tProjectTrustEvent,\n\tProjectTrustEventDecision,\n\tProjectTrustEventResult,\n\tProjectTrustHandler,\n\t// Provider Registration\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tReadToolResultEvent,\n\t// Commands\n\tRegisteredCommand,\n\tRegisteredTool,\n\tReplacedSessionContext,\n\tResolvedCommand,\n\t// Events - Resources\n\tResourcesDiscoverEvent,\n\tResourcesDiscoverResult,\n\tSendMessageHandler,\n\tSendUserMessageHandler,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeCompactResult,\n\tSessionBeforeForkEvent,\n\tSessionBeforeForkResult,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeSwitchResult,\n\tSessionBeforeTreeEvent,\n\tSessionBeforeTreeResult,\n\tSessionCompactEvent,\n\tSessionEvent,\n\tSessionInfoChangedEvent,\n\tSessionShutdownEvent,\n\t// Events - Session\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSetActiveToolsHandler,\n\tSetLabelHandler,\n\tSetModelHandler,\n\tSetThinkingLevelHandler,\n\tTerminalInputHandler,\n\t// Events - Tool\n\tToolCallEvent,\n\tToolCallEventResult,\n\t// Tools\n\tToolDefinition,\n\t// Events - Tool Execution\n\tToolExecutionEndEvent,\n\t// Tool execution mode\n\tToolExecutionMode,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tToolResultEventResult,\n\tTreePreparation,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\t// Events - User Bash\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n\tWriteToolResultEvent,\n} from \"./types.ts\";\n// Type guards\nexport {\n\tdefineTool,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisStaleExtensionContextError,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\tSTALE_EXTENSION_CONTEXT_MESSAGE,\n} from \"./types.ts\";\nexport { wrapRegisteredTool, wrapRegisteredTools } from \"./wrapper.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/extensions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACN,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACd,MAAM,aAAa,CAAC;AASrB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA0J9C,cAAc;AACd,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,iBAAiB,EACjB,+BAA+B,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * Extension system for lifecycle events and custom tools.\n */\n\nexport type { SlashCommandInfo, SlashCommandSource } from \"../slash-commands.ts\";\nexport type { SourceInfo } from \"../source-info.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdiscoverAndLoadExtensions,\n\tloadExtensionFromFactory,\n\tloadExtensions,\n} from \"./loader.ts\";\nexport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner.ts\";\nexport { ExtensionRunner } from \"./runner.ts\";\nexport type {\n\tAfterProviderResponseEvent,\n\tAgentEndEvent,\n\tAgentSettledEvent,\n\tAgentStartEvent,\n\t// Re-exports\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppendEntryHandler,\n\t// App keybindings (for custom editors)\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\t// Events - Tool (ToolCallEvent types)\n\tBashToolCallEvent,\n\tBashToolResultEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderHeadersEvent,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\t// Context\n\tCompactionTiming,\n\tCompactOptions,\n\t// Events - Agent\n\tContextEvent,\n\t// Event Results\n\tContextEventResult,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tCustomToolResultEvent,\n\tEditorFactory,\n\tEditToolCallEvent,\n\tEditToolResultEvent,\n\t// Message and Entry Rendering\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\t// API\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\t// Errors\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionMode,\n\t// Runtime\n\tExtensionRuntime,\n\tExtensionSelectDialogOptions,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tFindToolResultEvent,\n\tGetActiveToolsHandler,\n\tGetAllToolsHandler,\n\tGetCommandsHandler,\n\tGetThinkingLevelHandler,\n\tGrepToolCallEvent,\n\tGrepToolResultEvent,\n\tInlineExtension,\n\t// Events - Input\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tLsToolResultEvent,\n\t// Events - Message\n\tMessageEndEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tModelSelectEvent,\n\tModelSelectSource,\n\tProjectTrustContext,\n\tProjectTrustEvent,\n\tProjectTrustEventDecision,\n\tProjectTrustEventResult,\n\tProjectTrustHandler,\n\t// Provider Registration\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tReadToolResultEvent,\n\t// Commands\n\tRegisteredCommand,\n\tRegisteredTool,\n\tReplacedSessionContext,\n\tResolvedCommand,\n\t// Events - Resources\n\tResourcesDiscoverEvent,\n\tResourcesDiscoverResult,\n\tSelectOption,\n\tSendMessageHandler,\n\tSendUserMessageHandler,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeCompactResult,\n\tSessionBeforeForkEvent,\n\tSessionBeforeForkResult,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeSwitchResult,\n\tSessionBeforeTreeEvent,\n\tSessionBeforeTreeResult,\n\tSessionCompactEvent,\n\tSessionEvent,\n\tSessionInfoChangedEvent,\n\tSessionShutdownEvent,\n\t// Events - Session\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSetActiveToolsHandler,\n\tSetLabelHandler,\n\tSetModelHandler,\n\tSetThinkingLevelHandler,\n\tTerminalInputHandler,\n\t// Events - Tool\n\tToolCallEvent,\n\tToolCallEventResult,\n\t// Tools\n\tToolDefinition,\n\t// Events - Tool Execution\n\tToolExecutionEndEvent,\n\t// Tool execution mode\n\tToolExecutionMode,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tToolResultEventResult,\n\tTreePreparation,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\t// Events - User Bash\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n\tWriteToolResultEvent,\n} from \"./types.ts\";\n// Type guards\nexport {\n\tdefineTool,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisStaleExtensionContextError,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\tSTALE_EXTENSION_CONTEXT_MESSAGE,\n} from \"./types.ts\";\nexport { wrapRegisteredTool, wrapRegisteredTools } from \"./wrapper.ts\";\n"]}
@@ -38,6 +38,27 @@ export interface ExtensionUIDialogOptions {
38
38
  /** Timeout in milliseconds. Dialog auto-dismisses with live countdown display. */
39
39
  timeout?: number;
40
40
  }
41
+ /**
42
+ * One choice in a select dialog. A bare string is shorthand for `{ label }`;
43
+ * the object form adds a muted description line beneath the label, so the
44
+ * action and its rationale can be scanned separately.
45
+ */
46
+ export interface SelectOption {
47
+ /** The choice itself. This is what select() resolves to. */
48
+ label: string;
49
+ /** Muted second line explaining the choice. */
50
+ description?: string;
51
+ }
52
+ /** Options accepted by select dialogs. */
53
+ export interface ExtensionSelectDialogOptions extends ExtensionUIDialogOptions {
54
+ /** Muted line under the title, for context that is not itself a choice. */
55
+ subtitle?: string;
56
+ /**
57
+ * Wording for the dismiss key hint. Defaults to "cancel"; override when
58
+ * dismissing is not destructive so the hint matches what Esc actually does.
59
+ */
60
+ cancelHint?: string;
61
+ }
41
62
  /** Placement for extension widgets. */
42
63
  export type WidgetPlacement = "aboveEditor" | "belowEditor";
43
64
  /** Options for extension widgets. */
@@ -65,8 +86,8 @@ export type EditorFactory = (tui: TUI, theme: EditorTheme, keybindings: Keybindi
65
86
  * Each mode (interactive, RPC, print) provides its own implementation.
66
87
  */
67
88
  export interface ExtensionUIContext {
68
- /** Show a selector and return the user's choice. */
69
- select(title: string, options: string[], opts?: ExtensionUIDialogOptions): Promise<string | undefined>;
89
+ /** Show a selector and return the label of the user's choice. */
90
+ select(title: string, options: ReadonlyArray<string | SelectOption>, opts?: ExtensionSelectDialogOptions): Promise<string | undefined>;
70
91
  /** Show a confirmation dialog. */
71
92
  confirm(title: string, message: string, opts?: ExtensionUIDialogOptions): Promise<boolean>;
72
93
  /** Show a text input dialog. */
@@ -305,7 +326,7 @@ export interface ToolRenderResultOptions {
305
326
  isPartial: boolean;
306
327
  }
307
328
  /** Context passed to tool renderers. */
308
- export interface ToolRenderContext<TState = any, TArgs = any> {
329
+ export interface ToolRenderContext<TState = any, TArgs = any, TDetails = unknown> {
309
330
  /** Current tool call arguments. Shared across call/result renders for the same tool call. */
310
331
  args: TArgs;
311
332
  /** Unique id for this tool execution. Stable across call/result renders for the same tool call. */
@@ -330,6 +351,8 @@ export interface ToolRenderContext<TState = any, TArgs = any> {
330
351
  showImages: boolean;
331
352
  /** Whether the current result is an error. */
332
353
  isError: boolean;
354
+ /** Current final or partial result, when one has been received. Error state remains available through isError. */
355
+ result?: AgentToolResult<TDetails>;
333
356
  /** True when renderCall is producing a collapsed grouped-tool summary. */
334
357
  toolGroupSummary?: boolean;
335
358
  }
@@ -368,9 +391,9 @@ export interface ToolDefinition<TParams extends TSchema = TSchema, TDetails = un
368
391
  /** Execute the tool. */
369
392
  execute(toolCallId: string, params: Static<TParams>, signal: AbortSignal | undefined, onUpdate: AgentToolUpdateCallback<TDetails> | undefined, ctx: ExtensionContext): Promise<AgentToolResult<TDetails>>;
370
393
  /** Custom rendering for tool call display */
371
- renderCall?: (args: Static<TParams>, theme: Theme, context: ToolRenderContext<TState, Static<TParams>>) => Component;
394
+ renderCall?: (args: Static<TParams>, theme: Theme, context: ToolRenderContext<TState, Static<TParams>, TDetails>) => Component;
372
395
  /** Custom rendering for tool result display */
373
- renderResult?: (result: AgentToolResult<TDetails>, options: ToolRenderResultOptions, theme: Theme, context: ToolRenderContext<TState, Static<TParams>>) => Component;
396
+ renderResult?: (result: AgentToolResult<TDetails>, options: ToolRenderResultOptions, theme: Theme, context: ToolRenderContext<TState, Static<TParams>, TDetails>) => Component;
374
397
  }
375
398
  type AnyToolDefinition = ToolDefinition<any, any, any>;
376
399
  /**