@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.
- package/node_modules/@vellumai/gateway-client/src/__tests__/binding-strength-contract.test.ts +122 -0
- package/node_modules/@vellumai/gateway-client/src/binding-strength-contract.ts +155 -0
- package/node_modules/@vellumai/gateway-client/src/index.ts +14 -0
- package/package.json +1 -1
- package/src/__tests__/approval-source-link.test.ts +208 -0
- package/src/__tests__/btw-routes.test.ts +13 -2
- package/src/__tests__/conversation-store-ephemeral.test.ts +182 -0
- package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -1
- package/src/__tests__/slack-notification-approval-card.test.ts +103 -20
- package/src/__tests__/tool-approval-seed-content-blocks.test.ts +179 -96
- package/src/__tests__/ui-choice-copy-surfaces.test.ts +144 -3
- package/src/api/events/memory-recalled.ts +59 -0
- package/src/api/events/memory-status.ts +29 -0
- package/src/api/events/service-group-update-complete.ts +29 -0
- package/src/api/events/service-group-update-progress.ts +23 -0
- package/src/api/events/service-group-update-starting.ts +26 -0
- package/src/api/index.ts +36 -1
- package/src/api/surfaces.ts +77 -21
- package/src/calls/__tests__/voice-triage-escalate.test.ts +58 -3
- package/src/calls/voice-session-bridge.ts +6 -2
- package/src/calls/voice-triage-escalate.ts +30 -1
- package/src/config/feature-flag-registry.json +9 -0
- package/src/daemon/conversation-store.ts +14 -2
- package/src/daemon/conversation-surfaces.ts +78 -168
- package/src/daemon/conversation-tool-setup.ts +7 -3
- package/src/daemon/handlers/shared.ts +11 -1
- package/src/daemon/message-types/memory.ts +8 -46
- package/src/daemon/message-types/surfaces.ts +1 -1
- package/src/daemon/message-types/upgrades.ts +11 -28
- package/src/daemon/trust-context-types.ts +8 -0
- package/src/messaging/channel-binding-schema.ts +6 -2
- package/src/messaging/providers/slack/approval-source.ts +87 -0
- package/src/messaging/providers/slack/deep-link.ts +45 -8
- package/src/messaging/providers/slack/message-metadata.ts +16 -0
- package/src/notifications/AGENTS.md +2 -0
- package/src/notifications/access-request-copy.ts +10 -21
- package/src/notifications/adapters/slack.ts +67 -13
- package/src/notifications/approval-card-data.ts +58 -16
- package/src/notifications/broadcaster.ts +41 -19
- package/src/notifications/guardian-question-mode.ts +81 -0
- package/src/notifications/types.ts +5 -0
- package/src/persistence/delivery-crud.ts +48 -1
- package/src/persistence/migrations/347-delete-stray-greeting-conversation.ts +46 -0
- package/src/persistence/migrations/__tests__/347-delete-stray-greeting-conversation.test.ts +100 -0
- package/src/persistence/steps.ts +2 -0
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +2 -2
- package/src/plugins/mtime-cache.ts +21 -10
- package/src/runtime/approval-source-link.ts +107 -0
- package/src/runtime/confirmation-request-guardian-bridge.ts +9 -0
- package/src/runtime/introduction-policy.ts +23 -54
- package/src/runtime/routes/btw-routes.ts +9 -2
- package/src/runtime/routes/inbound-message-handler.ts +5 -13
- package/src/runtime/routes/upgrade-broadcast-routes.ts +6 -8
- package/src/runtime/tool-grant-request-helper.ts +14 -0
- package/src/tools/registry.ts +26 -17
- package/src/tools/tool-approval-handler.ts +2 -0
- package/src/tools/types.ts +8 -0
- package/src/tools/ui-surface/definitions.ts +20 -16
- package/src/tools/ui-surface/surface-shape-docs.ts +21 -6
package/src/tools/registry.ts
CHANGED
|
@@ -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}
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
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
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
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 =
|
|
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
|
-
//
|
|
1095
|
-
//
|
|
1096
|
-
//
|
|
1097
|
-
//
|
|
1098
|
-
//
|
|
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),
|
package/src/tools/types.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
148
|
-
|
|
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
|
|
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
|
|
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
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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 {
|
|
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?: (
|
|
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
|
-
|
|
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
|
}
|