@oh-my-pi/pi-coding-agent 17.0.0 → 17.0.2

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 (202) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/dist/cli.js +4006 -3966
  3. package/dist/types/advisor/advise-tool.d.ts +5 -2
  4. package/dist/types/advisor/config.d.ts +14 -6
  5. package/dist/types/advisor/runtime.d.ts +20 -11
  6. package/dist/types/autolearn/controller.d.ts +1 -0
  7. package/dist/types/cli-commands.d.ts +14 -1
  8. package/dist/types/config/model-discovery.d.ts +17 -0
  9. package/dist/types/config/model-registry.d.ts +4 -0
  10. package/dist/types/config/model-resolver.d.ts +6 -2
  11. package/dist/types/config/models-config-schema.d.ts +10 -0
  12. package/dist/types/config/models-config.d.ts +6 -0
  13. package/dist/types/config/settings-schema.d.ts +32 -7
  14. package/dist/types/config/settings.d.ts +50 -0
  15. package/dist/types/cursor.d.ts +11 -0
  16. package/dist/types/discovery/helpers.d.ts +5 -2
  17. package/dist/types/discovery/substitute-plugin-root.d.ts +20 -7
  18. package/dist/types/exec/bash-executor.d.ts +2 -0
  19. package/dist/types/extensibility/extensions/managed-timers.d.ts +15 -0
  20. package/dist/types/extensibility/extensions/runner.d.ts +7 -0
  21. package/dist/types/extensibility/extensions/types.d.ts +18 -0
  22. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +40 -0
  23. package/dist/types/extensibility/shared-events.d.ts +6 -0
  24. package/dist/types/extensibility/utils.d.ts +2 -2
  25. package/dist/types/internal-urls/agent-protocol.d.ts +1 -0
  26. package/dist/types/lib/xai-http.d.ts +11 -0
  27. package/dist/types/mcp/transports/stdio.d.ts +13 -1
  28. package/dist/types/modes/acp/acp-agent.d.ts +3 -0
  29. package/dist/types/modes/acp/acp-mode.d.ts +6 -2
  30. package/dist/types/modes/components/advisor-config.d.ts +8 -1
  31. package/dist/types/modes/components/assistant-message.d.ts +2 -0
  32. package/dist/types/modes/components/custom-editor-plugin-ctor.test.d.ts +1 -0
  33. package/dist/types/modes/components/custom-editor.d.ts +23 -1
  34. package/dist/types/modes/components/hook-editor.d.ts +16 -2
  35. package/dist/types/modes/components/login-dialog.test.d.ts +1 -0
  36. package/dist/types/modes/components/model-hub.d.ts +5 -2
  37. package/dist/types/modes/components/session-selector.d.ts +4 -0
  38. package/dist/types/modes/components/tool-execution.d.ts +8 -1
  39. package/dist/types/modes/components/tool-execution.test.d.ts +1 -0
  40. package/dist/types/modes/controllers/command-controller.d.ts +8 -0
  41. package/dist/types/modes/controllers/selector-controller.d.ts +3 -1
  42. package/dist/types/modes/interactive-mode.d.ts +6 -0
  43. package/dist/types/modes/noninteractive-dispose.test.d.ts +1 -0
  44. package/dist/types/modes/print-mode.d.ts +1 -1
  45. package/dist/types/modes/types.d.ts +10 -0
  46. package/dist/types/modes/utils/transcript-render-helpers.d.ts +2 -2
  47. package/dist/types/modes/warp-events.d.ts +24 -0
  48. package/dist/types/modes/warp-events.test.d.ts +1 -0
  49. package/dist/types/plan-mode/model-transition.d.ts +47 -0
  50. package/dist/types/plan-mode/model-transition.test.d.ts +1 -0
  51. package/dist/types/registry/agent-lifecycle.d.ts +26 -1
  52. package/dist/types/sdk.d.ts +13 -2
  53. package/dist/types/session/agent-session.d.ts +43 -11
  54. package/dist/types/session/session-history-format.d.ts +10 -0
  55. package/dist/types/session/session-manager.d.ts +14 -0
  56. package/dist/types/session/streaming-output.d.ts +2 -0
  57. package/dist/types/slash-commands/helpers/active-oauth-account.d.ts +9 -0
  58. package/dist/types/slash-commands/types.d.ts +4 -4
  59. package/dist/types/system-prompt.d.ts +1 -1
  60. package/dist/types/task/label.d.ts +1 -1
  61. package/dist/types/telemetry-export.d.ts +34 -9
  62. package/dist/types/tools/approval.d.ts +8 -0
  63. package/dist/types/tools/bash.d.ts +2 -0
  64. package/dist/types/tools/browser/registry.d.ts +7 -3
  65. package/dist/types/tools/browser/tab-supervisor.d.ts +2 -0
  66. package/dist/types/tools/essential-tools.d.ts +29 -0
  67. package/dist/types/tools/image-gen.d.ts +2 -1
  68. package/dist/types/tools/index.d.ts +4 -1
  69. package/dist/types/tools/manage-skill.d.ts +2 -0
  70. package/dist/types/tools/xdev.d.ts +11 -2
  71. package/dist/types/utils/title-generator.d.ts +2 -1
  72. package/dist/types/web/search/index.d.ts +2 -0
  73. package/dist/types/web/search/providers/base.d.ts +3 -0
  74. package/dist/types/web/search/providers/kimi.d.ts +4 -1
  75. package/dist/types/web/search/types.d.ts +1 -1
  76. package/package.json +21 -16
  77. package/src/advisor/__tests__/advisor.test.ts +1358 -86
  78. package/src/advisor/__tests__/config.test.ts +58 -2
  79. package/src/advisor/advise-tool.ts +7 -3
  80. package/src/advisor/config.ts +76 -24
  81. package/src/advisor/runtime.ts +445 -92
  82. package/src/autolearn/controller.ts +23 -28
  83. package/src/cli/bench-cli.ts +4 -1
  84. package/src/cli/grep-cli.ts +2 -1
  85. package/src/cli-commands.ts +57 -23
  86. package/src/cli.ts +5 -1
  87. package/src/config/model-discovery.ts +81 -21
  88. package/src/config/model-registry.ts +34 -6
  89. package/src/config/model-resolver.ts +57 -12
  90. package/src/config/models-config-schema.ts +1 -0
  91. package/src/config/settings-schema.ts +43 -6
  92. package/src/config/settings.ts +405 -25
  93. package/src/cursor.ts +20 -3
  94. package/src/debug/report-bundle.ts +40 -4
  95. package/src/discovery/codex.ts +14 -4
  96. package/src/discovery/helpers.ts +28 -5
  97. package/src/discovery/substitute-plugin-root.ts +23 -7
  98. package/src/exec/bash-executor.ts +14 -5
  99. package/src/export/html/template.js +2 -0
  100. package/src/extensibility/custom-tools/loader.ts +3 -3
  101. package/src/extensibility/custom-tools/wrapper.ts +2 -1
  102. package/src/extensibility/extensions/loader.ts +3 -3
  103. package/src/extensibility/extensions/managed-timers.ts +83 -0
  104. package/src/extensibility/extensions/runner.ts +26 -0
  105. package/src/extensibility/extensions/types.ts +18 -0
  106. package/src/extensibility/extensions/wrapper.ts +2 -1
  107. package/src/extensibility/hooks/loader.ts +3 -3
  108. package/src/extensibility/legacy-pi-coding-agent-shim.ts +96 -1
  109. package/src/extensibility/plugins/legacy-pi-compat.ts +225 -22
  110. package/src/extensibility/plugins/manager.ts +2 -2
  111. package/src/extensibility/shared-events.ts +6 -0
  112. package/src/extensibility/utils.ts +91 -25
  113. package/src/internal-urls/__tests__/agent-protocol-nested.test.ts +73 -0
  114. package/src/internal-urls/agent-protocol.ts +73 -39
  115. package/src/irc/bus.ts +22 -3
  116. package/src/launch/broker.ts +3 -2
  117. package/src/launch/client.ts +2 -2
  118. package/src/launch/presence.ts +2 -2
  119. package/src/lib/xai-http.ts +28 -2
  120. package/src/lsp/client.ts +1 -1
  121. package/src/main.ts +11 -8
  122. package/src/mcp/manager.ts +9 -3
  123. package/src/mcp/transports/stdio.ts +103 -23
  124. package/src/modes/acp/acp-agent.ts +28 -9
  125. package/src/modes/acp/acp-event-mapper.ts +8 -0
  126. package/src/modes/acp/acp-mode.ts +18 -4
  127. package/src/modes/components/advisor-config.ts +65 -3
  128. package/src/modes/components/ask-dialog.ts +1 -1
  129. package/src/modes/components/assistant-message.ts +35 -14
  130. package/src/modes/components/chat-transcript-builder.ts +2 -0
  131. package/src/modes/components/custom-editor-plugin-ctor.test.ts +36 -0
  132. package/src/modes/components/custom-editor.ts +62 -1
  133. package/src/modes/components/hook-editor.ts +35 -5
  134. package/src/modes/components/login-dialog.test.ts +56 -0
  135. package/src/modes/components/login-dialog.ts +7 -3
  136. package/src/modes/components/model-hub.ts +138 -42
  137. package/src/modes/components/plan-review-overlay.ts +51 -10
  138. package/src/modes/components/session-selector.ts +10 -0
  139. package/src/modes/components/status-line/component.test.ts +1 -0
  140. package/src/modes/components/status-line/component.ts +2 -4
  141. package/src/modes/components/status-line/segments.ts +21 -6
  142. package/src/modes/components/tool-execution.test.ts +101 -0
  143. package/src/modes/components/tool-execution.ts +117 -9
  144. package/src/modes/components/transcript-container.ts +30 -2
  145. package/src/modes/controllers/command-controller-shared.ts +1 -1
  146. package/src/modes/controllers/command-controller.ts +168 -48
  147. package/src/modes/controllers/event-controller.ts +6 -0
  148. package/src/modes/controllers/extension-ui-controller.ts +4 -22
  149. package/src/modes/controllers/input-controller.ts +12 -12
  150. package/src/modes/controllers/selector-controller.ts +208 -46
  151. package/src/modes/interactive-mode.ts +205 -65
  152. package/src/modes/noninteractive-dispose.test.ts +60 -0
  153. package/src/modes/print-mode.ts +10 -5
  154. package/src/modes/rpc/host-tools.ts +2 -1
  155. package/src/modes/rpc/rpc-mode.ts +31 -7
  156. package/src/modes/theme/theme.ts +2 -2
  157. package/src/modes/types.ts +10 -0
  158. package/src/modes/utils/interactive-context-helpers.ts +3 -1
  159. package/src/modes/utils/transcript-render-helpers.ts +3 -2
  160. package/src/modes/warp-events.test.ts +794 -0
  161. package/src/modes/warp-events.ts +232 -0
  162. package/src/plan-mode/model-transition.test.ts +60 -0
  163. package/src/plan-mode/model-transition.ts +51 -0
  164. package/src/prompts/system/system-prompt.md +1 -1
  165. package/src/registry/agent-lifecycle.ts +133 -18
  166. package/src/sdk.ts +227 -44
  167. package/src/session/agent-session.ts +1364 -382
  168. package/src/session/session-history-format.ts +20 -5
  169. package/src/session/session-listing.ts +6 -5
  170. package/src/session/session-loader.ts +9 -0
  171. package/src/session/session-manager.ts +48 -0
  172. package/src/session/session-persistence.ts +11 -0
  173. package/src/session/streaming-output.ts +3 -1
  174. package/src/slash-commands/builtin-registry.ts +9 -0
  175. package/src/slash-commands/helpers/active-oauth-account.ts +16 -0
  176. package/src/slash-commands/types.ts +4 -4
  177. package/src/system-prompt.ts +2 -2
  178. package/src/task/executor.ts +1 -1
  179. package/src/task/label.ts +2 -0
  180. package/src/telemetry-export.ts +453 -97
  181. package/src/tools/approval.ts +11 -0
  182. package/src/tools/bash.ts +71 -38
  183. package/src/tools/browser/registry.ts +9 -2
  184. package/src/tools/browser/tab-supervisor.ts +65 -10
  185. package/src/tools/browser.ts +4 -3
  186. package/src/tools/essential-tools.ts +45 -0
  187. package/src/tools/eval.ts +3 -0
  188. package/src/tools/gh.ts +169 -2
  189. package/src/tools/image-gen.ts +624 -513
  190. package/src/tools/index.ts +10 -6
  191. package/src/tools/manage-skill.ts +5 -3
  192. package/src/tools/output-meta.ts +7 -0
  193. package/src/tools/path-utils.ts +8 -5
  194. package/src/tools/read.ts +48 -3
  195. package/src/tools/write.ts +22 -4
  196. package/src/tools/xdev.ts +14 -3
  197. package/src/utils/title-generator.ts +15 -4
  198. package/src/web/search/index.ts +21 -6
  199. package/src/web/search/providers/base.ts +3 -0
  200. package/src/web/search/providers/kimi.ts +18 -12
  201. package/src/web/search/providers/xai.ts +40 -9
  202. package/src/web/search/types.ts +6 -1
@@ -18,7 +18,7 @@ import { type CompactionResult, type ShakeConfig } from "@oh-my-pi/pi-agent-core
18
18
  import type { AssistantMessage, Context, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, ServiceTier, ServiceTierByFamily, ServiceTierFamily, SimpleStreamOptions, TextContent, ToolChoice, UsageReport } from "@oh-my-pi/pi-ai";
19
19
  import { Effort } from "@oh-my-pi/pi-ai";
20
20
  import { postmortem } from "@oh-my-pi/pi-utils";
21
- import { type AdvisorConfig } from "../advisor/index.js";
21
+ import { type AdvisorConfig, type AdvisorRuntimeStatus } from "../advisor/index.js";
22
22
  import { type AsyncJob, type AsyncJobDeliveryState, AsyncJobManager } from "../async/index.js";
23
23
  import type { Rule } from "../capability/rule.js";
24
24
  import type { ModelRegistry } from "../config/model-registry.js";
@@ -34,7 +34,7 @@ import type { CustomTool } from "../extensibility/custom-tools/types.js";
34
34
  import type { ExtensionRunner } from "../extensibility/extensions/index.js";
35
35
  import type { CompactOptions, ContextUsage } from "../extensibility/extensions/types.js";
36
36
  import type { RecoveredRetryError } from "../extensibility/shared-events.js";
37
- import type { Skill, SkillWarning } from "../extensibility/skills.js";
37
+ import { type Skill, type SkillWarning } from "../extensibility/skills.js";
38
38
  import { type FileSlashCommand } from "../extensibility/slash-commands.js";
39
39
  import { GoalRuntime } from "../goals/runtime.js";
40
40
  import type { Goal, GoalModeState } from "../goals/state.js";
@@ -209,6 +209,8 @@ export interface AgentSessionConfig {
209
209
  skills?: Skill[];
210
210
  /** Skill loading warnings (already captured by SDK) */
211
211
  skillWarnings?: SkillWarning[];
212
+ /** Whether runtime reloads may rediscover disk-backed skills for this session. */
213
+ skillsReloadable?: boolean;
212
214
  /** Custom commands (TypeScript slash commands) */
213
215
  customCommands?: LoadedCustomCommand[];
214
216
  skillsSettings?: SkillsSettings;
@@ -222,6 +224,8 @@ export interface AgentSessionConfig {
222
224
  builtInToolNames?: Iterable<string>;
223
225
  /** Update tool-session predicates that render guidance from the live active tool set. */
224
226
  setActiveToolNames?: (names: Iterable<string>) => void;
227
+ /** Register the write transport lazily when runtime xdev mounts first need it. */
228
+ ensureWriteRegistered?: () => Promise<boolean>;
225
229
  /** Current session pre-LLM message transform pipeline */
226
230
  transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => AgentMessage[] | Promise<AgentMessage[]>;
227
231
  /**
@@ -273,7 +277,8 @@ export interface AgentSessionConfig {
273
277
  xdevRegistry?: XdevRegistry;
274
278
  /** Discoverable tools mounted under `xd://` in the initial enabled set (startup partition in `sdk.ts`). */
275
279
  initialMountedXdevToolNames?: string[];
276
- requestedToolNames?: ReadonlySet<string>;
280
+ /** Explicit/effective names pinned top-level during runtime repartitioning. */
281
+ presentationPinnedToolNames?: ReadonlySet<string>;
277
282
  /**
278
283
  * Optional accessor for live MCP server instructions. Read by the session's
279
284
  * `rebuildSystemPrompt`-skip optimization to detect server-side instruction
@@ -489,15 +494,20 @@ export interface AdvisorStats {
489
494
  /** Per-advisor breakdown; one entry per active advisor (single-advisor sessions have one). */
490
495
  advisors: PerAdvisorStat[];
491
496
  }
492
- /** One advisor's slice of {@link AdvisorStats}, surfaced for the multi-advisor status panel. */
497
+ /** One advisor's slice of {@link AdvisorStats}. Active advisors carry full
498
+ * token/cost data; disabled/no-model/quota-exhausted advisors appear with
499
+ * just `name` + `status` so the status line can render a dot for every
500
+ * configured advisor. */
493
501
  export interface PerAdvisorStat {
494
502
  name: string;
495
- model: Model;
503
+ status: AdvisorRuntimeStatus;
504
+ model?: Model;
496
505
  contextWindow: number;
497
506
  contextTokens: number;
498
507
  tokens: AdvisorStats["tokens"];
499
508
  cost: number;
500
509
  messages: AdvisorStats["messages"];
510
+ sessionId?: string;
501
511
  }
502
512
  export interface FreshSessionResult {
503
513
  previousSessionId: string;
@@ -610,6 +620,8 @@ export declare class AgentSession {
610
620
  */
611
621
  subscribe(listener: AgentSessionEventListener): () => void;
612
622
  subscribeCommandMetadataChanged(listener: CommandMetadataChangedListener): () => void;
623
+ /** Run one abortable auto-learn capture outside the primary agent loop. */
624
+ runAutolearnCapture(capture: (signal: AbortSignal) => Promise<void>): Promise<void>;
613
625
  /** True once dispose() has begun; deferred background work (e.g. the deferred
614
626
  * MCP discovery task in sdk.ts) must not touch the session past this point. */
615
627
  get isDisposed(): boolean;
@@ -689,6 +701,12 @@ export declare class AgentSession {
689
701
  /** Removes tools installed by {@link activateVibeTools} and activates `nextToolNames`. */
690
702
  deactivateVibeTools(nextToolNames: string[]): Promise<void>;
691
703
  getSelectedMCPToolNames(): string[];
704
+ /**
705
+ * Rediscover disk-backed skills and rebuild prompt-facing state without
706
+ * recreating the session. Explicit skill snapshots (`--no-skills`,
707
+ * SDK-provided `skills`) remain fixed for the lifetime of the session.
708
+ */
709
+ refreshSkills(): Promise<void>;
692
710
  /**
693
711
  * Set active tools by name.
694
712
  * Only tools in the registry can be enabled. Unknown tool names are ignored.
@@ -907,6 +925,12 @@ export declare class AgentSession {
907
925
  get skillWarnings(): readonly SkillWarning[];
908
926
  getTodoPhases(): TodoPhase[];
909
927
  setTodoPhases(phases: TodoPhase[]): void;
928
+ /**
929
+ * Generate an automatic session title tied to this session's lifecycle.
930
+ * Input and replan callers share the signal so disposal cancels provider and
931
+ * local-worker requests instead of leaving background inference alive.
932
+ */
933
+ generateTitle(firstMessage: string): Promise<string | null>;
910
934
  /** Currently-applied {@link TITLE_SYSTEM.md} override, or undefined when the
911
935
  * bundled prompt is in effect. Consumed by {@link InteractiveMode} so the
912
936
  * first-input title path and the replan refresh share one source. */
@@ -1159,8 +1183,7 @@ export declare class AgentSession {
1159
1183
  */
1160
1184
  retry(): Promise<boolean>;
1161
1185
  /**
1162
- * Execute a bash command.
1163
- * Adds result to agent context and session.
1186
+ * Execute a bash command and retain the session/branch that owned its start.
1164
1187
  * @param command The bash command to execute
1165
1188
  * @param onChunk Optional streaming callback for output
1166
1189
  * @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
@@ -1170,10 +1193,7 @@ export declare class AgentSession {
1170
1193
  excludeFromContext?: boolean;
1171
1194
  useUserShell?: boolean;
1172
1195
  }): Promise<BashResult>;
1173
- /**
1174
- * Record a bash execution result in session history.
1175
- * Used by executeBash and by extensions that handle bash execution themselves.
1176
- */
1196
+ /** Record a bash result supplied outside executeBash in the current ownership scope. */
1177
1197
  recordBashResult(command: string, result: BashResult, options?: {
1178
1198
  excludeFromContext?: boolean;
1179
1199
  }): void;
@@ -1463,6 +1483,18 @@ export declare class AgentSession {
1463
1483
  * (`streamFn`, `promptCacheKey`, `providerSessionState`, ...).
1464
1484
  */
1465
1485
  getAdvisorAgent(): Agent | undefined;
1486
+ /**
1487
+ * Lightweight advisor status for the status line: returns just the configured
1488
+ * flag and per-advisor name/status without computing token/cost breakdowns.
1489
+ * Avoids re-tokenizing the advisor transcript on every render frame.
1490
+ */
1491
+ getAdvisorStatusOverview(): {
1492
+ configured: boolean;
1493
+ advisors: {
1494
+ name: string;
1495
+ status: AdvisorRuntimeStatus;
1496
+ }[];
1497
+ };
1466
1498
  /**
1467
1499
  * Return structured advisor stats for the status command and TUI panel.
1468
1500
  */
@@ -1,3 +1,4 @@
1
+ import type { ToolResultMessage } from "@oh-my-pi/pi-ai";
1
2
  export interface HistoryFormatOptions {
2
3
  /** Optional H1 prepended to the transcript. */
3
4
  title?: string;
@@ -24,6 +25,15 @@ export interface HistoryFormatOptions {
24
25
  * this so it sees what changed without re-reading the file.
25
26
  */
26
27
  expandEditDiffs?: boolean;
28
+ /**
29
+ * Chunked rendering support: a caller formatting one logical transcript in
30
+ * several calls (the advisor's chunked delta render) passes a result index
31
+ * built over the WHOLE delta plus one shared consumed-id set, so a toolCall
32
+ * finds its toolResult across chunk boundaries and the result is never
33
+ * re-rendered as an orphan in a later chunk.
34
+ */
35
+ toolResultIndex?: ReadonlyMap<string, ToolResultMessage>;
36
+ consumedToolCallIds?: Set<string>;
27
37
  }
28
38
  /**
29
39
  * Hidden custom messages that inject the primary agent's operative *constraints*
@@ -48,6 +48,15 @@ export declare class SessionManager {
48
48
  /** Synchronous variant of {@link putBlob} for rebuild-only render paths. */
49
49
  putBlobSync(data: Buffer, options?: BlobPutOptions): BlobPutResult;
50
50
  captureState(): SessionManagerStateSnapshot;
51
+ /**
52
+ * Create an independent manager for the current logical session and branch.
53
+ * The clone shares the storage backend but owns its entry index and writer, so
54
+ * callers can finish session-owned work after this manager switches elsewhere.
55
+ * Set `persist` false when the original session is intentionally being dropped.
56
+ */
57
+ cloneCurrentSession(options?: {
58
+ persist?: boolean;
59
+ }): SessionManager;
51
60
  restoreState(snapshot: SessionManagerStateSnapshot): void;
52
61
  /** Switch to a different session file (resume / branch). */
53
62
  setSessionFile(sessionFile: string): Promise<void>;
@@ -140,6 +149,11 @@ export declare class SessionManager {
140
149
  * top-level entries via appendCompaction()/branchWithSummary().
141
150
  */
142
151
  appendMessage(message: Message | CustomMessage | HookMessage | BashExecutionMessage | PythonExecutionMessage | FileMentionMessage): string;
152
+ /**
153
+ * Append to a non-active branch without changing the current leaf.
154
+ * Used by work that retains ownership of a branch across tree navigation.
155
+ */
156
+ appendMessageToBranch(message: Message | CustomMessage | HookMessage | BashExecutionMessage | PythonExecutionMessage | FileMentionMessage, parentId: string | null): string;
143
157
  /** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */
144
158
  appendThinkingLevelChange(thinkingLevel?: string, configured?: string): string;
145
159
  appendServiceTierChange(serviceTier: ServiceTierByFamily | null): string;
@@ -26,6 +26,8 @@ export interface OutputSummary {
26
26
  columnDroppedBytes?: number;
27
27
  /** Number of distinct lines that hit the per-line column cap. */
28
28
  columnTruncatedLines?: number;
29
+ /** Configured per-line column cap in effect (chars), when > 0. */
30
+ columnMax?: number;
29
31
  /** Artifact ID for internal URL access (artifact://<id>) when truncated */
30
32
  artifactId?: string;
31
33
  }
@@ -1,5 +1,14 @@
1
1
  import type { UsageLimit, UsageReport } from "@oh-my-pi/pi-ai";
2
2
  import type { OAuthAccountIdentity } from "../../session/auth-storage.js";
3
+ /**
4
+ * Session marker label for an active OAuth identity: the base identifier
5
+ * (email → accountId → projectId) suffixed with the organization when present
6
+ * and distinct. Same-email Anthropic multi-org accounts share the base, so the
7
+ * org suffix is the only field that tells the session's quota pool apart —
8
+ * mirrors the account-list rows (`formatUsageReportAccount`) and login success.
9
+ * Returns `undefined` when no identifier is recoverable.
10
+ */
11
+ export declare function formatActiveAccountLabel(identity: OAuthAccountIdentity | undefined): string | undefined;
3
12
  /**
4
13
  * True when a single usage-limit column belongs to the given OAuth identity.
5
14
  *
@@ -63,10 +63,10 @@ export interface SlashCommandRuntime {
63
63
  /** Re-advertise the available command list (no-op outside ACP). */
64
64
  refreshCommands: () => Promise<void> | void;
65
65
  /**
66
- * Reload plugin state (caches, slash command registry, project registries)
67
- * and re-emit available commands. Used by `/reload-plugins`, `/move`, and
68
- * `/marketplace`/`/plugins` mutations so the session sees a consistent view
69
- * after plugin or project-scope changes.
66
+ * Reload plugin state (caches, skills, slash command registry, project
67
+ * registries) and re-emit available commands. Used by `/reload-plugins`,
68
+ * `/move`, and `/marketplace`/`/plugins` mutations so the session sees a
69
+ * consistent view after plugin or project-scope changes.
70
70
  */
71
71
  reloadPlugins: () => Promise<void>;
72
72
  notifyTitleChanged?: () => Promise<void> | void;
@@ -79,7 +79,7 @@ export interface BuildSystemPromptOptions {
79
79
  depth?: number;
80
80
  }>;
81
81
  /** Skills provided directly to system prompt construction. */
82
- skills?: Skill[];
82
+ skills?: readonly Skill[];
83
83
  /** Pre-loaded rulebook rules (descriptions, excluding TTSR and always-apply). */
84
84
  rules?: Array<{
85
85
  name: string;
@@ -1,4 +1,4 @@
1
1
  import type { ModelRegistry } from "../config/model-registry.js";
2
2
  import type { Settings } from "../config/settings.js";
3
3
  /** Compresses a delegated assignment into a one-sentence UI label via the tiny title model — fired by the executor spawn path because the task wire schema no longer carries a `description`; null on empty input or failure. */
4
- export declare function generateTaskLabel(assignment: string, registry: ModelRegistry, settings: Settings, sessionId?: string): Promise<string | null>;
4
+ export declare function generateTaskLabel(assignment: string, registry: ModelRegistry, settings: Settings, sessionId?: string, signal?: AbortSignal): Promise<string | null>;
@@ -1,19 +1,44 @@
1
1
  /**
2
- * Whether {@link initTelemetryExport} registered a real provider. The CLI uses
3
- * this to decide whether to switch on the agent loop's telemetry config — there
4
- * is no point emitting spans into a no-op tracer.
2
+ * OTLP telemetry export bootstrap.
3
+ *
4
+ * oh-my-pi's agent core (`@oh-my-pi/pi-agent-core`) emits OpenTelemetry GenAI
5
+ * spans through the global `@opentelemetry/api` tracer, and exposes run-level
6
+ * callbacks for metrics/log pipelines. This module registers the OTLP/proto
7
+ * trace, log, and metric SDK providers when the standard `OTEL_*` endpoint env
8
+ * vars are set so `omp` can be observed by any OTLP collector without vendor
9
+ * coupling.
10
+ *
11
+ * Only the `http/protobuf` transport is supported — an
12
+ * `OTEL_EXPORTER_OTLP*_PROTOCOL` of `grpc` or `http/json` declines rather than
13
+ * misrouting protobuf payloads. The exporter line is pinned to the 0.218/2.7
14
+ * family validated under Bun; the 1.x OTLP line deadlocks when its
15
+ * `req.on("close")` handler fires after a successful export.
16
+ */
17
+ import type { AgentTelemetryConfig } from "@oh-my-pi/pi-agent-core";
18
+ /**
19
+ * Whether {@link initTelemetryExport} registered any real OTLP signal provider.
20
+ * The CLI uses this to decide whether to switch on the agent loop's telemetry
21
+ * hooks; metrics and structured logs need those callbacks even when traces are
22
+ * disabled.
5
23
  */
6
24
  export declare function isTelemetryExportEnabled(): boolean;
7
25
  /**
8
- * Register the global TracerProvider + OTLP exporter when an OTLP endpoint is
9
- * configured via env. Idempotent, and a no-op when no endpoint is set (or when
10
- * the OTEL kill-switches are engaged), so it is safe to call unconditionally at
11
- * startup.
26
+ * Merge OTLP metrics/log hooks into an existing agent telemetry config.
27
+ *
28
+ * The caller still owns content-capture policy, cost estimation, and custom
29
+ * attributes. This only appends host-level metrics/log forwarding for the
30
+ * providers registered by {@link initTelemetryExport}.
31
+ */
32
+ export declare function createTelemetryExportConfig(config: AgentTelemetryConfig | undefined): AgentTelemetryConfig | undefined;
33
+ /**
34
+ * Register global trace/log/meter providers when OTLP endpoints are configured
35
+ * through env. Idempotent, and a no-op when no signal has an endpoint (or when
36
+ * the OTEL kill-switches are engaged), so startup can call it unconditionally.
12
37
  */
13
38
  export declare function initTelemetryExport(): Promise<void>;
14
39
  /**
15
- * Flush any buffered spans to the exporter. No-op when export is disabled.
40
+ * Flush buffered spans, log records, and metrics. No-op when export is disabled.
16
41
  * Hosts embedding the agent can call this at natural boundaries (e.g. the end
17
- * of a turn) so traces surface promptly rather than on the batch interval.
42
+ * of a turn) so telemetry surfaces promptly rather than on the batch interval.
18
43
  */
19
44
  export declare function flushTelemetryExport(): Promise<void>;
@@ -17,6 +17,14 @@ export interface ResolvedApproval {
17
17
  reason?: string;
18
18
  override: boolean;
19
19
  }
20
+ /**
21
+ * Evaluate a tool's own approval declaration against `args` and return the
22
+ * resulting capability tier, defaulting to `exec` when the tool omits an
23
+ * approval. Unlike reading `tool.approval` directly, this runs function-valued
24
+ * approvals — the write tool's `xd://` gate uses it to take a mounted device's
25
+ * argument-dependent tier instead of falling back to `exec`.
26
+ */
27
+ export declare function resolveToolTier(tool: ApprovalSubject, args: unknown): ToolTier;
20
28
  /**
21
29
  * Resolve approval policy for a tool call.
22
30
  *
@@ -76,6 +76,8 @@ export interface BashToolDetails {
76
76
  wallTimeMs?: number;
77
77
  /** Exit code of a command that ran to completion but failed (non-zero). */
78
78
  exitCode?: number;
79
+ /** True when the command was killed by its timeout deadline (not a failure). */
80
+ timedOut?: boolean;
79
81
  terminalId?: string;
80
82
  async?: {
81
83
  state: "running" | "completed" | "failed";
@@ -37,6 +37,12 @@ export interface CmuxBrowserHandle extends BrowserHandleCommon {
37
37
  surface?: string;
38
38
  }
39
39
  export type BrowserHandle = PuppeteerBrowserHandle | CmuxBrowserHandle;
40
+ /** Controls bounded browser-handle teardown and identifies the owning resource in timeout diagnostics. */
41
+ export interface ReleaseBrowserOptions {
42
+ kill: boolean;
43
+ timeoutMs?: number;
44
+ resource?: string;
45
+ }
40
46
  export interface AcquireBrowserOptions {
41
47
  cwd: string;
42
48
  viewport?: {
@@ -50,9 +56,7 @@ export interface AcquireBrowserOptions {
50
56
  export declare function acquireBrowser(kind: BrowserKind, opts: AcquireBrowserOptions): Promise<BrowserHandle>;
51
57
  export declare function normalizeConnectedCdpUrl(rawCdpUrl: string): string;
52
58
  export declare function holdBrowser(handle: BrowserHandle): void;
53
- export declare function releaseBrowser(handle: BrowserHandle, opts: {
54
- kill: boolean;
55
- }): Promise<void>;
59
+ export declare function releaseBrowser(handle: BrowserHandle, opts: ReleaseBrowserOptions): Promise<void>;
56
60
  /** Test-only accessor for the module-global browsers map. */
57
61
  export declare function getBrowsersMapForTest(): ReadonlyMap<string, BrowserHandle>;
58
62
  export {};
@@ -87,6 +87,8 @@ export interface RunInTabOptions {
87
87
  }
88
88
  export interface ReleaseTabOptions {
89
89
  kill?: boolean;
90
+ /** Maximum time for each asynchronous cleanup resource before close fails with diagnostics. */
91
+ timeoutMs?: number;
90
92
  }
91
93
  export declare function getTab(name: string): TabSession | undefined;
92
94
  export declare function acquireTab(name: string, browser: BrowserHandle, opts: AcquireTabOptions): Promise<AcquireTabResult>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Canonical set of built-in tools that must stay top-level.
3
+ *
4
+ * These are the coding essentials the model always needs directly in its
5
+ * callable schema. `read`/`write` are additionally the `xd://` transport
6
+ * (`read xd://` lists devices, `write xd://<tool>` executes them), so demoting
7
+ * them under xdev makes every mounted device unreachable.
8
+ *
9
+ * Adapter boundaries (extension `registerTool`, SDK custom tools, RPC host
10
+ * tools) default an omitted `loadMode` to `"discoverable"`. A UI-only
11
+ * re-register of a built-in — e.g. wrapping `read`/`write`/`bash`/`edit`/`glob`
12
+ * to customize rendering — would then silently demote it to `discoverable` and,
13
+ * with `tools.xdev` on, unmount it from the top-level schema (issue #5764).
14
+ * {@link defaultLoadModeForToolName} pins these names to `"essential"` when the
15
+ * definition omits `loadMode`, so re-registering a built-in never demotes it.
16
+ */
17
+ import type { ToolLoadMode } from "@oh-my-pi/pi-agent-core";
18
+ /**
19
+ * Built-in tool names whose classes declare `loadMode = "essential"`. Kept in
20
+ * sync with the tool classes by `essential-tools.test.ts` (drift guard).
21
+ */
22
+ export declare const ESSENTIAL_BUILTIN_TOOL_NAMES: Record<string, true>;
23
+ /**
24
+ * Resolve a tool's presentation mode at an adapter boundary. An explicit
25
+ * `declared` mode always wins. When omitted, known essential built-in names
26
+ * default to `"essential"` (so a re-register never demotes them); everything
27
+ * else defaults to `"discoverable"`.
28
+ */
29
+ export declare function defaultLoadModeForToolName(name: string, declared?: ToolLoadMode): ToolLoadMode;
@@ -2,7 +2,7 @@ import { type Model } from "@oh-my-pi/pi-ai";
2
2
  import { type ModelRegistry } from "../config/model-registry.js";
3
3
  import type { CustomTool } from "../extensibility/custom-tools/types.js";
4
4
  export type ImageProvider = "antigravity" | "gemini" | "openai" | "openai-codex" | "openrouter" | "xai";
5
- export type ImageProviderPreference = Exclude<ImageProvider, "openai-codex"> | "auto";
5
+ export type ImageProviderPreference = ImageProvider | "auto";
6
6
  declare const responseModalitySchema: import("arktype/internal/variants/string.ts").StringType<"IMAGE" | "TEXT", {}>;
7
7
  export declare const imageGenSchema: import("arktype/internal/variants/object.ts").ObjectType<{
8
8
  subject: string;
@@ -20,6 +20,7 @@ export declare const imageGenSchema: import("arktype/internal/variants/object.ts
20
20
  data?: string | undefined;
21
21
  mime_type?: string | undefined;
22
22
  }[] | undefined;
23
+ provider?: "antigravity" | "auto" | "gemini" | "openai" | "openai-codex" | "openrouter" | "xai" | undefined;
23
24
  }, {}>;
24
25
  export type ImageGenParams = typeof imageGenSchema.infer;
25
26
  export type GeminiResponseModality = typeof responseModalitySchema.infer;
@@ -40,6 +40,7 @@ export * from "./bash.js";
40
40
  export * from "./browser.js";
41
41
  export * from "./checkpoint.js";
42
42
  export * from "./debug.js";
43
+ export * from "./essential-tools.js";
43
44
  export * from "./eval.js";
44
45
  export * from "./eval-backends.js";
45
46
  export * from "./gh.js";
@@ -121,7 +122,9 @@ export interface ToolSession {
121
122
  /** Pre-loaded workspace tree (forwarded to subagents to skip re-scanning) */
122
123
  workspaceTree?: WorkspaceTree;
123
124
  /** Pre-loaded skills */
124
- skills?: Skill[];
125
+ skills?: readonly Skill[];
126
+ /** Rediscover live session skills after a tool mutates their backing files. */
127
+ refreshSkills?: () => Promise<void>;
125
128
  /** Pre-loaded prompt templates */
126
129
  promptTemplates?: PromptTemplate[];
127
130
  /** Pre-loaded rules (forwarded to subagents to skip re-discovery). */
@@ -12,6 +12,7 @@ export type ManageSkillParams = typeof manageSkillSchema.infer;
12
12
  * `autolearn.enabled`; backend-independent (the skill side is standalone).
13
13
  */
14
14
  export declare class ManageSkillTool implements AgentTool<typeof manageSkillSchema> {
15
+ private readonly refreshSkills?;
15
16
  readonly name = "manage_skill";
16
17
  readonly approval: "write";
17
18
  readonly label = "Manage Skill";
@@ -25,6 +26,7 @@ export declare class ManageSkillTool implements AgentTool<typeof manageSkillSche
25
26
  readonly strict = true;
26
27
  readonly loadMode: "essential";
27
28
  readonly summary = "Create, update, or delete an isolated managed skill";
29
+ constructor(refreshSkills?: (() => Promise<void>) | undefined);
28
30
  static createIf(session: ToolSession): ManageSkillTool | null;
29
31
  execute(_id: string, params: ManageSkillParams): Promise<AgentToolResult>;
30
32
  }
@@ -37,11 +37,20 @@ import type { ToolRenderer } from "./renderers.js";
37
37
  * behind dispatch.
38
38
  */
39
39
  export declare const XDEV_KEEP_TOP_LEVEL: Record<string, true>;
40
+ /**
41
+ * Tools that carry the `xd://` transport itself and therefore can never be
42
+ * mounted as devices: `read xd://` lists/documents devices and
43
+ * `write xd://<tool>` executes them. Demoting either leaves every mounted
44
+ * device unreachable (issue #5764), so they stay top-level regardless of a
45
+ * declared `loadMode`.
46
+ */
47
+ export declare const XDEV_TRANSPORT_TOOLS: Record<string, true>;
40
48
  /**
41
49
  * Whether an enabled tool is presented under `xd://` (rather than top-level)
42
50
  * while the `xd://` transport is active. Discoverable tools mount unless they
43
- * are pinned top-level by {@link XDEV_KEEP_TOP_LEVEL}; essential tools never do.
44
- * The caller gates this on the transport being active (a session-owned
51
+ * are pinned top-level by {@link XDEV_KEEP_TOP_LEVEL} or carry the transport
52
+ * itself ({@link XDEV_TRANSPORT_TOOLS}); essential tools never do. The caller
53
+ * gates this on the transport being active (a session-owned
45
54
  * {@link XdevRegistry} existing).
46
55
  */
47
56
  export declare function isMountableUnderXdev(tool: {
@@ -14,8 +14,9 @@ import type { Settings } from "../config/settings.js";
14
14
  * resolver instead of a pre-evaluated value ensures the metadata's account_uuid
15
15
  * reflects the credential actually selected for this request.
16
16
  * @param customSystemPrompt Optional title-specific system prompt override
17
+ * @param signal Session-lifecycle cancellation for background title requests
17
18
  */
18
- export declare function generateSessionTitle(firstMessage: string, registry: ModelRegistry, settings: Settings, sessionId?: string, currentModel?: Model<Api>, metadataResolver?: (provider: string) => Record<string, unknown> | undefined, customSystemPrompt?: string): Promise<string | null>;
19
+ export declare function generateSessionTitle(firstMessage: string, registry: ModelRegistry, settings: Settings, sessionId?: string, currentModel?: Model<Api>, metadataResolver?: (provider: string) => Record<string, unknown> | undefined, customSystemPrompt?: string, signal?: AbortSignal): Promise<string | null>;
19
20
  export declare function generateTitleOnline(firstMessage: string, registry: ModelRegistry, settings: Settings, sessionId?: string, currentModel?: Model<Api>, metadataResolver?: (provider: string) => Record<string, unknown> | undefined, signal?: AbortSignal, customSystemPrompt?: string): Promise<string | null>;
20
21
  export declare function formatSessionTerminalTitle(sessionName: string | undefined, cwd?: string): string;
21
22
  /**
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
8
8
  import type { AuthStorage } from "@oh-my-pi/pi-ai";
9
+ import { ModelRegistry } from "../../config/model-registry.js";
9
10
  import type { CustomTool } from "../../extensibility/custom-tools/types.js";
10
11
  import type { ToolSession } from "../../tools/index.js";
11
12
  import { type SearchRenderDetails } from "./render.js";
@@ -32,6 +33,7 @@ export interface SearchQueryParams extends SearchToolParams {
32
33
  */
33
34
  export declare function runSearchQuery(params: SearchQueryParams, options?: {
34
35
  authStorage?: AuthStorage;
36
+ modelRegistry?: ModelRegistry;
35
37
  sessionId?: string;
36
38
  signal?: AbortSignal;
37
39
  }): Promise<{
@@ -1,4 +1,5 @@
1
1
  import type { AuthStorage, FetchImpl } from "@oh-my-pi/pi-ai";
2
+ import type { ModelRegistry } from "../../../config/model-registry.js";
2
3
  import type { SearchProviderId, SearchResponse } from "../types.js";
3
4
  /**
4
5
  * Shared web search parameters passed to providers.
@@ -44,6 +45,8 @@ export interface SearchParams {
44
45
  * the per-credential single-flight refresh.
45
46
  */
46
47
  authStorage: AuthStorage;
48
+ /** Provider/model transport settings used by native search endpoints. */
49
+ modelRegistry?: ModelRegistry;
47
50
  /**
48
51
  * Optional session id used as the round-robin / sticky key when selecting
49
52
  * among multiple credentials for the same provider. Pass through from the
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * Kimi Web Search Provider
3
3
  *
4
- * Uses Moonshot Kimi Code search API to retrieve web results.
4
+ * Uses the Kimi Code search API to retrieve web results. This is the Kimi Code
5
+ * membership service, distinct from the Moonshot Open Platform — it requires a
6
+ * Kimi Code Console credential (`omp /login kimi-code` or an explicit
7
+ * `MOONSHOT_SEARCH_API_KEY` / `KIMI_SEARCH_API_KEY`), not `MOONSHOT_API_KEY`.
5
8
  * Endpoint: POST https://api.kimi.com/coding/v1/search
6
9
  */
7
10
  import { type AuthStorage, type FetchImpl } from "@oh-my-pi/pi-ai";
@@ -62,7 +62,7 @@ export declare const SEARCH_PROVIDER_OPTIONS: readonly [{
62
62
  }, {
63
63
  readonly value: "kimi";
64
64
  readonly label: "Kimi";
65
- readonly description: "Requires MOONSHOT_SEARCH_API_KEY or MOONSHOT_API_KEY";
65
+ readonly description: "Kimi Code search (requires a Kimi Code Console key via KIMI_SEARCH_API_KEY/MOONSHOT_SEARCH_API_KEY or /login kimi-code; not MOONSHOT_API_KEY)";
66
66
  }, {
67
67
  readonly value: "parallel";
68
68
  readonly label: "Parallel";
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": "17.0.0",
4
+ "version": "17.0.2",
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",
@@ -52,23 +52,28 @@
52
52
  "@agentclientprotocol/sdk": "1.2.1",
53
53
  "@babel/parser": "^7.29.7",
54
54
  "@mozilla/readability": "^0.6.0",
55
- "@oh-my-pi/hashline": "17.0.0",
56
- "@oh-my-pi/omp-stats": "17.0.0",
57
- "@oh-my-pi/pi-agent-core": "17.0.0",
58
- "@oh-my-pi/pi-ai": "17.0.0",
59
- "@oh-my-pi/pi-catalog": "17.0.0",
60
- "@oh-my-pi/pi-mnemopi": "17.0.0",
61
- "@oh-my-pi/pi-natives": "17.0.0",
62
- "@oh-my-pi/pi-tui": "17.0.0",
63
- "@oh-my-pi/pi-utils": "17.0.0",
64
- "@oh-my-pi/pi-wire": "17.0.0",
65
- "@oh-my-pi/snapcompact": "17.0.0",
55
+ "@oh-my-pi/hashline": "17.0.2",
56
+ "@oh-my-pi/omp-stats": "17.0.2",
57
+ "@oh-my-pi/pi-agent-core": "17.0.2",
58
+ "@oh-my-pi/pi-ai": "17.0.2",
59
+ "@oh-my-pi/pi-catalog": "17.0.2",
60
+ "@oh-my-pi/pi-mnemopi": "17.0.2",
61
+ "@oh-my-pi/pi-natives": "17.0.2",
62
+ "@oh-my-pi/pi-tui": "17.0.2",
63
+ "@oh-my-pi/pi-utils": "17.0.2",
64
+ "@oh-my-pi/pi-wire": "17.0.2",
65
+ "@oh-my-pi/snapcompact": "17.0.2",
66
66
  "@opentelemetry/api": "^1.9.1",
67
- "@opentelemetry/context-async-hooks": "^2.7.1",
67
+ "@opentelemetry/api-logs": "^0.220.0",
68
+ "@opentelemetry/context-async-hooks": "^2.9.0",
69
+ "@opentelemetry/exporter-logs-otlp-proto": "^0.220.0",
70
+ "@opentelemetry/exporter-metrics-otlp-proto": "^0.220.0",
68
71
  "@opentelemetry/exporter-trace-otlp-proto": "^0.220.0",
69
- "@opentelemetry/resources": "^2.7.1",
70
- "@opentelemetry/sdk-trace-base": "^2.7.1",
71
- "@opentelemetry/sdk-trace-node": "^2.7.1",
72
+ "@opentelemetry/resources": "^2.9.0",
73
+ "@opentelemetry/sdk-logs": "^0.220.0",
74
+ "@opentelemetry/sdk-metrics": "^2.9.0",
75
+ "@opentelemetry/sdk-trace-base": "^2.9.0",
76
+ "@opentelemetry/sdk-trace-node": "^2.9.0",
72
77
  "@puppeteer/browsers": "^3.0.6",
73
78
  "@types/turndown": "5.0.6",
74
79
  "@xterm/headless": "^6.0.0",