@oh-my-pi/pi-coding-agent 15.2.4 → 15.3.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 (55) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/types/config/model-registry.d.ts +26 -0
  3. package/dist/types/config/settings-schema.d.ts +34 -1
  4. package/dist/types/config/settings.d.ts +6 -0
  5. package/dist/types/discovery/helpers.d.ts +1 -0
  6. package/dist/types/goals/runtime.d.ts +4 -0
  7. package/dist/types/modes/components/status-line/types.d.ts +10 -0
  8. package/dist/types/modes/components/status-line.d.ts +16 -0
  9. package/dist/types/modes/interactive-mode.d.ts +3 -1
  10. package/dist/types/modes/types.d.ts +3 -1
  11. package/dist/types/modes/utils/context-usage.d.ts +17 -0
  12. package/dist/types/modes/utils/ui-helpers.d.ts +5 -1
  13. package/dist/types/session/agent-session.d.ts +9 -0
  14. package/dist/types/session/session-manager.d.ts +10 -0
  15. package/dist/types/task/executor.d.ts +3 -1
  16. package/dist/types/task/types.d.ts +35 -0
  17. package/dist/types/tools/bash-command-fixup.d.ts +0 -5
  18. package/dist/types/utils/clipboard.d.ts +3 -1
  19. package/dist/types/utils/image-resize.d.ts +4 -1
  20. package/package.json +7 -7
  21. package/src/config/model-registry.ts +46 -21
  22. package/src/config/settings-schema.ts +29 -1
  23. package/src/config/settings.ts +19 -0
  24. package/src/discovery/helpers.ts +5 -1
  25. package/src/extensibility/plugins/legacy-pi-compat.ts +27 -5
  26. package/src/goals/runtime.ts +35 -13
  27. package/src/hashline/parser.ts +6 -1
  28. package/src/internal-urls/docs-index.generated.ts +2 -1
  29. package/src/main.ts +1 -1
  30. package/src/modes/components/model-selector.ts +53 -22
  31. package/src/modes/components/status-line/segments.ts +53 -0
  32. package/src/modes/components/status-line/types.ts +4 -0
  33. package/src/modes/components/status-line.ts +243 -15
  34. package/src/modes/controllers/command-controller.ts +9 -0
  35. package/src/modes/controllers/event-controller.ts +8 -0
  36. package/src/modes/interactive-mode.ts +23 -8
  37. package/src/modes/theme/theme.ts +1 -1
  38. package/src/modes/types.ts +1 -1
  39. package/src/modes/utils/context-usage.ts +42 -8
  40. package/src/modes/utils/ui-helpers.ts +11 -1
  41. package/src/prompts/agents/frontmatter.md +1 -0
  42. package/src/sdk.ts +24 -0
  43. package/src/session/agent-session.ts +70 -0
  44. package/src/session/session-manager.ts +119 -1
  45. package/src/slash-commands/builtin-registry.ts +15 -0
  46. package/src/task/executor.ts +50 -1
  47. package/src/task/index.ts +11 -0
  48. package/src/task/render.ts +26 -2
  49. package/src/task/types.ts +35 -0
  50. package/src/tools/bash-command-fixup.ts +0 -10
  51. package/src/tools/bash.ts +1 -9
  52. package/src/utils/clipboard.ts +79 -3
  53. package/src/utils/image-resize.ts +78 -30
  54. package/dist/types/modes/components/status-line-segment-editor.d.ts +0 -24
  55. package/src/modes/components/status-line-segment-editor.ts +0 -359
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [15.3.0] - 2026-05-25
6
+
7
+ ### Added
8
+
9
+ - Added `OMP_NO_WEBP` environment variable to disable WebP encoding in image resize, fixing HTTP 400 errors when attaching browser snapshots to vision models running on local llama.cpp (which uses STB library that lacks WebP support)
10
+ - Fixed loop mode submitting the next prompt while a background async-job delivery turn (idle flush) was still pending, which could cause the job result to be silently dropped and make the session appear to keep firing while work was ongoing ([#1294](https://github.com/can1357/oh-my-pi/issues/1294))
11
+ - Fixed clipboard image paste (Ctrl+V) silently failing on WSL2 by routing image reads through a `powershell.exe` bridge when WSL interop is detected, since `arboard` returns `ContentNotAvailable` under WSLg ([#1280](https://github.com/can1357/oh-my-pi/issues/1280))
12
+ - Fixed extension `ctx.ui.notify()` messages emitted during `session_start` being cleared before the first interactive render ([#1316](https://github.com/can1357/oh-my-pi/issues/1316)).
13
+ - Fixed append-only context mode not being recomputed after model switches — the mode was frozen at session construction time using the initial model's provider, so `provider.appendOnlyContext=auto` left append-only enabled after switching away from DeepSeek (or disabled after switching to DeepSeek) for the rest of the session
14
+
15
+ ### Fixed
16
+ - Fixed clipboard image paste (Ctrl+V) silently failing on WSL2 by routing image reads through a `powershell.exe` bridge when WSL interop is detected, since `arboard` returns `ContentNotAvailable` under WSLg ([#1280](https://github.com/can1357/oh-my-pi/issues/1280))
5
17
  ## [15.2.4] - 2026-05-22
6
18
  ### Breaking Changes
7
19
 
@@ -114,6 +126,10 @@
114
126
  - Fixed streaming edit previews for `apply_patch` and `hashline` jittering as the model typed `+added` lines. Two root causes addressed: (1) the trailing partial line of the streaming text input is now trimmed at each tick so a half-typed `+added` line no longer flickers; (2) the preview is rendered in the model's input order during streaming instead of re-deriving a unified diff via `Diff.structuredPatch`, whose coalescing previously reshuffled existing `+added` lines downward each time a new `-removed` line arrived. Existing additions now stay put and the preview only grows at the bottom while streaming. A residual trailing `-removed`/hunk-header block whose matching `+added` companion has not yet arrived is also suppressed until the additions land.
115
127
  - Fixed Perplexity web search appearing "logged out" roughly an hour after `omp auth login perplexity`. The search provider's `findOAuthToken` was honoring the bogus `expires = login_time + 1h` written by older logins (Perplexity JWTs typically omit `exp` because sessions are server-side) and silently dropping the credential. The loader now decodes the JWT's `exp` claim directly and only skips when the JWT itself is expired; tokens without an `exp` claim are treated as non-expiring.
116
128
 
129
+ ### Fixed
130
+
131
+ - Fixed `legacy-pi-compat` failing to load plugin extensions (e.g. `pi-schedule-prompt@0.3.0`) that import `@mariozechner/pi-ai` when running from a compiled binary. `getResolvedSpecifier` called `Bun.resolveSync` against `import.meta.dir` inside `/$bunfs/root`, where the virtual FS exposes no resolvable `node_modules` tree at runtime; the throw silently dropped the plugin. The fix lets `rewriteLegacyPiImports` fall back gracefully on resolution failure so that `rewriteBareImportsForLegacyExtension` — which already runs immediately after — can resolve the original specifier against the plugin's own installed peer deps instead. The same fallback is applied to `resolveLegacyPiSpecifier` (the Bun plugin shim's `onResolve` handler) for tool/hook files loaded directly via Bun's import system. ([#1215](https://github.com/can1357/oh-my-pi/issues/1215))
132
+
117
133
  ## [15.1.7] - 2026-05-19
118
134
 
119
135
  ### Fixed
@@ -122,6 +138,9 @@
122
138
  - Fixed hashline edit payloads that use a readability space after `~` by warning on separator-padding-shaped payload blocks and tightening the model prompt. ([#1166](https://github.com/can1357/oh-my-pi/issues/1166))
123
139
  - Fixed ACP bash permission requests to include execute tool metadata and command content so clients can render command approval prompts consistently. ([#1189](https://github.com/can1357/oh-my-pi/issues/1189))
124
140
  - Fixed the status-line fast-mode indicator (`⚡`) rendering for scoped service tiers (`openai-only`, `claude-only`) even when the active model's provider didn't realize them — e.g. `serviceTier: "openai-only"` would still show the indicator next to a Claude model the wire request couldn't apply fast mode to. The indicator now consults a new `AgentSession.isFastModeActive()` predicate that runs the configured tier through `resolveServiceTier(tier, model.provider)` and only lights up when the result is `"priority"` for the current model. `isFastModeEnabled()` keeps its scope-aware semantics so `/fast on|off|toggle` and `/fast status` continue to reflect the user's configured intent.
141
+ ### Fixed
142
+
143
+ - Fixed status-line context% computation freezing the UI for ~1.1 s every 2 s on long sessions (2,000+ messages). The earlier alignment fix (which uses `computeContextBreakdown` to match the `/context` slash command) was running on every agent event via `updateEditorTopBorder()` (event-controller.ts:163), and `computeContextBreakdown` walks every message through the native `countTokens` tokenizer (~0.5 ms each) — for the user's 2,312-message session this was ~1,120 ms synchronous blocking per cache miss, producing the user-visible "jittery rendering" and "status bar disappearing during streaming". `StatusLineComponent.getCachedContextBreakdown()` now uses an incremental per-message token cache: messages are walked ONCE during warm-up, and subsequent refreshes only compute tokens for the NEW messages appended since last call (typically 0–1 per refresh during streaming). The LAST message is always recomputed because its content may still be growing mid-stream; all prior messages are immutable once a newer message exists. Compaction (messages array shrinks) resets the cache. Non-message tokens (system prompt + tools + skills) are cached separately and invalidated via a cheap identity fingerprint. Result: 2,300-message warm refresh drops from ~1,120 ms to ~0.04 ms — 28,000× faster. Functional parity with the prior `computeContextBreakdown` path is preserved.
125
144
 
126
145
  ### Added
127
146
 
@@ -156,6 +175,7 @@
156
175
  - Fixed `deferAgentInitiatedTurns` handling during ACP async-job draining so background completion follow-up turns are delivered even when agent-initiated turns are deferred
157
176
  - Fixed ACP ordinary file-editing calls (`edit`, `write`, `ast_edit`) incorrectly requesting `session/request_permission` before every call, while keeping permission prompts for edit operations that delete or move files; permission requests now report the gated tool call as `pending` so clients can render the approval UI instead of returning `Permission request cancelled` without a visible prompt. ([#1134](https://github.com/can1357/oh-my-pi/pull/1134) by [@jiwangyihao](https://github.com/jiwangyihao))
158
177
  - Fixed the session tree selector to preserve a readable message column when deeply nested branch gutters would otherwise consume the viewport. ([#1144](https://github.com/can1357/oh-my-pi/issues/1144))
178
+ - Fixed the TUI model selector to keep provider tab labels separate from provider ids, so the human-readable Ollama Cloud tab refreshes and filters `ollama-cloud` models correctly. ([#1153](https://github.com/can1357/oh-my-pi/issues/1153))
159
179
 
160
180
  ## [15.1.3] - 2026-05-17
161
181
  ### Breaking Changes
@@ -213,6 +213,32 @@ export declare const ModelsConfigFile: ConfigFile<{
213
213
  exclude?: string[] | undefined;
214
214
  } | undefined;
215
215
  }>;
216
+ /** Provider override config (baseUrl, headers, apiKey, compat, transport) without custom models */
217
+ interface ProviderOverride {
218
+ baseUrl?: string;
219
+ headers?: Record<string, string>;
220
+ apiKey?: string;
221
+ authHeader?: boolean;
222
+ compat?: Model<Api>["compat"];
223
+ transport?: Model<Api>["transport"];
224
+ }
225
+ /**
226
+ * Merge a freshly discovered model with the matching bundled/configured entry
227
+ * (or a runtime provider override when no bundled entry exists).
228
+ *
229
+ * `baseUrl` resolution priority:
230
+ * 1. User-set `providerOverride.baseUrl` (explicit override in models.json)
231
+ * 2. Discovered baseUrl (xiaomi `tp-` token-plan keys resolve to
232
+ * `token-plan-sgp.xiaomimimo.com` at discovery time)
233
+ * 3. Existing bundled baseUrl (the host baked into `models.json`)
234
+ *
235
+ * Without (1), the user's override would lose to discovery; without (2)
236
+ * preferred over (3), the bundled `api.xiaomimimo.com` would shadow the
237
+ * tp- token-plan host and produce 401s on the first stream call.
238
+ * See `xiaomi-tp-discovery-merge.test.ts` and the `refresh()` baseUrl-override
239
+ * regression in `model-registry.test.ts`.
240
+ */
241
+ export declare function mergeDiscoveredModel<TApi extends Api>(model: Model<TApi>, existing: Model<Api> | undefined, providerOverride?: Pick<ProviderOverride, "baseUrl" | "headers" | "transport">): Model<TApi>;
216
242
  export type ProviderDiscoveryStatus = "idle" | "ok" | "empty" | "cached" | "unavailable" | "unauthenticated";
217
243
  export interface ProviderDiscoveryState {
218
244
  provider: string;
@@ -23,7 +23,7 @@ export declare const TAB_METADATA: Record<SettingTab, {
23
23
  icon: `tab.${string}`;
24
24
  }>;
25
25
  /** Status line segment identifiers */
26
- export type StatusLineSegmentId = "pi" | "model" | "mode" | "path" | "git" | "pr" | "subagents" | "token_in" | "token_out" | "token_total" | "token_rate" | "cost" | "context_pct" | "context_total" | "time_spent" | "time" | "session" | "hostname" | "cache_read" | "cache_write" | "session_name";
26
+ export type StatusLineSegmentId = "pi" | "model" | "mode" | "path" | "git" | "pr" | "subagents" | "token_in" | "token_out" | "token_total" | "token_rate" | "cost" | "context_pct" | "context_total" | "time_spent" | "time" | "session" | "hostname" | "cache_read" | "cache_write" | "session_name" | "usage";
27
27
  /** Submenu choice metadata. */
28
28
  export type SubmenuOption<V extends string = string> = {
29
29
  value: V;
@@ -991,6 +991,15 @@ export declare const SETTINGS_SCHEMA: {
991
991
  readonly type: "number";
992
992
  readonly default: 2000;
993
993
  };
994
+ readonly "retry.maxDelayMs": {
995
+ readonly type: "number";
996
+ readonly default: number;
997
+ readonly ui: {
998
+ readonly tab: "model";
999
+ readonly label: "Max Retry Delay";
1000
+ readonly description: "Maximum wait between retries, in ms. When the provider asks us to wait longer than this and no credential or model fallback succeeds, the request fails fast instead of sleeping (e.g. 3-hour Anthropic rate-limit windows).";
1001
+ };
1002
+ };
994
1003
  readonly "retry.fallbackChains": {
995
1004
  readonly type: "record";
996
1005
  readonly default: Record<string, string[]>;
@@ -3075,6 +3084,29 @@ export declare const SETTINGS_SCHEMA: {
3075
3084
  readonly description: "Use Parallel extract API for URL fetching when credentials are available";
3076
3085
  };
3077
3086
  };
3087
+ readonly "provider.appendOnlyContext": {
3088
+ readonly type: "enum";
3089
+ readonly values: readonly ["auto", "on", "off"];
3090
+ readonly default: "auto";
3091
+ readonly ui: {
3092
+ readonly tab: "providers";
3093
+ readonly label: "Append-Only Context";
3094
+ readonly description: "Cache system prompt + tool specs and keep an append-only message log so provider prefix caches (DeepSeek, Anthropic) hit at maximum rate. Auto enables for DeepSeek.";
3095
+ readonly options: readonly [{
3096
+ readonly value: "auto";
3097
+ readonly label: "Auto";
3098
+ readonly description: "Enable for DeepSeek (recommended)";
3099
+ }, {
3100
+ readonly value: "on";
3101
+ readonly label: "On";
3102
+ readonly description: "Always enable append-only context";
3103
+ }, {
3104
+ readonly value: "off";
3105
+ readonly label: "Off";
3106
+ readonly description: "Disable append-only context";
3107
+ }];
3108
+ };
3109
+ };
3078
3110
  readonly "exa.enabled": {
3079
3111
  readonly type: "boolean";
3080
3112
  readonly default: true;
@@ -3283,6 +3315,7 @@ export interface RetrySettings {
3283
3315
  enabled: boolean;
3284
3316
  maxRetries: number;
3285
3317
  baseDelayMs: number;
3318
+ maxDelayMs: number;
3286
3319
  }
3287
3320
  export interface MemoriesSettings {
3288
3321
  enabled: boolean;
@@ -113,6 +113,12 @@ export declare class Settings {
113
113
  */
114
114
  setDisabledProviders(ids: string[]): void;
115
115
  }
116
+ /**
117
+ * Subscribe to append-only mode setting changes.
118
+ * Returns an unsubscribe function. Multiple sessions (main + subagents)
119
+ * can register independently without overwriting each other.
120
+ */
121
+ export declare function onAppendOnlyModeChanged(cb: (value: string) => void): () => void;
116
122
  export declare function isSettingsInitialized(): boolean;
117
123
  /**
118
124
  * Reset the global singleton for testing.
@@ -101,6 +101,7 @@ export interface ParsedAgentFields {
101
101
  model?: string[];
102
102
  output?: unknown;
103
103
  thinkingLevel?: ThinkingLevel;
104
+ autoloadSkills?: string[];
104
105
  blocking?: boolean;
105
106
  }
106
107
  /**
@@ -54,6 +54,10 @@ export declare class GoalRuntime {
54
54
  objective: string;
55
55
  tokenBudget?: number;
56
56
  }): Promise<GoalModeState>;
57
+ replaceGoal(input: {
58
+ objective: string;
59
+ tokenBudget?: number;
60
+ }): Promise<GoalModeState>;
57
61
  resumeGoal(): Promise<GoalModeState>;
58
62
  pauseGoal(): Promise<GoalModeState | undefined>;
59
63
  dropGoal(): Promise<Goal | undefined>;
@@ -44,6 +44,16 @@ export interface SegmentContext {
44
44
  url: string;
45
45
  } | null;
46
46
  };
47
+ usage: {
48
+ fiveHour?: {
49
+ percent: number;
50
+ resetMinutes?: number;
51
+ };
52
+ sevenDay?: {
53
+ percent: number;
54
+ resetHours?: number;
55
+ };
56
+ } | null;
47
57
  }
48
58
  export interface RenderedSegment {
49
59
  content: string;
@@ -53,6 +53,22 @@ export declare class StatusLineComponent implements Component {
53
53
  watchBranch(onBranchChange: () => void): void;
54
54
  dispose(): void;
55
55
  invalidate(): void;
56
+ /**
57
+ * Background-refresh the Anthropic OAuth quota report. Guarded by a 5-min
58
+ * TTL on both success (cache lifetime) and error (backoff). Exposed
59
+ * (non-private) so unit tests can verify the backoff invariant.
60
+ */
61
+ refreshUsageInBackground(): void;
62
+ /**
63
+ * Compute the (cached) used-tokens / context-window totals for the
64
+ * status-line context% segment. Exposed (non-private) so unit tests can
65
+ * verify the incremental-cache invariants; not part of any external
66
+ * API.
67
+ */
68
+ getCachedContextBreakdown(): {
69
+ usedTokens: number;
70
+ contextWindow: number;
71
+ };
56
72
  getTopBorder(width: number): {
57
73
  content: string;
58
74
  width: number;
@@ -171,7 +171,9 @@ export declare class InteractiveMode implements InteractiveModeContext {
171
171
  updateFooter?: boolean;
172
172
  populateHistory?: boolean;
173
173
  }): void;
174
- renderInitialMessages(prebuiltContext?: SessionContext): void;
174
+ renderInitialMessages(prebuiltContext?: SessionContext, options?: {
175
+ preserveExistingChat?: boolean;
176
+ }): void;
175
177
  getUserMessageText(message: Message): string;
176
178
  findLastAssistantMessage(): AssistantMessage | undefined;
177
179
  extractAssistantText(message: AssistantMessage): string;
@@ -168,7 +168,9 @@ export interface InteractiveModeContext {
168
168
  updateFooter?: boolean;
169
169
  populateHistory?: boolean;
170
170
  }): void;
171
- renderInitialMessages(prebuiltContext?: SessionContext): void;
171
+ renderInitialMessages(prebuiltContext?: SessionContext, options?: {
172
+ preserveExistingChat?: boolean;
173
+ }): void;
172
174
  getUserMessageText(message: Message): string;
173
175
  findLastAssistantMessage(): AssistantMessage | undefined;
174
176
  extractAssistantText(message: AssistantMessage): string;
@@ -1,5 +1,7 @@
1
1
  import type { Model } from "@oh-my-pi/pi-ai";
2
+ import type { Skill } from "../../extensibility/skills";
2
3
  import type { AgentSession } from "../../session/agent-session";
4
+ import type { Tool } from "../../tools";
3
5
  import type { theme as Theme } from "../theme/theme";
4
6
  type CategoryId = "systemPrompt" | "systemContext" | "systemTools" | "skills" | "messages";
5
7
  interface CategoryInfo {
@@ -17,6 +19,21 @@ export interface ContextBreakdown {
17
19
  autoCompactBufferTokens: number;
18
20
  freeTokens: number;
19
21
  }
22
+ export declare function estimateSkillsTokens(skills: readonly Skill[]): number;
23
+ export declare function estimateToolSchemaTokens(tools: ReadonlyArray<Pick<Tool, "name" | "description" | "parameters">>): number;
24
+ /**
25
+ * Compute just the NON-MESSAGE token total: system prompt (with its skills
26
+ * section subtracted, since skills are tokenized separately) + system context
27
+ * (the rest of the system-prompt array) + tools + skills.
28
+ *
29
+ * Exposed so callers like `StatusLineComponent` can cache the non-message
30
+ * total separately from the message total. Non-message inputs (skills,
31
+ * tools, system prompt) change rarely; the message list grows on every
32
+ * streaming turn. Splitting the two lets the caller refresh each on its own
33
+ * cadence — non-message recomputed only when the inputs identity changes,
34
+ * messages walked incrementally as new entries append.
35
+ */
36
+ export declare function computeNonMessageTokens(session: AgentSession): number;
20
37
  /**
21
38
  * Compute a breakdown of estimated context usage by category for the active
22
39
  * session and model.
@@ -3,6 +3,9 @@ import type { AssistantMessage, Message } from "@oh-my-pi/pi-ai";
3
3
  import { type Component } from "@oh-my-pi/pi-tui";
4
4
  import type { InteractiveModeContext } from "../../modes/types";
5
5
  import type { SessionContext } from "../../session/session-manager";
6
+ interface RenderInitialMessagesOptions {
7
+ preserveExistingChat?: boolean;
8
+ }
6
9
  export declare class UiHelpers {
7
10
  #private;
8
11
  private ctx;
@@ -31,7 +34,7 @@ export declare class UiHelpers {
31
34
  updateFooter?: boolean;
32
35
  populateHistory?: boolean;
33
36
  }): void;
34
- renderInitialMessages(prebuiltContext?: SessionContext): void;
37
+ renderInitialMessages(prebuiltContext?: SessionContext, options?: RenderInitialMessagesOptions): void;
35
38
  clearEditor(): void;
36
39
  showError(errorMessage: string): void;
37
40
  showWarning(warningMessage: string): void;
@@ -47,3 +50,4 @@ export declare class UiHelpers {
47
50
  findLastAssistantMessage(): AssistantMessage | undefined;
48
51
  extractAssistantText(message: AssistantMessage): string;
49
52
  }
53
+ export {};
@@ -417,6 +417,15 @@ export declare class AgentSession {
417
417
  refreshRpcHostTools(rpcTools: AgentTool[]): Promise<void>;
418
418
  /** Whether auto-compaction is currently running */
419
419
  get isCompacting(): boolean;
420
+ /**
421
+ * Whether idle-flush tasks, auto-continuations, or other short-lived
422
+ * post-prompt work are pending. True in the brief window after
423
+ * `session.prompt()` returns but before a scheduled background delivery
424
+ * (e.g. an async-job result) has finished its own streaming turn.
425
+ * Loop-mode and similar auto-submit paths should treat this as a block
426
+ * to avoid racing against the delivery turn.
427
+ */
428
+ get hasPostPromptWork(): boolean;
420
429
  /** All messages including custom types like BashExecutionMessage */
421
430
  get messages(): AgentMessage[];
422
431
  buildDisplaySessionContext(): SessionContext;
@@ -214,6 +214,16 @@ declare class RecentSessionInfo {
214
214
  /** Human-readable relative time (e.g., "2 hours ago") */
215
215
  get timeAgo(): string;
216
216
  }
217
+ /**
218
+ * Promote orphaned `<basename>.jsonl.<snowflake>.bak` backups created by
219
+ * `#replaceSessionFileAfterEperm` back to their primary path when the primary
220
+ * is missing. This runs once per session-dir scan, before the main `*.jsonl`
221
+ * glob, so a crash between the two renames in the EPERM-rewrite path does not
222
+ * leave the user's last good state stranded outside the loader's view.
223
+ *
224
+ * Exported for testing.
225
+ */
226
+ export declare function recoverOrphanedBackups(sessionDir: string, storage: SessionStorage): Promise<void>;
217
227
  /** Exported for testing */
218
228
  export declare function findMostRecentSession(sessionDir: string, storage?: SessionStorage): Promise<string | null>;
219
229
  /** Get recent sessions for display in welcome screen */
@@ -7,7 +7,7 @@ import type { AgentTelemetryConfig, ThinkingLevel } from "@oh-my-pi/pi-agent-cor
7
7
  import { ModelRegistry } from "../config/model-registry";
8
8
  import type { PromptTemplate } from "../config/prompt-templates";
9
9
  import { Settings } from "../config/settings";
10
- import type { Skill } from "../extensibility/skills";
10
+ import { type Skill } from "../extensibility/skills";
11
11
  import type { HindsightSessionState } from "../hindsight/state";
12
12
  import type { LocalProtocolOptions } from "../internal-urls";
13
13
  import type { MCPManager } from "../mcp/manager";
@@ -73,6 +73,8 @@ export interface ExecutorOptions {
73
73
  * transition explicitly.
74
74
  */
75
75
  parentTelemetry?: AgentTelemetryConfig;
76
+ /** Skills to autoload via sendCustomMessage before the first prompt */
77
+ autoloadSkills?: Skill[];
76
78
  }
77
79
  export interface YieldItem {
78
80
  data?: unknown;
@@ -148,6 +148,7 @@ export interface AgentDefinition {
148
148
  thinkingLevel?: ThinkingLevel;
149
149
  output?: unknown;
150
150
  blocking?: boolean;
151
+ autoloadSkills?: string[];
151
152
  source: AgentSource;
152
153
  filePath?: string;
153
154
  }
@@ -189,6 +190,30 @@ export interface AgentProgress {
189
190
  modelOverride?: string | string[];
190
191
  /** Data extracted by registered subprocess tool handlers (keyed by tool name) */
191
192
  extractedToolData?: Record<string, unknown[]>;
193
+ /**
194
+ * Auto-retry state when the subagent is sleeping between provider retries
195
+ * (e.g. 429 rate-limit with retry-after). Cleared when the retry resolves
196
+ * or fails. Surfacing this to the parent prevents the task tool from
197
+ * looking indefinitely "in progress" when a child is actually blocked on
198
+ * provider quota.
199
+ */
200
+ retryState?: {
201
+ attempt: number;
202
+ maxAttempts: number;
203
+ delayMs: number;
204
+ errorMessage: string;
205
+ startedAtMs: number;
206
+ };
207
+ /**
208
+ * Terminal retry failure surfaced once the subagent gave up retrying
209
+ * (e.g. retry-after exceeded the cap, or all attempts exhausted). Carries
210
+ * the final error so the parent UI can render "blocked: rate-limited"
211
+ * instead of waiting for a status that never arrives.
212
+ */
213
+ retryFailure?: {
214
+ attempt: number;
215
+ errorMessage: string;
216
+ };
192
217
  }
193
218
  /** Result from a single agent execution */
194
219
  export interface SingleResult {
@@ -227,6 +252,16 @@ export interface SingleResult {
227
252
  nestedPatches?: NestedRepoPatch[];
228
253
  /** Data extracted by registered subprocess tool handlers (keyed by tool name) */
229
254
  extractedToolData?: Record<string, unknown[]>;
255
+ /**
256
+ * Terminal retry failure, when the subagent exited because the auto-retry
257
+ * loop gave up (retry-after exceeded the cap, or all attempts exhausted).
258
+ * Lets the parent task tool surface a "blocked: rate-limited" outcome
259
+ * instead of a generic failure.
260
+ */
261
+ retryFailure?: {
262
+ attempt: number;
263
+ errorMessage: string;
264
+ };
230
265
  /** Output metadata for agent:// URL integration */
231
266
  outputMeta?: {
232
267
  lineCount: number;
@@ -9,8 +9,3 @@ export interface BashFixupResult {
9
9
  * or no-op transform, returns the input verbatim with `stripped: []`.
10
10
  */
11
11
  export declare function applyBashFixups(command: string): BashFixupResult;
12
- /**
13
- * Human-readable notice for the fixups that fired. Mirrors the shape of
14
- * `formatTimeoutClampNotice` so it can ride alongside the other bash notices.
15
- */
16
- export declare function formatBashFixupNotice(stripped: readonly string[]): string | undefined;
@@ -13,7 +13,9 @@ export declare function copyToClipboard(text: string): Promise<void>;
13
13
  * Read an image from the system clipboard.
14
14
  *
15
15
  * Returns null on Termux (no image clipboard support) or when no display
16
- * server is available (headless/SSH without forwarding).
16
+ * server is available (headless/SSH without forwarding). Under WSL the
17
+ * Windows clipboard is reached through `powershell.exe`, since WSLg's
18
+ * Wayland clipboard does not carry image payloads through to `arboard`.
17
19
  *
18
20
  * @returns PNG payload or null when no image is available.
19
21
  */
@@ -4,6 +4,7 @@ export interface ImageResizeOptions {
4
4
  maxHeight?: number;
5
5
  maxBytes?: number;
6
6
  jpegQuality?: number;
7
+ excludeWebP?: boolean;
7
8
  }
8
9
  export interface ResizedImage {
9
10
  buffer: Uint8Array;
@@ -20,11 +21,13 @@ export interface ResizedImage {
20
21
  *
21
22
  * Strategy:
22
23
  * 1. Probe metadata. If already within all limits, return original.
23
- * 2. Resize to fit max dimensions and encode at high quality across PNG/JPEG/WebP — return smallest.
24
+ * 2. Resize to fit max dimensions and encode at high quality across PNG/JPEG (+ WebP) — return smallest.
24
25
  * 3. If still too large, walk a lossy JPEG/WebP quality ladder.
25
26
  * 4. If still too large, walk a dimension-scale ladder × quality ladder.
26
27
  * 5. If still too large, return the smallest variant produced.
27
28
  *
29
+ * Set OMP_NO_WEBP to exclude WebP from encoding (llama.cpp STB doesn't decode it).
30
+ *
28
31
  * Backed by `Bun.Image`: a chainable native pipeline that runs decode/transform/encode
29
32
  * off the JS thread when the terminal (`.bytes()`) is awaited.
30
33
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-coding-agent",
4
- "version": "15.2.4",
4
+ "version": "15.3.1",
5
5
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -47,12 +47,12 @@
47
47
  "@agentclientprotocol/sdk": "0.21.0",
48
48
  "@babel/parser": "^7.29.3",
49
49
  "@mozilla/readability": "^0.6.0",
50
- "@oh-my-pi/omp-stats": "15.2.4",
51
- "@oh-my-pi/pi-agent-core": "15.2.4",
52
- "@oh-my-pi/pi-ai": "15.2.4",
53
- "@oh-my-pi/pi-natives": "15.2.4",
54
- "@oh-my-pi/pi-tui": "15.2.4",
55
- "@oh-my-pi/pi-utils": "15.2.4",
50
+ "@oh-my-pi/omp-stats": "15.3.1",
51
+ "@oh-my-pi/pi-agent-core": "15.3.1",
52
+ "@oh-my-pi/pi-ai": "15.3.1",
53
+ "@oh-my-pi/pi-natives": "15.3.1",
54
+ "@oh-my-pi/pi-tui": "15.3.1",
55
+ "@oh-my-pi/pi-utils": "15.3.1",
56
56
  "@puppeteer/browsers": "^2.13.0",
57
57
  "@types/turndown": "5.0.6",
58
58
  "@xterm/headless": "^6.0.0",
@@ -252,6 +252,45 @@ interface ProviderOverride {
252
252
  transport?: Model<Api>["transport"];
253
253
  }
254
254
 
255
+ /**
256
+ * Merge a freshly discovered model with the matching bundled/configured entry
257
+ * (or a runtime provider override when no bundled entry exists).
258
+ *
259
+ * `baseUrl` resolution priority:
260
+ * 1. User-set `providerOverride.baseUrl` (explicit override in models.json)
261
+ * 2. Discovered baseUrl (xiaomi `tp-` token-plan keys resolve to
262
+ * `token-plan-sgp.xiaomimimo.com` at discovery time)
263
+ * 3. Existing bundled baseUrl (the host baked into `models.json`)
264
+ *
265
+ * Without (1), the user's override would lose to discovery; without (2)
266
+ * preferred over (3), the bundled `api.xiaomimimo.com` would shadow the
267
+ * tp- token-plan host and produce 401s on the first stream call.
268
+ * See `xiaomi-tp-discovery-merge.test.ts` and the `refresh()` baseUrl-override
269
+ * regression in `model-registry.test.ts`.
270
+ */
271
+ export function mergeDiscoveredModel<TApi extends Api>(
272
+ model: Model<TApi>,
273
+ existing: Model<Api> | undefined,
274
+ providerOverride?: Pick<ProviderOverride, "baseUrl" | "headers" | "transport">,
275
+ ): Model<TApi> {
276
+ if (existing) {
277
+ return {
278
+ ...model,
279
+ baseUrl: providerOverride?.baseUrl ?? model.baseUrl ?? existing.baseUrl,
280
+ headers: existing.headers ? { ...existing.headers, ...model.headers } : model.headers,
281
+ };
282
+ }
283
+ if (providerOverride) {
284
+ return {
285
+ ...model,
286
+ baseUrl: providerOverride.baseUrl ?? model.baseUrl,
287
+ headers: providerOverride.headers ? { ...model.headers, ...providerOverride.headers } : model.headers,
288
+ ...(providerOverride.transport !== undefined ? { transport: providerOverride.transport } : {}),
289
+ };
290
+ }
291
+ return model;
292
+ }
293
+
255
294
  interface DiscoveryProviderConfig {
256
295
  provider: string;
257
296
  api: Api;
@@ -1182,27 +1221,13 @@ export class ModelRegistry {
1182
1221
  return;
1183
1222
  }
1184
1223
  const discoveredModels = this.#applyHardcodedModelPolicies(
1185
- discovered.map(model => {
1186
- const existing = this.find(model.provider, model.id);
1187
- if (existing) {
1188
- return {
1189
- ...model,
1190
- baseUrl: existing.baseUrl,
1191
- headers: existing.headers ? { ...existing.headers, ...model.headers } : model.headers,
1192
- };
1193
- }
1194
- const providerOverride = this.#providerOverrides.get(model.provider);
1195
- return providerOverride
1196
- ? {
1197
- ...model,
1198
- baseUrl: providerOverride.baseUrl ?? model.baseUrl,
1199
- headers: providerOverride.headers
1200
- ? { ...model.headers, ...providerOverride.headers }
1201
- : model.headers,
1202
- ...(providerOverride.transport !== undefined ? { transport: providerOverride.transport } : {}),
1203
- }
1204
- : model;
1205
- }),
1224
+ discovered.map(model =>
1225
+ mergeDiscoveredModel(
1226
+ model,
1227
+ this.find(model.provider, model.id),
1228
+ this.#providerOverrides.get(model.provider),
1229
+ ),
1230
+ ),
1206
1231
  );
1207
1232
  const resolved = this.#mergeResolvedModels(this.#models, discoveredModels);
1208
1233
  const withConfigModels = this.#mergeCustomModels(resolved, this.#customModelOverlays);
@@ -81,7 +81,8 @@ export type StatusLineSegmentId =
81
81
  | "hostname"
82
82
  | "cache_read"
83
83
  | "cache_write"
84
- | "session_name";
84
+ | "session_name"
85
+ | "usage";
85
86
 
86
87
  /** Submenu choice metadata. */
87
88
  export type SubmenuOption<V extends string = string> = {
@@ -836,6 +837,16 @@ export const SETTINGS_SCHEMA = {
836
837
  },
837
838
 
838
839
  "retry.baseDelayMs": { type: "number", default: 2000 },
840
+ "retry.maxDelayMs": {
841
+ type: "number",
842
+ default: 5 * 60 * 1000,
843
+ ui: {
844
+ tab: "model",
845
+ label: "Max Retry Delay",
846
+ description:
847
+ "Maximum wait between retries, in ms. When the provider asks us to wait longer than this and no credential or model fallback succeeds, the request fails fast instead of sleeping (e.g. 3-hour Anthropic rate-limit windows).",
848
+ },
849
+ },
839
850
  "retry.fallbackChains": { type: "record", default: {} as Record<string, string[]> },
840
851
  "retry.fallbackRevertPolicy": {
841
852
  type: "enum",
@@ -2612,6 +2623,22 @@ export const SETTINGS_SCHEMA = {
2612
2623
  description: "Use Parallel extract API for URL fetching when credentials are available",
2613
2624
  },
2614
2625
  },
2626
+ "provider.appendOnlyContext": {
2627
+ type: "enum",
2628
+ values: ["auto", "on", "off"] as const,
2629
+ default: "auto",
2630
+ ui: {
2631
+ tab: "providers",
2632
+ label: "Append-Only Context",
2633
+ description:
2634
+ "Cache system prompt + tool specs and keep an append-only message log so provider prefix caches (DeepSeek, Anthropic) hit at maximum rate. Auto enables for DeepSeek.",
2635
+ options: [
2636
+ { value: "auto", label: "Auto", description: "Enable for DeepSeek (recommended)" },
2637
+ { value: "on", label: "On", description: "Always enable append-only context" },
2638
+ { value: "off", label: "Off", description: "Disable append-only context" },
2639
+ ],
2640
+ },
2641
+ },
2615
2642
 
2616
2643
  // Exa
2617
2644
  "exa.enabled": {
@@ -2843,6 +2870,7 @@ export interface RetrySettings {
2843
2870
  enabled: boolean;
2844
2871
  maxRetries: number;
2845
2872
  baseDelayMs: number;
2873
+ maxDelayMs: number;
2846
2874
  }
2847
2875
 
2848
2876
  export interface MemoriesSettings {