@vellumai/assistant 0.10.2 → 0.10.3-dev.202606252046.9075fd5

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 (546) hide show
  1. package/bun.lock +20 -0
  2. package/docs/workspace-tools.md +42 -33
  3. package/eslint-rules/cli-no-daemon-internals.js +6 -0
  4. package/node_modules/@vellumai/gateway-client/src/__tests__/guardian-delivery-contract.test.ts +91 -0
  5. package/node_modules/@vellumai/gateway-client/src/__tests__/trust-verdict-contract.test.ts +31 -0
  6. package/node_modules/@vellumai/gateway-client/src/gateway-ipc-contracts.ts +44 -0
  7. package/node_modules/@vellumai/gateway-client/src/guardian-delivery-contract.ts +48 -0
  8. package/node_modules/@vellumai/gateway-client/src/index.ts +14 -0
  9. package/node_modules/@vellumai/gateway-client/src/trust-verdict-contract.ts +17 -0
  10. package/node_modules/@vellumai/service-contracts/package.json +1 -0
  11. package/node_modules/@vellumai/service-contracts/src/__tests__/channels.test.ts +28 -0
  12. package/node_modules/@vellumai/service-contracts/src/channels.ts +41 -0
  13. package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
  14. package/openapi.yaml +196 -56
  15. package/package.json +4 -1
  16. package/scripts/test.sh +36 -15
  17. package/src/__tests__/actor-token-service.test.ts +36 -14
  18. package/src/__tests__/actor-trust-resolver-address-fallback.test.ts +83 -31
  19. package/src/__tests__/agent-loop-override-profile.test.ts +1 -0
  20. package/src/__tests__/agent-wake-disk-pressure-callsite.test.ts +2 -0
  21. package/src/__tests__/agent-wake-override-profile.test.ts +2 -0
  22. package/src/__tests__/annotate-activity-metadata.test.ts +2 -0
  23. package/src/__tests__/annotate-risk-options.test.ts +2 -0
  24. package/src/__tests__/approval-cascade.test.ts +2 -0
  25. package/src/__tests__/assistant-attachments.test.ts +42 -0
  26. package/src/__tests__/background-workers-disk-pressure.test.ts +2 -0
  27. package/src/__tests__/btw-routes.test.ts +2 -0
  28. package/src/__tests__/build-persisted-content.test.ts +2 -0
  29. package/src/__tests__/call-controller.test.ts +19 -0
  30. package/src/__tests__/channel-approval-routes.test.ts +21 -26
  31. package/src/__tests__/channel-delivery-store.test.ts +28 -0
  32. package/src/__tests__/channel-guardian.test.ts +164 -78
  33. package/src/__tests__/channel-inbound-disk-pressure.test.ts +11 -19
  34. package/src/__tests__/channel-reply-delivery.test.ts +2 -0
  35. package/src/__tests__/code-search-tool.test.ts +585 -0
  36. package/src/__tests__/compaction-events.test.ts +2 -0
  37. package/src/__tests__/compaction-ledger-store.test.ts +128 -0
  38. package/src/__tests__/compaction.benchmark.test.ts +2 -0
  39. package/src/__tests__/compactor-call-site-logging.test.ts +2 -0
  40. package/src/__tests__/compactor-low-watermark-cut.test.ts +2 -0
  41. package/src/__tests__/compactor-preserved-tail-count.test.ts +2 -0
  42. package/src/__tests__/compactor-summary-call-truncation.test.ts +2 -0
  43. package/src/__tests__/compactor-web-search-strip.test.ts +2 -0
  44. package/src/__tests__/config-loader-backfill.test.ts +123 -10
  45. package/src/__tests__/config-schema.test.ts +1 -0
  46. package/src/__tests__/confirmation-request-guardian-bridge.test.ts +31 -29
  47. package/src/__tests__/consult-deadline.test.ts +60 -0
  48. package/src/__tests__/contact-store-interaction-info.test.ts +156 -0
  49. package/src/__tests__/contact-store-user-file.test.ts +7 -10
  50. package/src/__tests__/contacts-relay-reads.test.ts +19 -24
  51. package/src/__tests__/contacts-write.test.ts +0 -2
  52. package/src/__tests__/conversation-abort-tool-results.test.ts +2 -0
  53. package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +2 -0
  54. package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +2 -0
  55. package/src/__tests__/conversation-agent-loop-overflow.test.ts +2 -0
  56. package/src/__tests__/conversation-agent-loop.test.ts +134 -0
  57. package/src/__tests__/conversation-analysis-routes.test.ts +2 -0
  58. package/src/__tests__/conversation-app-control-lifecycle.test.ts +2 -0
  59. package/src/__tests__/conversation-attention-telegram.test.ts +9 -11
  60. package/src/__tests__/conversation-confirmation-signals.test.ts +2 -0
  61. package/src/__tests__/conversation-fork-crud.test.ts +354 -24
  62. package/src/__tests__/conversation-history-web-search.test.ts +2 -0
  63. package/src/__tests__/conversation-load-history-repair.test.ts +2 -0
  64. package/src/__tests__/conversation-load-history-stripped.test.ts +2 -0
  65. package/src/__tests__/conversation-pairing.test.ts +2 -0
  66. package/src/__tests__/conversation-process-app-control-preactivation.test.ts +2 -0
  67. package/src/__tests__/conversation-process-callsite.test.ts +2 -0
  68. package/src/__tests__/conversation-provider-retry-repair.test.ts +2 -0
  69. package/src/__tests__/conversation-queue.test.ts +91 -0
  70. package/src/__tests__/conversation-routes-guardian-reply.test.ts +14 -0
  71. package/src/__tests__/conversation-routes-slash-commands.test.ts +14 -0
  72. package/src/__tests__/conversation-slash-queue.test.ts +2 -0
  73. package/src/__tests__/conversation-slash-unknown.test.ts +2 -0
  74. package/src/__tests__/conversation-speed-override.test.ts +2 -0
  75. package/src/__tests__/conversation-surfaces-task-progress.test.ts +29 -0
  76. package/src/__tests__/conversation-title-service.test.ts +2 -0
  77. package/src/__tests__/conversation-tool-setup-attribution.test.ts +47 -0
  78. package/src/__tests__/conversation-usage.test.ts +2 -0
  79. package/src/__tests__/conversation-workspace-cache-state.test.ts +2 -0
  80. package/src/__tests__/conversation-workspace-injection.test.ts +2 -0
  81. package/src/__tests__/conversation-workspace-tool-tracking.test.ts +2 -0
  82. package/src/__tests__/credential-security-invariants.test.ts +1 -1
  83. package/src/__tests__/db-compaction-events-migration.test.ts +129 -0
  84. package/src/__tests__/db-migration-rollback.test.ts +205 -171
  85. package/src/__tests__/db-test-helpers.ts +5 -4
  86. package/src/__tests__/delete-propagation.test.ts +5 -3
  87. package/src/__tests__/deterministic-verification-control-plane.test.ts +4 -2
  88. package/src/__tests__/disk-pressure-guard.test.ts +41 -0
  89. package/src/__tests__/dm-backfill.test.ts +6 -4
  90. package/src/__tests__/dm-persistence.test.ts +2 -0
  91. package/src/__tests__/emit-signal-routing-intent.test.ts +7 -6
  92. package/src/__tests__/events-dev-bypass-actor.test.ts +7 -1
  93. package/src/__tests__/exploration-drift-hook.test.ts +3 -2
  94. package/src/__tests__/filing-service.test.ts +2 -0
  95. package/src/__tests__/guardian-binding-drift-heal.test.ts +104 -19
  96. package/src/__tests__/guardian-dispatch.test.ts +140 -1
  97. package/src/__tests__/guardian-expiry-notifier.test.ts +282 -0
  98. package/src/__tests__/guardian-outbound-http.test.ts +13 -0
  99. package/src/__tests__/guardian-routing-state.test.ts +6 -10
  100. package/src/__tests__/heartbeat-disk-pressure.test.ts +2 -0
  101. package/src/__tests__/heartbeat-service.test.ts +2 -0
  102. package/src/__tests__/helpers/channel-test-adapter.ts +46 -19
  103. package/src/__tests__/helpers/create-guardian-binding.ts +15 -23
  104. package/src/__tests__/helpers/mock-logger.ts +1 -0
  105. package/src/__tests__/helpers/seed-contact-channel.ts +96 -0
  106. package/src/__tests__/host-app-control-routes.test.ts +24 -30
  107. package/src/__tests__/host-bash-routes.test.ts +31 -41
  108. package/src/__tests__/host-browser-routes.test.ts +26 -32
  109. package/src/__tests__/host-cu-routes-targeted.test.ts +25 -33
  110. package/src/__tests__/host-file-routes-targeted.test.ts +40 -52
  111. package/src/__tests__/host-transfer-routes-targeted.test.ts +31 -43
  112. package/src/__tests__/http-user-message-parity.test.ts +290 -8
  113. package/src/__tests__/inbound-invite-redemption.test.ts +115 -10
  114. package/src/__tests__/inbound-slack-persistence.test.ts +2 -0
  115. package/src/__tests__/invite-redemption-service.test.ts +471 -53
  116. package/src/__tests__/invite-routes-http.test.ts +34 -0
  117. package/src/__tests__/invite-service-ipc.test.ts +65 -2
  118. package/src/__tests__/llm-context-normalization.test.ts +105 -0
  119. package/src/__tests__/llm-request-log-error-payload.test.ts +71 -9
  120. package/src/__tests__/llm-usage-store.test.ts +25 -0
  121. package/src/__tests__/mcp-config-secret-boundary.test.ts +392 -0
  122. package/src/__tests__/mcp-health-check.test.ts +2 -1
  123. package/src/__tests__/media-stream-server-integration.test.ts +127 -0
  124. package/src/__tests__/memory-retrieval-hook.test.ts +2 -0
  125. package/src/__tests__/messaging-send-tool.test.ts +2 -0
  126. package/src/__tests__/migration-import-from-url.test.ts +2 -2
  127. package/src/__tests__/mtime-cache.test.ts +275 -5
  128. package/src/__tests__/native-web-search.test.ts +2 -0
  129. package/src/__tests__/non-member-access-request.test.ts +191 -17
  130. package/src/__tests__/notification-broadcaster.test.ts +4 -0
  131. package/src/__tests__/notification-decision-recipient-context.test.ts +33 -32
  132. package/src/__tests__/notification-deep-link.test.ts +6 -0
  133. package/src/__tests__/notification-guardian-path.test.ts +19 -0
  134. package/src/__tests__/onboarding-persona-write.test.ts +52 -22
  135. package/src/__tests__/openai-provider.test.ts +22 -12
  136. package/src/__tests__/openai-responses-provider.test.ts +12 -2
  137. package/src/__tests__/outbound-slack-persistence.test.ts +2 -0
  138. package/src/__tests__/pending-interactions-resolved-event.test.ts +7 -4
  139. package/src/__tests__/persist-onboarding-artifacts.test.ts +1 -0
  140. package/src/__tests__/persistence-secret-redaction.test.ts +2 -0
  141. package/src/__tests__/persona-resolver.test.ts +75 -45
  142. package/src/__tests__/plugin-bootstrap.test.ts +21 -83
  143. package/src/__tests__/plugin-disabled-state.test.ts +190 -0
  144. package/src/__tests__/plugin-pipeline.test.ts +96 -0
  145. package/src/__tests__/plugin-route-contribution.test.ts +6 -19
  146. package/src/__tests__/plugin-tool-contribution.test.ts +5 -20
  147. package/src/__tests__/plugin-types.test.ts +2 -4
  148. package/src/__tests__/process-message-background-slack.test.ts +2 -0
  149. package/src/__tests__/process-message-display-content.test.ts +2 -0
  150. package/src/__tests__/provider-error-scenarios.test.ts +5 -4
  151. package/src/__tests__/provider-usage-tracking.test.ts +39 -0
  152. package/src/__tests__/reaction-intercept-cold-cache-warm.test.ts +135 -0
  153. package/src/__tests__/reaction-intercept-member-verdict-warm.test.ts +158 -0
  154. package/src/__tests__/reaction-persistence.test.ts +51 -4
  155. package/src/__tests__/regenerate-fire-and-forget-trace.test.ts +2 -0
  156. package/src/__tests__/registry.test.ts +4 -1
  157. package/src/__tests__/relay-server.test.ts +758 -32
  158. package/src/__tests__/runtime-attachment-metadata.test.ts +9 -12
  159. package/src/__tests__/secret-ingress-http.test.ts +14 -0
  160. package/src/__tests__/send-endpoint-busy.test.ts +30 -8
  161. package/src/__tests__/settings-routes.test.ts +32 -0
  162. package/src/__tests__/skills.test.ts +44 -0
  163. package/src/__tests__/slack-inbound-verification.test.ts +47 -2
  164. package/src/__tests__/sse-actor-principal-guardian-source.test.ts +79 -0
  165. package/src/__tests__/steer-on-enqueue-question.test.ts +181 -0
  166. package/src/__tests__/stt-hints.test.ts +49 -15
  167. package/src/__tests__/subagent-detail.test.ts +27 -0
  168. package/src/__tests__/subagent-disposal.test.ts +65 -0
  169. package/src/__tests__/subagent-fork-prompt-role.test.ts +195 -0
  170. package/src/__tests__/subagent-fork-spawn.test.ts +6 -7
  171. package/src/__tests__/subagent-notify-parent.test.ts +2 -0
  172. package/src/__tests__/subagent-role-registry.test.ts +24 -6
  173. package/src/__tests__/subagent-spawn-and-await.test.ts +546 -0
  174. package/src/__tests__/subagent-spawn-tool-fork.test.ts +2 -0
  175. package/src/__tests__/subagent-tools.test.ts +398 -1
  176. package/src/__tests__/suggestion-routes.test.ts +2 -0
  177. package/src/__tests__/thread-backfill.test.ts +3 -3
  178. package/src/__tests__/title-generate-hook.test.ts +2 -0
  179. package/src/__tests__/tool-executor-lifecycle-events.test.ts +2 -0
  180. package/src/__tests__/tool-executor.test.ts +16 -11
  181. package/src/__tests__/tool-preview-lifecycle.test.ts +2 -0
  182. package/src/__tests__/tool-result-metadata-plumbing.test.ts +2 -0
  183. package/src/__tests__/tool-start-timestamp.test.ts +2 -0
  184. package/src/__tests__/trusted-contact-approval-notifier.test.ts +37 -51
  185. package/src/__tests__/trusted-contact-inline-approval-integration.test.ts +12 -12
  186. package/src/__tests__/trusted-contact-lifecycle-notifications.test.ts +9 -7
  187. package/src/__tests__/trusted-contact-multichannel.test.ts +16 -7
  188. package/src/__tests__/trusted-contact-verification.test.ts +79 -54
  189. package/src/__tests__/twilio-routes.test.ts +96 -0
  190. package/src/__tests__/ui-file-upload-surface.test.ts +86 -0
  191. package/src/__tests__/verification-control-plane-policy.test.ts +2 -0
  192. package/src/__tests__/voice-guardian-cold-cache-warm.test.ts +137 -0
  193. package/src/__tests__/voice-invite-redemption.test.ts +216 -20
  194. package/src/__tests__/web-search-backend-failure.test.ts +2 -0
  195. package/src/__tests__/workspace-migration-102-preserve-heartbeat-enabled-for-existing-workspaces.test.ts +3 -3
  196. package/src/__tests__/workspace-migration-111-prune-seeded-callsite-defaults.test.ts +208 -0
  197. package/src/__tests__/workspace-migration-112-remove-advisor-callsite-override.test.ts +170 -0
  198. package/src/__tests__/workspace-migration-drop-user-md.test.ts +196 -238
  199. package/src/__tests__/workspace-migration-remove-hooks.test.ts +14 -35
  200. package/src/__tests__/workspace-tool-loader.test.ts +195 -2
  201. package/src/a2a/__tests__/e2e-a2a-channel.test.ts +35 -47
  202. package/src/agent/loop-exclusive-tool.test.ts +154 -0
  203. package/src/agent/loop-native-web-search.test.ts +200 -0
  204. package/src/agent/loop.ts +164 -1
  205. package/src/api/constants/sse-replay.ts +41 -0
  206. package/src/api/events/conversation-notice.ts +26 -0
  207. package/src/api/index.ts +19 -1
  208. package/src/api/responses/llm-request-log-entry.ts +29 -0
  209. package/src/api/responses/subagent-detail.ts +17 -0
  210. package/src/api/surfaces.ts +39 -3
  211. package/src/approvals/guardian-channel-delivery.ts +30 -0
  212. package/src/approvals/guardian-expiry-notifier.ts +148 -0
  213. package/src/approvals/guardian-request-resolvers.ts +17 -15
  214. package/src/calls/__tests__/relay-setup-router.test.ts +267 -17
  215. package/src/calls/call-domain.ts +3 -3
  216. package/src/calls/guardian-dispatch.ts +14 -9
  217. package/src/calls/inbound-trust-reader.ts +24 -2
  218. package/src/calls/media-stream-server.ts +21 -0
  219. package/src/calls/relay-access-wait.ts +6 -6
  220. package/src/calls/relay-server.ts +188 -51
  221. package/src/calls/relay-setup-router.ts +47 -17
  222. package/src/calls/relay-verification.ts +4 -4
  223. package/src/calls/stt-hints.ts +9 -12
  224. package/src/calls/twilio-routes.ts +14 -4
  225. package/src/channels/types.ts +10 -20
  226. package/src/cli/commands/__tests__/cache.test.ts +8 -1
  227. package/src/cli/commands/__tests__/conversations-slack.test.ts +1 -0
  228. package/src/cli/commands/cache.ts +194 -181
  229. package/src/cli/commands/contacts.ts +10 -7
  230. package/src/cli/commands/db/__tests__/repair.test.ts +6 -5
  231. package/src/cli/commands/db/status.ts +37 -1
  232. package/src/cli/commands/mcp.ts +252 -218
  233. package/src/cli/commands/memory/__tests__/worker.test.ts +432 -0
  234. package/src/cli/commands/memory/index.ts +2 -0
  235. package/src/cli/commands/memory/worker.ts +242 -0
  236. package/src/cli/commands/plugins.ts +125 -13
  237. package/src/cli/lib/__tests__/install-from-github.test.ts +102 -0
  238. package/src/cli/lib/__tests__/list-installed-plugins.test.ts +160 -1
  239. package/src/cli/lib/__tests__/publish-plugin.test.ts +404 -0
  240. package/src/cli/lib/list-installed-plugins.ts +179 -1
  241. package/src/cli/lib/publish-plugin.ts +633 -0
  242. package/src/config/__tests__/loader-callsite-strip-fallback.test.ts +143 -0
  243. package/src/config/__tests__/sync-gated-profiles.test.ts +16 -10
  244. package/src/config/bundled-skills/contacts/tools/contact-merge.ts +27 -17
  245. package/src/config/bundled-skills/contacts/tools/contact-search.ts +13 -3
  246. package/src/config/bundled-skills/subagent/SKILL.md +17 -2
  247. package/src/config/bundled-skills/subagent/TOOLS.json +5 -4
  248. package/src/config/call-site-defaults.ts +0 -6
  249. package/src/config/feature-flag-registry.json +5 -13
  250. package/src/config/llm-resolver.ts +0 -3
  251. package/src/config/loader.ts +38 -5
  252. package/src/config/prune-seeded-callsite-defaults.ts +110 -0
  253. package/src/config/schemas/__tests__/memory-v3.test.ts +1 -0
  254. package/src/config/schemas/call-site-catalog.ts +0 -7
  255. package/src/config/schemas/heartbeat.ts +2 -5
  256. package/src/config/schemas/llm.ts +3 -12
  257. package/src/config/schemas/memory-lifecycle.ts +12 -0
  258. package/src/config/schemas/memory-v3.ts +7 -0
  259. package/src/config/schemas/memory.ts +4 -0
  260. package/src/config/schemas/timeouts.ts +8 -0
  261. package/src/config/seed-inference-profiles.ts +30 -34
  262. package/src/config/skills.ts +27 -5
  263. package/src/config/sync-gated-profiles.ts +12 -16
  264. package/src/contacts/__tests__/contacts-write-revoke-relay.test.ts +128 -0
  265. package/src/contacts/__tests__/guardian-delivery-reader.test.ts +312 -0
  266. package/src/contacts/__tests__/member-write-relay.test.ts +226 -0
  267. package/src/contacts/contact-store.ts +27 -237
  268. package/src/contacts/contacts-write.ts +18 -55
  269. package/src/contacts/gateway-channel-read.ts +51 -0
  270. package/src/contacts/guardian-delivery-reader.ts +223 -0
  271. package/src/contacts/member-write-relay.ts +183 -0
  272. package/src/contacts/types.ts +3 -15
  273. package/src/daemon/__tests__/conversation-tool-setup-exclude.test.ts +35 -0
  274. package/src/daemon/__tests__/conversation-tool-setup.test.ts +0 -44
  275. package/src/daemon/assistant-attachments.ts +27 -4
  276. package/src/daemon/conversation-agent-loop.ts +28 -0
  277. package/src/daemon/conversation-notices.ts +60 -0
  278. package/src/daemon/conversation-process.ts +35 -16
  279. package/src/daemon/conversation-surfaces.ts +111 -38
  280. package/src/daemon/conversation-tool-setup.ts +71 -30
  281. package/src/daemon/conversation.ts +23 -1
  282. package/src/daemon/disk-pressure-guard.ts +12 -2
  283. package/src/daemon/event-loop-watchdog.ts +28 -1
  284. package/src/daemon/external-plugins-bootstrap.ts +17 -41
  285. package/src/daemon/handlers/__tests__/config-a2a-accept.test.ts +0 -1
  286. package/src/daemon/handlers/__tests__/config-a2a-complete.test.ts +0 -2
  287. package/src/daemon/handlers/__tests__/config-a2a-redeem.test.ts +25 -2
  288. package/src/daemon/handlers/__tests__/config-channels.test.ts +220 -0
  289. package/src/daemon/handlers/config-a2a.ts +6 -14
  290. package/src/daemon/handlers/config-channels.ts +67 -26
  291. package/src/daemon/handlers/conversations.ts +77 -0
  292. package/src/daemon/lifecycle.ts +16 -0
  293. package/src/daemon/mcp-reload-service.ts +10 -0
  294. package/src/daemon/memory-v2-startup.test.ts +72 -0
  295. package/src/daemon/memory-v2-startup.ts +87 -19
  296. package/src/daemon/message-types/conversations.ts +2 -0
  297. package/src/daemon/message-types/surfaces.ts +12 -12
  298. package/src/daemon/server.ts +0 -4
  299. package/src/daemon/shutdown-handlers.ts +20 -0
  300. package/src/daemon/tool-setup-types.ts +9 -0
  301. package/src/heartbeat/heartbeat-service.ts +5 -0
  302. package/src/home/relationship-state-writer.ts +5 -0
  303. package/src/hooks/hook-loader.ts +341 -0
  304. package/src/ipc/__tests__/clients-list-ipc.test.ts +1 -1
  305. package/src/ipc/assistant-server.ts +2 -2
  306. package/src/mcp/__tests__/mcp-auth-orchestrator.test.ts +1 -0
  307. package/src/mcp/client.ts +15 -1
  308. package/src/mcp/mcp-auth-orchestrator.ts +6 -1
  309. package/src/mcp/mcp-header-store.ts +134 -0
  310. package/src/mcp/mcp-oauth-provider.ts +19 -8
  311. package/src/memory/__tests__/301-create-watchdog-events.test.ts +110 -0
  312. package/src/memory/__tests__/memory-retrospective-job.test.ts +8 -0
  313. package/src/memory/__tests__/prompt-override.test.ts +192 -0
  314. package/src/memory/__tests__/watchdog-events-store.test.ts +161 -0
  315. package/src/memory/compaction-ledger-store.ts +107 -0
  316. package/src/memory/conversation-crud.ts +129 -61
  317. package/src/memory/db-connection.ts +22 -3
  318. package/src/memory/db-init.ts +37 -503
  319. package/src/memory/db-singleton.ts +6 -4
  320. package/src/memory/jobs-worker.ts +104 -0
  321. package/src/memory/llm-request-log-store.ts +26 -1
  322. package/src/memory/llm-usage-store.ts +48 -20
  323. package/src/memory/memory-retrospective-job.ts +14 -8
  324. package/src/memory/migrations/209-strip-thinking-from-consolidated.ts +152 -56
  325. package/src/memory/migrations/300-add-processing-started-at.ts +30 -0
  326. package/src/memory/migrations/301-create-watchdog-events.ts +45 -0
  327. package/src/memory/migrations/302-create-compaction-events.ts +107 -0
  328. package/src/memory/migrations/__tests__/209-strip-thinking-from-consolidated.test.ts +297 -0
  329. package/src/memory/migrations/__tests__/run-migrations.test.ts +2 -2
  330. package/src/memory/migrations/run-migrations.ts +106 -10
  331. package/src/memory/migrations/validate-migration-state.ts +105 -67
  332. package/src/memory/prompt-override.ts +129 -0
  333. package/src/memory/schema/contacts.ts +6 -2
  334. package/src/memory/schema/conversations.ts +37 -0
  335. package/src/memory/schema/infrastructure.ts +20 -0
  336. package/src/memory/steps.ts +1294 -0
  337. package/src/memory/v2/__tests__/cli-command-store.test.ts +25 -0
  338. package/src/memory/v2/__tests__/skill-store.test.ts +80 -0
  339. package/src/memory/v2/cli-command-store.ts +75 -38
  340. package/src/memory/v2/prompts/consolidation.ts +13 -82
  341. package/src/memory/v2/prompts/router.ts +21 -93
  342. package/src/memory/v2/skill-store.ts +68 -31
  343. package/src/memory/watchdog-events-store.ts +87 -0
  344. package/src/memory/worker-control.ts +204 -0
  345. package/src/memory/worker-process.ts +89 -0
  346. package/src/messaging/channel-binding-metadata.ts +31 -0
  347. package/src/messaging/provider-types.ts +8 -0
  348. package/src/messaging/providers/slack/binding-metadata.ts +60 -0
  349. package/src/notifications/__tests__/broadcaster.test.ts +8 -8
  350. package/src/notifications/__tests__/connected-channels.test.ts +86 -0
  351. package/src/notifications/__tests__/decision-engine.test.ts +78 -9
  352. package/src/notifications/__tests__/destination-resolver.test.ts +151 -0
  353. package/src/notifications/broadcaster.ts +8 -1
  354. package/src/notifications/decision-engine.ts +15 -7
  355. package/src/notifications/destination-resolver.ts +53 -25
  356. package/src/notifications/emit-signal.ts +34 -15
  357. package/src/onboarding/checkin-event.test.ts +222 -0
  358. package/src/onboarding/checkin-event.ts +321 -0
  359. package/src/onboarding/schedule-checkin.ts +190 -0
  360. package/src/permissions/question-prompter.test.ts +1 -1
  361. package/src/permissions/question-prompter.ts +7 -4
  362. package/src/plugin-api/index.ts +12 -12
  363. package/src/plugin-api/types.ts +12 -14
  364. package/src/plugin-api/vision-support.test.ts +28 -4
  365. package/src/plugin-api/vision-support.ts +66 -31
  366. package/src/plugins/defaults/empty-response/hooks/post-model-call.ts +2 -2
  367. package/src/plugins/defaults/empty-response/hooks/stop.ts +2 -2
  368. package/src/plugins/defaults/exploration-drift/hooks/post-tool-use.ts +4 -3
  369. package/src/plugins/defaults/history-repair/hooks/post-model-call.ts +2 -2
  370. package/src/plugins/defaults/history-repair/hooks/stop.ts +2 -2
  371. package/src/plugins/defaults/history-repair/hooks/user-prompt-submit.ts +2 -2
  372. package/src/plugins/defaults/image-fallback/__tests__/image-fallback.test.ts +47 -7
  373. package/src/plugins/defaults/image-fallback/hooks/post-tool-use.ts +12 -13
  374. package/src/plugins/defaults/image-fallback/hooks/user-prompt-submit.ts +14 -22
  375. package/src/plugins/defaults/image-fallback/src/caption-blocks.ts +42 -11
  376. package/src/plugins/defaults/image-recovery/hooks/post-model-call.ts +2 -2
  377. package/src/plugins/defaults/image-recovery/hooks/stop.ts +2 -2
  378. package/src/plugins/defaults/index.ts +0 -35
  379. package/src/plugins/defaults/max-tokens-continue/hooks/post-model-call.ts +2 -2
  380. package/src/plugins/defaults/max-tokens-continue/hooks/stop.ts +2 -2
  381. package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +2 -2
  382. package/src/plugins/defaults/memory-retrieval/hooks/user-prompt-submit.ts +2 -2
  383. package/src/plugins/defaults/memory-v3-shadow/__tests__/injection.test.ts +33 -3
  384. package/src/plugins/defaults/memory-v3-shadow/__tests__/pool-select.test.ts +48 -4
  385. package/src/plugins/defaults/memory-v3-shadow/__tests__/shadow-plugin.test.ts +4 -8
  386. package/src/plugins/defaults/memory-v3-shadow/hooks/post-compact.ts +2 -2
  387. package/src/plugins/defaults/memory-v3-shadow/hooks/user-prompt-submit.ts +2 -2
  388. package/src/plugins/defaults/memory-v3-shadow/injector.ts +43 -15
  389. package/src/plugins/defaults/memory-v3-shadow/orchestrate.ts +11 -2
  390. package/src/plugins/defaults/memory-v3-shadow/pool-select.test.ts +146 -0
  391. package/src/plugins/defaults/memory-v3-shadow/pool-select.ts +77 -13
  392. package/src/plugins/defaults/memory-v3-shadow/shadow-plugin.ts +12 -11
  393. package/src/plugins/defaults/surface-completion-nudge/hooks/post-model-call.ts +2 -2
  394. package/src/plugins/defaults/surface-completion-nudge/hooks/stop.ts +2 -2
  395. package/src/plugins/defaults/task-progress-nudge/hooks/post-tool-use.ts +2 -2
  396. package/src/plugins/defaults/title-generate/hooks/stop.ts +2 -2
  397. package/src/plugins/defaults/title-generate/hooks/user-prompt-submit.ts +2 -2
  398. package/src/plugins/defaults/tool-error/hooks/post-tool-use.ts +2 -2
  399. package/src/plugins/defaults/tool-result-truncate/hooks/post-tool-use.ts +2 -2
  400. package/src/plugins/disabled-state.ts +31 -0
  401. package/src/plugins/external-plugin-loader.ts +2 -2
  402. package/src/plugins/mtime-cache.ts +186 -330
  403. package/src/plugins/pipeline.ts +111 -13
  404. package/src/plugins/registry.ts +59 -16
  405. package/src/plugins/surface-import.ts +121 -0
  406. package/src/plugins/types.ts +7 -9
  407. package/src/prompts/persona-resolver.ts +43 -11
  408. package/src/providers/anthropic/client.ts +5 -0
  409. package/src/providers/call-site-routing.ts +45 -0
  410. package/src/providers/model-catalog.ts +16 -0
  411. package/src/providers/openai/__tests__/api-error-normalization.test.ts +321 -0
  412. package/src/providers/openai/api-error-normalization.ts +270 -0
  413. package/src/providers/openai/chat-completions-provider.ts +37 -83
  414. package/src/providers/openai/responses-provider.ts +50 -46
  415. package/src/providers/openrouter/client.ts +5 -0
  416. package/src/providers/provider-send-message.ts +10 -0
  417. package/src/providers/ratelimit.ts +10 -0
  418. package/src/providers/registry.ts +1 -1
  419. package/src/providers/retry.ts +10 -0
  420. package/src/providers/types.ts +22 -0
  421. package/src/providers/usage-tracking.ts +10 -0
  422. package/src/runtime/__tests__/channel-verification-service.test.ts +133 -0
  423. package/src/runtime/__tests__/guardian-vellum-migration.test.ts +184 -0
  424. package/src/runtime/__tests__/is-guardian-bound-for-channel.test.ts +66 -0
  425. package/src/runtime/__tests__/local-principal-trust.test.ts +162 -0
  426. package/src/runtime/__tests__/member-verdict-cache.test.ts +119 -0
  427. package/src/runtime/__tests__/trust-verdict-consumer.test.ts +402 -123
  428. package/src/runtime/access-request-helper.ts +18 -39
  429. package/src/runtime/actor-trust-resolver.ts +46 -19
  430. package/src/runtime/anchored-guardian.test.ts +109 -0
  431. package/src/runtime/anchored-guardian.ts +86 -0
  432. package/src/runtime/assistant-event-hub.ts +1 -1
  433. package/src/runtime/assistant-stream-state.ts +9 -2
  434. package/src/runtime/auth/__tests__/require-bound-guardian.test.ts +99 -0
  435. package/src/runtime/auth/require-bound-guardian.ts +21 -11
  436. package/src/runtime/channel-verification-service.ts +56 -31
  437. package/src/runtime/confirmation-request-guardian-bridge.ts +3 -3
  438. package/src/runtime/guardian-vellum-migration.ts +69 -8
  439. package/src/runtime/invite-redemption-service.ts +213 -187
  440. package/src/runtime/local-actor-identity.test.ts +108 -0
  441. package/src/runtime/local-actor-identity.ts +85 -13
  442. package/src/runtime/local-principal-trust.ts +52 -0
  443. package/src/runtime/member-verdict-cache.ts +0 -0
  444. package/src/runtime/pending-interactions.ts +11 -1
  445. package/src/runtime/routes/__tests__/channel-verification-revoke.test.ts +56 -5
  446. package/src/runtime/routes/__tests__/channel-verification-routes.test.ts +1 -1
  447. package/src/runtime/routes/__tests__/contact-routes.test.ts +305 -0
  448. package/src/runtime/routes/__tests__/global-search-routes.test.ts +92 -0
  449. package/src/runtime/routes/__tests__/http-adapter-actor-header.test.ts +129 -0
  450. package/src/runtime/routes/__tests__/surface-action-routes.test.ts +188 -0
  451. package/src/runtime/routes/browser-routes.ts +1 -1
  452. package/src/runtime/routes/canonical-guardian-expiry-sweep.ts +13 -5
  453. package/src/runtime/routes/channel-verification-routes.ts +3 -3
  454. package/src/runtime/routes/contact-routes.ts +48 -57
  455. package/src/runtime/routes/conversation-cli-routes.ts +4 -5
  456. package/src/runtime/routes/conversation-list-routes.ts +4 -7
  457. package/src/runtime/routes/conversation-query-routes.ts +72 -0
  458. package/src/runtime/routes/conversation-routes.ts +84 -85
  459. package/src/runtime/routes/events-routes.ts +2 -2
  460. package/src/runtime/routes/global-search-routes.ts +3 -1
  461. package/src/runtime/routes/guardian-action-routes.ts +4 -5
  462. package/src/runtime/routes/host-app-control-routes.ts +5 -4
  463. package/src/runtime/routes/host-bash-routes.ts +5 -4
  464. package/src/runtime/routes/host-browser-routes.ts +9 -11
  465. package/src/runtime/routes/host-cu-routes.ts +5 -4
  466. package/src/runtime/routes/host-file-routes.ts +5 -4
  467. package/src/runtime/routes/host-transfer-routes.ts +6 -6
  468. package/src/runtime/routes/http-adapter.ts +16 -1
  469. package/src/runtime/routes/identity-routes.ts +3 -2
  470. package/src/runtime/routes/inbound-message-handler.ts +5 -5
  471. package/src/runtime/routes/inbound-stages/acl-enforcement.test.ts +97 -5
  472. package/src/runtime/routes/inbound-stages/acl-enforcement.ts +61 -59
  473. package/src/runtime/routes/inbound-stages/background-dispatch.ts +13 -5
  474. package/src/runtime/routes/inbound-stages/escalation-intercept.ts +7 -7
  475. package/src/runtime/routes/inbound-stages/guardian-activation-intercept.test.ts +21 -8
  476. package/src/runtime/routes/inbound-stages/guardian-activation-intercept.ts +14 -3
  477. package/src/runtime/routes/inbound-stages/reaction-intercept.ts +19 -0
  478. package/src/runtime/routes/index.ts +2 -0
  479. package/src/runtime/routes/llm-context-normalization.ts +83 -0
  480. package/src/runtime/routes/mcp-auth-routes.ts +171 -19
  481. package/src/runtime/routes/migration-rollback-routes.ts +4 -3
  482. package/src/runtime/routes/migration-routes.ts +4 -1
  483. package/src/runtime/routes/onboarding-checkin-routes.ts +86 -0
  484. package/src/runtime/routes/settings-routes.ts +8 -3
  485. package/src/runtime/routes/subagents-routes.ts +5 -0
  486. package/src/runtime/routes/surface-action-routes.ts +42 -56
  487. package/src/runtime/services/__tests__/conversation-serializer.test.ts +1 -0
  488. package/src/runtime/services/conversation-serializer.ts +13 -58
  489. package/src/runtime/tool-grant-request-helper.ts +3 -3
  490. package/src/runtime/trust-verdict-consumer.ts +111 -40
  491. package/src/runtime/verification-outbound-actions.ts +18 -18
  492. package/src/signals/user-message.ts +16 -0
  493. package/src/subagent/__tests__/consult-prompt.test.ts +35 -0
  494. package/src/{plugins/defaults/advisor/__tests__/transcript.test.ts → subagent/__tests__/consult-transcript.test.ts} +47 -10
  495. package/src/{plugins/defaults/advisor/steering.ts → subagent/consult-prompt.ts} +22 -32
  496. package/src/{plugins/defaults/advisor/transcript.ts → subagent/consult-transcript.ts} +18 -8
  497. package/src/subagent/index.ts +1 -1
  498. package/src/subagent/manager.ts +254 -33
  499. package/src/subagent/types.ts +11 -4
  500. package/src/telemetry/types.ts +34 -1
  501. package/src/telemetry/usage-telemetry-reporter.test.ts +3 -2
  502. package/src/telemetry/usage-telemetry-reporter.ts +87 -3
  503. package/src/tools/ask-question/ask-question-tool.test.ts +29 -0
  504. package/src/tools/ask-question/ask-question-tool.ts +13 -0
  505. package/src/tools/executor.ts +4 -4
  506. package/src/tools/filesystem/search.ts +543 -0
  507. package/src/tools/registry.ts +38 -0
  508. package/src/tools/shared/filesystem/path-policy.ts +12 -5
  509. package/src/tools/subagent/consult-deadline.ts +49 -0
  510. package/src/tools/subagent/spawn.ts +234 -5
  511. package/src/tools/tool-approval-handler.ts +1 -1
  512. package/src/tools/tool-defaults.ts +9 -2
  513. package/src/tools/tool-manifest.ts +3 -0
  514. package/src/tools/types.ts +131 -25
  515. package/src/tools/workspace-tools/loader.ts +348 -244
  516. package/src/util/errors.ts +26 -1
  517. package/src/util/logger.ts +9 -0
  518. package/src/util/platform.ts +19 -0
  519. package/src/util/telemetry-db-path.ts +24 -0
  520. package/src/workflows/library.test.ts +140 -0
  521. package/src/workflows/library.ts +82 -28
  522. package/src/workspace/migrations/017-seed-persona-dirs.ts +3 -34
  523. package/src/workspace/migrations/019-scope-journal-to-guardian.ts +3 -24
  524. package/src/workspace/migrations/031-drop-user-md.ts +232 -148
  525. package/src/workspace/migrations/048-remove-workspace-hooks.ts +14 -66
  526. package/src/workspace/migrations/111-prune-seeded-callsite-defaults.ts +134 -0
  527. package/src/workspace/migrations/112-remove-advisor-callsite-override.ts +64 -0
  528. package/src/workspace/migrations/registry.ts +4 -0
  529. package/src/__tests__/workspace-tools-watcher-flag.test.ts +0 -70
  530. package/src/daemon/workspace-tools-watcher.ts +0 -328
  531. package/src/memory/migrations/registry.ts +0 -573
  532. package/src/plugins/defaults/advisor/__tests__/advisor-gate.test.ts +0 -56
  533. package/src/plugins/defaults/advisor/__tests__/advisor-state-store.test.ts +0 -43
  534. package/src/plugins/defaults/advisor/__tests__/agent-loop-integration.test.ts +0 -137
  535. package/src/plugins/defaults/advisor/__tests__/consult.test.ts +0 -153
  536. package/src/plugins/defaults/advisor/__tests__/hooks.test.ts +0 -138
  537. package/src/plugins/defaults/advisor/advisor-gate.ts +0 -29
  538. package/src/plugins/defaults/advisor/advisor-state-store.ts +0 -94
  539. package/src/plugins/defaults/advisor/config.ts +0 -21
  540. package/src/plugins/defaults/advisor/consult.ts +0 -93
  541. package/src/plugins/defaults/advisor/hooks/post-model-call.ts +0 -34
  542. package/src/plugins/defaults/advisor/hooks/pre-model-call.ts +0 -30
  543. package/src/plugins/defaults/advisor/hooks/user-prompt-submit.ts +0 -19
  544. package/src/plugins/defaults/advisor/package.json +0 -14
  545. package/src/plugins/defaults/advisor/tools/advisor.ts +0 -65
  546. package/src/providers/openai/__tests__/api-error-detail.test.ts +0 -120
@@ -0,0 +1,143 @@
1
+ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import {
4
+ afterAll,
5
+ afterEach,
6
+ beforeEach,
7
+ describe,
8
+ expect,
9
+ mock,
10
+ test,
11
+ } from "bun:test";
12
+
13
+ const WORKSPACE_DIR = process.env.VELLUM_WORKSPACE_DIR!;
14
+ const CONFIG_PATH = join(WORKSPACE_DIR, "config.json");
15
+
16
+ function ensureTestDir(): void {
17
+ const dirs = [
18
+ WORKSPACE_DIR,
19
+ join(WORKSPACE_DIR, "data"),
20
+ join(WORKSPACE_DIR, "data", "memory"),
21
+ join(WORKSPACE_DIR, "data", "logs"),
22
+ ];
23
+ for (const dir of dirs) {
24
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
25
+ }
26
+ }
27
+
28
+ function makeLoggerStub(): Record<string, unknown> {
29
+ const stub: Record<string, unknown> = {};
30
+ for (const m of [
31
+ "info",
32
+ "warn",
33
+ "error",
34
+ "debug",
35
+ "trace",
36
+ "fatal",
37
+ "silent",
38
+ "child",
39
+ ]) {
40
+ stub[m] = m === "child" ? () => makeLoggerStub() : () => {};
41
+ }
42
+ return stub;
43
+ }
44
+
45
+ mock.module("../../util/logger.js", () => ({
46
+ getLogger: () => makeLoggerStub(),
47
+ }));
48
+
49
+ afterAll(() => {
50
+ mock.restore();
51
+ });
52
+
53
+ import { resolveCallSiteConfig } from "../llm-resolver.js";
54
+ import { invalidateConfigCache, loadConfig } from "../loader.js";
55
+
56
+ function writeConfig(obj: unknown): void {
57
+ writeFileSync(CONFIG_PATH, JSON.stringify(obj, null, 2) + "\n");
58
+ }
59
+
60
+ /**
61
+ * Base config where the active profile resolves to a DIFFERENT model than the
62
+ * `balanced` profile that the shipped `memoryV3SelectL2` call-site default
63
+ * points at. This lets each test distinguish the two failure modes:
64
+ * - call-site default applied (fixed) -> model "balanced-model"
65
+ * - silently downgraded to active -> model "active-model"
66
+ */
67
+ function baseLlm(callSites: Record<string, unknown>): unknown {
68
+ return {
69
+ llm: {
70
+ default: { provider: "anthropic", model: "default-model" },
71
+ profiles: {
72
+ balanced: { provider: "anthropic", model: "balanced-model" },
73
+ speedy: { provider: "anthropic", model: "active-model" },
74
+ },
75
+ activeProfile: "speedy",
76
+ callSites,
77
+ },
78
+ };
79
+ }
80
+
81
+ describe("config recovery prunes call-site overrides emptied by a strip", () => {
82
+ beforeEach(() => {
83
+ ensureTestDir();
84
+ if (existsSync(CONFIG_PATH)) rmSync(CONFIG_PATH, { force: true });
85
+ delete process.env.IS_PLATFORM;
86
+ invalidateConfigCache();
87
+ });
88
+
89
+ afterEach(() => {
90
+ delete process.env.IS_PLATFORM;
91
+ if (existsSync(CONFIG_PATH)) rmSync(CONFIG_PATH, { force: true });
92
+ invalidateConfigCache();
93
+ });
94
+
95
+ test("an undefined call-site profile ref falls back to the shipped default, not the active profile", () => {
96
+ // The `.profile` ref is invalid (no such profile), so schema recovery
97
+ // strips it. Before the fix this left `callSites.memoryV3SelectL2 = {}`,
98
+ // which the resolver treats as a present override and so skips the shipped
99
+ // `{profile:"balanced"}` default — silently resolving to the active profile.
100
+ writeConfig(baseLlm({ memoryV3SelectL2: { profile: "ghost-profile" } }));
101
+
102
+ const config = loadConfig();
103
+
104
+ // The emptied call-site entry must be pruned entirely, not left as `{}`.
105
+ expect(config.llm.callSites?.memoryV3SelectL2).toBeUndefined();
106
+
107
+ // Resolution now lands on the shipped call-site default (balanced), not the
108
+ // active profile ("active-model"), which is what the bug produced.
109
+ const resolved = resolveCallSiteConfig("memoryV3SelectL2", config.llm);
110
+ expect(resolved.model).toBe("balanced-model");
111
+ });
112
+
113
+ test("a valid sibling call-site override survives while the invalid one is pruned", () => {
114
+ // memoryRouter -> balanced is valid and must be preserved; only the invalid
115
+ // memoryV3SelectL2 entry is pruned. Guards against over-pruning the parent.
116
+ writeConfig(
117
+ baseLlm({
118
+ memoryV3SelectL2: { profile: "missing" },
119
+ memoryRouter: { profile: "balanced" },
120
+ }),
121
+ );
122
+
123
+ const config = loadConfig();
124
+
125
+ expect(config.llm.callSites?.memoryV3SelectL2).toBeUndefined();
126
+ expect(config.llm.callSites?.memoryRouter).toEqual({ profile: "balanced" });
127
+ });
128
+
129
+ test("a partial override keeping other fields is not pruned", () => {
130
+ // Stripping the invalid `.profile` leaves a non-empty `{temperature:0.5}`,
131
+ // a legitimate user override the resolver should keep (and which therefore
132
+ // still shadows the shipped default per existing either/or semantics).
133
+ writeConfig(
134
+ baseLlm({ memoryV3SelectL2: { profile: "missing", temperature: 0.5 } }),
135
+ );
136
+
137
+ const config = loadConfig();
138
+
139
+ expect(config.llm.callSites?.memoryV3SelectL2).toEqual({
140
+ temperature: 0.5,
141
+ });
142
+ });
143
+ });
@@ -109,10 +109,13 @@ describe("reconcileFlagGatedProfiles", () => {
109
109
 
110
110
  const raw = readConfig();
111
111
  const osBeta = raw.llm.profiles["os-beta"]!;
112
- expect(osBeta.model).toBe("accounts/fireworks/models/glm-5p2");
113
- expect(osBeta.provider_connection).toBe("fireworks-managed");
112
+ expect(osBeta.model).toBe("MiniMaxAI/MiniMax-M3");
113
+ expect(osBeta.provider_connection).toBe("together-managed");
114
+ expect(osBeta.provider).toBe("together");
114
115
  expect(osBeta.source).toBe("managed");
115
116
  expect(osBeta.label).toBe("OS Beta");
117
+ expect(osBeta.effort).toBe("low");
118
+ expect(osBeta.topP).toBe(0.95);
116
119
 
117
120
  const order = raw.llm.profileOrder;
118
121
  expect(order.indexOf("os-beta")).toBe(order.indexOf("balanced") + 1);
@@ -128,6 +131,7 @@ describe("reconcileFlagGatedProfiles", () => {
128
131
  expect(osBeta.status).toBe("disabled");
129
132
  expect(osBeta.label).toBe("OS Beta (Managed)");
130
133
  expect(osBeta.source).toBe("managed");
134
+ expect(osBeta.effort).toBe("low");
131
135
  });
132
136
 
133
137
  test("flag on is idempotent across repeated runs", () => {
@@ -149,7 +153,7 @@ describe("reconcileFlagGatedProfiles", () => {
149
153
  const raw = readConfig();
150
154
  raw.llm.profiles["os-beta"]!.label = "My OS Beta";
151
155
  raw.llm.profiles["os-beta"]!.status = "disabled";
152
- raw.llm.profiles["os-beta"]!.advisorEnabled = true;
156
+ raw.llm.profiles["os-beta"]!.topP = 0.8;
153
157
  writeConfig(raw);
154
158
  invalidateConfigCache();
155
159
 
@@ -158,8 +162,10 @@ describe("reconcileFlagGatedProfiles", () => {
158
162
  const after = readConfig().llm.profiles["os-beta"]!;
159
163
  expect(after.label).toBe("My OS Beta");
160
164
  expect(after.status).toBe("disabled");
161
- expect(after.advisorEnabled).toBe(true);
162
- expect(after.model).toBe("accounts/fireworks/models/glm-5p2");
165
+ expect(after.topP).toBe(0.8);
166
+ expect(after.model).toBe("MiniMaxAI/MiniMax-M3");
167
+ expect(after.provider_connection).toBe("together-managed");
168
+ expect(after.effort).toBe("low");
163
169
  });
164
170
 
165
171
  test("flag off removes a managed os-beta and applies fallbacks", () => {
@@ -316,7 +322,7 @@ describe("reconcileFlagGatedProfiles", () => {
316
322
 
317
323
  const raw = readConfig();
318
324
  (raw.llm as Record<string, unknown>).callSites = {
319
- advisor: { profile: "os-beta", temperature: 0.3 },
325
+ inference: { profile: "os-beta", temperature: 0.3 },
320
326
  };
321
327
  writeConfig(raw);
322
328
  invalidateConfigCache();
@@ -325,14 +331,14 @@ describe("reconcileFlagGatedProfiles", () => {
325
331
  expect(reconcileFlagGatedProfiles()).toBe(true);
326
332
 
327
333
  const after = readConfig();
328
- const advisor = (
334
+ const inference = (
329
335
  after.llm as unknown as Record<
330
336
  string,
331
337
  Record<string, Record<string, unknown>>
332
338
  >
333
- ).callSites.advisor;
334
- expect(advisor.profile).toBeUndefined();
335
- expect(advisor.temperature).toBe(0.3);
339
+ ).callSites.inference;
340
+ expect(inference.profile).toBeUndefined();
341
+ expect(inference.temperature).toBe(0.3);
336
342
 
337
343
  expect(LLMSchema.safeParse(after.llm).success).toBe(true);
338
344
  });
@@ -1,4 +1,5 @@
1
- import type { ContactWithChannels } from "../../../../contacts/types.js";
1
+ import type { ContactRead } from "@vellumai/gateway-client/gateway-ipc-contracts";
2
+
2
3
  import { cliIpcCall } from "../../../../ipc/cli-client.js";
3
4
  import { resolveGuardianName } from "../../../../prompts/user-reference.js";
4
5
  import type {
@@ -6,6 +7,12 @@ import type {
6
7
  ToolExecutionResult,
7
8
  } from "../../../../tools/types.js";
8
9
 
10
+ function guardianAwareName(contact: Pick<ContactRead, "role" | "displayName">) {
11
+ return contact.role === "guardian"
12
+ ? resolveGuardianName(contact.displayName)
13
+ : contact.displayName;
14
+ }
15
+
9
16
  export async function executeContactMerge(
10
17
  input: Record<string, unknown>,
11
18
  _context: ToolContext,
@@ -22,10 +29,10 @@ export async function executeContactMerge(
22
29
 
23
30
  // Validate both contacts exist before merging
24
31
  const [keepRes, mergeRes] = await Promise.all([
25
- cliIpcCall<{ contact: ContactWithChannels }>("getContact", {
32
+ cliIpcCall<{ contact: ContactRead }>("getContact", {
26
33
  pathParams: { id: keepId },
27
34
  }),
28
- cliIpcCall<{ contact: ContactWithChannels }>("getContact", {
35
+ cliIpcCall<{ contact: ContactRead }>("getContact", {
29
36
  pathParams: { id: mergeId },
30
37
  }),
31
38
  ]);
@@ -42,7 +49,7 @@ export async function executeContactMerge(
42
49
 
43
50
  const mergeResult = await cliIpcCall<{
44
51
  ok: boolean;
45
- contact: ContactWithChannels;
52
+ contact: ContactRead;
46
53
  }>("merge_contacts", {
47
54
  body: { keepId, mergeId },
48
55
  });
@@ -51,19 +58,22 @@ export async function executeContactMerge(
51
58
  return { content: `Error: ${mergeResult.error}`, isError: true };
52
59
  }
53
60
 
54
- const merged = mergeResult.result!.contact;
55
- const displayName =
56
- merged.role === "guardian"
57
- ? resolveGuardianName(merged.displayName)
58
- : merged.displayName;
59
- const keepName =
60
- keepContact.role === "guardian"
61
- ? resolveGuardianName(keepContact.displayName)
62
- : keepContact.displayName;
63
- const mergeName =
64
- mergeContact.role === "guardian"
65
- ? resolveGuardianName(mergeContact.displayName)
66
- : mergeContact.displayName;
61
+ const mergedId = mergeResult.result!.contact.id;
62
+
63
+ // Re-read the surviving contact through the gateway-relayed read so role and
64
+ // interactionCount come from the gateway ContactRead.
65
+ const mergedRes = await cliIpcCall<{ contact: ContactRead }>("getContact", {
66
+ pathParams: { id: mergedId },
67
+ });
68
+
69
+ if (!mergedRes.ok) {
70
+ return { content: `Error: ${mergedRes.error}`, isError: true };
71
+ }
72
+
73
+ const merged = mergedRes.result!.contact;
74
+ const displayName = guardianAwareName(merged);
75
+ const keepName = guardianAwareName(keepContact);
76
+ const mergeName = guardianAwareName(mergeContact);
67
77
 
68
78
  const channelList = merged.channels
69
79
  .map(
@@ -1,4 +1,5 @@
1
- import type { ContactWithChannels } from "../../../../contacts/types.js";
1
+ import type { ContactRead } from "@vellumai/gateway-client/gateway-ipc-contracts";
2
+
2
3
  import { cliIpcCall } from "../../../../ipc/cli-client.js";
3
4
  import { resolveGuardianName } from "../../../../prompts/user-reference.js";
4
5
  import type {
@@ -6,7 +7,16 @@ import type {
6
7
  ToolExecutionResult,
7
8
  } from "../../../../tools/types.js";
8
9
 
9
- function formatContactSummary(c: ContactWithChannels): string {
10
+ // The search route may carry an optional per-channel `externalChatId` not modeled
11
+ // on the gateway `ContactRead` channel contract.
12
+ type SearchChannel = ContactRead["channels"][number] & {
13
+ externalChatId?: string | null;
14
+ };
15
+ type SearchContact = Omit<ContactRead, "channels"> & {
16
+ channels: SearchChannel[];
17
+ };
18
+
19
+ function formatContactSummary(c: SearchContact): string {
10
20
  const displayName =
11
21
  c.role === "guardian" ? resolveGuardianName(c.displayName) : c.displayName;
12
22
  const parts = [`- **${displayName}** (ID: ${c.id})`];
@@ -45,7 +55,7 @@ export async function executeContactSearch(
45
55
  };
46
56
  }
47
57
 
48
- const res = await cliIpcCall<ContactWithChannels[]>("search_contacts", {
58
+ const res = await cliIpcCall<SearchContact[]>("search_contacts", {
49
59
  body: { query, channelAddress, channelType, limit },
50
60
  });
51
61
 
@@ -39,10 +39,25 @@ Each subagent is spawned with a role that determines its tool access. Choose the
39
39
  | `researcher` | `web_search`, `web_fetch`, `file_read`, `file_list`, `recall`, `notify_parent` | Information gathering, web research, codebase exploration, reading documentation |
40
40
  | `coder` | `bash`, `file_read`, `file_write`, `file_edit`, `web_search`, `recall`, `notify_parent` | Code changes, file editing, running commands, build/test tasks |
41
41
  | `planner` | `file_read`, `file_list`, `web_search`, `web_fetch`, `recall`, `notify_parent` | Analysis, planning, synthesizing information, reviewing approaches |
42
- | `investigator` | `bash`, `file_read`, `file_list`, `web_search`, `web_fetch`, `recall`, `notify_parent` | Root-cause analysis: debugging, log forensics, tracing behavior across many files. Shell access is for read-only investigation (grep/find/reading logs); returns a compact root-cause report |
42
+ | `investigator` | `code_search`, `file_read`, `file_list`, `web_search`, `web_fetch`, `recall`, `notify_parent` | Root-cause analysis: debugging, log forensics, tracing behavior across many files. Read-only search/read tools only (no shell): use `code_search` to grep file contents across directories, `file_list` to enumerate paths, `file_read` to read whole files and logs; returns a compact root-cause report |
43
+ | `advisor` | None (tool-less) | Read-only senior-advisor consult. Runs on a stronger model, inherits full parent context, and BLOCKS until it returns guidance |
43
44
 
44
45
  All specialized roles (`researcher`, `coder`, `planner`) include `notify_parent` for mid-run communication with the parent.
45
46
 
47
+ ## Consulting the Advisor
48
+
49
+ The `advisor` role is the one role you spawn on your own judgment, unprompted — you do NOT wait for the user to ask for a subagent. The other roles (`researcher`, `coder`, `planner`, `investigator`, `general`) stay delegation-driven: reach for them to offload work, typically when the user's request calls for it. The advisor is different: proactively consult it whenever the conditions below are met.
50
+
51
+ Orient yourself first (read the relevant files, understand the task), then consult the advisor:
52
+
53
+ - **Before you commit to an approach and start building** — to shape a plan when you don't have one, or to pressure-test and sharpen a plan you've already drafted.
54
+ - **When you get stuck or are weighing a change in direction.**
55
+ - **Once before you declare the task done.**
56
+
57
+ The consult is synchronous and read-only: spawning an `advisor` subagent BLOCKS until it returns guidance. It runs on a stronger model and inherits your full context, so it sees the task, your tool calls, and their results without you re-explaining. Give its guidance serious weight; only override it when primary-source evidence contradicts a specific claim — and say so when you do.
58
+
59
+ Spawn the advisor **alone** — do NOT batch the consult in the same turn as other tool calls (especially file edits, shell commands, or anything destructive or expensive). Tool calls you issue in the same turn run concurrently with the consult, so they would execute before you see its guidance. Consult the advisor by itself, read its guidance, then act.
60
+
46
61
  ## Parent Communication
47
62
 
48
63
  Subagents use `notify_parent` to send messages to the parent conversation while still running. Each notification has an urgency level:
@@ -79,7 +94,7 @@ Set `inference_profile` to an `llm.profiles` key when a subagent should run unde
79
94
 
80
95
  Forks are sub-agents that inherit the parent's full context -- messages, system prompt, and memory -- sharing the KV cache for near-free context inheritance. Use forks when the task benefits from knowing what you've been discussing; use a regular sub-agent when the task is self-contained.
81
96
 
82
- **Key behaviors:** Forks always run as `general` role (the `role` parameter is ignored). `send_result_to_user` defaults to `false`. Read fork output with `last_n: 1` to get only the final synthesis.
97
+ **Key behaviors:** Forks default to `general` role (the `role` parameter is ignored for forks), except the special `advisor` role, which is honored even as a fork. `send_result_to_user` defaults to `false`. Read fork output with `last_n: 1` to get only the final synthesis.
83
98
 
84
99
  **When to fork vs regular sub-agent:**
85
100
 
@@ -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. Always runs as general role. 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.",
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.",
7
7
  "category": "orchestration",
8
8
  "risk": "low",
9
9
  "input_schema": {
@@ -23,7 +23,7 @@
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 always runs as 'general' role (the role parameter is ignored) 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. 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."
27
27
  },
28
28
  "send_result_to_user": {
29
29
  "type": "boolean",
@@ -36,9 +36,10 @@
36
36
  "researcher",
37
37
  "coder",
38
38
  "planner",
39
- "investigator"
39
+ "investigator",
40
+ "advisor"
40
41
  ],
41
- "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; has bash for read-only investigation (grep/find/log inspection) and returns a compact root-cause report. 'general': full access (default). Ignored when fork: true (forks always use general)."
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). Non-advisor roles are ignored when fork: true (forks default to general); the advisor role is honored even as a fork."
42
43
  },
43
44
  "inference_profile": {
44
45
  "type": "string",
@@ -69,12 +69,6 @@ export const CALL_SITE_DEFAULTS: Record<LLMCallSite, CallSiteDefaultConfig> = {
69
69
  meetConsentMonitor: { profile: "cost-optimized" },
70
70
  meetChatOpportunity: { profile: "cost-optimized" },
71
71
  inference: { profile: "cost-optimized" },
72
- // The advisor consults the strongest managed profile (`frontier`, Opus),
73
- // which seeding writes into `llm.advisorProfile` on boot and floats above this
74
- // layer. This static fallback — used only when no `advisorProfile` resolves —
75
- // stays on the always-reserved `quality-optimized` so it can never resolve to
76
- // a user-owned profile that happens to be named `frontier`.
77
- advisor: { profile: "quality-optimized" },
78
72
  // Vision captioning for the image-fallback plugin. No pinned profile — the
79
73
  // plugin resolves a vision-capable profile itself via `doesSupportVision` and
80
74
  // passes it as an `overrideProfile`, so the call-site default is a fallback
@@ -66,14 +66,6 @@
66
66
  "description": "Gate per-turn conversation trace (user/assistant/tool-call/tool-response) collection. The daemon attaches a trace to its turn telemetry only when this flag AND the owner's share_diagnostics consent are both on. Defaults off (fail-closed) — the live value is delivered from LaunchDarkly.",
67
67
  "defaultEnabled": false
68
68
  },
69
- {
70
- "id": "workspace-tools-watcher",
71
- "scope": "assistant",
72
- "key": "workspace-tools-watcher",
73
- "label": "Workspace tools file watcher",
74
- "description": "Hot-reload workspace tool overrides under `<workspaceDir>/tools/` by watching the directory and re-registering tools as files change. When disabled, workspace tools still load from disk once at daemon startup, but live edits require a restart to take effect.",
75
- "defaultEnabled": false
76
- },
77
69
  {
78
70
  "id": "settings-developer-nav",
79
71
  "scope": "assistant",
@@ -411,11 +403,11 @@
411
403
  "defaultEnabled": false
412
404
  },
413
405
  {
414
- "id": "mcp-settings",
406
+ "id": "mcp-add-server",
415
407
  "scope": "assistant",
416
- "key": "mcp-settings",
417
- "label": "MCP Settings",
418
- "description": "Show the MCP page in Settings for managing Model Context Protocol server connections: view status, enable/disable, configure, and inspect registered tools per server.",
408
+ "key": "mcp-add-server",
409
+ "label": "MCP Add Server",
410
+ "description": "Show the Add Server action on the MCP settings page. The MCP page itself remains visible; this flag gates only creating new Model Context Protocol server connections.",
419
411
  "defaultEnabled": false
420
412
  },
421
413
  {
@@ -423,7 +415,7 @@
423
415
  "scope": "assistant",
424
416
  "key": "os-beta",
425
417
  "label": "OS Beta",
426
- "description": "Enable the OS Beta model profile (GLM 5.2 / Fireworks) in the assistant's model profile selection.",
418
+ "description": "Enable the OS Beta model profile (MiniMax M3 / Together) in the assistant's model profile selection.",
427
419
  "defaultEnabled": false
428
420
  }
429
421
  ]
@@ -497,9 +497,6 @@ function profileConfigFragment(profile: ProfileEntry): Mergeable {
497
497
  // lower-precedence (e.g. active) profile into one that merely inherited it.
498
498
  // `RetryProvider` resolves it from the applied profile, not the merge.
499
499
  logitBias: _logitBias,
500
- // Per-profile advisor toggle is profile identity, not inheritable model
501
- // config — strip it so it can't leak into the merged `LLMConfigBase`.
502
- advisorEnabled: _advisorEnabled,
503
500
  // `temperature`/`top_p` are provider-coupled: only the winning profile
504
501
  // contributes them (tracked via `samplingRef`, applied post-merge), so a
505
502
  // shadowed profile's sampling can never reach a different provider through
@@ -14,6 +14,7 @@ import {
14
14
  getConfigQuarantineNoticePath,
15
15
  getWorkspaceConfigPath,
16
16
  } from "../util/platform.js";
17
+ import { pruneSeededCallsiteDefaultsFromConfig } from "./prune-seeded-callsite-defaults.js";
17
18
  import { AssistantConfigSchema } from "./schema.js";
18
19
  import type { AssistantConfig } from "./types.js";
19
20
 
@@ -300,14 +301,20 @@ function validateWithSchema(raw: Record<string, unknown>): AssistantConfig {
300
301
  }
301
302
 
302
303
  // Strip invalid fields by setting them to undefined so Zod defaults apply,
303
- // then re-parse. We walk the error paths and delete the offending keys.
304
+ // then re-parse. We walk the error paths and delete the offending keys,
305
+ // pruning any ancestor object the deletion leaves empty. Pruning matters for
306
+ // nested overrides like `llm.callSites.<id>.profile`: stripping just the
307
+ // invalid `.profile` leaf would leave `llm.callSites.<id> = {}`, which the
308
+ // resolver treats as a present (non-default) override and so skips the
309
+ // shipped call-site default — silently downgrading the call site to the
310
+ // active profile. Removing the emptied object lets that default apply.
304
311
  const cleaned = structuredClone(raw);
305
312
  for (const issue of result.error.issues) {
306
313
  if (issue.path.length === 0) {
307
314
  // Top-level error — return full defaults
308
315
  return cloneDefaultConfig();
309
316
  }
310
- deleteNestedKey(cleaned, issue.path as (string | number)[]);
317
+ deleteNestedKey(cleaned, issue.path as (string | number)[], true);
311
318
  }
312
319
 
313
320
  const retry = AssistantConfigSchema.safeParse(cleaned);
@@ -320,17 +327,42 @@ function validateWithSchema(raw: Record<string, unknown>): AssistantConfig {
320
327
  return cloneDefaultConfig();
321
328
  }
322
329
 
330
+ /**
331
+ * Delete the key at `path` from `obj`. When `pruneEmptyAncestors` is set, also
332
+ * remove any ancestor object the deletion leaves empty, walking up until the
333
+ * first ancestor that still holds other keys. Only empty plain objects are
334
+ * pruned (arrays are left alone), and a still-populated ancestor stops the walk
335
+ * so a container holding other config is never removed.
336
+ */
323
337
  function deleteNestedKey(
324
338
  obj: Record<string, unknown>,
325
339
  path: (string | number)[],
340
+ pruneEmptyAncestors = false,
326
341
  ): void {
342
+ // Record each (container, key) hop on the way down so we can prune upward
343
+ // after deleting the leaf.
344
+ const chain: Array<{ container: Record<string, unknown>; key: string }> = [];
327
345
  let current: unknown = obj;
328
346
  for (let i = 0; i < path.length - 1; i++) {
329
347
  if (current == null || typeof current !== "object") return;
330
- current = (current as Record<string, unknown>)[String(path[i])];
348
+ const key = String(path[i]);
349
+ chain.push({ container: current as Record<string, unknown>, key });
350
+ current = (current as Record<string, unknown>)[key];
331
351
  }
332
- if (current != null && typeof current === "object") {
333
- delete (current as Record<string, unknown>)[String(path[path.length - 1])];
352
+ if (current == null || typeof current !== "object") return;
353
+ delete (current as Record<string, unknown>)[String(path[path.length - 1])];
354
+
355
+ if (!pruneEmptyAncestors) return;
356
+ // Remove ancestors emptied by the deletion, deepest first; stop at the first
357
+ // that still has keys.
358
+ for (let i = chain.length - 1; i >= 0; i--) {
359
+ const { container, key } = chain[i];
360
+ const child = container[key];
361
+ if (isPlainObject(child) && Object.keys(child).length === 0) {
362
+ delete container[key];
363
+ } else {
364
+ break;
365
+ }
334
366
  }
335
367
  }
336
368
 
@@ -598,6 +630,7 @@ export function mergeDefaultWorkspaceConfig(): DefaultWorkspaceConfigMergeResult
598
630
  }
599
631
 
600
632
  deepMergeOverwrite(existing, defaults as Record<string, unknown>);
633
+ pruneSeededCallsiteDefaultsFromConfig(existing);
601
634
 
602
635
  const dir = dirname(configPath);
603
636
  if (!existsSync(dir)) {
@@ -0,0 +1,110 @@
1
+ // Exact system-owned default materializations. These are resolved through
2
+ // shipped call-site defaults rather than persisted as user overrides.
3
+ const SEEDED_CALL_SITES: Record<string, Record<string, unknown>> = {
4
+ guardianQuestionCopy: latencySeed(),
5
+ interactionClassifier: latencySeed(),
6
+ skillCategoryInference: latencySeed(),
7
+ inviteInstructionGenerator: latencySeed(),
8
+ notificationDecision: latencySeed(),
9
+ preferenceExtraction: latencySeed(),
10
+ commitMessage: {
11
+ model: "claude-haiku-4-5-20251001",
12
+ maxTokens: 120,
13
+ temperature: 0.2,
14
+ effort: "low",
15
+ thinking: { enabled: false },
16
+ },
17
+ conversationStarters: latencySeed(),
18
+ conversationSummarization: {
19
+ model: "claude-opus-4-7",
20
+ effort: "low",
21
+ thinking: { enabled: false },
22
+ },
23
+ recall: {
24
+ profile: "cost-optimized",
25
+ maxTokens: 4096,
26
+ effort: "low",
27
+ thinking: { enabled: false, streamThinking: false },
28
+ temperature: 0,
29
+ disableCache: true,
30
+ },
31
+ heartbeatAgent: {
32
+ profile: "cost-optimized",
33
+ maxTokens: 2048,
34
+ effort: "low",
35
+ temperature: 0,
36
+ thinking: { enabled: false, streamThinking: false },
37
+ contextWindow: { maxInputTokens: 16000 },
38
+ },
39
+ replySuggestion: {
40
+ model: "claude-haiku-4-5-20251001",
41
+ effort: "low",
42
+ thinking: { enabled: false },
43
+ disableCache: true,
44
+ },
45
+ memoryRouter: {
46
+ profile: "cost-optimized",
47
+ contextWindow: { maxInputTokens: 1_000_000 },
48
+ },
49
+ };
50
+
51
+ export function pruneSeededCallsiteDefaultsFromConfig(
52
+ config: Record<string, unknown>,
53
+ ): boolean {
54
+ const llm = readObject(config.llm);
55
+ if (llm === null) return false;
56
+
57
+ const callSites = readObject(llm.callSites);
58
+ if (callSites === null) return false;
59
+
60
+ let changed = false;
61
+ for (const [callSite, seed] of Object.entries(SEEDED_CALL_SITES)) {
62
+ if (deepEqual(callSites[callSite], seed)) {
63
+ delete callSites[callSite];
64
+ changed = true;
65
+ }
66
+ }
67
+ if (!changed) return false;
68
+
69
+ if (Object.keys(callSites).length === 0) {
70
+ delete llm.callSites;
71
+ } else {
72
+ llm.callSites = callSites;
73
+ }
74
+ config.llm = llm;
75
+ return true;
76
+ }
77
+
78
+ function latencySeed(): Record<string, unknown> {
79
+ return {
80
+ model: "claude-haiku-4-5-20251001",
81
+ effort: "low",
82
+ thinking: { enabled: false },
83
+ };
84
+ }
85
+
86
+ function readObject(value: unknown): Record<string, unknown> | null {
87
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
88
+ return null;
89
+ }
90
+ return value as Record<string, unknown>;
91
+ }
92
+
93
+ function deepEqual(a: unknown, b: unknown): boolean {
94
+ if (a === b) return true;
95
+ if (a === null || b === null) return false;
96
+ if (typeof a !== "object" || typeof b !== "object") return false;
97
+ if (Array.isArray(a) || Array.isArray(b)) return false;
98
+
99
+ const aRecord = a as Record<string, unknown>;
100
+ const bRecord = b as Record<string, unknown>;
101
+ const aKeys = Object.keys(aRecord);
102
+ const bKeys = Object.keys(bRecord);
103
+ if (aKeys.length !== bKeys.length) return false;
104
+
105
+ for (const key of aKeys) {
106
+ if (!Object.prototype.hasOwnProperty.call(bRecord, key)) return false;
107
+ if (!deepEqual(aRecord[key], bRecord[key])) return false;
108
+ }
109
+ return true;
110
+ }