@vellumai/assistant 0.12.0-dev.202609121414.3df3699 → 0.12.0-dev.202609122213.71fcf45

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.12.0-dev.202609121414.3df3699",
3
+ "version": "0.12.0-dev.202609122213.71fcf45",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -26,7 +26,7 @@ afterAll(() => {
26
26
  });
27
27
 
28
28
  describe("always-loaded tool count", () => {
29
- test("should be exactly 14 with recall occupying the existing slot", async () => {
29
+ test("should be exactly 19 with recall occupying the existing slot", async () => {
30
30
  await initializeTools();
31
31
  const allDefs = getAllToolDefinitions();
32
32
 
@@ -44,20 +44,24 @@ describe("always-loaded tool count", () => {
44
44
  );
45
45
  const activeNames = activeTools.map((t) => t.name).sort();
46
46
 
47
- // Host tools (host_bash, host_file_*) are excluded when no client is
48
- // connected — without a human in the loop, the guardian auto-approve
49
- // path would allow unchecked host command execution.
50
- //
51
47
  // `watch_retro_report` survives this baseline for the same reason the
52
48
  // ui_* tools do: a watch retrospective runs clientless, so it can only
53
49
  // report through a tool that survives this baseline. The ui_* tools are
54
50
  // here because background UI surfaces persist and return instead of
55
51
  // awaiting action, so they no longer need a connected client.
52
+ // Host tool definitions stay on the wire for background turns: schemas
53
+ // are cache-stable, and the shared execution gate rejects host tools on
54
+ // explicitly non-interactive turns before any proxy dispatch.
56
55
  const expectedNames = [
57
56
  "bash",
58
57
  "file_edit",
59
58
  "file_read",
60
59
  "file_write",
60
+ "host_bash",
61
+ "host_file_edit",
62
+ "host_file_read",
63
+ "host_file_transfer",
64
+ "host_file_write",
61
65
  "recall",
62
66
  "remember",
63
67
  "skill_execute",
@@ -72,6 +76,6 @@ describe("always-loaded tool count", () => {
72
76
 
73
77
  expect(activeNames).toEqual(expectedNames);
74
78
  expect(activeNames.filter((name) => name === "recall")).toHaveLength(1);
75
- expect(activeTools.length).toBe(14);
79
+ expect(activeTools.length).toBe(19);
76
80
  });
77
81
  });
@@ -901,6 +901,32 @@ describe("pairDeliveryWithConversation", () => {
901
901
  // body has to land there for that button to open something that contains
902
902
  // the notification the user tapped.
903
903
 
904
+ test("assistant reply keeps the source conversation without appending its preview", async () => {
905
+ mockExistingConversations["conv-user-chat"] = {
906
+ id: "conv-user-chat",
907
+ source: "user",
908
+ title: "An ordinary chat",
909
+ };
910
+ const signal = makeSignal({
911
+ requiresConversation: undefined,
912
+ sourceContextId: "conv-user-chat",
913
+ sourceEventName: "chat.assistant_reply",
914
+ });
915
+
916
+ const result = await pairDeliveryWithConversation(
917
+ signal,
918
+ "vellum" as NotificationChannel,
919
+ makeCopy({ body: "A short push preview…" }),
920
+ );
921
+
922
+ expect(result.conversationId).toBe("conv-user-chat");
923
+ expect(result.messageId).toBeNull();
924
+ expect(result.createdNewConversation).toBe(false);
925
+ expect(createConversationMock).not.toHaveBeenCalled();
926
+ expect(addMessageMock).not.toHaveBeenCalled();
927
+ expect(messagesInvalidated).toEqual([]);
928
+ });
929
+
904
930
  test("passive vellum signal appends the body to the producing conversation", async () => {
905
931
  mockExistingConversations["conv-producer"] = {
906
932
  id: "conv-producer",
@@ -354,6 +354,57 @@ describe("createToolExecutor isInteractive threading", () => {
354
354
  });
355
355
  });
356
356
 
357
+ describe("createToolExecutor unattended host-tool gate", () => {
358
+ test("rejects a direct host tool in a background turn before dispatch", async () => {
359
+ const { executor, calls } = makeCapturingExecutor();
360
+ const toolFn = makeToolFn(
361
+ executor,
362
+ makeCtx({ currentTurnIsNonInteractive: true, transportInterface: "web" }),
363
+ );
364
+
365
+ const result = await toolFn("host_bash", { command: "pwd" });
366
+
367
+ expect(result).toMatchObject({ isError: true });
368
+ expect(result.content).toContain("requires an interactive user turn");
369
+ expect(calls).toHaveLength(0);
370
+ });
371
+
372
+ test("rejects a skill-dispatched host tool in a background turn before dispatch", async () => {
373
+ const { executor, calls } = makeCapturingExecutor();
374
+ const toolFn = makeToolFn(
375
+ executor,
376
+ makeCtx({ currentTurnIsNonInteractive: true, transportInterface: "web" }),
377
+ );
378
+
379
+ const result = await toolFn("skill_execute", {
380
+ tool: "host_file_read",
381
+ input: { path: "/tmp/a" },
382
+ activity: "testing",
383
+ });
384
+
385
+ expect(result).toMatchObject({ isError: true });
386
+ expect(result.content).toContain("requires an interactive user turn");
387
+ expect(calls).toHaveLength(0);
388
+ });
389
+
390
+ test("dispatches a host tool during an interactive turn", async () => {
391
+ const { executor, calls } = makeCapturingExecutor();
392
+ const toolFn = makeToolFn(
393
+ executor,
394
+ makeCtx({
395
+ currentTurnIsNonInteractive: false,
396
+ transportInterface: "web",
397
+ }),
398
+ );
399
+
400
+ const result = await toolFn("host_bash", { command: "pwd" });
401
+
402
+ expect(result).toMatchObject({ content: "ok", isError: false });
403
+ expect(calls).toHaveLength(1);
404
+ expect(calls[0].name).toBe("host_bash");
405
+ });
406
+ });
407
+
357
408
  describe("createToolExecutor channel-permission coordinate threading", () => {
358
409
  beforeEach(() => {
359
410
  mockBindingExternalChatId = null;
@@ -669,23 +669,31 @@ describe("HostBashProxy", () => {
669
669
  expect(sentMessages).toHaveLength(0);
670
670
  });
671
671
 
672
- test("rejects ambiguously when multiple same-user capable clients are connected and no targetClientId", async () => {
673
- // Regression: previously fell through to untargeted broadcast, fanning
674
- // a single targeted-style request out across every same-user machine.
672
+ test("selects the most recently active same-user client when several are connected", async () => {
675
673
  setup();
676
674
  setupMultipleClients(["client-1", "client-2", "client-3"]);
677
675
 
678
- const result = await proxy.request(
676
+ const resultPromise = proxy.request(
679
677
  { command: "echo hello" },
680
678
  "session-1",
681
679
  undefined,
682
680
  "user-A",
683
681
  );
684
682
 
685
- expect(result.isError).toBe(true);
686
- expect(result.content).toContain("target_client_id");
687
- // No broadcast happened
688
- expect(sentMessages).toHaveLength(0);
683
+ const sent = sentMessages[0] as Record<string, unknown>;
684
+ expect(sent.targetClientId).toBe("client-1");
685
+ const options = sentMessageOptions[0] as
686
+ | Record<string, unknown>
687
+ | undefined;
688
+ expect(options?.targetClientId).toBe("client-1");
689
+
690
+ proxy.resolveResult(sent.requestId as string, {
691
+ stdout: "hello\n",
692
+ stderr: "",
693
+ exitCode: 0,
694
+ timedOut: false,
695
+ });
696
+ expect((await resultPromise).isError).toBe(false);
689
697
  });
690
698
 
691
699
  test("falls through to broadcast when zero capable clients (existing timeout path)", async () => {
@@ -832,30 +840,19 @@ describe("HostBashProxy", () => {
832
840
  expect(sentMessages).toHaveLength(0);
833
841
  });
834
842
 
835
- test("untargeted local flow unchanged when no auto-resolve match", async () => {
843
+ test("rejects when the actor has no capable client", async () => {
836
844
  setup();
837
- // No capable clients connected — untargeted path runs.
838
845
 
839
- const resultPromise = proxy.request(
846
+ const result = await proxy.request(
840
847
  { command: "echo hello" },
841
848
  "session-1",
842
849
  undefined,
843
850
  "user-A",
844
851
  );
845
852
 
846
- expect(sentMessages).toHaveLength(1);
847
- const sent = sentMessages[0] as Record<string, unknown>;
848
- expect(sent.type).toBe("host_bash_request");
849
- expect(sent.targetClientId).toBeUndefined();
850
-
851
- const requestId = sent.requestId as string;
852
- proxy.resolveResult(requestId, {
853
- stdout: "hello\n",
854
- stderr: "",
855
- exitCode: 0,
856
- timedOut: false,
857
- });
858
- await resultPromise;
853
+ expect(result).toMatchObject({ isError: true });
854
+ expect(result.content).toContain("belongs to this user");
855
+ expect(sentMessages).toHaveLength(0);
859
856
  });
860
857
 
861
858
  test("auto-resolve to same-user client succeeds", async () => {
@@ -883,36 +880,20 @@ describe("HostBashProxy", () => {
883
880
  await resultPromise;
884
881
  });
885
882
 
886
- test("auto-resolve to different-user client falls through to untargeted", async () => {
883
+ test("rejects when only a different user has a capable client", async () => {
887
884
  setup();
888
- // Single capable client owned by user-B; caller is user-A.
889
885
  setupSingleClient("client-abc", "user-B");
890
886
 
891
- const resultPromise = proxy.request(
887
+ const result = await proxy.request(
892
888
  { command: "echo hello" },
893
889
  "session-1",
894
890
  undefined,
895
891
  "user-A",
896
892
  );
897
893
 
898
- // Auto-resolve must NOT pick the cross-user client; the untargeted
899
- // broadcast path runs instead.
900
- expect(sentMessages).toHaveLength(1);
901
- const sent = sentMessages[0] as Record<string, unknown>;
902
- expect(sent.type).toBe("host_bash_request");
903
- expect(sent.targetClientId).toBeUndefined();
904
-
905
- const opts = sentMessageOptions[0] as Record<string, unknown> | undefined;
906
- expect(opts?.targetClientId).toBeUndefined();
907
-
908
- const requestId = sent.requestId as string;
909
- proxy.resolveResult(requestId, {
910
- stdout: "hello\n",
911
- stderr: "",
912
- exitCode: 0,
913
- timedOut: false,
914
- });
915
- await resultPromise;
894
+ expect(result).toMatchObject({ isError: true });
895
+ expect(result.content).toContain("belongs to this user");
896
+ expect(sentMessages).toHaveLength(0);
916
897
  });
917
898
  });
918
899
  });
@@ -608,22 +608,17 @@ describe("HostBrowserProxy", () => {
608
608
  },
609
609
  ];
610
610
 
611
- const resultPromise = proxy.request(
611
+ const result = await proxy.request(
612
612
  { cdpMethod: "Page.navigate", cdpParams: { url: "https://a.test" } },
613
613
  "session-1",
614
614
  undefined,
615
615
  "user-1",
616
616
  );
617
617
 
618
- // Auto-resolution filters out the cross-user candidate, so the
619
- // proxy falls into the existing "no active extension connection"
620
- // rejection — we never broadcast to a different actor's client.
621
- await expect(resultPromise).rejects.toThrow(
622
- "no active extension connection",
623
- );
618
+ expect(result).toMatchObject({ isError: true });
619
+ expect(result.content).toContain("belongs to this user");
624
620
  expect(getPublishedMessages()).toHaveLength(0);
625
621
  });
626
-
627
622
  test("prefers the chrome-extension client over a more-recently-active macOS bridge", async () => {
628
623
  // Mock `listClientsByCapability` returns mockClients in array
629
624
  // order, which mirrors production's `lastActiveAt`-desc ordering.
@@ -720,11 +715,6 @@ describe("HostBrowserProxy", () => {
720
715
  });
721
716
 
722
717
  test("rejects when caller has actor but no host_browser-capable client is connected for that actor", async () => {
723
- // Same-user filter returns empty even though listClientsByCapability
724
- // would return a non-empty list (because that list is for a
725
- // different actor). The unfiltered fallback path runs only when
726
- // the caller has no actor — we don't silently broadcast to anyone
727
- // when the caller IS authenticated to a specific actor.
728
718
  mockClients = [
729
719
  {
730
720
  clientId: "other-user-ext",
@@ -734,16 +724,15 @@ describe("HostBrowserProxy", () => {
734
724
  },
735
725
  ];
736
726
 
737
- const resultPromise = proxy.request(
727
+ const result = await proxy.request(
738
728
  { cdpMethod: "Page.navigate", cdpParams: { url: "https://a.test" } },
739
729
  "session-1",
740
730
  undefined,
741
731
  "user-1",
742
732
  );
743
733
 
744
- await expect(resultPromise).rejects.toThrow(
745
- "no active extension connection",
746
- );
734
+ expect(result).toMatchObject({ isError: true });
735
+ expect(result.content).toContain("belongs to this user");
747
736
  expect(getPublishedMessages()).toHaveLength(0);
748
737
  });
749
738
  });
@@ -274,6 +274,29 @@ describe("HostFileProxy — targetClientId (Phase 2)", () => {
274
274
  });
275
275
  });
276
276
 
277
+ test("selects the most recently active same-user client when several are connected", async () => {
278
+ setup();
279
+ setupMultipleClients(["client-1", "client-2"]);
280
+
281
+ const resultPromise = proxy.request(
282
+ { operation: "read", path: "/tmp/file.txt" },
283
+ "session-1",
284
+ undefined,
285
+ undefined,
286
+ TEST_PRINCIPAL,
287
+ );
288
+
289
+ const sent = sentMessages[0] as Record<string, unknown>;
290
+ expect(sent.targetClientId).toBe("client-1");
291
+ const options = sentMessageOptions[0] as
292
+ | Record<string, unknown>
293
+ | undefined;
294
+ expect(options?.targetClientId).toBe("client-1");
295
+
296
+ proxy.resolve(sent.requestId as string, { content: "ok", isError: false });
297
+ expect((await resultPromise).isError).toBe(false);
298
+ });
299
+
277
300
  // ── targetClientId in cancel (abort signal) ──────────────────────────
278
301
 
279
302
  describe("targetClientId in cancel — abort signal", () => {
@@ -746,9 +746,8 @@ describe("HostFileProxy", () => {
746
746
  expect(sentMessages).toHaveLength(0);
747
747
  });
748
748
 
749
- test("untargeted request with no auto-resolve match still broadcasts (legacy path unchanged)", async () => {
749
+ test("rejects when the actor has no capable client", async () => {
750
750
  setup();
751
- // No matching same-user clients available.
752
751
  mockClients = [
753
752
  {
754
753
  clientId: "client-A",
@@ -757,23 +756,18 @@ describe("HostFileProxy", () => {
757
756
  },
758
757
  ];
759
758
 
760
- const resultPromise = proxy.request(
759
+ const result = await proxy.request(
761
760
  { operation: "read", path: "/tmp/test.txt" },
762
761
  "session-1",
763
762
  undefined,
764
763
  undefined,
765
- "user-B", // No same-user match → no auto-resolve, broadcast untargeted.
764
+ "user-B",
766
765
  );
767
766
 
768
- expect(sentMessages).toHaveLength(1);
769
- const sent = sentMessages[0] as Record<string, unknown>;
770
- expect(sent.targetClientId).toBeUndefined();
771
- const requestId = sent.requestId as string;
772
-
773
- proxy.resolve(requestId, { content: "ok", isError: false });
774
- await resultPromise;
767
+ expect(result).toMatchObject({ isError: true });
768
+ expect(result.content).toContain("belongs to this user");
769
+ expect(sentMessages).toHaveLength(0);
775
770
  });
776
-
777
771
  test("auto-resolve picks the same-user client when there's exactly one", async () => {
778
772
  setup();
779
773
  mockClients = [
@@ -807,7 +801,7 @@ describe("HostFileProxy", () => {
807
801
  await resultPromise;
808
802
  });
809
803
 
810
- test("auto-resolve falls through when no client matches the source user", async () => {
804
+ test("rejects when only a different user has a capable client", async () => {
811
805
  setup();
812
806
  mockClients = [
813
807
  {
@@ -817,7 +811,7 @@ describe("HostFileProxy", () => {
817
811
  },
818
812
  ];
819
813
 
820
- const resultPromise = proxy.request(
814
+ const result = await proxy.request(
821
815
  { operation: "read", path: "/tmp/test.txt" },
822
816
  "session-1",
823
817
  undefined,
@@ -825,16 +819,10 @@ describe("HostFileProxy", () => {
825
819
  "user-C",
826
820
  );
827
821
 
828
- // No same-user client → no auto-resolve, broadcast untargeted.
829
- expect(sentMessages).toHaveLength(1);
830
- const sent = sentMessages[0] as Record<string, unknown>;
831
- expect(sent.targetClientId).toBeUndefined();
832
- const requestId = sent.requestId as string;
833
-
834
- proxy.resolve(requestId, { content: "ok", isError: false });
835
- await resultPromise;
822
+ expect(result).toMatchObject({ isError: true });
823
+ expect(result.content).toContain("belongs to this user");
824
+ expect(sentMessages).toHaveLength(0);
836
825
  });
837
-
838
826
  test("legacy embedded targetClientId in input still goes through the same-user gate", async () => {
839
827
  setup();
840
828
  mockClients = [
@@ -812,7 +812,7 @@ describe("HostTransferProxy — targetClientId", () => {
812
812
  await resultPromise;
813
813
  });
814
814
 
815
- test("requestToHost: auto-resolve falls through when no client matches the source user", async () => {
815
+ test("requestToHost: rejects when no client matches the source user", async () => {
816
816
  setup();
817
817
  mockClientRegistry.set("client-A", {
818
818
  clientId: "client-A",
@@ -824,7 +824,7 @@ describe("HostTransferProxy — targetClientId", () => {
824
824
  const srcPath = `/tmp/htp-auto-no-match-${Date.now()}.txt`;
825
825
  await globalThis.Bun.write(srcPath, "data");
826
826
 
827
- const resultPromise = proxy.requestToHost(
827
+ const result = await proxy.requestToHost(
828
828
  {
829
829
  sourcePath: srcPath,
830
830
  destPath: "/host/dest.txt",
@@ -835,13 +835,9 @@ describe("HostTransferProxy — targetClientId", () => {
835
835
  "user-C",
836
836
  );
837
837
 
838
- await waitForMessages(sentMessages, 1);
839
- const sent = sentMessages[0] as Record<string, unknown>;
840
- expect(sent.targetClientId).toBeUndefined();
841
-
842
- const requestId = sent.requestId as string;
843
- proxy.resolveTransferResult(requestId, { isError: false });
844
- await resultPromise;
838
+ expect(result).toMatchObject({ isError: true });
839
+ expect(result.content).toContain("belongs to this user");
840
+ expect(sentMessages).toHaveLength(0);
845
841
  });
846
842
 
847
843
  test("requestToSandbox: targeted request from a different user is rejected", async () => {
@@ -897,6 +893,31 @@ describe("HostTransferProxy — targetClientId", () => {
897
893
  await resultPromise;
898
894
  });
899
895
 
896
+ test("requestToSandbox: rejects when no client matches the source user", async () => {
897
+ setup();
898
+ const a: MockClient = {
899
+ clientId: "client-A",
900
+ capabilities: ["host_file"],
901
+ actorPrincipalId: "user-A",
902
+ };
903
+ mockCapableClients = [a];
904
+ mockClientRegistry.set("client-A", a);
905
+
906
+ const result = await proxy.requestToSandbox(
907
+ {
908
+ sourcePath: "/host/source.txt",
909
+ destPath: "/sandbox/dest.txt",
910
+ conversationId: "conv-same-9-no-match",
911
+ },
912
+ undefined,
913
+ "user-C",
914
+ );
915
+
916
+ expect(result).toMatchObject({ isError: true });
917
+ expect(result.content).toContain("belongs to this user");
918
+ expect(sentMessages).toHaveLength(0);
919
+ });
920
+
900
921
  test("requestToSandbox: auto-resolve picks the same-user client when there's exactly one", async () => {
901
922
  setup();
902
923
  const a: MockClient = {
@@ -249,17 +249,21 @@ describe("createResolveToolsCallback — toolContextPin", () => {
249
249
  });
250
250
  }
251
251
 
252
- test("control: without a pin, a clientless fork drops every client-gated tool but ui_show", () => {
252
+ test("control: without a pin, a clientless fork drops client-gated tools but keeps host and UI tools", () => {
253
253
  projectedSkillToolNames = [];
254
254
  const resolve = createResolveToolsCallback(
255
255
  CLIENT_GATED_DEFS,
256
256
  clientlessExecutionCtx(),
257
257
  )!;
258
258
 
259
- // ui_show stays on the wire: background UI surfaces persist and return
260
- // instead of awaiting action, so they no longer need a connected client.
259
+ // Host tool definitions stay on the wire for background turns, and
260
+ // ui_show stays because background UI surfaces persist and return. The
261
+ // executor rejects host tools on explicitly non-interactive turns before
262
+ // dispatch; ask_question and request_system_permission remain
263
+ // client-gated at resolution.
261
264
  expect(resolve(EMPTY_HISTORY).map((t) => t.name)).toEqual([
262
265
  "remember",
266
+ "host_bash",
263
267
  "ui_show",
264
268
  ]);
265
269
  });
@@ -296,9 +300,12 @@ describe("createResolveToolsCallback — toolContextPin", () => {
296
300
  }),
297
301
  )!;
298
302
 
299
- // ui_show survives the clientless pin: it persists and returns.
303
+ // Host tool definitions stay on the wire for background turns, and
304
+ // ui_show survives the clientless pin: it persists and returns. The
305
+ // executor rejects host tools on explicitly non-interactive turns.
300
306
  expect(resolve(EMPTY_HISTORY).map((t) => t.name)).toEqual([
301
307
  "remember",
308
+ "host_bash",
302
309
  "ui_show",
303
310
  ]);
304
311
  });