@oh-my-pi/pi-coding-agent 17.0.9 → 17.1.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 (349) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +1 -1
  3. package/dist/cli.js +4685 -4614
  4. package/dist/types/async/job-manager.d.ts +37 -1
  5. package/dist/types/cli/args.d.ts +2 -0
  6. package/dist/types/cli/bench-cli.d.ts +41 -0
  7. package/dist/types/commands/bench.d.ts +15 -3
  8. package/dist/types/commands/launch.d.ts +4 -0
  9. package/dist/types/config/model-registry.d.ts +3 -1
  10. package/dist/types/config/models-config-schema.d.ts +18 -6
  11. package/dist/types/config/models-config.d.ts +14 -5
  12. package/dist/types/config/provider-globals.d.ts +2 -2
  13. package/dist/types/config/service-tier.d.ts +5 -1
  14. package/dist/types/config/settings-schema.d.ts +374 -47
  15. package/dist/types/config/settings.d.ts +7 -0
  16. package/dist/types/dap/client.d.ts +20 -0
  17. package/dist/types/exec/bash-executor.d.ts +38 -0
  18. package/dist/types/exec/direnv.d.ts +33 -0
  19. package/dist/types/export/html/args.d.ts +15 -0
  20. package/dist/types/export/html/index.d.ts +11 -26
  21. package/dist/types/export/html/web-palette.d.ts +55 -116
  22. package/dist/types/extensibility/extensions/loader.d.ts +3 -0
  23. package/dist/types/extensibility/extensions/types.d.ts +17 -2
  24. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +3 -0
  25. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +13 -0
  26. package/dist/types/live/attestation.d.ts +2 -0
  27. package/dist/types/live/controller.d.ts +48 -0
  28. package/dist/types/live/protocol.d.ts +85 -0
  29. package/dist/types/live/protocol.test.d.ts +1 -0
  30. package/dist/types/live/transport.d.ts +35 -0
  31. package/dist/types/live/visualizer.d.ts +30 -0
  32. package/dist/types/lsp/client.d.ts +16 -1
  33. package/dist/types/mcp/config-writer.test.d.ts +1 -0
  34. package/dist/types/mcp/oauth-discovery.d.ts +2 -0
  35. package/dist/types/mcp/smithery-auth.d.ts +1 -1
  36. package/dist/types/mcp/smithery-auth.test.d.ts +1 -0
  37. package/dist/types/memory-backend/tool-names.d.ts +2 -0
  38. package/dist/types/modes/components/assistant-message.d.ts +1 -0
  39. package/dist/types/modes/components/custom-message.d.ts +1 -1
  40. package/dist/types/modes/components/login-dialog.d.ts +2 -2
  41. package/dist/types/modes/components/message-frame.d.ts +8 -4
  42. package/dist/types/modes/components/plan-review-overlay.d.ts +26 -0
  43. package/dist/types/modes/components/session-account-selector.d.ts +11 -0
  44. package/dist/types/modes/components/settings-defs.d.ts +7 -1
  45. package/dist/types/modes/components/status-line/component.jj-cache.test.d.ts +1 -0
  46. package/dist/types/modes/components/tool-execution.d.ts +9 -1
  47. package/dist/types/modes/controllers/command-controller.d.ts +1 -1
  48. package/dist/types/modes/controllers/event-controller.d.ts +6 -1
  49. package/dist/types/modes/controllers/live-command-controller.d.ts +14 -0
  50. package/dist/types/modes/controllers/selector-controller.d.ts +1 -0
  51. package/dist/types/modes/interactive-mode.d.ts +6 -0
  52. package/dist/types/modes/theme/theme.d.ts +1 -1
  53. package/dist/types/modes/types.d.ts +4 -1
  54. package/dist/types/modes/utils/context-usage.d.ts +12 -2
  55. package/dist/types/plan-mode/plan-files.d.ts +10 -0
  56. package/dist/types/registry/agent-lifecycle.d.ts +21 -9
  57. package/dist/types/registry/agent-registry.d.ts +11 -4
  58. package/dist/types/sdk.d.ts +15 -1
  59. package/dist/types/secrets/index.d.ts +15 -2
  60. package/dist/types/secrets/obfuscator.d.ts +113 -15
  61. package/dist/types/session/acp-permission-gate.d.ts +19 -0
  62. package/dist/types/session/agent-session-events.d.ts +84 -0
  63. package/dist/types/session/agent-session-types.d.ts +321 -0
  64. package/dist/types/session/agent-session.d.ts +135 -753
  65. package/dist/types/session/async-job-delivery.d.ts +28 -0
  66. package/dist/types/session/auth-storage.d.ts +1 -1
  67. package/dist/types/session/bash-runner.d.ts +75 -0
  68. package/dist/types/session/blob-store.d.ts +11 -1
  69. package/dist/types/session/blob-store.test.d.ts +1 -0
  70. package/dist/types/session/checkpoint-entries.d.ts +28 -0
  71. package/dist/types/session/eval-runner.d.ts +51 -0
  72. package/dist/types/session/irc-bridge.d.ts +46 -0
  73. package/dist/types/session/messages.d.ts +24 -0
  74. package/dist/types/session/model-controls.d.ts +180 -0
  75. package/dist/types/session/prewalk.d.ts +46 -0
  76. package/dist/types/session/queued-messages.d.ts +22 -0
  77. package/dist/types/session/redis-session-storage.d.ts +1 -0
  78. package/dist/types/session/retry-fallback-chains.d.ts +74 -0
  79. package/dist/types/session/role-models.d.ts +15 -0
  80. package/dist/types/session/session-advisors.d.ts +228 -0
  81. package/dist/types/session/session-entries.d.ts +8 -0
  82. package/dist/types/session/session-handoff.d.ts +70 -0
  83. package/dist/types/session/session-history-format.d.ts +6 -1
  84. package/dist/types/session/session-maintenance.d.ts +246 -0
  85. package/dist/types/session/session-manager.d.ts +41 -0
  86. package/dist/types/session/session-memory.d.ts +56 -0
  87. package/dist/types/session/session-provider-boundary.d.ts +62 -0
  88. package/dist/types/session/session-stats.d.ts +48 -0
  89. package/dist/types/session/session-tools.d.ts +158 -0
  90. package/dist/types/session/session-workspace.d.ts +32 -0
  91. package/dist/types/session/stream-guards.d.ts +44 -0
  92. package/dist/types/session/streaming-output.d.ts +8 -0
  93. package/dist/types/session/todo-tracker.d.ts +56 -0
  94. package/dist/types/session/ttsr-coordinator.d.ts +51 -0
  95. package/dist/types/session/turn-recovery.d.ts +225 -0
  96. package/dist/types/slash-commands/helpers/session-pin.d.ts +9 -0
  97. package/dist/types/stt/index.d.ts +0 -2
  98. package/dist/types/stt/stt-controller.d.ts +7 -0
  99. package/dist/types/system-prompt.d.ts +2 -0
  100. package/dist/types/task/executor.d.ts +4 -1
  101. package/dist/types/task/output-manager.d.ts +3 -1
  102. package/dist/types/tiny/title-client.d.ts +10 -0
  103. package/dist/types/tools/approval.d.ts +1 -0
  104. package/dist/types/tools/browser/launch.d.ts +5 -0
  105. package/dist/types/tools/builtin-names.d.ts +1 -1
  106. package/dist/types/tools/computer/protocol.d.ts +43 -0
  107. package/dist/types/tools/computer/supervisor.d.ts +32 -0
  108. package/dist/types/tools/computer/worker-entry.d.ts +1 -0
  109. package/dist/types/tools/computer/worker.d.ts +15 -0
  110. package/dist/types/tools/computer-renderer.d.ts +22 -0
  111. package/dist/types/tools/computer.d.ts +71 -0
  112. package/dist/types/tools/context.d.ts +2 -0
  113. package/dist/types/tools/default-renderer.d.ts +21 -0
  114. package/dist/types/tools/image-gen.d.ts +4 -4
  115. package/dist/types/tools/image-providers.d.ts +38 -0
  116. package/dist/types/tools/index.d.ts +7 -0
  117. package/dist/types/tools/path-utils.d.ts +8 -0
  118. package/dist/types/tools/todo.d.ts +10 -4
  119. package/dist/types/tools/xdev.d.ts +5 -1
  120. package/dist/types/tts/streaming-player.d.ts +10 -29
  121. package/dist/types/tts/vocalizer.d.ts +5 -0
  122. package/dist/types/utils/jj.d.ts +29 -0
  123. package/dist/types/utils/lang-from-path.d.ts +1 -0
  124. package/dist/types/utils/title-generator.d.ts +30 -0
  125. package/dist/types/utils/tools-manager.d.ts +1 -2
  126. package/dist/types/vibe/runtime.d.ts +36 -8
  127. package/dist/types/web/search/index.d.ts +1 -1
  128. package/dist/types/web/search/provider.d.ts +15 -5
  129. package/dist/types/web/search/types.d.ts +94 -0
  130. package/package.json +12 -12
  131. package/scripts/generate-share-viewer.ts +4 -6
  132. package/src/advisor/__tests__/advisor.test.ts +643 -0
  133. package/src/advisor/runtime.ts +144 -43
  134. package/src/async/job-manager.ts +90 -2
  135. package/src/cli/args.ts +3 -0
  136. package/src/cli/auth-gateway-cli.ts +18 -3
  137. package/src/cli/bench-cli.ts +395 -29
  138. package/src/cli/flag-tables.ts +3 -0
  139. package/src/cli/gc-cli.ts +2 -2
  140. package/src/cli/setup-cli.ts +2 -14
  141. package/src/cli/usage-cli.ts +10 -1
  142. package/src/cli.ts +8 -0
  143. package/src/collab/host.ts +3 -2
  144. package/src/commands/bench.ts +18 -4
  145. package/src/commands/launch.ts +4 -0
  146. package/src/config/model-registry.ts +16 -2
  147. package/src/config/models-config-schema.ts +15 -4
  148. package/src/config/provider-globals.ts +9 -9
  149. package/src/config/service-tier.ts +26 -1
  150. package/src/config/settings-schema.ts +270 -51
  151. package/src/config/settings.ts +81 -2
  152. package/src/dap/client.ts +37 -4
  153. package/src/edit/index.ts +49 -12
  154. package/src/eval/executor-base.ts +1 -0
  155. package/src/eval/js/executor.ts +2 -0
  156. package/src/eval/py/executor.ts +103 -33
  157. package/src/exec/bash-executor.ts +90 -6
  158. package/src/exec/direnv.ts +145 -0
  159. package/src/export/html/args.ts +20 -0
  160. package/src/export/html/index.ts +45 -47
  161. package/src/export/html/template.css +19 -1
  162. package/src/export/html/template.html +6 -0
  163. package/src/export/html/template.js +21 -0
  164. package/src/export/html/tool-views.generated.js +31 -31
  165. package/src/export/html/web-palette.ts +116 -132
  166. package/src/export/share.ts +249 -49
  167. package/src/extensibility/extensions/loader.ts +29 -1
  168. package/src/extensibility/extensions/runner.ts +6 -0
  169. package/src/extensibility/extensions/types.ts +33 -2
  170. package/src/extensibility/extensions/wrapper.ts +68 -12
  171. package/src/extensibility/legacy-pi-coding-agent-shim.ts +7 -1
  172. package/src/extensibility/plugins/legacy-pi-compat.ts +19 -1
  173. package/src/hindsight/state.ts +64 -6
  174. package/src/internal-urls/local-protocol.ts +2 -1
  175. package/src/internal-urls/memory-protocol.ts +2 -2
  176. package/src/internal-urls/skill-protocol.ts +2 -2
  177. package/src/internal-urls/ssh-protocol.ts +2 -1
  178. package/src/internal-urls/vault-protocol.ts +2 -1
  179. package/src/live/attestation.ts +91 -0
  180. package/src/live/controller.ts +517 -0
  181. package/src/live/prompts/agent-final-message.md +3 -0
  182. package/src/live/prompts/live-instructions.md +23 -0
  183. package/src/live/protocol.test.ts +140 -0
  184. package/src/live/protocol.ts +233 -0
  185. package/src/live/transport.ts +422 -0
  186. package/src/live/visualizer.ts +214 -0
  187. package/src/lsp/client.ts +29 -9
  188. package/src/lsp/index.ts +19 -4
  189. package/src/main.ts +8 -1
  190. package/src/mcp/config-writer.test.ts +43 -0
  191. package/src/mcp/config-writer.ts +109 -82
  192. package/src/mcp/oauth-discovery.ts +10 -2
  193. package/src/mcp/smithery-auth.test.ts +29 -0
  194. package/src/mcp/smithery-auth.ts +3 -2
  195. package/src/memories/index.ts +40 -20
  196. package/src/memory-backend/tool-names.ts +2 -0
  197. package/src/mnemopi/backend.ts +24 -7
  198. package/src/modes/acp/acp-agent.ts +56 -10
  199. package/src/modes/acp/acp-event-mapper.ts +8 -1
  200. package/src/modes/components/agent-hub.ts +1 -1
  201. package/src/modes/components/assistant-message.ts +7 -2
  202. package/src/modes/components/custom-message.ts +4 -1
  203. package/src/modes/components/login-dialog.ts +14 -4
  204. package/src/modes/components/message-frame.ts +14 -8
  205. package/src/modes/components/plan-review-overlay.ts +350 -35
  206. package/src/modes/components/session-account-selector.ts +62 -0
  207. package/src/modes/components/settings-defs.ts +23 -1
  208. package/src/modes/components/settings-selector.ts +169 -1
  209. package/src/modes/components/status-line/component.jj-cache.test.ts +229 -0
  210. package/src/modes/components/status-line/component.ts +123 -2
  211. package/src/modes/components/tool-execution.ts +28 -112
  212. package/src/modes/controllers/command-controller.ts +56 -15
  213. package/src/modes/controllers/event-controller.ts +111 -16
  214. package/src/modes/controllers/extension-ui-controller.test.ts +1 -0
  215. package/src/modes/controllers/extension-ui-controller.ts +20 -4
  216. package/src/modes/controllers/input-controller.ts +47 -39
  217. package/src/modes/controllers/live-command-controller.ts +255 -0
  218. package/src/modes/controllers/mcp-command-controller.ts +10 -1
  219. package/src/modes/controllers/omfg-controller.ts +44 -40
  220. package/src/modes/controllers/selector-controller.ts +80 -10
  221. package/src/modes/controllers/session-focus-controller.ts +6 -1
  222. package/src/modes/interactive-mode.ts +176 -38
  223. package/src/modes/runtime-init.ts +2 -0
  224. package/src/modes/setup-wizard/scenes/web-search.ts +17 -9
  225. package/src/modes/theme/theme.ts +1 -1
  226. package/src/modes/types.ts +4 -1
  227. package/src/modes/utils/context-usage.ts +23 -7
  228. package/src/modes/utils/ui-helpers.ts +10 -5
  229. package/src/plan-mode/plan-files.ts +40 -0
  230. package/src/prompts/bench/cache-prefix-chunk.md +1 -0
  231. package/src/prompts/bench/cache-prefix.md +3 -0
  232. package/src/prompts/bench/cache-suffix.md +1 -0
  233. package/src/prompts/system/computer-safety.md +14 -0
  234. package/src/prompts/system/custom-system-prompt.md +1 -1
  235. package/src/prompts/system/project-prompt.md +8 -1
  236. package/src/prompts/system/subagent-async-pending.md +6 -0
  237. package/src/prompts/system/system-prompt.md +1 -1
  238. package/src/prompts/system/workflow-notice.md +48 -40
  239. package/src/prompts/system/xdev-mount-notice.md +4 -0
  240. package/src/prompts/tools/computer.md +26 -0
  241. package/src/prompts/tools/todo.md +3 -1
  242. package/src/registry/agent-lifecycle.ts +116 -46
  243. package/src/registry/agent-registry.ts +35 -8
  244. package/src/registry/persisted-agents.ts +26 -2
  245. package/src/sdk.ts +215 -136
  246. package/src/secrets/index.ts +127 -4
  247. package/src/secrets/obfuscator.ts +2328 -105
  248. package/src/session/acp-permission-gate.ts +165 -0
  249. package/src/session/agent-session-error-log.test.ts +1 -1
  250. package/src/session/agent-session-events.ts +66 -0
  251. package/src/session/agent-session-types.ts +343 -0
  252. package/src/session/agent-session.ts +1940 -12218
  253. package/src/session/artifacts.ts +6 -5
  254. package/src/session/async-job-delivery.ts +74 -0
  255. package/src/session/auth-storage.ts +1 -0
  256. package/src/session/bash-runner.ts +326 -0
  257. package/src/session/blob-store.test.ts +56 -0
  258. package/src/session/blob-store.ts +18 -2
  259. package/src/session/checkpoint-entries.ts +81 -0
  260. package/src/session/eval-runner.ts +217 -0
  261. package/src/session/indexed-session-storage.ts +9 -2
  262. package/src/session/irc-bridge.ts +203 -0
  263. package/src/session/messages.ts +266 -1
  264. package/src/session/model-controls.ts +714 -0
  265. package/src/session/prewalk.ts +252 -0
  266. package/src/session/queued-messages.ts +93 -0
  267. package/src/session/redis-session-storage.ts +51 -11
  268. package/src/session/retry-fallback-chains.ts +455 -0
  269. package/src/session/role-models.ts +85 -0
  270. package/src/session/session-advisors.ts +1679 -0
  271. package/src/session/session-context.ts +6 -3
  272. package/src/session/session-entries.ts +8 -0
  273. package/src/session/session-handoff.ts +308 -0
  274. package/src/session/session-history-format.ts +20 -9
  275. package/src/session/session-loader.ts +0 -46
  276. package/src/session/session-maintenance.ts +2983 -0
  277. package/src/session/session-manager.ts +390 -30
  278. package/src/session/session-memory.ts +222 -0
  279. package/src/session/session-provider-boundary.ts +307 -0
  280. package/src/session/session-stats.ts +293 -0
  281. package/src/session/session-tools.ts +980 -0
  282. package/src/session/session-workspace.ts +53 -0
  283. package/src/session/stream-guards.ts +417 -0
  284. package/src/session/streaming-output.ts +52 -5
  285. package/src/session/todo-tracker.ts +380 -0
  286. package/src/session/ttsr-coordinator.ts +496 -0
  287. package/src/session/turn-recovery.ts +1629 -0
  288. package/src/slash-commands/builtin-registry.ts +257 -20
  289. package/src/slash-commands/helpers/session-pin.ts +44 -0
  290. package/src/slash-commands/helpers/usage-report.ts +22 -3
  291. package/src/stt/downloader.ts +0 -2
  292. package/src/stt/index.ts +0 -2
  293. package/src/stt/stt-controller.ts +57 -146
  294. package/src/system-prompt.ts +45 -17
  295. package/src/task/executor.ts +285 -70
  296. package/src/task/index.ts +98 -105
  297. package/src/task/output-manager.ts +25 -3
  298. package/src/task/persisted-revive.ts +4 -3
  299. package/src/task/structured-subagent.ts +1 -0
  300. package/src/tiny/title-client.ts +22 -0
  301. package/src/tools/approval.ts +55 -10
  302. package/src/tools/bash-interactive.ts +116 -86
  303. package/src/tools/bash-skill-urls.ts +28 -2
  304. package/src/tools/bash.ts +339 -123
  305. package/src/tools/browser/launch.ts +9 -1
  306. package/src/tools/browser/tab-supervisor.ts +8 -5
  307. package/src/tools/browser.ts +94 -47
  308. package/src/tools/builtin-names.ts +1 -0
  309. package/src/tools/computer/protocol.ts +28 -0
  310. package/src/tools/computer/supervisor.ts +258 -0
  311. package/src/tools/computer/worker-entry.ts +25 -0
  312. package/src/tools/computer/worker.ts +135 -0
  313. package/src/tools/computer-renderer.ts +108 -0
  314. package/src/tools/computer.ts +433 -0
  315. package/src/tools/context.ts +2 -0
  316. package/src/tools/default-renderer.ts +139 -0
  317. package/src/tools/essential-tools.ts +1 -0
  318. package/src/tools/image-gen.ts +20 -28
  319. package/src/tools/image-providers.ts +50 -0
  320. package/src/tools/index.ts +14 -0
  321. package/src/tools/path-utils.ts +49 -2
  322. package/src/tools/read.ts +156 -88
  323. package/src/tools/renderers.ts +9 -1
  324. package/src/tools/todo.ts +101 -11
  325. package/src/tools/vibe.ts +1 -2
  326. package/src/tools/write.ts +51 -1
  327. package/src/tools/xdev.ts +121 -29
  328. package/src/tts/streaming-player.ts +82 -283
  329. package/src/tts/vocalizer.ts +18 -1
  330. package/src/utils/clipboard.ts +1 -30
  331. package/src/utils/jj.ts +125 -4
  332. package/src/utils/lang-from-path.ts +7 -0
  333. package/src/utils/mac-file-urls.applescript +37 -0
  334. package/src/utils/title-generator.ts +137 -1
  335. package/src/utils/tool-choice.ts +14 -0
  336. package/src/utils/tools-manager.ts +1 -19
  337. package/src/vibe/runtime.ts +852 -72
  338. package/src/web/search/index.ts +3 -6
  339. package/src/web/search/provider.ts +31 -16
  340. package/src/web/search/providers/xai.ts +7 -1
  341. package/src/web/search/types.ts +3 -0
  342. package/dist/types/stt/recorder.d.ts +0 -30
  343. package/dist/types/stt/transcriber.d.ts +0 -14
  344. package/dist/types/stt/wav.d.ts +0 -29
  345. package/dist/types/tts/player.d.ts +0 -32
  346. package/src/stt/recorder.ts +0 -551
  347. package/src/stt/transcriber.ts +0 -60
  348. package/src/stt/wav.ts +0 -173
  349. package/src/tts/player.ts +0 -137
@@ -43,6 +43,44 @@ export interface BashResult {
43
43
  artifactId?: string;
44
44
  workingDir?: string;
45
45
  }
46
+ export interface DirenvPreflightOptions {
47
+ /** Caller-supplied env overlay; these values win over direnv-provided ones. */
48
+ callerEnv?: Record<string, string>;
49
+ signal?: AbortSignal;
50
+ /** Full direnv-load budget (`bash.direnvLoadTimeoutMs`). A positive
51
+ * `callerTimeoutMs` clamps the effective load below this; `0`/undefined
52
+ * leaves the full budget. */
53
+ timeoutMs?: number;
54
+ /** The caller's command deadline (ms). A positive value clamps the direnv
55
+ * load so a cold `.envrc` can't outlast a short-timeout command; `0` or
56
+ * undefined means "no caller clamp" — the load keeps its full `timeoutMs`
57
+ * budget (a disabled command deadline is NOT a 0 ms load). Centralizing the
58
+ * clamp here keeps every backend (executeBash, ACP terminal, PTY) on one
59
+ * contract instead of each re-deriving it. */
60
+ callerTimeoutMs?: number;
61
+ /** `bash.direnv` setting — `"off"` skips the load entirely. */
62
+ direnvSetting: "auto" | "off";
63
+ /** Shell wrapper prefix (profiler/strace) to place *after* the unset prefix,
64
+ * matching `executeBash`'s ordering. Backends that apply their own shell
65
+ * wrapping (ACP `wrapShellLineForClientTerminal`) omit this. */
66
+ commandPrefix?: string | undefined;
67
+ }
68
+ /**
69
+ * Load the repo's direnv/devenv env and fold it into a `(command, env)` pair so
70
+ * every bash backend (one-shot `executeBash`, ACP client terminal, PTY) exposes
71
+ * the same devenv tools. Encapsulates: load the diff, merge `set` under the
72
+ * caller's overlay (caller wins), and prepend a regex-gated `unset -v` for
73
+ * variables the `.envrc` removes (skipping any the caller re-supplied).
74
+ *
75
+ * Returns the possibly-prefixed command plus the merged env, or the inputs
76
+ * unchanged (`env` = `callerEnv`) when direnv is off, absent, or has no `.envrc`.
77
+ * Pure transform: does NOT layer non-interactive env defaults — that stays the
78
+ * caller's job (so interactive PTY/ACP paths keep their own env shape).
79
+ */
80
+ export declare function applyDirenvPreflight(command: string, cwd: string, opts: DirenvPreflightOptions): Promise<{
81
+ command: string;
82
+ env: Record<string, string> | undefined;
83
+ }>;
46
84
  /** Translate `ShellMinimizerSettings` into native `MinimizerOptions`, or `undefined` when disabled. */
47
85
  export declare function buildMinimizerOptions(group: ShellMinimizerSettings): MinimizerOptions | undefined;
48
86
  export declare function isPersistentShellCdCommand(command: string): boolean;
@@ -0,0 +1,33 @@
1
+ /** Default cap on a single `direnv` invocation. The first export for a devenv
2
+ * `.envrc` can build a shell; callers may raise this via `bash.direnvLoadTimeoutMs`. */
3
+ export declare const DEFAULT_DIRENV_TIMEOUT_MS = 30000;
4
+ /** Walk up from `startDir` to the nearest directory containing an `.envrc`. */
5
+ export declare function findEnvrc(startDir: string): Promise<string | null>;
6
+ export interface DirenvExportDiff {
7
+ /** Variables direnv sets to a concrete value. */
8
+ set: Record<string, string>;
9
+ /** Variables direnv removes (JSON `null`). */
10
+ unset: string[];
11
+ }
12
+ /** Parse `direnv export json` output (`{VAR: value|null}`) into set/unset halves. */
13
+ export declare function parseDirenvExport(jsonText: string): DirenvExportDiff;
14
+ /**
15
+ * Resolve the nearest `.envrc` from `cwd` and return its `direnv export` diff
16
+ * (variables to set, and variables direnv removes). Returns `null` when there
17
+ * is no `.envrc`, `direnv` is not installed, the `.envrc` is not on direnv's
18
+ * allow list, or the export fails/times out.
19
+ *
20
+ * direnv's own allow list is honored — an `.envrc` the user has not
21
+ * `direnv allow`ed is NEVER executed or auto-allowed. This keeps OMP's trust
22
+ * boundary identical to the user's own shell: cloning a repo with a poisoned
23
+ * `.envrc` grants it nothing until the user explicitly allows it.
24
+ *
25
+ * Always re-invokes `direnv export json` rather than serving a cached diff:
26
+ * direnv is fast once warm, and its own watch/mtime invalidation is the
27
+ * authoritative freshness signal (a content-hash cache here would go stale when
28
+ * a `watch_file` target changes without the `.envrc` text changing).
29
+ */
30
+ export declare function loadDirenvEnv(cwd: string, opts?: {
31
+ timeoutMs?: number;
32
+ signal?: AbortSignal;
33
+ }): Promise<DirenvExportDiff | null>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `/export` argument parsing, split from `./index.ts` so slash-command
3
+ * registries can parse arguments without eagerly loading the export module's
4
+ * embedded template/tool-view text.
5
+ */
6
+ /** Dark and light TUI theme names bundled into a dual-theme export. */
7
+ export interface ExportThemeNames {
8
+ dark: string;
9
+ light: string;
10
+ }
11
+ /** Parse `/export [--themes] [path]`; paths containing spaces were never supported. */
12
+ export declare function parseExportArgs(args: string): {
13
+ outputPath?: string;
14
+ useUserThemes: boolean;
15
+ };
@@ -1,45 +1,30 @@
1
1
  import type { AgentState } from "@oh-my-pi/pi-agent-core";
2
2
  import type { SessionEntry, SessionHeader } from "../../session/session-entries.js";
3
3
  import { SessionManager } from "../../session/session-manager.js";
4
+ import type { ExportThemeNames } from "./args.js";
5
+ export { type ExportThemeNames, parseExportArgs } from "./args.js";
4
6
  /** Compose the standalone export template: minified CSS, tool renderers, and viewer JS inlined. */
5
7
  export declare function getTemplate(): string;
6
8
  export interface ExportOptions {
7
9
  outputPath?: string;
8
- /**
9
- * Which color palette the export ships with.
10
- * - `"web"` (default) — the omp brand identity (collab-web pink/purple),
11
- * so public HTML exports and the `/s/<id>` share viewer match the live
12
- * `my.omp.sh` client. See `web-palette.ts`.
13
- * - `"theme"` — derive from `themeName` (or the active TUI theme), preserving
14
- * the pre-15.12 behavior where an export mirrored the user's terminal.
15
- */
10
+ /** `"web"` bundles the omp web themes; `"theme"` bundles TUI themes. */
16
11
  palette?: "web" | "theme";
17
- /**
18
- * TUI theme to derive colors from when `palette: "theme"`. Ignored for the
19
- * default `"web"` palette. Resolves to the active TUI theme when omitted.
20
- */
12
+ /** Legacy single TUI theme name. Prefer `themeNames` for dual-theme exports. */
21
13
  themeName?: string;
14
+ /** Dark and light TUI themes to bundle when `palette` is `"theme"`. */
15
+ themeNames?: ExportThemeNames;
22
16
  /** Embed subagent session transcripts found next to the session file (default true). */
23
17
  includeSubSessions?: boolean;
24
18
  }
25
19
  /**
26
- * Generate CSS custom properties for the export `:root`.
20
+ * Generate CSS custom properties for one export theme.
27
21
  *
28
- * Two call shapes:
29
- * `generateThemeVars("web" | "theme", themeName?)` — explicit palette.
30
- * `"web"` (the default for public artifacts) returns the fixed omp brand
31
- * palette from `web-palette.ts` — collab-web pink/purple identity, shared
32
- * with the live `my.omp.sh` client, so exports and the share viewer render
33
- * identically to it. `"theme"` derives from the TUI theme via
34
- * `getResolvedThemeColors(themeName)` plus the three
35
- * `export.{pageBg,cardBg,infoBg}` surface overrides.
36
- * • `generateThemeVars(themeName)` — legacy single-arg form: derive from the
37
- * named TUI theme. Kept so existing callers (and the theme-islight test)
38
- * keep working; equivalent to `generateThemeVars("theme", themeName)`.
39
- *
40
- * Exported for the share-viewer build script.
22
+ * The single-argument theme-name form remains available to callers that need
23
+ * one TUI palette. Standalone HTML uses `generateThemeStyles()` below.
41
24
  */
42
25
  export declare function generateThemeVars(palette?: "web" | "theme" | (string & {}), themeName?: string): Promise<string>;
26
+ /** Generate dark, light, and auto-following CSS rules for a standalone viewer. */
27
+ export declare function generateThemeStyles(palette: "web" | "theme", themeNames?: ExportThemeNames, legacyThemeName?: string): Promise<string>;
43
28
  /** Embedded subagent session transcript, keyed by slash-joined agent path in `SessionData.subSessions`. */
44
29
  export interface SubSession {
45
30
  /** Bare agent id (session file stem), e.g. "ToolAsk". */
@@ -1,117 +1,56 @@
1
- /**
2
- * Web/export palette the omp brand identity shared by the collab-web live
3
- * client (`my.omp.sh/`) and every public HTML export / share viewer (`/s/<id>`).
4
- *
5
- * Why this exists separately from `modes/theme/dark.json`: the `dark` theme is
6
- * the **default TUI theme** — its amber accent (`#febc38`) drives the terminal
7
- * status line, syntax highlighting, thinking levels, and bash/python mode
8
- * colors for every omp user. The public web artifacts want the collab-web
9
- * pink/purple identity instead, so they pin this palette rather than inheriting
10
- * the TUI's. Editing `dark.json` to repurpose it for the web would repaint
11
- * every terminal; this file keeps the two surfaces decoupled.
12
- *
13
- * Token layout emitted as CSS custom properties on `:root`:
14
- * • Legacy export names consumed by `template.css` / `template.js`
15
- * (`--text`, `--body-bg`, `--container-bg`, `--info-bg`, `--accent`,
16
- * `--border`, `--success`, `--error`, `--warning`, `--muted`, `--dim`,
17
- * `--borderAccent`, `--selectedBg`, `--userMessageBg`, `--customMessageBg`,
18
- * `--customMessageLabel`, `--mdHeading`, `--mdLink`, `--mdCode`,
19
- * `--mdListBullet`, `--toolOutput`, `--thinkingText`, syntax*, ).
20
- * • collab-web-native aliases consumed by the `tv-` tool-render bridge
21
- * (`tool-render.css`: `var(--bg-inset, …)`, `var(--fg, …)`, …) so embedded
22
- * tool cards resolve to the *real* collab-web tokens and render
23
- * pixel-identical to the live client.
24
- *
25
- * Alpha-bearing tokens (`--border`, `--ring`, `--accent-muted`, …) keep their
26
- * `oklch(… / N%)` form — flattening them to opaque hex would produce harsh
27
- * white borders and non-matching translucent focus rings. Opaque surfaces are
28
- * sRGB hex (the collab-web `tokens.css` OKLCH dark-theme tokens converted via
29
- * the standard OKLab→linear-sRGB→gamma path); if the live client palette
30
- * changes, regenerate those from there.
31
- */
32
- export declare const WEB_EXPORT_PALETTE: {
33
- readonly "--bg": "#0f0b14";
34
- readonly "--bg-raised": "#16111c";
35
- readonly "--bg-inset": "#09060c";
36
- readonly "--bg-overlay": "#211b28";
37
- readonly "--fg": "#e6e3ea";
38
- readonly "--fg-muted": "#a49faa";
39
- readonly "--fg-faint": "#6e6974";
40
- readonly "--accent": "#ed4abf";
41
- readonly "--accent-muted": "oklch(0.674 0.23 341 / 18%)";
42
- readonly "--ok": "#68ca80";
43
- readonly "--err": "#f05653";
44
- readonly "--warn": "#e4b33f";
45
- readonly "--ring": "oklch(0.817 0.112 205 / 70%)";
46
- readonly "--font-mono": 'ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace';
47
- readonly "--body-bg": "#0f0b14";
48
- readonly "--container-bg": "#16111c";
49
- readonly "--info-bg": "#09060c";
50
- readonly "--text": "#e6e3ea";
51
- readonly "--muted": "#a49faa";
52
- readonly "--dim": "#6e6974";
53
- readonly "--thinkingText": "#a49faa";
54
- readonly "--border": "oklch(1 0 0 / 9%)";
55
- readonly "--borderMuted": "oklch(1 0 0 / 6%)";
56
- readonly "--borderAccent": "#945ff9";
57
- readonly "--selectedBg": "#2d2535";
58
- readonly "--success": "#68ca80";
59
- readonly "--error": "#f05653";
60
- readonly "--warning": "#e4b33f";
61
- readonly "--userMessageBg": "oklch(0.674 0.23 341 / 6%)";
62
- readonly "--userMessageText": "#e6e3ea";
63
- readonly "--customMessageBg": "#211b28";
64
- readonly "--customMessageText": "#a49faa";
65
- readonly "--customMessageLabel": "#b281d6";
66
- readonly "--toolPendingBg": "#16111c";
67
- readonly "--toolSuccessBg": "#09060c";
68
- readonly "--toolErrorBg": "oklch(0.66 0.19 25 / 14%)";
69
- readonly "--toolTitle": "#e6e3ea";
70
- readonly "--toolOutput": "#a49faa";
71
- readonly "--mdHeading": "#ed4abf";
72
- readonly "--mdLink": "#5ad8e5";
73
- readonly "--mdLinkUrl": "#6e6974";
74
- readonly "--mdCode": "#e6e3ea";
75
- readonly "--mdCodeBlock": "#e6e3ea";
76
- readonly "--mdCodeBlockBorder": "oklch(1 0 0 / 9%)";
77
- readonly "--mdQuote": "#a49faa";
78
- readonly "--mdQuoteBorder": "oklch(1 0 0 / 13%)";
79
- readonly "--mdHr": "oklch(1 0 0 / 9%)";
80
- readonly "--mdListBullet": "#ed4abf";
81
- readonly "--toolDiffAdded": "#68ca80";
82
- readonly "--toolDiffRemoved": "#f05653";
83
- readonly "--toolDiffContext": "#6e6974";
84
- readonly "--syntaxComment": "#6e6974";
85
- readonly "--syntaxKeyword": "#945ff9";
86
- readonly "--syntaxFunction": "#e4b33f";
87
- readonly "--syntaxVariable": "#5ad8e5";
88
- readonly "--syntaxString": "#68ca80";
89
- readonly "--syntaxNumber": "#ed4abf";
90
- readonly "--syntaxType": "#b281d6";
91
- readonly "--syntaxOperator": "#e6e3ea";
92
- readonly "--syntaxPunctuation": "#a49faa";
93
- readonly "--thinkingOff": "#6e6974";
94
- readonly "--thinkingMinimal": "#6e6974";
95
- readonly "--thinkingLow": "#945ff9";
96
- readonly "--thinkingMedium": "#b281d6";
97
- readonly "--thinkingHigh": "#ed4abf";
98
- readonly "--thinkingXhigh": "#e4b33f";
99
- readonly "--bashMode": "#5ad8e5";
100
- readonly "--pythonMode": "#e4b33f";
101
- readonly "--statusLineBg": "#0f0b14";
102
- readonly "--statusLineSep": "#6e6974";
103
- readonly "--statusLineModel": "#ed4abf";
104
- readonly "--statusLinePath": "#5ad8e5";
105
- readonly "--statusLineGitClean": "#68ca80";
106
- readonly "--statusLineGitDirty": "#e4b33f";
107
- readonly "--statusLineContext": "#a49faa";
108
- readonly "--statusLineSpend": "#5ad8e5";
109
- readonly "--statusLineStaged": "#68ca80";
110
- readonly "--statusLineDirty": "#e4b33f";
111
- readonly "--statusLineUntracked": "#945ff9";
112
- readonly "--statusLineOutput": "#b281d6";
113
- readonly "--statusLineCost": "#b281d6";
114
- readonly "--statusLineSubagents": "#ed4abf";
1
+ /** omp web palette bundled into standalone exports and the share viewer. */
2
+ export type WebExportScheme = "dark" | "light";
3
+ export declare const WEB_EXPORT_PALETTES: {
4
+ readonly dark: {
5
+ readonly "--bg": "#0f0b14";
6
+ readonly "--bg-raised": "#16111c";
7
+ readonly "--bg-inset": "#09060c";
8
+ readonly "--bg-overlay": "#211b28";
9
+ readonly "--fg": "#e6e3ea";
10
+ readonly "--fg-muted": "#a49faa";
11
+ readonly "--fg-faint": "#6e6974";
12
+ readonly "--accent": "#ed4abf";
13
+ readonly "--accent-muted": "oklch(0.674 0.23 341 / 18%)";
14
+ readonly "--ok": "#68ca80";
15
+ readonly "--err": "#f05653";
16
+ readonly "--warn": "#e4b33f";
17
+ readonly "--border": "oklch(1 0 0 / 9%)";
18
+ readonly "--border-strong": "oklch(1 0 0 / 13%)";
19
+ readonly "--ring": "oklch(0.817 0.112 205 / 70%)";
20
+ readonly "--link": "#5ad8e5";
21
+ readonly "--syntaxComment": "#6e6974";
22
+ readonly "--syntaxKeyword": "#945ff9";
23
+ readonly "--syntaxFunction": "#e4b33f";
24
+ readonly "--syntaxVariable": "#5ad8e5";
25
+ readonly "--syntaxString": "#68ca80";
26
+ readonly "--syntaxNumber": "#ed4abf";
27
+ readonly "--syntaxType": "#b281d6";
28
+ };
29
+ readonly light: {
30
+ readonly "--bg": "oklch(0.985 0.004 307)";
31
+ readonly "--bg-raised": "oklch(1 0 0)";
32
+ readonly "--bg-inset": "oklch(0.95 0.006 307)";
33
+ readonly "--bg-overlay": "oklch(0.965 0.006 307)";
34
+ readonly "--fg": "oklch(0.26 0.03 307)";
35
+ readonly "--fg-muted": "oklch(0.46 0.03 307)";
36
+ readonly "--fg-faint": "oklch(0.58 0.025 307)";
37
+ readonly "--accent": "oklch(0.62 0.23 341)";
38
+ readonly "--accent-muted": "oklch(0.62 0.23 341 / 14%)";
39
+ readonly "--ok": "oklch(0.55 0.13 150)";
40
+ readonly "--err": "oklch(0.55 0.19 25)";
41
+ readonly "--warn": "oklch(0.6 0.13 85)";
42
+ readonly "--border": "oklch(0 0 0 / 10%)";
43
+ readonly "--border-strong": "oklch(0 0 0 / 15%)";
44
+ readonly "--ring": "oklch(0.58 0.13 230 / 70%)";
45
+ readonly "--link": "#0f7a88";
46
+ readonly "--syntaxComment": "#77717c";
47
+ readonly "--syntaxKeyword": "#6d35c7";
48
+ readonly "--syntaxFunction": "#8a6000";
49
+ readonly "--syntaxVariable": "#087f8c";
50
+ readonly "--syntaxString": "#247a3d";
51
+ readonly "--syntaxNumber": "#b51f88";
52
+ readonly "--syntaxType": "#7b3fa2";
53
+ };
115
54
  };
116
- /** Serialize the palette as `--key: value;` declarations for `:root { … }`. */
117
- export declare function webExportThemeVars(): string;
55
+ /** Serialize one web color scheme as CSS custom-property declarations. */
56
+ export declare function webExportThemeVars(scheme: WebExportScheme): string;
@@ -1,4 +1,5 @@
1
1
  import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
2
+ import type { ServiceTierByFamily } from "@oh-my-pi/pi-ai";
2
3
  import { EventBus } from "../../utils/event-bus.js";
3
4
  import type { Extension, ExtensionFactory, ExtensionRuntime as IExtensionRuntime, LoadExtensionsResult, ProviderConfig } from "./types.js";
4
5
  export declare class ExtensionRuntimeNotInitializedError extends Error {
@@ -26,6 +27,8 @@ export declare class ExtensionRuntime implements IExtensionRuntime {
26
27
  setModel(): Promise<boolean>;
27
28
  getThinkingLevel(): ThinkingLevel;
28
29
  setThinkingLevel(): void;
30
+ getServiceTiers(): ServiceTierByFamily;
31
+ setServiceTier(): void;
29
32
  getSessionName(): string | undefined;
30
33
  setSessionName(): Promise<void>;
31
34
  }
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import type { AgentMessage, AgentToolResult, AgentToolUpdateCallback, ThinkingLevel, ToolApproval, ToolLoadMode } from "@oh-my-pi/pi-agent-core";
11
11
  import type { CompactionResult } from "@oh-my-pi/pi-agent-core/compaction";
12
- import type { Api, AssistantMessageEvent, AssistantMessageEventStream, Context, ImageContent, Model, ModelSpec, ProviderResponseMetadata, SimpleStreamOptions, Static, TextContent, TSchema } from "@oh-my-pi/pi-ai";
12
+ import type { Api, AssistantMessageEvent, AssistantMessageEventStream, Context, ImageContent, Model, ModelSpec, ProviderResponseMetadata, ServiceTier, ServiceTierByFamily, ServiceTierFamily, SimpleStreamOptions, Static, TextContent, TSchema } from "@oh-my-pi/pi-ai";
13
13
  import type { OAuthCredentials, OAuthLoginCallbacks } from "@oh-my-pi/pi-ai/oauth/types";
14
14
  import type { AutocompleteItem, AutocompleteProvider, Component, EditorTheme, KeyId, TUI } from "@oh-my-pi/pi-tui";
15
15
  import type { logger as PiLogger } from "@oh-my-pi/pi-utils";
@@ -690,6 +690,8 @@ export interface RegisteredCommand {
690
690
  }
691
691
  /** Handler function type for events */
692
692
  export type ExtensionHandler<E, R = undefined> = (event: E, ctx: ExtensionContext) => Promise<R | void> | R | void;
693
+ /** Service tiers accepted by each provider family. */
694
+ export type ExtensionServiceTier<Family extends ServiceTierFamily> = Family extends "anthropic" ? "priority" : Family extends "google" ? "flex" | "priority" : ServiceTier;
693
695
  /**
694
696
  * ExtensionAPI passed to extension factory functions.
695
697
  */
@@ -806,6 +808,13 @@ export interface ExtensionAPI {
806
808
  getThinkingLevel(): ThinkingLevel | undefined;
807
809
  /** Set thinking level for the current session. */
808
810
  setThinkingLevel(level: ThinkingLevel): void;
811
+ /** Get a snapshot of the current session's per-family service tiers. */
812
+ getServiceTiers(): Readonly<ServiceTierByFamily>;
813
+ /**
814
+ * Set one provider family's service tier for subsequent requests, or clear
815
+ * its session override with `undefined`.
816
+ */
817
+ setServiceTier<Family extends ServiceTierFamily>(family: Family, tier: ExtensionServiceTier<Family> | undefined): void;
809
818
  /** Get the current session name. */
810
819
  getSessionName(): string | undefined;
811
820
  /** Set the session name. Persists to the session file. */
@@ -957,6 +966,8 @@ export type SetActiveToolsHandler = (toolNames: string[]) => Promise<void>;
957
966
  export type SetModelHandler = (model: Model) => Promise<boolean>;
958
967
  export type GetThinkingLevelHandler = () => ThinkingLevel | undefined;
959
968
  export type SetThinkingLevelHandler = (level: ThinkingLevel, persist?: boolean) => void;
969
+ export type GetServiceTiersHandler = () => ServiceTierByFamily;
970
+ export type SetServiceTierHandler = (family: ServiceTierFamily, tier: ServiceTier | undefined) => void;
960
971
  /** Shared state created by loader, used during registration and runtime. */
961
972
  export interface ExtensionRuntimeState {
962
973
  flagValues: Map<string, boolean | string>;
@@ -980,6 +991,8 @@ export interface ExtensionActions {
980
991
  setModel: SetModelHandler;
981
992
  getThinkingLevel: GetThinkingLevelHandler;
982
993
  setThinkingLevel: SetThinkingLevelHandler;
994
+ getServiceTiers?: GetServiceTiersHandler;
995
+ setServiceTier?: SetServiceTierHandler;
983
996
  getSessionName: () => string | undefined;
984
997
  setSessionName: (name: string) => Promise<void>;
985
998
  }
@@ -1018,8 +1031,10 @@ export interface ExtensionCommandContextActions {
1018
1031
  }>;
1019
1032
  reload: () => Promise<void>;
1020
1033
  }
1021
- /** Full runtime = state + actions. */
1034
+ /** Full runtime = state + actions, including host-compatible service-tier fallbacks. */
1022
1035
  export interface ExtensionRuntime extends ExtensionRuntimeState, ExtensionActions {
1036
+ getServiceTiers: GetServiceTiersHandler;
1037
+ setServiceTier: SetServiceTierHandler;
1023
1038
  }
1024
1039
  /** Loaded extension with all registered items. */
1025
1040
  export interface Extension {
@@ -12,6 +12,7 @@
12
12
  * the same module identity as a direct `@oh-my-pi/pi-coding-agent` import.
13
13
  */
14
14
  import { type AuthCredential, type TSchema } from "@oh-my-pi/pi-ai";
15
+ import { type Keybinding } from "@oh-my-pi/pi-tui";
15
16
  import type { PromptTemplate } from "../config/prompt-templates.js";
16
17
  import { Settings } from "../config/settings.js";
17
18
  import type { CreateAgentSessionOptions, CreateAgentSessionResult, LoadExtensionsResult } from "../sdk.js";
@@ -75,6 +76,8 @@ export interface LsOperations {
75
76
  export interface LsToolOptions {
76
77
  operations?: LsOperations;
77
78
  }
79
+ /** Format the active shortcut for legacy extensions that render keybinding hints. */
80
+ export declare function keyText(action: Keybinding): string;
78
81
  /** Parse frontmatter using the historical Pi package-root helper. */
79
82
  export interface ParsedFrontmatter<T extends Record<string, unknown> = Record<string, unknown>> {
80
83
  frontmatter: T;
@@ -58,6 +58,19 @@ export declare function __validateLegacyPiPackageRootOverrides(candidates: Recor
58
58
  export declare function __buildLegacyPiPackageRootOverrides(isCompiled: boolean, bundledModuleKeys?: Iterable<string>): Record<string, string>;
59
59
  /** Test seam for compiled-binary legacy extension source rewriting. */
60
60
  export declare function __rewriteLegacyExtensionSourceForTests(source: string, importerPath: string, mtimeTag?: string | null, resolvedImportMtimeTag?: string | null): Promise<string>;
61
+ /**
62
+ * Register {@link evaluateGraphCommonJs} as the graph-owned CommonJS require
63
+ * bridge on `globalThis`, first-wins.
64
+ *
65
+ * On source-link installs the `@(scope)/pi-coding-agent` root shim is served
66
+ * from `src/`, so an extension import can evaluate a second instance of this
67
+ * module with empty graph state. An unconditional set would let that empty
68
+ * instance clobber the host bundle's populated bridge and break transitive
69
+ * CommonJS resolution (#6449); guarding preserves the first (host-owned)
70
+ * registration. Idempotent: a subsequent call with a value already present is a
71
+ * no-op.
72
+ */
73
+ export declare function ensureGraphCommonJsRequireRegistered(): void;
61
74
  /**
62
75
  * Load a legacy Pi extension module from its real on-disk location.
63
76
  *
@@ -0,0 +1,2 @@
1
+ /** Generates the Codex DeviceCheck attestation envelope sent as `x-oai-attestation` on ChatGPT-OAuth requests. */
2
+ export declare function generateCodexAttestation(): Promise<string | undefined>;
@@ -0,0 +1,48 @@
1
+ import type { AssistantMessage } from "@oh-my-pi/pi-ai";
2
+ import type { AgentSession } from "../session/agent-session.js";
3
+ import type { LivePhase } from "./visualizer.js";
4
+ /** Incremental or final transcript for one realtime conversational turn. */
5
+ export interface LiveTranscript {
6
+ role: "user" | "assistant";
7
+ text: string;
8
+ /** Monotonic role-local turn number used to coalesce streaming updates. */
9
+ turn: number;
10
+ final: boolean;
11
+ }
12
+ /** UI notifications emitted during a live session. */
13
+ export interface LiveSessionCallbacks {
14
+ /** Reports connection and activity phase changes. */
15
+ onPhase(phase: LivePhase): void;
16
+ /** Reports clamped microphone and speaker RMS levels. */
17
+ onLevels(input: number, output: number): void;
18
+ /** Reports the latest available conversational transcript. */
19
+ onTranscript(transcript: LiveTranscript | undefined): void;
20
+ /** Reports one terminal stop, optionally carrying its cause. */
21
+ onTerminal(error?: Error): void;
22
+ }
23
+ /** Dependencies and presentation callbacks for a live session. */
24
+ export interface LiveSessionControllerOptions {
25
+ /** Agent session that performs all delegated coding work. */
26
+ session: AgentSession;
27
+ /** UI callbacks for live session state. */
28
+ callbacks: LiveSessionCallbacks;
29
+ /** Extracts visible assistant text using the caller's normal UI rules. */
30
+ extractAssistantText(message: AssistantMessage): string;
31
+ /** Realtime output voice, defaulting to sol. */
32
+ voice?: string;
33
+ }
34
+ /** Coordinates the realtime conversational surface with normal AgentSession turns. */
35
+ export declare class LiveSessionController {
36
+ #private;
37
+ constructor(options: LiveSessionControllerOptions);
38
+ /** Current realtime call phase. */
39
+ get phase(): LivePhase;
40
+ /** Whether microphone input is currently muted. */
41
+ get muted(): boolean;
42
+ /** Connects the realtime surface and starts microphone streaming. */
43
+ start(): Promise<void>;
44
+ /** Toggles microphone capture while leaving output and the session connected. */
45
+ toggleMute(): void;
46
+ /** Stops recording, closes the live session, and emits one terminal callback. */
47
+ stop(): Promise<void>;
48
+ }
@@ -0,0 +1,85 @@
1
+ /** Frameless Bidi model used by Codex Desktop live calls. */
2
+ export declare const LIVE_MODEL: "gpt-live-1-codex";
3
+ /** Maximum UTF-8 payload size accepted by each context append. */
4
+ export declare const CONTEXT_CHUNK_BYTES = 500;
5
+ /** Semantic stream selected for appended Frameless Bidi context. */
6
+ export type LiveContextChannel = "speakable" | "commentary";
7
+ /** Text content item accepted by Frameless Bidi context appends. */
8
+ export type LiveInputTextContent = {
9
+ type: "input_text";
10
+ text: string;
11
+ };
12
+ /** Session object posted alongside the SDP when opening a live call. */
13
+ export type LiveSessionPayload = {
14
+ model: typeof LIVE_MODEL;
15
+ instructions: string;
16
+ audio: {
17
+ output: {
18
+ voice: string;
19
+ };
20
+ };
21
+ delegation: {
22
+ type: "client";
23
+ };
24
+ };
25
+ /** Messages sent by the client over the Frameless Bidi data channel. */
26
+ export type LiveClientMessage = {
27
+ type: "delegation.context.append";
28
+ delegation_item_id: string;
29
+ channel?: LiveContextChannel;
30
+ content: LiveInputTextContent[];
31
+ } | {
32
+ type: "session.context.append";
33
+ channel?: LiveContextChannel;
34
+ content: LiveInputTextContent[];
35
+ } | {
36
+ type: "session.close";
37
+ };
38
+ /** Parsed Frameless Bidi server events, including unsupported wire event types. */
39
+ export type LiveServerEvent = {
40
+ type: "session.started" | "session.updated";
41
+ session: {
42
+ id: string;
43
+ instructions?: string;
44
+ };
45
+ } | {
46
+ type: "output_audio.delta";
47
+ audio: string;
48
+ } | {
49
+ type: "input_transcript.added" | "output_transcript.added";
50
+ item: {
51
+ text: string;
52
+ };
53
+ } | {
54
+ type: "turn.done";
55
+ turn: {
56
+ role: "user" | "assistant";
57
+ transcript: string;
58
+ };
59
+ } | {
60
+ type: "delegation.created";
61
+ item: {
62
+ type: "delegation";
63
+ target: "client";
64
+ id: string;
65
+ content: LiveInputTextContent[];
66
+ };
67
+ } | {
68
+ type: "error";
69
+ message: string;
70
+ } | {
71
+ type: "unknown";
72
+ wireType: string;
73
+ };
74
+ /** Parse a JSON string or decoded value from the Frameless Bidi data channel. */
75
+ export declare function parseLiveServerEvent(payload: unknown): LiveServerEvent | null;
76
+ /** Build the session object posted in the multipart WebRTC call request. */
77
+ export declare function buildLiveSessionPayload(instructions: string, voice: string): LiveSessionPayload;
78
+ /** Build a context append associated with a server-created delegation. */
79
+ export declare function buildDelegationContextAppend(delegationItemId: string, text: string, channel?: LiveContextChannel): LiveClientMessage;
80
+ /** Build context appended to the live session outside a delegation. */
81
+ export declare function buildSessionContextAppend(text: string, channel?: LiveContextChannel): LiveClientMessage;
82
+ /** Build the message that gracefully closes a live session. */
83
+ export declare function buildSessionClose(): LiveClientMessage;
84
+ /** Split context into character-safe chunks of at most 500 UTF-8 bytes. */
85
+ export declare function chunkLiveContext(text: string): string[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import { type AuthStorage } from "@oh-my-pi/pi-ai";
2
+ import { type LiveClientMessage, type LiveServerEvent } from "./protocol.js";
3
+ /** Callbacks emitted by the live WebRTC transport. */
4
+ export interface LiveTransportCallbacks {
5
+ onEvent(event: LiveServerEvent): void;
6
+ onOutputLevel(level: number): void;
7
+ }
8
+ /** Configuration required to establish a Codex live call. */
9
+ export interface LiveTransportOptions {
10
+ authStorage: AuthStorage;
11
+ sessionId: string;
12
+ instructions: string;
13
+ voice: string;
14
+ callbacks: LiveTransportCallbacks;
15
+ signal?: AbortSignal;
16
+ }
17
+ /** Extracts the server-assigned `rtc_*` call ID from a signaling Location header. */
18
+ export declare function parseLiveCallId(location: string | null): string | undefined;
19
+ /** Builds the Frameless Bidi sideband WebSocket URL for an accepted Codex call. */
20
+ export declare function buildLiveSidebandUrl(callId: string): string;
21
+ /** Native WebRTC transport for a Codex Frameless Bidi live session. */
22
+ export declare class CodexLiveTransport {
23
+ #private;
24
+ constructor(options: LiveTransportOptions);
25
+ /** Establish the native peer, perform Codex signaling, and wait for the data channel. */
26
+ connect(): Promise<void>;
27
+ /** Serialize one Frameless Bidi control message onto the call's sideband WebSocket. */
28
+ send(message: LiveClientMessage): Promise<void>;
29
+ /** Queue 16 kHz mono Float32 PCM for native Opus transmission. */
30
+ pushAudio(samples: Float32Array): void;
31
+ /** Enable or disable the native audio source and discard partial input when muted. */
32
+ setMuted(muted: boolean): Promise<void>;
33
+ /** Stop sideband signaling and the native WebRTC media peer. Safe to call repeatedly. */
34
+ close(): Promise<void>;
35
+ }