@vellumai/assistant 0.10.11-dev.202607221933.baa2119 → 0.10.11-dev.202607222129.31c06e5

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 (59) hide show
  1. package/node_modules/@vellumai/gateway-client/src/__tests__/binding-strength-contract.test.ts +122 -0
  2. package/node_modules/@vellumai/gateway-client/src/binding-strength-contract.ts +155 -0
  3. package/node_modules/@vellumai/gateway-client/src/index.ts +14 -0
  4. package/package.json +1 -1
  5. package/src/__tests__/approval-source-link.test.ts +208 -0
  6. package/src/__tests__/btw-routes.test.ts +13 -2
  7. package/src/__tests__/conversation-store-ephemeral.test.ts +182 -0
  8. package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -1
  9. package/src/__tests__/slack-notification-approval-card.test.ts +103 -20
  10. package/src/__tests__/tool-approval-seed-content-blocks.test.ts +179 -96
  11. package/src/__tests__/ui-choice-copy-surfaces.test.ts +144 -3
  12. package/src/api/events/memory-recalled.ts +59 -0
  13. package/src/api/events/memory-status.ts +29 -0
  14. package/src/api/events/service-group-update-complete.ts +29 -0
  15. package/src/api/events/service-group-update-progress.ts +23 -0
  16. package/src/api/events/service-group-update-starting.ts +26 -0
  17. package/src/api/index.ts +36 -1
  18. package/src/api/surfaces.ts +77 -21
  19. package/src/calls/__tests__/voice-triage-escalate.test.ts +58 -3
  20. package/src/calls/voice-session-bridge.ts +6 -2
  21. package/src/calls/voice-triage-escalate.ts +30 -1
  22. package/src/config/feature-flag-registry.json +9 -0
  23. package/src/daemon/conversation-store.ts +14 -2
  24. package/src/daemon/conversation-surfaces.ts +78 -168
  25. package/src/daemon/conversation-tool-setup.ts +7 -3
  26. package/src/daemon/handlers/shared.ts +11 -1
  27. package/src/daemon/message-types/memory.ts +8 -46
  28. package/src/daemon/message-types/surfaces.ts +1 -1
  29. package/src/daemon/message-types/upgrades.ts +11 -28
  30. package/src/daemon/trust-context-types.ts +8 -0
  31. package/src/messaging/channel-binding-schema.ts +6 -2
  32. package/src/messaging/providers/slack/approval-source.ts +87 -0
  33. package/src/messaging/providers/slack/deep-link.ts +45 -8
  34. package/src/messaging/providers/slack/message-metadata.ts +16 -0
  35. package/src/notifications/AGENTS.md +2 -0
  36. package/src/notifications/access-request-copy.ts +10 -21
  37. package/src/notifications/adapters/slack.ts +67 -13
  38. package/src/notifications/approval-card-data.ts +58 -16
  39. package/src/notifications/broadcaster.ts +41 -19
  40. package/src/notifications/guardian-question-mode.ts +81 -0
  41. package/src/notifications/types.ts +5 -0
  42. package/src/persistence/delivery-crud.ts +48 -1
  43. package/src/persistence/migrations/347-delete-stray-greeting-conversation.ts +46 -0
  44. package/src/persistence/migrations/__tests__/347-delete-stray-greeting-conversation.test.ts +100 -0
  45. package/src/persistence/steps.ts +2 -0
  46. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +2 -2
  47. package/src/plugins/mtime-cache.ts +21 -10
  48. package/src/runtime/approval-source-link.ts +107 -0
  49. package/src/runtime/confirmation-request-guardian-bridge.ts +9 -0
  50. package/src/runtime/introduction-policy.ts +23 -54
  51. package/src/runtime/routes/btw-routes.ts +9 -2
  52. package/src/runtime/routes/inbound-message-handler.ts +5 -13
  53. package/src/runtime/routes/upgrade-broadcast-routes.ts +6 -8
  54. package/src/runtime/tool-grant-request-helper.ts +14 -0
  55. package/src/tools/registry.ts +26 -17
  56. package/src/tools/tool-approval-handler.ts +2 -0
  57. package/src/tools/types.ts +8 -0
  58. package/src/tools/ui-surface/definitions.ts +20 -16
  59. package/src/tools/ui-surface/surface-shape-docs.ts +21 -6
@@ -428,18 +428,25 @@ export function unregisterPluginTools(pluginName: string): void {
428
428
  * Pull the active user-plugin tool set from the plugin mtime-cache into the
429
429
  * registry. This is the pull half of the plugin-tool relationship — the
430
430
  * mtime-cache never writes to the registry; instead this reconcile reads
431
- * {@link import("../plugins/mtime-cache.js").getActiveUserPluginTools} (which
432
- * syncs against the source-versions sentinel first) and diffs the result into
433
- * the registry: plugins that vanished are unregistered, new plugins register,
434
- * and a plugin whose per-tool source mtimes moved is re-registered. Mirrors
435
- * how hooks resolve through `getUserHookEntriesFor`.
431
+ * {@link import("../plugins/mtime-cache.js").getActiveUserPluginTools} and diffs
432
+ * the result into the registry: plugins that vanished are unregistered, new
433
+ * plugins register, and a plugin whose per-tool source mtimes moved is
434
+ * re-registered. Mirrors how hooks resolve through `getUserHookEntriesFor`.
436
435
  *
437
- * Idempotent, cheap when nothing changed (one sentinel stat + fingerprint
438
- * compares), and concurrency-safe (concurrent callers coalesce onto one
439
- * in-flight reconcile). Runs as the final step of `initializeTools()` (at
440
- * daemon boot the plugin cache is already populated by then), and
441
- * fire-and-forget from the per-turn conversation tool resolver — the same
442
- * cadence `loadWorkspaceTools` runs on.
436
+ * This is a pure read of the plugin cache — it does NOT reconcile the cache
437
+ * against the source-versions sentinel, so it never activates a plugin or runs
438
+ * an `init` hook. Cache reconciliation is owned by the hook-dispatch gate and
439
+ * the boot/install paths (see `getActiveUserPluginTools`); this pull picks up
440
+ * whatever they last landed. That keeps tool registration decoupled from plugin
441
+ * lifecycle: sidecar workers call `initializeTools()` for their own tool
442
+ * surface and must never run a plugin's `init` as a side effect.
443
+ *
444
+ * Idempotent, cheap when nothing changed (a fingerprint compare per plugin),
445
+ * and concurrency-safe (concurrent callers coalesce onto one in-flight
446
+ * reconcile). Runs as the final step of `initializeTools()` (at daemon boot the
447
+ * plugin cache is already populated by then), and fire-and-forget from the
448
+ * per-turn conversation tool resolver — the same cadence `loadWorkspaceTools`
449
+ * runs on.
443
450
  */
444
451
  export function loadPluginTools(): Promise<void> {
445
452
  if (pluginToolsReconcileInFlight) {
@@ -462,7 +469,7 @@ async function reconcilePluginToolsFromCache(): Promise<void> {
462
469
  try {
463
470
  const { getActiveUserPluginTools } =
464
471
  await import("../plugins/mtime-cache.js");
465
- active = await getActiveUserPluginTools();
472
+ active = getActiveUserPluginTools();
466
473
  } catch (err) {
467
474
  log.warn(
468
475
  { err },
@@ -1091,11 +1098,13 @@ async function runToolInitialization(): Promise<void> {
1091
1098
 
1092
1099
  // Pull the active user-plugin tool set last, so core and workspace
1093
1100
  // registrations already own their names when plugin conflicts resolve.
1094
- // At daemon boot the plugin mtime-cache is populated before this runs
1095
- // (`initializePlugins()` precedes `initializeTools()` in the lifecycle);
1096
- // in worker/standalone processes the cache is empty and this is a no-op.
1097
- // Runtime changes keep flowing through the same reconcile, re-fired by
1098
- // the per-turn conversation tool resolver.
1101
+ // This is a pure cache read (it never activates a plugin or runs `init`):
1102
+ // at daemon boot the plugin mtime-cache is already populated by
1103
+ // `initializePlugins()`, which precedes `initializeTools()` in the lifecycle;
1104
+ // in worker/standalone processes the cache is empty, so this registers no
1105
+ // plugin tools and — critically — runs no plugin lifecycle. Runtime changes
1106
+ // reach the cache via the hook-dispatch reconcile and are re-pulled by the
1107
+ // per-turn conversation tool resolver.
1099
1108
  await loadPluginTools();
1100
1109
  }
1101
1110
 
@@ -672,6 +672,8 @@ export class ToolApprovalHandler {
672
672
  conversationId: context.conversationId,
673
673
  requesterExternalUserId: context.requesterExternalUserId,
674
674
  requesterChatId: context.requesterChatId,
675
+ sourceMessageId: context.sourceMessageId,
676
+ sourceThreadId: context.sourceThreadId,
675
677
  toolName: name,
676
678
  inputDigest,
677
679
  questionText: buildToolGrantQuestionText(name, input, context),
@@ -327,6 +327,14 @@ export interface ToolContext {
327
327
  * @legacy
328
328
  */
329
329
  requesterChatId?: string;
330
+ /**
331
+ * Channel-native id (`ts` for Slack) of the inbound message that started
332
+ * the current turn. Lets tool-grant escalations link approval cards to
333
+ * the exact triggering message.
334
+ */
335
+ sourceMessageId?: string;
336
+ /** Channel-native thread id of that message, when it arrived in a thread. */
337
+ sourceThreadId?: string;
330
338
  /**
331
339
  * Human-readable identifier for the requester (e.g., @username).
332
340
  * @legacy
@@ -7,6 +7,7 @@
7
7
  * handled locally by the daemon.
8
8
  */
9
9
 
10
+ import { coerceSurfaceDataRecord } from "../../api/surfaces.js";
10
11
  import { RiskLevel } from "../../permissions/types.js";
11
12
  import { isWeakOpenModel } from "../../providers/weak-open-model.js";
12
13
  import type {
@@ -130,8 +131,7 @@ function isTaskProgressCardShow(input: Record<string, unknown>): boolean {
130
131
  if (input.template === "task_progress") {
131
132
  return true;
132
133
  }
133
- const data = asRecord(input.data);
134
- return data?.template === "task_progress";
134
+ return coerceSurfaceDataRecord(input.data).template === "task_progress";
135
135
  }
136
136
 
137
137
  /**
@@ -144,16 +144,24 @@ function isTaskProgressCardShow(input: Record<string, unknown>): boolean {
144
144
  * as content.
145
145
  */
146
146
  function isEmptyUpdate(input: Record<string, unknown>): boolean {
147
- const data = asRecord(input.data);
148
- return data === null || !hasContent(data);
147
+ return !hasContent(coerceSurfaceDataRecord(input.data));
148
+ }
149
+
150
+ /**
151
+ * The dynamic_page markup, honoring the same top-level recovery as the
152
+ * daemon's `normalizeDynamicPageShowData`: `data.html` wins, a top-level
153
+ * `html` fills in when the model put it outside `data`.
154
+ */
155
+ function dynamicPageHtml(input: Record<string, unknown>): unknown {
156
+ const html = coerceSurfaceDataRecord(input.data).html;
157
+ return typeof html === "string" ? html : input.html;
149
158
  }
150
159
 
151
160
  function isEmptyDynamicPage(input: Record<string, unknown>): boolean {
152
161
  if (input.surface_type !== "dynamic_page") {
153
162
  return false;
154
163
  }
155
- const data = asRecord(input.data);
156
- const html = data?.html;
164
+ const html = dynamicPageHtml(input);
157
165
  return typeof html !== "string" || html.trim().length === 0;
158
166
  }
159
167
 
@@ -182,8 +190,7 @@ const INTERACTIVE_HTML_RE =
182
190
  /<script\b|on[a-z]+\s*=|addEventListener|new Chart\b|window\.vellum\b/i;
183
191
 
184
192
  function isSubstantialInteractiveHtml(input: Record<string, unknown>): boolean {
185
- const data = asRecord(input.data);
186
- const html = data?.html;
193
+ const html = dynamicPageHtml(input);
187
194
  if (typeof html !== "string") {
188
195
  return false;
189
196
  }
@@ -195,14 +202,11 @@ function collectRoutingText(input: Record<string, unknown>): string[] {
195
202
  addString(values, input.title);
196
203
  addString(values, input.activity);
197
204
 
198
- const data = asRecord(input.data);
199
- if (data) {
200
- const preview = asRecord(data.preview);
201
- if (preview) {
202
- addString(values, preview.title);
203
- addString(values, preview.subtitle);
204
- addString(values, preview.description);
205
- }
205
+ const preview = asRecord(coerceSurfaceDataRecord(input.data).preview);
206
+ if (preview) {
207
+ addString(values, preview.title);
208
+ addString(values, preview.subtitle);
209
+ addString(values, preview.description);
206
210
  }
207
211
 
208
212
  return values;
@@ -16,7 +16,11 @@
16
16
  * stay accepted, so card has no guard here.
17
17
  */
18
18
 
19
- import { FileUploadSurfaceDataSchema } from "../../api/surfaces.js";
19
+ import {
20
+ coerceSurfaceDataRecord,
21
+ FileUploadSurfaceDataSchema,
22
+ normalizeCopyBlockShowData,
23
+ } from "../../api/surfaces.js";
20
24
 
21
25
  export function asRecord(value: unknown): Record<string, unknown> | null {
22
26
  return value !== null && typeof value === "object"
@@ -62,9 +66,15 @@ interface SurfaceShapeDoc {
62
66
  * Returns a description of what keeps the payload from rendering as intended
63
67
  * — missing load-bearing content, or keys that would be silently dropped —
64
68
  * or null when the payload is fine. Absent for types the daemon normalizes
65
- * leniently (card) or that have bespoke handling (dynamic_page).
69
+ * leniently (card) or that have bespoke handling (dynamic_page). Guards for
70
+ * types whose daemon normalizer recovers top-level input fields also receive
71
+ * the full tool `input`, so the guard accepts exactly what the normalizer
72
+ * accepts.
66
73
  */
67
- missingContent?: (data: Record<string, unknown>) => string | null;
74
+ missingContent?: (
75
+ data: Record<string, unknown>,
76
+ input: Record<string, unknown>,
77
+ ) => string | null;
68
78
  }
69
79
 
70
80
  /** templateData shape of a task_progress card (shared with channel variants). */
@@ -85,8 +95,8 @@ export const SURFACE_SHAPE_DOCS: Record<string, SurfaceShapeDoc> = {
85
95
  purpose: "copyable text with a visible copy button",
86
96
  shape:
87
97
  "{ text, label?, language? } — shows copyable text with a visible copy button; use for prompts, commands, paths, or snippets the user should copy",
88
- missingContent: (data) =>
89
- isNonEmptyString(data.text)
98
+ missingContent: (data, input) =>
99
+ isNonEmptyString(normalizeCopyBlockShowData(input, data).text)
90
100
  ? null
91
101
  : "`data.text` must be a non-empty string",
92
102
  },
@@ -258,7 +268,12 @@ export function uiShowTeachingError(
258
268
  if (!doc.missingContent) {
259
269
  return null;
260
270
  }
261
- const missing = doc.missingContent(asRecord(input.data) ?? {});
271
+ // Coerce rather than asRecord: a JSON-string-encoded `data` payload carries
272
+ // real content, and rejecting it here reports a populated surface as empty.
273
+ const missing = doc.missingContent(
274
+ coerceSurfaceDataRecord(input.data),
275
+ input,
276
+ );
262
277
  if (missing === null) {
263
278
  return null;
264
279
  }