@oh-my-pi/pi-coding-agent 16.1.23 → 16.2.1

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 (260) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/cli.js +3785 -3695
  3. package/dist/types/advisor/__tests__/emission-guard.test.d.ts +1 -0
  4. package/dist/types/advisor/emission-guard.d.ts +73 -0
  5. package/dist/types/advisor/index.d.ts +1 -0
  6. package/dist/types/advisor/runtime.d.ts +7 -0
  7. package/dist/types/advisor/watchdog.d.ts +13 -0
  8. package/dist/types/cli/flag-tables.d.ts +1 -0
  9. package/dist/types/cli/gallery-fixtures/search.d.ts +1 -1
  10. package/dist/types/collab/display-name.d.ts +3 -0
  11. package/dist/types/collab/host.d.ts +0 -2
  12. package/dist/types/commands/worktree.d.ts +0 -3
  13. package/dist/types/config/inline-tool-descriptors-mode.d.ts +13 -0
  14. package/dist/types/config/model-discovery.d.ts +6 -1
  15. package/dist/types/config/model-registry.d.ts +6 -2
  16. package/dist/types/config/model-resolver.d.ts +12 -0
  17. package/dist/types/config/models-config-schema.d.ts +29 -2
  18. package/dist/types/config/models-config.d.ts +22 -1
  19. package/dist/types/config/settings-schema.d.ts +91 -21
  20. package/dist/types/config/settings.d.ts +2 -0
  21. package/dist/types/dap/config.d.ts +1 -1
  22. package/dist/types/edit/hashline/filesystem.d.ts +4 -2
  23. package/dist/types/edit/renderer.d.ts +4 -0
  24. package/dist/types/extensibility/extensions/types.d.ts +17 -17
  25. package/dist/types/extensibility/hooks/types.d.ts +10 -10
  26. package/dist/types/extensibility/plugins/marketplace/types.d.ts +1 -0
  27. package/dist/types/internal-urls/__tests__/ssh-protocol.test.d.ts +1 -0
  28. package/dist/types/internal-urls/index.d.ts +1 -0
  29. package/dist/types/internal-urls/registry-helpers.d.ts +2 -0
  30. package/dist/types/internal-urls/router.d.ts +1 -1
  31. package/dist/types/internal-urls/ssh-protocol.d.ts +10 -0
  32. package/dist/types/internal-urls/types.d.ts +19 -2
  33. package/dist/types/irc/bus.d.ts +6 -0
  34. package/dist/types/modes/acp/acp-event-mapper.d.ts +1 -0
  35. package/dist/types/modes/components/__tests__/move-overlay.test.d.ts +1 -0
  36. package/dist/types/modes/components/custom-editor.d.ts +7 -0
  37. package/dist/types/modes/components/move-overlay.d.ts +23 -0
  38. package/dist/types/modes/components/plugin-selector.d.ts +2 -1
  39. package/dist/types/modes/components/queue-mode-selector.d.ts +2 -1
  40. package/dist/types/modes/components/select-list-mouse-routing.d.ts +2 -0
  41. package/dist/types/modes/components/settings-defs.d.ts +4 -1
  42. package/dist/types/modes/components/settings-selector.d.ts +2 -0
  43. package/dist/types/modes/components/show-images-selector.d.ts +2 -1
  44. package/dist/types/modes/components/status-line/component.d.ts +2 -0
  45. package/dist/types/modes/components/status-line/types.d.ts +2 -0
  46. package/dist/types/modes/components/theme-selector.d.ts +2 -1
  47. package/dist/types/modes/components/thinking-selector.d.ts +2 -1
  48. package/dist/types/modes/controllers/command-controller.d.ts +10 -1
  49. package/dist/types/modes/controllers/streaming-reveal.d.ts +6 -0
  50. package/dist/types/modes/interactive-mode.d.ts +10 -1
  51. package/dist/types/modes/internal-url-autocomplete.d.ts +1 -1
  52. package/dist/types/modes/running-subagent-badge.d.ts +6 -0
  53. package/dist/types/modes/theme/theme.d.ts +1 -1
  54. package/dist/types/modes/types.d.ts +9 -1
  55. package/dist/types/sdk.d.ts +2 -2
  56. package/dist/types/session/agent-session.d.ts +8 -1
  57. package/dist/types/session/blob-store.d.ts +4 -0
  58. package/dist/types/session/session-manager.d.ts +13 -0
  59. package/dist/types/slash-commands/builtin-registry.d.ts +1 -1
  60. package/dist/types/ssh/__tests__/connection-manager-args.test.d.ts +1 -0
  61. package/dist/types/ssh/__tests__/file-transfer-posix-guard.test.d.ts +1 -0
  62. package/dist/types/ssh/connection-manager.d.ts +2 -0
  63. package/dist/types/ssh/file-transfer.d.ts +79 -0
  64. package/dist/types/ssh/utils.d.ts +6 -0
  65. package/dist/types/system-prompt.d.ts +3 -0
  66. package/dist/types/task/executor.d.ts +16 -0
  67. package/dist/types/tiny/text.d.ts +1 -1
  68. package/dist/types/tools/builtin-names.d.ts +5 -1
  69. package/dist/types/tools/{find.d.ts → glob.d.ts} +15 -15
  70. package/dist/types/tools/{search.d.ts → grep.d.ts} +14 -14
  71. package/dist/types/tools/index.d.ts +3 -3
  72. package/dist/types/tools/path-utils.d.ts +29 -0
  73. package/dist/types/tools/read.d.ts +2 -2
  74. package/dist/types/tools/render-utils.d.ts +8 -0
  75. package/dist/types/tools/renderers.d.ts +11 -0
  76. package/dist/types/tools/ssh.d.ts +2 -0
  77. package/dist/types/tools/todo.d.ts +0 -16
  78. package/dist/types/tools/write.d.ts +2 -2
  79. package/dist/types/utils/active-repo-context.d.ts +8 -0
  80. package/dist/types/utils/image-resize.d.ts +1 -0
  81. package/dist/types/utils/markit-cache.d.ts +23 -0
  82. package/dist/types/utils/markit.d.ts +5 -1
  83. package/dist/types/utils/prompt-path.d.ts +1 -0
  84. package/dist/types/web/search/providers/duckduckgo.d.ts +14 -0
  85. package/dist/types/web/search/providers/firecrawl.d.ts +28 -0
  86. package/dist/types/web/search/providers/tinyfish.d.ts +29 -0
  87. package/dist/types/web/search/providers/xai.d.ts +13 -0
  88. package/dist/types/web/search/types.d.ts +18 -2
  89. package/package.json +30 -15
  90. package/scripts/build-binary.ts +9 -9
  91. package/scripts/bundle-dist.ts +2 -2
  92. package/src/advisor/__tests__/advisor.test.ts +61 -4
  93. package/src/advisor/__tests__/emission-guard.test.ts +147 -0
  94. package/src/advisor/advise-tool.ts +1 -1
  95. package/src/advisor/emission-guard.ts +172 -0
  96. package/src/advisor/index.ts +1 -0
  97. package/src/advisor/runtime.ts +11 -0
  98. package/src/advisor/watchdog.ts +27 -1
  99. package/src/cli/args.ts +5 -2
  100. package/src/cli/auth-broker-cli.ts +17 -0
  101. package/src/cli/config-cli.ts +4 -0
  102. package/src/cli/flag-tables.ts +7 -4
  103. package/src/cli/gallery-cli.ts +14 -2
  104. package/src/cli/gallery-fixtures/edit.ts +60 -0
  105. package/src/cli/gallery-fixtures/fs.ts +17 -17
  106. package/src/cli/gallery-fixtures/search.ts +4 -4
  107. package/src/cli/usage-cli.ts +20 -1
  108. package/src/cli/web-search-cli.ts +1 -1
  109. package/src/collab/display-name.ts +13 -0
  110. package/src/collab/guest.ts +5 -1
  111. package/src/collab/host.ts +2 -13
  112. package/src/commands/worktree.ts +6 -0
  113. package/src/config/inline-tool-descriptors-mode.ts +27 -0
  114. package/src/config/model-discovery.ts +77 -8
  115. package/src/config/model-registry.ts +89 -11
  116. package/src/config/model-resolver.ts +39 -1
  117. package/src/config/models-config-schema.ts +41 -5
  118. package/src/config/models-config.ts +4 -1
  119. package/src/config/settings-schema.ts +85 -27
  120. package/src/config/settings.ts +172 -1
  121. package/src/cursor.ts +1 -1
  122. package/src/dap/config.ts +152 -8
  123. package/src/dap/session.ts +1 -1
  124. package/src/discovery/claude-plugins.ts +3 -2
  125. package/src/discovery/helpers.ts +3 -1
  126. package/src/edit/hashline/diff.ts +14 -3
  127. package/src/edit/hashline/execute.ts +42 -6
  128. package/src/edit/hashline/filesystem.ts +38 -2
  129. package/src/edit/index.ts +1 -0
  130. package/src/edit/modes/patch.ts +11 -1
  131. package/src/edit/renderer.ts +140 -13
  132. package/src/eval/__tests__/agent-bridge.test.ts +101 -0
  133. package/src/eval/agent-bridge.ts +26 -3
  134. package/src/eval/js/tool-bridge.ts +2 -2
  135. package/src/export/html/index.ts +1 -1
  136. package/src/export/html/template.js +3 -1
  137. package/src/export/html/tool-views.generated.js +20 -20
  138. package/src/extensibility/extensions/types.ts +22 -22
  139. package/src/extensibility/hooks/types.ts +11 -11
  140. package/src/extensibility/plugins/legacy-pi-bundled-keys.ts +8 -3
  141. package/src/extensibility/plugins/legacy-pi-bundled-registry.ts +25 -10
  142. package/src/extensibility/plugins/marketplace/manager.ts +22 -0
  143. package/src/extensibility/plugins/marketplace/types.ts +1 -0
  144. package/src/internal-urls/__tests__/ssh-protocol.test.ts +331 -0
  145. package/src/internal-urls/docs-index.generated.txt +2 -2
  146. package/src/internal-urls/docs-index.ts +2 -3
  147. package/src/internal-urls/index.ts +1 -0
  148. package/src/internal-urls/registry-helpers.ts +19 -4
  149. package/src/internal-urls/router.ts +5 -3
  150. package/src/internal-urls/ssh-protocol.ts +367 -0
  151. package/src/internal-urls/types.ts +19 -2
  152. package/src/irc/bus.ts +11 -3
  153. package/src/mcp/tool-bridge.ts +32 -2
  154. package/src/memories/index.ts +1 -1
  155. package/src/modes/acp/acp-agent.ts +14 -1
  156. package/src/modes/acp/acp-event-mapper.ts +91 -27
  157. package/src/modes/components/__tests__/move-overlay.test.ts +166 -0
  158. package/src/modes/components/agent-hub.ts +3 -0
  159. package/src/modes/components/agent-transcript-viewer.ts +9 -7
  160. package/src/modes/components/custom-editor.ts +90 -5
  161. package/src/modes/components/move-overlay.ts +282 -0
  162. package/src/modes/components/plan-review-overlay.ts +35 -35
  163. package/src/modes/components/plugin-selector.ts +6 -1
  164. package/src/modes/components/queue-mode-selector.ts +6 -1
  165. package/src/modes/components/select-list-mouse-routing.ts +35 -0
  166. package/src/modes/components/session-selector.ts +11 -10
  167. package/src/modes/components/settings-defs.ts +14 -1
  168. package/src/modes/components/settings-selector.ts +196 -29
  169. package/src/modes/components/show-images-selector.ts +6 -1
  170. package/src/modes/components/status-line/component.ts +108 -28
  171. package/src/modes/components/status-line/segments.ts +5 -1
  172. package/src/modes/components/status-line/types.ts +2 -0
  173. package/src/modes/components/theme-selector.ts +6 -1
  174. package/src/modes/components/thinking-selector.ts +6 -1
  175. package/src/modes/components/tool-execution.ts +25 -9
  176. package/src/modes/components/tree-selector.ts +5 -5
  177. package/src/modes/controllers/command-controller.ts +140 -47
  178. package/src/modes/controllers/event-controller.ts +59 -3
  179. package/src/modes/controllers/input-controller.ts +68 -2
  180. package/src/modes/controllers/selector-controller.ts +5 -2
  181. package/src/modes/controllers/streaming-reveal.ts +17 -0
  182. package/src/modes/controllers/tool-args-reveal.ts +1 -1
  183. package/src/modes/interactive-mode.ts +116 -50
  184. package/src/modes/internal-url-autocomplete.ts +17 -2
  185. package/src/modes/prompt-action-autocomplete.ts +3 -1
  186. package/src/modes/running-subagent-badge.ts +13 -0
  187. package/src/modes/setup-wizard/scenes/glyph.ts +2 -13
  188. package/src/modes/setup-wizard/scenes/providers.ts +2 -1
  189. package/src/modes/setup-wizard/scenes/theme.ts +6 -12
  190. package/src/modes/setup-wizard/scenes/web-search.ts +8 -13
  191. package/src/modes/setup-wizard/wizard-overlay.ts +6 -5
  192. package/src/modes/theme/theme.ts +9 -1
  193. package/src/modes/types.ts +9 -1
  194. package/src/modes/utils/interactive-context-helpers.ts +1 -1
  195. package/src/priority.json +15 -0
  196. package/src/prompts/advisor/active-repo-watchdog.md +6 -0
  197. package/src/prompts/advisor/context-files.md +8 -0
  198. package/src/prompts/advisor/system.md +21 -7
  199. package/src/prompts/agents/designer.md +1 -1
  200. package/src/prompts/agents/explore.md +1 -1
  201. package/src/prompts/agents/librarian.md +2 -2
  202. package/src/prompts/agents/plan.md +2 -2
  203. package/src/prompts/agents/reviewer.md +1 -1
  204. package/src/prompts/agents/task.md +2 -2
  205. package/src/prompts/system/active-repo-context.md +4 -0
  206. package/src/prompts/system/gemini-tool-call-reminder.md +9 -0
  207. package/src/prompts/system/plan-mode-active.md +3 -3
  208. package/src/prompts/system/project-prompt.md +2 -2
  209. package/src/prompts/system/system-prompt.md +6 -6
  210. package/src/prompts/tools/bash.md +2 -2
  211. package/src/prompts/tools/checkpoint.md +1 -1
  212. package/src/prompts/tools/{find.md → glob.md} +1 -1
  213. package/src/prompts/tools/{search.md → grep.md} +3 -3
  214. package/src/prompts/tools/read.md +4 -2
  215. package/src/sdk.ts +65 -25
  216. package/src/session/agent-session.ts +519 -132
  217. package/src/session/blob-store.ts +24 -0
  218. package/src/session/session-history-format.ts +2 -2
  219. package/src/session/session-manager.ts +46 -0
  220. package/src/slash-commands/builtin-registry.ts +138 -20
  221. package/src/slash-commands/helpers/usage-report.ts +23 -2
  222. package/src/ssh/__tests__/connection-manager-args.test.ts +69 -0
  223. package/src/ssh/__tests__/file-transfer-posix-guard.test.ts +68 -0
  224. package/src/ssh/connection-manager.ts +12 -15
  225. package/src/ssh/file-transfer.ts +209 -0
  226. package/src/ssh/utils.ts +24 -0
  227. package/src/system-prompt.ts +56 -28
  228. package/src/task/executor.ts +96 -36
  229. package/src/task/index.ts +3 -3
  230. package/src/task/render.ts +14 -13
  231. package/src/task/worktree.ts +38 -1
  232. package/src/tiny/text.ts +49 -4
  233. package/src/tiny/worker.ts +3 -3
  234. package/src/tools/bash.ts +2 -2
  235. package/src/tools/builtin-names.ts +26 -2
  236. package/src/tools/{find.ts → glob.ts} +48 -42
  237. package/src/tools/{search.ts → grep.ts} +311 -129
  238. package/src/tools/index.ts +13 -14
  239. package/src/tools/irc.ts +6 -2
  240. package/src/tools/path-utils.ts +64 -1
  241. package/src/tools/read.ts +35 -6
  242. package/src/tools/render-utils.ts +14 -0
  243. package/src/tools/renderers.ts +15 -4
  244. package/src/tools/ssh.ts +17 -2
  245. package/src/tools/todo.ts +4 -26
  246. package/src/tools/write.ts +25 -9
  247. package/src/utils/active-repo-context.ts +143 -0
  248. package/src/utils/image-resize.ts +88 -7
  249. package/src/utils/lang-from-path.ts +3 -3
  250. package/src/utils/markit-cache.ts +166 -0
  251. package/src/utils/markit.ts +86 -18
  252. package/src/utils/prompt-path.ts +3 -0
  253. package/src/utils/title-generator.ts +1 -1
  254. package/src/web/search/provider.ts +54 -34
  255. package/src/web/search/providers/duckduckgo.ts +140 -0
  256. package/src/web/search/providers/firecrawl.ts +144 -0
  257. package/src/web/search/providers/tinyfish.ts +159 -0
  258. package/src/web/search/providers/xai.ts +292 -0
  259. package/src/web/search/providers/zai.ts +142 -56
  260. package/src/web/search/types.ts +6 -2
@@ -48,7 +48,7 @@ import type { ClientBridge } from "./client-bridge";
48
48
  import { type CustomMessage } from "./messages";
49
49
  import type { BuildSessionContextOptions, SessionContext } from "./session-context";
50
50
  import type { BranchSummaryEntry, NewSessionOptions } from "./session-entries";
51
- import type { SessionManager } from "./session-manager";
51
+ import { type SessionManager } from "./session-manager";
52
52
  import type { ShakeMode, ShakeResult } from "./shake-types";
53
53
  import { ToolChoiceQueue } from "./tool-choice-queue";
54
54
  import { YieldQueue } from "./yield-queue";
@@ -239,6 +239,12 @@ export interface AgentSessionConfig {
239
239
  advisorReadOnlyTools?: AgentTool[];
240
240
  /** Preloaded watchdog prompt content for the advisor. */
241
241
  advisorWatchdogPrompt?: string;
242
+ /**
243
+ * Preloaded project context files (AGENTS.md, etc.) rendered as a system-prompt
244
+ * block for the advisor — the same standing instructions the primary agent
245
+ * receives, so the reviewer holds the agent to them.
246
+ */
247
+ advisorContextPrompt?: string;
242
248
  /**
243
249
  * Strip tool descriptions from provider-bound tool specs on side requests
244
250
  * (handoff). Must match the session-start value used to build the system
@@ -459,6 +465,7 @@ export declare class AgentSession {
459
465
  /** True once dispose() has begun; deferred background work (e.g. the deferred
460
466
  * MCP discovery task in sdk.ts) must not touch the session past this point. */
461
467
  get isDisposed(): boolean;
468
+ markMovedFromEmptySessionFile(sessionFile: string): void;
462
469
  /**
463
470
  * Synchronously mark the session as disposing so new work is rejected
464
471
  * immediately: eval starts throw, queued asides are dropped, and the
@@ -27,6 +27,8 @@ export declare class BlobStore {
27
27
  putSync(data: Buffer, options?: BlobPutOptions): BlobPutResult;
28
28
  /** Read blob by hash, returns Buffer or null if not found. */
29
29
  get(hash: string): Promise<Buffer | null>;
30
+ /** Synchronous variant of {@link get}. */
31
+ getSync(hash: string): Buffer | null;
30
32
  /** Check if a blob exists. */
31
33
  has(hash: string): Promise<boolean>;
32
34
  }
@@ -62,3 +64,5 @@ export declare function resolveImageDataUrl(blobStore: BlobStore, data: string):
62
64
  * If the blob is missing, logs a warning and returns a placeholder.
63
65
  */
64
66
  export declare function resolveImageData(blobStore: BlobStore, data: string): Promise<string>;
67
+ /** Synchronous variant of {@link resolveImageData}. */
68
+ export declare function resolveImageDataSync(blobStore: BlobStore, data: string): string;
@@ -237,6 +237,14 @@ export declare class SessionManager {
237
237
  * @param sessionDir Optional session directory; defaults to the cwd-derived dir.
238
238
  */
239
239
  static create(cwd: string, sessionDir?: string, storage?: SessionStorage): SessionManager;
240
+ /**
241
+ * Create a fresh empty session file in the default session directory for
242
+ * `cwd`, writing only the session header. The returned path can be passed to
243
+ * `setSessionFile` / `AgentSession.switchSession` to start a new empty
244
+ * session in that directory. Used by `/move` to switch projects without
245
+ * dragging the current conversation along.
246
+ */
247
+ static createEmptySessionFile(cwd: string, storage?: SessionStorage): string;
240
248
  /**
241
249
  * Fork a session into the current project directory: copy history from another
242
250
  * session file while creating a fresh session file in this sessionDir.
@@ -290,4 +298,9 @@ export declare class SessionManager {
290
298
  /** List all sessions across all project directories. */
291
299
  static listAll(storage?: SessionStorage): Promise<SessionInfo[]>;
292
300
  }
301
+ /**
302
+ * If the current session was created by `/move` and contains no real
303
+ * user/assistant messages, delete it so empty move sessions don't accumulate.
304
+ */
305
+ export declare function cleanupEmptyMoveSession(sessionManager: SessionManager, movedFromEmptySessionFile: string | undefined): Promise<void>;
293
306
  export {};
@@ -4,7 +4,7 @@ export type { BuiltinSlashCommand, SubcommandDef } from "./types";
4
4
  /** TUI-specific runtime accepted by `executeBuiltinSlashCommand`. */
5
5
  export type BuiltinSlashCommandRuntime = TuiSlashCommandRuntime;
6
6
  export interface TuiBuiltinSlashCommand extends BuiltinSlashCommand {
7
- getArgumentCompletions?: (prefix: string) => AutocompleteItem[] | null;
7
+ getArgumentCompletions?: (prefix: string) => AutocompleteItem[] | null | Promise<AutocompleteItem[] | null>;
8
8
  getInlineHint?: (argumentText: string) => string | null;
9
9
  getAutocompleteDescription?: () => string | undefined;
10
10
  }
@@ -19,6 +19,8 @@ export interface SSHHostInfo {
19
19
  }
20
20
  interface SSHArgsOptions {
21
21
  platform?: SshPlatform;
22
+ /** When true, omit `-n` so the remote command can read from our piped stdin. */
23
+ allowStdin?: boolean;
22
24
  }
23
25
  export declare function getHostInfo(hostName: string): Promise<SSHHostInfo | undefined>;
24
26
  export declare function getHostInfoForHost(host: SSHConnectionTarget): Promise<SSHHostInfo | undefined>;
@@ -0,0 +1,79 @@
1
+ import { type SSHConnectionTarget } from "./connection-manager";
2
+ export interface RemoteFileReadOptions {
3
+ /** Maximum bytes to materialize; the helper fetches one extra byte to detect truncation. */
4
+ maxBytes: number;
5
+ signal?: AbortSignal;
6
+ timeoutMs?: number;
7
+ }
8
+ export interface RemoteFileReadResult {
9
+ /** Raw file bytes, capped at `maxBytes`. */
10
+ bytes: Uint8Array;
11
+ /** True when the remote file was larger than `maxBytes` (`bytes` is the prefix). */
12
+ truncated: boolean;
13
+ }
14
+ export interface RemoteFileWriteOptions {
15
+ signal?: AbortSignal;
16
+ timeoutMs?: number;
17
+ }
18
+ /**
19
+ * Read a remote file's raw bytes. Fetches `maxBytes + 1` so the caller can
20
+ * distinguish an exactly-`maxBytes` file from a larger (truncated) one.
21
+ *
22
+ * Throws `ptree.NonZeroExitError` (carrying the remote stderr tail) when the
23
+ * file is missing/unreadable or the host is unreachable.
24
+ */
25
+ export declare function readRemoteFile(target: SSHConnectionTarget, remotePath: string, opts: RemoteFileReadOptions): Promise<RemoteFileReadResult>;
26
+ /**
27
+ * Write `content` to a remote file byte-exact. Stdin is always staged first into
28
+ * a uniquely named temp in the destination directory (so the remote never blocks
29
+ * on an unread pipe and a dropped connection lands in the temp, never the
30
+ * destination). The destination then dictates the commit:
31
+ * - a directory — or a symlink to one, since the `-d` test follows links — is
32
+ * refused (a plain `mv tmp dir` would move the temp INTO it).
33
+ * - an existing non-symlink regular file is rewritten IN PLACE from the staged
34
+ * temp, preserving its inode and therefore its ordinary permission bits (a
35
+ * `0600` secret stays `0600` on overwrite), ACLs, xattrs, and hardlinks. The
36
+ * setuid/setgid bits may be cleared by the write (per POSIX). This commit is
37
+ * not fully atomic — a remote-side failure during the local temp->dest copy
38
+ * (e.g. the disk filling) can truncate the destination — but the slow network
39
+ * transfer has already landed in the temp, and the temp is removed on failure.
40
+ * It also needs write permission on the file itself (a read-only file is
41
+ * refused, not silently replaced).
42
+ * - an existing special file (FIFO/socket/device) is refused, not replaced.
43
+ * - anything else (a new path, a symlink to a non-directory, a dangling symlink)
44
+ * is committed with an atomic rename, which REPLACES a symlink with a regular
45
+ * file rather than writing through it (resolving the link target is not
46
+ * portable across the macOS/Linux hosts this stack supports).
47
+ * Throws `ptree.NonZeroExitError` when the remote path is unwritable or the host
48
+ * is unreachable.
49
+ */
50
+ export declare function writeRemoteFile(target: SSHConnectionTarget, remotePath: string, content: Uint8Array, opts: RemoteFileWriteOptions): Promise<void>;
51
+ /** Classification of a remote path, used by the read handler's directory dispatch. */
52
+ export type RemotePathKind = "file" | "directory" | "other" | "missing";
53
+ /**
54
+ * Classify a remote path with POSIX `test` (portable across Linux/BSD/macOS):
55
+ * `directory`, regular `file`, `other` (special file), or `missing`.
56
+ */
57
+ export declare function statRemotePath(target: SSHConnectionTarget, remotePath: string, opts?: {
58
+ signal?: AbortSignal;
59
+ timeoutMs?: number;
60
+ }): Promise<RemotePathKind>;
61
+ /** A single entry in a remote directory listing. */
62
+ export interface RemoteDirEntry {
63
+ /** Entry name (no path component), trailing `/` stripped. */
64
+ name: string;
65
+ /** True when the entry is a directory. */
66
+ isDirectory: boolean;
67
+ }
68
+ /**
69
+ * List a remote directory one level deep with `ls -1Ap` (one per line; all
70
+ * entries incl. dotfiles but not `.`/`..`; trailing `/` marks directories).
71
+ * Plain `ls` (no `| head`) so a permission/race failure surfaces as a non-zero
72
+ * exit instead of being masked as an empty listing. Entries are returned in
73
+ * full, sorted directories-first then by name to mirror the local
74
+ * directory-resource contract, so the read tool can paginate the listing.
75
+ */
76
+ export declare function listRemoteDir(target: SSHConnectionTarget, remotePath: string, opts?: {
77
+ signal?: AbortSignal;
78
+ timeoutMs?: number;
79
+ }): Promise<RemoteDirEntry[]>;
@@ -1,2 +1,8 @@
1
1
  export declare function sanitizeHostName(name: string): string;
2
2
  export declare function buildSshTarget(username: string | undefined, host: string): string;
3
+ /**
4
+ * Single-quote a path for a POSIX remote shell, escaping embedded single quotes.
5
+ * Mirrors the private `quoteRemotePath` in `tools/ssh.ts`; shared here for the
6
+ * `ssh://` file-transfer helpers.
7
+ */
8
+ export declare function quotePosixPath(value: string): string;
@@ -5,6 +5,7 @@ import type { AgentTool } from "@oh-my-pi/pi-agent-core";
5
5
  import type { ToolExample, TSchema } from "@oh-my-pi/pi-ai";
6
6
  import type { Personality, SkillsSettings } from "./config/settings";
7
7
  import { type Skill } from "./extensibility/skills";
8
+ import { type ActiveRepoContext } from "./utils/active-repo-context";
8
9
  import { type WorkspaceTree } from "./workspace-tree";
9
10
  interface AlwaysApplyRule {
10
11
  name: string;
@@ -114,6 +115,8 @@ export interface BuildSystemPromptOptions {
114
115
  includeWorkspaceTree?: boolean;
115
116
  /** Whether Mermaid fenced blocks render as terminal ASCII diagrams. Default: true */
116
117
  renderMermaid?: boolean;
118
+ /** Pre-resolved nested active repo context. Undefined resolves from cwd. */
119
+ activeRepoContext?: ActiveRepoContext | null;
117
120
  }
118
121
  /** Result of building provider-facing system prompt messages. */
119
122
  export interface BuildSystemPromptResult {
@@ -17,6 +17,7 @@ import type { HindsightSessionState } from "../hindsight/state";
17
17
  import type { LocalProtocolOptions } from "../internal-urls";
18
18
  import type { MCPManager } from "../mcp/manager";
19
19
  import type { MnemopiSessionState } from "../mnemopi/state";
20
+ import type { AgentSession } from "../session/agent-session";
20
21
  import type { ArtifactManager } from "../session/artifacts";
21
22
  import type { AuthStorage } from "../session/auth-storage";
22
23
  import type { ContextFileEntry } from "../tools";
@@ -156,6 +157,12 @@ export interface ExecutorOptions {
156
157
  * passes its own `getAgentId()`).
157
158
  */
158
159
  parentAgentId?: string;
160
+ /**
161
+ * Keep the finished subagent addressable in the registry for IRC/revival.
162
+ * Defaults to true. Eval bridge agents are programmatic one-shot helpers and
163
+ * set this false so disposal unregisters them instead of leaving idle peers.
164
+ */
165
+ keepAlive?: boolean;
159
166
  }
160
167
  export interface YieldItem {
161
168
  data?: unknown;
@@ -197,6 +204,15 @@ export declare function finalizeSubprocessOutput(args: FinalizeSubprocessOutputA
197
204
  */
198
205
  export declare function createMCPProxyTools(mcpManager: MCPManager): CustomTool[];
199
206
  export declare function createSubagentSettings(baseSettings: Settings, overrides?: Partial<Record<SettingPath, unknown>>, inheritedServiceTier?: ServiceTier | null): Settings;
207
+ export declare function finalizeSubagentLifecycle(args: {
208
+ id: string;
209
+ session: AgentSession;
210
+ aborted: boolean;
211
+ keepAlive: boolean;
212
+ isolated: boolean;
213
+ agentIdleTtlMs: number;
214
+ reviveSession: (() => Promise<AgentSession>) | null;
215
+ }): Promise<void>;
200
216
  /**
201
217
  * Run a single agent in-process.
202
218
  */
@@ -33,4 +33,4 @@ export declare function isLowSignalTitleInput(message: string): boolean;
33
33
  * `none` instruction in `prompts/system/title-system.md`.
34
34
  */
35
35
  export declare const NO_TITLE_SENTINEL = "none";
36
- export declare function normalizeGeneratedTitle(value: string | null | undefined): string | null;
36
+ export declare function normalizeGeneratedTitle(value: string | null | undefined, sourceText?: string): string | null;
@@ -1,2 +1,6 @@
1
- export declare const BUILTIN_TOOL_NAMES: readonly ["read", "bash", "edit", "ast_grep", "ast_edit", "ask", "debug", "eval", "ssh", "github", "find", "search", "lsp", "inspect_image", "browser", "checkpoint", "rewind", "task", "job", "irc", "todo", "web_search", "search_tool_bm25", "write", "memory_edit", "retain", "recall", "reflect", "learn", "manage_skill"];
1
+ export declare const BUILTIN_TOOL_NAMES: readonly ["read", "bash", "edit", "ast_grep", "ast_edit", "ask", "debug", "eval", "ssh", "github", "glob", "grep", "lsp", "inspect_image", "browser", "checkpoint", "rewind", "task", "job", "irc", "todo", "web_search", "search_tool_bm25", "write", "memory_edit", "retain", "recall", "reflect", "learn", "manage_skill"];
2
2
  export type BuiltinToolName = (typeof BUILTIN_TOOL_NAMES)[number];
3
+ /** Return the canonical tool name for current and legacy built-in tool IDs. */
4
+ export declare function normalizeToolName(name: string): string;
5
+ /** Normalize and deduplicate tool names while preserving first-seen order. */
6
+ export declare function normalizeToolNames(names: Iterable<string>): string[];
@@ -12,8 +12,8 @@ declare const findSchema: import("arktype/internal/variants/object.ts").ObjectTy
12
12
  gitignore?: boolean | undefined;
13
13
  limit?: number | undefined;
14
14
  }, {}>;
15
- export type FindToolInput = typeof findSchema.infer;
16
- export interface FindToolDetails {
15
+ export type GlobToolInput = typeof findSchema.infer;
16
+ export interface GlobToolDetails {
17
17
  truncation?: TruncationResult;
18
18
  resultLimitReached?: number;
19
19
  meta?: OutputMeta;
@@ -34,7 +34,7 @@ export interface FindToolDetails {
34
34
  * Pluggable operations for the find tool.
35
35
  * Override these to delegate file search to remote systems (e.g., SSH).
36
36
  */
37
- export interface FindOperations {
37
+ export interface GlobOperations {
38
38
  /** Check if path exists */
39
39
  exists: (absolutePath: string) => Promise<boolean> | boolean;
40
40
  /** Optional stat for distinguishing files vs directories. */
@@ -51,17 +51,17 @@ export interface FindOperations {
51
51
  limit: number;
52
52
  }) => Promise<string[]> | string[];
53
53
  }
54
- export interface FindToolOptions {
54
+ export interface GlobToolOptions {
55
55
  /** Custom operations for find. Default: local filesystem + rg */
56
- operations?: FindOperations;
56
+ operations?: GlobOperations;
57
57
  }
58
- export declare class FindTool implements AgentTool<typeof findSchema, FindToolDetails> {
58
+ export declare class GlobTool implements AgentTool<typeof findSchema, GlobToolDetails> {
59
59
  #private;
60
60
  private readonly session;
61
- readonly name = "find";
61
+ readonly name = "glob";
62
62
  readonly approval: "read";
63
63
  readonly loadMode = "essential";
64
- readonly label = "Find";
64
+ readonly label = "Glob";
65
65
  readonly description: string;
66
66
  readonly parameters: import("arktype/internal/variants/object.ts").ObjectType<{
67
67
  paths: string[];
@@ -71,24 +71,24 @@ export declare class FindTool implements AgentTool<typeof findSchema, FindToolDe
71
71
  }, {}>;
72
72
  readonly examples: readonly ToolExample<typeof findSchema.infer>[];
73
73
  readonly strict = true;
74
- constructor(session: ToolSession, options?: FindToolOptions);
75
- execute(_toolCallId: string, params: typeof findSchema.infer, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<FindToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<FindToolDetails>>;
74
+ constructor(session: ToolSession, options?: GlobToolOptions);
75
+ execute(_toolCallId: string, params: typeof findSchema.infer, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<GlobToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<GlobToolDetails>>;
76
76
  }
77
- interface FindRenderArgs {
77
+ interface GlobRenderArgs {
78
78
  paths?: string | string[];
79
79
  limit?: number;
80
80
  }
81
- export declare const findToolRenderer: {
81
+ export declare const globToolRenderer: {
82
82
  inline: boolean;
83
- renderCall(args: FindRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component;
83
+ renderCall(args: GlobRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component;
84
84
  renderResult(result: {
85
85
  content: Array<{
86
86
  type: string;
87
87
  text?: string;
88
88
  }>;
89
- details?: FindToolDetails;
89
+ details?: GlobToolDetails;
90
90
  isError?: boolean;
91
- }, options: RenderResultOptions, uiTheme: Theme, args?: FindRenderArgs): Component;
91
+ }, options: RenderResultOptions, uiTheme: Theme, args?: GlobRenderArgs): Component;
92
92
  mergeCallAndResult: boolean;
93
93
  };
94
94
  export {};
@@ -1,4 +1,4 @@
1
- import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
1
+ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback, ToolTier } from "@oh-my-pi/pi-agent-core";
2
2
  import type { Component } from "@oh-my-pi/pi-tui";
3
3
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
4
4
  import type { Theme } from "../modes/theme/theme";
@@ -12,7 +12,7 @@ declare const searchSchema: import("arktype/internal/variants/object.ts").Object
12
12
  gitignore?: boolean | undefined;
13
13
  skip?: number | null | undefined;
14
14
  }, {}>;
15
- export type SearchToolInput = typeof searchSchema.infer;
15
+ export type GrepToolInput = typeof searchSchema.infer;
16
16
  export declare function toPathList(input: string | string[] | undefined): string[];
17
17
  /** Maximum number of distinct files surfaced in a single response. The
18
18
  * agent paginates further pages via `skip`. */
@@ -23,7 +23,7 @@ export declare const MULTI_FILE_PER_FILE_MATCHES = 20;
23
23
  /** Per-file match cap for single-file searches — there's no diversity
24
24
  * concern when the scope is one file. */
25
25
  export declare const SINGLE_FILE_MATCHES = 200;
26
- export interface SearchToolDetails {
26
+ export interface GrepToolDetails {
27
27
  truncation?: TruncationResult;
28
28
  fileLimitReached?: number;
29
29
  perFileLimitReached?: number;
@@ -56,13 +56,13 @@ export interface SearchToolDetails {
56
56
  missingPaths?: string[];
57
57
  }
58
58
  type SearchParams = typeof searchSchema.infer;
59
- export declare class SearchTool implements AgentTool<typeof searchSchema, SearchToolDetails> {
59
+ export declare class GrepTool implements AgentTool<typeof searchSchema, GrepToolDetails> {
60
60
  private readonly session;
61
- readonly name = "search";
62
- readonly approval: "read";
63
- readonly label = "Search";
61
+ readonly name = "grep";
62
+ readonly approval: (args: unknown) => ToolTier;
63
+ readonly label = "Grep";
64
64
  readonly loadMode = "discoverable";
65
- readonly summary = "Search file contents using ripgrep (fast text search)";
65
+ readonly summary = "Grep file contents using ripgrep (fast regex search)";
66
66
  readonly description: string;
67
67
  readonly parameters: import("arktype/internal/variants/object.ts").ObjectType<{
68
68
  pattern: string;
@@ -73,26 +73,26 @@ export declare class SearchTool implements AgentTool<typeof searchSchema, Search
73
73
  }, {}>;
74
74
  readonly strict = true;
75
75
  constructor(session: ToolSession);
76
- execute(_toolCallId: string, params: SearchParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<SearchToolDetails>, _toolContext?: AgentToolContext): Promise<AgentToolResult<SearchToolDetails>>;
76
+ execute(_toolCallId: string, params: SearchParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<GrepToolDetails>, _toolContext?: AgentToolContext): Promise<AgentToolResult<GrepToolDetails>>;
77
77
  }
78
- interface SearchRenderArgs {
78
+ interface GrepRenderArgs {
79
79
  pattern: string;
80
80
  paths?: string | string[];
81
81
  case?: boolean;
82
82
  gitignore?: boolean;
83
83
  skip?: number;
84
84
  }
85
- export declare const searchToolRenderer: {
85
+ export declare const grepToolRenderer: {
86
86
  inline: boolean;
87
- renderCall(args: SearchRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component;
87
+ renderCall(args: GrepRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component;
88
88
  renderResult(result: {
89
89
  content: Array<{
90
90
  type: string;
91
91
  text?: string;
92
92
  }>;
93
- details?: SearchToolDetails;
93
+ details?: GrepToolDetails;
94
94
  isError?: boolean;
95
- }, options: RenderResultOptions, uiTheme: Theme, args?: SearchRenderArgs): Component;
95
+ }, options: RenderResultOptions, uiTheme: Theme, args?: GrepRenderArgs): Component;
96
96
  mergeCallAndResult: boolean;
97
97
  };
98
98
  export {};
@@ -23,7 +23,7 @@ import type { AgentOutputManager } from "../task/output-manager";
23
23
  import type { DiscoverableTool, DiscoverableToolSearchIndex } from "../tool-discovery/tool-index";
24
24
  import type { EventBus } from "../utils/event-bus";
25
25
  import type { WorkspaceTree } from "../workspace-tree";
26
- import type { BuiltinToolName } from "./builtin-names";
26
+ import { type BuiltinToolName } from "./builtin-names";
27
27
  import { type CheckpointState } from "./checkpoint";
28
28
  import { type TodoPhase } from "./todo";
29
29
  export * from "../edit";
@@ -41,8 +41,9 @@ export * from "./checkpoint";
41
41
  export * from "./debug";
42
42
  export * from "./eval";
43
43
  export * from "./eval-backends";
44
- export * from "./find";
45
44
  export * from "./gh";
45
+ export * from "./glob";
46
+ export * from "./grep";
46
47
  export * from "./image-gen";
47
48
  export * from "./inspect-image";
48
49
  export * from "./irc";
@@ -57,7 +58,6 @@ export * from "./read";
57
58
  export * from "./report-tool-issue";
58
59
  export * from "./resolve";
59
60
  export * from "./review";
60
- export * from "./search";
61
61
  export * from "./search-tool-bm25";
62
62
  export * from "./ssh";
63
63
  export * from "./todo";
@@ -58,8 +58,37 @@ export declare function splitInternalUrlSel(rawPath: string): {
58
58
  path: string;
59
59
  sel?: string;
60
60
  };
61
+ /**
62
+ * Peel a read-tool selector off an internal-URL write target so `write` resolves
63
+ * the same file `read` does (e.g. `ssh://h/f:raw` -> `ssh://h/f`). Only the
64
+ * whole-file display modes `raw`/`conflicts` are accepted (they do not change
65
+ * which bytes are written); any other selector-shaped tail `splitInternalUrlSel`
66
+ * peels — a line range, a compound like `raw:1-20`, or a malformed `:-N` — throws,
67
+ * because `write` addresses a whole file, not a partial range, and silently
68
+ * stripping it would write to a path the caller never named. Non-URL paths and
69
+ * URLs without a selector pass through unchanged.
70
+ */
71
+ export declare function peelWriteUrlSelector(rawPath: string): string;
61
72
  export declare function normalizeLocalScheme(filePath: string): string;
62
73
  export declare function isInternalUrlPath(filePath: string): boolean;
74
+ /**
75
+ * True when a tool path argument references the `ssh://` scheme anywhere.
76
+ *
77
+ * Substring (not anchored) on purpose: it feeds the read/search/write approval
78
+ * tier, which runs synchronously on the raw args. `search` only flattens a
79
+ * delimited `paths: "a,ssh://h/x"` into separate entries *after* approval, so an
80
+ * anchored check would let an embedded `ssh://` slip through at the read tier.
81
+ * Matching the literal `ssh://` substring also tracks exactly what routes to the
82
+ * SSH handler; over-matching only over-prompts (fail-closed).
83
+ */
84
+ export declare function pathTargetsSsh(path: string): boolean;
85
+ /**
86
+ * True when a path is specifically an `ssh://` URL (anchored scheme match).
87
+ * Unlike {@link pathTargetsSsh} (substring, for the pre-expansion approval
88
+ * scan), this is the exact per-entry check used to reject `ssh://` *before* a
89
+ * side-effecting `InternalUrlRouter.resolve` in tools that need a local file.
90
+ */
91
+ export declare function isSshUrl(path: string): boolean;
63
92
  /**
64
93
  * Resolve a path relative to the given cwd.
65
94
  * Handles ~ expansion and absolute paths.
@@ -1,4 +1,4 @@
1
- import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
1
+ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback, ToolTier } from "@oh-my-pi/pi-agent-core";
2
2
  import type { Component } from "@oh-my-pi/pi-tui";
3
3
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
4
4
  import { type Theme } from "../modes/theme/theme";
@@ -53,7 +53,7 @@ export declare class ReadTool implements AgentTool<typeof readSchema, ReadToolDe
53
53
  #private;
54
54
  private readonly session;
55
55
  readonly name = "read";
56
- readonly approval: "read";
56
+ readonly approval: (args: unknown) => ToolTier;
57
57
  readonly label = "Read";
58
58
  readonly loadMode = "essential";
59
59
  readonly description: string;
@@ -52,6 +52,14 @@ export declare function expandKeyHint(): string;
52
52
  * Get first N lines of text as preview, with each line truncated.
53
53
  */
54
54
  export declare function getPreviewLines(text: string, maxLines: number, maxLineLen: number, ellipsis?: Ellipsis): string[];
55
+ /**
56
+ * Collapse a possibly multi-line string into a single line, then truncate it to
57
+ * `maxWidth` display cells. {@link truncateToWidth} alone caps width but
58
+ * newlines are zero-width, so multi-line content (markdown briefs, tool args,
59
+ * provider errors) would otherwise spill a single status row across several
60
+ * visual lines. Whitespace runs collapse to one space, so tabs are handled too.
61
+ */
62
+ export declare function previewLine(text: string, maxWidth: number, ellipsis?: Ellipsis): string;
55
63
  /**
56
64
  * Extract domain from URL, stripping www. prefix.
57
65
  */
@@ -30,5 +30,16 @@ export type ToolRenderer = {
30
30
  * streams rows the result render preserves.
31
31
  */
32
32
  provisionalPendingPreview?: boolean | "collapsed";
33
+ /**
34
+ * Whether the partial-result render is provisional: chrome rows (header
35
+ * glyph, frame state) that change between `options.isPartial === true` and
36
+ * the final result render. When `true`, the block is treated as
37
+ * commit-unstable while a partial result is in flight, so the
38
+ * stable-prefix ratchet in `deriveLiveCommitState` cannot promote the
39
+ * partial chrome to native scrollback only to have the final render strand
40
+ * it above the settled frame. Absent = the partial render is byte-stable
41
+ * with the final render and may commit like any settled stream.
42
+ */
43
+ provisionalPartialResult?: boolean;
33
44
  };
34
45
  export declare const toolRenderers: Record<string, ToolRenderer>;
@@ -62,10 +62,12 @@ export declare const sshToolRenderer: {
62
62
  text?: string;
63
63
  }>;
64
64
  details?: SSHToolDetails;
65
+ isError?: boolean;
65
66
  }, options: RenderResultOptions & {
66
67
  renderContext?: SshRenderContext;
67
68
  }, uiTheme: Theme, args?: SshRenderArgs): Component;
68
69
  mergeCallAndResult: boolean;
69
70
  provisionalPendingPreview: string;
71
+ provisionalPartialResult: boolean;
70
72
  };
71
73
  export {};
@@ -37,22 +37,6 @@ type TodoParams = TodoSchema;
37
37
  type TodoSchema = typeof todoSchema.infer;
38
38
  export declare const USER_TODO_EDIT_CUSTOM_TYPE = "user_todo_edit";
39
39
  export declare function getLatestTodoPhasesFromEntries(entries: SessionEntry[]): TodoPhase[];
40
- /**
41
- * Pick the actionable window of tasks to display in the sticky todo panel.
42
- *
43
- * Returns up to `maxVisible` open (pending / in_progress) tasks in their
44
- * original phase order, plus the count of remaining open tasks not shown so
45
- * the caller can render a `+N more` hint. When every task in `tasks` is
46
- * closed (completed or abandoned), returns the trailing `maxVisible` tasks
47
- * with `hiddenOpenCount = 0`, so the panel keeps useful context until the
48
- * active-phase pointer advances on the next `todo`.
49
- *
50
- * Task identity and order are preserved — this is a slice, never a sort.
51
- */
52
- export declare function selectStickyTodoWindow(tasks: TodoItem[], maxVisible?: number): {
53
- visible: TodoItem[];
54
- hiddenOpenCount: number;
55
- };
56
40
  /**
57
41
  * Report whether `content` likely names the same work as any entry in
58
42
  * `descriptions`. Used by the sticky todo panel to light up a pending todo
@@ -1,4 +1,4 @@
1
- import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
1
+ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback, ToolTier } from "@oh-my-pi/pi-agent-core";
2
2
  import type { Component } from "@oh-my-pi/pi-tui";
3
3
  import type { RenderResultOptions } from "../extensibility/custom-tools/types";
4
4
  import { type FileDiagnosticsResult } from "../lsp";
@@ -30,7 +30,7 @@ export declare class WriteTool implements AgentTool<typeof writeSchema, WriteToo
30
30
  #private;
31
31
  private readonly session;
32
32
  readonly name = "write";
33
- readonly approval: (args: unknown) => "read" | "write";
33
+ readonly approval: (args: unknown) => ToolTier;
34
34
  readonly formatApprovalDetails: (args: unknown) => string[];
35
35
  readonly label = "Write";
36
36
  readonly description: string;
@@ -0,0 +1,8 @@
1
+ export interface ActiveRepoContext {
2
+ cwd: string;
3
+ repoRoot: string;
4
+ relativeRepoRoot: string;
5
+ source: "single-direct-child-repo";
6
+ }
7
+ export declare function resolveActiveRepoContext(cwd: string): Promise<ActiveRepoContext | null>;
8
+ export declare function resolveActiveRepoContextSync(cwd: string): ActiveRepoContext | null;
@@ -16,6 +16,7 @@ export interface ResizedImage {
16
16
  width: number;
17
17
  height: number;
18
18
  wasResized: boolean;
19
+ decodeFailed?: boolean;
19
20
  get data(): string;
20
21
  }
21
22
  /**
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Cache schema/format revision. Bumping it changes the on-disk key prefix
3
+ * (`v<N>-...`), so old entries become unreachable and are pruned naturally.
4
+ * Bump when the cache *file* shape changes (entry JSON layout, key scheme).
5
+ *
6
+ * Converter *output* changes are handled separately: the package version is
7
+ * folded into the key (see {@link markitConversionCacheKey}), so any release
8
+ * that ships new markdown from `src/markit/converters/*` auto-invalidates the
9
+ * cache without a manual bump here.
10
+ */
11
+ export declare const MARKIT_CONVERSION_CACHE_VERSION = 1;
12
+ export declare const MAX_MARKIT_CONVERSION_CACHE_BYTES: number;
13
+ export type MarkitConversionCacheStatus = "hit" | "miss" | "skipped";
14
+ export type MarkitConversionCacheReadResult = {
15
+ status: "hit";
16
+ content: string;
17
+ } | {
18
+ status: "miss";
19
+ };
20
+ export declare function markitConversionCacheKey(bytes: Uint8Array, extension: string): string;
21
+ export declare function readMarkitConversionCache(key: string): Promise<MarkitConversionCacheReadResult>;
22
+ export declare function pruneMarkitConversionCache(cacheDir: string): Promise<void>;
23
+ export declare function writeMarkitConversionCache(key: string, content: string): Promise<void>;
@@ -1,7 +1,9 @@
1
+ import { type MarkitConversionCacheStatus } from "./markit-cache";
1
2
  export interface MarkitConversionResult {
2
3
  content: string;
3
4
  ok: boolean;
4
5
  error?: string;
6
+ cache?: MarkitConversionCacheStatus;
5
7
  }
6
8
  export interface MarkitFileConversionOptions {
7
9
  /**
@@ -13,4 +15,6 @@ export interface MarkitFileConversionOptions {
13
15
  imageDir?: string;
14
16
  }
15
17
  export declare function convertFileWithMarkit(filePath: string, signal?: AbortSignal, options?: MarkitFileConversionOptions): Promise<MarkitConversionResult>;
16
- export declare function convertBufferWithMarkit(buffer: Uint8Array, extension: string, signal?: AbortSignal): Promise<MarkitConversionResult>;
18
+ export declare function convertBufferWithMarkit(buffer: Uint8Array, extension: string, signal?: AbortSignal, options?: {
19
+ useCache?: boolean;
20
+ }): Promise<MarkitConversionResult>;