@vellumai/assistant 0.8.9 → 0.8.10-dev.202606092238.d04fd59
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/AGENTS.md +1 -1
- package/examples/plugins/echo/README.md +3 -3
- package/node_modules/@vellumai/skill-host-contracts/src/tool-types.ts +2 -0
- package/openapi.yaml +38 -12
- package/package.json +1 -1
- package/scripts/sync-llm-catalog.ts +2 -0
- package/src/__tests__/agent-loop-exit-reason.test.ts +19 -14
- package/src/__tests__/build-persisted-content.test.ts +75 -1
- package/src/__tests__/config-managed-gemini-defaults.test.ts +2 -46
- package/src/__tests__/context-overflow-reducer.test.ts +264 -124
- package/src/__tests__/context-window-manager-overflow-rung.test.ts +289 -0
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +22 -22
- package/src/__tests__/conversation-agent-loop.test.ts +45 -37
- package/src/__tests__/conversation-fork-crud.test.ts +110 -0
- package/src/__tests__/conversation-provider-retry-repair.test.ts +16 -20
- package/src/__tests__/conversation-runtime-assembly.test.ts +118 -5
- package/src/__tests__/conversation-surfaces-app-control.test.ts +4 -1
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +91 -142
- package/src/__tests__/conversation-tool-setup-skill-attribution.test.ts +116 -0
- package/src/__tests__/conversation-tool-setup-test-helpers.ts +98 -0
- package/src/__tests__/corrected-target.test.ts +93 -0
- package/src/__tests__/credential-execution-feature-gates.test.ts +3 -5
- package/src/__tests__/credential-security-invariants.test.ts +1 -0
- package/src/__tests__/embedding-managed-proxy-selection.test.ts +6 -40
- package/src/__tests__/external-plugin-loader.test.ts +0 -1
- package/src/__tests__/guardian-routing-invariants.test.ts +91 -0
- package/src/__tests__/history-repair-hook.test.ts +2 -0
- package/src/__tests__/host-app-control-proxy.test.ts +45 -0
- package/src/__tests__/llm-catalog-parity.test.ts +4 -0
- package/src/__tests__/memory-retrieval-hook.test.ts +29 -15
- package/src/__tests__/notification-decision-strategy.test.ts +3 -3
- package/src/__tests__/persistence-secret-redaction.test.ts +78 -0
- package/src/__tests__/plugin-bootstrap.test.ts +82 -73
- package/src/__tests__/plugin-tool-contribution.test.ts +7 -4
- package/src/__tests__/plugin-types.test.ts +0 -8
- package/src/__tests__/provider-catalog-visibility.test.ts +1 -9
- package/src/__tests__/retry-thinking-adaptive-only.test.ts +245 -0
- package/src/__tests__/server-history-render.test.ts +39 -0
- package/src/__tests__/skills.test.ts +123 -0
- package/src/__tests__/title-generate-hook.test.ts +2 -0
- package/src/__tests__/tool-audit-listener.test.ts +51 -0
- package/src/__tests__/tool-executor-lifecycle-events.test.ts +32 -0
- package/src/__tests__/tool-start-timestamp.test.ts +218 -0
- package/src/agent/loop.ts +26 -23
- package/src/api/events/tool-result.ts +9 -0
- package/src/api/events/tool-use-start.ts +7 -0
- package/src/api/responses/conversation-message.ts +91 -14
- package/src/approvals/guardian-request-resolvers.ts +26 -0
- package/src/cli/commands/channel-verification-sessions.ts +6 -6
- package/src/cli/commands/inference-providers.ts +0 -8
- package/src/cli/commands/plugins.ts +2 -2
- package/src/cli/lib/__tests__/install-from-github.test.ts +174 -18
- package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +1 -1
- package/src/cli/lib/__tests__/plugin-details.test.ts +1 -1
- package/src/cli/lib/__tests__/plugin-marketplace.test.ts +1 -1
- package/src/cli/lib/__tests__/search-plugins.test.ts +11 -11
- package/src/cli/lib/install-from-github.ts +130 -19
- package/src/cli/lib/plugin-catalog-cache.ts +1 -1
- package/src/cli/lib/plugin-details.ts +4 -4
- package/src/cli/lib/plugin-marketplace.ts +2 -2
- package/src/cli/lib/search-plugins.ts +6 -6
- package/src/config/bundled-skills/skill-management/SKILL.md +89 -1
- package/src/config/env-registry.ts +12 -0
- package/src/config/feature-flag-registry.json +0 -80
- package/src/config/loader.ts +5 -22
- package/src/config/seed-inference-profiles.ts +1 -1
- package/src/config/skills.ts +101 -47
- package/src/context/strip-injections.ts +7 -4
- package/src/daemon/conversation-agent-loop-handlers.ts +102 -6
- package/src/daemon/conversation-agent-loop.ts +134 -232
- package/src/daemon/conversation-runtime-assembly.ts +44 -8
- package/src/daemon/conversation-tool-setup.ts +9 -1
- package/src/daemon/external-plugins-bootstrap.ts +33 -87
- package/src/daemon/handlers/config-channels.ts +11 -2
- package/src/daemon/handlers/shared.ts +9 -1
- package/src/daemon/handlers/skills.ts +6 -2
- package/src/daemon/host-app-control-proxy.ts +72 -57
- package/src/daemon/message-protocol.ts +0 -7
- package/src/daemon/message-types/skills.ts +4 -0
- package/src/events/tool-audit-listener.ts +7 -1
- package/src/memory/__tests__/tool-invocation-test-helpers.ts +69 -0
- package/src/memory/conversation-crud.ts +44 -1
- package/src/memory/db-init.ts +4 -0
- package/src/memory/embedding-backend.ts +5 -22
- package/src/memory/memory-retrospective-startup-cleanup.ts +1 -1
- package/src/memory/migrations/275-tool-invocations-add-skill-id.test.ts +81 -0
- package/src/memory/migrations/275-tool-invocations-add-skill-id.ts +20 -0
- package/src/memory/migrations/276-tool-invocations-created-at-id-index.test.ts +68 -0
- package/src/memory/migrations/276-tool-invocations-created-at-id-index.ts +20 -0
- package/src/memory/migrations/index.ts +2 -0
- package/src/memory/schema/conversations.ts +3 -0
- package/src/memory/tool-execution-events-store.test.ts +162 -0
- package/src/memory/tool-execution-events-store.ts +73 -0
- package/src/memory/tool-usage-store.ts +4 -3
- package/src/memory/v2/__tests__/injected-block-slugs.test.ts +51 -0
- package/src/memory/v2/activation-store.ts +50 -1
- package/src/memory/v2/injected-block-slugs.ts +30 -0
- package/src/notifications/__tests__/copy-composer.test.ts +244 -0
- package/src/notifications/access-request-copy.ts +298 -0
- package/src/notifications/adapters/slack.ts +3 -3
- package/src/notifications/adapters/telegram.ts +2 -1
- package/src/notifications/copy-composer.ts +49 -267
- package/src/notifications/decision-engine.ts +16 -35
- package/src/notifications/home-feed-side-effect.ts +1 -6
- package/src/platform/client.ts +1 -3
- package/src/platform/feature-gate.ts +3 -12
- package/src/plugin-api/constants.ts +2 -0
- package/src/plugin-api/index.ts +34 -6
- package/src/plugin-api/types.ts +19 -0
- package/src/plugins/defaults/compaction/compact.ts +39 -1
- package/src/plugins/defaults/compaction/context-overflow-reducer.ts +240 -32
- package/src/plugins/defaults/compaction/corrected-target.ts +53 -0
- package/src/plugins/defaults/compaction/window-manager.ts +136 -0
- package/src/plugins/defaults/index.ts +24 -0
- package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +68 -43
- package/src/plugins/defaults/memory-retrieval/hooks/{user-prompt-submit-temp.ts → user-prompt-submit.ts} +36 -67
- package/src/plugins/defaults/memory-retrieval/package.json +14 -0
- package/src/plugins/external-api.ts +1 -1
- package/src/plugins/types.ts +5 -51
- package/src/providers/inference/__tests__/base-url-route-validation.test.ts +1 -2
- package/src/providers/model-catalog.ts +57 -1
- package/src/providers/registry.ts +0 -8
- package/src/providers/retry.ts +35 -7
- package/src/runtime/routes/__tests__/acp-routes.test.ts +151 -0
- package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +0 -62
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +4 -4
- package/src/runtime/routes/acp-routes.test.ts +106 -0
- package/src/runtime/routes/acp-routes.ts +248 -2
- package/src/runtime/routes/browser-tabs-routes.ts +1 -1
- package/src/runtime/routes/channel-verification-routes.ts +14 -5
- package/src/runtime/routes/chatgpt-subscription-auth-routes.ts +0 -14
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +33 -34
- package/src/runtime/routes/inference-provider-connection-routes.ts +0 -45
- package/src/runtime/routes/plugins-routes.ts +3 -3
- package/src/runtime/verification-outbound-actions.ts +147 -2
- package/src/runtime/verification-templates.ts +29 -3
- package/src/telemetry/types.ts +25 -1
- package/src/telemetry/usage-telemetry-reporter.test.ts +141 -7
- package/src/telemetry/usage-telemetry-reporter.ts +63 -7
- package/src/tools/executor.ts +4 -1
- package/src/tools/skills/load.ts +11 -6
- package/src/tools/terminal/safe-env.ts +1 -0
- package/src/tools/types.ts +10 -0
- package/src/__tests__/plugin-skill-contribution.test.ts +0 -355
- package/src/daemon/message-types/browser.ts +0 -10
- package/src/notifications/__tests__/emit-signal-home-feed.test.ts +0 -187
- package/src/plugins/plugin-skill-contributions.ts +0 -292
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* 2. Walks {@link getRegisteredPlugins} in registration order.
|
|
15
15
|
* 3. For each plugin, consults `manifest.requiresFlag` against
|
|
16
16
|
* {@link isAssistantFeatureFlagEnabled}. If any listed flag is disabled,
|
|
17
|
-
* the plugin is skipped wholesale — no `init()`, no tool/route
|
|
17
|
+
* the plugin is skipped wholesale — no `init()`, no tool/route
|
|
18
18
|
* contributions, no entry in the shutdown hook, and the plugin is also
|
|
19
19
|
* dropped from the registry via {@link unregisterPlugin} so none of its
|
|
20
20
|
* hooks participate in the turn lifecycle. This is the primary mechanism for
|
|
@@ -29,22 +29,21 @@
|
|
|
29
29
|
* through untouched).
|
|
30
30
|
* 6. Creates `<workspaceDir>/plugins-data/<plugin>/` on demand for per-plugin
|
|
31
31
|
* writable state and exposes it via {@link PluginInitContext.pluginStorageDir}.
|
|
32
|
-
* 7. For each surviving plugin, registers its contributed tools
|
|
33
|
-
*
|
|
34
|
-
* {@link
|
|
35
|
-
* {@link registerPluginSkills}. Contributions land BEFORE `init()` so
|
|
32
|
+
* 7. For each surviving plugin, registers its contributed tools and routes
|
|
33
|
+
* into their global registries via {@link registerPluginTools} and
|
|
34
|
+
* {@link registerSkillRoute}. Contributions land BEFORE `init()` so
|
|
36
35
|
* the plugin's hook can observe a registry where its own model-visible
|
|
37
36
|
* surface is already wired — useful for plugins that want to attach
|
|
38
37
|
* metadata, warm caches, or otherwise interact with their own
|
|
39
38
|
* contributions during initialization.
|
|
40
|
-
* 8. Awaits `plugin.init(ctx)` sequentially. An init failure
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
39
|
+
* 8. Awaits `plugin.init(ctx)` sequentially. An init failure is contained to
|
|
40
|
+
* the offending plugin: its already-registered tools and routes are rolled
|
|
41
|
+
* back, it is dropped from the registry, the failure is logged, and
|
|
42
|
+
* bootstrap continues with the remaining plugins. A single plugin's failure
|
|
43
|
+
* never deregisters plugins that already initialized — in particular the
|
|
44
|
+
* first-party defaults, which carry core turn behavior (memory retrieval,
|
|
45
|
+
* history repair, title generation) — so the daemon comes up with the
|
|
46
|
+
* failing plugin absent rather than blacking out the whole plugin layer.
|
|
48
47
|
*
|
|
49
48
|
* A single shutdown hook is registered via
|
|
50
49
|
* {@link registerShutdownHook} that walks the plugin list in **reverse
|
|
@@ -67,10 +66,6 @@ import { HOOKS } from "../plugin-api/constants.js";
|
|
|
67
66
|
import { registerDefaultPlugins } from "../plugins/defaults/index.js";
|
|
68
67
|
import { installPluginRuntime } from "../plugins/external-api.js";
|
|
69
68
|
import { buildExternalPlugin } from "../plugins/external-plugin-loader.js";
|
|
70
|
-
import {
|
|
71
|
-
registerPluginSkills,
|
|
72
|
-
unregisterPluginSkills,
|
|
73
|
-
} from "../plugins/plugin-skill-contributions.js";
|
|
74
69
|
import {
|
|
75
70
|
getRegisteredPlugin,
|
|
76
71
|
getRegisteredPlugins,
|
|
@@ -81,7 +76,6 @@ import {
|
|
|
81
76
|
type Plugin,
|
|
82
77
|
PluginExecutionError,
|
|
83
78
|
type PluginShutdownContext,
|
|
84
|
-
type PluginSkillRegistration,
|
|
85
79
|
} from "../plugins/types.js";
|
|
86
80
|
import { loadUserPlugins } from "../plugins/user-loader.js";
|
|
87
81
|
import {
|
|
@@ -218,9 +212,10 @@ export async function initializePlugins(): Promise<void> {
|
|
|
218
212
|
* Run every registered plugin's `init()` hook sequentially and install a
|
|
219
213
|
* reverse-order shutdown hook. See the module docstring for full semantics.
|
|
220
214
|
*
|
|
221
|
-
* Returns once every plugin has
|
|
222
|
-
*
|
|
223
|
-
* the
|
|
215
|
+
* Returns once every plugin has been processed. A plugin whose `init()` throws
|
|
216
|
+
* is rolled back, dropped from the registry, and logged; bootstrap continues
|
|
217
|
+
* with the rest, so one failing plugin never blocks the others — or the
|
|
218
|
+
* first-party defaults — from coming up.
|
|
224
219
|
*
|
|
225
220
|
* Must be called after any custom/third-party plugin registrations have run
|
|
226
221
|
* and before the first conversation is served. First-party defaults are
|
|
@@ -259,35 +254,14 @@ export async function bootstrapPlugins(): Promise<void> {
|
|
|
259
254
|
// onShutdown" invariant.
|
|
260
255
|
const activePlugins: ActivePlugin[] = [];
|
|
261
256
|
|
|
262
|
-
// Tear down a plugin's contributions AND remove it from the registry. The
|
|
263
|
-
// two steps always move together on the bootstrap failure path: the former
|
|
264
|
-
// clears tools/routes/skills (so they stop appearing to the model/HTTP
|
|
265
|
-
// server), the latter drops the plugin's entry from the Map (so the registry
|
|
266
|
-
// doesn't expose an uninitialized plugin's hooks).
|
|
267
257
|
// Shutdown context is identical for every plugin in this boot — construct
|
|
268
|
-
// once and reuse across the
|
|
269
|
-
//
|
|
270
|
-
//
|
|
258
|
+
// once and reuse across the per-plugin teardown and the normal shutdown
|
|
259
|
+
// hook below. Only `assistantVersion` is exposed today; future additions
|
|
260
|
+
// live on {@link PluginShutdownContext}.
|
|
271
261
|
const shutdownContext: PluginShutdownContext = {
|
|
272
262
|
assistantVersion: APP_VERSION,
|
|
273
263
|
};
|
|
274
264
|
|
|
275
|
-
async function rollbackPlugin(active: ActivePlugin): Promise<void> {
|
|
276
|
-
await teardownPlugin(active, "bootstrap-failed", shutdownContext);
|
|
277
|
-
unregisterPlugin(active.plugin.manifest.name);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// If one plugin's init or contribution phase throws, tear down any plugins
|
|
281
|
-
// that already fully initialized (in reverse registration order) before
|
|
282
|
-
// re-throwing. Without this, a mid-loop failure would leave earlier plugins
|
|
283
|
-
// with live tools/routes/skills and no `onShutdown()` call — the shutdown
|
|
284
|
-
// hook is only registered once the loop completes successfully.
|
|
285
|
-
async function teardownPartialInit(): Promise<void> {
|
|
286
|
-
for (let i = activePlugins.length - 1; i >= 0; i--) {
|
|
287
|
-
await rollbackPlugin(activePlugins[i]!);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
265
|
for (const plugin of plugins) {
|
|
292
266
|
const name = plugin.manifest.name;
|
|
293
267
|
const disabledFlag = getDisabledPluginFlag(plugin, assistantConfig);
|
|
@@ -303,9 +277,18 @@ export async function bootstrapPlugins(): Promise<void> {
|
|
|
303
277
|
try {
|
|
304
278
|
activePlugins.push(await initializePlugin(plugin, assistantConfig));
|
|
305
279
|
} catch (err) {
|
|
280
|
+
// Contain the failure to this plugin. `initializePlugin` already rolled
|
|
281
|
+
// back its own partial tool/route contributions, so we just drop
|
|
282
|
+
// it from the registry and move on. A single plugin's init failure must
|
|
283
|
+
// never deregister the plugins that already came up — above all the
|
|
284
|
+
// first-party defaults, which carry core turn behavior. The daemon stays
|
|
285
|
+
// reachable with the failing plugin absent rather than losing the whole
|
|
286
|
+
// plugin layer.
|
|
306
287
|
unregisterPlugin(name);
|
|
307
|
-
|
|
308
|
-
|
|
288
|
+
log.warn(
|
|
289
|
+
{ err, plugin: name },
|
|
290
|
+
`plugin ${name} failed to initialize — skipping (continuing with remaining plugins)`,
|
|
291
|
+
);
|
|
309
292
|
}
|
|
310
293
|
}
|
|
311
294
|
|
|
@@ -323,12 +306,6 @@ export async function bootstrapPlugins(): Promise<void> {
|
|
|
323
306
|
// 3. Call `onShutdown()` (if defined) so the plugin can release resources
|
|
324
307
|
// (background tasks, timers, connections) with its tools and routes
|
|
325
308
|
// already removed.
|
|
326
|
-
// 4. Unregister contributed skills via the ref-counted helper. Skills tear
|
|
327
|
-
// down last so `onShutdown()` can still invoke skill-resolving code
|
|
328
|
-
// (e.g. to flush pending skill work) before the catalog is emptied.
|
|
329
|
-
// This mirrors the symmetry of registerPluginSkills() — every
|
|
330
|
-
// successful registration must get a matching unregister call,
|
|
331
|
-
// regardless of whether onShutdown throws.
|
|
332
309
|
const shutdownSnapshot: ActivePlugin[] = [...activePlugins];
|
|
333
310
|
registerShutdownHook("plugins", async (reason) => {
|
|
334
311
|
for (let i = shutdownSnapshot.length - 1; i >= 0; i--) {
|
|
@@ -404,23 +381,6 @@ async function initializePlugin(
|
|
|
404
381
|
);
|
|
405
382
|
}
|
|
406
383
|
|
|
407
|
-
if (plugin.skills && plugin.skills.length > 0) {
|
|
408
|
-
try {
|
|
409
|
-
registerPluginSkills(
|
|
410
|
-
name,
|
|
411
|
-
plugin.skills as readonly PluginSkillRegistration[],
|
|
412
|
-
);
|
|
413
|
-
} catch (err) {
|
|
414
|
-
throw new PluginExecutionError(
|
|
415
|
-
`plugin ${name} skill registration failed: ${
|
|
416
|
-
err instanceof Error ? err.message : String(err)
|
|
417
|
-
}`,
|
|
418
|
-
name,
|
|
419
|
-
{ cause: err },
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
384
|
if (plugin.hooks?.[HOOKS.INIT]) {
|
|
425
385
|
try {
|
|
426
386
|
await plugin.hooks[HOOKS.INIT](initContext);
|
|
@@ -448,9 +408,6 @@ async function initializePlugin(
|
|
|
448
408
|
unregisterSkillRoute(handle);
|
|
449
409
|
}
|
|
450
410
|
unregisterPluginTools(name);
|
|
451
|
-
if (plugin.skills && plugin.skills.length > 0) {
|
|
452
|
-
unregisterPluginSkills(name);
|
|
453
|
-
}
|
|
454
411
|
}
|
|
455
412
|
throw err;
|
|
456
413
|
}
|
|
@@ -458,9 +415,9 @@ async function initializePlugin(
|
|
|
458
415
|
|
|
459
416
|
/**
|
|
460
417
|
* Tear down a single fully-initialized plugin: unregister routes, unregister
|
|
461
|
-
* tools, invoke `onShutdown()` if present
|
|
462
|
-
*
|
|
463
|
-
*
|
|
418
|
+
* tools, then invoke `onShutdown()` if present. Every step swallows errors and
|
|
419
|
+
* logs with plugin attribution so one bad plugin can't block teardown of the
|
|
420
|
+
* rest.
|
|
464
421
|
*
|
|
465
422
|
* Shared between the normal shutdown hook and the bootstrap error path; both
|
|
466
423
|
* consume plugins that already cleared every contribution step.
|
|
@@ -514,17 +471,6 @@ async function teardownPlugin(
|
|
|
514
471
|
);
|
|
515
472
|
}
|
|
516
473
|
}
|
|
517
|
-
|
|
518
|
-
if (plugin.skills && plugin.skills.length > 0) {
|
|
519
|
-
try {
|
|
520
|
-
unregisterPluginSkills(name);
|
|
521
|
-
} catch (err) {
|
|
522
|
-
log.warn(
|
|
523
|
-
{ err, plugin: name, reason },
|
|
524
|
-
"plugin skill unregistration failed (continuing with remaining plugins)",
|
|
525
|
-
);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
474
|
}
|
|
529
475
|
|
|
530
476
|
/** Rebuild a changed external plugin and swap it into the live registry. */
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from "../../runtime/channel-verification-service.js";
|
|
32
32
|
import {
|
|
33
33
|
cancelOutbound,
|
|
34
|
+
deliverVerificationEmail,
|
|
34
35
|
deliverVerificationSlack,
|
|
35
36
|
deliverVerificationTelegram,
|
|
36
37
|
DESTINATION_RATE_WINDOW_MS,
|
|
@@ -555,7 +556,11 @@ export async function handleChannelVerificationSession(
|
|
|
555
556
|
const { userId, text, assistantId: aid } = result._pendingSlackDm;
|
|
556
557
|
deliverVerificationSlack(userId, text, aid);
|
|
557
558
|
}
|
|
558
|
-
|
|
559
|
+
if (result._pendingEmail) {
|
|
560
|
+
const { to, text, subject, assistantId: aid } = result._pendingEmail;
|
|
561
|
+
deliverVerificationEmail(to, text, subject, aid);
|
|
562
|
+
}
|
|
563
|
+
const { _pendingSlackDm: _, _pendingEmail: __, ...publicResult } = result;
|
|
559
564
|
broadcastMessage({
|
|
560
565
|
type: "channel_verification_session_response",
|
|
561
566
|
...publicResult,
|
|
@@ -600,7 +605,11 @@ export async function handleChannelVerificationSession(
|
|
|
600
605
|
const { userId, text, assistantId: aid } = result._pendingSlackDm;
|
|
601
606
|
deliverVerificationSlack(userId, text, aid);
|
|
602
607
|
}
|
|
603
|
-
|
|
608
|
+
if (result._pendingEmail) {
|
|
609
|
+
const { to, text, subject, assistantId: aid } = result._pendingEmail;
|
|
610
|
+
deliverVerificationEmail(to, text, subject, aid);
|
|
611
|
+
}
|
|
612
|
+
const { _pendingSlackDm: _, _pendingEmail: __, ...publicResult } = result;
|
|
604
613
|
broadcastMessage({
|
|
605
614
|
type: "channel_verification_session_response",
|
|
606
615
|
...publicResult,
|
|
@@ -428,7 +428,15 @@ export function renderHistoryContent(
|
|
|
428
428
|
finalizeSegment();
|
|
429
429
|
thinkingSegments.push(block.thinking);
|
|
430
430
|
contentOrder.push(`thinking:${thinkingSegments.length - 1}`);
|
|
431
|
-
|
|
431
|
+
const thinkingBlock: Extract<
|
|
432
|
+
ConversationContentBlock,
|
|
433
|
+
{ type: "thinking" }
|
|
434
|
+
> = { type: "thinking", thinking: block.thinking };
|
|
435
|
+
if (typeof block._startedAt === "number")
|
|
436
|
+
thinkingBlock.startedAt = block._startedAt;
|
|
437
|
+
if (typeof block._completedAt === "number")
|
|
438
|
+
thinkingBlock.completedAt = block._completedAt;
|
|
439
|
+
contentBlocks.push(thinkingBlock);
|
|
432
440
|
continue;
|
|
433
441
|
}
|
|
434
442
|
|
|
@@ -314,9 +314,11 @@ function deriveKind(
|
|
|
314
314
|
): SlimSkillResponse["kind"] {
|
|
315
315
|
if (source === "bundled") return "bundled";
|
|
316
316
|
if (source === "catalog") return "catalog";
|
|
317
|
-
// Plugin-
|
|
317
|
+
// Plugin-resident skills are framework-provided like bundled skills —
|
|
318
318
|
// expose them under the same "bundled" kind so the UI doesn't invent a
|
|
319
|
-
// new category that existing clients don't know how to render.
|
|
319
|
+
// new category that existing clients don't know how to render. Attribution
|
|
320
|
+
// to the owning plugin rides on the separate `pluginName` field, derived
|
|
321
|
+
// from the skill's `owner` descriptor.
|
|
320
322
|
if (source === "plugin") return "bundled";
|
|
321
323
|
return "installed"; // managed, workspace, extra
|
|
322
324
|
}
|
|
@@ -359,6 +361,7 @@ function toSlimSkillResponse(
|
|
|
359
361
|
kind,
|
|
360
362
|
status,
|
|
361
363
|
category,
|
|
364
|
+
pluginName: summary.owner?.kind === "plugin" ? summary.owner.id : undefined,
|
|
362
365
|
} as const;
|
|
363
366
|
|
|
364
367
|
switch (origin) {
|
|
@@ -712,6 +715,7 @@ export async function getSkill(
|
|
|
712
715
|
origin: slim.origin,
|
|
713
716
|
status: slim.status,
|
|
714
717
|
category: slim.category,
|
|
718
|
+
pluginName: slim.pluginName,
|
|
715
719
|
};
|
|
716
720
|
return { skill: detail };
|
|
717
721
|
}
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
* translation on top.
|
|
13
13
|
*
|
|
14
14
|
* **Session lock.** Only one conversation may hold an active app-control
|
|
15
|
-
* session at a time, and that session is bound to a specific target app
|
|
15
|
+
* session at a time, and that session is bound to a specific target app
|
|
16
|
+
* on a specific client.
|
|
16
17
|
* The lock is module-level (`activeAppControlSession`) because the session
|
|
17
18
|
* targets the user's actual desktop application, which is a host-wide
|
|
18
19
|
* resource. It is acquired optimistically when `app_control_start` is
|
|
19
|
-
* dispatched (storing `(conversationId, app)`) so that the synchronous
|
|
20
|
+
* dispatched (storing `(conversationId, app, targetClientId)`) so that the synchronous
|
|
20
21
|
* guard and the asynchronous host round-trip cannot race. A separate
|
|
21
22
|
* `confirmedAppControlSession` tracks the last session the host reported
|
|
22
23
|
* `running`; the rollback path on a failed `start` restores from the
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
* user's medium-risk approval at start time is the consent boundary. All
|
|
33
34
|
* other tools (observe / press / combo / sequence / type / click / drag)
|
|
34
35
|
* require the calling conversation to own an active session targeting the
|
|
35
|
-
* same `app
|
|
36
|
+
* same `app` and client; otherwise the call is rejected before any host dispatch.
|
|
36
37
|
* This prevents prompt-injected tool calls from sending raw input to
|
|
37
38
|
* arbitrary apps without the user having approved control of that
|
|
38
39
|
* specific app.
|
|
@@ -78,9 +79,9 @@ const STUCK_REPEAT_THRESHOLD = 4;
|
|
|
78
79
|
// ---------------------------------------------------------------------------
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
|
-
* Active app-control session: the conversation that owns the lock
|
|
82
|
-
* `app` it was approved against. Set on a successful
|
|
83
|
-
* cleared by the owning proxy's `dispose()`.
|
|
82
|
+
* Active app-control session: the conversation that owns the lock, the
|
|
83
|
+
* `app` and client it was approved against. Set on a successful
|
|
84
|
+
* `app_control_start`; cleared by the owning proxy's `dispose()`.
|
|
84
85
|
*/
|
|
85
86
|
export interface ActiveAppControlSession {
|
|
86
87
|
conversationId: string;
|
|
@@ -90,6 +91,11 @@ export interface ActiveAppControlSession {
|
|
|
90
91
|
* the `app` of subsequent non-start tool calls.
|
|
91
92
|
*/
|
|
92
93
|
app: string;
|
|
94
|
+
/**
|
|
95
|
+
* The client selected for `app_control_start`. Undefined when the start
|
|
96
|
+
* was untargeted; subsequent calls must match the same value.
|
|
97
|
+
*/
|
|
98
|
+
targetClientId?: string;
|
|
93
99
|
/**
|
|
94
100
|
* Strictly monotonic counter assigned when the session is created (in
|
|
95
101
|
* `request()` for a `start`). Used by {@link promoteStartIfCurrent} to
|
|
@@ -153,11 +159,13 @@ export function _resetActiveAppControlSession(): void {
|
|
|
153
159
|
export function _setActiveAppControlSession(session: {
|
|
154
160
|
conversationId: string;
|
|
155
161
|
app: string;
|
|
162
|
+
targetClientId?: string;
|
|
156
163
|
dispatchedAt?: number;
|
|
157
164
|
}): void {
|
|
158
165
|
const full: ActiveAppControlSession = {
|
|
159
166
|
conversationId: session.conversationId,
|
|
160
167
|
app: session.app,
|
|
168
|
+
targetClientId: session.targetClientId,
|
|
161
169
|
dispatchedAt: session.dispatchedAt ?? nextDispatchedAt++,
|
|
162
170
|
};
|
|
163
171
|
activeAppControlSession = full;
|
|
@@ -177,6 +185,7 @@ export function _setActiveAppControlSession(session: {
|
|
|
177
185
|
function checkNonStartAuthorization(
|
|
178
186
|
input: HostAppControlInput,
|
|
179
187
|
conversationId: string,
|
|
188
|
+
targetClientId: string | undefined,
|
|
180
189
|
): ToolExecutionResult | null {
|
|
181
190
|
if (activeAppControlSession == null) {
|
|
182
191
|
return {
|
|
@@ -219,6 +228,16 @@ function checkNonStartAuthorization(
|
|
|
219
228
|
isError: true,
|
|
220
229
|
};
|
|
221
230
|
}
|
|
231
|
+
if (activeAppControlSession.targetClientId !== targetClientId) {
|
|
232
|
+
return {
|
|
233
|
+
content:
|
|
234
|
+
`Active app-control session targets client ` +
|
|
235
|
+
`${activeAppControlSession.targetClientId ?? "<default>"}; cannot ` +
|
|
236
|
+
`send actions to client ${targetClientId ?? "<default>"}. Call ` +
|
|
237
|
+
`app_control_stop and app_control_start to switch clients.`,
|
|
238
|
+
isError: true,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
222
241
|
return null;
|
|
223
242
|
}
|
|
224
243
|
|
|
@@ -284,11 +303,53 @@ export class HostAppControlProxy extends HostProxyBase<
|
|
|
284
303
|
return { content: "Aborted", isError: true };
|
|
285
304
|
}
|
|
286
305
|
|
|
306
|
+
// Resolve target client and enforce same-actor BEFORE acquiring the
|
|
307
|
+
// session lock. This way early-exit errors don't need rollback, and
|
|
308
|
+
// the resolved client id can be stored in the session.
|
|
309
|
+
let resolvedTargetClientId = targetClientId;
|
|
310
|
+
if (resolvedTargetClientId == null) {
|
|
311
|
+
const resolved = pickSameUserAutoResolve({
|
|
312
|
+
hub: assistantEventHub,
|
|
313
|
+
capability: "host_app_control",
|
|
314
|
+
sourceActorPrincipalId,
|
|
315
|
+
});
|
|
316
|
+
if (resolved.kind === "ambiguous") {
|
|
317
|
+
return {
|
|
318
|
+
content:
|
|
319
|
+
"Multiple host_app_control clients are connected for this user. Specify target_client_id to disambiguate.",
|
|
320
|
+
isError: true,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
if (resolved.kind === "match") {
|
|
324
|
+
resolvedTargetClientId = resolved.clientId;
|
|
325
|
+
} else if (
|
|
326
|
+
assistantEventHub.listClientsByCapability("host_app_control").length > 0
|
|
327
|
+
) {
|
|
328
|
+
return {
|
|
329
|
+
content:
|
|
330
|
+
"App control is not available for the current actor. Connect a host_app_control-capable client as the same user.",
|
|
331
|
+
isError: true,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (resolvedTargetClientId != null) {
|
|
337
|
+
const rejection = enforceSameActorOrErrorResult({
|
|
338
|
+
hub: assistantEventHub,
|
|
339
|
+
sourceActorPrincipalId,
|
|
340
|
+
targetClientId: resolvedTargetClientId,
|
|
341
|
+
op: "host_app_control",
|
|
342
|
+
});
|
|
343
|
+
if (rejection) {
|
|
344
|
+
return rejection;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
287
348
|
// Authorization gate. `start` acquires the session lock (the user's
|
|
288
349
|
// medium-risk approval is the consent boundary); all other tools must
|
|
289
|
-
// belong to the active session and target the same `app
|
|
290
|
-
// gate, prompt-injected calls would bypass the start-time
|
|
291
|
-
// send raw input to arbitrary apps.
|
|
350
|
+
// belong to the active session and target the same `app` and client.
|
|
351
|
+
// Without this gate, prompt-injected calls would bypass the start-time
|
|
352
|
+
// approval and send raw input to arbitrary apps or clients.
|
|
292
353
|
let attemptedSession: ActiveAppControlSession | undefined;
|
|
293
354
|
if (input.tool === "start") {
|
|
294
355
|
if (
|
|
@@ -314,6 +375,7 @@ export class HostAppControlProxy extends HostProxyBase<
|
|
|
314
375
|
attemptedSession = {
|
|
315
376
|
conversationId: this.conversationId,
|
|
316
377
|
app: input.app,
|
|
378
|
+
targetClientId: resolvedTargetClientId,
|
|
317
379
|
dispatchedAt: nextDispatchedAt++,
|
|
318
380
|
};
|
|
319
381
|
activeAppControlSession = attemptedSession;
|
|
@@ -321,60 +383,13 @@ export class HostAppControlProxy extends HostProxyBase<
|
|
|
321
383
|
const sessionError = checkNonStartAuthorization(
|
|
322
384
|
input,
|
|
323
385
|
this.conversationId,
|
|
386
|
+
resolvedTargetClientId,
|
|
324
387
|
);
|
|
325
388
|
if (sessionError != null) {
|
|
326
389
|
return sessionError;
|
|
327
390
|
}
|
|
328
391
|
}
|
|
329
392
|
|
|
330
|
-
let resolvedTargetClientId = targetClientId;
|
|
331
|
-
if (resolvedTargetClientId == null) {
|
|
332
|
-
const resolved = pickSameUserAutoResolve({
|
|
333
|
-
hub: assistantEventHub,
|
|
334
|
-
capability: "host_app_control",
|
|
335
|
-
sourceActorPrincipalId,
|
|
336
|
-
});
|
|
337
|
-
if (resolved.kind === "ambiguous") {
|
|
338
|
-
if (input.tool === "start") {
|
|
339
|
-
this.rollbackStartIfCurrent(attemptedSession);
|
|
340
|
-
}
|
|
341
|
-
return {
|
|
342
|
-
content:
|
|
343
|
-
"Multiple host_app_control clients are connected for this user. Specify target_client_id to disambiguate.",
|
|
344
|
-
isError: true,
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
if (resolved.kind === "match") {
|
|
348
|
-
resolvedTargetClientId = resolved.clientId;
|
|
349
|
-
} else if (
|
|
350
|
-
assistantEventHub.listClientsByCapability("host_app_control").length > 0
|
|
351
|
-
) {
|
|
352
|
-
if (input.tool === "start") {
|
|
353
|
-
this.rollbackStartIfCurrent(attemptedSession);
|
|
354
|
-
}
|
|
355
|
-
return {
|
|
356
|
-
content:
|
|
357
|
-
"App control is not available for the current actor. Connect a host_app_control-capable client as the same user.",
|
|
358
|
-
isError: true,
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (resolvedTargetClientId != null) {
|
|
364
|
-
const rejection = enforceSameActorOrErrorResult({
|
|
365
|
-
hub: assistantEventHub,
|
|
366
|
-
sourceActorPrincipalId,
|
|
367
|
-
targetClientId: resolvedTargetClientId,
|
|
368
|
-
op: "host_app_control",
|
|
369
|
-
});
|
|
370
|
-
if (rejection) {
|
|
371
|
-
if (input.tool === "start") {
|
|
372
|
-
this.rollbackStartIfCurrent(attemptedSession);
|
|
373
|
-
}
|
|
374
|
-
return rejection;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
393
|
try {
|
|
379
394
|
const payload = await this.dispatchRequest(
|
|
380
395
|
toolName,
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
export * from "./message-types/acp.js";
|
|
17
17
|
export * from "./message-types/apps.js";
|
|
18
18
|
export * from "./message-types/bookmarks.js";
|
|
19
|
-
export * from "./message-types/browser.js";
|
|
20
19
|
export * from "./message-types/computer-use.js";
|
|
21
20
|
export * from "./message-types/contacts.js";
|
|
22
21
|
export * from "./message-types/conversations.js";
|
|
@@ -57,10 +56,6 @@ import type {
|
|
|
57
56
|
_AppsServerMessages,
|
|
58
57
|
} from "./message-types/apps.js";
|
|
59
58
|
import type { _BookmarksServerMessages } from "./message-types/bookmarks.js";
|
|
60
|
-
import type {
|
|
61
|
-
_BrowserClientMessages,
|
|
62
|
-
_BrowserServerMessages,
|
|
63
|
-
} from "./message-types/browser.js";
|
|
64
59
|
import type {
|
|
65
60
|
_ComputerUseClientMessages,
|
|
66
61
|
_ComputerUseServerMessages,
|
|
@@ -167,7 +162,6 @@ export type ClientMessage =
|
|
|
167
162
|
| _ComputerUseClientMessages
|
|
168
163
|
| _ContactsClientMessages
|
|
169
164
|
| _WorkItemsClientMessages
|
|
170
|
-
| _BrowserClientMessages
|
|
171
165
|
| _HostBrowserClientMessages
|
|
172
166
|
| _SubagentsClientMessages
|
|
173
167
|
| _DocumentsClientMessages
|
|
@@ -191,7 +185,6 @@ export type ServerMessage =
|
|
|
191
185
|
| _ComputerUseServerMessages
|
|
192
186
|
| _ContactsServerMessages
|
|
193
187
|
| _WorkItemsServerMessages
|
|
194
|
-
| _BrowserServerMessages
|
|
195
188
|
| _SubagentsServerMessages
|
|
196
189
|
| _DocumentsServerMessages
|
|
197
190
|
| _DocumentCommentsServerMessages
|
|
@@ -91,6 +91,8 @@ interface SlimSkillBase {
|
|
|
91
91
|
kind: "bundled" | "installed" | "catalog";
|
|
92
92
|
status: "enabled" | "disabled" | "available";
|
|
93
93
|
category: string;
|
|
94
|
+
/** Name of the installed plugin shipping this skill, when plugin-resident. */
|
|
95
|
+
pluginName?: string;
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
interface VellumSlimSkill extends SlimSkillBase {
|
|
@@ -163,6 +165,8 @@ interface SkillDetailBase {
|
|
|
163
165
|
kind: "bundled" | "installed" | "catalog";
|
|
164
166
|
status: "enabled" | "disabled" | "available";
|
|
165
167
|
category: string;
|
|
168
|
+
/** Name of the installed plugin shipping this skill, when plugin-resident. */
|
|
169
|
+
pluginName?: string;
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
interface VellumSkillDetail extends SkillDetailBase {
|
|
@@ -41,10 +41,14 @@ function toInvocationRecord(
|
|
|
41
41
|
conversationId: event.conversationId,
|
|
42
42
|
toolName: event.toolName,
|
|
43
43
|
input: stringifyInput(event.input),
|
|
44
|
-
result: redactSecrets(event.result.content).slice(
|
|
44
|
+
result: redactSecrets(event.result.content).slice(
|
|
45
|
+
0,
|
|
46
|
+
RESULT_PREVIEW_LIMIT,
|
|
47
|
+
),
|
|
45
48
|
decision: event.decision,
|
|
46
49
|
riskLevel: event.riskLevel,
|
|
47
50
|
matchedTrustRuleId: event.matchedTrustRuleId,
|
|
51
|
+
skillId: event.skillId,
|
|
48
52
|
durationMs: event.durationMs,
|
|
49
53
|
};
|
|
50
54
|
case "error":
|
|
@@ -56,6 +60,7 @@ function toInvocationRecord(
|
|
|
56
60
|
decision: "error",
|
|
57
61
|
riskLevel: event.riskLevel,
|
|
58
62
|
matchedTrustRuleId: event.matchedTrustRuleId,
|
|
63
|
+
skillId: event.skillId,
|
|
59
64
|
durationMs: event.durationMs,
|
|
60
65
|
};
|
|
61
66
|
case "permission_denied":
|
|
@@ -67,6 +72,7 @@ function toInvocationRecord(
|
|
|
67
72
|
decision: "denied",
|
|
68
73
|
riskLevel: event.riskLevel,
|
|
69
74
|
matchedTrustRuleId: event.matchedTrustRuleId,
|
|
75
|
+
skillId: event.skillId,
|
|
70
76
|
durationMs: event.durationMs,
|
|
71
77
|
};
|
|
72
78
|
case "start":
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared seeding helper for tests that exercise the tool_invocations →
|
|
3
|
+
* telemetry projection chain. Inserts raw audit rows (with PII-sentinel
|
|
4
|
+
* input/result payloads) plus the FK-required conversation row.
|
|
5
|
+
*
|
|
6
|
+
* Zero runtime imports: per the test-machinery isolation rule
|
|
7
|
+
* (`assistant/AGENTS.md`), shared test helpers must not pull in source
|
|
8
|
+
* modules' import-time side effects. Production types are referenced via
|
|
9
|
+
* `import type` only (erased at compile time); callers pass in the real
|
|
10
|
+
* `getDb()` handle and schema table refs.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { DrizzleDb } from "../db-connection.js";
|
|
14
|
+
import type { conversations, toolInvocations } from "../schema.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Sentinel embedded in the seeded raw input/result payloads. Assert it
|
|
18
|
+
* never appears in any telemetry projection or wire payload.
|
|
19
|
+
*/
|
|
20
|
+
export const TOOL_INVOCATION_PII_SENTINEL = "must never leave the device";
|
|
21
|
+
|
|
22
|
+
export interface ToolInvocationSeedDeps {
|
|
23
|
+
db: DrizzleDb;
|
|
24
|
+
conversations: typeof conversations;
|
|
25
|
+
toolInvocations: typeof toolInvocations;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SeedToolInvocationSpec {
|
|
29
|
+
id: string;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
conversationId: string;
|
|
32
|
+
toolName?: string;
|
|
33
|
+
skillId?: string;
|
|
34
|
+
decision?: string;
|
|
35
|
+
riskLevel?: string;
|
|
36
|
+
durationMs?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function seedToolInvocation(
|
|
40
|
+
deps: ToolInvocationSeedDeps,
|
|
41
|
+
spec: SeedToolInvocationSpec,
|
|
42
|
+
): void {
|
|
43
|
+
// tool_invocations has an enforced FK to conversations.
|
|
44
|
+
deps.db
|
|
45
|
+
.insert(deps.conversations)
|
|
46
|
+
.values({
|
|
47
|
+
id: spec.conversationId,
|
|
48
|
+
title: "test",
|
|
49
|
+
createdAt: 1000,
|
|
50
|
+
updatedAt: 1000,
|
|
51
|
+
})
|
|
52
|
+
.onConflictDoNothing()
|
|
53
|
+
.run();
|
|
54
|
+
deps.db
|
|
55
|
+
.insert(deps.toolInvocations)
|
|
56
|
+
.values({
|
|
57
|
+
id: spec.id,
|
|
58
|
+
conversationId: spec.conversationId,
|
|
59
|
+
toolName: spec.toolName ?? "calendar_list_events",
|
|
60
|
+
input: `{"secret":"raw tool args — ${TOOL_INVOCATION_PII_SENTINEL}"}`,
|
|
61
|
+
result: `{"secret":"raw tool output — ${TOOL_INVOCATION_PII_SENTINEL}"}`,
|
|
62
|
+
decision: spec.decision ?? "allow",
|
|
63
|
+
riskLevel: spec.riskLevel ?? "low",
|
|
64
|
+
skillId: spec.skillId ?? null,
|
|
65
|
+
durationMs: spec.durationMs ?? 12,
|
|
66
|
+
createdAt: spec.createdAt,
|
|
67
|
+
})
|
|
68
|
+
.run();
|
|
69
|
+
}
|