@vellumai/assistant 0.10.8-dev.202607151636.0aafaf2 → 0.10.8-dev.202607151831.d3cec7b

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 CHANGED
@@ -14341,7 +14341,10 @@ paths:
14341
14341
  post:
14342
14342
  operationId: inference_providerconnections_post
14343
14343
  summary: Create a provider connection
14344
- description: Create a new named provider connection. Fails with 409 if a connection with this name already exists.
14344
+ description:
14345
+ Create a new named provider connection. When auth is omitted it is derived from the provider (keyless
14346
+ providers get none, vellum gets platform, everything else needs credential for api_key auth). Fails with 409 if
14347
+ a connection with this name already exists.
14345
14348
  tags:
14346
14349
  - inference
14347
14350
  requestBody:
@@ -14358,6 +14361,9 @@ paths:
14358
14361
  $ref: "#/components/schemas/ConnectionProvider"
14359
14362
  auth:
14360
14363
  $ref: "#/components/schemas/Auth"
14364
+ credential:
14365
+ type: string
14366
+ minLength: 1
14361
14367
  label:
14362
14368
  type: string
14363
14369
  minLength: 1
@@ -14375,7 +14381,6 @@ paths:
14375
14381
  required:
14376
14382
  - name
14377
14383
  - provider
14378
- - auth
14379
14384
  responses:
14380
14385
  "201":
14381
14386
  description: Successful response
@@ -14447,7 +14452,8 @@ paths:
14447
14452
  operationId: inference_providerconnections_by_name_patch
14448
14453
  summary: Update a provider connection
14449
14454
  description:
14450
- Update an existing connection. Cannot rename or change the provider. For the Vellum-managed connection
14455
+ Update an existing connection. Cannot rename or change the provider. Omitting auth keeps the stored auth;
14456
+ passing credential alone rotates the key via provider-derived api_key auth. For the Vellum-managed connection
14451
14457
  (vellum) the auth is locked to platform; label remains editable.
14452
14458
  tags:
14453
14459
  - inference
@@ -14466,6 +14472,9 @@ paths:
14466
14472
  properties:
14467
14473
  auth:
14468
14474
  $ref: "#/components/schemas/Auth"
14475
+ credential:
14476
+ type: string
14477
+ minLength: 1
14469
14478
  label:
14470
14479
  anyOf:
14471
14480
  - type: string
@@ -14482,8 +14491,6 @@ paths:
14482
14491
  items:
14483
14492
  $ref: "#/components/schemas/ConnectionModel"
14484
14493
  - type: "null"
14485
- required:
14486
- - auth
14487
14494
  responses:
14488
14495
  "200":
14489
14496
  description: Successful response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.8-dev.202607151636.0aafaf2",
3
+ "version": "0.10.8-dev.202607151831.d3cec7b",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -251,28 +251,17 @@ export async function getMemoryGraph(
251
251
 
252
252
  const workspaceDir = getWorkspaceDir();
253
253
  const pageIndex = await getPageIndex(workspaceDir);
254
- // Concepts plus functionality (skills / CLI-command capabilities). Feeding the
255
- // full set to the edge builders is what lets a concept's `[[skills/foo]]` link
256
- // and skill↔concept co-selections resolve to real edges — buildEdgeGraph and
257
- // computeLearnedEdgeGraph both drop endpoints outside the set they're given.
258
- // Functionality nodes that end up disconnected are pruned in assembleMemoryGraph.
259
- const entries = pageIndex.entries;
260
-
261
- // Synthetic rows (skills / CLI commands) carry `modifiedAt: 0` and have no
262
- // on-disk page. Keyed by slug (not prefix) so a real user page that happens
263
- // to live under a reserved prefix is NOT mistaken for a synthetic one.
264
- const syntheticSlugs = new Set(
265
- entries.filter((e) => e.modifiedAt <= 0).map((e) => e.slug),
266
- );
254
+ // The Memory graph is the assistant's learned mind: concept pages and the
255
+ // links between them. Skills and plugins have their own dedicated pages, so
256
+ // synthetic capability rows (skills / CLI commands, which carry `modifiedAt: 0`)
257
+ // are excluded here — the map is about what the assistant knows, not what it
258
+ // can do.
259
+ const entries = pageIndex.entries.filter((e) => e.modifiedAt > 0);
267
260
 
268
261
  // Raw (frontmatter + body) page reader, matching the v3 lane build. A read
269
262
  // that rejects drops that article's authored/wikilink edges but keeps its
270
- // numeric fallbacks. Synthetic capability rows have no page, so short-circuit
271
- // their guaranteed-miss read; a real page is read so its links are captured.
263
+ // numeric fallbacks.
272
264
  const pageRaw = async (slug: Slug): Promise<string> => {
273
- if (syntheticSlugs.has(slug)) {
274
- return "";
275
- }
276
265
  const page = await readPage(workspaceDir, slug);
277
266
  if (!page) {
278
267
  throw new Error(`page not found: ${slug}`);
@@ -309,7 +298,6 @@ export async function getMemoryGraph(
309
298
  entries,
310
299
  staticAdjacency: staticGraph.adjacency,
311
300
  learnedAdjacency: learnedGraph.adjacency,
312
- pruneDisconnectedNonConcepts: true,
313
301
  });
314
302
 
315
303
  return { backend: BACKEND_MEMORY_V3, supported: true, ...assembled };
@@ -44,6 +44,29 @@ export const AuthSchema = z
44
44
 
45
45
  export type Auth = z.infer<typeof AuthSchema>;
46
46
 
47
+ /**
48
+ * Derive the auth configuration a provider implies when a client omits an
49
+ * explicit `auth` object: keyless catalog providers (`setupMode: "keyless"`,
50
+ * e.g. ollama) need none, the Vellum-managed sentinel routes via the
51
+ * platform proxy, and every other provider authenticates by API key. Returns
52
+ * null when an API key is required but no credential was supplied, so route
53
+ * handlers can reject with a 400. `oauth_subscription` is never derived —
54
+ * the ChatGPT PKCE routes own that connection.
55
+ */
56
+ export function deriveAuthForProvider(
57
+ provider: string,
58
+ credential?: string,
59
+ ): Auth | null {
60
+ if (provider === VELLUM_MANAGED_PROVIDER) {
61
+ return { type: "platform" };
62
+ }
63
+ const entry = PROVIDER_CATALOG.find((p) => p.id === provider);
64
+ if (entry?.setupMode === "keyless") {
65
+ return { type: "none" };
66
+ }
67
+ return credential ? { type: "api_key", credential } : null;
68
+ }
69
+
47
70
  // ---------------------------------------------------------------------------
48
71
  // ResolvedAuth — what the dispatcher hands to each adapter
49
72
  // ---------------------------------------------------------------------------
@@ -225,6 +225,63 @@ describe("POST inference/provider-connections (create)", () => {
225
225
  expect(result.auth).toEqual({ type: "none" });
226
226
  });
227
227
 
228
+ test("derives api_key auth from provider + credential when auth is omitted", async () => {
229
+ const result = (await call(
230
+ findHandler("inference_provider_connections_create"),
231
+ {
232
+ body: {
233
+ name: "derived-anthropic",
234
+ provider: "anthropic",
235
+ credential: "vault/anthropic/key",
236
+ },
237
+ },
238
+ )) as { auth: object };
239
+ expect(result.auth).toEqual({
240
+ type: "api_key",
241
+ credential: "vault/anthropic/key",
242
+ });
243
+ });
244
+
245
+ test("derives none auth for keyless providers when auth is omitted", async () => {
246
+ const result = (await call(
247
+ findHandler("inference_provider_connections_create"),
248
+ {
249
+ body: { name: "derived-ollama", provider: "ollama" },
250
+ },
251
+ )) as { auth: object };
252
+ expect(result.auth).toEqual({ type: "none" });
253
+ });
254
+
255
+ test("derives platform auth for the vellum provider when auth is omitted", async () => {
256
+ const result = (await call(
257
+ findHandler("inference_provider_connections_create"),
258
+ {
259
+ body: { name: "derived-vellum", provider: "vellum" },
260
+ },
261
+ )) as { auth: object };
262
+ expect(result.auth).toEqual({ type: "platform" });
263
+ });
264
+
265
+ test("throws 400 when auth is omitted and a keyed provider has no credential", async () => {
266
+ await expect(
267
+ call(findHandler("inference_provider_connections_create"), {
268
+ body: { name: "derived-no-cred", provider: "anthropic" },
269
+ }),
270
+ ).rejects.toBeInstanceOf(BadRequestError);
271
+ });
272
+
273
+ test("throws 400 when the derived credential is not a non-empty string", async () => {
274
+ await expect(
275
+ call(findHandler("inference_provider_connections_create"), {
276
+ body: {
277
+ name: "derived-bad-cred",
278
+ provider: "anthropic",
279
+ credential: "",
280
+ },
281
+ }),
282
+ ).rejects.toBeInstanceOf(BadRequestError);
283
+ });
284
+
228
285
  test("throws 409 when connection name already exists", async () => {
229
286
  seedConnection({
230
287
  name: "dup-name",
@@ -332,6 +389,59 @@ describe("PATCH inference/provider-connections/:name (update)", () => {
332
389
  }),
333
390
  ).rejects.toBeInstanceOf(BadRequestError);
334
391
  });
392
+
393
+ test("keeps stored auth when both auth and credential are omitted", async () => {
394
+ seedConnection({
395
+ name: "label-only",
396
+ provider: "openai",
397
+ auth: { type: "oauth_subscription", credential: "vault/chatgpt/token" },
398
+ });
399
+
400
+ const result = (await call(
401
+ findHandler("inference_provider_connections_update"),
402
+ {
403
+ pathParams: { name: "label-only" },
404
+ body: { label: "Renamed" },
405
+ },
406
+ )) as { auth: object; label: string | null };
407
+ expect(result.auth).toEqual({
408
+ type: "oauth_subscription",
409
+ credential: "vault/chatgpt/token",
410
+ });
411
+ expect(result.label).toBe("Renamed");
412
+ });
413
+
414
+ test("throws 400 on credential-only PATCH of an oauth_subscription connection", async () => {
415
+ seedConnection({
416
+ name: "chatgpt-subscription",
417
+ provider: "openai",
418
+ auth: { type: "oauth_subscription", credential: "vault/chatgpt/token" },
419
+ });
420
+
421
+ await expect(
422
+ call(findHandler("inference_provider_connections_update"), {
423
+ pathParams: { name: "chatgpt-subscription" },
424
+ body: { credential: "vault/other" },
425
+ }),
426
+ ).rejects.toBeInstanceOf(BadRequestError);
427
+ });
428
+
429
+ test("rotates to derived api_key auth when only credential is passed", async () => {
430
+ seedConnection({
431
+ name: "rotate-cred",
432
+ provider: "anthropic",
433
+ auth: { type: "api_key", credential: "vault/old" },
434
+ });
435
+
436
+ const result = (await call(
437
+ findHandler("inference_provider_connections_update"),
438
+ {
439
+ pathParams: { name: "rotate-cred" },
440
+ body: { credential: "vault/new" },
441
+ },
442
+ )) as { auth: object };
443
+ expect(result.auth).toEqual({ type: "api_key", credential: "vault/new" });
444
+ });
335
445
  });
336
446
 
337
447
  // ── DELETE ────────────────────────────────────────────────────────────────────
@@ -19,10 +19,12 @@ import { getIsPlatform } from "../../config/env-registry.js";
19
19
  import { getConfigReadOnly } from "../../config/loader.js";
20
20
  import { getDb } from "../../persistence/db-connection.js";
21
21
  import {
22
+ type Auth,
22
23
  AuthSchema,
23
24
  type ConnectionModel,
24
25
  ConnectionModelSchema,
25
26
  ConnectionProviderSchema,
27
+ deriveAuthForProvider,
26
28
  ProviderConnectionSchema,
27
29
  PROVIDERS_REQUIRING_BASE_URL_AND_MODELS,
28
30
  VALID_CONNECTION_PROVIDERS,
@@ -159,6 +161,28 @@ async function parseCustomProviderFields(
159
161
  return out;
160
162
  }
161
163
 
164
+ /**
165
+ * Derive the auth object for a body that omits `auth`, from the provider and
166
+ * the optional top-level `credential` field. Throws the 400s for the cases
167
+ * the derivation can't express: a malformed credential, or a provider that
168
+ * needs an API key when none was supplied.
169
+ */
170
+ function deriveConnectionAuth(provider: string, credential: unknown): Auth {
171
+ if (
172
+ credential !== undefined &&
173
+ (typeof credential !== "string" || credential.length === 0)
174
+ ) {
175
+ throw new BadRequestError("credential must be a non-empty string");
176
+ }
177
+ const derived = deriveAuthForProvider(provider, credential);
178
+ if (!derived) {
179
+ throw new BadRequestError(
180
+ `Provider "${provider}" requires an API key. Pass "credential" (a vault credential key) or an explicit "auth" object.`,
181
+ );
182
+ }
183
+ return derived;
184
+ }
185
+
162
186
  // ---------------------------------------------------------------------------
163
187
  // Handlers
164
188
  // ---------------------------------------------------------------------------
@@ -197,7 +221,9 @@ async function handleCreateConnection({ body = {} }: RouteHandlerArgs) {
197
221
  `Invalid provider "${String(provider)}". Valid: ${VALID_CONNECTION_PROVIDERS.join(", ")}`,
198
222
  );
199
223
  }
200
- const authResult = AuthSchema.safeParse(auth);
224
+ const authResult = AuthSchema.safeParse(
225
+ auth ?? deriveConnectionAuth(providerResult.data, body.credential),
226
+ );
201
227
  if (!authResult.success) {
202
228
  throw new BadRequestError(`Invalid auth: ${authResult.error.message}`);
203
229
  }
@@ -263,7 +289,27 @@ async function handleUpdateConnection({
263
289
  const existing = getConnection(getDb(), name);
264
290
  if (!existing) throw new NotFoundError(`Connection "${name}" not found.`);
265
291
 
266
- const auth = body.auth;
292
+ // `auth` is optional: an explicit object wins; a bare `credential` rotates
293
+ // the key by re-deriving from the provider; omitting both leaves the stored
294
+ // auth untouched (so label-only edits never disturb e.g. an
295
+ // oauth_subscription connection).
296
+ if (
297
+ body.auth === undefined &&
298
+ body.credential !== undefined &&
299
+ existing.auth.type === "oauth_subscription"
300
+ ) {
301
+ // Derivation would silently flip the auth type to api_key. Rotating a
302
+ // subscription token goes through the ChatGPT sign-in routes; switching
303
+ // to key auth requires an explicit `auth` object.
304
+ throw new BadRequestError(
305
+ `Connection "${name}" uses subscription auth, which "credential" cannot rotate. Re-run the ChatGPT sign-in flow, or pass an explicit "auth" object to switch auth types.`,
306
+ );
307
+ }
308
+ const auth =
309
+ body.auth ??
310
+ (body.credential !== undefined
311
+ ? deriveConnectionAuth(existing.provider, body.credential)
312
+ : existing.auth);
267
313
  const authResult = AuthSchema.safeParse(auth);
268
314
  if (!authResult.success) {
269
315
  throw new BadRequestError(`Invalid auth: ${authResult.error.message}`);
@@ -471,12 +517,13 @@ export const ROUTES: RouteDefinition[] = [
471
517
  },
472
518
  summary: "Create a provider connection",
473
519
  description:
474
- "Create a new named provider connection. Fails with 409 if a connection with this name already exists.",
520
+ "Create a new named provider connection. When auth is omitted it is derived from the provider (keyless providers get none, vellum gets platform, everything else needs credential for api_key auth). Fails with 409 if a connection with this name already exists.",
475
521
  tags: ["inference"],
476
522
  requestBody: z.object({
477
523
  name: z.string().min(1),
478
524
  provider: ConnectionProviderSchema,
479
- auth: AuthSchema,
525
+ auth: AuthSchema.optional(),
526
+ credential: z.string().min(1).optional(),
480
527
  label: z.string().min(1).optional(),
481
528
  base_url: z.string().url().nullable().optional(),
482
529
  models: z.array(ConnectionModelSchema).nullable().optional(),
@@ -499,11 +546,12 @@ export const ROUTES: RouteDefinition[] = [
499
546
  },
500
547
  summary: "Update a provider connection",
501
548
  description:
502
- "Update an existing connection. Cannot rename or change the provider. For the Vellum-managed connection (vellum) the auth is locked to platform; label remains editable.",
549
+ "Update an existing connection. Cannot rename or change the provider. Omitting auth keeps the stored auth; passing credential alone rotates the key via provider-derived api_key auth. For the Vellum-managed connection (vellum) the auth is locked to platform; label remains editable.",
503
550
  tags: ["inference"],
504
551
  pathParams: [{ name: "name", description: "Connection name" }],
505
552
  requestBody: z.object({
506
- auth: AuthSchema,
553
+ auth: AuthSchema.optional(),
554
+ credential: z.string().min(1).optional(),
507
555
  label: z.string().min(1).nullable().optional(),
508
556
  base_url: z.string().url().nullable().optional(),
509
557
  models: z.array(ConnectionModelSchema).nullable().optional(),