@oh-my-pi/pi-coding-agent 16.1.15 → 16.1.16

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 (85) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/cli.js +3725 -4029
  3. package/dist/types/cli/args.d.ts +2 -5
  4. package/dist/types/cli/flag-tables.d.ts +2 -2
  5. package/dist/types/cli/session-picker.d.ts +4 -2
  6. package/dist/types/commands/launch.d.ts +1 -1
  7. package/dist/types/config/settings-schema.d.ts +12 -1
  8. package/dist/types/eval/agent-bridge.d.ts +19 -0
  9. package/dist/types/eval/js/shared/helpers.d.ts +1 -13
  10. package/dist/types/eval/js/shared/types.d.ts +1 -1
  11. package/dist/types/eval/js/worker-protocol.d.ts +1 -1
  12. package/dist/types/eval/py/executor.d.ts +1 -1
  13. package/dist/types/internal-urls/local-protocol.d.ts +18 -1
  14. package/dist/types/main.d.ts +2 -0
  15. package/dist/types/modes/components/plugin-settings.d.ts +5 -0
  16. package/dist/types/modes/components/session-selector.d.ts +25 -0
  17. package/dist/types/task/isolation-runner.d.ts +128 -0
  18. package/dist/types/task/worktree.d.ts +14 -1
  19. package/dist/types/thinking.d.ts +15 -0
  20. package/dist/types/tools/eval-render.d.ts +3 -0
  21. package/dist/types/tools/eval.d.ts +11 -17
  22. package/dist/types/tools/todo.d.ts +26 -28
  23. package/dist/types/tui/output-block.d.ts +8 -0
  24. package/dist/types/utils/image-resize.d.ts +2 -0
  25. package/dist/types/web/search/providers/exa.d.ts +2 -0
  26. package/package.json +12 -12
  27. package/scripts/build-binary.ts +18 -4
  28. package/src/cli/args.ts +4 -5
  29. package/src/cli/flag-tables.ts +3 -3
  30. package/src/cli/gallery-fixtures/interaction.ts +6 -9
  31. package/src/cli/gallery-fixtures/shell.ts +15 -23
  32. package/src/cli/session-picker.ts +17 -3
  33. package/src/commands/launch.ts +3 -3
  34. package/src/config/settings-schema.ts +13 -1
  35. package/src/edit/renderer.ts +34 -12
  36. package/src/eval/__tests__/agent-bridge.test.ts +462 -3
  37. package/src/eval/__tests__/helpers-local-roots.test.ts +2 -5
  38. package/src/eval/__tests__/julia-prelude.test.ts +1 -30
  39. package/src/eval/__tests__/prelude-agent.test.ts +42 -8
  40. package/src/eval/agent-bridge.ts +301 -71
  41. package/src/eval/jl/prelude.jl +32 -227
  42. package/src/eval/jl/runner.jl +38 -12
  43. package/src/eval/js/shared/helpers.ts +1 -114
  44. package/src/eval/js/shared/prelude.txt +13 -27
  45. package/src/eval/js/shared/runtime.ts +0 -6
  46. package/src/eval/js/shared/types.ts +1 -1
  47. package/src/eval/js/worker-protocol.ts +1 -1
  48. package/src/eval/py/__tests__/prelude.test.ts +13 -0
  49. package/src/eval/py/executor.ts +1 -1
  50. package/src/eval/py/prelude.py +47 -105
  51. package/src/eval/py/runner.py +0 -6
  52. package/src/eval/rb/prelude.rb +21 -189
  53. package/src/eval/rb/runner.rb +116 -9
  54. package/src/export/html/tool-views.generated.js +29 -29
  55. package/src/internal-urls/docs-index.generated.txt +1 -1
  56. package/src/internal-urls/local-protocol.ts +100 -53
  57. package/src/main.ts +15 -4
  58. package/src/modes/acp/acp-event-mapper.ts +7 -2
  59. package/src/modes/components/plugin-settings.ts +7 -1
  60. package/src/modes/components/session-selector.ts +143 -29
  61. package/src/modes/controllers/command-controller.ts +5 -0
  62. package/src/modes/rpc/rpc-mode.ts +6 -0
  63. package/src/modes/utils/copy-targets.ts +7 -2
  64. package/src/prompts/system/system-prompt.md +3 -3
  65. package/src/prompts/system/workflow-notice.md +3 -3
  66. package/src/prompts/tools/bash.md +16 -0
  67. package/src/prompts/tools/eval.md +19 -19
  68. package/src/prompts/tools/todo.md +1 -1
  69. package/src/session/agent-session.ts +231 -50
  70. package/src/task/index.ts +61 -207
  71. package/src/task/isolation-runner.ts +354 -0
  72. package/src/task/worktree.ts +46 -9
  73. package/src/thinking.ts +20 -0
  74. package/src/tools/ask.ts +44 -38
  75. package/src/tools/bash.ts +9 -2
  76. package/src/tools/browser/tab-worker.ts +1 -1
  77. package/src/tools/eval-render.ts +34 -27
  78. package/src/tools/eval.ts +100 -103
  79. package/src/tools/index.ts +8 -1
  80. package/src/tools/read.ts +136 -60
  81. package/src/tools/todo.ts +60 -64
  82. package/src/tui/code-cell.ts +1 -1
  83. package/src/tui/output-block.ts +11 -0
  84. package/src/utils/image-resize.ts +30 -0
  85. package/src/web/search/providers/exa.ts +85 -1
@@ -1,7 +1,4 @@
1
- /**
2
- * CLI argument parsing and help display
3
- */
4
- import { type Effort } from "@oh-my-pi/pi-catalog/effort";
1
+ import { type ConfiguredThinkingLevel } from "../thinking";
5
2
  export type Mode = "text" | "json" | "rpc" | "acp" | "rpc-ui";
6
3
  export interface Args {
7
4
  cwd?: string;
@@ -18,7 +15,7 @@ export interface Args {
18
15
  apiKey?: string;
19
16
  systemPrompt?: string;
20
17
  appendSystemPrompt?: string;
21
- thinking?: Effort;
18
+ thinking?: ConfiguredThinkingLevel;
22
19
  hideThinking?: boolean;
23
20
  advisor?: boolean;
24
21
  continue?: boolean;
@@ -29,7 +29,7 @@
29
29
  * tables), they're passed in through {@link ParseDeps} and `args.ts` wires the
30
30
  * real implementations at the dispatch site.
31
31
  */
32
- import type { Effort } from "@oh-my-pi/pi-ai";
32
+ import type { ConfiguredThinkingLevel } from "../thinking";
33
33
  import type { Args } from "./args";
34
34
  /**
35
35
  * Runtime dependencies injected into setters that need to validate input or
@@ -44,7 +44,7 @@ export interface ParseDeps {
44
44
  logger: {
45
45
  warn: (message: string, meta?: Record<string, unknown>) => void;
46
46
  };
47
- parseEffort: (value: string | null | undefined) => Effort | undefined;
47
+ parseThinking: (value: string | null | undefined) => ConfiguredThinkingLevel | undefined;
48
48
  builtinToolNames: readonly string[];
49
49
  thinkingEfforts: readonly string[];
50
50
  }
@@ -1,8 +1,10 @@
1
1
  import type { SessionInfo } from "../session/session-listing";
2
2
  /**
3
3
  * Show the TUI session selector and return the selected session, or null if
4
- * cancelled. Tab toggles between current-folder and all-projects scope; the
5
- * all-projects list is loaded lazily via `SessionManager.listAll`.
4
+ * cancelled. Rendered as a fullscreen overlay on the terminal's alternate
5
+ * screen, so the list scrolls and rows are clickable with the mouse. Tab
6
+ * toggles between current-folder and all-projects scope; the all-projects list
7
+ * is loaded lazily via `SessionManager.listAll`.
6
8
  */
7
9
  export declare function selectSession(sessions: SessionInfo[], options?: {
8
10
  allSessions?: SessionInfo[];
@@ -92,7 +92,7 @@ export default class Index extends Command {
92
92
  };
93
93
  thinking: import("@oh-my-pi/pi-utils/cli").FlagDescriptor<"string"> & {
94
94
  description: string;
95
- options: import("@oh-my-pi/pi-catalog").Effort[];
95
+ options: string[];
96
96
  };
97
97
  "hide-thinking": import("@oh-my-pi/pi-utils/cli").FlagDescriptor<"boolean"> & {
98
98
  description: string;
@@ -3726,7 +3726,7 @@ export declare const SETTINGS_SCHEMA: {
3726
3726
  readonly tab: "tools";
3727
3727
  readonly group: "Discovery & MCP";
3728
3728
  readonly label: "Essential Tools Override";
3729
- readonly description: "Override the always-loaded built-in tools (default: read, bash, edit). Leave empty to use defaults.";
3729
+ readonly description: "Override the always-loaded built-in tools (default: read, bash, edit, write, find, eval). Leave empty to use defaults.";
3730
3730
  };
3731
3731
  };
3732
3732
  readonly "mcp.enableProjectConfig": {
@@ -4935,6 +4935,16 @@ export declare const SETTINGS_SCHEMA: {
4935
4935
  readonly description: "Enable Exa basic search, deep search, code search, and crawl tools";
4936
4936
  };
4937
4937
  };
4938
+ readonly "exa.searchDelayMs": {
4939
+ readonly type: "number";
4940
+ readonly default: 1000;
4941
+ readonly ui: {
4942
+ readonly tab: "providers";
4943
+ readonly group: "Services";
4944
+ readonly label: "Exa Search Delay";
4945
+ readonly description: "Minimum delay between Exa web search requests in milliseconds; set 0 to disable pacing";
4946
+ };
4947
+ };
4938
4948
  readonly "exa.enableResearcher": {
4939
4949
  readonly type: "boolean";
4940
4950
  readonly default: false;
@@ -5202,6 +5212,7 @@ export interface TtsrSettings {
5202
5212
  export interface ExaSettings {
5203
5213
  enabled: boolean;
5204
5214
  enableSearch: boolean;
5215
+ searchDelayMs: number;
5205
5216
  enableResearcher: boolean;
5206
5217
  enableWebsets: boolean;
5207
5218
  }
@@ -1,3 +1,4 @@
1
+ import { type NestedRepoPatch } from "../task/worktree";
1
2
  import type { ToolSession } from "../tools";
2
3
  import type { JsStatusEvent } from "./js/shared/types";
3
4
  import "../tools/review";
@@ -17,6 +18,24 @@ export interface EvalAgentResult {
17
18
  id: string;
18
19
  model?: string | string[];
19
20
  structured: boolean;
21
+ /** True iff this run executed inside an isolation worktree. */
22
+ isolated?: boolean;
23
+ /** Captured patch artifact (patch mode) — surfaced regardless of `apply`. */
24
+ patchPath?: string;
25
+ /** Captured branch (branch mode) — surfaced regardless of `apply`. */
26
+ branchName?: string;
27
+ /** Captured nested repository patches — surfaced for isolated `apply=false` manual application. */
28
+ nestedPatches?: NestedRepoPatch[];
29
+ /**
30
+ * Tri-state apply outcome for isolated runs:
31
+ * - `true` — apply ran (or had nothing to do) and left the repo clean.
32
+ * - `false` — apply attempted and failed; artifacts preserved.
33
+ * - `null` — caller opted out via `apply=false`.
34
+ * Omitted for non-isolated runs.
35
+ */
36
+ changesApplied?: boolean | null;
37
+ /** Human-readable isolation apply/merge summary; kept out of schema-backed `text`. */
38
+ isolationSummary?: string;
20
39
  };
21
40
  }
22
41
  /**
@@ -1,13 +1,7 @@
1
1
  import type { JsStatusEvent } from "./types";
2
2
  export interface HelperOptions {
3
- path?: string;
4
- hidden?: boolean;
5
- maxDepth?: number;
6
3
  limit?: number;
7
4
  offset?: number;
8
- reverse?: boolean;
9
- unique?: boolean;
10
- count?: boolean;
11
5
  }
12
6
  /**
13
7
  * Inputs the helper factory needs from its host runtime. `cwd` is a getter so the runtime
@@ -27,18 +21,12 @@ export interface HelperContext {
27
21
  }
28
22
  /**
29
23
  * The set of functions exposed to user code via `globalThis.__omp_helpers__`. The JS
30
- * prelude reads from this bag and attaches short aliases (`read`, `write`, `tree`, ...)
24
+ * prelude reads from this bag and attaches short aliases (`read`, `write`, `env`, ...)
31
25
  * onto the global scope.
32
26
  */
33
27
  export interface HelperBundle {
34
28
  read(rawPath: string, options?: HelperOptions): Promise<string>;
35
29
  writeFile(rawPath: string, data: unknown): Promise<string>;
36
- append(rawPath: string, content: string): Promise<string>;
37
- sortText(text: string, options?: HelperOptions): string;
38
- uniqText(text: string, options?: HelperOptions): string | Array<[number, string]>;
39
- counter(items: string | string[], options?: HelperOptions): Array<[number, string]>;
40
- diff(rawA: string, rawB: string): Promise<string>;
41
- tree(searchPath?: string, options?: HelperOptions): Promise<string>;
42
30
  env(key?: string, value?: string): string | Record<string, string> | undefined;
43
31
  }
44
32
  export declare function createHelpers(ctx: HelperContext): HelperBundle;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Structured status payload emitted by helpers (`read`, `write`, `tree`, etc.) and the
2
+ * Structured status payload emitted by helpers (`read`, `write`, `env`, etc.) and the
3
3
  * tool-call bridge. Surfaces to the model as part of `displays` so it has machine-readable
4
4
  * context about what side effects happened.
5
5
  */
@@ -5,7 +5,7 @@ export interface SessionSnapshot {
5
5
  sessionId: string;
6
6
  /**
7
7
  * On-disk roots the helpers substitute for internal-URL schemes
8
- * (e.g. `{ local: "/…/artifacts/local" }`). Lets `read`/`write`/`append`
8
+ * (e.g. `{ local: "/…/artifacts/local" }`). Lets `read`/`write`
9
9
  * accept `local://…` paths instead of writing a literal `local:/` directory.
10
10
  */
11
11
  localRoots?: Record<string, string>;
@@ -45,7 +45,7 @@ export interface PythonExecutorOptions {
45
45
  artifactPath?: string;
46
46
  artifactId?: string;
47
47
  /**
48
- * On-disk roots the prelude helpers (`read`/`write`/`append`) substitute for
48
+ * On-disk roots the prelude helpers (`read`/`write`) substitute for
49
49
  * internal-URL schemes (e.g. `{ local: "/…/artifacts/local" }`). Exported to
50
50
  * the kernel as `PI_EVAL_LOCAL_ROOTS` (JSON) so `write("local://x")` lands
51
51
  * where `read local://x` resolves instead of a literal `local:/` directory.
@@ -8,7 +8,7 @@ export declare function resolveLocalRoot(options: LocalProtocolOptions, platform
8
8
  /** Resolve a local:// URL to an on-disk path under the active session's local root. */
9
9
  export declare function resolveLocalUrlToPath(input: string | InternalUrl, options: LocalProtocolOptions, platform?: NodeJS.Platform): string;
10
10
  /**
11
- * On-disk roots the eval helpers (`read`/`write`/`append`) substitute for
11
+ * On-disk roots the eval helpers (`read`/`write`) substitute for
12
12
  * internal-URL schemes so e.g. `write("local://x.md")` lands where a later
13
13
  * `read local://x.md` resolves — instead of a literal `local:/` directory under
14
14
  * the cwd (a stdlib `pathlib.Path`/`path.resolve` collapses `local://` to
@@ -17,6 +17,23 @@ export declare function resolveLocalUrlToPath(input: string | InternalUrl, optio
17
17
  * re-plumbing the worker boundary.
18
18
  */
19
19
  export declare function buildEvalUrlRoots(options: LocalProtocolOptions): Record<string, string>;
20
+ /**
21
+ * Resolve a local:// URL to a regular on-disk file, applying the same
22
+ * realpath + containment guarantees as {@link LocalProtocolHandler.resolve}
23
+ * but WITHOUT reading or UTF-8-decoding its contents. Returns null when there
24
+ * is no active session or when the URL targets the root listing or a directory;
25
+ * throws the handler's not-found and "escapes local root" errors for missing
26
+ * files and symlink escapes.
27
+ *
28
+ * Options are resolved via {@link LocalProtocolHandler.resolveOptions} so the
29
+ * caller-options → override → registry order matches router resolution exactly.
30
+ * The read tool uses this to detect and emit image files from their real path
31
+ * before the text-only resource contract would decode the binary into mojibake.
32
+ */
33
+ export declare function resolveLocalUrlToFile(input: string | InternalUrl, context?: ResolveContext): Promise<{
34
+ path: string;
35
+ size: number;
36
+ } | null>;
20
37
  /**
21
38
  * Protocol handler for local:// URLs.
22
39
  *
@@ -1,4 +1,5 @@
1
1
  import { type Args } from "./cli/args";
2
+ import { selectSession } from "./cli/session-picker";
2
3
  import { ModelRegistry } from "./config/model-registry";
3
4
  import { type ScopedModel } from "./config/model-resolver";
4
5
  import { Settings } from "./config/settings";
@@ -59,6 +60,7 @@ export declare function applyResolvedSystemPromptInputs(options: CreateAgentSess
59
60
  interface RunRootCommandDependencies {
60
61
  createAgentSession?: typeof createAgentSession;
61
62
  discoverAuthStorage?: typeof discoverAuthStorage;
63
+ selectSession?: typeof selectSession;
62
64
  runAcpMode?: RunAcpMode;
63
65
  settings?: Settings;
64
66
  forceSetupWizard?: boolean;
@@ -14,6 +14,11 @@ import type { InstalledPluginSummary } from "../../extensibility/plugins/marketp
14
14
  import type { InstalledPlugin } from "../../extensibility/plugins/types";
15
15
  /**
16
16
  * Forwards a keystroke to `input`, but cancels via `onCancel` when the user presses Escape.
17
+ *
18
+ * Escape is decoded via `matchesKey` rather than a raw `\x1b` compare: inside the
19
+ * fullscreen settings overlay the kitty keyboard protocol is active (ghostty/kitty),
20
+ * where the Escape key arrives as the CSI-u sequence `\x1b[27u`, not a bare `\x1b`.
21
+ * The literal fallbacks preserve legacy single/double-escape on terminals without it.
17
22
  */
18
23
  export declare function handleInputOrEscape(data: string, input: {
19
24
  handleInput(data: string): void;
@@ -39,6 +39,12 @@ declare class SessionList implements Component {
39
39
  /** Replace the visible dataset, e.g. when toggling folder/all-projects scope. */
40
40
  setSessions(sessions: SessionInfo[], showCwd: boolean): void;
41
41
  removeSession(sessionPath: string): void;
42
+ /** Resolve a list-local rendered-line index to a filtered-session index. */
43
+ hitTestSession(line: number): number | undefined;
44
+ /** Wheel notch: move the selection one step (clamped, no wrap). */
45
+ handleWheel(delta: -1 | 1): void;
46
+ /** Mouse click: select the session under the pointer and resume it. */
47
+ selectAndConfirm(index: number): void;
42
48
  invalidate(): void;
43
49
  render(width: number): readonly string[];
44
50
  handleInput(keyData: string): void;
@@ -55,6 +61,13 @@ export interface SessionSelectorOptions {
55
61
  * Omitted only in tests; defaults to a conservative 24 rows.
56
62
  */
57
63
  getTerminalRows?: () => number;
64
+ /**
65
+ * Fill the whole viewport and pin the footer (hint + bottom border) to the
66
+ * last rows, so the footer stops drifting as the list window changes height.
67
+ * Set by the standalone `--resume` picker (fullscreen alternate screen); the
68
+ * in-editor selector leaves it off and renders compactly.
69
+ */
70
+ fillHeight?: boolean;
58
71
  }
59
72
  /**
60
73
  * Component that renders a session selector with optional confirmation dialog
@@ -63,6 +76,18 @@ export declare class SessionSelectorComponent extends Container {
63
76
  #private;
64
77
  constructor(sessions: SessionInfo[], onSelect: (session: SessionInfo) => void, onCancel: () => void, onExit: () => void, options?: SessionSelectorOptions);
65
78
  setOnRequestRender(callback: () => void): void;
79
+ /**
80
+ * Concatenate the children's renders (like {@link Container}) while recording
81
+ * the line where the session list begins, so the fullscreen picker can hit-
82
+ * test mouse rows against the live list window. SessionList rebuilds its lines
83
+ * every frame, so Container's reference-memoization never applied here.
84
+ *
85
+ * In fill-height mode the body is padded (or, on a cramped terminal, trimmed)
86
+ * to leave exactly enough room for the footer at the screen bottom, so the
87
+ * footer is always visible and never drifts as the list window resizes. The
88
+ * in-editor selector just appends the footer directly.
89
+ */
90
+ render(width: number): readonly string[];
66
91
  handleInput(keyData: string): void;
67
92
  getSessionList(): SessionList;
68
93
  }
@@ -0,0 +1,128 @@
1
+ import type * as natives from "@oh-my-pi/pi-natives";
2
+ import type { ToolSession } from "../tools";
3
+ import type { ExecutorOptions } from "./executor";
4
+ import type { SingleResult } from "./types";
5
+ import { type WorktreeBaseline } from "./worktree";
6
+ type IsoBackendKind = natives.IsoBackendKind;
7
+ /** Resolved repo + baseline used by every isolated spawn in a single call. */
8
+ export interface IsolationContext {
9
+ repoRoot: string;
10
+ baseline: WorktreeBaseline;
11
+ }
12
+ /**
13
+ * Resolve the git repo root and capture the worktree baseline used to diff
14
+ * each isolated spawn against. Throws when the cwd is not inside a git
15
+ * repository; callers surface the error as a task-tool failure.
16
+ */
17
+ export declare function prepareIsolationContext(cwd: string): Promise<IsolationContext>;
18
+ /** Build a commit-message callback for branch/nested commits; `undefined` ⇒ fall back to generic message. */
19
+ export type BuildCommitMessage = () => undefined | ((diff: string) => Promise<string | null>);
20
+ /**
21
+ * Construct the commit-message factory used by isolation branch commits and
22
+ * nested-repo patch commits. Returns a closure that, each time it's called,
23
+ * either yields an AI-backed `(diff) => Promise<string|null>` callback (when
24
+ * `task.isolation.commits === "ai"` and a model registry is available) or
25
+ * `undefined` so the caller falls back to a generic commit message.
26
+ *
27
+ * Centralized so `TaskTool` and the eval `agent()` bridge share one wiring;
28
+ * a drift here previously meant the two callers built subtly different
29
+ * generators for the same setting.
30
+ */
31
+ export declare function makeIsolationCommitMessage(session: ToolSession): BuildCommitMessage;
32
+ export interface IsolatedRunOptions {
33
+ /**
34
+ * Base run options handed to the subagent subprocess. This helper sets
35
+ * `worktree`, clears `preloadedExtensionPaths` / `preloadedCustomToolPaths`
36
+ * (isolated runs re-discover inside the worktree), and forwards everything
37
+ * else unchanged.
38
+ */
39
+ baseOptions: ExecutorOptions;
40
+ /** Context returned by {@link prepareIsolationContext}. Baseline is cloned per spawn. */
41
+ context: IsolationContext;
42
+ /** PAL backend hint from `parseIsolationMode(...)` (undefined ⇒ resolver picks). */
43
+ preferredBackend: IsoBackendKind | undefined;
44
+ /** Stable id used as the isolation worktree namespace and as the branch suffix. */
45
+ agentId: string;
46
+ /** Merge mode driving how changes are captured ("branch" commits, "patch" diffs). */
47
+ mergeMode: "patch" | "branch";
48
+ /** Output dir for `${agentId}.patch` artifacts (patch mode). */
49
+ artifactsDir: string;
50
+ /** Human description carried onto the branch commit (branch mode). */
51
+ description?: string;
52
+ /** Build a commit-message callback (`task.isolation.commits === "ai"`). */
53
+ buildCommitMessage?: BuildCommitMessage;
54
+ /**
55
+ * Construct a `SingleResult` when isolation setup throws — the caller has
56
+ * the full metadata (index, agent, assignment, modelOverride) needed to
57
+ * build a result shape consistent with their non-isolated path.
58
+ */
59
+ buildFailureResult: (err: unknown) => SingleResult;
60
+ }
61
+ /**
62
+ * Run a subagent inside an isolation worktree and capture its changes.
63
+ *
64
+ * Branch mode: on success, commits the diff onto `omp/task/${agentId}` and
65
+ * returns `branchName` + `nestedPatches`. On commit failure the branch is
66
+ * deleted and `result.error` carries the merge-failure message.
67
+ *
68
+ * Patch mode: on success, writes `${artifactsDir}/${agentId}.patch` and
69
+ * returns `patchPath` + `nestedPatches`.
70
+ *
71
+ * Failure paths preserve the underlying `SingleResult` whenever possible so
72
+ * the caller can still surface the subagent's output; only isolation setup
73
+ * itself routes through {@link IsolatedRunOptions.buildFailureResult}.
74
+ *
75
+ * The isolation handle is always torn down in `finally`.
76
+ */
77
+ export declare function runIsolatedSubprocess(opts: IsolatedRunOptions): Promise<SingleResult>;
78
+ export interface IsolationMergeOptions {
79
+ result: SingleResult;
80
+ repoRoot: string;
81
+ mergeMode: "patch" | "branch";
82
+ }
83
+ export interface IsolationMergeOutcome {
84
+ /** Trailing summary appended to the subagent's result text. May be empty. */
85
+ summary: string;
86
+ /**
87
+ * Tri-state apply outcome:
88
+ * - `true` — merge ran (or had nothing to apply) and left the repo clean.
89
+ * - `false` — merge attempted and failed; artifacts are preserved.
90
+ * - `null` — caller skipped the merge phase entirely (e.g. `apply=false`).
91
+ */
92
+ changesApplied: boolean | null;
93
+ hadAnyChanges: boolean;
94
+ /** True iff the root branch actually merged — gates nested-repo patch application. */
95
+ mergedBranchForNestedPatches: boolean;
96
+ }
97
+ /**
98
+ * Apply changes captured by {@link runIsolatedSubprocess} back to the parent
99
+ * repo: patch apply (patch mode) or cherry-pick + cleanup (branch mode).
100
+ *
101
+ * The caller decides whether to run this at all — eval `agent()` with
102
+ * `apply=False` skips this step and surfaces the patch artifact / branch name
103
+ * instead.
104
+ */
105
+ export declare function mergeIsolatedChanges(opts: IsolationMergeOptions): Promise<IsolationMergeOutcome>;
106
+ export interface NestedPatchApplyOptions {
107
+ /** Subagent result carrying `nestedPatches`/`exitCode`/`aborted`. */
108
+ result: SingleResult;
109
+ repoRoot: string;
110
+ mergeMode: "patch" | "branch";
111
+ /** Parent merge outcome — patch mode skips nested apply when this is `false`. */
112
+ changesApplied: boolean | null;
113
+ /** Branch mode gates nested apply on whether the root branch merged. */
114
+ mergedBranchForNestedPatches: boolean;
115
+ /** Optional AI commit-message callback for nested commits; falls back to a generic message. */
116
+ commitMessage?: (diff: string) => Promise<string | null>;
117
+ }
118
+ /**
119
+ * Apply nested-repo patches after the parent merge phase. Centralizes the
120
+ * three-way gate (exitCode/aborted, patch-mode failed parent, branch-mode
121
+ * branch-merged) and the non-fatal failure handling so `TaskTool` and the
122
+ * eval `agent()` bridge use one implementation.
123
+ *
124
+ * Returns a system-notification suffix to append to the parent merge summary,
125
+ * or an empty string when nothing was applied or the nested apply succeeded.
126
+ */
127
+ export declare function applyEligibleNestedPatches(opts: NestedPatchApplyOptions): Promise<string>;
128
+ export {};
@@ -33,10 +33,23 @@ export interface DeltaPatchResult {
33
33
  export declare function captureDeltaPatch(isolationDir: string, baseline: WorktreeBaseline): Promise<DeltaPatchResult>;
34
34
  /**
35
35
  * Apply nested repo patches directly to their working directories after parent merge.
36
+ *
37
+ * Pre-existing dirty state in a nested repo is stashed before the patch is
38
+ * applied and popped back (with `--index` so staged WIP stays staged) after
39
+ * the commit, so unrelated user edits never get folded into the agent's
40
+ * commit. A failing `git stash pop` (e.g. user edits collide with the patched
41
+ * lines) leaves the stash entry intact, emits a `logger.warn`, and is
42
+ * returned to the caller as a human-readable warning string — the agent
43
+ * commit already landed, so this is a partial success the workflow needs to
44
+ * see, not a thrown failure.
45
+ *
46
+ * Returns the collected stash-restore warnings (empty when every nested repo
47
+ * was restored cleanly). Throws when the patch apply itself fails.
48
+ *
36
49
  * @param commitMessage Optional async function to generate a commit message from the combined diff.
37
50
  * If omitted or returns null, falls back to a generic message.
38
51
  */
39
- export declare function applyNestedPatches(repoRoot: string, patches: NestedRepoPatch[], commitMessage?: (diff: string) => Promise<string | null>): Promise<void>;
52
+ export declare function applyNestedPatches(repoRoot: string, patches: NestedRepoPatch[], commitMessage?: (diff: string) => Promise<string | null>): Promise<string[]>;
40
53
  /**
41
54
  * User-facing isolation mode names exposed by the `task.isolation.mode`
42
55
  * setting. Mapped to a backend-kind hint via {@link parseIsolationMode};
@@ -55,6 +55,21 @@ export interface ConfiguredThinkingLevelMetadata {
55
55
  export declare function parseConfiguredThinkingLevel(value: string | null | undefined): ConfiguredThinkingLevel | undefined;
56
56
  /** Returns display metadata for a configured selector, including `auto`. */
57
57
  export declare function getConfiguredThinkingLevelMetadata(level: ConfiguredThinkingLevel): ConfiguredThinkingLevelMetadata;
58
+ /**
59
+ * Thinking selectors accepted by the `--thinking` CLI flag, in display order:
60
+ * `off`, every concrete effort (`minimal`..`xhigh`), then `auto`. Single source
61
+ * for the flag's `options` list, shell completions, and the "invalid level"
62
+ * warning so all three stay in sync.
63
+ */
64
+ export declare const CLI_THINKING_LEVELS: readonly string[];
65
+ /**
66
+ * Parses a `--thinking` CLI value. Accepts every {@link parseConfiguredThinkingLevel}
67
+ * selector (`off`, `auto`, `minimal`..`xhigh`, plus the `max` alias) but rejects
68
+ * `inherit`: an explicit `inherit` on the command line would suppress the
69
+ * settings/scoped-model fallback during startup resolution only to resolve back
70
+ * to the provider default, which is never what the user means.
71
+ */
72
+ export declare function parseCliThinkingLevel(value: string | null | undefined): ConfiguredThinkingLevel | undefined;
58
73
  /**
59
74
  * Resolves an auto-classified effort against the active model's supported
60
75
  * range. Unlike {@link clampThinkingLevelForModel}, `auto` never resolves below
@@ -20,6 +20,9 @@ interface EvalRenderCellArg {
20
20
  title?: string;
21
21
  }
22
22
  interface EvalRenderArgs {
23
+ language?: string;
24
+ code?: string;
25
+ title?: string;
23
26
  cells?: EvalRenderCellArg[];
24
27
  __partialJson?: string;
25
28
  }
@@ -6,29 +6,21 @@ export { EVAL_DEFAULT_PREVIEW_LINES, evalToolRenderer } from "./eval-render";
6
6
  /** Language tokens the eval tool accepts, in stable display order. */
7
7
  export type EvalLanguageToken = "py" | "js" | "rb" | "jl";
8
8
  /**
9
- * Per-cell input. Each cell runs in order; state persists within a language
10
- * across cells and across tool calls. This static schema carries the full
11
- * language union for typing; {@link buildEvalSchema} narrows the wire copy per
12
- * session so disabled backends are never advertised to the model.
9
+ * Per-call input: a single cell. State persists within a language across
10
+ * separate eval calls and across tool calls, so each call is one logical step
11
+ * and later calls reuse what earlier ones defined. This static schema carries
12
+ * the full language union for typing; {@link buildEvalSchema} narrows the wire
13
+ * copy per session so disabled backends are never advertised to the model.
13
14
  */
14
- declare const evalCellSchema: import("arktype/internal/variants/object.ts").ObjectType<{
15
+ export declare const evalSchema: import("arktype/internal/variants/object.ts").ObjectType<{
15
16
  title?: string | undefined;
16
17
  timeout?: number | undefined;
17
18
  reset?: boolean | undefined;
18
19
  language: "jl" | "js" | "py" | "rb";
19
20
  code: string;
20
21
  }, {}>;
21
- export type EvalCellInput = typeof evalCellSchema.infer;
22
- export declare const evalSchema: import("arktype/internal/variants/object.ts").ObjectType<{
23
- cells: {
24
- title?: string | undefined;
25
- timeout?: number | undefined;
26
- reset?: boolean | undefined;
27
- language: "jl" | "js" | "py" | "rb";
28
- code: string;
29
- }[];
30
- }, {}>;
31
22
  export type EvalToolParams = typeof evalSchema.infer;
23
+ export type EvalCellInput = EvalToolParams;
32
24
  export type EvalToolResult = {
33
25
  content: Array<{
34
26
  type: "text";
@@ -62,10 +54,12 @@ export declare class EvalTool implements AgentTool<typeof evalSchema> {
62
54
  readonly approval: "exec";
63
55
  readonly formatApprovalDetails: (args: unknown) => string[];
64
56
  get summary(): string;
65
- readonly loadMode = "discoverable";
57
+ readonly loadMode = "essential";
66
58
  readonly label = "Eval";
67
59
  get description(): string;
68
- readonly examples: readonly ToolExample<typeof evalSchema.infer>[];
60
+ /** All reuse-chain examples; the `examples` getter filters by enabled languages. */
61
+ private static readonly ALL_EXAMPLES;
62
+ get examples(): readonly ToolExample<typeof evalSchema.infer>[];
69
63
  get parameters(): typeof evalSchema;
70
64
  readonly concurrency = "exclusive";
71
65
  readonly strict = true;
@@ -24,16 +24,14 @@ export interface TodoToolDetails {
24
24
  completedTasks?: TodoCompletionTransition[];
25
25
  }
26
26
  declare const todoSchema: import("arktype/internal/variants/object.ts").ObjectType<{
27
- ops: {
28
- op: "append" | "done" | "drop" | "init" | "rm" | "start" | "view";
29
- list?: {
30
- phase: string;
31
- items: string[];
32
- }[] | undefined;
33
- task?: string | undefined;
34
- phase?: string | undefined;
35
- items?: string[] | undefined;
36
- }[];
27
+ op: "append" | "done" | "drop" | "init" | "rm" | "start" | "view";
28
+ list?: {
29
+ phase: string;
30
+ items: string[];
31
+ }[] | undefined;
32
+ task?: string | undefined;
33
+ phase?: string | undefined;
34
+ items?: string[] | undefined;
37
35
  }, {}>;
38
36
  type TodoParams = TodoSchema;
39
37
  type TodoSchema = typeof todoSchema.infer;
@@ -70,7 +68,7 @@ export declare function selectStickyTodoWindow(tasks: TodoItem[], maxVisible?: n
70
68
  */
71
69
  export declare function todoMatchesAnyDescription(content: string, descriptions: readonly string[]): boolean;
72
70
  /** Apply an array of `todo`-style ops to existing phases. Used by /todo slash command. */
73
- export declare function applyOpsToPhases(currentPhases: TodoPhase[], ops: TodoParams["ops"]): {
71
+ export declare function applyOpsToPhases(currentPhases: TodoPhase[], ops: TodoParams[]): {
74
72
  phases: TodoPhase[];
75
73
  errors: string[];
76
74
  };
@@ -90,16 +88,14 @@ export declare class TodoTool implements AgentTool<typeof todoSchema, TodoToolDe
90
88
  readonly summary = "Write a structured todo list to track progress within a session";
91
89
  readonly description: string;
92
90
  readonly parameters: import("arktype/internal/variants/object.ts").ObjectType<{
93
- ops: {
94
- op: "append" | "done" | "drop" | "init" | "rm" | "start" | "view";
95
- list?: {
96
- phase: string;
97
- items: string[];
98
- }[] | undefined;
99
- task?: string | undefined;
100
- phase?: string | undefined;
101
- items?: string[] | undefined;
102
- }[];
91
+ op: "append" | "done" | "drop" | "init" | "rm" | "start" | "view";
92
+ list?: {
93
+ phase: string;
94
+ items: string[];
95
+ }[] | undefined;
96
+ task?: string | undefined;
97
+ phase?: string | undefined;
98
+ items?: string[] | undefined;
103
99
  }, {}>;
104
100
  readonly concurrency = "exclusive";
105
101
  readonly strict = true;
@@ -108,13 +104,15 @@ export declare class TodoTool implements AgentTool<typeof todoSchema, TodoToolDe
108
104
  constructor(session: ToolSession);
109
105
  execute(_toolCallId: string, params: TodoParams, _signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<TodoToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<TodoToolDetails>>;
110
106
  }
111
- type TodoRenderArgs = {
112
- ops?: Array<{
113
- op?: string;
114
- task?: string;
115
- phase?: string;
116
- items?: string[];
117
- }>;
107
+ type TodoRenderOp = {
108
+ op?: string;
109
+ task?: string;
110
+ phase?: string;
111
+ items?: string[];
112
+ };
113
+ /** New single-op shape `{op,...}`; legacy `{ops:[...]}` still seen in old transcripts. */
114
+ type TodoRenderArgs = TodoRenderOp & {
115
+ ops?: TodoRenderOp[];
118
116
  };
119
117
  /** One-based ASCII roman numeral for display (I, II, III, IV, …). */
120
118
  export declare function phaseRomanNumeral(oneBasedIndex: number): string;
@@ -26,6 +26,14 @@ export type FramedBlockComponent = Component & {
26
26
  };
27
27
  export declare function markFramedBlockComponent<T extends Component>(component: T): T & FramedBlockComponent;
28
28
  export declare function isFramedBlockComponent(component: Component): boolean;
29
+ /**
30
+ * Inner content width that {@link renderOutputBlock} wraps its body to, for a
31
+ * given outer `width`: both vertical borders (1 cell each) plus the left
32
+ * content padding. Renderers that size a tail window MUST budget visual rows
33
+ * against this, not the outer width — otherwise the block re-wraps their lines
34
+ * into more rows than they counted and the box overflows its intended height.
35
+ */
36
+ export declare function outputBlockContentWidth(width: number, contentPaddingLeft?: number): number;
29
37
  export declare function renderOutputBlock(options: OutputBlockOptions, theme: Theme): string[];
30
38
  /**
31
39
  * Cached wrapper around `renderOutputBlock`.
@@ -2,6 +2,8 @@ import type { ImageContent } from "@oh-my-pi/pi-ai";
2
2
  export interface ImageResizeOptions {
3
3
  maxWidth?: number;
4
4
  maxHeight?: number;
5
+ /** Smallest allowed edge length (px). Inputs below this are scaled up. */
6
+ minDimension?: number;
5
7
  maxBytes?: number;
6
8
  jpegQuality?: number;
7
9
  excludeWebP?: boolean;