@oh-my-pi/pi-coding-agent 15.10.11 → 15.11.0

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 (217) hide show
  1. package/CHANGELOG.md +103 -2
  2. package/dist/cli.js +5790 -5731
  3. package/dist/types/async/index.d.ts +0 -1
  4. package/dist/types/cli/args.d.ts +1 -0
  5. package/dist/types/cli/gallery-fixtures/types.d.ts +5 -0
  6. package/dist/types/cli-commands.d.ts +12 -0
  7. package/dist/types/commands/launch.d.ts +4 -0
  8. package/dist/types/config/api-key-resolver.d.ts +3 -0
  9. package/dist/types/config/keybindings.d.ts +6 -1
  10. package/dist/types/config/model-registry.d.ts +1 -0
  11. package/dist/types/config/model-resolver.d.ts +18 -0
  12. package/dist/types/config/settings-schema.d.ts +85 -34
  13. package/dist/types/config/settings.d.ts +7 -0
  14. package/dist/types/edit/hashline/noop-loop-guard.d.ts +72 -0
  15. package/dist/types/eval/py/executor.d.ts +5 -0
  16. package/dist/types/eval/py/kernel.d.ts +6 -1
  17. package/dist/types/eval/py/runtime.d.ts +9 -0
  18. package/dist/types/exec/bash-executor.d.ts +2 -0
  19. package/dist/types/export/html/template.generated.d.ts +1 -1
  20. package/dist/types/extensibility/custom-tools/types.d.ts +2 -2
  21. package/dist/types/extensibility/extensions/runner.d.ts +3 -2
  22. package/dist/types/extensibility/extensions/types.d.ts +3 -0
  23. package/dist/types/extensibility/shared-events.d.ts +2 -2
  24. package/dist/types/internal-urls/history-protocol.d.ts +14 -0
  25. package/dist/types/internal-urls/index.d.ts +1 -0
  26. package/dist/types/internal-urls/types.d.ts +1 -1
  27. package/dist/types/irc/bus.d.ts +66 -0
  28. package/dist/types/memory-backend/index.d.ts +1 -0
  29. package/dist/types/memory-backend/runtime.d.ts +4 -0
  30. package/dist/types/memory-backend/types.d.ts +66 -1
  31. package/dist/types/modes/components/agent-hub.d.ts +30 -0
  32. package/dist/types/modes/components/compaction-summary-message.d.ts +10 -4
  33. package/dist/types/modes/components/custom-editor.d.ts +2 -0
  34. package/dist/types/modes/components/tool-execution.d.ts +8 -0
  35. package/dist/types/modes/components/ttsr-notification.d.ts +5 -1
  36. package/dist/types/modes/components/welcome.d.ts +3 -9
  37. package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
  38. package/dist/types/modes/index.d.ts +3 -3
  39. package/dist/types/modes/interactive-mode.d.ts +10 -4
  40. package/dist/types/modes/oauth-manual-input.d.ts +7 -0
  41. package/dist/types/modes/rpc/rpc-client.d.ts +39 -2
  42. package/dist/types/modes/rpc/rpc-mode.d.ts +31 -2
  43. package/dist/types/modes/rpc/rpc-subagents.d.ts +24 -0
  44. package/dist/types/modes/rpc/rpc-types.d.ts +75 -1
  45. package/dist/types/modes/setup-wizard/index.d.ts +5 -1
  46. package/dist/types/modes/setup-wizard/lazy.d.ts +2 -0
  47. package/dist/types/modes/theme/theme.d.ts +2 -1
  48. package/dist/types/modes/types.d.ts +5 -2
  49. package/dist/types/modes/utils/ui-helpers.d.ts +1 -1
  50. package/dist/types/registry/agent-lifecycle.d.ts +51 -0
  51. package/dist/types/registry/agent-registry.d.ts +16 -5
  52. package/dist/types/secrets/index.d.ts +1 -1
  53. package/dist/types/secrets/obfuscator.d.ts +8 -2
  54. package/dist/types/session/agent-session.d.ts +49 -32
  55. package/dist/types/session/messages.d.ts +2 -4
  56. package/dist/types/session/session-history-format.d.ts +12 -0
  57. package/dist/types/session/session-manager.d.ts +21 -3
  58. package/dist/types/session/streaming-output.d.ts +46 -0
  59. package/dist/types/slash-commands/acp-builtins.d.ts +16 -0
  60. package/dist/types/slash-commands/builtin-registry.d.ts +1 -0
  61. package/dist/types/slash-commands/types.d.ts +1 -1
  62. package/dist/types/system-prompt.d.ts +2 -0
  63. package/dist/types/task/executor.d.ts +12 -2
  64. package/dist/types/task/index.d.ts +13 -6
  65. package/dist/types/task/output-manager.d.ts +0 -7
  66. package/dist/types/task/repair-args.d.ts +8 -7
  67. package/dist/types/task/types.d.ts +63 -51
  68. package/dist/types/thinking.d.ts +4 -0
  69. package/dist/types/tiny/title-client.d.ts +11 -0
  70. package/dist/types/tiny/title-protocol.d.ts +1 -0
  71. package/dist/types/tools/browser/tab-worker.d.ts +3 -1
  72. package/dist/types/tools/find.d.ts +0 -11
  73. package/dist/types/tools/grouped-file-output.d.ts +0 -49
  74. package/dist/types/tools/index.d.ts +7 -3
  75. package/dist/types/tools/irc.d.ts +76 -38
  76. package/dist/types/tools/job.d.ts +7 -1
  77. package/dist/types/utils/git.d.ts +15 -2
  78. package/dist/types/utils/title-generator.d.ts +3 -2
  79. package/examples/extensions/with-deps/package.json +1 -0
  80. package/package.json +11 -10
  81. package/scripts/bundle-dist.ts +28 -19
  82. package/src/async/index.ts +0 -1
  83. package/src/auto-thinking/classifier.ts +1 -0
  84. package/src/cli/args.ts +3 -0
  85. package/src/cli/gallery-cli.ts +1 -1
  86. package/src/cli/gallery-fixtures/agentic.ts +230 -115
  87. package/src/cli/gallery-fixtures/types.ts +5 -0
  88. package/src/cli-commands.ts +29 -0
  89. package/src/cli.ts +28 -15
  90. package/src/commands/launch.ts +4 -0
  91. package/src/commit/agentic/tools/analyze-file.ts +38 -19
  92. package/src/commit/model-selection.ts +3 -2
  93. package/src/config/api-key-resolver.ts +8 -6
  94. package/src/config/keybindings.ts +6 -1
  95. package/src/config/model-registry.ts +97 -30
  96. package/src/config/model-resolver.ts +60 -0
  97. package/src/config/settings-schema.ts +99 -55
  98. package/src/config/settings.ts +68 -3
  99. package/src/edit/hashline/execute.ts +39 -2
  100. package/src/edit/hashline/noop-loop-guard.ts +99 -0
  101. package/src/eval/__tests__/agent-bridge.test.ts +5 -3
  102. package/src/eval/agent-bridge.ts +3 -16
  103. package/src/eval/completion-bridge.ts +1 -0
  104. package/src/eval/js/shared/prelude.txt +1 -1
  105. package/src/eval/py/executor.ts +29 -7
  106. package/src/eval/py/index.ts +6 -1
  107. package/src/eval/py/kernel.ts +31 -11
  108. package/src/eval/py/prelude.py +5 -6
  109. package/src/eval/py/runtime.ts +37 -0
  110. package/src/exec/bash-executor.ts +82 -3
  111. package/src/export/html/template.generated.ts +1 -1
  112. package/src/export/html/template.js +38 -13
  113. package/src/extensibility/custom-tools/types.ts +2 -2
  114. package/src/extensibility/extensions/get-commands-handler.ts +2 -1
  115. package/src/extensibility/extensions/runner.ts +6 -1
  116. package/src/extensibility/extensions/types.ts +3 -0
  117. package/src/extensibility/shared-events.ts +2 -2
  118. package/src/hindsight/bank.ts +17 -2
  119. package/src/internal-urls/docs-index.generated.ts +11 -11
  120. package/src/internal-urls/history-protocol.ts +113 -0
  121. package/src/internal-urls/index.ts +1 -0
  122. package/src/internal-urls/router.ts +3 -1
  123. package/src/internal-urls/types.ts +1 -1
  124. package/src/irc/bus.ts +292 -0
  125. package/src/main.ts +26 -66
  126. package/src/memories/index.ts +2 -0
  127. package/src/memory-backend/index.ts +1 -0
  128. package/src/memory-backend/local-backend.ts +9 -0
  129. package/src/memory-backend/off-backend.ts +9 -0
  130. package/src/memory-backend/runtime.ts +66 -0
  131. package/src/memory-backend/types.ts +81 -1
  132. package/src/mnemopi/backend.ts +151 -4
  133. package/src/modes/acp/acp-agent.ts +119 -11
  134. package/src/modes/components/{session-observer-overlay.ts → agent-hub.ts} +586 -367
  135. package/src/modes/components/assistant-message.ts +19 -21
  136. package/src/modes/components/compaction-summary-message.ts +68 -32
  137. package/src/modes/components/custom-editor.ts +10 -0
  138. package/src/modes/components/footer.ts +3 -1
  139. package/src/modes/components/status-line/component.ts +118 -34
  140. package/src/modes/components/tool-execution.ts +31 -1
  141. package/src/modes/components/ttsr-notification.ts +72 -30
  142. package/src/modes/components/welcome.ts +9 -33
  143. package/src/modes/controllers/command-controller.ts +1 -1
  144. package/src/modes/controllers/event-controller.ts +65 -0
  145. package/src/modes/controllers/extension-ui-controller.ts +8 -8
  146. package/src/modes/controllers/input-controller.ts +19 -2
  147. package/src/modes/controllers/mcp-command-controller.ts +38 -3
  148. package/src/modes/controllers/selector-controller.ts +21 -17
  149. package/src/modes/index.ts +3 -21
  150. package/src/modes/interactive-mode.ts +47 -22
  151. package/src/modes/oauth-manual-input.ts +30 -3
  152. package/src/modes/rpc/rpc-client.ts +154 -3
  153. package/src/modes/rpc/rpc-mode.ts +97 -12
  154. package/src/modes/rpc/rpc-subagents.ts +265 -0
  155. package/src/modes/rpc/rpc-types.ts +81 -1
  156. package/src/modes/setup-wizard/index.ts +12 -2
  157. package/src/modes/setup-wizard/lazy.ts +16 -0
  158. package/src/modes/theme/theme.ts +18 -5
  159. package/src/modes/types.ts +5 -5
  160. package/src/modes/utils/hotkeys-markdown.ts +1 -0
  161. package/src/modes/utils/ui-helpers.ts +51 -49
  162. package/src/prompts/system/irc-incoming.md +3 -4
  163. package/src/prompts/system/orchestrate-notice.md +2 -2
  164. package/src/prompts/system/subagent-system-prompt.md +0 -5
  165. package/src/prompts/system/system-prompt.md +1 -0
  166. package/src/prompts/system/workflow-notice.md +2 -2
  167. package/src/prompts/tools/eval.md +3 -3
  168. package/src/prompts/tools/irc.md +29 -19
  169. package/src/prompts/tools/read.md +2 -2
  170. package/src/prompts/tools/task-summary.md +5 -16
  171. package/src/prompts/tools/task.md +38 -29
  172. package/src/registry/agent-lifecycle.ts +218 -0
  173. package/src/registry/agent-registry.ts +16 -5
  174. package/src/sdk.ts +37 -10
  175. package/src/secrets/index.ts +8 -1
  176. package/src/secrets/obfuscator.ts +39 -18
  177. package/src/session/agent-session.ts +422 -291
  178. package/src/session/messages.ts +11 -78
  179. package/src/session/session-history-format.ts +246 -0
  180. package/src/session/session-manager.ts +59 -5
  181. package/src/session/streaming-output.ts +226 -10
  182. package/src/slash-commands/acp-builtins.ts +24 -0
  183. package/src/slash-commands/builtin-registry.ts +20 -0
  184. package/src/slash-commands/types.ts +1 -1
  185. package/src/system-prompt.ts +14 -0
  186. package/src/task/executor.ts +851 -461
  187. package/src/task/index.ts +721 -796
  188. package/src/task/output-manager.ts +0 -11
  189. package/src/task/render.ts +148 -63
  190. package/src/task/repair-args.ts +21 -9
  191. package/src/task/types.ts +82 -66
  192. package/src/thinking.ts +7 -0
  193. package/src/tiny/title-client.ts +34 -5
  194. package/src/tiny/title-protocol.ts +1 -1
  195. package/src/tiny/worker.ts +6 -4
  196. package/src/tools/ask.ts +4 -2
  197. package/src/tools/bash.ts +61 -10
  198. package/src/tools/browser/tab-worker.ts +26 -7
  199. package/src/tools/browser.ts +28 -1
  200. package/src/tools/find.ts +2 -27
  201. package/src/tools/grouped-file-output.ts +1 -118
  202. package/src/tools/image-gen.ts +11 -4
  203. package/src/tools/index.ts +17 -13
  204. package/src/tools/inspect-image.ts +1 -0
  205. package/src/tools/irc.ts +596 -171
  206. package/src/tools/job.ts +41 -7
  207. package/src/tools/read.ts +57 -1
  208. package/src/tools/renderers.ts +2 -0
  209. package/src/tools/resolve.ts +4 -1
  210. package/src/utils/commit-message-generator.ts +1 -0
  211. package/src/utils/git.ts +267 -13
  212. package/src/utils/title-generator.ts +24 -5
  213. package/dist/types/async/support.d.ts +0 -2
  214. package/dist/types/modes/components/session-observer-overlay.d.ts +0 -11
  215. package/dist/types/task/simple-mode.d.ts +0 -8
  216. package/src/async/support.ts +0 -5
  217. package/src/task/simple-mode.ts +0 -27
@@ -2,6 +2,15 @@ import type { AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
2
2
  export declare const DEFAULT_MAX_LINES = 3000;
3
3
  export declare const DEFAULT_MAX_BYTES: number;
4
4
  export declare const DEFAULT_MAX_COLUMN = 512;
5
+ /**
6
+ * Default artifact-on-disk cap for {@link OutputSink}.
7
+ *
8
+ * `0` means unbounded: by default, `artifact://<id>` references preserve the
9
+ * complete raw stream instead of a capped head/tail sample.
10
+ */
11
+ export declare const ARTIFACT_DEFAULT_MAX_BYTES = 0;
12
+ /** Default head budget; the remainder becomes the rolling tail window. */
13
+ export declare const ARTIFACT_DEFAULT_HEAD_BYTES: number;
5
14
  export interface OutputSummary {
6
15
  output: string;
7
16
  truncated: boolean;
@@ -41,6 +50,20 @@ export interface OutputSinkOptions {
41
50
  onChunk?: (chunk: string) => void;
42
51
  /** Minimum ms between onChunk calls. 0 = every chunk (default). */
43
52
  chunkThrottleMs?: number;
53
+ /**
54
+ * Optional cap on bytes written to the artifact-on-disk file. When the cap
55
+ * is hit, the head window is preserved verbatim and subsequent output feeds
56
+ * a rolling tail window; on close, the sink writes a single
57
+ * `[ARTIFACT TRUNCATED: …]` notice between them. Default
58
+ * {@link ARTIFACT_DEFAULT_MAX_BYTES} (unbounded).
59
+ */
60
+ artifactMaxBytes?: number;
61
+ /**
62
+ * Bytes reserved for the head window of the capped artifact file. The
63
+ * tail window receives `artifactMaxBytes - artifactHeadBytes`. Default
64
+ * {@link ARTIFACT_DEFAULT_HEAD_BYTES}; clamped to `[0, artifactMaxBytes]`.
65
+ */
66
+ artifactHeadBytes?: number;
44
67
  }
45
68
  export interface TruncationResult {
46
69
  content: string;
@@ -136,6 +159,29 @@ export declare function formatMiddleElisionMarker(elidedLines: number, elidedByt
136
159
  * budget is empty or the content already fits.
137
160
  */
138
161
  export declare function truncateMiddle(content: string, options?: TruncationOptions): TruncationResult;
162
+ /** Options for {@link enforceInlineByteCap}. */
163
+ export interface InlineByteCapOptions {
164
+ /** Inline byte budget. Defaults to {@link DEFAULT_MAX_BYTES}. */
165
+ maxBytes?: number;
166
+ /** What the text is, for the elision marker (e.g. "bash output"). */
167
+ label: string;
168
+ /**
169
+ * Persist the full text as a session artifact. When an artifact id is
170
+ * returned, a `[raw output: artifact://<id>]` footer is appended so the
171
+ * elided bytes stay recoverable.
172
+ */
173
+ saveArtifact?: (full: string) => string | undefined | Promise<string | undefined>;
174
+ }
175
+ /**
176
+ * Final-defense inline size guard for tool results.
177
+ *
178
+ * No-op when `text` fits within `maxBytes` (the common path). Otherwise keeps
179
+ * ~60% of the budget from the head and ~25% from the tail — cut on line
180
+ * boundaries, never splitting a multi-byte UTF-8 sequence — with an elision
181
+ * marker between. The remaining ~15% is slack for the marker and the optional
182
+ * `[raw output: artifact://<id>]` footer, so the result stays under `maxBytes`.
183
+ */
184
+ export declare function enforceInlineByteCap(text: string, options: InlineByteCapOptions): Promise<string>;
139
185
  export declare class TailBuffer {
140
186
  #private;
141
187
  readonly maxBytes: number;
@@ -1,6 +1,22 @@
1
1
  import type { AvailableCommand } from "@agentclientprotocol/sdk";
2
2
  import type { AcpBuiltinSlashCommandResult, SlashCommandRuntime } from "./types";
3
3
  export type { AcpBuiltinSlashCommandResult } from "./types";
4
+ /**
5
+ * All names (primary + aliases) that are reserved by ACP builtins. Used to
6
+ * filter out extension commands that would shadow a builtin or its alias at
7
+ * dispatch time (e.g. `models` is an alias for `/model`, so an extension
8
+ * registering `models` would appear in the palette but execute the builtin).
9
+ */
10
+ export declare const ACP_BUILTIN_RESERVED_NAMES: ReadonlySet<string>;
11
+ /**
12
+ * Whether an extension command named `name` would be captured by ACP builtin
13
+ * dispatch before reaching the extension handler. Beyond exact name/alias
14
+ * collisions, `parseSlashCommand` treats `:` as a name/args separator, so a
15
+ * colon-namespaced name whose prefix is a handled builtin (e.g. `model:foo`)
16
+ * executes the `/model` builtin with `foo` as args. Such names must not be
17
+ * advertised to ACP clients.
18
+ */
19
+ export declare function isAcpBuiltinShadowedName(name: string): boolean;
4
20
  /**
5
21
  * Commands advertised to ACP clients. Entries without a text-mode `handle`
6
22
  * (e.g. `/quit`, `/login`, dashboards) are filtered out so the client doesn't
@@ -2,6 +2,7 @@ import type { BuiltinSlashCommand, ParsedSlashCommand, SlashCommandResult, Slash
2
2
  export type { BuiltinSlashCommand, SubcommandDef } from "./types";
3
3
  /** TUI-specific runtime accepted by `executeBuiltinSlashCommand`. */
4
4
  export type BuiltinSlashCommandRuntime = TuiSlashCommandRuntime;
5
+ export declare const BUILTIN_SLASH_COMMAND_RESERVED_NAMES: ReadonlySet<string>;
5
6
  /** Builtin command metadata used for slash-command autocomplete and help text. */
6
7
  export declare const BUILTIN_SLASH_COMMAND_DEFS: ReadonlyArray<BuiltinSlashCommand>;
7
8
  /**
@@ -12,6 +12,7 @@ export interface SubcommandDef {
12
12
  /** Declarative builtin slash command metadata used by autocomplete and help UI. */
13
13
  export interface BuiltinSlashCommand {
14
14
  name: string;
15
+ aliases?: string[];
15
16
  description: string;
16
17
  /** Subcommands for dropdown completion (e.g. /mcp add, /mcp list). */
17
18
  subcommands?: SubcommandDef[];
@@ -79,7 +80,6 @@ export interface TuiSlashCommandRuntime {
79
80
  }
80
81
  /** Unified slash-command spec consumed by both TUI and ACP dispatchers. */
81
82
  export interface SlashCommandSpec extends BuiltinSlashCommand {
82
- aliases?: string[];
83
83
  /** When false, the dispatcher refuses to handle invocations that include arguments. */
84
84
  allowArgs?: boolean;
85
85
  /**
@@ -10,6 +10,8 @@ interface AlwaysApplyRule {
10
10
  content: string;
11
11
  path: string;
12
12
  }
13
+ /** Discover TITLE_SYSTEM.md file for automatic session-title prompt overrides */
14
+ export declare function discoverTitleSystemPromptFile(cwd?: string): string | undefined;
13
15
  /** Resolve input as file path or literal string */
14
16
  export declare function resolvePromptInput(input: string | undefined, description: string): Promise<string | undefined>;
15
17
  export interface LoadContextFilesOptions {
@@ -22,6 +22,16 @@ import type { ContextFileEntry } from "../tools";
22
22
  import type { EventBus } from "../utils/event-bus";
23
23
  import type { WorkspaceTree } from "../workspace-tree";
24
24
  import { type AgentDefinition, type AgentProgress, type ReviewFinding, type SingleResult } from "./types";
25
+ /**
26
+ * Soft per-agent request budgets (assistant requests per run). When a subagent
27
+ * crosses its budget it receives ONE steering notice asking it to wrap up; at
28
+ * 1.5x the budget the run is aborted gracefully so partial output is salvaged.
29
+ * The `default` key applies to agents without an explicit entry and can be
30
+ * overridden via the `task.softRequestBudget` setting (0 disables the guard).
31
+ */
32
+ export declare const SOFT_REQUEST_BUDGET: Record<string, number>;
33
+ /** Steering notice injected once when a subagent crosses its soft request budget. */
34
+ export declare function buildBudgetNotice(requests: number): string;
25
35
  /** Options for subagent execution */
26
36
  export interface ExecutorOptions {
27
37
  cwd: string;
@@ -29,6 +39,7 @@ export interface ExecutorOptions {
29
39
  agent: AgentDefinition;
30
40
  task: string;
31
41
  assignment?: string;
42
+ /** Shared background from the task call (`task.batch`), rendered into the subagent's system prompt. */
32
43
  context?: string;
33
44
  /**
34
45
  * The session's active overall plan, handed off so subagents spawned during
@@ -42,6 +53,7 @@ export interface ExecutorOptions {
42
53
  description?: string;
43
54
  index: number;
44
55
  id: string;
56
+ parentToolCallId?: string;
45
57
  modelOverride?: string | string[];
46
58
  /**
47
59
  * Active model selector of the parent session, used as an auth-aware fallback
@@ -65,8 +77,6 @@ export interface ExecutorOptions {
65
77
  sessionFile?: string | null;
66
78
  persistArtifacts?: boolean;
67
79
  artifactsDir?: string;
68
- /** Path to parent conversation context file */
69
- contextFile?: string;
70
80
  eventBus?: EventBus;
71
81
  contextFiles?: ContextFileEntry[];
72
82
  skills?: Skill[];
@@ -1,22 +1,29 @@
1
1
  import type { AgentTool, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
2
2
  import type { ToolSession } from "..";
3
3
  import type { Theme } from "../modes/theme/theme";
4
- import { type AgentDefinition, type TaskToolDetails, type TaskToolSchemaInstance } from "./types";
4
+ import { type AgentDefinition, type SingleResult, type TaskToolDetails, type TaskToolSchemaInstance } from "./types";
5
5
  import "../tools/review";
6
6
  import { renderResult, renderCall as renderTaskCall } from "./render";
7
7
  export { loadBundledAgents as BUNDLED_AGENTS } from "./agents";
8
8
  export { discoverCommands, expandCommand, getCommand } from "./commands";
9
9
  export { discoverAgents, getAgent } from "./discovery";
10
10
  export { AgentOutputManager } from "./output-manager";
11
- export type { AgentDefinition, AgentProgress, SingleResult, SubagentLifecyclePayload, SubagentProgressPayload, TaskParams, TaskToolDetails, } from "./types";
11
+ export type { AgentDefinition, AgentProgress, SingleResult, SubagentEventPayload, SubagentLifecyclePayload, SubagentProgressPayload, TaskParams, TaskToolDetails, } from "./types";
12
12
  export { TASK_SUBAGENT_EVENT_CHANNEL, TASK_SUBAGENT_LIFECYCLE_CHANNEL, TASK_SUBAGENT_PROGRESS_CHANNEL, taskSchema, } from "./types";
13
13
  export declare const READ_ONLY_TOOL_NAMES: ReadonlySet<string>;
14
14
  export declare function isReadOnlyAgent(agent: AgentDefinition): boolean;
15
+ /**
16
+ * Preview text for a child result. Falls back to "(no output)" — annotated
17
+ * with the request count when the child actually did work, so the parent can
18
+ * tell a no-op child from one that burned requests before being cancelled.
19
+ */
20
+ export declare function formatResultOutputFallback(result: Pick<SingleResult, "output" | "stderr" | "requests">): string;
15
21
  /**
16
22
  * Task tool - Delegate tasks to specialized agents.
17
23
  *
18
- * Requires async initialization to discover available agents.
19
- * Use `TaskTool.create(session)` to instantiate.
24
+ * Each call spawns one subagent or, with `task.batch`, one per `tasks[]`
25
+ * item. Spawning is non-blocking: the call registers AsyncJobManager jobs and
26
+ * returns immediately; each result is delivered when that agent yields.
20
27
  */
21
28
  export declare class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetails, Theme> {
22
29
  #private;
@@ -25,7 +32,7 @@ export declare class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskT
25
32
  readonly approval: "exec";
26
33
  readonly formatApprovalDetails: (args: unknown) => string[];
27
34
  readonly label = "Task";
28
- readonly summary = "Spawn a subagent to complete a parallel task";
35
+ readonly summary = "Spawn a subagent to complete a task in the background";
29
36
  readonly strict = true;
30
37
  readonly loadMode = "discoverable";
31
38
  readonly renderResult: typeof renderResult;
@@ -39,5 +46,5 @@ export declare class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskT
39
46
  * Create a TaskTool instance with async agent discovery.
40
47
  */
41
48
  static create(session: ToolSession): Promise<TaskTool>;
42
- execute(_toolCallId: string, rawParams: unknown, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<TaskToolDetails>): Promise<AgentToolResult<TaskToolDetails>>;
49
+ execute(toolCallId: string, rawParams: unknown, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<TaskToolDetails>): Promise<AgentToolResult<TaskToolDetails>>;
43
50
  }
@@ -17,11 +17,4 @@ export declare class AgentOutputManager {
17
17
  * @returns Unique ID ("Anna" first, then "Anna-2", "Anna-3", …)
18
18
  */
19
19
  allocate(id: string): Promise<string>;
20
- /**
21
- * Allocate unique IDs for a batch of tasks.
22
- *
23
- * @param ids Array of requested IDs
24
- * @returns Array of unique IDs in same order
25
- */
26
- allocateBatch(ids: string[]): Promise<string[]>;
27
20
  }
@@ -2,7 +2,7 @@
2
2
  * Repair double-encoded JSON string arguments for the task tool.
3
3
  *
4
4
  * Models occasionally JSON-escape a string value twice when emitting a
5
- * `task` tool call, so a `context`/`assignment` that should read
5
+ * `task` tool call, so an `assignment` that should read
6
6
  *
7
7
  * # Role
8
8
  * You are a judge … "describe this" … return —
@@ -24,7 +24,7 @@
24
24
  * string.
25
25
  *
26
26
  * This is deliberately scoped to the task tool's natural-language fields
27
- * (`context`, `assignment`, `description`). It is NOT applied to code-bearing
27
+ * (`assignment`, `description`). It is NOT applied to code-bearing
28
28
  * tools (write/edit/bash/search), where a backslash or quote is load-bearing
29
29
  * and a false-positive unescape would silently corrupt a file or command.
30
30
  */
@@ -43,10 +43,11 @@ import type { TaskParams } from "./types";
43
43
  */
44
44
  export declare function repairDoubleEncodedJsonString(value: string): string;
45
45
  /**
46
- * Repair double-encoded prose in task-tool params (`context` and each task's
47
- * `assignment`/`description`). Returns the same reference when nothing changed
48
- * so callers can cheaply skip work. Defensive against partially-streamed args
49
- * (missing/undefined fields, partial task arrays) so it is safe on the render
50
- * path as well as on execution.
46
+ * Repair double-encoded prose in task-tool params (`assignment`,
47
+ * `description`, shared `context`, and each batch task item's prose fields).
48
+ * Returns the same reference when nothing changed so callers can cheaply skip
49
+ * work. Defensive against partially-streamed args (missing/undefined fields,
50
+ * partial task arrays) so it is safe on the render path as well as on
51
+ * execution.
51
52
  */
52
53
  export declare function repairTaskParams(params: TaskParams): TaskParams;
@@ -1,7 +1,7 @@
1
1
  import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
2
2
  import type { Usage } from "@oh-my-pi/pi-ai";
3
3
  import * as z from "zod/v4";
4
- import { type TaskSimpleMode } from "./simple-mode";
4
+ import type { AgentSessionEvent } from "../session/agent-session";
5
5
  import type { NestedRepoPatch } from "./worktree";
6
6
  /** Source of an agent definition */
7
7
  export type AgentSource = "bundled" | "user" | "project";
@@ -21,10 +21,16 @@ export interface SubagentProgressPayload {
21
21
  agent: string;
22
22
  agentSource: AgentSource;
23
23
  task: string;
24
+ parentToolCallId?: string;
24
25
  assignment?: string;
25
26
  progress: AgentProgress;
26
27
  sessionFile?: string;
27
28
  }
29
+ /** Payload emitted on TASK_SUBAGENT_EVENT_CHANNEL */
30
+ export interface SubagentEventPayload {
31
+ id: string;
32
+ event: AgentSessionEvent;
33
+ }
28
34
  /** Payload emitted on TASK_SUBAGENT_LIFECYCLE_CHANNEL */
29
35
  export interface SubagentLifecyclePayload {
30
36
  id: string;
@@ -33,87 +39,89 @@ export interface SubagentLifecyclePayload {
33
39
  description?: string;
34
40
  status: "started" | "completed" | "failed" | "aborted";
35
41
  sessionFile?: string;
42
+ parentToolCallId?: string;
36
43
  index: number;
37
44
  }
38
- /** Single task item for parallel execution (default shape with context enabled). */
39
45
  export declare const taskItemSchema: z.ZodObject<{
40
- id: z.ZodString;
41
- description: z.ZodString;
46
+ id: z.ZodOptional<z.ZodString>;
47
+ description: z.ZodOptional<z.ZodString>;
42
48
  assignment: z.ZodString;
43
49
  }, z.core.$strip>;
44
- export type TaskItem = z.infer<typeof taskItemSchema>;
50
+ /** Single task item. Fields are optional defensively: args stream in token by token. */
51
+ export interface TaskItem {
52
+ /** Stable agent id; default = generated AdjectiveNoun. */
53
+ id?: string;
54
+ /** UI label, not seen by the subagent. */
55
+ description?: string;
56
+ /** The work; required by the schema. */
57
+ assignment?: string;
58
+ /** Run this spawn in an isolated worktree (batch form; flat form carries it top-level). */
59
+ isolated?: boolean;
60
+ }
45
61
  export declare const taskSchema: z.ZodObject<{
62
+ id: z.ZodOptional<z.ZodString>;
63
+ description: z.ZodOptional<z.ZodString>;
64
+ assignment: z.ZodString;
65
+ isolated: z.ZodOptional<z.ZodBoolean>;
46
66
  agent: z.ZodString;
47
- tasks: z.ZodArray<z.ZodObject<{
48
- id: z.ZodString;
49
- description: z.ZodString;
50
- assignment: z.ZodString;
51
- }, z.core.$strip>>;
52
- }, z.core.$strip>;
53
- export declare const taskSchemaNoIsolation: z.ZodObject<{
54
- agent: z.ZodString;
55
- tasks: z.ZodArray<z.ZodObject<{
56
- id: z.ZodString;
57
- description: z.ZodString;
58
- assignment: z.ZodString;
59
- }, z.core.$strip>>;
60
67
  }, z.core.$strip>;
61
68
  declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
69
+ id: z.ZodOptional<z.ZodString>;
70
+ description: z.ZodOptional<z.ZodString>;
71
+ assignment: z.ZodString;
72
+ isolated: z.ZodOptional<z.ZodBoolean>;
62
73
  agent: z.ZodString;
63
- tasks: z.ZodArray<z.ZodObject<{
64
- id: z.ZodString;
65
- description: z.ZodString;
66
- assignment: z.ZodString;
67
- }, z.core.$strip>>;
68
- }, z.core.$strip>, z.ZodObject<{
69
- agent: z.ZodString;
70
- tasks: z.ZodArray<z.ZodObject<{
71
- id: z.ZodString;
72
- description: z.ZodString;
73
- assignment: z.ZodString;
74
- }, z.core.$strip>>;
75
- }, z.core.$strip>, z.ZodObject<{
76
- agent: z.ZodString;
77
- tasks: z.ZodArray<z.ZodObject<{
78
- id: z.ZodString;
79
- description: z.ZodString;
80
- assignment: z.ZodString;
81
- }, z.core.$strip>>;
82
74
  }, z.core.$strip>, z.ZodObject<{
75
+ id: z.ZodOptional<z.ZodString>;
76
+ description: z.ZodOptional<z.ZodString>;
77
+ assignment: z.ZodString;
83
78
  agent: z.ZodString;
84
- tasks: z.ZodArray<z.ZodObject<{
85
- id: z.ZodString;
86
- description: z.ZodString;
87
- assignment: z.ZodString;
88
- }, z.core.$strip>>;
89
79
  }, z.core.$strip>, z.ZodObject<{
90
80
  agent: z.ZodString;
81
+ context: z.ZodString;
91
82
  tasks: z.ZodArray<z.ZodObject<{
92
- id: z.ZodString;
93
- description: z.ZodString;
83
+ id: z.ZodOptional<z.ZodString>;
84
+ description: z.ZodOptional<z.ZodString>;
94
85
  assignment: z.ZodString;
86
+ isolated: z.ZodOptional<z.ZodBoolean>;
95
87
  }, z.core.$strip>>;
96
88
  }, z.core.$strip>, z.ZodObject<{
97
89
  agent: z.ZodString;
90
+ context: z.ZodString;
98
91
  tasks: z.ZodArray<z.ZodObject<{
99
- id: z.ZodString;
100
- description: z.ZodString;
92
+ id: z.ZodOptional<z.ZodString>;
93
+ description: z.ZodOptional<z.ZodString>;
101
94
  assignment: z.ZodString;
102
95
  }, z.core.$strip>>;
103
96
  }, z.core.$strip>];
104
97
  type DynamicTaskSchema = (typeof ALL_TASK_SCHEMAS)[number];
105
98
  export type TaskSchema = typeof taskSchema;
106
- /** Active task tool parameter schema for the current simple-mode / isolation flags */
99
+ /** Active task tool parameter schema for the current isolation / batch flags */
107
100
  export type TaskToolSchemaInstance = DynamicTaskSchema;
108
101
  export declare function getTaskSchema(options: {
109
102
  isolationEnabled: boolean;
110
- simpleMode: TaskSimpleMode;
103
+ batchEnabled: boolean;
111
104
  }): DynamicTaskSchema;
105
+ /**
106
+ * Runtime params union over both wire shapes. The model sees exactly one shape
107
+ * (`{ agent, context, tasks[] }` when `task.batch` is on, `{ agent, ...item }`
108
+ * otherwise); runtime stays permissive so internal callers and stale
109
+ * transcripts using the flat form keep working under either setting.
110
+ */
112
111
  export interface TaskParams {
113
- agent: string;
112
+ /** Agent type; required. */
113
+ agent?: string;
114
+ /** Stable agent id (flat form); default = generated AdjectiveNoun. */
115
+ id?: string;
116
+ /** UI label (flat form), not seen by the subagent. */
117
+ description?: string;
118
+ /** The work (flat form). */
119
+ assignment?: string;
120
+ /** Batch form (`task.batch`): one subagent per item. */
121
+ tasks?: TaskItem[];
122
+ /** Batch form: shared background prepended to every assignment; required by the batch schema. */
114
123
  context?: string;
115
- schema?: string;
116
- tasks: TaskItem[];
124
+ /** Run in an isolated worktree (flat form; per-item in batch form). */
117
125
  isolated?: boolean;
118
126
  }
119
127
  /** A code review finding reported by the reviewer agent */
@@ -175,6 +183,8 @@ export interface AgentProgress {
175
183
  }>;
176
184
  recentOutput: string[];
177
185
  toolCount: number;
186
+ /** Count of assistant requests (assistant message_end events) across the run. Drives the soft request budget guard. */
187
+ requests: number;
178
188
  /** Cumulative input + output + cacheWrite tokens across all turns. Excludes cacheRead (re-reads cached context every turn, making cumulative sum misleading). */
179
189
  tokens: number;
180
190
  /**
@@ -244,6 +254,8 @@ export interface SingleResult {
244
254
  durationMs: number;
245
255
  /** Cumulative input + output + cacheWrite tokens across all turns. Excludes cacheRead (re-reads cached context every turn, making cumulative sum misleading). */
246
256
  tokens: number;
257
+ /** Count of assistant requests (assistant message_end events) across the run. */
258
+ requests: number;
247
259
  /** Latest per-turn context size at task completion. See `AgentProgress.contextTokens`. */
248
260
  contextTokens?: number;
249
261
  /** Model's context window in tokens, when known. */
@@ -24,6 +24,10 @@ export declare function getThinkingLevelMetadata(level: ThinkingLevel): Thinking
24
24
  * Converts an agent-local selector into the effort sent to providers.
25
25
  */
26
26
  export declare function toReasoningEffort(level: ThinkingLevel | undefined): Effort | undefined;
27
+ /**
28
+ * True when a selector explicitly requests provider-side reasoning disablement.
29
+ */
30
+ export declare function shouldDisableReasoning(level: ThinkingLevel | undefined): boolean;
27
31
  /**
28
32
  * Resolves a selector against the current model while preserving explicit "off".
29
33
  */
@@ -18,6 +18,16 @@ export interface TinyTitleDownloadOptions {
18
18
  signal?: AbortSignal;
19
19
  onProgress?: (event: TinyTitleProgressEvent) => void;
20
20
  }
21
+ /**
22
+ * Per-request controls for {@link TinyTitleClient.generate}.
23
+ *
24
+ * Carries the optional abort signal and title-system-prompt override used by
25
+ * callers that customize automatic session-title generation.
26
+ */
27
+ export interface TinyTitleGenerateOptions {
28
+ signal?: AbortSignal;
29
+ systemPrompt?: string;
30
+ }
21
31
  /**
22
32
  * Hidden subcommand on the main CLI that boots the tiny-model worker in the
23
33
  * spawned subprocess. Kept in sync with the dispatch in `cli.ts`.
@@ -56,6 +66,7 @@ export declare class TinyTitleClient {
56
66
  constructor(spawnWorker?: () => WorkerHandle);
57
67
  onProgress(listener: (event: TinyTitleProgressEvent) => void): () => void;
58
68
  generate(modelKey: string, message: string, signal?: AbortSignal): Promise<string | null>;
69
+ generate(modelKey: string, message: string, options?: TinyTitleGenerateOptions): Promise<string | null>;
59
70
  complete(modelKey: string, prompt: string, options?: {
60
71
  maxTokens?: number;
61
72
  signal?: AbortSignal;
@@ -24,6 +24,7 @@ export type TinyTitleWorkerInbound = {
24
24
  id: string;
25
25
  modelKey: TinyTitleLocalModelKey;
26
26
  message: string;
27
+ systemPrompt?: string;
27
28
  } | {
28
29
  type: "complete";
29
30
  id: string;
@@ -1,5 +1,5 @@
1
1
  import type { HTMLElement } from "linkedom";
2
- import type { ElementHandle } from "puppeteer-core";
2
+ import type { ElementHandle, ImageFormat } from "puppeteer-core";
3
3
  import type { Transport } from "./tab-protocol";
4
4
  declare global {
5
5
  interface Element extends HTMLElement {
@@ -23,6 +23,8 @@ export interface InflightOp {
23
23
  }
24
24
  /** Human-readable label for a screenshot op, used in op tracking + timeout errors. */
25
25
  export declare function describeScreenshot(opts?: ScreenshotOptions): string;
26
+ /** Map an explicit save path's extension to a puppeteer capture format (default png). */
27
+ export declare function imageFormatForPath(filePath: string): ImageFormat;
26
28
  /** Summarize still-running helpers (oldest first) so a cell timeout names what stalled. */
27
29
  export declare function describeInflight(inflight: Map<number, InflightOp>): string;
28
30
  export declare class WorkerCore {
@@ -14,17 +14,6 @@ declare const findSchema: z.ZodObject<{
14
14
  timeout: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
15
15
  }, z.core.$strict>;
16
16
  export type FindToolInput = z.infer<typeof findSchema>;
17
- /**
18
- * Group find matches into a multi-level directory tree so the model doesn't pay
19
- * repeated tokens for shared path prefixes. Single-child directory chains fold
20
- * into one header (`# a/b/c/`), so a common prefix — including an absolute root
21
- * for out-of-cwd results — collapses to a single line. Each level adds one `#`;
22
- * files are listed bare under the deepest directory header that owns them.
23
- *
24
- * Order follows the input (mtime-desc for native glob): a directory appears when
25
- * its first member is emitted, and a node's own files precede its subdirectories.
26
- */
27
- export declare function formatFindGroupedOutput(paths: readonly string[]): string;
28
17
  export interface FindToolDetails {
29
18
  truncation?: TruncationResult;
30
19
  resultLimitReached?: number;
@@ -1,51 +1,3 @@
1
- interface PathTreeNode {
2
- /** Direct file leaves, in first-seen order. */
3
- files: Array<{
4
- name: string;
5
- key: string;
6
- }>;
7
- /** Dedup set for `files` (a glob can surface the same path twice on retry). */
8
- fileNames: Set<string>;
9
- /** Child directories, in first-seen order. */
10
- subdirs: Array<{
11
- name: string;
12
- node: PathTreeNode;
13
- }>;
14
- /** Dedup index for `subdirs`. */
15
- dirIndex: Map<string, PathTreeNode>;
16
- }
17
- export interface PathTreeInput {
18
- /** Path string; absolute, cwd-relative, or url-like. Backslashes are normalized. */
19
- path: string;
20
- /** Whether the leaf itself is a directory (trailing-slash match from find). */
21
- isDir: boolean;
22
- /** Opaque key carried onto file events for section lookup. Defaults to `path`. */
23
- key?: string;
24
- }
25
- /** One node emitted while walking the tree: a folded directory or a file leaf. */
26
- export interface GroupedTreeEvent {
27
- kind: "dir" | "file";
28
- /** 0-based nesting depth (root children are depth 0). */
29
- depth: number;
30
- /** Folded chain for dirs (e.g. `a/b/c`, no trailing slash); basename for files. */
31
- name: string;
32
- /** File key for `kind === "file"`; empty string for directories. */
33
- key: string;
34
- }
35
- /**
36
- * Build a directory tree from a flat list of paths. URL-like entries are kept
37
- * whole as root-level file leaves (they have no meaningful directory structure).
38
- * Absolute paths carry a leading empty segment so they share a common `/` root
39
- * and fold like any other prefix.
40
- */
41
- export declare function buildPathTree(entries: Iterable<PathTreeInput>): PathTreeNode;
42
- /**
43
- * Depth-first walk yielding directory and file events. Directories collapse their
44
- * single-child chains (`a` → `a/b` → `a/b/c`) so a shared prefix becomes one
45
- * header. Each node's direct files are emitted before its subdirectories, keeping
46
- * a file unambiguously attached to the header above it.
47
- */
48
- export declare function walkPathTree(node: PathTreeNode, depth?: number): Generator<GroupedTreeEvent>;
49
1
  /**
50
2
  * One file's contribution to a grouped file output. The header itself is generated
51
3
  * by `formatGroupedFiles` (one `#` per nesting level); use `headerSuffix` to tack
@@ -116,4 +68,3 @@ export declare function classifyGroupedLines(lines: readonly string[], headerBas
116
68
  * indices lets callers slice parallel arrays (raw lines, styled lines, contexts).
117
69
  */
118
70
  export declare function groupLineIndicesByBlank(rawLines: readonly string[]): number[][];
119
- export {};
@@ -13,7 +13,7 @@ import type { LocalProtocolOptions } from "../internal-urls";
13
13
  import type { MCPManager } from "../mcp";
14
14
  import type { MnemopiSessionState } from "../mnemopi/state";
15
15
  import type { PlanModeState } from "../plan-mode/state";
16
- import { type AgentRegistry } from "../registry/agent-registry";
16
+ import type { AgentRegistry } from "../registry/agent-registry";
17
17
  import type { ArtifactManager } from "../session/artifacts";
18
18
  import type { ClientBridge } from "../session/client-bridge";
19
19
  import type { CustomMessage } from "../session/messages";
@@ -220,8 +220,6 @@ export interface ToolSession {
220
220
  recordEvalSubagentUsage?: (output: number) => void;
221
221
  /** Bridge to the connected client (e.g. ACP editor host). Tools should route fs/terminal/permission requests through this when available. */
222
222
  getClientBridge?: () => ClientBridge | undefined;
223
- /** Get compact conversation context for subagents (excludes tool results, system prompts) */
224
- getCompactContext?: () => string;
225
223
  /** Get cached todo phases for this session. */
226
224
  getTodoPhases?: () => TodoPhase[];
227
225
  /** Replace cached todo phases for this session. */
@@ -279,6 +277,12 @@ export interface ToolSession {
279
277
  /** Per-session ledger of post-edit LSP diagnostics already surfaced to the
280
278
  * model for each file. Lazily initialized by `getDiagnosticsLedger`. */
281
279
  diagnosticsLedger?: import("../lsp/diagnostics-ledger").DiagnosticsLedger;
280
+ /** Per-session ledger of consecutive byte-identical no-op edits, keyed by
281
+ * canonical file path. The hashline executor escalates a soft no-op hint
282
+ * to a thrown error once the same payload no-ops `NOOP_HARD_LIMIT` times,
283
+ * breaking subagent loops that ignore the textual hint (issue #2081).
284
+ * Lazily initialized by `getNoopLoopGuard`. */
285
+ noopLoopGuard?: import("../edit/hashline/noop-loop-guard").NoopLoopGuard;
282
286
  /** Queue a hidden message to be injected at the next agent turn. */
283
287
  queueDeferredMessage?(message: CustomMessage): void;
284
288
  /** Queue late LSP diagnostics (arrived after an edit/write returned) to be shown