@vellumai/assistant 0.12.1-dev.202609151617.4f8b2b2 → 0.12.1-dev.202609151714.4f7c874

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.1-dev.202609151617.4f8b2b2",
3
+ "version": "0.12.1-dev.202609151714.4f7c874",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1900,7 +1900,7 @@ describe("HostCuProxy", () => {
1900
1900
  });
1901
1901
  });
1902
1902
 
1903
- describe("screenshot on request", () => {
1903
+ describe("screenshot policy", () => {
1904
1904
  const TREE = 'Window: "Inbox" (Mail)\n [1] button "Reply" at (10, 10)';
1905
1905
  const OMITTED = "Screenshot omitted";
1906
1906
 
@@ -1913,15 +1913,20 @@ describe("HostCuProxy", () => {
1913
1913
  "host_cu",
1914
1914
  "host_cu_window_capture",
1915
1915
  "host_cu_annotate",
1916
+ "host_cu_sequence",
1916
1917
  ],
1917
1918
  },
1918
1919
  ];
1919
1920
  }
1920
1921
 
1921
- /** Dispatch one request and return what was sent, without answering it. */
1922
+ /**
1923
+ * Dispatch one request and return what was sent, without answering it. A
1924
+ * plain observation is the only step whose pixels depend on policy, so it
1925
+ * is the default.
1926
+ */
1922
1927
  function dispatch(
1923
- input: Record<string, unknown> = { element_id: 1 },
1924
- toolName = "computer_use_click",
1928
+ input: Record<string, unknown> = {},
1929
+ toolName = "computer_use_observe",
1925
1930
  ) {
1926
1931
  const pending = proxy.request(
1927
1932
  toolName,
@@ -1955,22 +1960,42 @@ describe("HostCuProxy", () => {
1955
1960
  return !Object.hasOwn(sent.input, "includeScreenshot");
1956
1961
  }
1957
1962
 
1958
- test("the first observed step attaches and the next unscoped step does not", async () => {
1963
+ test("the first observation attaches and the next plain one does not", async () => {
1959
1964
  setup();
1960
1965
  connect();
1961
1966
  const first = await step({ axTree: TREE, screenshot: "img" });
1962
- expect(first.sent.input).toEqual({ element_id: 1 });
1967
+ expect(first.sent.input).toEqual({});
1963
1968
  expect(first.result.content).not.toContain(OMITTED);
1964
1969
 
1965
1970
  const second = await step({ axTree: TREE });
1966
- expect(second.sent.input).toEqual({
1967
- element_id: 1,
1968
- includeScreenshot: false,
1969
- });
1971
+ expect(second.sent.input).toEqual({ includeScreenshot: false });
1970
1972
  expect(second.result.content).toContain(OMITTED);
1971
1973
  expect(second.result.isError).toBe(false);
1972
1974
  });
1973
1975
 
1976
+ test("every action attaches after the first look", async () => {
1977
+ setup();
1978
+ connect();
1979
+ await step({ axTree: TREE, screenshot: "img" });
1980
+ for (const [toolName, input] of [
1981
+ ["computer_use_click", { element_id: 1 }],
1982
+ ["computer_use_type_text", { text: "hi" }],
1983
+ ["computer_use_key", { key: "enter" }],
1984
+ ["computer_use_scroll", { direction: "down" }],
1985
+ ["computer_use_wait", { duration: 1 }],
1986
+ ["computer_use_sequence", { actions: [] }],
1987
+ ] as const) {
1988
+ const action = await step(
1989
+ { axTree: TREE, screenshot: "img" },
1990
+ { ...input, include_screenshot: false },
1991
+ toolName,
1992
+ );
1993
+ expect(action.sent.input).toEqual(input);
1994
+ expect(action.result.content).not.toContain(OMITTED);
1995
+ expect(action.result.contentBlocks).toHaveLength(1);
1996
+ }
1997
+ });
1998
+
1974
1999
  test("the first look is per desktop, so a newly targeted one attaches", async () => {
1975
2000
  setup();
1976
2001
  mockClients = [
@@ -1987,8 +2012,8 @@ describe("HostCuProxy", () => {
1987
2012
  ];
1988
2013
  const on = (clientId: string) => {
1989
2014
  const pending = proxy.request(
1990
- "computer_use_click",
1991
- { element_id: 1 },
2015
+ "computer_use_observe",
2016
+ {},
1992
2017
  "session-1",
1993
2018
  1,
1994
2019
  undefined,
@@ -25,10 +25,12 @@ desktop client and is never handled locally by the assistant.
25
25
 
26
26
  ## Observations
27
27
 
28
- Every computer-use step returns the accessibility tree. A screenshot comes with
29
- a desktop's first look, with window-scoped observations, or when you call
30
- `computer_use_observe` with `include_screenshot: true`. Ask for one whenever the
31
- tree is not enough to act on: a canvas, a game, a custom-drawn view, few or
28
+ Every computer-use step returns the accessibility tree. Every action also
29
+ returns a screenshot taken after it ran (one at the end of a
30
+ `computer_use_sequence`), so check it to see what your action did. An
31
+ observation comes with a screenshot on a desktop's first look, when it is
32
+ window-scoped, or when you pass `include_screenshot: true`. Ask for one whenever
33
+ the tree is not enough to act on: a canvas, a game, a custom-drawn view, few or
32
34
  unlabeled controls, or a layout question.
33
35
 
34
36
  The tree is walked to a limited depth to keep steps fast, and says when it was
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "include_screenshot": {
19
19
  "type": "boolean",
20
- "description": "Force a screenshot with this observation. The accessibility tree is returned every step; ask for pixels whenever the tree is not enough to act on, such as a canvas, a game, a custom-drawn view, a window with few or unlabeled controls, or a question about layout."
20
+ "description": "Force a screenshot with this observation. The accessibility tree is returned every step and actions always return a screenshot of their result; ask for pixels on an observation whenever the tree is not enough to act on, such as a canvas, a game, a custom-drawn view, a window with few or unlabeled controls, or a question about layout."
21
21
  },
22
22
  "full_tree": {
23
23
  "type": "boolean",
@@ -638,20 +638,24 @@ export class HostCuProxy {
638
638
 
639
639
  /**
640
640
  * Whether the request about to be dispatched should carry a screenshot. The
641
- * accessibility tree comes back every step. Pixels come back on the first
642
- * look since the last reset, for a window- or display-scoped capture, and
643
- * when the model asks for them. Otherwise whether the tree is enough is the
644
- * model's call.
641
+ * accessibility tree comes back every step. Pixels come back after every
642
+ * action, so the model sees what its action did, on the first look since
643
+ * the last reset, for a window- or display-scoped capture, and when the
644
+ * model asks for them. Only a plain observation leaves whether the tree is
645
+ * enough to the model.
645
646
  */
646
647
  private shouldAttachScreenshot(
647
648
  toolName: string,
648
649
  input: Record<string, unknown>,
649
650
  targetKey: string,
650
651
  ): boolean {
652
+ if (toolName !== "computer_use_observe") {
653
+ return true;
654
+ }
651
655
  return (
652
656
  !this._observedTargets.has(targetKey) ||
653
657
  hasCaptureTarget(input) ||
654
- (toolName === "computer_use_observe" && input.include_screenshot === true)
658
+ input.include_screenshot === true
655
659
  );
656
660
  }
657
661
 
@@ -5,7 +5,7 @@
5
5
  * implementations unless this file's tests are running.
6
6
  */
7
7
 
8
- import { mkdirSync, rmSync, writeFileSync } from "node:fs";
8
+ import { mkdirSync, rmSync, utimesSync, writeFileSync } from "node:fs";
9
9
  import { tmpdir } from "node:os";
10
10
  import { join } from "node:path";
11
11
  import {
@@ -33,6 +33,9 @@ const realCompiler = { ...(await import("../../../bundler/app-compiler.js")) };
33
33
  const realNotify = {
34
34
  ...(await import("../../../daemon/app-change-notify.js")),
35
35
  };
36
+ const realPinStore = {
37
+ ...(await import("../../../apps/app-pin-store.js")),
38
+ };
36
39
 
37
40
  const compileApp = mock(
38
41
  async (
@@ -70,6 +73,16 @@ mock.module("../../../daemon/app-change-notify.js", () => ({
70
73
  },
71
74
  }));
72
75
 
76
+ mock.module("../../../apps/app-pin-store.js", () => ({
77
+ ...realPinStore,
78
+ listAppPins: () => {
79
+ if (!mockActive) {
80
+ return realPinStore.listAppPins();
81
+ }
82
+ return [];
83
+ },
84
+ }));
85
+
73
86
  const { createApp } = await import("../../../apps/app-store.js");
74
87
  const { getWorkspacePluginsDir } = await import("../../../util/platform.js");
75
88
  const { ROUTES } = await import("../app-management-routes.js");
@@ -83,6 +96,7 @@ function findHandler(operationId: string) {
83
96
  }
84
97
 
85
98
  const handleRefreshApp = findHandler("apps_refresh");
99
+ const handleListApps = findHandler("apps_list");
86
100
 
87
101
  let workspaceDir: string;
88
102
  let previousWorkspaceDir: string | undefined;
@@ -142,6 +156,30 @@ describe("apps_refresh route", () => {
142
156
  });
143
157
  });
144
158
 
159
+ test("advances the workspace app list revision when compiled output changes", async () => {
160
+ const created = createApp({
161
+ name: "Budget",
162
+ schemaJson: "{}",
163
+ htmlDefinition: "<h1>Budget</h1>",
164
+ });
165
+ const builtAt = Math.ceil(created.updatedAt) + 1_000;
166
+ compileApp.mockImplementationOnce(async (appDir) => {
167
+ const distDir = join(appDir, "dist");
168
+ mkdirSync(distDir, { recursive: true });
169
+ utimesSync(distDir, new Date(builtAt), new Date(builtAt));
170
+ return { ok: true, errors: [], warnings: [], durationMs: 11 };
171
+ });
172
+
173
+ await handleRefreshApp({ pathParams: { id: created.id } });
174
+ const listed = (await handleListApps({})) as {
175
+ apps: Array<{ id: string; updatedAt: number }>;
176
+ };
177
+
178
+ expect(listed.apps.find((app) => app.id === created.id)?.updatedAt).toBe(
179
+ builtAt,
180
+ );
181
+ });
182
+
145
183
  test("compiles a plugin app in place", async () => {
146
184
  const pluginName = `charts-${Math.random().toString(36).slice(2, 8)}`;
147
185
  const pluginDir = join(getWorkspacePluginsDir(), pluginName);
@@ -157,9 +195,7 @@ describe("apps_refresh route", () => {
157
195
  pathParams: { id: pluginAppId },
158
196
  });
159
197
 
160
- expect(compileApp).toHaveBeenCalledWith(
161
- join(pluginDir, "apps", "viewer"),
162
- );
198
+ expect(compileApp).toHaveBeenCalledWith(join(pluginDir, "apps", "viewer"));
163
199
  expect(notifyAppSurfacesChanged).toHaveBeenCalledWith(pluginAppId, {
164
200
  fileChange: true,
165
201
  });
@@ -171,6 +207,40 @@ describe("apps_refresh route", () => {
171
207
  });
172
208
  });
173
209
 
210
+ test("advances the plugin app list revision when compiled output changes", async () => {
211
+ const pluginName = `charts-${Math.random().toString(36).slice(2, 8)}`;
212
+ const appDir = join(getWorkspacePluginsDir(), pluginName, "apps", "viewer");
213
+ mkdirSync(appDir, { recursive: true });
214
+ writeFileSync(
215
+ join(getWorkspacePluginsDir(), pluginName, "package.json"),
216
+ JSON.stringify({ name: pluginName, version: "1.0.0" }),
217
+ );
218
+ const pluginAppId = `plugins~${pluginName}~viewer`;
219
+ const before = (await handleListApps({})) as {
220
+ apps: Array<{ id: string; updatedAt: number }>;
221
+ };
222
+ const previousRevision = before.apps.find(
223
+ (app) => app.id === pluginAppId,
224
+ )?.updatedAt;
225
+ expect(previousRevision).toBeDefined();
226
+ const builtAt = Math.ceil(previousRevision!) + 1_000;
227
+ compileApp.mockImplementationOnce(async (sourceDir) => {
228
+ const distDir = join(sourceDir, "dist");
229
+ mkdirSync(distDir, { recursive: true });
230
+ utimesSync(distDir, new Date(builtAt), new Date(builtAt));
231
+ return { ok: true, errors: [], warnings: [], durationMs: 11 };
232
+ });
233
+
234
+ await handleRefreshApp({ pathParams: { id: pluginAppId } });
235
+ const after = (await handleListApps({})) as {
236
+ apps: Array<{ id: string; updatedAt: number }>;
237
+ };
238
+
239
+ expect(after.apps.find((app) => app.id === pluginAppId)?.updatedAt).toBe(
240
+ builtAt,
241
+ );
242
+ });
243
+
174
244
  test("returns compile errors without throwing", async () => {
175
245
  const created = createApp({
176
246
  name: "Budget",
@@ -181,7 +181,7 @@ function workspaceAppItem(a: AppDefinition): AppListItem {
181
181
  description: a.description,
182
182
  icon: a.icon,
183
183
  createdAt: a.createdAt,
184
- updatedAt: a.updatedAt,
184
+ updatedAt: appContentUpdatedAt(getAppDirPath(a.id), a.updatedAt),
185
185
  version: a.version ?? "1.0.0",
186
186
  contentId: computeContentId(a.name),
187
187
  origin: "workspace",
@@ -203,13 +203,28 @@ function pluginAppItem(app: EnumeratedApp): AppListItem {
203
203
  id: app.id,
204
204
  name: app.name,
205
205
  createdAt: mtime,
206
- updatedAt: mtime,
206
+ updatedAt: appContentUpdatedAt(app.sourcePath, mtime),
207
207
  version: "1.0.0",
208
208
  contentId: computeContentId(app.name),
209
209
  origin: `plugin:${pluginName}`,
210
210
  };
211
211
  }
212
212
 
213
+ /** The newest persisted metadata or compiled-output revision for an app. */
214
+ function appContentUpdatedAt(
215
+ sourcePath: string,
216
+ metadataUpdatedAt: number,
217
+ ): number {
218
+ try {
219
+ return Math.max(
220
+ metadataUpdatedAt,
221
+ statSync(join(sourcePath, "dist")).mtimeMs,
222
+ );
223
+ } catch {
224
+ return metadataUpdatedAt;
225
+ }
226
+ }
227
+
213
228
  function getAppDataResult(
214
229
  method: string,
215
230
  appId: string,
@@ -569,7 +569,7 @@ export const computerUseObserveTool = {
569
569
  include_screenshot: {
570
570
  type: "boolean",
571
571
  description:
572
- "Force a screenshot with this observation. The accessibility tree is returned every step; ask for pixels whenever the tree is not enough to act on, such as a canvas, a game, a custom-drawn view, a window with few or unlabeled controls, or a question about layout.",
572
+ "Force a screenshot with this observation. The accessibility tree is returned every step and actions always return a screenshot of their result; ask for pixels on an observation whenever the tree is not enough to act on, such as a canvas, a game, a custom-drawn view, a window with few or unlabeled controls, or a question about layout.",
573
573
  },
574
574
  full_tree: {
575
575
  type: "boolean",