@isomorph.ai/app-sdk 1.25.0 → 1.26.0

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.
@@ -1,4 +1,11 @@
1
+ export interface ComputerUseFile {
2
+ name: string;
3
+ contentType: "application/pdf";
4
+ dataBase64: string;
5
+ }
1
6
  export interface ComputerUseOptions {
7
+ /** App-authorized PDFs, at most five files and 2 MiB total. Never supplied by the model. */
8
+ files?: readonly ComputerUseFile[];
2
9
  /** The job's runId, or `<job name>/<scheduledAt>` for a scheduled job: one task record per job run. */
3
10
  runKey: string;
4
11
  /** The job's progress: called on each new step and at least once a minute, which renews the job's lease. */
@@ -8,6 +8,24 @@ const HEARTBEAT_MS = 60_000;
8
8
  // Checks the API did not answer (a throttle, a 5xx, no connection) before the tool gives up: about a minute.
9
9
  const MAX_MISSED_CHECKS = 12;
10
10
  export function createComputerUseTool(options) {
11
+ const files = options.files?.map(file => ({ ...file }));
12
+ if (files) {
13
+ const names = new Set();
14
+ let total = 0;
15
+ if (files.length > 5)
16
+ throw new Error("Computer use accepts at most five PDFs.");
17
+ for (const file of files) {
18
+ if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,119}\.pdf$/.test(file.name) || names.has(file.name))
19
+ throw new Error("Computer use PDF names must be unique safe basenames.");
20
+ if (file.contentType !== "application/pdf" || typeof file.dataBase64 !== "string" || file.dataBase64.length > Math.ceil(2 * 1024 * 1024 / 3) * 4)
21
+ throw new Error("Computer use needs base64 PDFs, at most 2 MiB total.");
22
+ const bytes = Buffer.from(file.dataBase64, "base64");
23
+ total += bytes.length;
24
+ if (bytes.toString("base64") !== file.dataBase64 || bytes.subarray(0, 5).toString() !== "%PDF-" || total > 2 * 1024 * 1024)
25
+ throw new Error("Computer use needs PDFs, at most 2 MiB total.");
26
+ names.add(file.name);
27
+ }
28
+ }
11
29
  const env = options.env ?? process.env;
12
30
  const base = env.ISOMORPH_COMPUTER_USE_URL?.replace(/\/+$/, '');
13
31
  if (!base)
@@ -26,7 +44,7 @@ export function createComputerUseTool(options) {
26
44
  description: 'Do one task in a web browser, such as filling in and submitting a form on a website. Describe the whole task in plain words, with the website address and any details it needs. Waits until the task ends and returns its status and a summary.',
27
45
  inputSchema: jsonSchema({ type: 'object', properties: { task: { type: 'string', minLength: 1 } }, required: ['task'], additionalProperties: false }),
28
46
  execute: async ({ task }) => {
29
- const started = await call('/tasks', { run_key: options.runKey, task });
47
+ const started = await call('/tasks', { run_key: options.runKey, task, ...(files?.length ? { files } : {}) });
30
48
  if (started.status !== 200)
31
49
  throw refused('/tasks', started.status, started.body);
32
50
  await options.progress(0, 'Computer use task started.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isomorph.ai/app-sdk",
3
- "version": "1.25.0",
3
+ "version": "1.26.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",