@vellumai/assistant 0.11.1 → 0.11.2-dev.202608042227.b54139c

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 (514) hide show
  1. package/Dockerfile +1 -3
  2. package/README.md +1 -1
  3. package/eslint.config.mjs +28 -8
  4. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +1 -0
  5. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/stripe-currency.test.ts +37 -0
  6. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/stripe-currency.ts +55 -0
  7. package/node_modules/@vellumai/environments/src/__tests__/install-layout.test.ts +98 -0
  8. package/node_modules/@vellumai/environments/src/__tests__/package-boundary.test.ts +5 -5
  9. package/node_modules/@vellumai/environments/src/index.ts +17 -6
  10. package/node_modules/@vellumai/environments/src/install-layout.ts +49 -0
  11. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +1 -0
  12. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/stripe-currency.test.ts +37 -0
  13. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/stripe-currency.ts +55 -0
  14. package/node_modules/@vellumai/service-contracts/package.json +1 -0
  15. package/node_modules/@vellumai/service-contracts/src/__tests__/stripe-currency.test.ts +37 -0
  16. package/node_modules/@vellumai/service-contracts/src/stripe-currency.ts +55 -0
  17. package/node_modules/@vellumai/slack-text/src/index.test.ts +48 -0
  18. package/node_modules/@vellumai/slack-text/src/index.ts +41 -8
  19. package/openapi.yaml +442 -8
  20. package/package.json +1 -1
  21. package/src/__tests__/agent-image-optimize.test.ts +4 -4
  22. package/src/__tests__/agent-loop-resume-interrupted.test.ts +223 -0
  23. package/src/__tests__/agent-loop-subagent-billing-headers.test.ts +166 -0
  24. package/src/__tests__/answered-question-persistence.test.ts +240 -0
  25. package/src/__tests__/assistant-feature-flags-integration.test.ts +10 -0
  26. package/src/__tests__/attachments-store-heic-normalize.test.ts +16 -12
  27. package/src/__tests__/attachments-store.test.ts +130 -68
  28. package/src/__tests__/attachments.test.ts +36 -36
  29. package/src/__tests__/byok-default-profile-ensure.test.ts +43 -0
  30. package/src/__tests__/cli-logger-boundary-guard.test.ts +87 -0
  31. package/src/__tests__/compaction-events.test.ts +139 -2
  32. package/src/__tests__/compactor-image-manifest-trust.test.ts +1 -1
  33. package/src/__tests__/compactor-truncation-pairing.test.ts +368 -0
  34. package/src/__tests__/config-loader-backfill.test.ts +35 -3
  35. package/src/__tests__/config-schema.test.ts +1 -0
  36. package/src/__tests__/consult-deadline.test.ts +65 -0
  37. package/src/__tests__/conversation-agent-loop-fatal-cleanup.test.ts +30 -0
  38. package/src/__tests__/conversation-agent-loop.test.ts +255 -8
  39. package/src/__tests__/conversation-disk-view-integration.test.ts +5 -1
  40. package/src/__tests__/conversation-disk-view.test.ts +4 -4
  41. package/src/__tests__/conversation-error.test.ts +211 -4
  42. package/src/__tests__/conversation-fork-crud.test.ts +5 -1
  43. package/src/__tests__/conversation-fork-retrospective.test.ts +5 -1
  44. package/src/__tests__/conversation-options-turn-scoped-transport.test.ts +64 -0
  45. package/src/__tests__/conversation-queue.test.ts +255 -1
  46. package/src/__tests__/conversation-retry-route.test.ts +46 -7
  47. package/src/__tests__/conversation-slash.test.ts +4 -2
  48. package/src/__tests__/conversation-store.test.ts +26 -10
  49. package/src/__tests__/conversation-summarize-route.test.ts +7 -1
  50. package/src/__tests__/conversation-summarize-up-to.test.ts +71 -5
  51. package/src/__tests__/conversation-surfaces-action-delivery.test.ts +10 -0
  52. package/src/__tests__/conversation-surfaces-history-restored-completion.test.ts +969 -0
  53. package/src/__tests__/conversation-surfaces-persisted-info.test.ts +312 -0
  54. package/src/__tests__/cu-unified-flow.test.ts +75 -11
  55. package/src/__tests__/disk-pressure-guard.test.ts +55 -55
  56. package/src/__tests__/disk-pressure-routes.test.ts +10 -10
  57. package/src/__tests__/disk-pressure-tools.test.ts +2 -2
  58. package/src/__tests__/disk-usage.test.ts +35 -20
  59. package/src/__tests__/document-create-dedupe.test.ts +2 -1
  60. package/src/__tests__/document-find-replace.test.ts +2 -1
  61. package/src/__tests__/document-tool-security.test.ts +2 -1
  62. package/src/__tests__/document-update-default-surface.test.ts +2 -1
  63. package/src/__tests__/document-workspace-file.test.ts +467 -0
  64. package/src/__tests__/dynamic-skill-background-guard.test.ts +2 -2
  65. package/src/__tests__/emit-signal-routing-intent.test.ts +290 -49
  66. package/src/__tests__/file-list-tool.test.ts +12 -10
  67. package/src/__tests__/file-ops-service.test.ts +76 -40
  68. package/src/__tests__/file-url-path-guard.test.ts +83 -0
  69. package/src/__tests__/filesystem-tools.test.ts +82 -66
  70. package/src/__tests__/guardian-card-withdrawal.test.ts +91 -3
  71. package/src/__tests__/history-repair.test.ts +39 -0
  72. package/src/__tests__/http-user-message-parity.test.ts +66 -0
  73. package/src/__tests__/identity-routes.test.ts +13 -13
  74. package/src/__tests__/image-conversion.test.ts +29 -26
  75. package/src/__tests__/image-source-path-reinject.test.ts +2 -2
  76. package/src/__tests__/list-messages-attachments.test.ts +139 -28
  77. package/src/__tests__/list-messages-background-tool-completion.test.ts +4 -4
  78. package/src/__tests__/list-messages-client-message-id.test.ts +2 -2
  79. package/src/__tests__/list-messages-hidden-metadata.test.ts +16 -16
  80. package/src/__tests__/list-messages-page-latest.test.ts +61 -61
  81. package/src/__tests__/list-messages-provider-error.test.ts +143 -0
  82. package/src/__tests__/list-messages-queued.test.ts +6 -6
  83. package/src/__tests__/list-messages-system-card.test.ts +100 -0
  84. package/src/__tests__/list-messages-tool-merge.test.ts +9 -9
  85. package/src/__tests__/llm-resolver.test.ts +19 -9
  86. package/src/__tests__/llm-usage-store.test.ts +55 -0
  87. package/src/__tests__/managed-profile-guard.test.ts +23 -0
  88. package/src/__tests__/migration-export-http.test.ts +1 -1
  89. package/src/__tests__/migration-import-commit-http.test.ts +1 -1
  90. package/src/__tests__/migration-import-preflight-http.test.ts +1 -1
  91. package/src/__tests__/migration-validate-http.test.ts +1 -1
  92. package/src/__tests__/notification-platform-adapter.test.ts +130 -2
  93. package/src/__tests__/notification-telegram-adapter.test.ts +6 -0
  94. package/src/__tests__/notification-vellum-adapter.test.ts +45 -0
  95. package/src/__tests__/persist-media-references.test.ts +2 -2
  96. package/src/__tests__/persist-unsendable-image-downscale.test.ts +5 -5
  97. package/src/__tests__/persist-unsendable-image.test.ts +23 -23
  98. package/src/__tests__/plugin-api-model-profiles.test.ts +10 -1
  99. package/src/__tests__/plugin-import-boundary-guard.test.ts +3 -0
  100. package/src/__tests__/profiler-routes.test.ts +13 -13
  101. package/src/__tests__/provider-error-scenarios.test.ts +140 -0
  102. package/src/__tests__/provider-send-message-override-profile.test.ts +95 -0
  103. package/src/__tests__/run-conversation-turn-persistence.test.ts +66 -3
  104. package/src/__tests__/runtime-attachment-metadata.test.ts +15 -7
  105. package/src/__tests__/scripted-turn-metadata-persistence.test.ts +209 -0
  106. package/src/__tests__/server-history-render.test.ts +97 -7
  107. package/src/__tests__/size-guard.test.ts +8 -8
  108. package/src/__tests__/skill-docs-sync-guard.test.ts +3 -2
  109. package/src/__tests__/skill-tool-factory.test.ts +247 -0
  110. package/src/__tests__/skills-install-staging.test.ts +15 -6
  111. package/src/__tests__/skills.test.ts +27 -0
  112. package/src/__tests__/slack-channels-routes.test.ts +0 -2
  113. package/src/__tests__/slack-edit-ordering-characterization.test.ts +103 -0
  114. package/src/__tests__/slack-mention-binding-invariance.test.ts +103 -0
  115. package/src/__tests__/slack-mention-provider-leak-audit.test.ts +135 -0
  116. package/src/__tests__/slack-share-routes.test.ts +0 -3
  117. package/src/__tests__/slack-users-routes.test.ts +0 -2
  118. package/src/__tests__/subagent-allowlist-validation.test.ts +26 -4
  119. package/src/__tests__/subagent-disposal.test.ts +10 -0
  120. package/src/__tests__/subagent-fork-notifications.test.ts +10 -0
  121. package/src/__tests__/subagent-fork-prompt-role.test.ts +85 -11
  122. package/src/__tests__/subagent-fork-spawn.test.ts +15 -7
  123. package/src/__tests__/subagent-manager-notify.test.ts +148 -0
  124. package/src/__tests__/subagent-notify-parent.test.ts +1 -1
  125. package/src/__tests__/subagent-persistence.test.ts +141 -0
  126. package/src/__tests__/subagent-role-registry.test.ts +172 -63
  127. package/src/__tests__/subagent-role-resolution.test.ts +88 -0
  128. package/src/__tests__/subagent-spawn-and-await.test.ts +48 -0
  129. package/src/__tests__/subagent-spawn-tool-fork.test.ts +111 -10
  130. package/src/__tests__/subagent-terminal-message.test.ts +88 -1
  131. package/src/__tests__/subagent-tool-gate-mode.test.ts +215 -0
  132. package/src/__tests__/subagent-tools.test.ts +1945 -97
  133. package/src/__tests__/surface-completion-compaction-boundary.test.ts +124 -0
  134. package/src/__tests__/surface-completion-in-flight-snapshot.test.ts +298 -0
  135. package/src/__tests__/tool-preview-lifecycle.test.ts +58 -0
  136. package/src/__tests__/tool-result-spool.test.ts +5 -4
  137. package/src/__tests__/tools-audio-read.test.ts +10 -10
  138. package/src/__tests__/tools-get-route.test.ts +85 -12
  139. package/src/__tests__/tools-list-cli.test.ts +171 -0
  140. package/src/__tests__/turn-boundary-resolution.test.ts +53 -0
  141. package/src/__tests__/turn-events-store.test.ts +26 -0
  142. package/src/__tests__/ui-visual-surface.test.ts +695 -0
  143. package/src/__tests__/unified-turn-context-visible-app.test.ts +99 -0
  144. package/src/__tests__/visible-app-context.test.ts +189 -0
  145. package/src/__tests__/workspace-git-service.test.ts +173 -33
  146. package/src/__tests__/workspace-migration-137-repair-retired-fireworks-minimax-model-id.test.ts +157 -0
  147. package/src/__tests__/workspace-migration-138-backfill-home-feed-titles.test.ts +373 -0
  148. package/src/__tests__/workspace-migration-139-clear-renamed-cost-profile-label.test.ts +137 -0
  149. package/src/agent/attachments.ts +26 -24
  150. package/src/agent/history-repair/history-repair.ts +8 -0
  151. package/src/agent/image-optimize.ts +6 -6
  152. package/src/agent/loop.ts +57 -16
  153. package/src/agent/message-types.ts +3 -3
  154. package/src/api/events/context-window-usage.ts +31 -0
  155. package/src/api/events/notification-intent.ts +8 -0
  156. package/src/api/events/question-answered.ts +53 -0
  157. package/src/api/events/tool-result.ts +7 -0
  158. package/src/api/events/ui-surface-pending.ts +35 -0
  159. package/src/api/index.ts +20 -0
  160. package/src/api/responses/conversation-message.ts +36 -4
  161. package/src/api/surfaces.ts +90 -1
  162. package/src/approvals/guardian-card-withdrawal.ts +66 -31
  163. package/src/approvals/guardian-decision-primitive.ts +4 -0
  164. package/src/calls/__tests__/call-setup-router.test.ts +156 -26
  165. package/src/calls/__tests__/voice-session-bridge.test.ts +201 -12
  166. package/src/calls/call-setup-router.ts +80 -36
  167. package/src/calls/voice-session-bridge.ts +173 -26
  168. package/src/cli/commands/__tests__/cache.test.ts +7 -4
  169. package/src/cli/commands/inference.help.ts +3 -3
  170. package/src/cli/commands/mcp.help.ts +4 -2
  171. package/src/cli/commands/notifications.help.ts +3 -2
  172. package/src/cli/commands/platform/__tests__/callback-routes-list.test.ts +42 -128
  173. package/src/cli/commands/platform/__tests__/credits.test.ts +9 -78
  174. package/src/cli/commands/platform/__tests__/helpers.ts +90 -0
  175. package/src/cli/commands/platform/__tests__/invoices.test.ts +238 -0
  176. package/src/cli/commands/platform/__tests__/plans.test.ts +9 -88
  177. package/src/cli/commands/platform/__tests__/status.test.ts +12 -87
  178. package/src/cli/commands/platform/__tests__/subscription.test.ts +9 -86
  179. package/src/cli/commands/platform/index.help.ts +92 -0
  180. package/src/cli/commands/platform/index.ts +7 -0
  181. package/src/cli/commands/platform/invoices.ts +132 -0
  182. package/src/cli/commands/tools.help.ts +4 -2
  183. package/src/cli/commands/tools.ts +38 -0
  184. package/src/cli/commands/usage.help.ts +1 -1
  185. package/src/cli/lib/list-installed-plugins.ts +2 -1
  186. package/src/config/__tests__/default-profile-catalog.test.ts +7 -10
  187. package/src/config/__tests__/deployment-context-defaults.test.ts +27 -5
  188. package/src/config/__tests__/profile-tool-support.test.ts +131 -0
  189. package/src/config/assistant-feature-flags.ts +7 -2
  190. package/src/config/bundled-skills/AGENTS.md +1 -1
  191. package/src/config/bundled-skills/app-builder/SKILL.md +3 -2
  192. package/src/config/bundled-skills/media-processing/SKILL.md +1 -1
  193. package/src/config/bundled-skills/media-processing/TOOLS.json +1 -1
  194. package/src/config/bundled-skills/media-processing/__tests__/media-analysis-default-model.test.ts +177 -0
  195. package/src/config/bundled-skills/media-processing/services/gemini-map.ts +4 -3
  196. package/src/config/bundled-skills/media-processing/services/gemini-video.ts +2 -1
  197. package/src/config/bundled-skills/media-processing/services/media-analysis-model.ts +12 -0
  198. package/src/config/bundled-skills/subagent/SKILL.md +55 -22
  199. package/src/config/bundled-skills/subagent/TOOLS.json +15 -14
  200. package/src/config/bundled-skills/visualize/SKILL.md +163 -0
  201. package/src/config/call-site-defaults.ts +3 -2
  202. package/src/config/default-profile-catalog.ts +75 -70
  203. package/src/config/default-profile-names.ts +13 -28
  204. package/src/config/env-registry.ts +1 -0
  205. package/src/config/feature-flag-registry.json +32 -8
  206. package/src/config/llm-resolver.ts +25 -8
  207. package/src/config/loader.ts +18 -11
  208. package/src/config/profile-tool-support.ts +110 -0
  209. package/src/config/schemas/llm.ts +1 -9
  210. package/src/config/schemas/memory-retrospective.ts +9 -0
  211. package/src/config/schemas/monitoring.ts +28 -2
  212. package/src/config/schemas/workspace-git.ts +15 -0
  213. package/src/config/seed-inference-profiles.ts +19 -5
  214. package/src/context/compactor.ts +45 -8
  215. package/src/context/post-turn-tool-result-truncation.ts +2 -2
  216. package/src/conversations/__tests__/message-consolidation.test.ts +54 -0
  217. package/src/conversations/message-consolidation.ts +17 -15
  218. package/src/daemon/__tests__/abort-null-controller.test.ts +141 -5
  219. package/src/daemon/__tests__/install-assistant-command.test.ts +234 -0
  220. package/src/daemon/__tests__/turn-tail-assistant-reply-notify.test.ts +182 -0
  221. package/src/daemon/__tests__/turn-tail-deleted-conversation.test.ts +181 -0
  222. package/src/daemon/conversation-agent-loop-handlers.ts +204 -64
  223. package/src/daemon/conversation-agent-loop.ts +115 -23
  224. package/src/daemon/conversation-attachments.ts +1 -1
  225. package/src/daemon/conversation-error.ts +169 -48
  226. package/src/daemon/conversation-lifecycle.ts +119 -17
  227. package/src/daemon/conversation-messaging.ts +118 -30
  228. package/src/daemon/conversation-process.ts +91 -64
  229. package/src/daemon/conversation-runtime-assembly.ts +57 -0
  230. package/src/daemon/conversation-store.ts +36 -1
  231. package/src/daemon/conversation-surface-state.ts +9 -0
  232. package/src/daemon/conversation-surfaces.ts +476 -108
  233. package/src/daemon/conversation-tool-setup.ts +54 -2
  234. package/src/daemon/conversation-turn-finalize.ts +76 -18
  235. package/src/daemon/conversation.ts +151 -29
  236. package/src/daemon/disk-pressure-guard-lifecycle.ts +2 -2
  237. package/src/daemon/disk-pressure-guard.ts +3 -3
  238. package/src/daemon/handlers/shared.ts +12 -0
  239. package/src/daemon/handlers/skills.ts +1 -1
  240. package/src/daemon/install-assistant-command.ts +322 -0
  241. package/src/daemon/lifecycle.ts +12 -3
  242. package/src/daemon/message-types/conversations.ts +8 -0
  243. package/src/daemon/message-types/surfaces.ts +3 -0
  244. package/src/daemon/persist-media-references.ts +23 -14
  245. package/src/daemon/process-message.ts +6 -6
  246. package/src/daemon/tool-setup-types.ts +31 -2
  247. package/src/documents/document-store.ts +247 -10
  248. package/src/home/__tests__/feed-types.test.ts +43 -8
  249. package/src/home/__tests__/feed-writer.test.ts +59 -0
  250. package/src/home/feed-types.ts +34 -7
  251. package/src/home/feed-writer.ts +15 -6
  252. package/src/live-voice/__tests__/activity-label.test.ts +95 -0
  253. package/src/live-voice/__tests__/live-activity-reporter.test.ts +86 -5
  254. package/src/live-voice/__tests__/live-voice-agent-turn.test.ts +310 -25
  255. package/src/live-voice/__tests__/live-voice-archive.test.ts +16 -16
  256. package/src/live-voice/__tests__/live-voice-events.test.ts +4 -4
  257. package/src/live-voice/__tests__/live-voice-integration.test.ts +7 -5
  258. package/src/live-voice/__tests__/live-voice-triage-escalate.test.ts +8 -4
  259. package/src/live-voice/__tests__/live-voice-vad.test.ts +44 -16
  260. package/src/live-voice/activity-label.ts +169 -0
  261. package/src/live-voice/live-activity-reporter.ts +35 -6
  262. package/src/live-voice/live-voice-archive.ts +13 -13
  263. package/src/live-voice/live-voice-session.ts +288 -41
  264. package/src/live-voice/protocol.ts +35 -0
  265. package/src/messaging/providers/slack/__tests__/adapter-mention-rendering.test.ts +84 -2
  266. package/src/messaging/providers/slack/adapter.ts +86 -19
  267. package/src/messaging/providers/slack/api.test.ts +85 -1
  268. package/src/messaging/providers/slack/api.ts +121 -288
  269. package/src/messaging/providers/slack/client.ts +20 -251
  270. package/src/messaging/providers/slack/mention-source.test.ts +285 -0
  271. package/src/messaging/providers/slack/mention-source.ts +287 -0
  272. package/src/messaging/providers/slack/send.test.ts +4 -9
  273. package/src/messaging/providers/slack/send.ts +1 -1
  274. package/src/messaging/providers/slack/types.ts +5 -0
  275. package/src/messaging/providers/slack/web-api-transport.test.ts +181 -0
  276. package/src/messaging/providers/slack/web-api-transport.ts +367 -0
  277. package/src/messaging/providers/slack/withdraw.ts +6 -14
  278. package/src/messaging/providers/telegram-bot/send.test.ts +31 -1
  279. package/src/messaging/providers/telegram-bot/send.ts +23 -2
  280. package/src/messaging/providers/telegram-bot/withdraw.test.ts +152 -0
  281. package/src/messaging/providers/telegram-bot/withdraw.ts +166 -0
  282. package/src/monitoring/__tests__/db-integrity-sample.test.ts +22 -5
  283. package/src/monitoring/__tests__/file-descriptors.test.ts +144 -0
  284. package/src/monitoring/db-integrity-sample.ts +6 -1
  285. package/src/monitoring/file-descriptors.ts +262 -0
  286. package/src/monitoring/process-memory.ts +4 -11
  287. package/src/monitoring/resource-sampler.ts +26 -5
  288. package/src/monitoring/worker.ts +12 -0
  289. package/src/notifications/__tests__/assistant-reply-producer.test.ts +740 -0
  290. package/src/notifications/__tests__/broadcaster.test.ts +347 -7
  291. package/src/notifications/__tests__/copy-composer.test.ts +53 -3
  292. package/src/notifications/__tests__/decision-engine.test.ts +349 -29
  293. package/src/notifications/__tests__/deterministic-checks.test.ts +21 -0
  294. package/src/notifications/__tests__/edit-notification.test.ts +330 -0
  295. package/src/notifications/__tests__/guardian-delivery-recorder.test.ts +71 -0
  296. package/src/notifications/__tests__/home-feed-side-effect.test.ts +170 -12
  297. package/src/notifications/adapters/macos.ts +3 -0
  298. package/src/notifications/adapters/platform.ts +90 -14
  299. package/src/notifications/adapters/telegram.ts +6 -4
  300. package/src/notifications/assistant-reply-producer.ts +219 -0
  301. package/src/notifications/broadcaster.ts +523 -317
  302. package/src/notifications/copy-composer.ts +27 -6
  303. package/src/notifications/decision-engine.ts +154 -77
  304. package/src/notifications/deterministic-checks.ts +6 -7
  305. package/src/notifications/edit-notification.ts +8 -4
  306. package/src/notifications/emit-signal.ts +49 -16
  307. package/src/notifications/guardian-delivery-recorder.ts +8 -2
  308. package/src/notifications/home-feed-side-effect.ts +43 -6
  309. package/src/notifications/notification-utils.ts +39 -4
  310. package/src/notifications/signal.ts +10 -0
  311. package/src/notifications/types.ts +17 -0
  312. package/src/permissions/question-prompter.test.ts +4 -0
  313. package/src/permissions/question-prompter.ts +21 -4
  314. package/src/persistence/attachments-store.ts +15 -15
  315. package/src/persistence/bookmark-crud.ts +18 -9
  316. package/src/persistence/conversation-attention-store.ts +26 -0
  317. package/src/persistence/conversation-bootstrap.ts +17 -0
  318. package/src/persistence/conversation-crud.ts +89 -32
  319. package/src/persistence/conversation-queries.ts +30 -15
  320. package/src/persistence/conversation-title-service.ts +5 -170
  321. package/src/persistence/conversation-types.ts +192 -1
  322. package/src/persistence/db-init.ts +14 -1
  323. package/src/persistence/db-maintenance.ts +5 -4
  324. package/src/persistence/embeddings/__tests__/plugin-index-qdrant-init.test.ts +219 -0
  325. package/src/persistence/embeddings/__tests__/plugin-index.test.ts +22 -0
  326. package/src/persistence/embeddings/__tests__/worker-script-version.test.ts +76 -0
  327. package/src/persistence/embeddings/embedding-local.ts +2 -1
  328. package/src/persistence/embeddings/embedding-runtime-manager.ts +29 -5
  329. package/src/persistence/embeddings/plugin-index.ts +84 -12
  330. package/src/persistence/llm-usage-store.ts +22 -0
  331. package/src/persistence/migrations/360-add-document-workspace-path.test.ts +110 -0
  332. package/src/persistence/migrations/360-add-document-workspace-path.ts +39 -0
  333. package/src/persistence/migrations/361-normalize-managed-connection-rows.test.ts +168 -0
  334. package/src/persistence/migrations/361-normalize-managed-connection-rows.ts +76 -0
  335. package/src/persistence/migrations/362-add-conversation-subagent-kind.test.ts +187 -0
  336. package/src/persistence/migrations/362-add-conversation-subagent-kind.ts +93 -0
  337. package/src/persistence/planner-statistics.ts +14 -0
  338. package/src/persistence/schema/conversations.ts +22 -0
  339. package/src/persistence/schema/documents.ts +26 -11
  340. package/src/persistence/steps.ts +19 -0
  341. package/src/persistence/subagent-store.ts +148 -6
  342. package/src/platform/client.test.ts +172 -2
  343. package/src/platform/client.ts +178 -55
  344. package/src/plugin-api/conversation-turn.ts +13 -0
  345. package/src/plugin-api/model-profiles.test.ts +6 -2
  346. package/src/plugins/defaults/exploration-drift/hooks/post-tool-use.ts +5 -5
  347. package/src/plugins/defaults/exploration-drift/package.json +1 -1
  348. package/src/plugins/defaults/image-recovery/hooks/post-model-call.ts +4 -2
  349. package/src/plugins/defaults/image-recovery/recover.ts +67 -57
  350. package/src/plugins/defaults/index.ts +1 -1
  351. package/src/plugins/defaults/memory/__tests__/bookmark-crud.test.ts +34 -0
  352. package/src/plugins/defaults/memory/__tests__/conversation-queries.test.ts +22 -0
  353. package/src/plugins/defaults/memory/__tests__/jobs-store-enqueue-gate.test.ts +11 -0
  354. package/src/plugins/defaults/memory/__tests__/memory-retrospective-accounting.test.ts +199 -0
  355. package/src/plugins/defaults/memory/__tests__/memory-retrospective-enqueue.test.ts +98 -1
  356. package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +105 -1
  357. package/src/plugins/defaults/memory/__tests__/memory-retrospective-sweep.test.ts +24 -2
  358. package/src/plugins/defaults/memory/__tests__/memory-retrospective-wake-chain.test.ts +524 -0
  359. package/src/plugins/defaults/memory/__tests__/memory-tier-boundary-guard.test.ts +1 -1
  360. package/src/plugins/defaults/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +9 -4
  361. package/src/plugins/defaults/memory/host-utils.ts +5 -0
  362. package/src/plugins/defaults/memory/memory-retrospective-accounting.ts +105 -1
  363. package/src/plugins/defaults/memory/memory-retrospective-enqueue.ts +64 -5
  364. package/src/plugins/defaults/memory/memory-retrospective-job.ts +36 -1
  365. package/src/plugins/defaults/memory/memory-retrospective-sweep.ts +12 -3
  366. package/src/plugins/defaults/memory/src/__tests__/memory-v2-simulate-route.test.ts +1 -0
  367. package/src/plugins/defaults/memory/substrate/__tests__/skill-store.test.ts +195 -1
  368. package/src/plugins/defaults/memory/substrate/consolidation-job.ts +1 -1
  369. package/src/plugins/defaults/memory/substrate/skill-store.ts +167 -29
  370. package/src/plugins/defaults/memory/v1/graph/injection.ts +1 -1
  371. package/src/plugins/defaults/memory/v2/__tests__/injection.test.ts +131 -0
  372. package/src/plugins/defaults/memory/v2/__tests__/router.test.ts +1 -0
  373. package/src/plugins/defaults/memory/v2/activation-log-store.ts +4 -0
  374. package/src/plugins/defaults/memory/v2/injection.ts +48 -3
  375. package/src/plugins/defaults/memory/v2/rerank-local.ts +6 -2
  376. package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +1 -1
  377. package/src/plugins/defaults/platform-hosted/routes/reengage.ts +1 -1
  378. package/src/plugins/defaults/turn-context/injectors.ts +1 -0
  379. package/src/plugins/defaults/turn-context/unified-turn-context.ts +26 -0
  380. package/src/plugins/types.ts +17 -0
  381. package/src/prompts/templates/system-sections.ts +2 -2
  382. package/src/providers/__tests__/dispatch-connection-routing.test.ts +43 -2
  383. package/src/providers/__tests__/retry-callsite.test.ts +67 -0
  384. package/src/providers/__tests__/vellum-connection-routing.test.ts +5 -10
  385. package/src/providers/__tests__/vellum-mismatch-routing.test.ts +8 -0
  386. package/src/providers/anthropic/client.ts +6 -4
  387. package/src/providers/call-site-routing.ts +77 -14
  388. package/src/providers/connection-resolution.ts +42 -2
  389. package/src/providers/gemini/client.ts +5 -5
  390. package/src/providers/inference/__tests__/adapter-factory-openai-compatible.test.ts +127 -1
  391. package/src/providers/inference/adapter-factory.ts +71 -12
  392. package/src/providers/media-resolve.ts +21 -11
  393. package/src/providers/model-catalog.ts +0 -11
  394. package/src/providers/model-intents.ts +11 -0
  395. package/src/providers/openai/__tests__/orphan-tool-result-guard.test.ts +478 -0
  396. package/src/providers/openai/chat-completions-provider.ts +50 -34
  397. package/src/providers/openai/orphaned-tool-result.ts +79 -0
  398. package/src/providers/openai/responses-provider.ts +53 -27
  399. package/src/providers/registry.ts +8 -0
  400. package/src/providers/retry.ts +110 -17
  401. package/src/providers/types.ts +8 -1
  402. package/src/providers/vellum-model-routing.ts +6 -7
  403. package/src/runtime/AGENTS.md +2 -0
  404. package/src/runtime/__tests__/agent-wake.test.ts +181 -0
  405. package/src/runtime/agent-wake.ts +132 -9
  406. package/src/runtime/channel-approval-types.ts +25 -0
  407. package/src/runtime/routes/__tests__/connection-routes-vs-cli-parity.test.ts +2 -2
  408. package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +11 -0
  409. package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +121 -9
  410. package/src/runtime/routes/__tests__/llm-call-sites-routes.test.ts +28 -1
  411. package/src/runtime/routes/__tests__/platform-invoice-routes.test.ts +392 -0
  412. package/src/runtime/routes/__tests__/question-routes.test.ts +64 -0
  413. package/src/runtime/routes/__tests__/slack-channel-routes.test.ts +7 -0
  414. package/src/runtime/routes/__tests__/workspace-commit-routes.test.ts +63 -0
  415. package/src/runtime/routes/archive-utils.ts +16 -12
  416. package/src/runtime/routes/attachment-routes.ts +13 -6
  417. package/src/runtime/routes/consolidation-routes.ts +1 -1
  418. package/src/runtime/routes/conversation-management-routes.ts +18 -6
  419. package/src/runtime/routes/conversation-query-routes.ts +14 -23
  420. package/src/runtime/routes/conversation-routes.ts +297 -181
  421. package/src/runtime/routes/credential-routes.ts +1 -5
  422. package/src/runtime/routes/documents-routes.ts +207 -12
  423. package/src/runtime/routes/identity-routes.ts +9 -99
  424. package/src/runtime/routes/inbound-message-handler.ts +5 -5
  425. package/src/runtime/routes/inbound-stages/admission-policy.test.ts +31 -1
  426. package/src/runtime/routes/inbound-stages/admission-policy.ts +18 -0
  427. package/src/runtime/routes/inference-profiles-routes.ts +1 -1
  428. package/src/runtime/routes/inference-provider-connection-routes.ts +52 -19
  429. package/src/runtime/routes/llm-call-sites-routes.ts +13 -0
  430. package/src/runtime/routes/log-export-routes.ts +1 -1
  431. package/src/runtime/routes/notification-routes.ts +4 -1
  432. package/src/runtime/routes/platform-routes.ts +238 -3
  433. package/src/runtime/routes/playground/guard.ts +1 -2
  434. package/src/runtime/routes/profiler-routes.ts +4 -2
  435. package/src/runtime/routes/question-routes.ts +28 -10
  436. package/src/runtime/routes/secret-routes.ts +8 -2
  437. package/src/runtime/routes/settings-routes.ts +41 -13
  438. package/src/runtime/routes/slack-channel-routes.ts +2 -4
  439. package/src/runtime/routes/workspace-commit-routes.ts +49 -2
  440. package/src/runtime/routes/workspace-routes.ts +11 -12
  441. package/src/runtime/routes/workspace-utils.ts +49 -2
  442. package/src/runtime/services/conversation-serializer.ts +2 -4
  443. package/src/skills/catalog-install.ts +20 -7
  444. package/src/skills/skillssh-registry.ts +1 -1
  445. package/src/subagent/__tests__/consult-context-gating.test.ts +98 -0
  446. package/src/subagent/__tests__/consult-context-skills.test.ts +82 -0
  447. package/src/subagent/__tests__/consult-context.test.ts +84 -0
  448. package/src/subagent/__tests__/consult-prompt.test.ts +61 -0
  449. package/src/subagent/consult-context.ts +410 -0
  450. package/src/subagent/consult-prompt.ts +41 -6
  451. package/src/subagent/consult-transcript.ts +1 -1
  452. package/src/subagent/manager.ts +288 -46
  453. package/src/subagent/progress-events.ts +35 -0
  454. package/src/subagent/role-resolution.ts +88 -0
  455. package/src/subagent/types.ts +303 -67
  456. package/src/subagent/validate-allowlists.ts +3 -4
  457. package/src/telemetry/__tests__/telemetry-event-fixtures.ts +2 -0
  458. package/src/telemetry/telemetry-event-sources.ts +13 -0
  459. package/src/telemetry/telemetry-wire-source.json +1 -1
  460. package/src/telemetry/telemetry-wire.generated.ts +3 -0
  461. package/src/telemetry/turn-events-store.ts +30 -1
  462. package/src/telemetry/types.ts +44 -0
  463. package/src/telemetry/usage-telemetry-reporter.test.ts +52 -0
  464. package/src/tools/__tests__/subagent-workflow-tool-input-schemas.test.ts +1 -1
  465. package/src/tools/ask-question/ask-question-tool.test.ts +118 -3
  466. package/src/tools/ask-question/ask-question-tool.ts +56 -2
  467. package/src/tools/browser/browser-execution.ts +1 -1
  468. package/src/tools/browser/pinned-tabs.ts +3 -1
  469. package/src/tools/executor.ts +7 -6
  470. package/src/tools/filesystem/edit.ts +1 -1
  471. package/src/tools/filesystem/list.ts +1 -1
  472. package/src/tools/filesystem/read.ts +1 -1
  473. package/src/tools/filesystem/search.ts +23 -21
  474. package/src/tools/filesystem/write.ts +4 -1
  475. package/src/tools/host-filesystem/edit.ts +1 -1
  476. package/src/tools/host-filesystem/read.ts +1 -1
  477. package/src/tools/host-filesystem/write.ts +4 -1
  478. package/src/tools/permission-checker.ts +8 -3
  479. package/src/tools/shared/filesystem/audio-read.ts +6 -4
  480. package/src/tools/shared/filesystem/file-ops-service.ts +140 -113
  481. package/src/tools/shared/filesystem/image-read.ts +12 -12
  482. package/src/tools/shared/filesystem/size-guard.ts +6 -6
  483. package/src/tools/shared/input-misuse.ts +72 -0
  484. package/src/tools/skills/skill-tool-factory.ts +14 -1
  485. package/src/tools/subagent/consult-deadline.ts +12 -7
  486. package/src/tools/subagent/read.ts +66 -4
  487. package/src/tools/subagent/spawn.ts +541 -51
  488. package/src/tools/terminal/safe-env.ts +1 -0
  489. package/src/tools/types.ts +9 -0
  490. package/src/tools/ui-surface/definitions.ts +39 -1
  491. package/src/tools/ui-surface/surface-shape-docs.ts +38 -4
  492. package/src/tools/ui-surface/visual-validation.ts +789 -0
  493. package/src/tools/workflows/run-workflow.test.ts +1 -0
  494. package/src/usage/__tests__/subagent-attribution.test.ts +109 -0
  495. package/src/usage/subagent-attribution.ts +108 -0
  496. package/src/util/__tests__/short-title.test.ts +229 -0
  497. package/src/util/__tests__/worker-compute.test.ts +65 -0
  498. package/src/util/abort-reasons.ts +16 -0
  499. package/src/util/cgroup-cpu.ts +93 -0
  500. package/src/util/disk-usage.ts +17 -13
  501. package/src/util/errors.ts +27 -0
  502. package/src/util/image-conversion.ts +20 -13
  503. package/src/util/process-tree.ts +19 -0
  504. package/src/util/short-title.ts +189 -0
  505. package/src/util/worker-compute.ts +83 -0
  506. package/src/util/worker-process.ts +7 -1
  507. package/src/workspace/byok-default-profile-ensure.ts +25 -15
  508. package/src/workspace/git-service.ts +89 -39
  509. package/src/workspace/migrations/137-repair-retired-fireworks-minimax-model-id.ts +131 -0
  510. package/src/workspace/migrations/138-backfill-home-feed-titles.ts +179 -0
  511. package/src/workspace/migrations/139-clear-renamed-cost-profile-label.ts +92 -0
  512. package/src/workspace/migrations/registry.ts +6 -0
  513. package/src/daemon/install-symlink.ts +0 -207
  514. package/src/plugins/defaults/memory/substrate/constants.ts +0 -8
@@ -3,7 +3,7 @@
3
3
  "tools": [
4
4
  {
5
5
  "name": "subagent_spawn",
6
- "description": "Spawn an independent subagent to work on a task in parallel. The subagent runs autonomously and its results are reported back when complete.\n\nTwo modes:\n- **Regular sub-agent** (fork: false or omitted): Gets only the objective + context fields. Use for self-contained tasks with clear objectives. Can use scoped roles (researcher, coder, planner).\n- **Fork** (fork: true): Inherits full parent context (messages, system prompt, memory). Shares KV cache for near-free context inheritance. Use when the task benefits from knowing what you've been discussing. Defaults to general role (the 'advisor' role is the exception — it is honored as a fork). Results are internal by default (send_result_to_user: false). Read with last_n: 1 to get only the final synthesis.\n\nDecision heuristic: Does the task need to know what we've been talking about? Fork. Is it self-contained? Regular sub-agent.\n\nThe 'advisor' role is a synchronous, read-only \"consult a stronger advisor\" mode: it inherits your full context, has no tools, and BLOCKS until it returns focused strategic guidance in a single response.",
6
+ "description": "Spawn an independent subagent to work on a task in parallel. The subagent runs autonomously and its results are reported back when complete.\n\nTwo modes:\n- **Regular sub-agent** (fork: false or omitted): Gets only the objective + context fields. Use for self-contained tasks with clear objectives. Pick its type with role: 'researcher' (read-only, fixed tool list) or 'builder' (write-capable, your whole tool surface).\n- **Fork** (fork: true): Inherits full parent context (messages, system prompt, memory). Shares KV cache for near-free context inheritance. Use when the task benefits from knowing what you've been discussing. A fork that names a role runs scoped to it; a fork that names none keeps your full tool surface. Results are internal by default (send_result_to_user: false). Read with last_n: 1 to get only the final synthesis.\n\nDecision heuristic: Does the task need to know what we've been talking about? Fork. Is it self-contained? Regular sub-agent.\n\nThe 'advisor' role is a synchronous, read-only \"consult a stronger advisor\" mode: it inherits your full context plus a snapshot of your environment (available tools, skill catalog, workspace), has read-only workspace tools for checking a decisive fact (file_read, file_list, code_search), and BLOCKS until it returns focused strategic guidance in a single response. It cannot change anything, persist output, or see other conversations.",
7
7
  "category": "orchestration",
8
8
  "risk": "low",
9
9
  "input_schema": {
@@ -19,11 +19,11 @@
19
19
  },
20
20
  "context": {
21
21
  "type": "string",
22
- "description": "Optional additional context to pass to the subagent. Ignored when fork is true — forks inherit the parent's full context."
22
+ "description": "Optional additional context to pass to the subagent. Ignored when fork is true; forks inherit the parent's full context."
23
23
  },
24
24
  "fork": {
25
25
  "type": "boolean",
26
- "description": "When true, the subagent inherits the parent's full context (messages, system prompt, memory) instead of receiving only the objective + context fields. Fork mode defaults to 'general' role (the role parameter is ignored for forks), except the special 'advisor' role which is honored even as a fork, and defaults send_result_to_user to false. Use for tasks that benefit from the full conversational context."
26
+ "description": "When true, the subagent inherits the parent's full context (messages, system prompt, memory) instead of receiving only the objective + context fields. A fork honors the role you name; naming none keeps this conversation's full tool surface, since the inherited system prompt describes those tools. Forks default send_result_to_user to false. Use for tasks that benefit from the full conversational context."
27
27
  },
28
28
  "send_result_to_user": {
29
29
  "type": "boolean",
@@ -31,19 +31,20 @@
31
31
  },
32
32
  "role": {
33
33
  "type": "string",
34
- "enum": [
35
- "general",
36
- "researcher",
37
- "coder",
38
- "planner",
39
- "investigator",
40
- "advisor"
41
- ],
42
- "description": "Agent specialization that controls tool access. 'researcher': read-only (web, files, memory). 'coder': file and bash access. 'planner': read-only analysis. 'investigator': root-cause analysis — debugging, log forensics, tracing behavior across many files; uses read-only search/read tools (code_search, file_read, file_list) with no shell access and returns a compact root-cause report. 'advisor': synchronous, read-only \"consult a stronger advisor\" — inherits full context, has no tools, and blocks until it returns focused strategic guidance. 'general': full access (default). The read-only roles (researcher, planner, investigator, advisor) cannot persist output — use 'coder' or 'general' for any objective that must write files or run commands, or a read-only subagent will finish without producing anything. Non-advisor roles are ignored when fork: true (forks default to general); the advisor role is honored even as a fork."
34
+ "description": "Which of the three subagent types to run, chosen by two questions: does it need to change anything, and do you need the answer before you can continue? 'researcher': changes nothing, runs in the background, scoped to a fixed read-only list (web_search, web_fetch, file_read, file_list, code_search, recall, skill_execute) for research, exploration, root-cause investigation, and review. 'builder': changes things, runs in the background on this conversation's whole tool surface (shell, file writes and edits, plus every connector, MCP, and browser tool you can reach) for code changes, file output, and anything that must run a command or act on an outside system. 'advisor': changes nothing and BLOCKS your turn until it answers; inherits your full context plus a snapshot of your environment (available tools, skill catalog, workspace), can read files and search code (file_read, file_list, code_search) to check a decisive fact, and returns focused strategic guidance. Default when omitted: 'builder', so a spawn that names no type keeps the full tool surface. The older names are still accepted as aliases ('planner' and 'investigator' run as researcher, 'coder' and 'general' run as builder). Any other text is not a type: the subagent runs as a researcher with that text as its persona, so if the task must write files or run commands, name 'builder' explicitly. A read-only subagent asked to produce a file finishes without producing anything. Roles apply to forks too; a fork that names no role runs as a builder and keeps this conversation's full tool surface, and a fork's persona reaches it through its task framing."
43
35
  },
44
36
  "inference_profile": {
45
37
  "type": "string",
46
- "description": "Optional llm.profiles key this subagent should run under. When omitted, the subagent inherits the parent turn's profile when one is active; otherwise it uses the subagentSpawn call site's default model selection."
38
+ "description": "Optional llm.profiles key this subagent should run under. When omitted, the subagent normally inherits the parent turn's profile if one is active, and otherwise uses the subagentSpawn call site's default model selection. When profile isolation is enabled, the subagent always takes the subagentSpawn default instead of the parent's profile, and a profile the model catalog does not report as tool-capable is replaced by that default with a note on the result. An advisor consult applies that tool-capability fallback whether or not profile isolation is enabled, since it carries read-only tools either way. An output_contract of 'verdict' takes a cheaper profile ahead of either path unless you name a profile here, or unless the subagentSpawn call site has its own profile pinned in config, which also beats the cheaper preset."
39
+ },
40
+ "confirm_repeat": {
41
+ "type": "boolean",
42
+ "description": "Set true to spawn anyway when the repeat-spawn guard reports that this objective already completed several times in the last day, or that near-identical copies of it are still running with nothing returned yet."
43
+ },
44
+ "output_contract": {
45
+ "type": "string",
46
+ "enum": ["report", "verdict", "artifact"],
47
+ "description": "What the subagent owes back. 'report' (default): prose answering the objective. 'verdict': per-criterion PASS or FAIL with the exact evidence (file path, line, value, or quote), CANNOT VERIFY where evidence is missing, and no prose beyond that list; researcher-only, and it defaults to a cheaper model because checking is mechanical. Use it for completion checks and audits instead of spawning a premium investigator. 'artifact': the deliverable is the thing produced, ending with the exact files created or modified; builder-only. A contract that does not match the role is rejected rather than coerced, and the advisor takes no contract at all."
47
48
  }
48
49
  },
49
50
  "required": ["label", "objective"]
@@ -123,7 +124,7 @@
123
124
  },
124
125
  {
125
126
  "name": "subagent_read",
126
- "description": "Read the full conversation output from a subagent. Use this after a subagent completes to retrieve its full work product.",
127
+ "description": "NOT a file reader: this returns a subagent's conversation output, addressed by subagent_id or label. To read a file from disk use file_read instead. Use this after a subagent completes to retrieve its full work product; while it is still running you will be notified automatically when it finishes, so there is no need to poll.",
127
128
  "category": "orchestration",
128
129
  "risk": "low",
129
130
  "input_schema": {
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: visualize
3
+ description: Render a polished visual inline in the chat as part of your answer — a diagram, a chart, an interactive explainer, or a UI mockup. Load it proactively whenever an explanation would land better as a picture than as prose. Do not wait to be asked.
4
+ metadata:
5
+ emoji: "📊"
6
+ vellum:
7
+ display-name: "Visualize"
8
+ category: "content"
9
+ always-candidate: true
10
+ activation-hints:
11
+ - "Explaining how something works, or how the parts of a system relate to each other"
12
+ - "Comparing options, tradeoffs, or before and after states side by side"
13
+ - "Walking through numbers, rates, growth, or a distribution the user should see"
14
+ - "Teaching a concept step by step, where the user should be able to move through it"
15
+ - "Answering how would you explain this, or helping the user teach or onboard someone else"
16
+ avoid-when:
17
+ - "Simple factual answers where a sentence or a markdown list already says it"
18
+ - "Durable apps or tools the user will reopen and keep using — use the app-builder skill"
19
+ ---
20
+
21
+ You are authoring a self-contained HTML fragment that renders inline in the chat transcript, directly beneath the paragraph you are writing. It renders in a sandboxed frame sized to your content, with the host's design tokens injected, so it looks native in light and dark mode.
22
+
23
+ ## Invocation
24
+
25
+ ```
26
+ ui_show { surface_type: "visual", data: { html: "<fragment>", height: 320 } }
27
+ ```
28
+
29
+ - `height` is a rough pixel estimate (80 to 1400); the host measures and corrects after first paint.
30
+ - One visual per call. To change one already shown, `ui_dismiss` its `surface_id` and show a new one.
31
+ - Prose goes in your reply, the visual goes in the tool: no titles, intros, or captions inside the fragment, and never describe in prose what the visual already shows.
32
+ - If ui_show returns an error, read it, fix the arguments, and call again. Every rejection is fixable in the next call; never debug via shell or files, and never narrate retries.
33
+
34
+ A visual is part of one answer. Durable things the user reopens (a dashboard, a tracker, a calculator they keep) are apps: use the `app-builder` skill.
35
+
36
+ ## Design instincts
37
+
38
+ - Seamless and flat: no gradients, shadows, glow, or texture. Flat fills, hairline borders.
39
+ - Compact and honest: show the essential, explain the rest in prose; every number on screen is one you actually have.
40
+ - Pick the lightest form that carries the idea, and invent freely: a bespoke drawing that fits this answer beats a stock layout. Interaction has to earn its place; steppers are for stages that genuinely follow one another, tabs are not a default. Vary layout between visuals in one conversation.
41
+ - Route diagrams on the verb: "walk me through" wants a flowchart; "how is it organised" wants containment boxes; "how does it actually work" wants the mechanism drawn as an intuition, not a safer flowchart.
42
+
43
+ ## Sandbox constraints (hard)
44
+
45
+ - No network: no script src, stylesheets, @import, remote images, web fonts, fetch, or CDN libraries. Charts and diagrams are hand-drawn inline SVG; images are inline SVG only.
46
+ - Fragment only: no DOCTYPE, html, head, or body. No HTML comments, no emoji.
47
+ - Hard cap 24000 characters; aim well under 8000. Too big to fit is too big to render. Split rich subjects into two visuals with prose between.
48
+ - No position fixed or sticky, no nested scrollbars: the frame auto-sizes from in-flow content.
49
+ - No localStorage, sessionStorage, or cookies. Hold state in JS variables.
50
+
51
+ ## Fragment structure
52
+
53
+ Order: a visually hidden `<h2 class="sr-only">` one-sentence summary, a short style block, the markup, one script element last. Always quote every attribute value (`class="row-box hit"`, never `class=row-box hit`). Include verbatim when using sr-only:
54
+
55
+ ```css
56
+ .sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
57
+ ```
58
+
59
+ Usable width is about 660px; the host insets content 6px vertically and 10px from the sides. Rows holding controls carry their own padding of at least 8px on the crowded sides. Keep the outer background transparent.
60
+
61
+ ## Design tokens
62
+
63
+ The COMPLETE list of injected CSS variables. Any other var() name is rejected unless your own style block declares it. Never hardcode a colour: hex, rgb(), hsl(), and oklch() literals are rejected everywhere, including SVG fill and stroke; only `transparent` and `currentColor` are allowed.
64
+
65
+ Semantic tokens flip automatically between light and dark. Use them for every surface, body text, border, and status colour:
66
+
67
+ - Surfaces: --surface-base (page), --surface-lift (card), --surface-overlay, --surface-sunken (recessed tile), --surface-hover, --surface-active.
68
+ - Text, strongest to faintest: --content-emphasised, --content-strong, --content-default (body), --content-secondary (labels and any text under 14px), --content-tertiary (14px and up only), --content-quiet, --content-faint, --content-disabled, --content-inset (on inverted fills). Text at 11 to 13px always takes --content-secondary or stronger.
69
+ - Borders: --border-base (hairline), --border-subtle, --border-element (visible control edge), --border-hover, --border-active, --border-disabled.
70
+ - Status pairs: --system-positive-strong/-weak, --system-negative-strong/-weak (and --system-negative-hover), --system-mid-strong/-weak, --system-info-strong/-weak. A non-text glyph sitting on its own -weak fill takes --system-positive-on-weak or --system-negative-on-weak; those clear the 3:1 that non-text indicators need, which --system-negative-strong misses on --system-negative-weak in the dark theme. Text on a -weak fill needs 4.5:1 and takes --content-default or stronger; --content-tertiary misses that on both fills in the light and dark themes, and --content-secondary misses it on the negative fill in light.
71
+ - Type: --font-sans (default), --font-mono (identifiers, code, tabular numbers only), --font-serif (editorial pull-quotes only).
72
+ - Radius: --radius-xs 2, --radius-sm 4, --radius-md 8, --radius-lg 12, --radius-xl 16, --radius-xxl 20, --radius-pill 999.
73
+
74
+ Palette ramps are for categorical encoding only, never page surfaces or body text: --color-moss-50..950 and --color-stone-50..950 (neutrals), --color-forest-100..950, --color-emerald-100..950, --color-danger-100..950, --color-amber-100..950. Stops run light (100) to dark (950). Author every ramp use against the light theme as a matched triple from ONE ramp, and the host mirrors it in dark mode as a unit:
75
+
76
+ ```css
77
+ background: var(--color-forest-100);
78
+ border-color: var(--color-forest-600);
79
+ color: var(--color-forest-900);
80
+ ```
81
+
82
+ The two rules the mirror imposes: text on a tinted fill takes the same ramp's 900 (secondary 800), never a --content-* token; and text sitting on the page (SVG labels, axis ticks, anything outside a tinted fill) takes --content-*, never a bare ramp stop. A dark ramp stop used as text is only valid where its light counterpart is painted right there on the same element or enclosing group.
83
+
84
+ Colour discipline: colour encodes category, not sequence. At most two accent ramps per visual plus a neutral, one accent moment per visual, system tokens only for genuine success/failure/warning/info, and a one-line legend whenever colour carries meaning. Never distinguish categories by colour alone; pair with a label or shape.
85
+
86
+ ## Typography and spacing
87
+
88
+ - Sizes: 18px section label, 15px item title, 14px body (default), 12px secondary, 11px floor. Weights 400 and 500 only. Sentence case everywhere.
89
+ - Line-height 1.6 for prose; vertical rhythm in rem (0.5, 1, 1.5, 2); internal gaps in px (8, 12, 16).
90
+ - Card: --surface-lift, 1px --border-base, --radius-lg, padding 1rem 1.25rem. Tile: --surface-sunken with a 1px --border-subtle (it dissolves into the light page without the hairline), --radius-md.
91
+ - Buttons and pills take --radius-pill or --radius-sm, one choice per visual. No box-shadow except a focus ring. Size height to content honestly; no empty bands.
92
+ - Round every displayed number (Math.round, toFixed, toLocaleString); give range inputs an explicit step so the control emits round values.
93
+
94
+ ## Complexity budget (hard)
95
+
96
+ At most 4 items across one row, 5 diagram nodes, 2 ramps, 5-word subtitles. Past any of these, split into two visuals with prose between. Over roughly 8000 characters means you are building too much.
97
+
98
+ ## SVG mechanics
99
+
100
+ Anything with nodes and arrows is ONE inline SVG with `width="100%"` and `viewBox="0 0 680 H"`, never a row of HTML divs (divs clip silently at the frame edge; SVG scales). Skeleton:
101
+
102
+ ```html
103
+ <svg width="100%" viewBox="0 0 680 320" role="img">
104
+ <title>One sentence.</title>
105
+ <desc>What the boxes and arrows are.</desc>
106
+ <style>
107
+ text{font-family:var(--font-sans)}
108
+ .th{font-size:14px;font-weight:500;fill:var(--content-strong)}
109
+ .ts{font-size:12px;fill:var(--content-secondary)}
110
+ .box rect{fill:var(--surface-lift);stroke:var(--border-element)}
111
+ .arr{stroke:var(--border-element);fill:none;marker-end:url(#a)}
112
+ </style>
113
+ <defs><marker id="a" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M2 1L8 5L2 9" fill="none" stroke="context-stroke" stroke-width="1.5" stroke-linecap="round"/></marker></defs>
114
+ </svg>
115
+ ```
116
+
117
+ - Keep viewBox width 680 (one unit = one CSS pixel). Lay nodes out on the grid below instead of computing positions: it is already sized so nothing overlaps and nothing clips, so there is no spacing arithmetic to do, and the validator checks bounds for you on submit.
118
+ - Node width 140, height 44 (single line, text at y + 22) or 56 (title at y + 20, subtitle at y + 38).
119
+ - 4 nodes across: x = 30, 200, 370, 540. 3 across: x = 60, 270, 480. 2 across: x = 120, 420.
120
+ - Rows at y = 20, 110, 200, 290. viewBox height = last row's y + 80.
121
+ - Horizontal arrows run between node edges at the node's mid height. Arrow labels fit only at 2 or 3 nodes across (12 above the arrow, centred on the gap); at 4 across the gaps are 30px, nothing fits, so leave those arrows unlabeled and carry the verbs in your prose.
122
+ - Containers wrap a row group with 16 of margin; free-form shapes for illustrative drawings stay inside one grid cell or one row band.
123
+ - Every coordinate is an absolute viewBox coordinate. Never use the transform attribute: translated groups mix local and absolute positions and labels land outside their boxes (the validator rejects transforms). A node is a rect plus its text at the rect's own position:
124
+
125
+ ```html
126
+ <g class="n-forest">
127
+ <rect x="200" y="110" width="140" height="56" rx="8" />
128
+ <text class="th" x="270" y="130" text-anchor="middle" dominant-baseline="central">Resolver</text>
129
+ <text class="ts" x="270" y="148" text-anchor="middle" dominant-baseline="central">checks cache</text>
130
+ </g>
131
+ ```
132
+
133
+ - Node titles fit at about 13 characters; subtitles at 5 words. Longer means shorten the words, never the spacing. SVG text never wraps; no rotated text.
134
+ - Background fills scope to the shape, never the group: `.note rect{fill:var(--surface-sunken)}`, not `.note{fill:...}`. fill inherits to text, so a group-level surface fill silently repaints the labels inside it in the background colour.
135
+ - Every text element needs `dominant-baseline="central"` with y at the centre of its slot. Two sizes only: 14px titles, 12px everything else.
136
+ - Any path or polyline used as a line carries `fill="none"` or it renders as a black blob. Strokes: 1px structure, 2px chart line. One arrowhead marker is the whole of defs; no filters, no gradients.
137
+ - A coloured node applies its matched ramp triple as one class on the group containing rect and text together.
138
+ - Charts: 2px lines, no dot per datum unless points are the story; bars with rx 2 and a 4px gap minimum; gridlines 1px --border-subtle; label axes directly rather than with a legend when there are two series or fewer.
139
+
140
+ ## Interaction mechanics
141
+
142
+ One state object, one render() function, handlers mutate state and call render(); call render() once at the end of the script so the first paint is populated. Controls are unstyled by the sandbox; style them yourself:
143
+
144
+ ```css
145
+ .btn{padding:6px 12px;border-radius:var(--radius-md);border:1px solid var(--border-element);background:transparent;font:400 13px var(--font-sans);color:var(--content-default);cursor:pointer}
146
+ .btn:hover{background:var(--surface-hover)}
147
+ ```
148
+
149
+ - Selected state lives on aria-pressed or aria-selected and the CSS keys off that attribute. Every control is a real button or input, never a clickable div; glyph-only controls get aria-label.
150
+ - Range inputs: min, max, value, explicit step; recompute on `input`; put the live readout beside the control with a min-width so digits do not jitter.
151
+ - A static table is better as markdown in your reply; a table earns a fragment only when rows react to interaction. Use table-layout:fixed and --font-mono at 12px.
152
+
153
+ A global `sendPrompt(text)` sends text to the chat as though the user typed it, for follow-ups that need you to think ("Compare last quarter"). Give such controls a trailing arrow glyph (&#8599;). Filtering, sorting, and recomputing happen in local JS instead, instantly. sendPrompt fires only from a real user click, never on load or a timer.
154
+
155
+ ## Accessibility
156
+
157
+ HTML fragments open with the sr-only h2; a lone-SVG fragment instead carries role="img" with title and desc as its first children. Toggle state never lives on colour alone.
158
+
159
+ ## Now compose
160
+
161
+ Everything you need is above, and none of it needs verifying in advance: the grid already spaces things, and the validator checks tokens, contrast, and bounds when you submit, telling you exactly what to change if anything is off. Pre-checking coordinates, estimating label widths, or reviewing markup in your head duplicates work the validator does in milliseconds.
162
+
163
+ Your next action is the ui_show call itself. Your entire reasoning budget for this visual is a few sentences: name the form, name the grid slots you will use, done. Markup written in reasoning does not render, does not count as showing the user anything, and has to be written all over again inside the call, so a draft there spends the entire budget and produces nothing on screen. Compose the fragment for the first time inside `data.html` as you write the call. If you notice yourself reasoning about the fragment's contents, stop and start the call.
@@ -123,10 +123,11 @@ export const CALL_SITE_DEFAULTS: Record<LLMCallSite, CallSiteDefaultConfig> = {
123
123
  },
124
124
  // Endpoint decisions gate live-voice turn-end latency, and `cost-optimized`'s
125
125
  // upstream cannot fit any usable decision budget (~1s+ per forced tool call).
126
- // `latency-optimized` is the internal latency-class profile (see
126
+ // `latency-optimized` is the latency-class profile (see
127
127
  // default-profile-catalog.ts): managed installs get the pinned latency model,
128
128
  // BYOK installs resolve their own provider's latency model through the intent
129
- // table rather than a model id they may hold no credential for.
129
+ // table rather than a model id they may hold no credential for. The profile
130
+ // is user-facing ("Speed"), so a user edit to it moves this call site too.
130
131
  voiceFrontDecision: {
131
132
  profile: "latency-optimized",
132
133
  effort: "low",
@@ -11,12 +11,8 @@ import {
11
11
  DEFAULT_PROFILE_PROVIDERS,
12
12
  type DefaultProfileKey,
13
13
  type DefaultProfileProvider,
14
- INTERNAL_PROFILE_KEYS,
15
- type InternalProfileKey,
16
14
  isDefaultProfileProvider,
17
15
  OS_BETA_PROFILE_KEY,
18
- PROFILE_MATRIX_KEYS,
19
- type ProfileMatrixKey,
20
16
  } from "./default-profile-names.js";
21
17
  import { resolveDefaultConnectionName } from "./default-provider-resolution.js";
22
18
  import {
@@ -28,7 +24,8 @@ import {
28
24
 
29
25
  /**
30
26
  * Code-defined catalog of the default inference profiles (`balanced`,
31
- * `quality-optimized`, `cost-optimized`, plus the flag-gated `os-beta`).
27
+ * `quality-optimized`, `cost-optimized`, `latency-optimized`, plus the
28
+ * flag-gated `os-beta`).
32
29
  *
33
30
  * The catalog is the single source of truth for default profile CONTENT,
34
31
  * structured as an intent × provider matrix: each default profile is an
@@ -60,6 +57,9 @@ export type DefaultProfileTemplate = Omit<
60
57
  provider: NonNullable<ProfileEntry["provider"]>;
61
58
  };
62
59
 
60
+ /** One implementation of every default profile, keyed by profile key. */
61
+ type ProfileImpls = Record<DefaultProfileKey, DefaultProfileTemplate>;
62
+
63
63
  /**
64
64
  * The `vellum` column: platform-managed implementations, stamped
65
65
  * `provider: "vellum"` — dispatch derives the upstream from the model.
@@ -68,7 +68,7 @@ export type DefaultProfileTemplate = Omit<
68
68
  * Overwritten in workspace config on every daemon boot so Vellum can push
69
69
  * model/config updates to customers in new releases.
70
70
  */
71
- const VELLUM_PROFILE_IMPLS: Record<ProfileMatrixKey, DefaultProfileTemplate> = {
71
+ const VELLUM_PROFILE_IMPLS: ProfileImpls = {
72
72
  balanced: {
73
73
  model: "gpt-5.6-luna",
74
74
  provider: "vellum",
@@ -99,11 +99,11 @@ const VELLUM_PROFILE_IMPLS: Record<ProfileMatrixKey, DefaultProfileTemplate> = {
99
99
  model: "accounts/fireworks/models/deepseek-v4-flash",
100
100
  provider: "vellum",
101
101
  source: "managed",
102
- label: "Speed",
102
+ label: "Cost",
103
103
  // Tier intent only - never name the concrete model here. Clients
104
104
  // surface the live model beside the description, so a model name in
105
105
  // this copy would go stale the moment the pin moves.
106
- description: "Fastest responses at lower cost",
106
+ description: "Cheapest responses, for high-volume work",
107
107
  maxTokens: 8192,
108
108
  // Explicit reasoning opt-out. OpenAI-compat APIs default reasoning to
109
109
  // "medium" when the field is omitted, and effort-driven providers encode
@@ -116,22 +116,24 @@ const VELLUM_PROFILE_IMPLS: Record<ProfileMatrixKey, DefaultProfileTemplate> = {
116
116
  },
117
117
  },
118
118
  "latency-optimized": {
119
- // The managed latency class. Its leading tokens are the live-voice
120
- // turn-taking verdict, so what this profile optimizes is the tail of
121
- // time-to-first-token rather than the median: a verdict slower than
122
- // `liveVoice.frontModel.endpointDecisionTimeoutMs` trips the speculative
123
- // fail-open commit in live-voice-session.ts, which is audible dead air.
119
+ // The managed latency class, also what the live-voice front model runs on.
120
+ // Its leading tokens are the turn-taking verdict, so what this profile
121
+ // optimizes is the tail of time-to-first-token rather than the median: a
122
+ // verdict slower than `liveVoice.frontModel.endpointDecisionTimeoutMs`
123
+ // trips the speculative fail-open commit in live-voice-session.ts, which
124
+ // is audible dead air.
124
125
  //
125
126
  // Two constraints bind the model id. Its managed credentials must be
126
127
  // provisioned in every environment, and it alone selects the upstream:
127
128
  // `provider` below is the provider-agnostic managed sentinel, so
128
129
  // `getManagedUpstream` resolves the real upstream from the model's catalog
129
- // owner.
130
+ // owner. Sharing `balanced`'s model is deliberate: the split is effort
131
+ // and thinking, and this model is the one live-voice TTFT drives validated.
130
132
  model: "gpt-5.6-luna",
131
133
  provider: "vellum",
132
134
  source: "managed",
133
- label: "Latency",
134
- description: "Lowest time-to-first-token, for real-time call sites",
135
+ label: "Speed",
136
+ description: "Fastest responses, with reasoning turned off",
135
137
  maxTokens: 8192,
136
138
  effort: "low",
137
139
  thinking: { enabled: false, streamThinking: false },
@@ -150,7 +152,7 @@ const VELLUM_PROFILE_IMPLS: Record<ProfileMatrixKey, DefaultProfileTemplate> = {
150
152
  * per-request for any other default-capable provider.
151
153
  */
152
154
  const BYOK_PROFILE_IMPLS: Record<
153
- ProfileMatrixKey,
155
+ DefaultProfileKey,
154
156
  Omit<DefaultProfileTemplate, "provider">
155
157
  > = {
156
158
  balanced: {
@@ -173,21 +175,24 @@ const BYOK_PROFILE_IMPLS: Record<
173
175
  thinking: { enabled: true, streamThinking: true },
174
176
  contextWindow: { maxInputTokens: DEFAULT_CONTEXT_WINDOW_MAX_INPUT_TOKENS },
175
177
  },
178
+ // On providers whose cheapest model is also their fastest (anthropic,
179
+ // ollama, fireworks) these two intents resolve the same model and the split
180
+ // is effort alone (see PROVIDER_MODEL_INTENTS).
176
181
  "cost-optimized": {
177
- intent: "latency-optimized",
182
+ intent: "cost-optimized",
178
183
  source: "user",
179
- label: "Speed",
180
- description: "Fastest responses at lower cost",
184
+ label: "Cost",
185
+ description: "Cheapest responses, for high-volume work",
181
186
  maxTokens: 8192,
182
- effort: "low",
187
+ effort: "none",
183
188
  thinking: { enabled: false, streamThinking: false },
184
189
  contextWindow: { maxInputTokens: DEFAULT_CONTEXT_WINDOW_MAX_INPUT_TOKENS },
185
190
  },
186
191
  "latency-optimized": {
187
192
  intent: "latency-optimized",
188
193
  source: "user",
189
- label: "Latency",
190
- description: "Lowest time-to-first-token, for real-time call sites",
194
+ label: "Speed",
195
+ description: "Fastest responses, with reasoning turned off",
191
196
  maxTokens: 8192,
192
197
  effort: "low",
193
198
  thinking: { enabled: false, streamThinking: false },
@@ -200,10 +205,10 @@ const BYOK_PROFILE_IMPLS: Record<
200
205
  * implementation of default profile `key` on `provider`.
201
206
  */
202
207
  export const PROFILE_IMPLS: Record<
203
- ProfileMatrixKey,
208
+ DefaultProfileKey,
204
209
  Record<DefaultProfileProvider, DefaultProfileTemplate>
205
210
  > = Object.fromEntries(
206
- PROFILE_MATRIX_KEYS.map((key) => [
211
+ DEFAULT_PROFILE_KEYS.map((key) => [
207
212
  key,
208
213
  Object.fromEntries(
209
214
  DEFAULT_PROFILE_PROVIDERS.map((provider) => [
@@ -215,7 +220,7 @@ export const PROFILE_IMPLS: Record<
215
220
  ) as Record<DefaultProfileProvider, DefaultProfileTemplate>,
216
221
  ]),
217
222
  ) as Record<
218
- ProfileMatrixKey,
223
+ DefaultProfileKey,
219
224
  Record<DefaultProfileProvider, DefaultProfileTemplate>
220
225
  >;
221
226
 
@@ -229,18 +234,45 @@ export const MANAGED_PROFILE_TEMPLATES: Record<string, DefaultProfileTemplate> =
229
234
  DEFAULT_PROFILE_KEYS.map((key) => [key, PROFILE_IMPLS[key].vellum]),
230
235
  );
231
236
 
237
+ /**
238
+ * The values BYOK hatch seeding wrote onto each `custom-*` copy, for the keys
239
+ * whose live template carries something else. The conversion pass recognizes
240
+ * an unedited copy by comparing it field-by-field against the frozen body, so
241
+ * every field here must describe what sits on disk, not what the profile
242
+ * resolves to today. A field the live template alone supplies makes every
243
+ * unedited copy read as user-edited and stop converting.
244
+ *
245
+ * `intent` selects the copy's model through `materializeProfile`, so it is the
246
+ * load-bearing pin. `label` is compared nowhere in the body, but
247
+ * `userOverlayState` reads it to tell a user rename from the hatch's own
248
+ * label, and a mismatch there carries a phantom rename onto the bare key.
249
+ */
250
+ const HATCH_ERA_TEMPLATE_FIELDS: Partial<
251
+ Record<DefaultProfileKey, Partial<DefaultProfileTemplate>>
252
+ > = {
253
+ "cost-optimized": {
254
+ intent: "latency-optimized",
255
+ label: "Speed",
256
+ description: "Fastest responses at lower cost",
257
+ effort: "low",
258
+ },
259
+ };
260
+
232
261
  /**
233
262
  * Frozen record of the `custom-*` profile bodies that pre-conversion BYOK
234
263
  * hatches wrote to workspace config (the anthropic column; provider and
235
264
  * connection were overridden per hatch). Consumed by the existing-install
236
265
  * conversion pass as the reference for recognizing unedited copies, which
237
266
  * are safe to remove in favor of the code-resolved defaults.
267
+ *
268
+ * The `latency-optimized` entry exists for shape only: hatch seeding writes no
269
+ * `custom-latency-optimized`, so no install holds one to recognize.
238
270
  */
239
271
  export const USER_PROFILE_TEMPLATES: Record<string, DefaultProfileTemplate> =
240
272
  Object.fromEntries(
241
273
  DEFAULT_PROFILE_KEYS.map((key) => [
242
274
  `custom-${key}`,
243
- PROFILE_IMPLS[key].anthropic,
275
+ { ...PROFILE_IMPLS[key].anthropic, ...HATCH_ERA_TEMPLATE_FIELDS[key] },
244
276
  ]),
245
277
  );
246
278
 
@@ -263,6 +295,17 @@ export const OS_BETA_PROFILE_TEMPLATE: DefaultProfileTemplate = {
263
295
  topP: 0.95,
264
296
  };
265
297
 
298
+ /**
299
+ * Profiles whose body is code-owned outright: no workspace overlay, and no
300
+ * user-owned shadow. The shadow rule below lets a user replace a default they
301
+ * can select, but `latency-optimized` fronts every live-voice turn through
302
+ * `voiceFrontDecision`/`voiceFrontDoor`, where a model outside the latency
303
+ * envelope is audible dead air rather than a slow reply. A same-named
304
+ * workspace entry stays on disk and stays listed; it just never governs what
305
+ * this name resolves to.
306
+ */
307
+ export const CODE_OWNED_PROFILE_NAMES = new Set<string>(["latency-optimized"]);
308
+
266
309
  // All managed profiles, including the flag-gated os-beta, are invariant:
267
310
  // their MANAGED-SOURCE entries are read-only to user-facing writes except
268
311
  // re-enabling a disabled one (enforced at commitConfigWrite). A user-owned
@@ -270,7 +313,6 @@ export const OS_BETA_PROFILE_TEMPLATE: DefaultProfileTemplate = {
270
313
  // the on-disk entry's `source` being `managed`.
271
314
  export const INVARIANT_PROFILE_NAMES = new Set<string>([
272
315
  ...DEFAULT_PROFILE_KEYS,
273
- ...INTERNAL_PROFILE_KEYS,
274
316
  OS_BETA_PROFILE_KEY,
275
317
  ]);
276
318
 
@@ -283,7 +325,6 @@ export const INVARIANT_PROFILE_NAMES = new Set<string>([
283
325
  // same-named user profile.
284
326
  export const MANAGED_PROFILE_NAMES = new Set<string>([
285
327
  ...DEFAULT_PROFILE_KEYS,
286
- ...INTERNAL_PROFILE_KEYS,
287
328
  OS_BETA_PROFILE_KEY,
288
329
  ]);
289
330
 
@@ -319,7 +360,7 @@ export function materializeProfile(
319
360
  // `PROVIDER_MODEL_INTENTS`' own check): exactly one of `intent`/`model` is
320
361
  // set, and every pinned model id exists in PROVIDER_CATALOG for its
321
362
  // underlying provider — catching drift when a model is renamed or removed.
322
- for (const key of PROFILE_MATRIX_KEYS) {
363
+ for (const key of DEFAULT_PROFILE_KEYS) {
323
364
  for (const provider of DEFAULT_PROFILE_PROVIDERS) {
324
365
  const impl = PROFILE_IMPLS[key][provider];
325
366
  if ((impl.model == null) === (impl.intent == null)) {
@@ -355,7 +396,7 @@ for (const provider of DEFAULT_PROVIDER_CHOICES) {
355
396
  if (isDefaultProfileProvider(provider)) {
356
397
  continue;
357
398
  }
358
- for (const key of PROFILE_MATRIX_KEYS) {
399
+ for (const key of DEFAULT_PROFILE_KEYS) {
359
400
  const { model } = materializeProfile(
360
401
  { ...BYOK_PROFILE_IMPLS[key], provider },
361
402
  provider,
@@ -372,7 +413,7 @@ for (const provider of DEFAULT_PROVIDER_CHOICES) {
372
413
 
373
414
  function buildDefaultProfileEntries(): Record<string, ProfileEntry> {
374
415
  const entries: Record<string, ProfileEntry> = {};
375
- for (const key of PROFILE_MATRIX_KEYS) {
416
+ for (const key of DEFAULT_PROFILE_KEYS) {
376
417
  const impl = PROFILE_IMPLS[key].vellum;
377
418
  entries[key] = materializeProfile(impl, impl.provider);
378
419
  }
@@ -445,15 +486,7 @@ function resolveAgainstBody(
445
486
  if (body == null) {
446
487
  return workspace;
447
488
  }
448
- // An internal profile's body is code-owned outright — no workspace overlay,
449
- // not even a user-owned shadow. The shadow rule below exists so a user can
450
- // deliberately replace a default they can see and select; an internal name
451
- // was never selectable, so a same-named workspace entry (legal before the
452
- // name was reserved) is unrelated state, not an override. Honoring it would
453
- // silently hand a latency-class call site an arbitrary user model. The
454
- // entry itself is untouched: it stays in `llm.profiles`, stays listed, and
455
- // stays valid as an `activeProfile` reference.
456
- if (isInternalProfileKey(name)) {
489
+ if (CODE_OWNED_PROFILE_NAMES.has(name)) {
457
490
  return { ...body };
458
491
  }
459
492
  if (workspace == null) {
@@ -506,27 +539,11 @@ export function isDefaultProfileKey(name: string): name is DefaultProfileKey {
506
539
  return (DEFAULT_PROFILE_KEYS as readonly string[]).includes(name);
507
540
  }
508
541
 
509
- /**
510
- * Whether a name is implemented by the intent × provider matrix — the
511
- * user-facing defaults plus the internal call-site-only profiles. This is the
512
- * predicate resolution uses: an internal profile must resolve through the
513
- * default provider's column exactly like a default, even though it is never
514
- * listed or seeded.
515
- */
516
- export function isMatrixProfileKey(name: string): name is ProfileMatrixKey {
517
- return (PROFILE_MATRIX_KEYS as readonly string[]).includes(name);
518
- }
519
-
520
- /** Whether a name is a code-owned profile that must never be listed to users. */
521
- export function isInternalProfileKey(name: string): name is InternalProfileKey {
522
- return (INTERNAL_PROFILE_KEYS as readonly string[]).includes(name);
523
- }
524
-
525
542
  function defaultProfileBodyForProvider(
526
543
  name: string,
527
544
  defaultProvider: DefaultProviderConfig | null,
528
545
  ): ProfileEntry | undefined {
529
- if (defaultProvider == null || !isMatrixProfileKey(name)) {
546
+ if (defaultProvider == null || !isDefaultProfileKey(name)) {
530
547
  return CODE_DEFAULT_PROFILE_ENTRIES[name];
531
548
  }
532
549
  const { provider } = defaultProvider;
@@ -569,12 +586,6 @@ function clampMaxTokensToModelCap(body: ProfileEntry): ProfileEntry {
569
586
  * available code default, merged per `getEffectiveProfile`. This is the
570
587
  * record all runtime readers of `llm.profiles` should consume; the raw
571
588
  * workspace record is a write-path concern.
572
- *
573
- * Internal profiles are omitted: they exist only to be named by a call-site
574
- * default, so listing them would offer them as selectable models and let
575
- * `activeProfile`/`overrideProfile` validation accept them. Resolution
576
- * reaches them by name through `resolveDefaultProfileForProvider`, which
577
- * does not go through this record.
578
589
  */
579
590
  export function getEffectiveProfiles(
580
591
  workspaceProfiles: Record<string, ProfileEntry> | undefined,
@@ -586,9 +597,6 @@ export function getEffectiveProfiles(
586
597
  ...(workspaceProfiles ?? {}),
587
598
  };
588
599
  for (const name of Object.keys(catalogEntries)) {
589
- if (isInternalProfileKey(name)) {
590
- continue;
591
- }
592
600
  const entry = getEffectiveProfile(workspaceProfiles, name, catalogEntries);
593
601
  if (entry != null) {
594
602
  effective[name] = entry;
@@ -613,9 +621,6 @@ export function getEffectiveProfilesForProvider(
613
621
  ...(workspaceProfiles ?? {}),
614
622
  };
615
623
  for (const name of Object.keys(CODE_DEFAULT_PROFILE_ENTRIES)) {
616
- if (isInternalProfileKey(name)) {
617
- continue;
618
- }
619
624
  const entry = resolveDefaultProfileForProvider(
620
625
  workspaceProfiles,
621
626
  name,
@@ -6,41 +6,26 @@
6
6
  * import cycles.
7
7
  */
8
8
 
9
- /** Stable keys of the always-available default profiles. */
9
+ /**
10
+ * Stable keys of the always-available default profiles, in picker order.
11
+ *
12
+ * A key is an on-disk contract: `llm.callSites.*.profile`, `activeProfile`,
13
+ * mix arms and schedule pins all reference it, so a key is fixed regardless of
14
+ * the label its profile carries. `cost-optimized` is labelled "Cost" and
15
+ * `latency-optimized` is labelled "Speed" (see `default-profile-catalog.ts`).
16
+ *
17
+ * `latency-optimized` also backs the live-voice front model, which is why it
18
+ * exists as a profile rather than a raw model pin on the call site: a pin
19
+ * resolves to a provider BYOK installs may hold no credential for.
20
+ */
10
21
  export const DEFAULT_PROFILE_KEYS = [
11
22
  "balanced",
12
23
  "quality-optimized",
13
24
  "cost-optimized",
25
+ "latency-optimized",
14
26
  ] as const;
15
27
  export type DefaultProfileKey = (typeof DEFAULT_PROFILE_KEYS)[number];
16
28
 
17
- /**
18
- * Code-owned profiles that exist only to be named by a call-site default —
19
- * never offered as a user-selectable model. They resolve through the same
20
- * intent × provider matrix as the defaults, but are deliberately excluded
21
- * from the workspace seed and from every profile listing, so the picker
22
- * still shows exactly Balanced / Speed / Quality.
23
- *
24
- * `latency-optimized` is the latency-class profile the live-voice front
25
- * model runs on: `cost-optimized`'s upstream cannot meet the turn-taking
26
- * latency envelope, and the alternative — a raw model pin on the call site —
27
- * resolves to a provider BYOK installs may hold no credential for.
28
- */
29
- export const INTERNAL_PROFILE_KEYS = ["latency-optimized"] as const;
30
- export type InternalProfileKey = (typeof INTERNAL_PROFILE_KEYS)[number];
31
-
32
- /**
33
- * Every key implemented by the intent × provider matrix: the user-selectable
34
- * defaults plus the internal call-site-only profiles. This is the set the
35
- * resolver dereferences against; `DEFAULT_PROFILE_KEYS` alone is the
36
- * user-facing subset.
37
- */
38
- export const PROFILE_MATRIX_KEYS = [
39
- ...DEFAULT_PROFILE_KEYS,
40
- ...INTERNAL_PROFILE_KEYS,
41
- ] as const;
42
- export type ProfileMatrixKey = DefaultProfileKey | InternalProfileKey;
43
-
44
29
  /**
45
30
  * Flag-gated default profile: only available while the `os-beta` feature
46
31
  * flag has reconciled it into the workspace (see `sync-gated-profiles.ts`).