@vellumai/assistant 0.10.7-dev.202607100313.fffdfea → 0.10.7-dev.202607100720.fba456e

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 (99) hide show
  1. package/openapi.yaml +846 -27
  2. package/package.json +1 -1
  3. package/src/__tests__/config-watcher-skill-reseed.test.ts +1 -0
  4. package/src/__tests__/config-watcher.test.ts +22 -4
  5. package/src/__tests__/credential-security-invariants.test.ts +1 -1
  6. package/src/__tests__/plugin-import-boundary-guard.test.ts +6 -9
  7. package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +0 -2
  8. package/src/cli/commands/__tests__/inference-models.test.ts +86 -0
  9. package/src/cli/commands/__tests__/inference-profiles.test.ts +254 -0
  10. package/src/cli/commands/__tests__/inference-providers.test.ts +171 -0
  11. package/src/cli/commands/__tests__/schedules.test.ts +133 -1
  12. package/src/cli/commands/__tests__/usage.test.ts +131 -0
  13. package/src/cli/commands/inference-callsites.ts +158 -0
  14. package/src/cli/commands/inference-models.ts +84 -0
  15. package/src/cli/commands/inference-profiles.ts +371 -0
  16. package/src/cli/commands/inference-providers-default.ts +89 -0
  17. package/src/cli/commands/inference-providers.ts +87 -16
  18. package/src/cli/commands/inference.ts +6 -0
  19. package/src/cli/commands/memory/nodes.ts +90 -50
  20. package/src/cli/commands/schedules.ts +17 -2
  21. package/src/cli/commands/usage.ts +59 -21
  22. package/src/cli/lib/__tests__/cli-output.test.ts +20 -0
  23. package/src/cli/lib/cli-output.ts +55 -0
  24. package/src/config/__tests__/loader-last-known-good.test.ts +229 -0
  25. package/src/config/__tests__/loader-sparse-array-cleanup.test.ts +166 -0
  26. package/src/config/default-profile-catalog.ts +28 -0
  27. package/src/config/loader.ts +276 -46
  28. package/src/daemon/config-watcher.ts +65 -20
  29. package/src/daemon/message-types/sync.ts +1 -0
  30. package/src/oauth/byo-connection.test.ts +1 -1
  31. package/src/oauth/connection-resolver.test.ts +140 -0
  32. package/src/oauth/connection-resolver.ts +48 -12
  33. package/src/plugins/defaults/memory/anisotropy.ts +1 -1
  34. package/src/plugins/defaults/memory/config.ts +1 -1
  35. package/src/plugins/defaults/memory/context-search/agent-protocol.ts +1 -1
  36. package/src/plugins/defaults/memory/context-search/search.ts +1 -1
  37. package/src/plugins/defaults/memory/graph/bootstrap.ts +1 -1
  38. package/src/plugins/defaults/memory/graph/consolidation.ts +1 -1
  39. package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +11 -1
  40. package/src/plugins/defaults/memory/graph/extraction.ts +1 -1
  41. package/src/plugins/defaults/memory/graph/narrative.ts +1 -1
  42. package/src/plugins/defaults/memory/graph/pattern-scan.ts +1 -1
  43. package/src/plugins/defaults/memory/graph/tool-handlers.ts +1 -1
  44. package/src/plugins/defaults/memory/graph/tools.ts +1 -1
  45. package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +43 -16
  46. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +1 -1
  47. package/src/plugins/defaults/memory/host-utils.ts +80 -0
  48. package/src/plugins/defaults/memory/identity-context.ts +1 -1
  49. package/src/plugins/defaults/memory/injectors.ts +1 -1
  50. package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +2 -2
  51. package/src/plugins/defaults/memory/jobs-worker.ts +2 -9
  52. package/src/plugins/defaults/memory/memory-retrospective-state.ts +1 -1
  53. package/src/plugins/defaults/memory/paths.ts +48 -0
  54. package/src/plugins/defaults/memory/pkb/autoinject.ts +1 -1
  55. package/src/plugins/defaults/memory/pkb/context.ts +2 -2
  56. package/src/plugins/defaults/memory/pkb/types.ts +1 -1
  57. package/src/plugins/defaults/memory/pkb-schedule.ts +2 -2
  58. package/src/plugins/defaults/memory/rerank-local.ts +2 -3
  59. package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +1 -1
  60. package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +149 -1
  61. package/src/plugins/defaults/memory/routes/memory-item-routes.ts +144 -1
  62. package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +1 -1
  63. package/src/plugins/defaults/memory/startup.ts +1 -1
  64. package/src/plugins/defaults/memory/v2/backfill-jobs.ts +1 -1
  65. package/src/plugins/defaults/memory/v2/consolidation-job.ts +2 -2
  66. package/src/plugins/defaults/memory/v2/injection.ts +1 -1
  67. package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +1 -1
  68. package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +1 -1
  69. package/src/plugins/defaults/memory/v2/qdrant.ts +1 -1
  70. package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
  71. package/src/plugins/defaults/memory/v2/static-context.ts +1 -1
  72. package/src/plugins/defaults/memory/v2/sweep-job.ts +1 -1
  73. package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
  74. package/src/plugins/defaults/memory/v3/maintain-job.ts +1 -1
  75. package/src/plugins/defaults/memory/v3/page-content.ts +1 -1
  76. package/src/plugins/defaults/memory/v3/pool-select.ts +1 -2
  77. package/src/plugins/defaults/memory/v3/selection-log-store.ts +1 -1
  78. package/src/plugins/defaults/memory/v3/shadow-plugin.ts +2 -5
  79. package/src/plugins/defaults/memory/worker.ts +1 -1
  80. package/src/plugins/defaults/workspace/injectors.ts +17 -15
  81. package/src/plugins/types.ts +9 -14
  82. package/src/providers/inference/connection-availability.ts +193 -0
  83. package/src/runtime/routes/__tests__/inference-callsites-routes.test.ts +54 -0
  84. package/src/runtime/routes/__tests__/inference-models-routes.test.ts +54 -0
  85. package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +405 -0
  86. package/src/runtime/routes/__tests__/inference-routes-registration.test.ts +42 -0
  87. package/src/runtime/routes/__tests__/theme-routes.test.ts +66 -0
  88. package/src/runtime/routes/conversation-query-routes.ts +5 -3
  89. package/src/runtime/routes/default-provider-routes.ts +5 -152
  90. package/src/runtime/routes/index.ts +8 -0
  91. package/src/runtime/routes/inference-callsites-routes.ts +211 -0
  92. package/src/runtime/routes/inference-models-routes.ts +104 -0
  93. package/src/runtime/routes/inference-profiles-routes.ts +717 -0
  94. package/src/runtime/routes/theme-routes.ts +36 -0
  95. package/src/runtime/sync/resource-sync-events.ts +4 -0
  96. package/src/theme/workspace-theme.test.ts +269 -0
  97. package/src/theme/workspace-theme.ts +304 -0
  98. package/src/watcher/__tests__/engine-auth-notify.test.ts +316 -0
  99. package/src/watcher/engine.ts +87 -2
@@ -22,17 +22,8 @@ import {
22
22
  resolveDefaultConnectionName,
23
23
  } from "../../config/default-provider-resolution.js";
24
24
  import { getConfigReadOnly } from "../../config/loader.js";
25
- import type { DefaultProviderConfig } from "../../config/schemas/llm.js";
26
25
  import { DefaultProviderSchema } from "../../config/schemas/llm.js";
27
- import { getDb } from "../../persistence/db-connection.js";
28
- import { getConnection } from "../../providers/inference/connections.js";
29
- import { resolveManagedProxyContext } from "../../providers/platform-proxy/context.js";
30
- import {
31
- isVellumManagedConnection,
32
- MANAGED_ROUTABLE_PROVIDERS,
33
- } from "../../providers/vellum-model-routing.js";
34
- import { credentialKey } from "../../security/credential-key.js";
35
- import { getSecureKeyResultAsync } from "../../security/secure-keys.js";
26
+ import { computeConnectionAvailability } from "../../providers/inference/connection-availability.js";
36
27
  import { ACTOR_PRINCIPALS } from "../auth/route-policy.js";
37
28
  import { BadRequestError } from "./errors.js";
38
29
  import type { RouteDefinition, RouteHandlerArgs } from "./types.js";
@@ -64,150 +55,9 @@ const defaultProviderStatusSchema = z
64
55
  .meta({ id: "DefaultProviderStatus" });
65
56
 
66
57
  type DefaultProviderStatus = z.infer<typeof defaultProviderStatusSchema>;
67
- type Availability = z.infer<typeof availabilitySchema>;
68
58
 
69
59
  const SETTINGS_HINT = "in Settings → Models & Services";
70
60
 
71
- async function vellumAvailability(): Promise<Availability> {
72
- const ctx = await resolveManagedProxyContext();
73
- if (ctx.enabled) {
74
- return { status: "ok" };
75
- }
76
- if (!ctx.platformBaseUrl) {
77
- return {
78
- status: "vellum_unauthenticated",
79
- message: "Not signed in to Vellum — the platform URL is not configured.",
80
- };
81
- }
82
- // The context collapses an unreachable credential read into "no key";
83
- // re-read reachability-aware so a CES outage isn't reported as logged out.
84
- const key = await getSecureKeyResultAsync(
85
- credentialKey("vellum", "assistant_api_key"),
86
- );
87
- if (key.value != null) {
88
- return { status: "ok" };
89
- }
90
- if (key.unreachable) {
91
- return {
92
- status: "unknown",
93
- message:
94
- "The credential store is unreachable, so Vellum sign-in could not be verified. Try again shortly.",
95
- };
96
- }
97
- return {
98
- status: "vellum_unauthenticated",
99
- message:
100
- "Not signed in to Vellum — no assistant API key is stored. Log in to use Vellum-managed inference.",
101
- };
102
- }
103
-
104
- function vellumManagedMismatch(
105
- resolvedConnectionName: string,
106
- provider: string,
107
- ): Availability {
108
- return {
109
- status: "provider_mismatch",
110
- message: `Connection "${resolvedConnectionName}" is the Vellum-managed connection, which cannot serve provider "${provider}". Pick a connection for "${provider}" ${SETTINGS_HINT}.`,
111
- };
112
- }
113
-
114
- async function computeAvailability(
115
- dp: DefaultProviderConfig,
116
- resolvedConnectionName: string,
117
- ): Promise<Availability> {
118
- // Every path loads the row — even the canonical `vellum` name. Boot seeding
119
- // (`seedCanonicalConnections`) deliberately leaves a user-owned connection
120
- // that claims that name in place, and dispatch reads whatever row is
121
- // stored, so availability must judge the actual row, not the name.
122
- let connection;
123
- try {
124
- connection = getConnection(getDb(), resolvedConnectionName);
125
- } catch {
126
- return {
127
- status: "unknown",
128
- message: `Connection "${resolvedConnectionName}" could not be looked up. Try again shortly.`,
129
- };
130
- }
131
- if (!connection) {
132
- return {
133
- status: "missing_connection",
134
- message: `No connection named "${resolvedConnectionName}" exists for provider "${dp.provider}". Add one ${SETTINGS_HINT}.`,
135
- };
136
- }
137
-
138
- // Mirror the dispatch-time provider check (`tryResolveProviderForConnectionName`):
139
- // the provider-agnostic Vellum-managed connection routes managed-routable
140
- // providers via platform auth; any other provider mismatch fails there, so
141
- // usable credentials must not read as ok.
142
- if (isVellumManagedConnection(connection)) {
143
- if (
144
- dp.provider === "vellum" ||
145
- MANAGED_ROUTABLE_PROVIDERS.has(dp.provider)
146
- ) {
147
- return vellumAvailability();
148
- }
149
- return vellumManagedMismatch(resolvedConnectionName, dp.provider);
150
- }
151
- if (connection.provider !== dp.provider) {
152
- return {
153
- status: "provider_mismatch",
154
- message: `Connection "${resolvedConnectionName}" is for provider "${connection.provider}", but the default provider is "${dp.provider}". Pick a connection for "${dp.provider}" or update the default ${SETTINGS_HINT}.`,
155
- };
156
- }
157
-
158
- switch (connection.auth.type) {
159
- // Schema-accepted but not dispatchable: `resolveAuth` returns
160
- // not_implemented for service_account, so a stored credential still
161
- // cannot serve inference.
162
- case "service_account":
163
- return {
164
- status: "unsupported_auth",
165
- message: `Connection "${resolvedConnectionName}" uses service-account auth, which inference does not support yet. Pick a connection with a different auth type.`,
166
- };
167
- case "api_key":
168
- case "oauth_subscription": {
169
- const result = await getSecureKeyResultAsync(connection.auth.credential);
170
- if (result.value != null) {
171
- return { status: "ok" };
172
- }
173
- if (result.unreachable) {
174
- // Credential store down ≠ credential missing. Reporting
175
- // `missing_credential` here would send the user re-entering a key
176
- // that is probably still stored.
177
- return {
178
- status: "unknown",
179
- message: `The credential store is unreachable, so the credential for connection "${resolvedConnectionName}" could not be verified. Try again shortly.`,
180
- };
181
- }
182
- const noun =
183
- connection.auth.type === "api_key" ? "API key" : "credential";
184
- return {
185
- status: "missing_credential",
186
- message: `Connection "${resolvedConnectionName}" has no ${noun} stored. Add one ${SETTINGS_HINT}.`,
187
- };
188
- }
189
- case "platform":
190
- // The managed proxy only serves managed-routable upstreams
191
- // (`resolveAuth` → `buildManagedBaseUrl` has no proxy path for the
192
- // rest), so platform auth on e.g. openrouter can never dispatch.
193
- if (MANAGED_ROUTABLE_PROVIDERS.has(dp.provider)) {
194
- return vellumAvailability();
195
- }
196
- return {
197
- status: "unsupported_auth",
198
- message: `Connection "${resolvedConnectionName}" uses Vellum platform auth, which cannot serve provider "${dp.provider}". Add an API-key connection for "${dp.provider}" ${SETTINGS_HINT}.`,
199
- };
200
- case "none":
201
- // Every default-provider candidate except vellum is an API-key
202
- // provider; dispatch (`createAdapterFromConnection`) yields no adapter
203
- // for keyless auth on them.
204
- return {
205
- status: "unsupported_auth",
206
- message: `Connection "${resolvedConnectionName}" has no authentication configured, but provider "${dp.provider}" requires an API key. Add a key ${SETTINGS_HINT}.`,
207
- };
208
- }
209
- }
210
-
211
61
  async function handleGetDefaultProvider(): Promise<DefaultProviderStatus> {
212
62
  const dp = getDefaultProviderFromConfig(getConfigReadOnly());
213
63
  if (!dp) {
@@ -225,7 +75,10 @@ async function handleGetDefaultProvider(): Promise<DefaultProviderStatus> {
225
75
  provider: dp.provider,
226
76
  ...(dp.connectionName ? { connectionName: dp.connectionName } : {}),
227
77
  resolvedConnectionName,
228
- availability: await computeAvailability(dp, resolvedConnectionName),
78
+ availability: await computeConnectionAvailability(
79
+ dp.provider,
80
+ resolvedConnectionName,
81
+ ),
229
82
  };
230
83
  }
231
84
 
@@ -81,7 +81,10 @@ import { ROUTES as HOST_FILE_ROUTES } from "./host-file-routes.js";
81
81
  import { ROUTES as HOST_TRANSFER_ROUTES } from "./host-transfer-routes.js";
82
82
  import { ROUTES as IDENTITY_ROUTES } from "./identity-routes.js";
83
83
  import { ROUTES as IMAGE_GENERATION_ROUTES } from "./image-generation-routes.js";
84
+ import { ROUTES as INFERENCE_CALLSITES_ROUTES } from "./inference-callsites-routes.js";
85
+ import { ROUTES as INFERENCE_MODELS_ROUTES } from "./inference-models-routes.js";
84
86
  import { ROUTES as INFERENCE_PROFILE_SESSION_ROUTES } from "./inference-profile-session-routes.js";
87
+ import { ROUTES as INFERENCE_PROFILES_ROUTES } from "./inference-profiles-routes.js";
85
88
  import { ROUTES as INFERENCE_PROVIDER_CONNECTION_ROUTES } from "./inference-provider-connection-routes.js";
86
89
  import { ROUTES as INFERENCE_SEND_ROUTES } from "./inference-send-routes.js";
87
90
  import { ROUTES as A2A_ROUTES } from "./integrations/a2a.js";
@@ -136,6 +139,7 @@ import { ROUTES as SURFACE_ACTION_ROUTES } from "./surface-action-routes.js";
136
139
  import { ROUTES as SURFACE_CONTENT_ROUTES } from "./surface-content-routes.js";
137
140
  import { ROUTES as TASK_ROUTES } from "./task-routes.js";
138
141
  import { ROUTES as TELEMETRY_ROUTES } from "./telemetry-routes.js";
142
+ import { ROUTES as THEME_ROUTES } from "./theme-routes.js";
139
143
  import { ROUTES as TRUST_RULES_ROUTES } from "./trust-rules-routes.js";
140
144
  import { ROUTES as TTS_ROUTES } from "./tts-routes.js";
141
145
  import type { RouteDefinition } from "./types.js";
@@ -221,7 +225,10 @@ export const ROUTES: RouteDefinition[] = [
221
225
  ...HOST_FILE_ROUTES,
222
226
  ...HOST_TRANSFER_ROUTES,
223
227
  ...IDENTITY_ROUTES,
228
+ ...INFERENCE_CALLSITES_ROUTES,
229
+ ...INFERENCE_MODELS_ROUTES,
224
230
  ...INFERENCE_PROFILE_SESSION_ROUTES,
231
+ ...INFERENCE_PROFILES_ROUTES,
225
232
  ...INFERENCE_PROVIDER_CONNECTION_ROUTES,
226
233
  ...INFERENCE_SEND_ROUTES,
227
234
  ...INTERNAL_OAUTH_ROUTES,
@@ -279,6 +286,7 @@ export const ROUTES: RouteDefinition[] = [
279
286
  ...TWILIO_ROUTES,
280
287
  ...TASK_ROUTES,
281
288
  ...TELEMETRY_ROUTES,
289
+ ...THEME_ROUTES,
282
290
  ...TRUST_RULES_ROUTES,
283
291
  ...TTS_ROUTES,
284
292
  ...UI_REQUEST_ROUTES,
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Route definitions for read-only inference call-site resolution inspection.
3
+ *
4
+ * GET /v1/inference/callsites — effective resolution for every call site
5
+ * GET /v1/inference/callsites/:site — resolution detail + chain for one site
6
+ *
7
+ * These expose what `resolveCallSiteConfig` / `selectWinningProfile` already
8
+ * compute so the assistant can inspect which profile wins each call site
9
+ * without reading raw `llm.callSites.*` config paths. The detail view reuses
10
+ * the resolver's own fallback reporting (`onResolutionFallback`) for the
11
+ * resolution chain and the dispatch preflight (`preflightResolvedConfig`) for
12
+ * the usability check — no explanation logic is duplicated here.
13
+ */
14
+
15
+ import { z } from "zod";
16
+
17
+ import { CALL_SITE_DEFAULTS } from "../../config/call-site-defaults.js";
18
+ import {
19
+ type ResolutionFallbackReason,
20
+ resolveCallSiteConfig,
21
+ selectWinningProfile,
22
+ } from "../../config/llm-resolver.js";
23
+ import { getConfigReadOnly } from "../../config/loader.js";
24
+ import { type LLMCallSite, LLMCallSiteEnum } from "../../config/schemas/llm.js";
25
+ import {
26
+ ConnectionResolutionError,
27
+ preflightResolvedConfig,
28
+ } from "../../providers/connection-resolution.js";
29
+ import { ACTOR_PRINCIPALS } from "../auth/route-policy.js";
30
+ import { BadRequestError } from "./errors.js";
31
+ import type { RouteDefinition, RouteHandlerArgs } from "./types.js";
32
+
33
+ const sourceEnum = z.enum(["override", "active", "call_site", "default"]);
34
+
35
+ const callSiteSummarySchema = z
36
+ .object({
37
+ callSite: z.string(),
38
+ profile: z.string().nullable(),
39
+ label: z.string().nullable(),
40
+ source: sourceEnum,
41
+ provider: z.string(),
42
+ model: z.string(),
43
+ effort: z.string(),
44
+ maxTokens: z.number(),
45
+ /** Notable tuning: the resolved context-window input cap, when set. */
46
+ maxInputTokens: z.number().optional(),
47
+ })
48
+ .meta({ id: "CallSiteResolutionSummary" });
49
+
50
+ const resolutionChainEntrySchema = z.object({
51
+ requested: z.string(),
52
+ reason: z.enum(["missing", "disabled", "incomplete"]),
53
+ });
54
+
55
+ const callSiteDetailSchema = z
56
+ .object({
57
+ callSite: z.string(),
58
+ winner: z.object({
59
+ profile: z.string().nullable(),
60
+ label: z.string().nullable(),
61
+ source: sourceEnum,
62
+ }),
63
+ resolved: z.object({
64
+ provider: z.string(),
65
+ model: z.string(),
66
+ maxTokens: z.number(),
67
+ effort: z.string(),
68
+ temperature: z.number().nullable(),
69
+ maxInputTokens: z.number().optional(),
70
+ }),
71
+ /** Rungs the resolver considered and skipped, oldest-first. */
72
+ resolutionChain: z.array(resolutionChainEntrySchema),
73
+ /** The shipped default fragment for this call site (code-owned). */
74
+ shippedDefault: z.record(z.string(), z.unknown()),
75
+ /** The user's call-site override fragment, if any. */
76
+ userPin: z.record(z.string(), z.unknown()).nullable(),
77
+ /** Present when the preflight can statically prove dispatch would fail. */
78
+ resolutionError: z
79
+ .object({ reason: z.string(), message: z.string() })
80
+ .optional(),
81
+ })
82
+ .meta({ id: "CallSiteResolutionDetail" });
83
+
84
+ function summarizeCallSite(
85
+ callSite: LLMCallSite,
86
+ llm: Parameters<typeof resolveCallSiteConfig>[1],
87
+ ) {
88
+ const selection = selectWinningProfile(callSite, llm, {});
89
+ const resolved = resolveCallSiteConfig(callSite, llm, {});
90
+ const label =
91
+ typeof selection.entry?.label === "string" ? selection.entry.label : null;
92
+ const maxInputTokens = resolved.contextWindow?.maxInputTokens;
93
+ return {
94
+ callSite,
95
+ profile: selection.profileName,
96
+ label,
97
+ source: selection.source,
98
+ provider: resolved.provider,
99
+ model: resolved.model,
100
+ effort: resolved.effort,
101
+ maxTokens: resolved.maxTokens,
102
+ ...(typeof maxInputTokens === "number" ? { maxInputTokens } : {}),
103
+ };
104
+ }
105
+
106
+ function handleListCallSites() {
107
+ const llm = getConfigReadOnly().llm;
108
+ const callSites = LLMCallSiteEnum.options.map((callSite) =>
109
+ summarizeCallSite(callSite, llm),
110
+ );
111
+ return { callSites };
112
+ }
113
+
114
+ async function handleGetCallSite({ pathParams = {} }: RouteHandlerArgs) {
115
+ const site = (pathParams.site ?? "").trim();
116
+ const parsedSite = LLMCallSiteEnum.safeParse(site);
117
+ if (!parsedSite.success) {
118
+ throw new BadRequestError(
119
+ `Unknown call site "${site}". Valid call sites: ${LLMCallSiteEnum.options.join(", ")}.`,
120
+ );
121
+ }
122
+ const callSite = parsedSite.data;
123
+ const llm = getConfigReadOnly().llm;
124
+
125
+ const resolutionChain: {
126
+ requested: string;
127
+ reason: ResolutionFallbackReason;
128
+ }[] = [];
129
+ const selection = selectWinningProfile(callSite, llm, {
130
+ onResolutionFallback: ({ requested, reason }) => {
131
+ resolutionChain.push({ requested, reason });
132
+ },
133
+ });
134
+ const resolved = resolveCallSiteConfig(callSite, llm, {});
135
+
136
+ let resolutionError: { reason: string; message: string } | undefined;
137
+ try {
138
+ await preflightResolvedConfig(resolved, {
139
+ profileName: selection.profileName ?? undefined,
140
+ });
141
+ } catch (err) {
142
+ if (err instanceof ConnectionResolutionError) {
143
+ resolutionError = { reason: err.reason, message: err.message };
144
+ } else {
145
+ throw err;
146
+ }
147
+ }
148
+
149
+ const maxInputTokens = resolved.contextWindow?.maxInputTokens;
150
+ return {
151
+ callSite,
152
+ winner: {
153
+ profile: selection.profileName,
154
+ label:
155
+ typeof selection.entry?.label === "string"
156
+ ? selection.entry.label
157
+ : null,
158
+ source: selection.source,
159
+ },
160
+ resolved: {
161
+ provider: resolved.provider,
162
+ model: resolved.model,
163
+ maxTokens: resolved.maxTokens,
164
+ effort: resolved.effort,
165
+ temperature: resolved.temperature ?? null,
166
+ ...(typeof maxInputTokens === "number" ? { maxInputTokens } : {}),
167
+ },
168
+ resolutionChain,
169
+ shippedDefault: CALL_SITE_DEFAULTS[callSite] as Record<string, unknown>,
170
+ userPin: (llm.callSites?.[callSite] ?? null) as Record<
171
+ string,
172
+ unknown
173
+ > | null,
174
+ ...(resolutionError ? { resolutionError } : {}),
175
+ };
176
+ }
177
+
178
+ export const ROUTES: RouteDefinition[] = [
179
+ {
180
+ operationId: "inference_callsites_list",
181
+ endpoint: "inference/callsites",
182
+ method: "GET",
183
+ policy: {
184
+ requiredScopes: ["settings.read"],
185
+ allowedPrincipalTypes: ACTOR_PRINCIPALS,
186
+ },
187
+ summary: "List call-site resolutions",
188
+ description:
189
+ "Return the effective resolution for every LLM call site: the winning profile, its source (override / active / call-site pin / shipped default), and the resolved provider/model plus notable tuning.",
190
+ tags: ["inference"],
191
+ responseBody: z.object({ callSites: z.array(callSiteSummarySchema) }),
192
+ handler: handleListCallSites,
193
+ },
194
+ {
195
+ operationId: "inference_callsites_get",
196
+ endpoint: "inference/callsites/:site",
197
+ method: "GET",
198
+ policy: {
199
+ requiredScopes: ["settings.read"],
200
+ allowedPrincipalTypes: ACTOR_PRINCIPALS,
201
+ },
202
+ summary: "Get a call-site resolution detail",
203
+ description:
204
+ "Return the full resolution for one call site: the winner, the resolution chain (rungs considered and skipped), the shipped default fragment, the user's pin fragment, and a preflight-derived resolution error when dispatch would provably fail.",
205
+ tags: ["inference"],
206
+ pathParams: [{ name: "site", description: "LLM call-site id" }],
207
+ responseBody: callSiteDetailSchema,
208
+ additionalResponses: { "400": { description: "Unknown call site" } },
209
+ handler: handleGetCallSite,
210
+ },
211
+ ];
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Route definitions for the inference model catalog.
3
+ *
4
+ * GET /v1/inference/models — list catalog models (optional ?provider= filter)
5
+ *
6
+ * The catalog (`PROVIDER_CATALOG`) is the code-owned source of truth for which
7
+ * model ids each provider serves. Exposing it lets clients (and the assistant
8
+ * itself) discover valid model ids instead of guessing — the same ids
9
+ * `isModelInCatalog` validates against when a profile is created.
10
+ */
11
+
12
+ import { z } from "zod";
13
+
14
+ import { PROVIDER_CATALOG } from "../../providers/model-catalog.js";
15
+ import { ACTOR_PRINCIPALS } from "../auth/route-policy.js";
16
+ import { BadRequestError } from "./errors.js";
17
+ import type { RouteDefinition, RouteHandlerArgs } from "./types.js";
18
+
19
+ const catalogModelSchema = z
20
+ .object({
21
+ provider: z.string(),
22
+ id: z.string(),
23
+ displayName: z.string(),
24
+ contextWindowTokens: z.number().optional(),
25
+ maxOutputTokens: z.number().optional(),
26
+ supportsThinking: z.boolean().optional(),
27
+ supportsVision: z.boolean().optional(),
28
+ supportsToolUse: z.boolean().optional(),
29
+ /** When set, the model is only visible while the named flag is enabled. */
30
+ featureFlag: z.string().optional(),
31
+ })
32
+ .meta({ id: "CatalogModel" });
33
+
34
+ function handleListModels({ queryParams = {} }: RouteHandlerArgs) {
35
+ const providerFilter = queryParams.provider?.trim();
36
+ if (providerFilter) {
37
+ const known = PROVIDER_CATALOG.some((p) => p.id === providerFilter);
38
+ if (!known) {
39
+ throw new BadRequestError(
40
+ `Unknown provider "${providerFilter}". Known providers: ${PROVIDER_CATALOG.map(
41
+ (p) => p.id,
42
+ ).join(", ")}.`,
43
+ );
44
+ }
45
+ }
46
+
47
+ const models = PROVIDER_CATALOG.filter(
48
+ (entry) => !providerFilter || entry.id === providerFilter,
49
+ ).flatMap((entry) =>
50
+ entry.models.map((model) => ({
51
+ provider: entry.id,
52
+ id: model.id,
53
+ displayName: model.displayName,
54
+ ...(model.contextWindowTokens !== undefined
55
+ ? { contextWindowTokens: model.contextWindowTokens }
56
+ : {}),
57
+ ...(model.maxOutputTokens !== undefined
58
+ ? { maxOutputTokens: model.maxOutputTokens }
59
+ : {}),
60
+ ...(model.supportsThinking !== undefined
61
+ ? { supportsThinking: model.supportsThinking }
62
+ : {}),
63
+ ...(model.supportsVision !== undefined
64
+ ? { supportsVision: model.supportsVision }
65
+ : {}),
66
+ ...(model.supportsToolUse !== undefined
67
+ ? { supportsToolUse: model.supportsToolUse }
68
+ : {}),
69
+ ...(model.featureFlag !== undefined
70
+ ? { featureFlag: model.featureFlag }
71
+ : {}),
72
+ })),
73
+ );
74
+
75
+ return { models };
76
+ }
77
+
78
+ export const ROUTES: RouteDefinition[] = [
79
+ {
80
+ operationId: "inference_models_list",
81
+ endpoint: "inference/models",
82
+ method: "GET",
83
+ policy: {
84
+ requiredScopes: ["settings.read"],
85
+ allowedPrincipalTypes: ACTOR_PRINCIPALS,
86
+ },
87
+ summary: "List inference catalog models",
88
+ description:
89
+ "Return every model in the code-owned provider catalog, each tagged with its provider. Optionally filter by provider with ?provider=<id>.",
90
+ tags: ["inference"],
91
+ queryParams: [
92
+ {
93
+ name: "provider",
94
+ schema: { type: "string" },
95
+ description: `Filter by provider id. One of: ${PROVIDER_CATALOG.map(
96
+ (p) => p.id,
97
+ ).join(", ")}`,
98
+ },
99
+ ],
100
+ responseBody: z.object({ models: z.array(catalogModelSchema) }),
101
+ additionalResponses: { "400": { description: "Unknown provider filter" } },
102
+ handler: handleListModels,
103
+ },
104
+ ];