@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
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import { queryUnreportedLifecycleEvents } from "../memory/lifecycle-events-store.js";
|
|
24
24
|
import { queryUnreportedUsageEvents } from "../memory/llm-usage-store.js";
|
|
25
25
|
import { queryUnreportedOnboardingEvents } from "../memory/onboarding-events-store.js";
|
|
26
|
+
import { queryUnreportedToolExecutionEvents } from "../memory/tool-execution-events-store.js";
|
|
26
27
|
import { queryUnreportedTurnEvents } from "../memory/turn-events-store.js";
|
|
27
28
|
import { VellumPlatformClient } from "../platform/client.js";
|
|
28
29
|
import { getDeviceId } from "../util/device-id.js";
|
|
@@ -56,6 +57,10 @@ const CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK =
|
|
|
56
57
|
"telemetry:auth_fallback:last_reported_at";
|
|
57
58
|
const CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK_ID =
|
|
58
59
|
"telemetry:auth_fallback:last_reported_id";
|
|
60
|
+
const CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK =
|
|
61
|
+
"telemetry:tool_execution:last_reported_at";
|
|
62
|
+
const CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK_ID =
|
|
63
|
+
"telemetry:tool_execution:last_reported_id";
|
|
59
64
|
const REPORT_INTERVAL_MS = 5 * 60 * 1000;
|
|
60
65
|
const INITIAL_FLUSH_DELAY_MS = 30_000; // Delay first flush to let CES handshake complete
|
|
61
66
|
const BATCH_SIZE = 500;
|
|
@@ -149,6 +154,7 @@ export class UsageTelemetryReporter {
|
|
|
149
154
|
setMemoryCheckpoint(CHECKPOINT_KEY_LIFECYCLE_WATERMARK, now);
|
|
150
155
|
setMemoryCheckpoint(CHECKPOINT_KEY_ONBOARDING_WATERMARK, now);
|
|
151
156
|
setMemoryCheckpoint(CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK, now);
|
|
157
|
+
setMemoryCheckpoint(CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK, now);
|
|
152
158
|
return;
|
|
153
159
|
}
|
|
154
160
|
|
|
@@ -189,6 +195,14 @@ export class UsageTelemetryReporter {
|
|
|
189
195
|
getMemoryCheckpoint(CHECKPOINT_KEY_AUTH_FALLBACK_WATERMARK_ID) ??
|
|
190
196
|
undefined;
|
|
191
197
|
|
|
198
|
+
// Read tool-execution watermark (compound cursor: createdAt + id)
|
|
199
|
+
const toolExecutionWatermark = Number(
|
|
200
|
+
getMemoryCheckpoint(CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK) ?? "0",
|
|
201
|
+
);
|
|
202
|
+
const toolExecutionWatermarkId =
|
|
203
|
+
getMemoryCheckpoint(CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK_ID) ??
|
|
204
|
+
undefined;
|
|
205
|
+
|
|
192
206
|
// Query unreported events
|
|
193
207
|
const events = queryUnreportedUsageEvents(
|
|
194
208
|
watermark,
|
|
@@ -215,13 +229,19 @@ export class UsageTelemetryReporter {
|
|
|
215
229
|
authFallbackWatermarkId,
|
|
216
230
|
BATCH_SIZE,
|
|
217
231
|
);
|
|
232
|
+
const toolExecutionEvents = queryUnreportedToolExecutionEvents(
|
|
233
|
+
toolExecutionWatermark,
|
|
234
|
+
toolExecutionWatermarkId,
|
|
235
|
+
BATCH_SIZE,
|
|
236
|
+
);
|
|
218
237
|
|
|
219
238
|
if (
|
|
220
239
|
events.length === 0 &&
|
|
221
240
|
turnEvents.length === 0 &&
|
|
222
241
|
lifecycleEvents.length === 0 &&
|
|
223
242
|
onboardingEvents.length === 0 &&
|
|
224
|
-
authFallbackEvents.length === 0
|
|
243
|
+
authFallbackEvents.length === 0 &&
|
|
244
|
+
toolExecutionEvents.length === 0
|
|
225
245
|
)
|
|
226
246
|
return;
|
|
227
247
|
|
|
@@ -236,6 +256,7 @@ export class UsageTelemetryReporter {
|
|
|
236
256
|
lifecycleCount: lifecycleEvents.length,
|
|
237
257
|
onboardingCount: onboardingEvents.length,
|
|
238
258
|
authFallbackCount: authFallbackEvents.length,
|
|
259
|
+
toolExecutionCount: toolExecutionEvents.length,
|
|
239
260
|
},
|
|
240
261
|
"Telemetry flush: resolved auth context",
|
|
241
262
|
);
|
|
@@ -375,11 +396,11 @@ export class UsageTelemetryReporter {
|
|
|
375
396
|
...(e.stepIndex != null ? { step_index: e.stepIndex } : {}),
|
|
376
397
|
...(e.completedAt ? { completed_at: e.completedAt } : {}),
|
|
377
398
|
...(e.funnelVersion ? { funnel_version: e.funnelVersion } : {}),
|
|
378
|
-
// Onboarding events fall back to the envelope `assistant_version
|
|
379
|
-
//
|
|
380
|
-
//
|
|
381
|
-
//
|
|
382
|
-
//
|
|
399
|
+
// Onboarding events fall back to the envelope `assistant_version`,
|
|
400
|
+
// so events recorded under an older build are attributed to the
|
|
401
|
+
// version running at upload time. Adding a record-time column to
|
|
402
|
+
// `onboarding_events` (mirroring `llm_usage_events`) is a known
|
|
403
|
+
// follow-up.
|
|
383
404
|
assistant_version: APP_VERSION,
|
|
384
405
|
}),
|
|
385
406
|
),
|
|
@@ -402,6 +423,26 @@ export class UsageTelemetryReporter {
|
|
|
402
423
|
assistant_version: APP_VERSION,
|
|
403
424
|
}),
|
|
404
425
|
),
|
|
426
|
+
...toolExecutionEvents.map(
|
|
427
|
+
(e): TelemetryEvent => ({
|
|
428
|
+
type: "tool_execution",
|
|
429
|
+
daemon_event_id: e.id,
|
|
430
|
+
recorded_at: e.createdAt,
|
|
431
|
+
tool_name: e.toolName,
|
|
432
|
+
skill_id: e.skillId,
|
|
433
|
+
decision: e.decision,
|
|
434
|
+
risk_level: e.riskLevel,
|
|
435
|
+
duration_ms: e.durationMs,
|
|
436
|
+
conversation_id: e.conversationId,
|
|
437
|
+
// `tool_invocations` has no record-time version column — stamp
|
|
438
|
+
// the running binary's `APP_VERSION` so the wire value is
|
|
439
|
+
// concrete rather than an explicit null that would override the
|
|
440
|
+
// envelope under the platform's per-event-wins contract. Adding
|
|
441
|
+
// the record-time column is a separate follow-up that mirrors
|
|
442
|
+
// what migration 267 did for `llm_usage_events`.
|
|
443
|
+
assistant_version: APP_VERSION,
|
|
444
|
+
}),
|
|
445
|
+
),
|
|
405
446
|
];
|
|
406
447
|
|
|
407
448
|
const organizationId = getPlatformOrganizationId() || undefined;
|
|
@@ -501,13 +542,28 @@ export class UsageTelemetryReporter {
|
|
|
501
542
|
);
|
|
502
543
|
}
|
|
503
544
|
|
|
545
|
+
// Advance tool-execution watermark (compound cursor)
|
|
546
|
+
if (toolExecutionEvents.length > 0) {
|
|
547
|
+
const lastToolExecution =
|
|
548
|
+
toolExecutionEvents[toolExecutionEvents.length - 1];
|
|
549
|
+
setMemoryCheckpoint(
|
|
550
|
+
CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK,
|
|
551
|
+
String(lastToolExecution.createdAt),
|
|
552
|
+
);
|
|
553
|
+
setMemoryCheckpoint(
|
|
554
|
+
CHECKPOINT_KEY_TOOL_EXECUTION_WATERMARK_ID,
|
|
555
|
+
lastToolExecution.id,
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
|
|
504
559
|
// If we got a full batch of any type, there may be more — recurse
|
|
505
560
|
if (
|
|
506
561
|
events.length === BATCH_SIZE ||
|
|
507
562
|
turnEvents.length === BATCH_SIZE ||
|
|
508
563
|
lifecycleEvents.length === BATCH_SIZE ||
|
|
509
564
|
onboardingEvents.length === BATCH_SIZE ||
|
|
510
|
-
authFallbackEvents.length === BATCH_SIZE
|
|
565
|
+
authFallbackEvents.length === BATCH_SIZE ||
|
|
566
|
+
toolExecutionEvents.length === BATCH_SIZE
|
|
511
567
|
) {
|
|
512
568
|
await this._doFlush(batchCount + 1);
|
|
513
569
|
}
|
package/src/tools/executor.ts
CHANGED
|
@@ -485,9 +485,12 @@ function emitLifecycleEvent(
|
|
|
485
485
|
const handler = context.onToolLifecycleEvent;
|
|
486
486
|
if (!handler) return;
|
|
487
487
|
|
|
488
|
-
// Redact sensitive fields from tool inputs before they reach audit
|
|
488
|
+
// Redact sensitive fields from tool inputs before they reach audit
|
|
489
|
+
// listeners, and stamp the triggering skill id (if any) so audit/telemetry
|
|
490
|
+
// consumers can attribute skill-routed calls.
|
|
489
491
|
const sanitizedEvent = {
|
|
490
492
|
...event,
|
|
493
|
+
skillId: context.skillId,
|
|
491
494
|
input: sanitizeToolInput(event.toolName, event.input),
|
|
492
495
|
};
|
|
493
496
|
|
package/src/tools/skills/load.ts
CHANGED
|
@@ -290,11 +290,13 @@ export const skillLoadTool = {
|
|
|
290
290
|
skill.inlineCommandExpansions && skill.inlineCommandExpansions.length > 0;
|
|
291
291
|
|
|
292
292
|
if (hasInlineCommands) {
|
|
293
|
-
if (skill.source === "extra") {
|
|
294
|
-
// Third-party
|
|
295
|
-
//
|
|
293
|
+
if (skill.source === "extra" || skill.source === "plugin") {
|
|
294
|
+
// Third-party skill roots — `extra` dirs and skills shipped inside
|
|
295
|
+
// installed plugins — are out of scope for inline command expansion.
|
|
296
|
+
// Their bodies are untrusted, so reject explicitly rather than
|
|
297
|
+
// executing shell from them.
|
|
296
298
|
return {
|
|
297
|
-
content: `Error: skill "${skill.id}" contains inline command expansions but inline commands are not supported for third-party (
|
|
299
|
+
content: `Error: skill "${skill.id}" contains inline command expansions but inline commands are not supported for third-party (${skill.source}) skill sources.`,
|
|
298
300
|
isError: true,
|
|
299
301
|
};
|
|
300
302
|
}
|
|
@@ -367,9 +369,12 @@ export const skillLoadTool = {
|
|
|
367
369
|
childLoaded.skill.inlineCommandExpansions.length > 0;
|
|
368
370
|
|
|
369
371
|
if (childHasInlineCommands) {
|
|
370
|
-
if (
|
|
372
|
+
if (
|
|
373
|
+
childLoaded.skill.source === "extra" ||
|
|
374
|
+
childLoaded.skill.source === "plugin"
|
|
375
|
+
) {
|
|
371
376
|
return {
|
|
372
|
-
content: `Error: included skill "${childId}" contains inline command expansions but inline commands are not supported for third-party (
|
|
377
|
+
content: `Error: included skill "${childId}" contains inline command expansions but inline commands are not supported for third-party (${childLoaded.skill.source}) skill sources.`,
|
|
373
378
|
isError: true,
|
|
374
379
|
};
|
|
375
380
|
}
|
package/src/tools/types.ts
CHANGED
|
@@ -172,6 +172,8 @@ export interface ToolExecutedEvent {
|
|
|
172
172
|
conversationId: string;
|
|
173
173
|
requestId?: string;
|
|
174
174
|
executionTarget?: ExecutionTarget;
|
|
175
|
+
/** Id of the skill whose `skill_execute` dispatch triggered this tool call. Absent for direct tool calls. */
|
|
176
|
+
skillId?: string;
|
|
175
177
|
riskLevel: string;
|
|
176
178
|
/** ID of the trust rule that matched this invocation (if any). */
|
|
177
179
|
matchedTrustRuleId?: string;
|
|
@@ -210,6 +212,14 @@ export interface ToolContext {
|
|
|
210
212
|
assistantId?: string;
|
|
211
213
|
/** When set, the tool execution is part of a task run. Used to retrieve ephemeral permission rules. */
|
|
212
214
|
taskRunId?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Id of the skill whose `skill_execute` dispatch triggered this tool
|
|
217
|
+
* invocation. Set by the `skill_execute` interception in
|
|
218
|
+
* `daemon/conversation-tool-setup.ts`; the executor stamps it onto every
|
|
219
|
+
* lifecycle event so audit/telemetry consumers can attribute skill-routed
|
|
220
|
+
* calls. Absent for direct (non-skill) tool calls.
|
|
221
|
+
*/
|
|
222
|
+
skillId?: string;
|
|
213
223
|
/** Optional callback for tool lifecycle events (start/prompt/deny/execute/error). */
|
|
214
224
|
onToolLifecycleEvent?: ToolLifecycleEventHandler;
|
|
215
225
|
/** Optional resolver for proxy tools - delegates execution to an external client. */
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for plugin-contributed skills (PR 33).
|
|
3
|
-
*
|
|
4
|
-
* Covers:
|
|
5
|
-
* - A plugin declaring `skills: [...]` has its entries registered after
|
|
6
|
-
* bootstrap's `init()` succeeds.
|
|
7
|
-
* - The registered skill is discoverable via `loadSkillCatalog` and
|
|
8
|
-
* resolvable via `loadSkillBySelector` (the exact entry points the model's
|
|
9
|
-
* `skill_load` / `skill_execute` flow use).
|
|
10
|
-
* - Shutdown (runShutdownHooks) unregisters the plugin's skills so repeated
|
|
11
|
-
* bootstraps don't leak catalog entries.
|
|
12
|
-
* - Ref-counted register/unregister semantics match the tool registry's
|
|
13
|
-
* per-skill-id semantics (PR 13 precedent).
|
|
14
|
-
*
|
|
15
|
-
* Strategy mirrors `plugin-bootstrap.test.ts`: stub the credential store so
|
|
16
|
-
* bootstrap doesn't hit real backends, and `resetPluginRegistryForTests` /
|
|
17
|
-
* `resetPluginSkillContributionsForTests` between cases for isolation.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { rm } from "node:fs/promises";
|
|
21
|
-
import { tmpdir } from "node:os";
|
|
22
|
-
import { join } from "node:path";
|
|
23
|
-
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
24
|
-
|
|
25
|
-
// Stub credential store before importing bootstrap so the module captures
|
|
26
|
-
// the fake binding.
|
|
27
|
-
const getSecureKeyAsyncMock = mock(
|
|
28
|
-
async (_account: string): Promise<string | undefined> => undefined,
|
|
29
|
-
);
|
|
30
|
-
mock.module("../security/secure-keys.js", () => ({
|
|
31
|
-
getSecureKeyAsync: getSecureKeyAsyncMock,
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
import { loadSkillBySelector, loadSkillCatalog } from "../config/skills.js";
|
|
35
|
-
import { bootstrapPlugins } from "../daemon/external-plugins-bootstrap.js";
|
|
36
|
-
import { runShutdownHooks } from "../daemon/shutdown-registry.js";
|
|
37
|
-
import {
|
|
38
|
-
getPluginContributedSkillDefinition,
|
|
39
|
-
getPluginContributedSkillSummaries,
|
|
40
|
-
getPluginSkillRefCount,
|
|
41
|
-
registerPluginSkills,
|
|
42
|
-
resetPluginSkillContributionsForTests,
|
|
43
|
-
unregisterPluginSkills,
|
|
44
|
-
} from "../plugins/plugin-skill-contributions.js";
|
|
45
|
-
import {
|
|
46
|
-
registerPlugin,
|
|
47
|
-
resetPluginRegistryForTests,
|
|
48
|
-
} from "../plugins/registry.js";
|
|
49
|
-
import {
|
|
50
|
-
type Plugin,
|
|
51
|
-
PluginExecutionError,
|
|
52
|
-
type PluginSkillRegistration,
|
|
53
|
-
} from "../plugins/types.js";
|
|
54
|
-
|
|
55
|
-
// Per-process temp tree so bootstrap's plugin-storage directory creation
|
|
56
|
-
// doesn't touch the developer's real ~/.vellum.
|
|
57
|
-
const TEST_WORKSPACE_DIR = join(
|
|
58
|
-
tmpdir(),
|
|
59
|
-
`vellum-plugin-skill-test-${process.pid}`,
|
|
60
|
-
);
|
|
61
|
-
process.env.VELLUM_WORKSPACE_DIR = TEST_WORKSPACE_DIR;
|
|
62
|
-
|
|
63
|
-
/** Build a plugin that contributes one or more skills. */
|
|
64
|
-
function buildSkillPlugin(
|
|
65
|
-
name: string,
|
|
66
|
-
skills: PluginSkillRegistration[],
|
|
67
|
-
extras: Partial<Omit<Plugin, "manifest" | "skills">> = {},
|
|
68
|
-
): Plugin {
|
|
69
|
-
return {
|
|
70
|
-
manifest: {
|
|
71
|
-
name,
|
|
72
|
-
version: "0.0.1",
|
|
73
|
-
},
|
|
74
|
-
skills,
|
|
75
|
-
...extras,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
describe("plugin skill contributions", () => {
|
|
80
|
-
beforeEach(async () => {
|
|
81
|
-
resetPluginRegistryForTests();
|
|
82
|
-
resetPluginSkillContributionsForTests();
|
|
83
|
-
getSecureKeyAsyncMock.mockReset();
|
|
84
|
-
getSecureKeyAsyncMock.mockImplementation(async () => undefined);
|
|
85
|
-
await rm(TEST_WORKSPACE_DIR, { recursive: true, force: true });
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("plugin skills are registered after bootstrap and exposed by the catalog", async () => {
|
|
89
|
-
const skill: PluginSkillRegistration = {
|
|
90
|
-
id: "plugin-demo-skill",
|
|
91
|
-
name: "plugin-demo",
|
|
92
|
-
displayName: "Plugin Demo",
|
|
93
|
-
description: "A skill contributed by a plugin",
|
|
94
|
-
body: "# Plugin Demo\n\nThis is the plugin-provided body.",
|
|
95
|
-
activationHints: ["demo", "plugin"],
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
registerPlugin(buildSkillPlugin("demo-plugin", [skill]));
|
|
99
|
-
await bootstrapPlugins();
|
|
100
|
-
|
|
101
|
-
// Ref count bumped to exactly 1 so we can tell register and unregister
|
|
102
|
-
// are balanced downstream.
|
|
103
|
-
expect(getPluginSkillRefCount("demo-plugin")).toBe(1);
|
|
104
|
-
|
|
105
|
-
// In-memory registry query surfaces the summary form.
|
|
106
|
-
const summaries = getPluginContributedSkillSummaries();
|
|
107
|
-
const registered = summaries.find((s) => s.id === "plugin-demo-skill");
|
|
108
|
-
expect(registered).toBeDefined();
|
|
109
|
-
expect(registered?.source).toBe("plugin");
|
|
110
|
-
expect(registered?.name).toBe("plugin-demo");
|
|
111
|
-
expect(registered?.displayName).toBe("Plugin Demo");
|
|
112
|
-
expect(registered?.activationHints).toEqual(["demo", "plugin"]);
|
|
113
|
-
// Summary must not carry the body — bodies are definition-only.
|
|
114
|
-
expect((registered as unknown as { body?: unknown }).body).toBeUndefined();
|
|
115
|
-
|
|
116
|
-
// The full definition is retrievable by id.
|
|
117
|
-
const def = getPluginContributedSkillDefinition("plugin-demo-skill");
|
|
118
|
-
expect(def).toBeDefined();
|
|
119
|
-
expect(def?.body).toContain("This is the plugin-provided body");
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test("catalog and loadSkillBySelector discover plugin-contributed skills (skill_load pathway)", async () => {
|
|
123
|
-
const skill: PluginSkillRegistration = {
|
|
124
|
-
id: "catalog-visible-skill",
|
|
125
|
-
name: "catalog-visible",
|
|
126
|
-
description: "A plugin skill expected to surface in loadSkillCatalog",
|
|
127
|
-
body: "# Catalog-Visible Skill\n\nBody content for skill_load.",
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
registerPlugin(buildSkillPlugin("catalog-plugin", [skill]));
|
|
131
|
-
await bootstrapPlugins();
|
|
132
|
-
|
|
133
|
-
// loadSkillCatalog is the exact entry point `skill_load` consults via
|
|
134
|
-
// `loadSkillBySelector` -> `resolveSkillSelector`.
|
|
135
|
-
const catalog = loadSkillCatalog();
|
|
136
|
-
const found = catalog.find((s) => s.id === "catalog-visible-skill");
|
|
137
|
-
expect(found).toBeDefined();
|
|
138
|
-
expect(found?.source).toBe("plugin");
|
|
139
|
-
expect(found?.description).toBe(skill.description);
|
|
140
|
-
|
|
141
|
-
// loadSkillBySelector is what SkillLoadTool.execute calls — it must
|
|
142
|
-
// return a fully-populated SkillDefinition, including the body.
|
|
143
|
-
const lookup = loadSkillBySelector("catalog-visible-skill");
|
|
144
|
-
expect(lookup.error).toBeUndefined();
|
|
145
|
-
expect(lookup.skill).toBeDefined();
|
|
146
|
-
expect(lookup.skill?.id).toBe("catalog-visible-skill");
|
|
147
|
-
expect(lookup.skill?.body).toContain("Body content for skill_load");
|
|
148
|
-
|
|
149
|
-
// And name-based resolution (what users type when the model picks a
|
|
150
|
-
// skill by name) works the same way.
|
|
151
|
-
const byName = loadSkillBySelector("catalog-visible");
|
|
152
|
-
expect(byName.skill?.id).toBe("catalog-visible-skill");
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test("shutdown unregisters plugin skills so the catalog no longer lists them", async () => {
|
|
156
|
-
const skill: PluginSkillRegistration = {
|
|
157
|
-
id: "ephemeral-skill",
|
|
158
|
-
name: "ephemeral",
|
|
159
|
-
description: "Disappears after shutdown",
|
|
160
|
-
body: "Only visible while the plugin is alive.",
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
registerPlugin(buildSkillPlugin("ephemeral-plugin", [skill]));
|
|
164
|
-
await bootstrapPlugins();
|
|
165
|
-
|
|
166
|
-
// Sanity: present before shutdown.
|
|
167
|
-
expect(loadSkillCatalog().some((s) => s.id === "ephemeral-skill")).toBe(
|
|
168
|
-
true,
|
|
169
|
-
);
|
|
170
|
-
expect(getPluginSkillRefCount("ephemeral-plugin")).toBe(1);
|
|
171
|
-
|
|
172
|
-
await runShutdownHooks("test-shutdown");
|
|
173
|
-
|
|
174
|
-
// After shutdown, the plugin's skill is gone from both the in-memory
|
|
175
|
-
// registry and any catalog view that consults it.
|
|
176
|
-
expect(getPluginSkillRefCount("ephemeral-plugin")).toBe(0);
|
|
177
|
-
expect(
|
|
178
|
-
getPluginContributedSkillDefinition("ephemeral-skill"),
|
|
179
|
-
).toBeUndefined();
|
|
180
|
-
|
|
181
|
-
const catalogAfter = loadSkillCatalog();
|
|
182
|
-
expect(catalogAfter.some((s) => s.id === "ephemeral-skill")).toBe(false);
|
|
183
|
-
|
|
184
|
-
// And the selector lookup the model would use fails closed.
|
|
185
|
-
const lookup = loadSkillBySelector("ephemeral-skill");
|
|
186
|
-
expect(lookup.skill).toBeUndefined();
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test("bootstrap is a no-op for plugins without a skills list", async () => {
|
|
190
|
-
// A plugin with no `skills` field must not bump ref counts or
|
|
191
|
-
// populate the catalog at all.
|
|
192
|
-
registerPlugin({
|
|
193
|
-
manifest: {
|
|
194
|
-
name: "no-skills-plugin",
|
|
195
|
-
version: "0.0.1",
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
await bootstrapPlugins();
|
|
200
|
-
|
|
201
|
-
expect(getPluginSkillRefCount("no-skills-plugin")).toBe(0);
|
|
202
|
-
expect(getPluginContributedSkillSummaries()).toEqual([]);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test("duplicate skill id across plugins fails bootstrap with the plugin named", async () => {
|
|
206
|
-
const shared: PluginSkillRegistration = {
|
|
207
|
-
id: "contested-id",
|
|
208
|
-
name: "contested",
|
|
209
|
-
description: "First",
|
|
210
|
-
body: "from first plugin",
|
|
211
|
-
};
|
|
212
|
-
const duplicate: PluginSkillRegistration = {
|
|
213
|
-
id: "contested-id",
|
|
214
|
-
name: "contested",
|
|
215
|
-
description: "Second",
|
|
216
|
-
body: "from second plugin",
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
registerPlugin(buildSkillPlugin("first-plugin", [shared]));
|
|
220
|
-
registerPlugin(buildSkillPlugin("second-plugin", [duplicate]));
|
|
221
|
-
|
|
222
|
-
let caught: unknown;
|
|
223
|
-
try {
|
|
224
|
-
await bootstrapPlugins();
|
|
225
|
-
} catch (err) {
|
|
226
|
-
caught = err;
|
|
227
|
-
}
|
|
228
|
-
expect(caught).toBeInstanceOf(PluginExecutionError);
|
|
229
|
-
// The error must identify which plugin tripped the collision so
|
|
230
|
-
// operators can deploy a fix.
|
|
231
|
-
const msg = (caught as PluginExecutionError).message;
|
|
232
|
-
expect(msg).toContain("second-plugin");
|
|
233
|
-
expect(msg).toContain("contested-id");
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test("intra-batch duplicate skill id in one plugin is rejected at registration", () => {
|
|
237
|
-
// Directly exercise the registry (no bootstrap) — a single plugin
|
|
238
|
-
// declaring the same id twice is a configuration bug and must fail
|
|
239
|
-
// loudly rather than silently overwrite.
|
|
240
|
-
expect(() =>
|
|
241
|
-
registerPluginSkills("dup-plugin", [
|
|
242
|
-
{
|
|
243
|
-
id: "dup-id",
|
|
244
|
-
name: "one",
|
|
245
|
-
description: "first",
|
|
246
|
-
body: "A",
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
id: "dup-id",
|
|
250
|
-
name: "two",
|
|
251
|
-
description: "second",
|
|
252
|
-
body: "B",
|
|
253
|
-
},
|
|
254
|
-
]),
|
|
255
|
-
).toThrow(PluginExecutionError);
|
|
256
|
-
expect(() =>
|
|
257
|
-
registerPluginSkills("dup-plugin", [
|
|
258
|
-
{ id: "x", name: "one", description: "a", body: "A" },
|
|
259
|
-
{ id: "x", name: "two", description: "b", body: "B" },
|
|
260
|
-
]),
|
|
261
|
-
).toThrow(/declared skill "x" more than once/);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
test("ref-counted unregister: second unregister call after repeated registers drops skills", () => {
|
|
265
|
-
const registrations: PluginSkillRegistration[] = [
|
|
266
|
-
{
|
|
267
|
-
id: "refcount-skill",
|
|
268
|
-
name: "refcount",
|
|
269
|
-
description: "Ref-count demo",
|
|
270
|
-
body: "stays until the counter hits zero",
|
|
271
|
-
},
|
|
272
|
-
];
|
|
273
|
-
|
|
274
|
-
registerPluginSkills("refcount-plugin", registrations);
|
|
275
|
-
// Second call is the "same plugin registered again" pattern (hot
|
|
276
|
-
// reload). It must bump the counter without re-inserting.
|
|
277
|
-
registerPluginSkills("refcount-plugin", registrations);
|
|
278
|
-
expect(getPluginSkillRefCount("refcount-plugin")).toBe(2);
|
|
279
|
-
expect(getPluginContributedSkillDefinition("refcount-skill")).toBeDefined();
|
|
280
|
-
|
|
281
|
-
// One unregister decrements only — skill must still be registered.
|
|
282
|
-
unregisterPluginSkills("refcount-plugin");
|
|
283
|
-
expect(getPluginSkillRefCount("refcount-plugin")).toBe(1);
|
|
284
|
-
expect(getPluginContributedSkillDefinition("refcount-skill")).toBeDefined();
|
|
285
|
-
|
|
286
|
-
// Second unregister drops the entry for real.
|
|
287
|
-
unregisterPluginSkills("refcount-plugin");
|
|
288
|
-
expect(getPluginSkillRefCount("refcount-plugin")).toBe(0);
|
|
289
|
-
expect(
|
|
290
|
-
getPluginContributedSkillDefinition("refcount-skill"),
|
|
291
|
-
).toBeUndefined();
|
|
292
|
-
|
|
293
|
-
// Third unregister (over-decrement) is a no-op, not a throw — mirrors
|
|
294
|
-
// the tool-registry behavior so shutdown races don't crash the
|
|
295
|
-
// daemon.
|
|
296
|
-
expect(() => unregisterPluginSkills("refcount-plugin")).not.toThrow();
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test("managed (filesystem) skill with the same id overrides a plugin-contributed skill", async () => {
|
|
300
|
-
// Plugin skills sit below managed/workspace in the catalog precedence
|
|
301
|
-
// chain so a user can shadow a plugin-provided skill by dropping a
|
|
302
|
-
// SKILL.md with the same id under ~/.vellum/workspace/skills. The test
|
|
303
|
-
// harness configures VELLUM_WORKSPACE_DIR via the bun test preload, so
|
|
304
|
-
// we can synthesize a filesystem skill for the same id and assert it
|
|
305
|
-
// wins.
|
|
306
|
-
const { mkdirSync, writeFileSync, rmSync, existsSync } =
|
|
307
|
-
await import("node:fs");
|
|
308
|
-
|
|
309
|
-
const workspaceDir = process.env.VELLUM_WORKSPACE_DIR;
|
|
310
|
-
// Skip the filesystem override check when the harness did not provide a
|
|
311
|
-
// workspace dir — the other tests in this file still cover catalog
|
|
312
|
-
// visibility, which is the core of PR 33.
|
|
313
|
-
if (!workspaceDir) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const skillsDir = join(workspaceDir, "skills", "shared-id");
|
|
318
|
-
mkdirSync(skillsDir, { recursive: true });
|
|
319
|
-
writeFileSync(
|
|
320
|
-
join(skillsDir, "SKILL.md"),
|
|
321
|
-
[
|
|
322
|
-
"---",
|
|
323
|
-
'name: "filesystem-version"',
|
|
324
|
-
'description: "User-authored override"',
|
|
325
|
-
"---",
|
|
326
|
-
"",
|
|
327
|
-
"# Filesystem Override",
|
|
328
|
-
].join("\n"),
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
const pluginSkill: PluginSkillRegistration = {
|
|
332
|
-
id: "shared-id",
|
|
333
|
-
name: "plugin-version",
|
|
334
|
-
description: "Plugin-provided skill that should be shadowed",
|
|
335
|
-
body: "plugin body",
|
|
336
|
-
};
|
|
337
|
-
registerPlugin(buildSkillPlugin("shadow-plugin", [pluginSkill]));
|
|
338
|
-
|
|
339
|
-
try {
|
|
340
|
-
await bootstrapPlugins();
|
|
341
|
-
|
|
342
|
-
const catalog = loadSkillCatalog();
|
|
343
|
-
const entry = catalog.find((s) => s.id === "shared-id");
|
|
344
|
-
// The filesystem SKILL.md wins — source flips to "managed" and the
|
|
345
|
-
// plugin's metadata is not what we see.
|
|
346
|
-
expect(entry).toBeDefined();
|
|
347
|
-
expect(entry?.source).toBe("managed");
|
|
348
|
-
expect(entry?.name).toBe("filesystem-version");
|
|
349
|
-
} finally {
|
|
350
|
-
if (existsSync(skillsDir)) {
|
|
351
|
-
rmSync(skillsDir, { recursive: true, force: true });
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Browser interaction types.
|
|
2
|
-
// CDP request/response messaging was removed — Playwright's connectOverCDP is broken
|
|
3
|
-
// under Bun's runtime. Browser is now launched directly via Playwright.
|
|
4
|
-
|
|
5
|
-
// --- Domain-level union aliases (consumed by the barrel file) ---
|
|
6
|
-
// These must exist (even as `never`) so the barrel union compiles.
|
|
7
|
-
|
|
8
|
-
export type _BrowserClientMessages = never;
|
|
9
|
-
|
|
10
|
-
export type _BrowserServerMessages = never;
|