@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.
- package/openapi.yaml +846 -27
- package/package.json +1 -1
- package/src/__tests__/config-watcher-skill-reseed.test.ts +1 -0
- package/src/__tests__/config-watcher.test.ts +22 -4
- package/src/__tests__/credential-security-invariants.test.ts +1 -1
- package/src/__tests__/plugin-import-boundary-guard.test.ts +6 -9
- package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +0 -2
- package/src/cli/commands/__tests__/inference-models.test.ts +86 -0
- package/src/cli/commands/__tests__/inference-profiles.test.ts +254 -0
- package/src/cli/commands/__tests__/inference-providers.test.ts +171 -0
- package/src/cli/commands/__tests__/schedules.test.ts +133 -1
- package/src/cli/commands/__tests__/usage.test.ts +131 -0
- package/src/cli/commands/inference-callsites.ts +158 -0
- package/src/cli/commands/inference-models.ts +84 -0
- package/src/cli/commands/inference-profiles.ts +371 -0
- package/src/cli/commands/inference-providers-default.ts +89 -0
- package/src/cli/commands/inference-providers.ts +87 -16
- package/src/cli/commands/inference.ts +6 -0
- package/src/cli/commands/memory/nodes.ts +90 -50
- package/src/cli/commands/schedules.ts +17 -2
- package/src/cli/commands/usage.ts +59 -21
- package/src/cli/lib/__tests__/cli-output.test.ts +20 -0
- package/src/cli/lib/cli-output.ts +55 -0
- package/src/config/__tests__/loader-last-known-good.test.ts +229 -0
- package/src/config/__tests__/loader-sparse-array-cleanup.test.ts +166 -0
- package/src/config/default-profile-catalog.ts +28 -0
- package/src/config/loader.ts +276 -46
- package/src/daemon/config-watcher.ts +65 -20
- package/src/daemon/message-types/sync.ts +1 -0
- package/src/oauth/byo-connection.test.ts +1 -1
- package/src/oauth/connection-resolver.test.ts +140 -0
- package/src/oauth/connection-resolver.ts +48 -12
- package/src/plugins/defaults/memory/anisotropy.ts +1 -1
- package/src/plugins/defaults/memory/config.ts +1 -1
- package/src/plugins/defaults/memory/context-search/agent-protocol.ts +1 -1
- package/src/plugins/defaults/memory/context-search/search.ts +1 -1
- package/src/plugins/defaults/memory/graph/bootstrap.ts +1 -1
- package/src/plugins/defaults/memory/graph/consolidation.ts +1 -1
- package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +11 -1
- package/src/plugins/defaults/memory/graph/extraction.ts +1 -1
- package/src/plugins/defaults/memory/graph/narrative.ts +1 -1
- package/src/plugins/defaults/memory/graph/pattern-scan.ts +1 -1
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +1 -1
- package/src/plugins/defaults/memory/graph/tools.ts +1 -1
- package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +43 -16
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +1 -1
- package/src/plugins/defaults/memory/host-utils.ts +80 -0
- package/src/plugins/defaults/memory/identity-context.ts +1 -1
- package/src/plugins/defaults/memory/injectors.ts +1 -1
- package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +2 -2
- package/src/plugins/defaults/memory/jobs-worker.ts +2 -9
- package/src/plugins/defaults/memory/memory-retrospective-state.ts +1 -1
- package/src/plugins/defaults/memory/paths.ts +48 -0
- package/src/plugins/defaults/memory/pkb/autoinject.ts +1 -1
- package/src/plugins/defaults/memory/pkb/context.ts +2 -2
- package/src/plugins/defaults/memory/pkb/types.ts +1 -1
- package/src/plugins/defaults/memory/pkb-schedule.ts +2 -2
- package/src/plugins/defaults/memory/rerank-local.ts +2 -3
- package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +149 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.ts +144 -1
- package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +1 -1
- package/src/plugins/defaults/memory/startup.ts +1 -1
- package/src/plugins/defaults/memory/v2/backfill-jobs.ts +1 -1
- package/src/plugins/defaults/memory/v2/consolidation-job.ts +2 -2
- package/src/plugins/defaults/memory/v2/injection.ts +1 -1
- package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +1 -1
- package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +1 -1
- package/src/plugins/defaults/memory/v2/qdrant.ts +1 -1
- package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
- package/src/plugins/defaults/memory/v2/static-context.ts +1 -1
- package/src/plugins/defaults/memory/v2/sweep-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
- package/src/plugins/defaults/memory/v3/maintain-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/page-content.ts +1 -1
- package/src/plugins/defaults/memory/v3/pool-select.ts +1 -2
- package/src/plugins/defaults/memory/v3/selection-log-store.ts +1 -1
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +2 -5
- package/src/plugins/defaults/memory/worker.ts +1 -1
- package/src/plugins/defaults/workspace/injectors.ts +17 -15
- package/src/plugins/types.ts +9 -14
- package/src/providers/inference/connection-availability.ts +193 -0
- package/src/runtime/routes/__tests__/inference-callsites-routes.test.ts +54 -0
- package/src/runtime/routes/__tests__/inference-models-routes.test.ts +54 -0
- package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +405 -0
- package/src/runtime/routes/__tests__/inference-routes-registration.test.ts +42 -0
- package/src/runtime/routes/__tests__/theme-routes.test.ts +66 -0
- package/src/runtime/routes/conversation-query-routes.ts +5 -3
- package/src/runtime/routes/default-provider-routes.ts +5 -152
- package/src/runtime/routes/index.ts +8 -0
- package/src/runtime/routes/inference-callsites-routes.ts +211 -0
- package/src/runtime/routes/inference-models-routes.ts +104 -0
- package/src/runtime/routes/inference-profiles-routes.ts +717 -0
- package/src/runtime/routes/theme-routes.ts +36 -0
- package/src/runtime/sync/resource-sync-events.ts +4 -0
- package/src/theme/workspace-theme.test.ts +269 -0
- package/src/theme/workspace-theme.ts +304 -0
- package/src/watcher/__tests__/engine-auth-notify.test.ts +316 -0
- package/src/watcher/engine.ts +87 -2
|
@@ -56,8 +56,7 @@ import { z } from "zod";
|
|
|
56
56
|
|
|
57
57
|
import { classifyConversationError } from "../../../../daemon/conversation-error.js";
|
|
58
58
|
import type { PendingConversationNotice } from "../../../../daemon/conversation-notices.js";
|
|
59
|
-
import { redactLogString } from "
|
|
60
|
-
import { truncate } from "../../../../util/truncate.js";
|
|
59
|
+
import { redactLogString, truncate } from "../host-utils.js";
|
|
61
60
|
import {
|
|
62
61
|
cachedTextBlock,
|
|
63
62
|
extractToolUse,
|
|
@@ -20,7 +20,7 @@ import type { MemoryV3SelectionLog } from "../../../../api/responses/memory-v3-s
|
|
|
20
20
|
import { getConfig } from "../../../../config/loader.js";
|
|
21
21
|
import { isMemoryV3Live } from "../../../../config/memory-v3-gate.js";
|
|
22
22
|
import { getDb, getSqliteFrom } from "../../../../persistence/db-connection.js";
|
|
23
|
-
import { getWorkspaceDir } from "
|
|
23
|
+
import { getWorkspaceDir } from "../paths.js";
|
|
24
24
|
import { readPage } from "../v2/page-store.js";
|
|
25
25
|
import { capabilityOrDiskBody } from "./capabilities.js";
|
|
26
26
|
import { sectionByOrdinal } from "./orchestrate.js";
|
|
@@ -31,12 +31,9 @@ import {
|
|
|
31
31
|
import { getConfig } from "../../../../config/loader.js";
|
|
32
32
|
import type { AssistantConfig } from "../../../../config/schema.js";
|
|
33
33
|
import { getDb, getSqliteFrom } from "../../../../persistence/db-connection.js";
|
|
34
|
-
import {
|
|
35
|
-
getWorkspaceDir,
|
|
36
|
-
getWorkspacePromptPath,
|
|
37
|
-
} from "../../../../util/platform.js";
|
|
38
|
-
import { stripCommentLines } from "../../../../util/strip-comment-lines.js";
|
|
34
|
+
import { stripCommentLines } from "../host-utils.js";
|
|
39
35
|
import { getLogger } from "../logging.js";
|
|
36
|
+
import { getWorkspaceDir, getWorkspacePromptPath } from "../paths.js";
|
|
40
37
|
import { getPageIndex } from "../v2/page-index.js";
|
|
41
38
|
import { readPage, renderPageContent } from "../v2/page-store.js";
|
|
42
39
|
import { capabilityOrDiskBody } from "./capabilities.js";
|
|
@@ -14,10 +14,10 @@ import { existsSync, unlinkSync, writeFileSync } from "node:fs";
|
|
|
14
14
|
|
|
15
15
|
import { getConfig } from "../../../config/loader.js";
|
|
16
16
|
import { initializeTools } from "../../../tools/registry.js";
|
|
17
|
-
import { getMemoryWorkerPidPath } from "../../../util/platform.js";
|
|
18
17
|
import { registerMemoryPluginJobHandlers } from "./job-handler-registration.js";
|
|
19
18
|
import { startInProcessMemoryJobsWorker } from "./jobs-worker.js";
|
|
20
19
|
import { getLogger } from "./logging.js";
|
|
20
|
+
import { getMemoryWorkerPidPath } from "./paths.js";
|
|
21
21
|
|
|
22
22
|
const log = getLogger("memory-worker-process");
|
|
23
23
|
|
|
@@ -266,14 +266,15 @@ function readConfigValidationResetNotice(): ConfigValidationResetNotice | null {
|
|
|
266
266
|
/**
|
|
267
267
|
* `config-validation-reset-notice` injector — order 26, prepend-user-tail.
|
|
268
268
|
*
|
|
269
|
-
* Surfaces a recent config-validation
|
|
270
|
-
* parses as JSON but fails schema validation
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* to `your-own
|
|
276
|
-
*
|
|
269
|
+
* Surfaces a recent config-validation event to the agent. When `config.json`
|
|
270
|
+
* parses as JSON but fails schema validation that per-key cleanup cannot repair,
|
|
271
|
+
* the loader recovers along a ladder (see `config/loader.ts`
|
|
272
|
+
* `recoverFromInvalidConfig`) and records a sentinel. Whichever rung it lands
|
|
273
|
+
* on, the saved config is not fully in effect: a section — or the whole config —
|
|
274
|
+
* may have reverted to schema defaults, flipping a managed email/OAuth service
|
|
275
|
+
* mode back to `your-own`, or the user's most recent edit may simply never have
|
|
276
|
+
* applied. That is otherwise invisible (log-only). This injector reads the
|
|
277
|
+
* sentinel and, when it is younger than
|
|
277
278
|
* {@link CONFIG_VALIDATION_RESET_NOTICE_MAX_AGE_MS}, injects a short block so the
|
|
278
279
|
* agent can explain a setting or connection that changed without the user asking
|
|
279
280
|
* — the on-disk config is intact, so recovery is fixing the flagged entries.
|
|
@@ -311,13 +312,14 @@ const configValidationResetNoticeInjector: Injector = {
|
|
|
311
312
|
: "(top-level)";
|
|
312
313
|
const text =
|
|
313
314
|
`<config_reset_notice>\n` +
|
|
314
|
-
`The user's config.json failed schema validation
|
|
315
|
-
`
|
|
316
|
-
`have silently reverted — including managed email/OAuth
|
|
317
|
-
`(a managed connection can flip back to "your-own" and
|
|
318
|
-
`choices, and other customizations
|
|
319
|
-
`
|
|
320
|
-
`effect again.
|
|
315
|
+
`The user's config.json failed schema validation at ${notice.resetAt} ` +
|
|
316
|
+
`and did not fully take effect. Settings the user did not change may ` +
|
|
317
|
+
`have silently reverted to defaults — including managed email/OAuth ` +
|
|
318
|
+
`service modes (a managed connection can flip back to "your-own" and ` +
|
|
319
|
+
`break), model choices, and other customizations — and a recent edit may ` +
|
|
320
|
+
`never have applied. The on-disk config.json is intact; the invalid ` +
|
|
321
|
+
`entries just need fixing for the saved values to take effect again. ` +
|
|
322
|
+
`Invalid config path(s): ${invalidList}.\n\n` +
|
|
321
323
|
`If the user reports a connection, setting, or integration that broke or ` +
|
|
322
324
|
`changed on its own — especially email/Outlook/OAuth — do NOT trust ` +
|
|
323
325
|
`memory or the Connected Services block: run a live check ` +
|
package/src/plugins/types.ts
CHANGED
|
@@ -13,19 +13,19 @@ import type { CompactionCircuitClosedEvent } from "../api/events/compaction-circ
|
|
|
13
13
|
import type { CompactionCircuitOpenEvent } from "../api/events/compaction-circuit-open.js";
|
|
14
14
|
import type { HookEventOwner } from "../api/events/hook-event.js";
|
|
15
15
|
import type { LLMCallSite } from "../config/schemas/llm.js";
|
|
16
|
+
import type { AssistantConfig } from "../config/types.js";
|
|
16
17
|
import type {
|
|
17
18
|
ChannelCapabilities,
|
|
18
19
|
InboundActorContext,
|
|
19
20
|
InjectionMode,
|
|
20
21
|
} from "../daemon/conversation-runtime-assembly.js";
|
|
21
22
|
import type { TrustContext } from "../daemon/trust-context-types.js";
|
|
23
|
+
import type { MemoryJob } from "../persistence/jobs-store.js";
|
|
22
24
|
import type { HookFunction } from "../plugin-api/types.js";
|
|
23
25
|
import type { Message } from "../providers/types.js";
|
|
24
26
|
import type { SkillRoute } from "../runtime/skill-route-registry.js";
|
|
25
27
|
import type { Tool } from "../tools/types.js";
|
|
26
28
|
import { AssistantError, ErrorCode } from "../util/errors.js";
|
|
27
|
-
import type { ConversationGraphMemory } from "./defaults/memory/graph/conversation-graph-memory.js";
|
|
28
|
-
import type { JobHandler } from "./defaults/memory/jobs-worker.js";
|
|
29
29
|
|
|
30
30
|
// ─── Manifest ────────────────────────────────────────────────────────────────
|
|
31
31
|
|
|
@@ -68,18 +68,6 @@ export type {
|
|
|
68
68
|
ShutdownReason,
|
|
69
69
|
} from "../plugin-api/types.js";
|
|
70
70
|
|
|
71
|
-
// ─── Memory-graph result ─────────────────────────────────────────────────────
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Full output of a single memory-graph retrieval — the object returned by
|
|
75
|
-
* {@link ConversationGraphMemory.prepareMemory} (injected messages, query
|
|
76
|
-
* vectors, metrics). The agent loop consumes these fields directly to drive
|
|
77
|
-
* PKB hint search and runtime injection.
|
|
78
|
-
*/
|
|
79
|
-
export type GraphMemoryResult = Awaited<
|
|
80
|
-
ReturnType<ConversationGraphMemory["prepareMemory"]>
|
|
81
|
-
>;
|
|
82
|
-
|
|
83
71
|
/**
|
|
84
72
|
* The complete set of compaction circuit-breaker transition events:
|
|
85
73
|
* `compaction_circuit_open` when the breaker trips and `compaction_circuit_closed`
|
|
@@ -336,6 +324,13 @@ export interface Injector {
|
|
|
336
324
|
*/
|
|
337
325
|
export type PluginRouteRegistration = SkillRoute;
|
|
338
326
|
|
|
327
|
+
/**
|
|
328
|
+
* Processes one claimed background job: receives the claimed job row and the
|
|
329
|
+
* live assistant config. The return value is ignored — a handler signals
|
|
330
|
+
* failure by throwing, which the worker records against the job.
|
|
331
|
+
*/
|
|
332
|
+
export type JobHandler = (job: MemoryJob, config: AssistantConfig) => unknown;
|
|
333
|
+
|
|
339
334
|
/**
|
|
340
335
|
* A single background-job-handler entry: a job `type` string paired with the
|
|
341
336
|
* {@link JobHandler} that processes it. The memory plugin's handler list
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared availability computation for a (provider, connection) pair: whether
|
|
3
|
+
* the connection exists, carries a usable credential, and can actually serve
|
|
4
|
+
* the provider. The status is reported, never enforced — a dangling or
|
|
5
|
+
* uncredentialed connection is a valid persisted state that surfaces an
|
|
6
|
+
* explainable error at dispatch time.
|
|
7
|
+
*
|
|
8
|
+
* Consumed by the default-provider status route (`llm.defaultProvider`) and
|
|
9
|
+
* the inference-profile list route (per-profile `provider_connection`) so the
|
|
10
|
+
* two never drift.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { getDb } from "../../persistence/db-connection.js";
|
|
14
|
+
import { credentialKey } from "../../security/credential-key.js";
|
|
15
|
+
import { getSecureKeyResultAsync } from "../../security/secure-keys.js";
|
|
16
|
+
import { PROVIDER_CATALOG } from "../model-catalog.js";
|
|
17
|
+
import { resolveManagedProxyContext } from "../platform-proxy/context.js";
|
|
18
|
+
import {
|
|
19
|
+
isVellumManagedConnection,
|
|
20
|
+
MANAGED_ROUTABLE_PROVIDERS,
|
|
21
|
+
} from "../vellum-model-routing.js";
|
|
22
|
+
import { getConnection } from "./connections.js";
|
|
23
|
+
|
|
24
|
+
export type ConnectionAvailabilityStatus =
|
|
25
|
+
| "ok"
|
|
26
|
+
| "missing_connection"
|
|
27
|
+
| "missing_credential"
|
|
28
|
+
| "provider_mismatch"
|
|
29
|
+
| "unsupported_auth"
|
|
30
|
+
| "vellum_unauthenticated"
|
|
31
|
+
| "unknown";
|
|
32
|
+
|
|
33
|
+
export interface ConnectionAvailability {
|
|
34
|
+
status: ConnectionAvailabilityStatus;
|
|
35
|
+
/** Present on every non-`ok` status: names the broken thing and the fix. */
|
|
36
|
+
message?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const SETTINGS_HINT = "in Settings → Models & Services";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Availability of the Vellum-managed platform proxy: signed in and reachable.
|
|
43
|
+
*/
|
|
44
|
+
export async function vellumConnectionAvailability(): Promise<ConnectionAvailability> {
|
|
45
|
+
const ctx = await resolveManagedProxyContext();
|
|
46
|
+
if (ctx.enabled) {
|
|
47
|
+
return { status: "ok" };
|
|
48
|
+
}
|
|
49
|
+
if (!ctx.platformBaseUrl) {
|
|
50
|
+
return {
|
|
51
|
+
status: "vellum_unauthenticated",
|
|
52
|
+
message: "Not signed in to Vellum — the platform URL is not configured.",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// The context collapses an unreachable credential read into "no key";
|
|
56
|
+
// re-read reachability-aware so a CES outage isn't reported as logged out.
|
|
57
|
+
const key = await getSecureKeyResultAsync(
|
|
58
|
+
credentialKey("vellum", "assistant_api_key"),
|
|
59
|
+
);
|
|
60
|
+
if (key.value != null) {
|
|
61
|
+
return { status: "ok" };
|
|
62
|
+
}
|
|
63
|
+
if (key.unreachable) {
|
|
64
|
+
return {
|
|
65
|
+
status: "unknown",
|
|
66
|
+
message:
|
|
67
|
+
"The credential store is unreachable, so Vellum sign-in could not be verified. Try again shortly.",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
status: "vellum_unauthenticated",
|
|
72
|
+
message:
|
|
73
|
+
"Not signed in to Vellum — no assistant API key is stored. Log in to use Vellum-managed inference.",
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function vellumManagedMismatch(
|
|
78
|
+
resolvedConnectionName: string,
|
|
79
|
+
provider: string,
|
|
80
|
+
): ConnectionAvailability {
|
|
81
|
+
return {
|
|
82
|
+
status: "provider_mismatch",
|
|
83
|
+
message: `Connection "${resolvedConnectionName}" is the Vellum-managed connection, which cannot serve provider "${provider}". Pick a connection for "${provider}" ${SETTINGS_HINT}.`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Compute the availability of `resolvedConnectionName` when used to serve
|
|
89
|
+
* `provider`. Mirrors the dispatch-time resolution checks
|
|
90
|
+
* (`tryResolveProviderForConnectionName` / `resolveAuth`) so a status of `ok`
|
|
91
|
+
* means dispatch would succeed.
|
|
92
|
+
*/
|
|
93
|
+
export async function computeConnectionAvailability(
|
|
94
|
+
provider: string,
|
|
95
|
+
resolvedConnectionName: string,
|
|
96
|
+
): Promise<ConnectionAvailability> {
|
|
97
|
+
// Every path loads the row — even the canonical `vellum` name. Boot seeding
|
|
98
|
+
// (`seedCanonicalConnections`) deliberately leaves a user-owned connection
|
|
99
|
+
// that claims that name in place, and dispatch reads whatever row is
|
|
100
|
+
// stored, so availability must judge the actual row, not the name.
|
|
101
|
+
let connection;
|
|
102
|
+
try {
|
|
103
|
+
connection = getConnection(getDb(), resolvedConnectionName);
|
|
104
|
+
} catch {
|
|
105
|
+
return {
|
|
106
|
+
status: "unknown",
|
|
107
|
+
message: `Connection "${resolvedConnectionName}" could not be looked up. Try again shortly.`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (!connection) {
|
|
111
|
+
return {
|
|
112
|
+
status: "missing_connection",
|
|
113
|
+
message: `No connection named "${resolvedConnectionName}" exists for provider "${provider}". Add one ${SETTINGS_HINT}.`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Mirror the dispatch-time provider check (`tryResolveProviderForConnectionName`):
|
|
118
|
+
// the provider-agnostic Vellum-managed connection routes managed-routable
|
|
119
|
+
// providers via platform auth; any other provider mismatch fails there, so
|
|
120
|
+
// usable credentials must not read as ok.
|
|
121
|
+
if (isVellumManagedConnection(connection)) {
|
|
122
|
+
if (provider === "vellum" || MANAGED_ROUTABLE_PROVIDERS.has(provider)) {
|
|
123
|
+
return vellumConnectionAvailability();
|
|
124
|
+
}
|
|
125
|
+
return vellumManagedMismatch(resolvedConnectionName, provider);
|
|
126
|
+
}
|
|
127
|
+
if (connection.provider !== provider) {
|
|
128
|
+
return {
|
|
129
|
+
status: "provider_mismatch",
|
|
130
|
+
message: `Connection "${resolvedConnectionName}" is for provider "${connection.provider}", but the requested provider is "${provider}". Pick a connection for "${provider}" ${SETTINGS_HINT}.`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
switch (connection.auth.type) {
|
|
135
|
+
// Schema-accepted but not dispatchable: `resolveAuth` returns
|
|
136
|
+
// not_implemented for service_account, so a stored credential still
|
|
137
|
+
// cannot serve inference.
|
|
138
|
+
case "service_account":
|
|
139
|
+
return {
|
|
140
|
+
status: "unsupported_auth",
|
|
141
|
+
message: `Connection "${resolvedConnectionName}" uses service-account auth, which inference does not support yet. Pick a connection with a different auth type.`,
|
|
142
|
+
};
|
|
143
|
+
case "api_key":
|
|
144
|
+
case "oauth_subscription": {
|
|
145
|
+
const result = await getSecureKeyResultAsync(connection.auth.credential);
|
|
146
|
+
if (result.value != null) {
|
|
147
|
+
return { status: "ok" };
|
|
148
|
+
}
|
|
149
|
+
if (result.unreachable) {
|
|
150
|
+
// Credential store down ≠ credential missing. Reporting
|
|
151
|
+
// `missing_credential` here would send the user re-entering a key
|
|
152
|
+
// that is probably still stored.
|
|
153
|
+
return {
|
|
154
|
+
status: "unknown",
|
|
155
|
+
message: `The credential store is unreachable, so the credential for connection "${resolvedConnectionName}" could not be verified. Try again shortly.`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const noun =
|
|
159
|
+
connection.auth.type === "api_key" ? "API key" : "credential";
|
|
160
|
+
return {
|
|
161
|
+
status: "missing_credential",
|
|
162
|
+
message: `Connection "${resolvedConnectionName}" has no ${noun} stored. Add one ${SETTINGS_HINT}.`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
case "platform":
|
|
166
|
+
// The managed proxy only serves managed-routable upstreams
|
|
167
|
+
// (`resolveAuth` → `buildManagedBaseUrl` has no proxy path for the
|
|
168
|
+
// rest), so platform auth on e.g. openrouter can never dispatch.
|
|
169
|
+
if (MANAGED_ROUTABLE_PROVIDERS.has(provider)) {
|
|
170
|
+
return vellumConnectionAvailability();
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
status: "unsupported_auth",
|
|
174
|
+
message: `Connection "${resolvedConnectionName}" uses Vellum platform auth, which cannot serve provider "${provider}". Add an API-key connection for "${provider}" ${SETTINGS_HINT}.`,
|
|
175
|
+
};
|
|
176
|
+
case "none": {
|
|
177
|
+
// Keyless providers (catalog setupMode "keyless", e.g. ollama)
|
|
178
|
+
// legitimately dispatch with none-auth — mirror
|
|
179
|
+
// `createAdapterFromConnection`, which only rejects none-auth for
|
|
180
|
+
// keyed catalog entries.
|
|
181
|
+
const isKeyless =
|
|
182
|
+
PROVIDER_CATALOG.find((entry) => entry.id === provider)?.setupMode ===
|
|
183
|
+
"keyless";
|
|
184
|
+
if (isKeyless) {
|
|
185
|
+
return { status: "ok" };
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
status: "unsupported_auth",
|
|
189
|
+
message: `Connection "${resolvedConnectionName}" has no authentication configured, but provider "${provider}" requires an API key. Add a key ${SETTINGS_HINT}.`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smoke tests for the inference call-site resolution routes.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/inference/callsites — one row per LLM call site
|
|
5
|
+
* GET /v1/inference/callsites/:site — 400 on an unknown site
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, mock, test } from "bun:test";
|
|
9
|
+
|
|
10
|
+
let fakeLlm: Record<string, unknown> = {};
|
|
11
|
+
mock.module("../../../config/loader.js", () => ({
|
|
12
|
+
getConfigReadOnly: () => ({ llm: fakeLlm }),
|
|
13
|
+
getConfig: () => ({ llm: fakeLlm }),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
import { LLMCallSiteEnum, LLMSchema } from "../../../config/schemas/llm.js";
|
|
17
|
+
import { BadRequestError } from "../errors.js";
|
|
18
|
+
import { ROUTES } from "../inference-callsites-routes.js";
|
|
19
|
+
import type { RouteDefinition, RouteHandlerArgs } from "../types.js";
|
|
20
|
+
|
|
21
|
+
fakeLlm = LLMSchema.parse({});
|
|
22
|
+
|
|
23
|
+
function handler(operationId: string): RouteDefinition["handler"] {
|
|
24
|
+
const route = ROUTES.find((r) => r.operationId === operationId);
|
|
25
|
+
if (!route) {
|
|
26
|
+
throw new Error(`Route ${operationId} not found`);
|
|
27
|
+
}
|
|
28
|
+
return route.handler;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function call(operationId: string, args: RouteHandlerArgs): Promise<unknown> {
|
|
32
|
+
return Promise.resolve(handler(operationId)(args));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe("GET inference/callsites", () => {
|
|
36
|
+
test("returns one summary row per call site", async () => {
|
|
37
|
+
const result = (await call("inference_callsites_list", {})) as {
|
|
38
|
+
callSites: { callSite: string; provider: string; model: string }[];
|
|
39
|
+
};
|
|
40
|
+
expect(result.callSites.length).toBe(LLMCallSiteEnum.options.length);
|
|
41
|
+
for (const row of result.callSites) {
|
|
42
|
+
expect(typeof row.provider).toBe("string");
|
|
43
|
+
expect(typeof row.model).toBe("string");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("GET inference/callsites/:site", () => {
|
|
49
|
+
test("400s on an unknown call site", async () => {
|
|
50
|
+
await expect(
|
|
51
|
+
call("inference_callsites_get", { pathParams: { site: "not-a-site" } }),
|
|
52
|
+
).rejects.toBeInstanceOf(BadRequestError);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the inference model-catalog route handler.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/inference/models — list all catalog models, optional ?provider=
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, expect, test } from "bun:test";
|
|
8
|
+
|
|
9
|
+
import { PROVIDER_CATALOG } from "../../../providers/model-catalog.js";
|
|
10
|
+
import { BadRequestError } from "../errors.js";
|
|
11
|
+
import { ROUTES } from "../inference-models-routes.js";
|
|
12
|
+
import type { RouteDefinition, RouteHandlerArgs } from "../types.js";
|
|
13
|
+
|
|
14
|
+
function handler(operationId: string): RouteDefinition["handler"] {
|
|
15
|
+
const route = ROUTES.find((r) => r.operationId === operationId);
|
|
16
|
+
if (!route) {
|
|
17
|
+
throw new Error(`Route ${operationId} not found`);
|
|
18
|
+
}
|
|
19
|
+
return route.handler;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function call(args: RouteHandlerArgs): {
|
|
23
|
+
models: { provider: string; id: string }[];
|
|
24
|
+
} {
|
|
25
|
+
return handler("inference_models_list")(args) as {
|
|
26
|
+
models: { provider: string; id: string }[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe("GET inference/models", () => {
|
|
31
|
+
test("lists every catalog model tagged with its provider", () => {
|
|
32
|
+
const { models } = call({});
|
|
33
|
+
const expected = PROVIDER_CATALOG.reduce(
|
|
34
|
+
(sum, p) => sum + p.models.length,
|
|
35
|
+
0,
|
|
36
|
+
);
|
|
37
|
+
expect(models.length).toBe(expected);
|
|
38
|
+
expect(models.every((m) => typeof m.provider === "string")).toBe(true);
|
|
39
|
+
expect(models.every((m) => typeof m.id === "string")).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("filters by provider", () => {
|
|
43
|
+
const provider = PROVIDER_CATALOG[0]!.id;
|
|
44
|
+
const { models } = call({ queryParams: { provider } });
|
|
45
|
+
expect(models.length).toBe(PROVIDER_CATALOG[0]!.models.length);
|
|
46
|
+
expect(models.every((m) => m.provider === provider)).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("400s on an unknown provider filter", () => {
|
|
50
|
+
expect(() => call({ queryParams: { provider: "not-a-provider" } })).toThrow(
|
|
51
|
+
BadRequestError,
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|