@phren/cli 0.2.15 → 0.3.0

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 (392) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-instructions.d.ts +12 -0
  3. package/dist/agent-instructions.js +52 -0
  4. package/dist/bridge/agent-hook-stores.d.ts +32 -0
  5. package/dist/bridge/agent-hook-stores.js +67 -0
  6. package/dist/bridge/agent-hooks.d.ts +195 -2
  7. package/dist/bridge/agent-hooks.js +1049 -38
  8. package/dist/bridge/canary.d.ts +27 -0
  9. package/dist/bridge/canary.js +189 -0
  10. package/dist/bridge/changes.d.ts +57 -0
  11. package/dist/bridge/changes.js +403 -0
  12. package/dist/bridge/client.d.ts +3 -0
  13. package/dist/bridge/client.js +36 -0
  14. package/dist/bridge/code-note.d.ts +23 -0
  15. package/dist/bridge/code-note.js +51 -0
  16. package/dist/bridge/code-routes.d.ts +151 -0
  17. package/dist/bridge/code-routes.js +442 -0
  18. package/dist/bridge/codex-threads.d.ts +27 -0
  19. package/dist/bridge/codex-threads.js +442 -0
  20. package/dist/bridge/command.d.ts +7 -0
  21. package/dist/bridge/command.js +50 -5
  22. package/dist/bridge/computer-names.d.ts +4 -0
  23. package/dist/bridge/computer-names.js +16 -0
  24. package/dist/bridge/computers.d.ts +9 -0
  25. package/dist/bridge/computers.js +111 -0
  26. package/dist/bridge/context.d.ts +14 -0
  27. package/dist/bridge/context.js +149 -0
  28. package/dist/bridge/dispatch-command.d.ts +3 -0
  29. package/dist/bridge/dispatch-command.js +93 -0
  30. package/dist/bridge/dispatch-hosts.d.ts +23 -0
  31. package/dist/bridge/dispatch-hosts.js +25 -0
  32. package/dist/bridge/dispatch-returns.d.ts +125 -0
  33. package/dist/bridge/dispatch-returns.js +283 -0
  34. package/dist/bridge/dispatch-tree.d.ts +54 -0
  35. package/dist/bridge/dispatch-tree.js +198 -0
  36. package/dist/bridge/dispatch.d.ts +210 -0
  37. package/dist/bridge/dispatch.js +286 -0
  38. package/dist/bridge/enroll.d.ts +31 -0
  39. package/dist/bridge/enroll.js +236 -0
  40. package/dist/bridge/fanout-messages.d.ts +74 -0
  41. package/dist/bridge/fanout-messages.js +230 -0
  42. package/dist/bridge/fanouts.d.ts +160 -0
  43. package/dist/bridge/fanouts.js +702 -0
  44. package/dist/bridge/file-range.d.ts +16 -0
  45. package/dist/bridge/file-range.js +90 -0
  46. package/dist/bridge/files.d.ts +20 -0
  47. package/dist/bridge/files.js +54 -0
  48. package/dist/bridge/git-publish.d.ts +23 -0
  49. package/dist/bridge/git-publish.js +145 -0
  50. package/dist/bridge/git-worktrees.d.ts +21 -0
  51. package/dist/bridge/git-worktrees.js +150 -0
  52. package/dist/bridge/git.d.ts +54 -0
  53. package/dist/bridge/git.js +552 -0
  54. package/dist/bridge/grants.d.ts +31 -0
  55. package/dist/bridge/grants.js +181 -0
  56. package/dist/bridge/hand-off.d.ts +79 -0
  57. package/dist/bridge/hand-off.js +151 -0
  58. package/dist/bridge/health.d.ts +128 -0
  59. package/dist/bridge/health.js +260 -0
  60. package/dist/bridge/herdr.d.ts +79 -6
  61. package/dist/bridge/herdr.js +292 -27
  62. package/dist/bridge/hook-main.js +2 -0
  63. package/dist/bridge/install.d.ts +28 -1
  64. package/dist/bridge/install.js +225 -38
  65. package/dist/bridge/launch-worktree.d.ts +21 -0
  66. package/dist/bridge/launch-worktree.js +70 -0
  67. package/dist/bridge/limits.d.ts +20 -0
  68. package/dist/bridge/limits.js +65 -0
  69. package/dist/bridge/locate.d.ts +16 -0
  70. package/dist/bridge/locate.js +75 -0
  71. package/dist/bridge/metrics.d.ts +29 -0
  72. package/dist/bridge/metrics.js +71 -0
  73. package/dist/bridge/model-switch.d.ts +35 -0
  74. package/dist/bridge/model-switch.js +250 -0
  75. package/dist/bridge/models.d.ts +46 -0
  76. package/dist/bridge/models.js +257 -0
  77. package/dist/bridge/opencode-approvals.d.ts +6 -0
  78. package/dist/bridge/opencode-approvals.js +60 -0
  79. package/dist/bridge/pane-text.d.ts +15 -0
  80. package/dist/bridge/pane-text.js +23 -0
  81. package/dist/bridge/peers.d.ts +27 -0
  82. package/dist/bridge/peers.js +130 -0
  83. package/dist/bridge/projects.d.ts +12 -1
  84. package/dist/bridge/projects.js +268 -20
  85. package/dist/bridge/protocol.d.ts +35 -2
  86. package/dist/bridge/protocol.js +61 -7
  87. package/dist/bridge/push.d.ts +83 -0
  88. package/dist/bridge/push.js +199 -0
  89. package/dist/bridge/questions.d.ts +38 -0
  90. package/dist/bridge/questions.js +205 -0
  91. package/dist/bridge/schedule-format.d.ts +103 -0
  92. package/dist/bridge/schedule-format.js +266 -0
  93. package/dist/bridge/schedule-launch.d.ts +11 -0
  94. package/dist/bridge/schedule-launch.js +169 -0
  95. package/dist/bridge/schedule-watch.d.ts +54 -0
  96. package/dist/bridge/schedule-watch.js +255 -0
  97. package/dist/bridge/schedules.d.ts +48 -0
  98. package/dist/bridge/schedules.js +205 -0
  99. package/dist/bridge/server-launch.d.ts +14 -0
  100. package/dist/bridge/server-launch.js +218 -0
  101. package/dist/bridge/server-overview.d.ts +45 -0
  102. package/dist/bridge/server-overview.js +102 -0
  103. package/dist/bridge/server-pane-routes.d.ts +36 -0
  104. package/dist/bridge/server-pane-routes.js +479 -0
  105. package/dist/bridge/server-routes.d.ts +108 -0
  106. package/dist/bridge/server-routes.js +556 -0
  107. package/dist/bridge/server-stream.d.ts +46 -0
  108. package/dist/bridge/server-stream.js +253 -0
  109. package/dist/bridge/server.d.ts +3 -15
  110. package/dist/bridge/server.js +162 -264
  111. package/dist/bridge/session-servers.d.ts +24 -0
  112. package/dist/bridge/session-servers.js +136 -0
  113. package/dist/bridge/side-questions.d.ts +74 -0
  114. package/dist/bridge/side-questions.js +252 -0
  115. package/dist/bridge/simulators.d.ts +28 -0
  116. package/dist/bridge/simulators.js +198 -0
  117. package/dist/bridge/speech-transcribe.d.ts +24 -0
  118. package/dist/bridge/speech-transcribe.js +124 -0
  119. package/dist/bridge/speech.d.ts +35 -0
  120. package/dist/bridge/speech.js +98 -0
  121. package/dist/bridge/steps.d.ts +13 -0
  122. package/dist/bridge/steps.js +222 -0
  123. package/dist/bridge/tab-activity.d.ts +18 -0
  124. package/dist/bridge/tab-activity.js +99 -0
  125. package/dist/bridge/terminal-choice.d.ts +64 -0
  126. package/dist/bridge/terminal-choice.js +281 -0
  127. package/dist/bridge/transcript-claude.d.ts +22 -0
  128. package/dist/bridge/transcript-claude.js +353 -0
  129. package/dist/bridge/transcript-codex.d.ts +30 -0
  130. package/dist/bridge/transcript-codex.js +282 -0
  131. package/dist/bridge/transcript-copilot.d.ts +4 -0
  132. package/dist/bridge/transcript-copilot.js +14 -0
  133. package/dist/bridge/transcript-opencode.d.ts +5 -0
  134. package/dist/bridge/transcript-opencode.js +26 -0
  135. package/dist/bridge/transcript-preview.d.ts +96 -0
  136. package/dist/bridge/transcript-preview.js +491 -0
  137. package/dist/bridge/transcripts.d.ts +81 -4
  138. package/dist/bridge/transcripts.js +332 -67
  139. package/dist/bridge/transport.d.ts +3 -0
  140. package/dist/bridge/transport.js +96 -15
  141. package/dist/bridge/uploads.d.ts +15 -0
  142. package/dist/bridge/uploads.js +44 -2
  143. package/dist/bridge/usage.d.ts +124 -0
  144. package/dist/bridge/usage.js +859 -0
  145. package/dist/bridge-hook.mjs +46545 -21051
  146. package/dist/cli/actions.js +14 -1
  147. package/dist/cli/config-policy.js +25 -0
  148. package/dist/cli/config-proactivity.d.ts +3 -1
  149. package/dist/cli/config-proactivity.js +35 -3
  150. package/dist/cli/config.js +4 -1
  151. package/dist/cli/extract.d.ts +0 -8
  152. package/dist/cli/extract.js +4 -7
  153. package/dist/cli/govern.js +5 -2
  154. package/dist/cli/hooks-globs.js +1 -1
  155. package/dist/cli/hooks.d.ts +1 -1
  156. package/dist/cli/hooks.js +9 -7
  157. package/dist/cli/namespaces-projects.js +12 -6
  158. package/dist/cli/namespaces-store.js +37 -6
  159. package/dist/cli/namespaces-tasks.js +1 -1
  160. package/dist/cli/schedules.d.ts +1 -0
  161. package/dist/cli/schedules.js +164 -0
  162. package/dist/cli/session-background.js +1 -1
  163. package/dist/cli/session-git.d.ts +8 -5
  164. package/dist/cli/session-git.js +45 -120
  165. package/dist/cli/session-start.js +3 -1
  166. package/dist/cli/session-stop.js +19 -8
  167. package/dist/cli/team.js +13 -10
  168. package/dist/cli-handlers.d.ts +1 -1
  169. package/dist/cli-handlers.js +8 -4
  170. package/dist/cli-help.d.ts +5 -4
  171. package/dist/cli-help.js +15 -15
  172. package/dist/cli-registry.d.ts +4 -1
  173. package/dist/cli-registry.js +119 -6
  174. package/dist/content/archive.js +2 -2
  175. package/dist/content/citation.d.ts +11 -0
  176. package/dist/content/citation.js +18 -0
  177. package/dist/content/learning.js +2 -0
  178. package/dist/content/summarize.d.ts +14 -15
  179. package/dist/content/summarize.js +60 -5
  180. package/dist/content/validate.d.ts +17 -4
  181. package/dist/content/validate.js +200 -122
  182. package/dist/core/project-registry.d.ts +26 -0
  183. package/dist/core/project-registry.js +573 -0
  184. package/dist/core/project.js +2 -3
  185. package/dist/data/access.d.ts +16 -1
  186. package/dist/data/access.js +31 -3
  187. package/dist/data/tasks.d.ts +18 -3
  188. package/dist/data/tasks.js +8 -7
  189. package/dist/entrypoint.js +44 -10
  190. package/dist/fanout/adapters/claude.d.ts +2 -0
  191. package/dist/fanout/adapters/claude.js +7 -0
  192. package/dist/fanout/adapters/codex.d.ts +2 -0
  193. package/dist/fanout/adapters/codex.js +9 -0
  194. package/dist/fanout/adapters/opencode.d.ts +4 -0
  195. package/dist/fanout/adapters/opencode.js +9 -0
  196. package/dist/fanout/adapters/types.d.ts +21 -0
  197. package/dist/fanout/adapters/types.js +3 -0
  198. package/dist/fanout/command.d.ts +2 -0
  199. package/dist/fanout/command.js +78 -0
  200. package/dist/fanout/launcher.d.ts +27 -0
  201. package/dist/fanout/launcher.js +156 -0
  202. package/dist/fanout/opencode-serve.d.ts +24 -0
  203. package/dist/fanout/opencode-serve.js +191 -0
  204. package/dist/fanout/picker.d.ts +91 -0
  205. package/dist/fanout/picker.js +51 -0
  206. package/dist/fanout/usage.d.ts +5 -0
  207. package/dist/fanout/usage.js +51 -0
  208. package/dist/fanout/watchdog.d.ts +10 -0
  209. package/dist/fanout/watchdog.js +27 -0
  210. package/dist/filenames.d.ts +9 -0
  211. package/dist/filenames.js +11 -0
  212. package/dist/finding/context.js +4 -22
  213. package/dist/generated/memory-ui-graph.browser.js +525 -419
  214. package/dist/governance/policy-constants.d.ts +11 -0
  215. package/dist/governance/policy-constants.js +9 -0
  216. package/dist/governance/policy.d.ts +5 -8
  217. package/dist/governance/policy.js +11 -8
  218. package/dist/graph-core/camera.d.ts +24 -0
  219. package/dist/graph-core/camera.js +18 -0
  220. package/dist/graph-core/index.d.ts +2 -0
  221. package/dist/graph-core/index.js +2 -0
  222. package/dist/graph-core/labels.d.ts +77 -0
  223. package/dist/graph-core/labels.js +124 -0
  224. package/dist/graph-core/model.d.ts +13 -0
  225. package/dist/graph-core/model.js +33 -0
  226. package/dist/graph-core/types.d.ts +2 -0
  227. package/dist/home-paths.d.ts +7 -0
  228. package/dist/home-paths.js +21 -0
  229. package/dist/hooks.d.ts +3 -15
  230. package/dist/hooks.js +14 -1
  231. package/dist/index.js +24 -2
  232. package/dist/init/guard-globals.d.ts +1 -1
  233. package/dist/init/guard-globals.js +4 -4
  234. package/dist/init/init-configure.js +3 -3
  235. package/dist/init/init-uninstall.js +15 -5
  236. package/dist/init/init-walkthrough.js +1 -1
  237. package/dist/init/init.js +26 -6
  238. package/dist/init/management-preset.d.ts +1 -1
  239. package/dist/init/management-preset.js +2 -2
  240. package/dist/init/preferences.js +1 -1
  241. package/dist/init/self-wiring.js +1 -1
  242. package/dist/init/setup.d.ts +3 -26
  243. package/dist/init/setup.js +68 -593
  244. package/dist/init/shared.js +2 -0
  245. package/dist/init/store-gitignore.d.ts +1 -6
  246. package/dist/init/store-gitignore.js +2 -8
  247. package/dist/init/teardown.d.ts +1 -1
  248. package/dist/init/teardown.js +2 -2
  249. package/dist/link/context-imports.d.ts +15 -0
  250. package/dist/link/context-imports.js +101 -0
  251. package/dist/link/context.js +1 -1
  252. package/dist/link/doctor.d.ts +22 -1
  253. package/dist/link/doctor.js +128 -58
  254. package/dist/link/link.js +29 -61
  255. package/dist/link/refresh.js +2 -2
  256. package/dist/link/skills.js +26 -5
  257. package/dist/machine-identity.d.ts +3 -0
  258. package/dist/machine-identity.js +6 -0
  259. package/dist/mcp/profile.d.ts +2 -19
  260. package/dist/mcp/profile.js +64 -22
  261. package/dist/memory-ui-graph.runtime.js +525 -419
  262. package/dist/modules/code-package.d.ts +16 -0
  263. package/dist/modules/code-package.js +160 -0
  264. package/dist/modules/command.d.ts +2 -0
  265. package/dist/modules/command.js +67 -0
  266. package/dist/modules/config.d.ts +4 -0
  267. package/dist/modules/config.js +70 -0
  268. package/dist/modules/manifest.d.ts +41 -0
  269. package/dist/modules/manifest.js +1 -0
  270. package/dist/modules/provision.d.ts +3 -0
  271. package/dist/modules/provision.js +84 -0
  272. package/dist/modules/registry.d.ts +16 -0
  273. package/dist/modules/registry.js +250 -0
  274. package/dist/modules/runtime.d.ts +15 -0
  275. package/dist/modules/runtime.js +59 -0
  276. package/dist/package-metadata.js +10 -2
  277. package/dist/phren-dotenv.js +4 -2
  278. package/dist/phren-paths.d.ts +3 -2
  279. package/dist/phren-paths.js +4 -5
  280. package/dist/profile-store.js +43 -8
  281. package/dist/project-config.d.ts +19 -1
  282. package/dist/project-config.js +29 -3
  283. package/dist/project-topics.d.ts +1 -0
  284. package/dist/project-topics.js +13 -10
  285. package/dist/provider-adapters.js +1 -4
  286. package/dist/query-correlation.js +6 -6
  287. package/dist/session/artifacts.js +5 -5
  288. package/dist/session/checkpoints.js +5 -0
  289. package/dist/session/utils.d.ts +2 -2
  290. package/dist/session/utils.js +6 -6
  291. package/dist/shared/content.d.ts +1 -1
  292. package/dist/shared/content.js +1 -1
  293. package/dist/shared/data-utils.js +1 -1
  294. package/dist/shared/fragment-graph.d.ts +1 -1
  295. package/dist/shared/fragment-graph.js +5 -5
  296. package/dist/shared/index.js +48 -7
  297. package/dist/shared/retrieval.d.ts +18 -3
  298. package/dist/shared/retrieval.js +101 -12
  299. package/dist/shared/search-fallback.js +4 -6
  300. package/dist/shared/sqljs.d.ts +2 -0
  301. package/dist/shared/sqljs.js +4 -2
  302. package/dist/shared.d.ts +0 -1
  303. package/dist/shared.js +0 -1
  304. package/dist/shell/input.d.ts +1 -5
  305. package/dist/shell/input.js +16 -10
  306. package/dist/shell/palette.d.ts +2 -2
  307. package/dist/shell/palette.js +3 -7
  308. package/dist/shell/render.d.ts +3 -1
  309. package/dist/shell/render.js +4 -4
  310. package/dist/shell/shell.js +4 -1
  311. package/dist/shell/types.d.ts +1 -0
  312. package/dist/shell/types.js +4 -0
  313. package/dist/shell/view.d.ts +0 -4
  314. package/dist/shell/view.js +19 -27
  315. package/dist/skill/registry.js +25 -17
  316. package/dist/skill/state.d.ts +3 -0
  317. package/dist/skill/state.js +13 -7
  318. package/dist/status.js +38 -17
  319. package/dist/store-registry.d.ts +44 -18
  320. package/dist/store-registry.js +169 -60
  321. package/dist/store-weight.d.ts +1 -6
  322. package/dist/store-weight.js +4 -2
  323. package/dist/sync/auth-doctor.d.ts +8 -0
  324. package/dist/sync/auth-doctor.js +27 -0
  325. package/dist/sync/auth.d.ts +27 -0
  326. package/dist/sync/auth.js +114 -0
  327. package/dist/sync/conflict-resolve.d.ts +9 -0
  328. package/dist/sync/conflict-resolve.js +146 -0
  329. package/dist/sync/git-state.d.ts +4 -0
  330. package/dist/sync/git-state.js +49 -0
  331. package/dist/sync/outcome.d.ts +34 -0
  332. package/dist/sync/outcome.js +57 -0
  333. package/dist/sync/pull.d.ts +15 -7
  334. package/dist/sync/pull.js +84 -35
  335. package/dist/sync/store-merge.d.ts +29 -0
  336. package/dist/sync/store-merge.js +137 -0
  337. package/dist/sync/task-merge.d.ts +22 -0
  338. package/dist/sync/task-merge.js +158 -0
  339. package/dist/task/github.js +1 -1
  340. package/dist/task/lifecycle.d.ts +5 -0
  341. package/dist/task/lifecycle.js +67 -23
  342. package/dist/terminal-text.d.ts +5 -0
  343. package/dist/terminal-text.js +11 -0
  344. package/dist/test-global-setup.js +7 -0
  345. package/dist/tool-registry.d.ts +1 -1
  346. package/dist/tool-registry.js +3 -1
  347. package/dist/tools/code.d.ts +3 -0
  348. package/dist/tools/code.js +186 -0
  349. package/dist/tools/config.js +8 -0
  350. package/dist/tools/data.js +14 -7
  351. package/dist/tools/dispatch.d.ts +2 -0
  352. package/dist/tools/dispatch.js +66 -0
  353. package/dist/tools/finding.d.ts +11 -0
  354. package/dist/tools/finding.js +180 -123
  355. package/dist/tools/ops.js +5 -2
  356. package/dist/tools/search.js +21 -8
  357. package/dist/tools/session.js +21 -22
  358. package/dist/tools/tasks.js +8 -2
  359. package/dist/tools/types.d.ts +2 -2
  360. package/dist/tools/types.js +2 -2
  361. package/dist/ui/assets.js +1 -1
  362. package/dist/ui/data.js +14 -15
  363. package/dist/ui/deep-void.d.ts +1 -1
  364. package/dist/ui/deep-void.js +0 -1
  365. package/dist/ui/graph-chrome.d.ts +1 -1
  366. package/dist/ui/graph-chrome.js +51 -0
  367. package/dist/ui/page.js +5 -5
  368. package/dist/ui/scripts.js +67 -30
  369. package/dist/ui/server.js +52 -7
  370. package/dist/update.js +22 -11
  371. package/dist/utils-fts.js +1 -0
  372. package/dist/utils-helpers.d.ts +7 -0
  373. package/dist/utils-helpers.js +17 -0
  374. package/dist/utils.d.ts +1 -1
  375. package/dist/utils.js +1 -1
  376. package/package.json +49 -7
  377. package/plugins/opencode/phren-transcript.js +340 -0
  378. package/starter/README.md +4 -4
  379. package/starter/global/{CLAUDE.md → AGENTS.md} +2 -2
  380. package/starter/global/skills/conductor/SKILL.md +106 -0
  381. package/starter/global/skills/fanout/SKILL.md +20 -0
  382. package/starter/global/skills/phren-discover/SKILL.md +6 -6
  383. package/starter/global/skills/phren-init/SKILL.md +4 -4
  384. package/starter/global/skills/phren-sync/SKILL.md +3 -3
  385. package/starter/templates/frontend/reference/README.md +1 -1
  386. package/starter/templates/library/reference/README.md +1 -1
  387. package/starter/templates/monorepo/reference/README.md +1 -1
  388. package/starter/templates/python-project/reference/README.md +1 -1
  389. /package/starter/templates/frontend/{CLAUDE.md → AGENTS.md} +0 -0
  390. /package/starter/templates/library/{CLAUDE.md → AGENTS.md} +0 -0
  391. /package/starter/templates/monorepo/{CLAUDE.md → AGENTS.md} +0 -0
  392. /package/starter/templates/python-project/{CLAUDE.md → AGENTS.md} +0 -0
@@ -0,0 +1,75 @@
1
+ import { realpathSync } from "node:fs";
2
+ import { readFile, stat } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import path from "node:path";
5
+ import { BridgeError } from "./protocol.js";
6
+ import { herdrRoot } from "./herdr.js";
7
+ import { phrenStoreRoot } from "./transcripts.js";
8
+ const PROJECT_NAME = /^[a-z0-9][a-z0-9-]*$/;
9
+ const SEARCH_ROOTS = ["", "Sites", "Projects", "projects", "Code", "code", "dev", "src", "repos", "workspace"];
10
+ export async function locateProject(project, activity, env = process.env) {
11
+ if (!PROJECT_NAME.test(project) || project.length > 100)
12
+ throw new BridgeError(400, "Invalid project name.");
13
+ const found = [];
14
+ const seen = new Set();
15
+ const offer = async (directory, source, lastSeen) => {
16
+ let dir = path.resolve(directory);
17
+ try {
18
+ if (!(await stat(dir)).isDirectory())
19
+ return;
20
+ // On a case-insensitive disk ~/projects and ~/Projects are one folder;
21
+ // the real path (native, so it carries the on-disk case) dedupes them.
22
+ dir = realpathSync.native(dir);
23
+ }
24
+ catch {
25
+ return; /* not on this computer */
26
+ }
27
+ if (seen.has(dir))
28
+ return;
29
+ seen.add(dir);
30
+ found.push({ directory: dir, source, ...(lastSeen ? { lastSeen } : {}) });
31
+ };
32
+ // Paths from journals and Herdr use whichever separator the computer
33
+ // does; split on both so Windows folders are trimmed like POSIX ones.
34
+ const segments = (directory) => directory.split(/[\\/]/);
35
+ const namesProject = (directory) => segments(directory).includes(project);
36
+ const trimmed = (directory) => {
37
+ const parts = segments(directory);
38
+ return parts.slice(0, parts.lastIndexOf(project) + 1).join(path.sep);
39
+ };
40
+ // 1. Folders an agent session ran in, newest first — the strongest signal
41
+ // that this is the folder the person means.
42
+ for (const event of [...activity].reverse()) {
43
+ const directory = typeof event.directory === "string" ? event.directory : undefined;
44
+ if (directory && path.isAbsolute(directory) && namesProject(directory)) {
45
+ // Trim to the project segment so a session started in a subfolder
46
+ // still opens the project itself.
47
+ await offer(trimmed(directory), "activity", typeof event.at === "string" ? event.at : undefined);
48
+ }
49
+ }
50
+ // 2. Workspaces Herdr has saved.
51
+ try {
52
+ const session = JSON.parse(await readFile(path.join(herdrRoot(), "session.json"), "utf8"));
53
+ for (const match of JSON.stringify(session).matchAll(/"cwd":\s*"((?:\\.|[^"\\])*)"/g)) {
54
+ const directory = JSON.parse(`"${match[1]}"`);
55
+ if (path.isAbsolute(directory) && namesProject(directory)) {
56
+ await offer(trimmed(directory), "herdr");
57
+ }
58
+ }
59
+ }
60
+ catch { /* no saved session */ }
61
+ // 3. phren's own registration, when it points at this machine.
62
+ try {
63
+ const config = await readFile(path.join(phrenStoreRoot(env), project, "phren.project.yaml"), "utf8");
64
+ const match = /^sourcePath:\s*(.+)$/m.exec(config);
65
+ if (match)
66
+ await offer(match[1].trim().replace(/^['"]|['"]$/g, ""), "phren");
67
+ }
68
+ catch { /* unregistered */ }
69
+ // 4. The roots phren's locator searches.
70
+ const home = homedir();
71
+ for (const root of [...(env.PROJECTS_DIR ? [env.PROJECTS_DIR] : []), ...SEARCH_ROOTS.map(r => path.join(home, r))]) {
72
+ await offer(path.join(root, project), "search");
73
+ }
74
+ return found.slice(0, 8);
75
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * In-memory Hook counters: Herdr RPCs by method, process identity probes,
3
+ * git child processes and timer ticks by name. Counting is an integer add on
4
+ * a Map entry, so the hot paths stay as they were. Nothing here is persisted
5
+ * and names come from the Hook's own code, never from a request.
6
+ */
7
+ export type MetricKind = "herdr" | "identity" | "git" | "timer";
8
+ export declare class HookMetrics {
9
+ private readonly now;
10
+ private readonly counters;
11
+ readonly startedAt: number;
12
+ constructor(now?: () => number);
13
+ count(kind: MetricKind, name: string): void;
14
+ /**
15
+ * Totals since start, the last complete minute, the minute in progress and
16
+ * the average per minute since start, for each counted name.
17
+ */
18
+ snapshot(): Json;
19
+ private minute;
20
+ private roll;
21
+ }
22
+ type Json = Record<string, unknown>;
23
+ /** The Hook process's counters. */
24
+ export declare const hookMetrics: HookMetrics;
25
+ export declare const countHerdr: (method: string) => void;
26
+ export declare const countIdentity: (probe: string) => void;
27
+ export declare const countGit: (caller: string) => void;
28
+ export declare const countTick: (timer: string) => void;
29
+ export {};
@@ -0,0 +1,71 @@
1
+ /**
2
+ * In-memory Hook counters: Herdr RPCs by method, process identity probes,
3
+ * git child processes and timer ticks by name. Counting is an integer add on
4
+ * a Map entry, so the hot paths stay as they were. Nothing here is persisted
5
+ * and names come from the Hook's own code, never from a request.
6
+ */
7
+ /** Distinct names kept per kind; anything past this counts under "other". */
8
+ const MAX_NAMES = 64;
9
+ const NAME = /^[a-z0-9][a-z0-9_.:-]{0,47}$/i;
10
+ export class HookMetrics {
11
+ now;
12
+ counters = new Map();
13
+ startedAt;
14
+ constructor(now = Date.now) {
15
+ this.now = now;
16
+ this.startedAt = now();
17
+ }
18
+ count(kind, name) {
19
+ let names = this.counters.get(kind);
20
+ if (!names) {
21
+ names = new Map();
22
+ this.counters.set(kind, names);
23
+ }
24
+ const key = NAME.test(name) ? name : "other";
25
+ let counter = names.get(key);
26
+ if (!counter) {
27
+ // "other" may take the slot past the limit, so it is always countable.
28
+ if (names.size >= MAX_NAMES && key !== "other")
29
+ return this.count(kind, "other");
30
+ counter = { total: 0, minute: this.minute(), current: 0, previous: 0 };
31
+ names.set(key, counter);
32
+ }
33
+ this.roll(counter);
34
+ counter.total++;
35
+ counter.current++;
36
+ }
37
+ /**
38
+ * Totals since start, the last complete minute, the minute in progress and
39
+ * the average per minute since start, for each counted name.
40
+ */
41
+ snapshot() {
42
+ const elapsedMinutes = Math.max((this.now() - this.startedAt) / 60_000, 1 / 60);
43
+ const kinds = {};
44
+ for (const kind of ["herdr", "identity", "git", "timer"]) {
45
+ const entries = {};
46
+ for (const [name, counter] of [...(this.counters.get(kind) ?? new Map())].sort(([a], [b]) => a.localeCompare(b))) {
47
+ this.roll(counter);
48
+ entries[name] = { total: counter.total, lastMinute: counter.previous, currentMinute: counter.current,
49
+ perMinute: Math.round(counter.total / elapsedMinutes * 100) / 100 };
50
+ }
51
+ kinds[kind] = entries;
52
+ }
53
+ return { pid: process.pid, startedAt: new Date(this.startedAt).toISOString(), uptimeSeconds: Math.round((this.now() - this.startedAt) / 1000),
54
+ herdr: kinds.herdr, identity: kinds.identity, git: kinds.git, timers: kinds.timer };
55
+ }
56
+ minute() { return Math.floor(this.now() / 60_000); }
57
+ roll(counter) {
58
+ const minute = this.minute();
59
+ if (minute === counter.minute)
60
+ return;
61
+ counter.previous = minute === counter.minute + 1 ? counter.current : 0;
62
+ counter.current = 0;
63
+ counter.minute = minute;
64
+ }
65
+ }
66
+ /** The Hook process's counters. */
67
+ export const hookMetrics = new HookMetrics();
68
+ export const countHerdr = (method) => hookMetrics.count("herdr", method);
69
+ export const countIdentity = (probe) => hookMetrics.count("identity", probe);
70
+ export const countGit = (caller) => hookMetrics.count("git", caller);
71
+ export const countTick = (timer) => hookMetrics.count("timer", timer);
@@ -0,0 +1,35 @@
1
+ import { AgentHooks } from "./agent-hooks.js";
2
+ import { ModelCatalog, type AgentModel } from "./models.js";
3
+ import { type Json, type Target } from "./protocol.js";
4
+ export declare const MODEL_BUSY = "This agent is working. The model switch can happen when the turn ends. Choose Switch after this turn.";
5
+ /** Busy slash commands must never enter the harness's text queue. Claude's
6
+ * `/btw` side question is the one made to run beside a working turn. */
7
+ export declare function refuseWorkingSlash(pane: Json, text: string, source?: string): void;
8
+ /** The levels Claude Code's `/effort` takes (2.1.280) when the catalogue
9
+ * lists none for a model; Claude still refuses one the model lacks. */
10
+ export declare const CLAUDE_EFFORTS: string[];
11
+ type EffortReply = {
12
+ effort: string;
13
+ } | {
14
+ error: string;
15
+ };
16
+ /** Claude Code's first reply to `/effort <level>` below its latest "Set model
17
+ * to" line, the switch this transaction just verified, so an older reply in
18
+ * the scrollback never confirms. A cap reports the level actually set; an
19
+ * override or refusal is an error. */
20
+ export declare function claudeEffortReply(text: string): EffortReply | undefined;
21
+ /** Only a footer below Codex's empty composer proves the active model. Text
22
+ * in history, a menu, or the startup banner must never confirm a switch. */
23
+ export declare function codexModelStatus(text: string, model: AgentModel): boolean;
24
+ /** One model transaction owns terminal input until it finishes or escapes. */
25
+ export declare class ModelSwitcher {
26
+ private readonly hooks;
27
+ private readonly catalog;
28
+ private readonly timeout;
29
+ private active;
30
+ constructor(hooks: AgentHooks, catalog?: ModelCatalog, timeout?: number);
31
+ private key;
32
+ assertAvailable(target: Target): void;
33
+ switch(target: Target, data: Json): Promise<Json>;
34
+ }
35
+ export {};
@@ -0,0 +1,250 @@
1
+ import { z } from "zod";
2
+ import { visibleTerminalChoice } from "./agent-hooks.js";
3
+ import { rpc, validateTarget } from "./herdr.js";
4
+ import { ModelCatalog } from "./models.js";
5
+ import { BridgeError } from "./protocol.js";
6
+ import { sideQuestionText } from "./side-questions.js";
7
+ import { stripTerminal } from "../terminal-text.js";
8
+ export const MODEL_BUSY = "This agent is working. The model switch can happen when the turn ends. Choose Switch after this turn.";
9
+ /** Busy slash commands must never enter the harness's text queue. Claude's
10
+ * `/btw` side question is the one made to run beside a working turn. */
11
+ export function refuseWorkingSlash(pane, text, source) {
12
+ if (source && sideQuestionText(source, text) !== undefined)
13
+ return;
14
+ if (pane.agent_status === "working" && /^\s*\//.test(text))
15
+ throw new BridgeError(409, MODEL_BUSY);
16
+ }
17
+ const request = z.object({ model: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._\[\]:/-]{0,99}$/),
18
+ effort: z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]).optional() });
19
+ const cleanLabel = (label) => label.replace(/\s*\((?:current|default|recommended)\)/gi, "").trim().toLowerCase();
20
+ const effortLabel = (label) => cleanLabel(label).replace(/^extra\s+high$/, "xhigh");
21
+ /** The levels Claude Code's `/effort` takes (2.1.280) when the catalogue
22
+ * lists none for a model; Claude still refuses one the model lacks. */
23
+ export const CLAUDE_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
24
+ /** Claude Code's first reply to `/effort <level>` below its latest "Set model
25
+ * to" line, the switch this transaction just verified, so an older reply in
26
+ * the scrollback never confirms. A cap reports the level actually set; an
27
+ * override or refusal is an error. */
28
+ export function claudeEffortReply(text) {
29
+ const lines = text.split(/\r?\n/).map(line => stripTerminal(line).trim().replace(/^[⏺●⎿]\s*/, ""));
30
+ let start = -1;
31
+ lines.forEach((line, index) => { if (line.startsWith("Set model to "))
32
+ start = index; });
33
+ if (start < 0)
34
+ return undefined;
35
+ const replies = [];
36
+ for (const output of lines.slice(start + 1)) {
37
+ let match;
38
+ if ((match = output.match(/^Set effort level to ([a-z]+)\b/)))
39
+ replies.push({ effort: match[1] });
40
+ else if ((match = output.match(/^Effort '[^']*' exceeds the cap\b.*; set to '([a-z]+)' instead/)))
41
+ replies.push({ effort: match[1] });
42
+ else if (/^(?:Not applied: )?CLAUDE_CODE_EFFORT_LEVEL=\S* overrides/.test(output)) {
43
+ replies.push({ error: "CLAUDE_CODE_EFFORT_LEVEL on the computer overrides Claude's effort in this session." });
44
+ }
45
+ else if ((match = output.match(/^(?:Failed to set effort level: |Invalid argument: )(.*)/))) {
46
+ replies.push({ error: `Claude did not set the effort: ${match[1].slice(0, 200)}` });
47
+ }
48
+ }
49
+ return replies[0];
50
+ }
51
+ /** Empty prompts can draw a dim placeholder. Only ANSI evidence that every
52
+ * character after the prompt is dim distinguishes that from a person's draft. */
53
+ function emptyComposer(line) {
54
+ if (!/^\s*[›❯>]\s*/.test(stripTerminal(line)))
55
+ return false;
56
+ let dim = false, prompt = false;
57
+ for (const token of line.match(/\x1b\[[0-9;]*m|[^\x1b]/g) ?? []) {
58
+ if (token.startsWith("\x1b")) {
59
+ const codes = token.slice(2, -1).split(";").map(Number);
60
+ for (let index = 0; index < codes.length; index++) {
61
+ const code = codes[index];
62
+ if ([38, 48, 58].includes(code)) {
63
+ index += codes[index + 1] === 2 ? 4 : codes[index + 1] === 5 ? 2 : 0;
64
+ continue;
65
+ }
66
+ if (code === 0 || code === 22)
67
+ dim = false;
68
+ else if (code === 2)
69
+ dim = true;
70
+ }
71
+ }
72
+ else if (!prompt && /[›❯>]/.test(token))
73
+ prompt = true;
74
+ else if (prompt && token.trim() && !dim)
75
+ return false;
76
+ }
77
+ return prompt;
78
+ }
79
+ /** Only a footer below Codex's empty composer proves the active model. Text
80
+ * in history, a menu, or the startup banner must never confirm a switch. */
81
+ export function codexModelStatus(text, model) {
82
+ const lines = text.split(/\r?\n/).reverse();
83
+ const composer = lines.findIndex(line => /^\s*[›❯>]/.test(stripTerminal(line)));
84
+ if (composer < 0 || !emptyComposer(lines[composer]) || visibleTerminalChoice(stripTerminal(text)))
85
+ return false;
86
+ return lines.slice(0, composer).filter(line => line.trim()).slice(0, 4).some(line => {
87
+ const footer = stripTerminal(line).trim().toLowerCase();
88
+ return [model.id, model.name].some(name => {
89
+ const lower = name.toLowerCase();
90
+ return footer === lower || footer.startsWith(lower + " ") || footer.startsWith(lower + " ·");
91
+ });
92
+ });
93
+ }
94
+ /** One model transaction owns terminal input until it finishes or escapes. */
95
+ export class ModelSwitcher {
96
+ hooks;
97
+ catalog;
98
+ timeout;
99
+ active = new Set();
100
+ constructor(hooks, catalog = new ModelCatalog(), timeout = 4_000) {
101
+ this.hooks = hooks;
102
+ this.catalog = catalog;
103
+ this.timeout = timeout;
104
+ }
105
+ key(target) { return `${target.server}:${target.pane}`; }
106
+ assertAvailable(target) {
107
+ if (this.active.has(this.key(target)))
108
+ throw new BridgeError(409, "A model switch is already in progress. Wait for it to finish.");
109
+ }
110
+ async switch(target, data) {
111
+ this.assertAvailable(target);
112
+ const { model: id, effort: chosenEffort } = request.parse(data);
113
+ this.active.add(this.key(target));
114
+ let opened = false;
115
+ let terminal;
116
+ const validate = async (idle = false) => {
117
+ const pane = await validateTarget(target, false, true);
118
+ if (terminal !== undefined && pane.terminal_id !== terminal)
119
+ throw new BridgeError(409, "The terminal changed during the model switch.");
120
+ if (opened && pane.agent_status === "working")
121
+ throw new BridgeError(409, "The agent started working during the model switch. The result is unconfirmed; check the terminal.");
122
+ refuseWorkingSlash(pane, "/model");
123
+ if (idle && !["idle", "done"].includes(String(pane.agent_status)))
124
+ throw new BridgeError(409, "Open terminal and finish the pending input before switching models.");
125
+ return pane;
126
+ };
127
+ const keys = async (values) => {
128
+ await validate();
129
+ await rpc(target.server, "agent.send_keys", { target: target.pane, keys: values });
130
+ };
131
+ const waitFor = async (read, step, ansi = false) => {
132
+ const deadline = Date.now() + this.timeout;
133
+ do {
134
+ await validate();
135
+ const value = read(await this.hooks.paneLines(target, !ansi));
136
+ if (value !== undefined)
137
+ return value;
138
+ await new Promise(resolve => setTimeout(resolve, 150));
139
+ } while (Date.now() < deadline);
140
+ throw new BridgeError(409, `Could not verify ${step}. Open terminal to check the model.`);
141
+ };
142
+ try {
143
+ terminal = (await validate(true)).terminal_id;
144
+ if (target.source === "opencode")
145
+ throw new BridgeError(422, "OpenCode uses an interactive /models picker. Open terminal to switch models; remote selection cannot yet be verified.");
146
+ if (!["codex", "claude"].includes(target.source))
147
+ throw new BridgeError(422, "Model switching is not supported for this harness. Open terminal to choose a model.");
148
+ const models = await this.catalog.list(target.source);
149
+ const model = models.find(model => model.id === id) ?? (target.source === "claude"
150
+ ? models.find(model => id === "default" ? model.isDefault : ["opus", "sonnet", "haiku", "fable"].includes(id) && model.id.startsWith(`claude-${id}-`) && !model.id.endsWith("[1m]")) : undefined);
151
+ if (!model)
152
+ throw new BridgeError(422, "That model is not in the computer's catalogue. Refresh the model list.");
153
+ const effort = chosenEffort ?? model.defaultReasoningEffort;
154
+ if (target.source === "codex" && (!effort || !model.supportedReasoningEfforts?.includes(effort))) {
155
+ throw new BridgeError(422, "The catalogue does not confirm that reasoning effort. Refresh the model list.");
156
+ }
157
+ if (target.source === "claude" && chosenEffort
158
+ && !(model.supportedReasoningEfforts?.length ? model.supportedReasoningEfforts : CLAUDE_EFFORTS).includes(chosenEffort)) {
159
+ throw new BridgeError(422, "Claude does not list that effort for this model. Refresh the model list.");
160
+ }
161
+ let claudeEffort;
162
+ const before = await this.hooks.paneLines(target, false);
163
+ // Preserve a person's draft and any pre-existing menu. Never clear it.
164
+ const composer = before.split(/\r?\n/).reverse().find(line => /^\s*[›❯>]/.test(stripTerminal(line)));
165
+ if (!composer || !emptyComposer(composer) || visibleTerminalChoice(stripTerminal(before))) {
166
+ throw new BridgeError(409, "The terminal has a draft or an unreadable prompt. Open terminal before switching models.");
167
+ }
168
+ await validate(true);
169
+ opened = true;
170
+ this.hooks.menuOpened(target, "/model");
171
+ await rpc(target.server, "agent.prompt", { target: target.pane, text: target.source === "codex" ? "/model" : `/model ${id}` });
172
+ if (target.source === "codex") {
173
+ let menu = await waitFor(text => {
174
+ const choice = visibleTerminalChoice(text);
175
+ return choice && /\b(?:select|choose) model\b/i.test(choice.title ?? "") ? choice : undefined;
176
+ }, "the Codex model menu");
177
+ const allModels = menu.options.filter(option => cleanLabel(option.label) === "all models");
178
+ if (!menu.options.some(option => cleanLabel(option.label) === model.name.toLowerCase()) && allModels.length === 1) {
179
+ // Codex 0.155 can put quick auto modes before its full catalogue.
180
+ await this.hooks.moveDialogHighlight(target, menu, allModels[0].key, async () => { await validate(); });
181
+ await keys(["enter"]);
182
+ const previous = JSON.stringify(menu.options);
183
+ menu = await waitFor(text => {
184
+ const choice = visibleTerminalChoice(text);
185
+ return choice && /\b(?:select|choose) model\b/i.test(choice.title ?? "")
186
+ && JSON.stringify(choice.options) !== previous ? choice : undefined;
187
+ }, "Codex's full model menu");
188
+ }
189
+ const rows = menu.options.filter(option => cleanLabel(option.label) === model.name.toLowerCase());
190
+ if (rows.length !== 1)
191
+ throw new BridgeError(409, "The chosen model row is missing or ambiguous in Codex's menu. Refresh the model list.");
192
+ await this.hooks.moveDialogHighlight(target, menu, rows[0].key, async () => { await validate(); });
193
+ await keys(["enter"]);
194
+ const reasoning = await waitFor(text => {
195
+ const choice = visibleTerminalChoice(text);
196
+ return choice && /\breasoning (?:level|effort)\b/i.test(choice.title ?? "") ? choice : undefined;
197
+ }, "the Codex reasoning effort menu");
198
+ const options = reasoning.options.filter(option => effortLabel(option.label) === effort);
199
+ if (options.length !== 1)
200
+ throw new BridgeError(409, "The reasoning effort row is missing or ambiguous. Open terminal to check the model.");
201
+ await this.hooks.moveDialogHighlight(target, reasoning, options[0].key, async () => { await validate(); });
202
+ await keys(["enter"]);
203
+ await waitFor(text => codexModelStatus(text, model) ? true : undefined, "the new model in Codex's status line", true);
204
+ }
205
+ else {
206
+ await waitFor(text => text !== stripTerminal(before) && text.split(/\r?\n/).some(line => {
207
+ const output = line.trim().replace(/^[⏺●⎿]\s*/, "");
208
+ return output.toLowerCase().startsWith("set model to ") && [model.name, model.id, id].some(name => {
209
+ const result = output.slice("Set model to ".length).toLowerCase();
210
+ return result === name.toLowerCase() || result.startsWith(name.toLowerCase() + " ") || result.startsWith(name.toLowerCase() + " (");
211
+ });
212
+ }) ? true : undefined, "Claude's model confirmation");
213
+ if (chosenEffort) {
214
+ // `/effort` after the model, so the new model's own default never
215
+ // replaces the chosen level.
216
+ await validate(true);
217
+ await rpc(target.server, "agent.prompt", { target: target.pane, text: `/effort ${chosenEffort}` });
218
+ const reply = await waitFor(text => claudeEffortReply(text), "Claude's effort confirmation");
219
+ if ("error" in reply)
220
+ throw new BridgeError(409, reply.error);
221
+ claudeEffort = reply.effort;
222
+ }
223
+ }
224
+ return { ok: true, model: model.id, name: model.name,
225
+ ...(target.source === "codex" ? { effort } : claudeEffort ? { effort: claudeEffort } : {}) };
226
+ }
227
+ catch (error) {
228
+ if (opened) {
229
+ // Escape only the same, non-working pane. Never interrupt a new turn
230
+ // or send cleanup input to a replacement session.
231
+ try {
232
+ for (let attempt = 0; attempt < 3; attempt++) {
233
+ await keys(["escape"]);
234
+ await new Promise(resolve => setTimeout(resolve, 150));
235
+ const menu = visibleTerminalChoice(await this.hooks.paneLines(target));
236
+ if (!menu || !/\b(?:(?:select|choose) model|reasoning (?:level|effort))\b/i.test(menu.title ?? ""))
237
+ break;
238
+ }
239
+ }
240
+ catch { /* Identity or activity changed. Do not type further. */ }
241
+ }
242
+ throw error;
243
+ }
244
+ finally {
245
+ this.hooks.menuClosed(target);
246
+ this.hooks.clearTerminalPrompt(target);
247
+ this.active.delete(this.key(target));
248
+ }
249
+ }
250
+ }
@@ -0,0 +1,46 @@
1
+ import { type Json } from "./protocol.js";
2
+ /** One entry of a `/model` menu as the phone draws it. */
3
+ export interface AgentModel {
4
+ id: string;
5
+ name: string;
6
+ description?: string;
7
+ isDefault?: boolean;
8
+ isCurrent?: boolean;
9
+ defaultReasoningEffort?: string;
10
+ supportedReasoningEfforts?: string[];
11
+ }
12
+ /** Only initialize and list. Never a thread, a prompt, or a login. */
13
+ export declare function readCodexModels(executable?: string): Promise<AgentModel[]>;
14
+ export declare function codexModels(result: Json): AgentModel[];
15
+ /** The menu used only when Claude Code's own catalogue cannot be read (it has
16
+ * never run on this computer, or the cache is unreadable). Normally the phone
17
+ * shows the live catalogue below, so a new model appears without anyone
18
+ * editing this table. Exported so a parity test can hold the phone's built-in
19
+ * offline fallback and the chat fixture to it. */
20
+ export declare const CLAUDE_MENU: readonly AgentModel[];
21
+ /** Claude Code fetches its `/model` catalogue from Anthropic and caches it as
22
+ * `<config>/cache/model-catalog/<account>-...-cc.json`, refreshing it itself:
23
+ * `catalog.config.models` is the menu in the terminal's order (`section`
24
+ * "main" first, older models under "overflow"), each row gated by
25
+ * `min_claude_code_version`, and `catalog.state.model` is the selected
26
+ * default. Reading that file keeps the phone's picker identical to the
27
+ * terminal's with nothing to maintain here. */
28
+ export declare function readClaudeCatalog(configDir?: string, installed?: string): Promise<AgentModel[]>;
29
+ /** The live catalogue when Claude Code has one cached on this computer,
30
+ * otherwise the offline fallback, copied per call so a caller cannot mutate it. */
31
+ export declare function readClaudeModels(configDir?: string, installed?: string | null): Promise<AgentModel[]>;
32
+ /** `opencode models` prints one `provider/model` id per line. The Go plan's
33
+ * models sit under `opencode-go/`, Zen's under `opencode/`, and everything
34
+ * else under the gateway it came from; the configured default is marked. */
35
+ export declare function readOpenCodeModels(executable?: string, configDir?: string): Promise<AgentModel[]>;
36
+ /** "claude-fable-5-1" reads as "Fable 5.1"; a date suffix is dropped. */
37
+ export declare function claudeName(id: string): string;
38
+ /** Catalogues change rarely and app-server takes seconds to start. */
39
+ export declare class ModelCatalog {
40
+ private readonly codex;
41
+ private readonly claude;
42
+ private readonly opencode;
43
+ private cache;
44
+ constructor(codex?: () => Promise<AgentModel[]>, claude?: () => Promise<AgentModel[]>, opencode?: () => Promise<AgentModel[]>);
45
+ list(source: string): Promise<AgentModel[]>;
46
+ }