@vellumai/assistant 0.10.12-dev.202607281836.950299d → 0.10.12-dev.202607281935.fa0f06f

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 (49) hide show
  1. package/docs/architecture/memory.md +7 -0
  2. package/openapi.yaml +38 -2
  3. package/package.json +1 -1
  4. package/src/__tests__/agent-loop-history-repair.test.ts +108 -0
  5. package/src/__tests__/channel-readiness-service.test.ts +107 -1
  6. package/src/__tests__/conversation-slash.test.ts +91 -0
  7. package/src/__tests__/managed-profile-guard.test.ts +53 -0
  8. package/src/__tests__/platform-callback-registration.test.ts +132 -2
  9. package/src/__tests__/plugin-bootstrap.test.ts +2 -3
  10. package/src/__tests__/plugin-import-boundary-guard.test.ts +6 -0
  11. package/src/agent/loop.ts +33 -0
  12. package/src/cli/lib/__tests__/list-installed-plugins.test.ts +3 -3
  13. package/src/config/__tests__/webhook-routing.test.ts +229 -0
  14. package/src/config/webhook-routing.ts +55 -14
  15. package/src/daemon/conversation-agent-loop.ts +24 -1
  16. package/src/daemon/conversation-runtime-assembly.ts +6 -2
  17. package/src/daemon/conversation-slash.ts +5 -2
  18. package/src/inbound/platform-callback-registration.ts +44 -10
  19. package/src/inbound/public-ingress-urls.ts +40 -9
  20. package/src/persistence/conversation-group-migration.ts +14 -0
  21. package/src/persistence/group-crud.test.ts +59 -0
  22. package/src/persistence/group-crud.ts +21 -6
  23. package/src/persistence/schema/conversation-groups.ts +2 -0
  24. package/src/plugin-api/model-profiles.test.ts +28 -0
  25. package/src/plugin-api/model-profiles.ts +5 -2
  26. package/src/plugins/defaults/index.ts +0 -34
  27. package/src/plugins/defaults/main.ts +4 -17
  28. package/src/plugins/defaults/memory/src/memory-item-routes.test.ts +22 -0
  29. package/src/plugins/defaults/memory/src/memory-item-routes.ts +22 -3
  30. package/src/plugins/defaults/memory/src/memory-v2-routes.ts +5 -2
  31. package/src/runtime/channel-readiness-service.ts +8 -10
  32. package/src/runtime/routes/conversation-query-routes.ts +29 -7
  33. package/src/runtime/routes/conversation-routes.ts +6 -2
  34. package/src/runtime/routes/group-routes.ts +41 -3
  35. package/src/runtime/routes/inference-profile-session-handler.ts +6 -2
  36. package/src/runtime/routes/inference-profiles-routes.ts +10 -5
  37. package/src/runtime/routes/inference-provider-connection-routes.ts +9 -3
  38. package/src/runtime/routes/inference-send-routes.ts +6 -2
  39. package/src/runtime/routes/llm-call-sites-routes.ts +5 -2
  40. package/src/runtime/routes/webhook-routes.ts +1 -13
  41. package/src/telegram/__tests__/webhook-health.test.ts +76 -13
  42. package/src/telegram/webhook-health.ts +1 -1
  43. package/src/tools/workflows/manage-workflows.ts +5 -2
  44. package/src/workflows/leaf-runner.ts +9 -2
  45. package/src/__tests__/history-repair-hook.test.ts +0 -392
  46. package/src/agent/history-repair/hooks/post-model-call.ts +0 -55
  47. package/src/agent/history-repair/hooks/stop.ts +0 -21
  48. package/src/agent/history-repair/hooks/user-prompt-submit.ts +0 -34
  49. package/src/agent/history-repair/repair-state-store.ts +0 -51
@@ -123,6 +123,13 @@ build can never drift. The same predicate gates procedural-memory-as-skills,
123
123
  so both v3-tier features honor the Memory opt-out identically. `GET /v1/memory-graph-node` serves node detail,
124
124
  including `buffer:` ids for pending entries.
125
125
 
126
+ `GET /v1/memory/stats` also reports `tier` (`memoryTier()`: `off` / `v1` /
127
+ `v2` / `v3`), which is what lets the web Memory tab explain an unavailable
128
+ graph instead of stating a bare "not available": `off` is the user's own
129
+ Memory opt-out and points at Settings, while `v1`/`v2` point at the v3
130
+ migration. `graph_supported` is exactly `tier === "v3"`, so the capability
131
+ bit and its explanation are derived from one gate.
132
+
126
133
  ## Capture beyond `remember`
127
134
 
128
135
  - **Retrospective** (`memory-retrospective-*.ts`): periodic per-conversation
package/openapi.yaml CHANGED
@@ -11875,6 +11875,11 @@ paths:
11875
11875
  type: string
11876
11876
  name:
11877
11877
  type: string
11878
+ icon:
11879
+ description: Client-chosen icon name; null when the group has none
11880
+ anyOf:
11881
+ - type: string
11882
+ - type: "null"
11878
11883
  sortPosition:
11879
11884
  type: number
11880
11885
  isSystemGroup:
@@ -11904,6 +11909,11 @@ paths:
11904
11909
  name:
11905
11910
  type: string
11906
11911
  description: Group name
11912
+ icon:
11913
+ description: Client-chosen icon name
11914
+ anyOf:
11915
+ - type: string
11916
+ - type: "null"
11907
11917
  required:
11908
11918
  - name
11909
11919
  responses:
@@ -11918,6 +11928,11 @@ paths:
11918
11928
  type: string
11919
11929
  name:
11920
11930
  type: string
11931
+ icon:
11932
+ description: Client-chosen icon name; null when the group has none
11933
+ anyOf:
11934
+ - type: string
11935
+ - type: "null"
11921
11936
  sortPosition:
11922
11937
  type: number
11923
11938
  isSystemGroup:
@@ -11953,7 +11968,7 @@ paths:
11953
11968
  patch:
11954
11969
  operationId: groups_by_groupId_patch
11955
11970
  summary: Update group
11956
- description: Update a conversation group's name or sort position.
11971
+ description: Update a conversation group's name, icon, or sort position.
11957
11972
  tags:
11958
11973
  - groups
11959
11974
  parameters:
@@ -11971,6 +11986,11 @@ paths:
11971
11986
  properties:
11972
11987
  name:
11973
11988
  type: string
11989
+ icon:
11990
+ description: Client-chosen icon name; null clears it
11991
+ anyOf:
11992
+ - type: string
11993
+ - type: "null"
11974
11994
  sortPosition:
11975
11995
  type: number
11976
11996
  responses:
@@ -11985,6 +12005,11 @@ paths:
11985
12005
  type: string
11986
12006
  name:
11987
12007
  type: string
12008
+ icon:
12009
+ description: Client-chosen icon name; null when the group has none
12010
+ anyOf:
12011
+ - type: string
12012
+ - type: "null"
11988
12013
  sortPosition:
11989
12014
  type: number
11990
12015
  isSystemGroup:
@@ -17748,7 +17773,9 @@ paths:
17748
17773
  "Return a cheap count of concept pages from the cached memory page index, for glanceable surfaces like the
17749
17774
  identity Memory card. Counts concept pages only and never builds the memory-concept graph. Also reports
17750
17775
  graph_supported: whether the memory-concept graph is available for this assistant (memory enabled and v3 live),
17751
- so callers can gate the graph entry point without building the graph."
17776
+ so callers can gate the graph entry point without building the graph, plus tier: the coarse memory tier
17777
+ explaining why the graph is unavailable (off = the user's Memory opt-out, v1/v2 = a legacy engine that has not
17778
+ migrated to v3)."
17752
17779
  tags:
17753
17780
  - memory
17754
17781
  responses:
@@ -17765,9 +17792,18 @@ paths:
17765
17792
  graph_supported:
17766
17793
  type: boolean
17767
17794
  description: Whether the memory-concept graph is available (memory enabled and v3 live)
17795
+ tier:
17796
+ type: string
17797
+ enum:
17798
+ - off
17799
+ - v1
17800
+ - v2
17801
+ - v3
17802
+ description: Coarse memory tier for this assistant; graph_supported is exactly tier === 'v3'
17768
17803
  required:
17769
17804
  - concepts
17770
17805
  - graph_supported
17806
+ - tier
17771
17807
  additionalProperties: false
17772
17808
  /v1/memory/v2/backfill:
17773
17809
  post:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.12-dev.202607281836.950299d",
3
+ "version": "0.10.12-dev.202607281935.fa0f06f",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,108 @@
1
+ import { beforeEach, describe, expect, test } from "bun:test";
2
+
3
+ import type { AgentEvent } from "../agent/loop.js";
4
+ import { AgentLoop } from "../agent/loop.js";
5
+ import { resetPluginRegistryAndRegisterDefaults } from "../plugins/defaults/index.js";
6
+ import type {
7
+ Message,
8
+ Provider,
9
+ ProviderResponse,
10
+ } from "../providers/types.js";
11
+ import { textResponse } from "./helpers/mock-provider.js";
12
+
13
+ /**
14
+ * The agent loop invokes history repair as built-in daemon logic (not a
15
+ * plugin): on a provider rejection whose message denotes a tool-use/tool-result
16
+ * pairing or ordering violation, it deep-repairs the working history and
17
+ * re-issues the call once per turn. These tests exercise that loop-integrated
18
+ * recovery; the repair transform itself is covered by `history-repair.test.ts`.
19
+ */
20
+
21
+ const userMessage: Message = {
22
+ role: "user",
23
+ content: [{ type: "text", text: "Hello" }],
24
+ };
25
+
26
+ // A provider whose message-ordering rejection matches `ORDERING_ERROR_PATTERNS`,
27
+ // so the loop treats it as repairable.
28
+ const ORDERING_REJECTION =
29
+ "messages: `tool_use` ids must have corresponding `tool_result` blocks";
30
+
31
+ /**
32
+ * Provider that rejects the first `errorCount` calls with an ordering error,
33
+ * then returns a plain text reply. Records how many times it was called.
34
+ */
35
+ function orderingRejectionProvider(errorCount: number): {
36
+ provider: Provider;
37
+ callCount: () => number;
38
+ } {
39
+ let calls = 0;
40
+ const provider: Provider = {
41
+ name: "test-ordering",
42
+ async sendMessage(): Promise<ProviderResponse> {
43
+ calls += 1;
44
+ if (calls <= errorCount) {
45
+ throw new Error(ORDERING_REJECTION);
46
+ }
47
+ return textResponse("recovered");
48
+ },
49
+ };
50
+ return { provider, callCount: () => calls };
51
+ }
52
+
53
+ describe("agent loop — built-in history-repair recovery", () => {
54
+ beforeEach(() => {
55
+ resetPluginRegistryAndRegisterDefaults();
56
+ });
57
+
58
+ test("deep-repairs and retries once on a provider ordering rejection", async () => {
59
+ const { provider, callCount } = orderingRejectionProvider(1);
60
+ const loop = new AgentLoop({
61
+ provider,
62
+ systemPrompt: "system",
63
+ conversationId: "test-conversation",
64
+ });
65
+
66
+ const events: AgentEvent[] = [];
67
+ const { history } = await loop.run({
68
+ requestId: "test-request",
69
+ messages: [userMessage],
70
+ onEvent: (e) => {
71
+ events.push(e);
72
+ },
73
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
74
+ });
75
+
76
+ // Initial call rejected → deep-repair → one retry that succeeded.
77
+ expect(callCount()).toBe(2);
78
+ expect(history[history.length - 1]).toEqual({
79
+ role: "assistant",
80
+ content: [{ type: "text", text: "recovered" }],
81
+ });
82
+ expect(events.some((e) => e.type === "error")).toBe(false);
83
+ });
84
+
85
+ test("bounds ordering-repair recovery to one attempt per turn", async () => {
86
+ // Provider keeps rejecting: the loop must not retry forever.
87
+ const { provider, callCount } = orderingRejectionProvider(Infinity);
88
+ const loop = new AgentLoop({
89
+ provider,
90
+ systemPrompt: "system",
91
+ conversationId: "test-conversation",
92
+ });
93
+
94
+ const events: AgentEvent[] = [];
95
+ await loop.run({
96
+ requestId: "test-request",
97
+ messages: [userMessage],
98
+ onEvent: (e) => {
99
+ events.push(e);
100
+ },
101
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
102
+ });
103
+
104
+ // Initial call + exactly one deep-repair retry, then the rejection surfaces.
105
+ expect(callCount()).toBe(2);
106
+ expect(events.some((e) => e.type === "error")).toBe(true);
107
+ });
108
+ });
@@ -6,6 +6,8 @@ import { setConfig } from "./helpers/set-config.js";
6
6
  let mockSecureKeys: Record<string, string>;
7
7
  let mockHasTwilioCredentials: boolean;
8
8
  let mockGetIsPlatform: boolean;
9
+ /** Platform credentials present: base URL + assistant ID + assistant API key. */
10
+ let mockPlatformConnected: boolean;
9
11
 
10
12
  mock.module("../calls/twilio-rest.js", () => ({
11
13
  getPhoneNumberSid: async () => null,
@@ -24,7 +26,22 @@ mock.module("../config/env-registry.js", () => ({
24
26
  getIsPlatform: () => mockGetIsPlatform,
25
27
  }));
26
28
 
27
- mock.module("../inbound/platform-callback-registration.js", () => ({}));
29
+ // Spread the real module: replacing it wholesale drops the exports peer test
30
+ // files import from it, which breaks their named-import validation whenever
31
+ // this mock wins evaluation in a combined run.
32
+ const actualRegistration =
33
+ await import("../inbound/platform-callback-registration.js");
34
+ mock.module("../inbound/platform-callback-registration.js", () => ({
35
+ ...actualRegistration,
36
+ resolvePlatformCallbackRegistrationContext: async () => ({
37
+ isPlatform: mockGetIsPlatform,
38
+ platformBaseUrl: "https://api.vellum.ai",
39
+ assistantId: mockPlatformConnected ? "assistant-123" : "",
40
+ hasAssistantApiKey: mockPlatformConnected,
41
+ authHeader: mockPlatformConnected ? "Api-Key secret" : null,
42
+ enabled: mockPlatformConnected,
43
+ }),
44
+ }));
28
45
 
29
46
  mock.module("../security/secure-keys.js", () => ({
30
47
  getSecureKeyAsync: async (key: string) => mockSecureKeys[key] ?? null,
@@ -85,6 +102,7 @@ describe("ChannelReadinessService", () => {
85
102
  mockSecureKeys = {};
86
103
  mockHasTwilioCredentials = false;
87
104
  mockGetIsPlatform = false;
105
+ mockPlatformConnected = false;
88
106
  });
89
107
 
90
108
  test("local checks run on every call (no caching of local results)", async () => {
@@ -278,6 +296,94 @@ describe("ChannelReadinessService", () => {
278
296
  });
279
297
  });
280
298
 
299
+ test("telegram readiness accepts a platform-connected assistant with no ingress", async () => {
300
+ // LUM-2882: `webhooks register telegram` resolves a platform callback URL
301
+ // in this configuration, so reporting missing ingress here would hide a
302
+ // registration that is really in place (or really broken).
303
+ mockPlatformConnected = true;
304
+ mockSecureKeys[credentialKey("telegram", "bot_token")] = "123:abc";
305
+ mockSecureKeys[credentialKey("telegram", "webhook_secret")] = "secret";
306
+
307
+ const readiness = createReadinessService();
308
+ const [snapshot] = await readiness.getReadiness("telegram");
309
+
310
+ expect(snapshot.ready).toBe(true);
311
+ expect(snapshot.localChecks).toContainEqual({
312
+ name: "ingress",
313
+ passed: true,
314
+ message: "Managed platform callback routing is configured",
315
+ });
316
+ });
317
+
318
+ test("phone readiness accepts a platform-connected assistant with no ingress", async () => {
319
+ mockPlatformConnected = true;
320
+ mockHasTwilioCredentials = true;
321
+ setConfig("twilio", { phoneNumber: "+15550123" });
322
+
323
+ const readiness = createReadinessService();
324
+ const [snapshot] = await readiness.getReadiness("phone");
325
+
326
+ expect(snapshot.ready).toBe(true);
327
+ expect(snapshot.localChecks).toContainEqual({
328
+ name: "ingress",
329
+ passed: true,
330
+ message: "Managed platform callback routing is configured",
331
+ });
332
+ });
333
+
334
+ test("configured ingress beats the platform-connected fallback", async () => {
335
+ // Any logged-in local assistant holds platform credentials for the LLM
336
+ // proxy. Reporting managed routing here would mislabel a webhook that
337
+ // `webhooks register` resolves to the self-hosted URL.
338
+ mockPlatformConnected = true;
339
+ mockSecureKeys[credentialKey("telegram", "bot_token")] = "123:abc";
340
+ mockSecureKeys[credentialKey("telegram", "webhook_secret")] = "secret";
341
+ setConfig("ingress", { publicBaseUrl: "https://tunnel.example.com" });
342
+
343
+ const readiness = createReadinessService();
344
+ const [snapshot] = await readiness.getReadiness("telegram");
345
+
346
+ expect(snapshot.ready).toBe(true);
347
+ expect(snapshot.localChecks).toContainEqual({
348
+ name: "ingress",
349
+ passed: true,
350
+ message: "Public ingress URL is configured",
351
+ });
352
+ });
353
+
354
+ test("explicit ingress opt-out blocks the platform-connected fallback", async () => {
355
+ // Switching ingress off is a decision not to accept inbound webhooks, not
356
+ // an invitation to route them through the platform instead.
357
+ mockPlatformConnected = true;
358
+ mockSecureKeys[credentialKey("telegram", "bot_token")] = "123:abc";
359
+ mockSecureKeys[credentialKey("telegram", "webhook_secret")] = "secret";
360
+ setConfig("ingress", { enabled: false });
361
+
362
+ const readiness = createReadinessService();
363
+ const [snapshot] = await readiness.getReadiness("telegram");
364
+
365
+ expect(snapshot.ready).toBe(false);
366
+ expect(snapshot.reasons).toContainEqual({
367
+ code: "ingress",
368
+ text: "No public ingress URL or managed callback route is configured",
369
+ });
370
+ });
371
+
372
+ test("email readiness ignores platform connectivity", async () => {
373
+ // Email passes `allowManagedCallbacks: false`, so the managed tiers are
374
+ // not offered to it and only a real ingress URL counts.
375
+ mockPlatformConnected = true;
376
+
377
+ const readiness = createReadinessService();
378
+ const [snapshot] = await readiness.getReadiness("email");
379
+
380
+ expect(snapshot.localChecks).toContainEqual({
381
+ name: "ingress",
382
+ passed: false,
383
+ message: "Public ingress URL is not configured or disabled",
384
+ });
385
+ });
386
+
281
387
  test("phone readiness accepts configured public ingress", async () => {
282
388
  mockHasTwilioCredentials = true;
283
389
  setConfig("twilio", { phoneNumber: "+15550123" });
@@ -0,0 +1,91 @@
1
+ import { beforeEach, describe, expect, test } from "bun:test";
2
+
3
+ import { getConfig } from "../config/loader.js";
4
+ import { setConfig } from "./helpers/set-config.js";
5
+
6
+ // ─── Fixture config ─────────────────────────────────────────────────────────
7
+
8
+ let mockLlm: Record<string, unknown> = {};
9
+
10
+ const { resolveSlash } = await import("../daemon/conversation-slash.js");
11
+
12
+ /**
13
+ * Install the current fixture `llm` config for real. A schema-valid baseline
14
+ * is seeded first so the loader caches a config object; `llm` is then
15
+ * overwritten on that live cached object so fixtures reach the resolver
16
+ * exactly as authored.
17
+ */
18
+ function applyConfig(): void {
19
+ setConfig("llm", { profiles: {} });
20
+ const config = getConfig() as { llm: unknown };
21
+ config.llm = mockLlm;
22
+ }
23
+
24
+ beforeEach(() => {
25
+ mockLlm = { profiles: {} };
26
+ applyConfig();
27
+ });
28
+
29
+ // ─── Tests ──────────────────────────────────────────────────────────────────
30
+
31
+ describe("/model list", () => {
32
+ test("lists the code-catalog defaults", async () => {
33
+ const result = await resolveSlash("/model");
34
+ expect(result.kind).toBe("unknown");
35
+ const message = (result as { message: string }).message;
36
+ expect(message).toContain("`balanced`");
37
+ expect(message).toContain("`quality-optimized`");
38
+ expect(message).toContain("`cost-optimized`");
39
+ });
40
+
41
+ test("default profile descriptions follow the default provider's column", async () => {
42
+ // The BYOK and vellum columns carry different description strings for
43
+ // quality-optimized and cost-optimized; the listing must show the column
44
+ // that actually dispatches on this install.
45
+ mockLlm = {
46
+ profiles: {},
47
+ defaultProvider: { provider: "anthropic" },
48
+ };
49
+ applyConfig();
50
+
51
+ const message = ((await resolveSlash("/model")) as { message: string })
52
+ .message;
53
+ expect(message).toContain("Best results with the most capable model");
54
+ expect(message).toContain("Fastest responses at lower cost");
55
+ expect(message).not.toContain("(DeepSeek V4 Flash)");
56
+ });
57
+
58
+ test("descriptions use the managed column without a default provider", async () => {
59
+ const message = ((await resolveSlash("/model")) as { message: string })
60
+ .message;
61
+ expect(message).toContain(
62
+ "High-quality results with the most capable model",
63
+ );
64
+ expect(message).toContain(
65
+ "Fastest responses at lower cost (DeepSeek V4 Flash)",
66
+ );
67
+ });
68
+ });
69
+
70
+ describe("/model switch", () => {
71
+ test("rejects an unknown profile with the available set", async () => {
72
+ const result = await resolveSlash("/model nope");
73
+ expect(result.kind).toBe("unknown");
74
+ const message = (result as { message: string }).message;
75
+ expect(message).toContain("`nope` not found");
76
+ expect(message).toContain("`balanced`");
77
+ });
78
+
79
+ test("validates against the same set under a BYO default provider", async () => {
80
+ mockLlm = {
81
+ profiles: {},
82
+ defaultProvider: { provider: "anthropic" },
83
+ };
84
+ applyConfig();
85
+
86
+ const result = await resolveSlash("/model nope");
87
+ expect((result as { message: string }).message).toContain(
88
+ "`nope` not found",
89
+ );
90
+ });
91
+ });
@@ -1197,6 +1197,59 @@ describe("code-owned default profiles — wire view and write normalization", ()
1197
1197
  });
1198
1198
  });
1199
1199
 
1200
+ describe("code-owned default profiles — BYO default provider wire view", () => {
1201
+ // With llm.defaultProvider set, the wire view must show the column of the
1202
+ // intent × provider matrix that actually dispatches — not the vellum
1203
+ // column — and the write path must echo-strip against that same view or an
1204
+ // honest GET → write round-trip is rejected.
1205
+ test("GET materializes the default provider's column for default profiles", async () => {
1206
+ seedRawConfig({
1207
+ llm: { defaultProvider: { provider: "anthropic" }, profiles: {} },
1208
+ });
1209
+ const response = (await getRoute.handler({})) as Record<string, any>;
1210
+ const wireBalanced = response.llm.profiles.balanced;
1211
+ expect(wireBalanced.provider).toBe("anthropic");
1212
+ expect(wireBalanced.model).toBe("claude-sonnet-4-6");
1213
+ expect(wireBalanced.provider_connection).toBe("anthropic-personal");
1214
+ expect(response.llm.profiles["quality-optimized"].provider).toBe(
1215
+ "anthropic",
1216
+ );
1217
+ });
1218
+
1219
+ test("GET → PATCH round-trip of the BYO wire view is accepted and keeps disk stubs thin", async () => {
1220
+ seedRawConfig({
1221
+ llm: {
1222
+ defaultProvider: { provider: "anthropic" },
1223
+ profiles: { balanced: { source: "managed", status: "disabled" } },
1224
+ },
1225
+ });
1226
+ const response = (await getRoute.handler({})) as Record<string, any>;
1227
+ const result = await patchRoute.handler({
1228
+ body: { llm: { profiles: response.llm.profiles } },
1229
+ });
1230
+ expect(result).toHaveProperty("llm");
1231
+ expectOneCommitCycle();
1232
+ expect(savedProfile("balanced")).toEqual({
1233
+ source: "managed",
1234
+ status: "disabled",
1235
+ });
1236
+ // Echoes of absent defaults reduce to a no-op managed stub.
1237
+ expect(savedProfile("quality-optimized")).toEqual({ source: "managed" });
1238
+ });
1239
+
1240
+ test("GET → SET llm round-trip of the BYO wire view is accepted", async () => {
1241
+ seedRawConfig({
1242
+ llm: { defaultProvider: { provider: "anthropic" }, profiles: {} },
1243
+ });
1244
+ const response = (await getRoute.handler({})) as Record<string, any>;
1245
+ const result = await setRoute.handler({
1246
+ body: { path: "llm", value: response.llm },
1247
+ });
1248
+ expect(result).toHaveProperty("ok");
1249
+ expect(savedProfile("balanced")).toEqual({ source: "managed" });
1250
+ });
1251
+ });
1252
+
1200
1253
  describe("code-owned default profiles — leaf SET source stamping", () => {
1201
1254
  test("a leaf SET creating a managed entry stamps the managed marker", async () => {
1202
1255
  seedRawConfig({ llm: { profiles: {} } });
@@ -33,8 +33,14 @@ mock.module("../security/secure-keys.js", () => ({
33
33
  const originalFetch = globalThis.fetch;
34
34
  const originalEnvCredential = process.env.ASSISTANT_API_KEY;
35
35
 
36
- const { registerCallbackRoute, resolvePlatformCallbackRegistrationContext } =
37
- await import("../inbound/platform-callback-registration.js");
36
+ const {
37
+ registerCallbackRoute,
38
+ resolveCallbackUrl,
39
+ resolvePlatformCallbackRegistrationContext,
40
+ } = await import("../inbound/platform-callback-registration.js");
41
+
42
+ const { PublicIngressDisabledError } =
43
+ await import("../inbound/public-ingress-urls.js");
38
44
 
39
45
  describe("platform callback registration", () => {
40
46
  beforeEach(() => {
@@ -150,3 +156,127 @@ describe("platform callback registration", () => {
150
156
  ).resolves.toBe("https://platform.example.com/v1/gateway/callbacks/x/");
151
157
  });
152
158
  });
159
+
160
+ /**
161
+ * `resolveCallbackUrl` drives Twilio voice/status callbacks and OAuth redirect
162
+ * URIs. Its tier order has to match `handleWebhooksRegister` in
163
+ * `runtime/routes/webhook-routes.ts` and `hasWebhookRoutingConfigured` in
164
+ * `config/webhook-routing.ts` (LUM-2882).
165
+ */
166
+ describe("resolveCallbackUrl resolution order", () => {
167
+ const PLATFORM_URL = "https://platform.example.com/v1/gateway/callbacks/x/";
168
+
169
+ /** Stand in for a URL builder that cannot resolve a public ingress URL. */
170
+ function noIngress(): string {
171
+ throw new Error(
172
+ "No public base URL configured. Set ingress.publicBaseUrl in config.",
173
+ );
174
+ }
175
+
176
+ /** Stand in for a URL builder reached while ingress is switched off. */
177
+ function ingressDisabled(): string {
178
+ throw new PublicIngressDisabledError();
179
+ }
180
+
181
+ function seedPlatformCredentials(): void {
182
+ mockSecureKeys[credentialKey("vellum", "platform_base_url")] =
183
+ "https://platform.example.com";
184
+ mockSecureKeys[credentialKey("vellum", "platform_assistant_id")] =
185
+ "11111111-2222-4333-8444-555555555555";
186
+ mockSecureKeys[credentialKey("vellum", "assistant_api_key")] =
187
+ "ast-managed-key";
188
+ }
189
+
190
+ let registerCalls: number;
191
+
192
+ beforeEach(() => {
193
+ mockIsPlatform = false;
194
+ mockPlatformBaseUrl = "";
195
+ mockPlatformAssistantId = "";
196
+ mockSecureKeys = {};
197
+ delete process.env.ASSISTANT_API_KEY;
198
+ registerCalls = 0;
199
+ globalThis.fetch = mock(async () => {
200
+ registerCalls++;
201
+ return new Response(
202
+ JSON.stringify({
203
+ callback_url: PLATFORM_URL,
204
+ callback_path: "webhooks/twilio/voice",
205
+ type: "twilio_voice",
206
+ assistant_id: "11111111-2222-4333-8444-555555555555",
207
+ }),
208
+ { status: 201, headers: { "content-type": "application/json" } },
209
+ );
210
+ }) as unknown as typeof fetch;
211
+ });
212
+
213
+ afterEach(() => {
214
+ globalThis.fetch = originalFetch;
215
+ });
216
+
217
+ test("platform pods register with the platform gateway", async () => {
218
+ mockIsPlatform = true;
219
+ seedPlatformCredentials();
220
+
221
+ // The direct supplier is never evaluated on a pod: there is no ingress of
222
+ // its own to advertise, and evaluating it would throw.
223
+ await expect(
224
+ resolveCallbackUrl(noIngress, "webhooks/twilio/voice", "twilio_voice"),
225
+ ).resolves.toBe(PLATFORM_URL);
226
+ expect(registerCalls).toBe(1);
227
+ });
228
+
229
+ test("a configured ingress wins over platform connectivity", async () => {
230
+ seedPlatformCredentials();
231
+
232
+ await expect(
233
+ resolveCallbackUrl(
234
+ () => "https://tunnel.example.com/webhooks/twilio/voice",
235
+ "webhooks/twilio/voice",
236
+ "twilio_voice",
237
+ ),
238
+ ).resolves.toBe("https://tunnel.example.com/webhooks/twilio/voice");
239
+ expect(registerCalls).toBe(0);
240
+ });
241
+
242
+ test("a platform-connected assistant with no ingress registers with the platform", async () => {
243
+ // LUM-2882: this used to return the direct builder's throw because the
244
+ // platform branch was gated on IS_PLATFORM, which is only true on a pod.
245
+ seedPlatformCredentials();
246
+
247
+ await expect(
248
+ resolveCallbackUrl(noIngress, "webhooks/twilio/voice", "twilio_voice"),
249
+ ).resolves.toBe(PLATFORM_URL);
250
+ expect(registerCalls).toBe(1);
251
+ });
252
+
253
+ test("query parameters are appended to the platform URL", async () => {
254
+ seedPlatformCredentials();
255
+
256
+ await expect(
257
+ resolveCallbackUrl(noIngress, "webhooks/twilio/voice", "twilio_voice", {
258
+ callSessionId: "conv-xyz",
259
+ }),
260
+ ).resolves.toBe(`${PLATFORM_URL}?callSessionId=conv-xyz`);
261
+ });
262
+
263
+ test("an explicit ingress opt-out is not routed around", async () => {
264
+ seedPlatformCredentials();
265
+
266
+ await expect(
267
+ resolveCallbackUrl(
268
+ ingressDisabled,
269
+ "webhooks/twilio/voice",
270
+ "twilio_voice",
271
+ ),
272
+ ).rejects.toThrow("Public ingress is disabled");
273
+ expect(registerCalls).toBe(0);
274
+ });
275
+
276
+ test("without platform credentials the ingress error surfaces unchanged", async () => {
277
+ await expect(
278
+ resolveCallbackUrl(noIngress, "webhooks/twilio/voice", "twilio_voice"),
279
+ ).rejects.toThrow("No public base URL configured");
280
+ expect(registerCalls).toBe(0);
281
+ });
282
+ });
@@ -217,10 +217,9 @@ describe("plugin bootstrap", () => {
217
217
  const names = getRegisteredPlugins().map((p) => p.manifest.name);
218
218
  expect(names).not.toContain("breaking-user-plugin");
219
219
  // AND every first-party default survived, so core turn behavior (memory
220
- // retrieval, history repair, title generation) keeps running in degraded
221
- // mode instead of being torn down with the failing plugin
220
+ // retrieval, title generation) keeps running in degraded mode instead of
221
+ // being torn down with the failing plugin
222
222
  expect(names).toContain("default-memory");
223
- expect(names).toContain("default-history-repair");
224
223
  expect(names).toContain("default-title-generate");
225
224
  });
226
225