@vellumai/assistant 0.10.0-dev.202606230530.bc0f32e → 0.10.0-dev.202606230919.3d7d154

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.0-dev.202606230530.bc0f32e",
3
+ "version": "0.10.0-dev.202606230919.3d7d154",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -2327,6 +2327,7 @@ describe("AgentLoop", () => {
2327
2327
  messages: [userMessage],
2328
2328
  onEvent: collectEvents(events),
2329
2329
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
2330
+ callSite: "mainAgent",
2330
2331
  });
2331
2332
 
2332
2333
  // Provider should be called 3 times: initial, empty response, retry
@@ -2410,6 +2411,7 @@ describe("AgentLoop", () => {
2410
2411
  messages: [userMessage],
2411
2412
  onEvent: collectEvents(events),
2412
2413
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
2414
+ callSite: "mainAgent",
2413
2415
  });
2414
2416
 
2415
2417
  // Provider called exactly 2 times: initial [text+tool_use], then empty.
@@ -2477,6 +2479,7 @@ describe("AgentLoop", () => {
2477
2479
  messages: [userMessage],
2478
2480
  onEvent: collectEvents(events),
2479
2481
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
2482
+ callSite: "mainAgent",
2480
2483
  });
2481
2484
 
2482
2485
  // Provider called 3 times: initial, empty, retry (also empty)
@@ -222,7 +222,6 @@ describe("Invariant 2: no generic plaintext secret read API", () => {
222
222
  "runtime/routes/platform-routes.ts", // CLI platform connect/disconnect/status routes (CLI-migrated to IPC)
223
223
  "ipc/skill-routes/providers.ts", // host.providers.secureKeys.getProviderKey IPC route (out-of-process SkillHost companion)
224
224
  "daemon/external-plugins-bootstrap.ts", // reads credentials at plugin init (manifest.requiresCredential) via the CES-mediated getSecureKeyAsync path
225
- "plugin-api/index.ts", // public @vellumai/plugin-api surface re-exports getSecureKeyAsync to dynamically-imported workspace plugins via the boot-time shim (compiled-binary plugin loading)
226
225
  "inbound/platform-callback-registration.ts", // managed credential lookup for platform base URL, assistant ID, and API key
227
226
  "tts/providers/elevenlabs-provider.ts", // ElevenLabs TTS API key lookup
228
227
  "tts/providers/deepgram-provider.ts", // Deepgram TTS API key lookup
@@ -326,6 +326,48 @@ describe("empty-response post-model-call hook — default decisions", () => {
326
326
  expect(ctx.decision).toBe("stop");
327
327
  expect(ctx.messages).toEqual([priorToolUseTurn]);
328
328
  });
329
+
330
+ // ─── Call-site gating ──────────────────────────────────────────────────────
331
+
332
+ test("empty turn after tools on a non-mainAgent call site → stop, no nudge", async () => {
333
+ // GIVEN an empty-after-tools turn that would nudge on the user-facing reply,
334
+ // but the call site is a background one (a memory retrospective). There is
335
+ // no user awaiting a summary, so the re-query nudge must not fire.
336
+ const ctx = makeCtx({
337
+ callSite: "memoryRetrospective",
338
+ messages: [priorToolUseTurn],
339
+ content: [],
340
+ });
341
+
342
+ // WHEN the hook runs.
343
+ await postModelCall(ctx);
344
+
345
+ // THEN the turn ends silently — no nudge appended, no re-query.
346
+ expect(ctx.decision).toBe("stop");
347
+ expect(ctx.messages).toEqual([priorToolUseTurn]);
348
+ });
349
+
350
+ test("refusal on a non-mainAgent call site is still rewritten to the fallback", async () => {
351
+ // GIVEN a refusal with no visible text on a background call site. The
352
+ // call-site gate scopes only the re-query nudge; the refusal-rewrite is a
353
+ // user-facing terminal fallback for any consumer that reads the final text,
354
+ // so it stays ungated.
355
+ const ctx = makeCtx({
356
+ callSite: "memoryRetrospective",
357
+ messages: [],
358
+ content: [],
359
+ stopReason: "refusal",
360
+ });
361
+
362
+ // WHEN the hook runs.
363
+ await postModelCall(ctx);
364
+
365
+ // THEN the empty refusal is still rewritten to the user-facing fallback.
366
+ expect(ctx.decision).toBe("stop");
367
+ expect(ctx.content).toEqual([
368
+ { type: "text", text: REFUSAL_FALLBACK_TEXT },
369
+ ]);
370
+ });
329
371
  });
330
372
 
331
373
  // ─── One-shot retry bound ────────────────────────────────────────────────────
@@ -20,8 +20,8 @@
20
20
  * the host hands to plugin hooks, and the logger shape they include.
21
21
  *
22
22
  * Alongside those types, the module exposes a small set of **runtime
23
- * handles** for plugins that need to reach the assistant's live singletons
24
- * (subscribe to runtime events, read secrets). These resolve to the
23
+ * handles for plugins that need to reach the assistant's live singletons
24
+ * (subscribe to runtime events, inspect inference profiles). These resolve to the
25
25
  * assistant's own instances: the host parks the loaded plugin-api namespace
26
26
  * on `globalThis` at boot, and the workspace-level shim re-binds each
27
27
  * runtime export from there — so a plugin's
@@ -31,7 +31,6 @@
31
31
  * disjoint module copy.
32
32
  *
33
33
  * - {@link assistantEventHub} — the assistant's pub/sub hub for runtime events
34
- * - {@link getSecureKeyAsync} — read a secret from secure storage
35
34
  * - {@link getModelProfiles} — list the workspace inference profiles a plugin
36
35
  * can route to (e.g. a model router building its category → profile map)
37
36
  * - {@link getConfiguredProvider} — resolve a {@link Provider} for a call site
@@ -130,7 +129,6 @@ export type {
130
129
  AssistantEventSubscription,
131
130
  } from "../runtime/assistant-event-hub.js";
132
131
  export { assistantEventHub } from "../runtime/assistant-event-hub.js";
133
- export { getSecureKeyAsync } from "../security/secure-keys.js";
134
132
  export { getModelProfiles } from "./model-profiles.js";
135
133
  // Check whether a profile's resolved model can process image input. Resolves
136
134
  // the effective (provider, model) by merging over the workspace default and
@@ -16,10 +16,12 @@
16
16
  * at least one prior assistant turn this run, and no earlier turn this run
17
17
  * already delivered visible text. The hook re-queries the model with
18
18
  * `NUDGE_TEXT` (a tool trail exists to summarize, so a retry can recover a
19
- * real answer). The retry is bounded to one pass per run by a one-shot
20
- * per-conversation mark this hook sets; the sibling `stop` hook (see
21
- * `./stop.ts`) clears it when the turn terminates, so the next run nudges
22
- * afresh.
19
+ * real answer). Main-agent turns only: background, subagent, and compaction
20
+ * calls have no user awaiting a summary, so per the post-model-call contract
21
+ * the nudge self-gates on {@link PostModelCallContext.callSite}. The retry is
22
+ * bounded to one pass per run by a one-shot per-conversation mark this hook
23
+ * sets; the sibling `stop` hook (see `./stop.ts`) clears it when the turn
24
+ * terminates, so the next run nudges afresh.
23
25
  *
24
26
  * Every other case leaves the decision at `"stop"` (the model said its piece,
25
27
  * or there is nothing to act on).
@@ -146,6 +148,13 @@ const postModelCall: PluginHookFn<PostModelCallContext> = async (ctx) => {
146
148
  !priorAssistantHadVisibleText;
147
149
 
148
150
  if (isEmptyTurnAfterTools) {
151
+ // Only the user-facing reply gets the re-query nudge. Background, subagent,
152
+ // and compaction calls have no user awaiting a summary, and the
153
+ // post-model-call contract requires self-gating on call site to avoid
154
+ // re-querying them. The refusal-rewrite above is a user-facing terminal
155
+ // fallback, not a re-query, so it stays ungated.
156
+ if (ctx.callSite !== "mainAgent") return;
157
+
149
158
  // Re-query once to recover a real answer. The one-shot per-conversation
150
159
  // mark makes the hook self-limiting: a second empty turn this run finds the
151
160
  // mark already set and lets the turn end rather than nudging again.