@vellumai/assistant 0.8.7-dev.202606052118.34cd356 → 0.8.7-dev.202606052135.3e62c5a

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/docs/plugins.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Plugins
2
2
 
3
3
  > **Note:** This guide documents the **legacy** plugin architecture — the
4
- > in-tree `register.ts` + middleware-pipeline system. We are converging on
4
+ > in-tree `register.ts` registration system. We are converging on
5
5
  > the schema at
6
6
  > [`experimental/plugins/README.md`](../../experimental/plugins/README.md)
7
7
  > (file-based discovery, a `package.json` manifest, the
@@ -26,10 +26,7 @@ wired surface.
26
26
  - [Where plugins live](#where-plugins-live)
27
27
  - [Manifest](#manifest)
28
28
  - [Registration](#registration)
29
- - [Middleware patterns](#middleware-patterns)
30
29
  - [Hooks](#hooks)
31
- - [Pipeline reference](#pipeline-reference)
32
- - [Timeouts](#timeouts)
33
30
  - [Strict-fail semantics](#strict-fail-semantics)
34
31
  - [Credentials and config](#credentials-and-config)
35
32
  - [Tool, route, and skill contributions](#tool-route-and-skill-contributions)
@@ -43,25 +40,22 @@ wired surface.
43
40
 
44
41
  1. Create a directory `<workspaceDir>/plugins/my-plugin/`.
45
42
  2. Drop a `package.json` with a `name` and a `peerDependencies["@vellumai/plugin-api"]` semver range.
46
- 3. Add `middlewares/<name>.ts` files (default export = middleware function).
43
+ 3. Add `hooks/<name>.ts` files (default export = hook function).
47
44
  4. Add `tools/<name>.ts` files (default export = tool definition).
48
45
  5. Restart the assistant — the loader scans `<workspaceDir>/plugins/*` and
49
46
  registers the plugin on startup.
50
47
 
51
48
  ## What a plugin can contribute today
52
49
 
53
- | Surface | Where | Discovery |
54
- | -------------------------- | ------------------- | ------------------------------------------------- |
55
- | Pipeline middleware | `plugin.middleware` | keyed by pipeline name in `PipelineMiddlewareMap` |
56
- | Model-visible tools | `plugin.tools` | each `PluginToolRegistration` |
57
- | HTTP routes | `plugin.routes` | each `PluginRouteRegistration` |
58
- | Skills | `plugin.skills` | each `PluginSkillRegistration` |
59
- | System-prompt injectors | `plugin.injectors` | each `Injector` |
60
- | Lifecycle & per-turn hooks | `plugin.hooks` | keyed by hook name (`init`, `shutdown`, …) |
50
+ | Surface | Where | Discovery |
51
+ | -------------------------- | --------------- | ------------------------------------------ |
52
+ | Model-visible tools | `plugin.tools` | each `PluginToolRegistration` |
53
+ | HTTP routes | `plugin.routes` | each `PluginRouteRegistration` |
54
+ | Skills | `plugin.skills` | each `PluginSkillRegistration` |
55
+ | Lifecycle & per-turn hooks | `plugin.hooks` | keyed by hook name (`init`, `shutdown`, …) |
61
56
 
62
- The modern schema wires only **hooks** and **tools**; the middleware
63
- pipelines, routes, skills, and injectors above are the surfaces that still
64
- have no modern equivalent.
57
+ The modern schema wires only **hooks** and **tools**; routes and skills
58
+ above are the surfaces that still have no modern equivalent.
65
59
 
66
60
  ---
67
61
 
@@ -70,8 +64,8 @@ have no modern equivalent.
70
64
  A plugin is a directory that exports a single `register.ts` (or compiled
71
65
  `register.js`) entry point. That file builds a `Plugin` object and passes
72
66
  it to `registerPlugin()` as an import-time side effect. Everything else —
73
- pipeline middleware, lifecycle hooks, model-visible capabilities — hangs
74
- off that one `Plugin` object.
67
+ lifecycle hooks, model-visible capabilities — hangs off that one `Plugin`
68
+ object.
75
69
 
76
70
  ```
77
71
  my-plugin/
@@ -90,8 +84,6 @@ export interface Plugin {
90
84
  tools?: Tool[];
91
85
  routes?: PluginRouteRegistration[];
92
86
  skills?: PluginSkillRegistration[];
93
- injectors?: Injector[];
94
- middleware?: Partial<PipelineMiddlewareMap>;
95
87
  }
96
88
  ```
97
89
 
@@ -256,7 +248,7 @@ const myPlugin: Plugin = {
256
248
  name: "my-plugin",
257
249
  version: "0.1.0",
258
250
  },
259
- middleware: {
251
+ hooks: {
260
252
  /* ... */
261
253
  },
262
254
  };
@@ -292,121 +284,6 @@ and they have no module-identity effect at runtime.
292
284
  - The bridge is installed by the daemon before `loadUserPlugins()` runs, so
293
285
  the global is always present when a plugin's module body executes.
294
286
 
295
- ## Middleware patterns
296
-
297
- Middleware is the heart of the plugin system. Every pipeline slot uses the
298
- same onion-style signature:
299
-
300
- ```typescript
301
- export type Middleware<A, R> = (
302
- args: A,
303
- next: (args: A) => Promise<R>,
304
- ctx: TurnContext,
305
- ) => Promise<R>;
306
- ```
307
-
308
- The runner composes an array of middleware around a terminal handler. The
309
- first middleware sees the request first and the response last; the
310
- terminal runs at the innermost layer. See
311
- [`assistant/src/plugins/pipeline.ts`](../src/plugins/pipeline.ts) for the
312
- composition algorithm.
313
-
314
- Five common patterns emerge from that signature:
315
-
316
- ### Observe-only
317
-
318
- Record something without changing the call. Call `next(args)` unchanged,
319
- return the result unchanged. Wrap the call in `try`/`finally` so your
320
- observer runs on both success and failure paths.
321
-
322
- ```typescript
323
- const observer: Middleware<MemoryArgs, MemoryResult> =
324
- async function observeRetrieval(args, next, ctx) {
325
- const start = performance.now();
326
- let outcome: "success" | "error" = "success";
327
- try {
328
- return await next(args);
329
- } catch (err) {
330
- outcome = "error";
331
- throw err;
332
- } finally {
333
- const ms = Math.round(performance.now() - start);
334
- console.error(
335
- JSON.stringify({ conversationId: args.conversationId, ms, outcome }),
336
- );
337
- }
338
- };
339
- ```
340
-
341
- ### Transform input
342
-
343
- Rewrite `args` before calling downstream. Useful for reshaping the inputs
344
- (forcing an untrusted read, narrowing the turn the retriever sees).
345
-
346
- ```typescript
347
- const untrustedRead: Middleware<MemoryArgs, MemoryResult> =
348
- async function untrustedRead(args, next, ctx) {
349
- return next({ ...args, trustContext: undefined });
350
- };
351
- ```
352
-
353
- ### Transform output
354
-
355
- Call `next(args)` first, then modify the result before returning.
356
-
357
- ```typescript
358
- const dropNow: Middleware<MemoryArgs, MemoryResult> = async function dropNow(
359
- args,
360
- next,
361
- ctx,
362
- ) {
363
- const result = await next(args);
364
- return { ...result, nowContent: null };
365
- };
366
- ```
367
-
368
- ### Short-circuit
369
-
370
- Do not call `next(args)` — return a synthetic result directly. The
371
- terminal and any inner middleware are skipped. Use this to stub, cache,
372
- or mock a pipeline.
373
-
374
- ```typescript
375
- const skipUntrusted: Middleware<MemoryArgs, MemoryResult> =
376
- async function skipUntrusted(args, next, ctx) {
377
- if (!isTrusted(ctx.trust)) {
378
- return { pkbContent: null, nowContent: null, graphResult: null };
379
- }
380
- return next(args);
381
- };
382
- ```
383
-
384
- ### Veto (throw)
385
-
386
- Throwing from middleware aborts the pipeline. The error propagates out
387
- through any outer middleware unchanged — there is no internal
388
- `try`/`catch` around user middleware.
389
-
390
- ```typescript
391
- const denyIfUntrusted: Middleware<CompactionArgs, CompactionResult> =
392
- async function denyIfUntrusted(args, next, ctx) {
393
- if (!isTrusted(ctx.trust)) {
394
- throw new Error(`compaction denied by policy`);
395
- }
396
- return next(args);
397
- };
398
- ```
399
-
400
- ### Naming middleware
401
-
402
- Give middleware a stable `name` (via `async function <name>(…)`). The
403
- pipeline runner pulls `Function.name` into its `chain` log field so
404
- operators can see the registered chain at a glance:
405
-
406
- ```
407
- plugin.pipeline pipeline=compaction chain=["observeCompaction","defaultCompaction"] durationMs=1840 outcome=success
408
- ```
409
-
410
287
  ## Hooks
411
288
 
412
289
  Hooks are the **modern** lifecycle surface: a plugin contributes one
@@ -428,35 +305,10 @@ first.
428
305
  | `post-tool-use` | Once per tool result, before it joins the provider-bound history. | `PostToolUseContext` |
429
306
  | `stop` | Once per run when the model yields a turn with no tool calls. | `StopContext` |
430
307
 
431
- ## Pipeline reference
432
-
433
- Every pipeline slot and its purpose. Type details live in
434
- [`types.ts`](../src/plugins/types.ts).
435
-
436
- | Pipeline | Purpose |
437
- | ------------ | ---------------------------------------------------------------------------- |
438
- | `compaction` | The conversation-compaction step. Wraps `ContextWindowManager.maybeCompact`. |
439
-
440
- ## Timeouts
441
-
442
- Each pipeline has a default timeout budget in milliseconds. When the
443
- budget is exceeded the runner throws `PluginTimeoutError` carrying the
444
- pipeline name, the offending plugin's name (if known), and the elapsed
445
- duration. See
446
- [`assistant/src/plugins/pipeline.ts`](../src/plugins/pipeline.ts) for the
447
- current values.
448
-
449
- | Pipeline | Timeout | Rationale |
450
- | ------------ | -------- | ---------------------------------------------------------------------------------------------------- |
451
- | `compaction` | 30000 ms | Summarization involves a provider call; mirrors the pipeline-level budget for LLM-backed operations. |
452
-
453
- `null` timeouts skip the timer entirely. Finite timeouts arm a
454
- `setTimeout` that races the pipeline via `Promise.race`.
455
-
456
308
  ## Strict-fail semantics
457
309
 
458
- **Plugin errors and timeouts fail the turn loudly. There is no silent
459
- fallback to the default behavior.**
310
+ **Plugin errors fail the turn loudly. There is no silent fallback to the
311
+ default behavior.**
460
312
 
461
313
  This is a deliberate design decision. The old inline behavior silently
462
314
  absorbed many edge cases (a memory retrieval failure became an empty
@@ -466,20 +318,15 @@ logs nobody checked.
466
318
 
467
319
  With strict-fail:
468
320
 
469
- - Any error thrown from middleware propagates up to the caller. The
470
- pipeline runner does not catch it.
471
- - Any `PluginTimeoutError` from a budget breach propagates identically.
321
+ - Any error thrown from a hook propagates up to the caller. The hook
322
+ runner does not catch it.
472
323
  - The caller (agent loop, memory subsystem, whoever) decides how to
473
- degrade. The pipeline itself does not paper over the failure.
474
- - Exactly one structured log line is emitted per pipeline invocation, in
475
- a `finally` block, regardless of outcome. It carries `outcome`
476
- (`"success" | "error" | "timeout"`), `durationMs`, `chain`, plugin
477
- attribution, and error details when applicable.
478
-
479
- If you're writing middleware that wants to "try, fall back to default on
480
- failure," express that at the call site instead — wrap the pipeline
324
+ degrade. The runner itself does not paper over the failure.
325
+
326
+ If you're writing a hook that wants to "try, fall back to default on
327
+ failure," express that at the call site instead — wrap the hook
481
328
  invocation in your own try/catch. Do not swallow the error inside your
482
- middleware's `try`/`catch` and silently return a degraded result.
329
+ hook's `try`/`catch` and silently return a degraded result.
483
330
 
484
331
  ## Credentials and config
485
332
 
@@ -569,7 +416,7 @@ assistant restart. The bootstrap creates it on demand.
569
416
  ## Tool, route, and skill contributions
570
417
 
571
418
  Plugins can contribute model-visible capabilities alongside their
572
- middleware. Each is optional.
419
+ hooks. Each is optional.
573
420
 
574
421
  ### Tools (`plugin.tools`)
575
422
 
@@ -659,37 +506,6 @@ See
659
506
  [`plugin-skill-contributions.ts`](../src/plugins/plugin-skill-contributions.ts)
660
507
  for the in-memory registry details and ref-counted lifecycle.
661
508
 
662
- ### Injectors (`plugin.injectors`)
663
-
664
- An array of `Injector` objects that emit system-prompt-time content.
665
- Each has a stable `name`, an ascending `order` used to position it in the
666
- injection chain, and a `produce(ctx)` method that returns an
667
- `InjectionBlock` or `null`.
668
-
669
- The default injectors use `order` 10 through 70 with gaps of 10, so
670
- plugin-contributed injectors can slot at `25`, `35`, etc. without
671
- renumbering.
672
-
673
- ```typescript
674
- const myPlugin: Plugin = {
675
- manifest: {
676
- /* ... */
677
- },
678
- injectors: [
679
- {
680
- name: "my-plugin/status",
681
- order: 25,
682
- async produce(ctx) {
683
- return {
684
- id: "my-plugin/status",
685
- text: `<my_plugin_status>ok</my_plugin_status>`,
686
- };
687
- },
688
- },
689
- ],
690
- };
691
- ```
692
-
693
509
  ## Cross-plugin communication
694
510
 
695
511
  Plugins should not call each other directly. There is no cross-plugin
@@ -770,50 +586,6 @@ The config block under `config.plugins.<name>` failed the manifest's
770
586
  parser. Check your config against the plugin's schema — the error
771
587
  message carries the validator's diagnostic.
772
588
 
773
- ### `PluginTimeoutError: Plugin pipeline '<name>' timed out after N ms`
774
-
775
- A plugin's middleware exceeded the pipeline's budget. The offending
776
- plugin is named in `ctx.pluginName` when available. Tighten the
777
- middleware (it's probably blocking on I/O it shouldn't) or, if the
778
- work is genuinely heavy, move it out of the critical path into a
779
- background job that publishes results through `assistantEventHub`.
780
-
781
- ### Reading pipeline log records
782
-
783
- Every pipeline invocation emits one structured line tagged
784
- `event=plugin.pipeline`. The fields:
785
-
786
- | Field | Meaning |
787
- | ------------------------------------------ | ----------------------------------------------------------------------- |
788
- | `pipeline` | Pipeline name (`compaction`). |
789
- | `chain` | Ordered list of middleware function names, outermost first. |
790
- | `durationMs` | Total time spent in the composed chain. |
791
- | `outcome` | `"success"`, `"error"`, or `"timeout"`. |
792
- | `pluginName` | The specific plugin's name when the runner could attribute the frame. |
793
- | `timeoutMs` | The configured budget (only when one was set). |
794
- | `errorName`, `errorMessage`, `errorStack` | Present on failure outcomes. |
795
- | `requestId`, `conversationId`, `turnIndex` | Per-turn context for correlating with the rest of the assistant's logs. |
796
-
797
- Pipe the assistant's stderr through `jq` to filter and inspect:
798
-
799
- ```bash
800
- tail -f ~/.vellum/daemon.log | jq 'select(.event == "plugin.pipeline")'
801
- ```
802
-
803
- To isolate slow pipelines:
804
-
805
- ```bash
806
- tail -f ~/.vellum/daemon.log \
807
- | jq 'select(.event == "plugin.pipeline" and .durationMs > 1000)'
808
- ```
809
-
810
- To isolate errors and timeouts:
811
-
812
- ```bash
813
- tail -f ~/.vellum/daemon.log \
814
- | jq 'select(.event == "plugin.pipeline" and .outcome != "success")'
815
- ```
816
-
817
589
  ### Plugin not loading at all
818
590
 
819
591
  - Confirm the directory is under `<workspaceDir>/plugins/`.
@@ -1,33 +1,30 @@
1
1
  # Echo plugin
2
2
 
3
- Minimal example plugin. Observes every assistant pipeline and logs one JSON
4
- line per invocation to `stderr`:
3
+ Minimal example plugin. Observes the assistant's turn-lifecycle hooks and logs
4
+ one JSON line per hook invocation to `stderr`:
5
5
 
6
6
  ```json
7
7
  {
8
8
  "plugin": "echo",
9
- "pipeline": "compaction",
10
- "durationMs": 1590,
11
- "outcome": "success"
9
+ "hook": "post-tool-use",
10
+ "conversationId": "conv_abc123"
12
11
  }
13
12
  ```
14
13
 
15
14
  Use this as a starting point for writing your own plugin, or as a quick way
16
- to eyeball which pipelines fire during a conversation and how long they
17
- take.
15
+ to eyeball which hooks fire during a conversation.
18
16
 
19
17
  For the full plugin authoring guide, see
20
18
  [`assistant/docs/plugins.md`](../../../docs/plugins.md).
21
19
 
22
20
  ## What it does
23
21
 
24
- - Registers one observer middleware per slot in
25
- `PipelineMiddlewareMap` — `compaction`.
26
- - Each middleware calls `next(args)` to pass the request through unchanged,
27
- measures wall-clock duration, and emits one line to `stderr` whether the
28
- downstream succeeded or threw.
29
- - Never modifies arguments, never rewrites results, never swallows errors.
30
- It is purely observational — safe to stack alongside any other plugin.
22
+ - Registers one observer hook per turn-lifecycle event:
23
+ `user-prompt-submit`, `post-tool-use`, and `stop`.
24
+ - Each hook emits one line to `stderr` and returns `void`, so the threaded
25
+ context flows through unchanged.
26
+ - Never modifies the turn's messages, tool results, or stop decision. It is
27
+ purely observational — safe to stack alongside any other plugin.
31
28
 
32
29
  ## Install locally
33
30
 
@@ -87,28 +84,23 @@ vellum restart
87
84
  ## Verify it works
88
85
 
89
86
  With the plugin installed and the assistant restarted, send any message
90
- that exercises a pipeline — a conversation turn, a tool call, a title
91
- generation — and tail the assistant's stderr log:
87
+ that exercises a turn — a conversation reply, a tool call — and tail the
88
+ assistant's stderr log:
92
89
 
93
90
  ```bash
94
91
  tail -f ~/.vellum/daemon.log
95
92
  ```
96
93
 
97
- You should see one line per pipeline invocation, similar to:
94
+ You should see one line per hook invocation, similar to:
98
95
 
99
96
  ```json
100
97
  {
101
98
  "plugin": "echo",
102
- "pipeline": "compaction",
103
- "durationMs": 1590,
104
- "outcome": "success"
99
+ "hook": "post-tool-use",
100
+ "conversationId": "conv_abc123"
105
101
  }
106
102
  ```
107
103
 
108
- If a pipeline throws (for example, a tool that errors out), you'll see a
109
- line with `"outcome":"error"` — the plugin rethrows after logging so the
110
- original error still propagates.
111
-
112
104
  ## Uninstall
113
105
 
114
106
  Remove the symlink (or the copied directory) and restart the assistant:
@@ -121,13 +113,11 @@ vellum restart
121
113
  ## Next steps
122
114
 
123
115
  - Read [`assistant/docs/plugins.md`](../../../docs/plugins.md) for the full
124
- plugin authoring guide: manifest shape, middleware patterns
125
- (observe / transform / short-circuit / veto), strict-fail semantics, the
126
- per-pipeline timeout table, credential and config access, and
127
- troubleshooting.
116
+ plugin authoring guide: manifest shape, hook patterns
117
+ (observe / transform), credential and config access, and troubleshooting.
128
118
  - Look at the first-party default plugins under
129
- `assistant/src/plugins/defaults/` for examples of non-observational
130
- middleware.
119
+ `assistant/src/plugins/defaults/` for examples of hooks that transform a
120
+ turn rather than just observing it.
131
121
  - Build your own plugin by copying this directory, renaming the manifest
132
- `name`, and replacing the observer with a middleware that does whatever
133
- you need.
122
+ `name`, and replacing the observer hooks with ones that do whatever you
123
+ need.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Echo plugin — observes every assistant pipeline and logs one structured
3
- * line per invocation to stderr.
2
+ * Echo plugin — observes the assistant's turn-lifecycle hooks and logs one
3
+ * structured line per hook invocation to stderr.
4
4
  *
5
5
  * Bundled in the repository as an authoring reference. To try it locally,
6
6
  * symlink (or copy) this directory into `<workspaceDir>/plugins/echo/` and
@@ -25,27 +25,25 @@
25
25
  *
26
26
  * ## Design
27
27
  *
28
- * - Registers an observer middleware on every slot of `PipelineMiddlewareMap`.
29
- * - Each middleware records a start timestamp, calls `next(args)`, and on
30
- * return — whether successful or not — emits one JSON line on `stderr` with
31
- * `{ plugin, pipeline, durationMs, outcome }`. A `try { return await next(); }
32
- * catch { outcome = "error"; rethrow; } finally { log(); }` pattern keeps the
33
- * observation strictly non-interfering: the plugin never swallows errors
34
- * and never rewrites arguments or results.
35
- * - Middleware is declared as async functions with stable names so the
36
- * pipeline runner's `chain` log field attributes them correctly.
28
+ * - Registers an observer hook for each turn-lifecycle event
29
+ * (`user-prompt-submit`, `post-tool-use`, `stop`).
30
+ * - Each hook emits one JSON line on `stderr` with `{ plugin, hook,
31
+ * conversationId }` and returns `void`, leaving the threaded context
32
+ * untouched. The plugin is purely observational — it never mutates the
33
+ * turn's messages, tool results, or stop decision.
37
34
  *
38
35
  * The file exports no named symbols at module level — it only runs
39
36
  * `registerPlugin(echoPlugin)` as an import-time side effect, matching the
40
37
  * user-plugin-loader contract (see `assistant/src/plugins/user-loader.ts`).
41
38
  */
42
39
 
43
- import type { VellumPluginRuntime } from "../../../src/plugins/external-api.js";
44
40
  import type {
45
- CompactionArgs,
46
- CompactionResult,
47
- Plugin,
48
- } from "../../../src/plugins/types.js";
41
+ PostToolUseContext,
42
+ StopContext,
43
+ UserPromptSubmitContext,
44
+ } from "../../../src/plugin-api/types.js";
45
+ import type { VellumPluginRuntime } from "../../../src/plugins/external-api.js";
46
+ import type { Plugin } from "../../../src/plugins/types.js";
49
47
 
50
48
  const runtime = (globalThis as { __vellumPluginRuntime?: VellumPluginRuntime })
51
49
  .__vellumPluginRuntime;
@@ -59,56 +57,18 @@ const { registerPlugin } = runtime;
59
57
  const PLUGIN_NAME = "echo";
60
58
 
61
59
  /**
62
- * One line written to stderr per pipeline invocation. Kept intentionally
63
- * compact — pino-style JSON so operators can pipe the assistant's stderr
64
- * through `jq` without reshaping.
60
+ * One line written to stderr per hook invocation. Kept intentionally compact —
61
+ * pino-style JSON so operators can pipe the assistant's stderr through `jq`
62
+ * without reshaping.
65
63
  */
66
- function emit(
67
- pipelineName: string,
68
- startMs: number,
69
- outcome: "success" | "error",
70
- ): void {
71
- const durationMs = Math.round(performance.now() - startMs);
72
- const record = {
73
- plugin: PLUGIN_NAME,
74
- pipeline: pipelineName,
75
- durationMs,
76
- outcome,
77
- };
64
+ function emit(hook: string, conversationId: string): void {
65
+ const record = { plugin: PLUGIN_NAME, hook, conversationId };
78
66
  process.stderr.write(`${JSON.stringify(record)}\n`);
79
67
  }
80
68
 
81
69
  /**
82
- * Factory for a pipeline-agnostic observer middleware. The returned function
83
- * carries a `name` so `runPipeline`'s `chain` log field attributes this
84
- * plugin's frame correctly. Error paths rethrow — the plugin is purely
85
- * observational and must never change the turn's outcome.
86
- */
87
- function makeObserver<A, R>(
88
- pipelineName: string,
89
- ): (args: A, next: (args: A) => Promise<R>, _ctx: unknown) => Promise<R> {
90
- const fn = async function echoObserver(
91
- args: A,
92
- next: (args: A) => Promise<R>,
93
- _ctx: unknown,
94
- ): Promise<R> {
95
- const start = performance.now();
96
- let outcome: "success" | "error" = "success";
97
- try {
98
- return await next(args);
99
- } catch (err) {
100
- outcome = "error";
101
- throw err;
102
- } finally {
103
- emit(pipelineName, start, outcome);
104
- }
105
- };
106
- return fn;
107
- }
108
-
109
- /**
110
- * The echo plugin. Declares one middleware per slot in
111
- * `PipelineMiddlewareMap` — all thin observers produced by `makeObserver`.
70
+ * The echo plugin. Declares one observer hook per turn-lifecycle event — each
71
+ * logs and returns `void`, so the threaded context flows through unchanged.
112
72
  *
113
73
  * Manifest:
114
74
  * - Host-compat range lives in `package.json` under
@@ -123,8 +83,20 @@ const echoPlugin: Plugin = {
123
83
  name: PLUGIN_NAME,
124
84
  version: "0.1.0",
125
85
  },
126
- middleware: {
127
- compaction: makeObserver<CompactionArgs, CompactionResult>("compaction"),
86
+ // Hook names are inlined as string literals rather than imported from the
87
+ // `HOOKS` constant: a value import would be a runtime repo-relative import,
88
+ // which breaks the documented standalone-copy install (the copied directory
89
+ // can't resolve `../../../src/...`). Only `import type` survives a copy.
90
+ hooks: {
91
+ "user-prompt-submit": async (ctx: UserPromptSubmitContext) => {
92
+ emit("user-prompt-submit", ctx.conversationId);
93
+ },
94
+ "post-tool-use": async (ctx: PostToolUseContext) => {
95
+ emit("post-tool-use", ctx.conversationId);
96
+ },
97
+ stop: async (ctx: StopContext) => {
98
+ emit("stop", ctx.conversationId);
99
+ },
128
100
  },
129
101
  };
130
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.8.7-dev.202606052118.34cd356",
3
+ "version": "0.8.7-dev.202606052135.3e62c5a",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -122,6 +122,7 @@ function seedActiveSurfaceConversation(
122
122
  surfaceId: string,
123
123
  data: SurfaceData,
124
124
  channelCapabilities?: ChannelCapabilities,
125
+ commandIntent?: { type: string; payload?: string; languageCode?: string },
125
126
  ): void {
126
127
  setConversation(conversationId, {
127
128
  conversationId,
@@ -134,6 +135,7 @@ function seedActiveSurfaceConversation(
134
135
  { surfaceType: SurfaceType; data: SurfaceData }
135
136
  >([[surfaceId, { surfaceType: "dynamic_page", data }]]),
136
137
  channelCapabilities: channelCapabilities ?? undefined,
138
+ commandIntent,
137
139
  } as never);
138
140
  }
139
141
 
@@ -819,7 +821,6 @@ describe("applyRuntimeInjections — injection mode", () => {
819
821
  };
820
822
 
821
823
  const fullOptions = {
822
- channelCommandContext: { type: "start" } as const,
823
824
  unifiedTurnContext:
824
825
  "<turn_context>\ncurrent_time: 2026-03-04 (Tuesday) 12:00:00 +00:00 (UTC)\ninterface: telegram\n</turn_context>",
825
826
  isNonInteractive: true,
@@ -849,6 +850,7 @@ describe("applyRuntimeInjections — injection mode", () => {
849
850
  "sf_1",
850
851
  { html: "<div>test</div>" },
851
852
  channelCapabilities,
853
+ { type: "start" },
852
854
  );
853
855
  });
854
856
  afterEach(() => {