@mantyx/sdk 0.16.0 → 0.18.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.
package/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  AgentSession: () => AgentSession,
34
+ COMPUTER_USE_ACTIONS: () => COMPUTER_USE_ACTIONS,
34
35
  DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
35
36
  DEFAULT_OAUTH_BASE_URL: () => DEFAULT_OAUTH_BASE_URL,
36
37
  DEFAULT_REFRESH_SKEW_MS: () => DEFAULT_REFRESH_SKEW_MS,
@@ -45,9 +46,13 @@ __export(index_exports, {
45
46
  MantyxScopeError: () => MantyxScopeError,
46
47
  MantyxToolError: () => MantyxToolError,
47
48
  SDK_VERSION: () => SDK_VERSION,
49
+ buildComputerUseSystemPrompt: () => buildComputerUseSystemPrompt,
50
+ defineComputerUseTools: () => defineComputerUseTools,
48
51
  defineLocalA2A: () => defineLocalA2A,
49
52
  defineLocalMcp: () => defineLocalMcp,
50
53
  defineLocalTool: () => defineLocalTool,
54
+ denormalizeCoordinate: () => denormalizeCoordinate,
55
+ extractActions: () => extractActions,
51
56
  inputFileAttachment: () => inputFileAttachment,
52
57
  inputFileUrlAttachment: () => inputFileUrlAttachment,
53
58
  isLocalA2ATool: () => isLocalA2ATool,
@@ -60,6 +65,7 @@ __export(index_exports, {
60
65
  parseRunOutput: () => parseRunOutput,
61
66
  planOnly: () => planOnly,
62
67
  readSseStream: () => readSseStream,
68
+ runComputerUse: () => runComputerUse,
63
69
  toToolParametersWire: () => toToolParametersWire,
64
70
  zodToJsonSchema: () => zodToJsonSchema
65
71
  });
@@ -168,6 +174,7 @@ function defineLocalTool(opts) {
168
174
  parameters: opts.parameters,
169
175
  outputSchema: opts.outputSchema,
170
176
  longRunning: opts.longRunning ?? false,
177
+ readOnly: opts.readOnly ?? false,
171
178
  execute: opts.execute
172
179
  };
173
180
  }
@@ -284,6 +291,32 @@ function prefixedMcpToolName(serverName, toolName) {
284
291
  const prefix = `${serverName}_`;
285
292
  return toolName.startsWith(prefix) ? toolName : `${prefix}${toolName}`;
286
293
  }
294
+ function normalizeLocalToolOutput(out) {
295
+ if (typeof out === "string") return { result: out };
296
+ if (isLocalToolResult(out)) {
297
+ const files = sanitizeToolResultFiles(out.files);
298
+ const result = typeof out.result === "string" ? out.result : "";
299
+ return files ? { result, files } : { result };
300
+ }
301
+ return { result: JSON.stringify(out) };
302
+ }
303
+ function isLocalToolResult(out) {
304
+ if (out === null || typeof out !== "object" || Array.isArray(out)) return false;
305
+ const o = out;
306
+ return (typeof o.result === "string" || o.result === void 0) && ("files" in o || "result" in o);
307
+ }
308
+ function sanitizeToolResultFiles(files) {
309
+ if (!Array.isArray(files) || files.length === 0) return void 0;
310
+ const out = [];
311
+ for (const f of files) {
312
+ if (!f || typeof f !== "object") continue;
313
+ const file = f;
314
+ if (typeof file.filename === "string" && typeof file.mimeType === "string" && typeof file.data === "string") {
315
+ out.push({ filename: file.filename, mimeType: file.mimeType, data: file.data });
316
+ }
317
+ }
318
+ return out.length > 0 ? out : void 0;
319
+ }
287
320
 
288
321
  // src/local-resolver.ts
289
322
  async function resolveLocalRefs(tools, opts = { fetch: globalThis.fetch }) {
@@ -705,6 +738,7 @@ function inputFileAttachment(opts) {
705
738
  function inputFileUrlAttachment(opts) {
706
739
  return { type: "input_file_url", ...opts };
707
740
  }
741
+ var RUN_FEEDBACK_EXPLANATION_MAX = 8e3;
708
742
  function planOnly(options = {}) {
709
743
  return {
710
744
  planOnly: true,
@@ -1010,6 +1044,7 @@ var MantyxClient = class {
1010
1044
  const kind = ev.kind ?? "local";
1011
1045
  try {
1012
1046
  let out;
1047
+ let files;
1013
1048
  if (kind === "a2a_local") {
1014
1049
  const tool = handlers.a2aTools.get(ev.name);
1015
1050
  if (!tool) {
@@ -1041,10 +1076,11 @@ var MantyxClient = class {
1041
1076
  return;
1042
1077
  }
1043
1078
  const args = handler.parameters ? handler.parameters.parse?.(ev.args) ?? ev.args : ev.args;
1044
- const result = await handler.execute(args);
1045
- out = typeof result === "string" ? result : JSON.stringify(result);
1079
+ const normalized = normalizeLocalToolOutput(await handler.execute(args));
1080
+ out = normalized.result;
1081
+ files = normalized.files;
1046
1082
  }
1047
- await this.postToolResult(runId, ev.toolUseId, { result: out });
1083
+ await this.postToolResult(runId, ev.toolUseId, files ? { result: out, files } : { result: out });
1048
1084
  } catch (err) {
1049
1085
  const message = err instanceof Error ? err.message : String(err);
1050
1086
  const handlerName = describeHandlerName(ev);
@@ -1066,6 +1102,32 @@ var MantyxClient = class {
1066
1102
  path: `/agent-runs/${encodeURIComponent(runId)}/cancel`
1067
1103
  });
1068
1104
  }
1105
+ /**
1106
+ * Record thumbs up/down feedback on a run. Requires the `feedback:write`
1107
+ * OAuth scope (workspace API keys have implicit access). Idempotent per
1108
+ * run — the first call returns HTTP 201, updates return 200; both carry
1109
+ * the same response body. See `docs/agent-runs-protocol.md` §9a.
1110
+ */
1111
+ async submitRunFeedback(runId, input) {
1112
+ if (input.verdict !== "UP" && input.verdict !== "DOWN") {
1113
+ throw new MantyxError(
1114
+ `feedback verdict must be "UP" or "DOWN", got ${JSON.stringify(input.verdict)}`
1115
+ );
1116
+ }
1117
+ if (input.explanation !== void 0 && input.explanation.length > RUN_FEEDBACK_EXPLANATION_MAX) {
1118
+ throw new MantyxError(
1119
+ `feedback explanation must be <= ${RUN_FEEDBACK_EXPLANATION_MAX} characters`
1120
+ );
1121
+ }
1122
+ const body = { verdict: input.verdict };
1123
+ if (input.explanation !== void 0) body.explanation = input.explanation;
1124
+ if (input.contentSnapshot !== void 0) body.contentSnapshot = input.contentSnapshot;
1125
+ return this.request({
1126
+ method: "POST",
1127
+ path: `/agent-runs/${encodeURIComponent(runId)}/feedback`,
1128
+ body
1129
+ });
1130
+ }
1069
1131
  // -------------------------------------------------------------- HTTP
1070
1132
  absoluteUrl(path) {
1071
1133
  return `${this.options.baseUrl}/api/v1/workspaces/${encodeURIComponent(this.options.workspaceSlug)}${path}`;
@@ -1345,7 +1407,8 @@ function serializeToolRefs(tools) {
1345
1407
  description: t.description,
1346
1408
  parameters: toToolParametersWire(t.parameters),
1347
1409
  ...t.outputSchema !== void 0 ? { outputSchema: toToolParametersWire(t.outputSchema) } : {},
1348
- ...t.longRunning ? { longRunning: true } : {}
1410
+ ...t.longRunning ? { longRunning: true } : {},
1411
+ ...t.readOnly ? { readOnly: true } : {}
1349
1412
  };
1350
1413
  case "a2a":
1351
1414
  return {
@@ -1981,11 +2044,366 @@ function normalizeScope(scope) {
1981
2044
  return joined.length > 0 ? joined : void 0;
1982
2045
  }
1983
2046
 
2047
+ // src/computer-use.ts
2048
+ var import_zod2 = require("zod");
2049
+ function denormalizeCoordinate(value, size) {
2050
+ return Math.round(value / 1e3 * size);
2051
+ }
2052
+ var COMPUTER_USE_ACTIONS = [
2053
+ "navigate",
2054
+ "click_at",
2055
+ "hover_at",
2056
+ "type_text_at",
2057
+ "key_combination",
2058
+ "scroll_at",
2059
+ "scroll_document",
2060
+ "drag_and_drop",
2061
+ "go_back",
2062
+ "go_forward",
2063
+ "wait"
2064
+ ];
2065
+ var WAIT_HINT = "Action performed. A fresh screenshot will be provided in the next message; do not call another action until you have seen it.";
2066
+ function defineComputerUseTools(controller, opts = {}) {
2067
+ const excluded = new Set(opts.excludeActions ?? []);
2068
+ const includeConfirm = opts.requestConfirmation ?? true;
2069
+ const px = async (x, y) => {
2070
+ const vp = await controller.viewport();
2071
+ return { x: denormalizeCoordinate(x, vp.width), y: denormalizeCoordinate(y, vp.height) };
2072
+ };
2073
+ const ack = async (note) => {
2074
+ let url;
2075
+ if (controller.currentUrl) {
2076
+ try {
2077
+ url = await controller.currentUrl();
2078
+ } catch {
2079
+ }
2080
+ }
2081
+ return JSON.stringify({
2082
+ status: "ok",
2083
+ ...note ? { note } : {},
2084
+ ...url ? { url } : {},
2085
+ hint: WAIT_HINT
2086
+ });
2087
+ };
2088
+ const tools = [];
2089
+ const add = (action, build) => {
2090
+ if (!excluded.has(action)) tools.push(build());
2091
+ };
2092
+ add(
2093
+ "navigate",
2094
+ () => defineLocalTool({
2095
+ name: "navigate",
2096
+ description: "Navigate the browser directly to a URL.",
2097
+ parameters: import_zod2.z.object({ url: import_zod2.z.string().describe("Absolute URL to open.") }),
2098
+ execute: async ({ url }) => {
2099
+ if (!controller.navigate) return errorResult("navigate is not supported by this environment");
2100
+ await controller.navigate(url);
2101
+ return ack();
2102
+ }
2103
+ })
2104
+ );
2105
+ add(
2106
+ "click_at",
2107
+ () => defineLocalTool({
2108
+ name: "click_at",
2109
+ description: "Click at a coordinate. x and y are on a 0-1000 grid scaled to the screen.",
2110
+ parameters: import_zod2.z.object({
2111
+ x: import_zod2.z.number().describe("Horizontal coordinate, 0-1000."),
2112
+ y: import_zod2.z.number().describe("Vertical coordinate, 0-1000.")
2113
+ }),
2114
+ execute: async ({ x, y }) => {
2115
+ const p = await px(x, y);
2116
+ await controller.clickAt(p.x, p.y);
2117
+ return ack();
2118
+ }
2119
+ })
2120
+ );
2121
+ add(
2122
+ "hover_at",
2123
+ () => defineLocalTool({
2124
+ name: "hover_at",
2125
+ description: "Hover the mouse at a coordinate (useful to reveal menus). x and y are on a 0-1000 grid.",
2126
+ parameters: import_zod2.z.object({
2127
+ x: import_zod2.z.number().describe("Horizontal coordinate, 0-1000."),
2128
+ y: import_zod2.z.number().describe("Vertical coordinate, 0-1000.")
2129
+ }),
2130
+ execute: async ({ x, y }) => {
2131
+ if (!controller.hoverAt) return errorResult("hover_at is not supported by this environment");
2132
+ const p = await px(x, y);
2133
+ await controller.hoverAt(p.x, p.y);
2134
+ return ack();
2135
+ }
2136
+ })
2137
+ );
2138
+ add(
2139
+ "type_text_at",
2140
+ () => defineLocalTool({
2141
+ name: "type_text_at",
2142
+ description: "Type text at a coordinate. By default clears the field first and presses Enter after typing. x and y are on a 0-1000 grid.",
2143
+ parameters: import_zod2.z.object({
2144
+ x: import_zod2.z.number().describe("Horizontal coordinate, 0-1000."),
2145
+ y: import_zod2.z.number().describe("Vertical coordinate, 0-1000."),
2146
+ text: import_zod2.z.string().describe("Text to type."),
2147
+ press_enter: import_zod2.z.boolean().optional().describe("Press Enter after typing. Default true."),
2148
+ clear_before_typing: import_zod2.z.boolean().optional().describe("Clear the field before typing. Default true.")
2149
+ }),
2150
+ execute: async ({ x, y, text, press_enter, clear_before_typing }) => {
2151
+ const p = await px(x, y);
2152
+ await controller.typeTextAt(p.x, p.y, text, {
2153
+ pressEnter: press_enter ?? true,
2154
+ clearBeforeTyping: clear_before_typing ?? true
2155
+ });
2156
+ return ack();
2157
+ }
2158
+ })
2159
+ );
2160
+ add(
2161
+ "key_combination",
2162
+ () => defineLocalTool({
2163
+ name: "key_combination",
2164
+ description: 'Press a key or chord, e.g. "Enter", "Control+C", "Control+A". Useful for submitting or clipboard actions.',
2165
+ parameters: import_zod2.z.object({
2166
+ keys: import_zod2.z.string().describe('Key or chord, e.g. "Enter" or "Control+C".')
2167
+ }),
2168
+ execute: async ({ keys }) => {
2169
+ if (!controller.keyCombination)
2170
+ return errorResult("key_combination is not supported by this environment");
2171
+ await controller.keyCombination(keys);
2172
+ return ack();
2173
+ }
2174
+ })
2175
+ );
2176
+ add(
2177
+ "scroll_at",
2178
+ () => defineLocalTool({
2179
+ name: "scroll_at",
2180
+ description: "Scroll the area at a coordinate in a direction by a pixel magnitude (default 800). Coordinates are on a 0-1000 grid.",
2181
+ parameters: import_zod2.z.object({
2182
+ x: import_zod2.z.number().describe("Horizontal coordinate, 0-1000."),
2183
+ y: import_zod2.z.number().describe("Vertical coordinate, 0-1000."),
2184
+ direction: import_zod2.z.enum(["up", "down", "left", "right"]),
2185
+ magnitude: import_zod2.z.number().optional().describe("Scroll distance in pixels. Default 800.")
2186
+ }),
2187
+ execute: async ({ x, y, direction, magnitude }) => {
2188
+ if (!controller.scrollAt) return errorResult("scroll_at is not supported by this environment");
2189
+ const p = await px(x, y);
2190
+ await controller.scrollAt(p.x, p.y, direction, magnitude ?? 800);
2191
+ return ack();
2192
+ }
2193
+ })
2194
+ );
2195
+ add(
2196
+ "scroll_document",
2197
+ () => defineLocalTool({
2198
+ name: "scroll_document",
2199
+ description: 'Scroll the whole page "up", "down", "left", or "right".',
2200
+ parameters: import_zod2.z.object({ direction: import_zod2.z.enum(["up", "down", "left", "right"]) }),
2201
+ execute: async ({ direction }) => {
2202
+ if (!controller.scrollDocument)
2203
+ return errorResult("scroll_document is not supported by this environment");
2204
+ await controller.scrollDocument(direction);
2205
+ return ack();
2206
+ }
2207
+ })
2208
+ );
2209
+ add(
2210
+ "drag_and_drop",
2211
+ () => defineLocalTool({
2212
+ name: "drag_and_drop",
2213
+ description: "Drag from a starting coordinate and drop at a destination coordinate. All coordinates are on a 0-1000 grid.",
2214
+ parameters: import_zod2.z.object({
2215
+ x: import_zod2.z.number().describe("Start horizontal, 0-1000."),
2216
+ y: import_zod2.z.number().describe("Start vertical, 0-1000."),
2217
+ destination_x: import_zod2.z.number().describe("Destination horizontal, 0-1000."),
2218
+ destination_y: import_zod2.z.number().describe("Destination vertical, 0-1000.")
2219
+ }),
2220
+ execute: async ({ x, y, destination_x, destination_y }) => {
2221
+ if (!controller.dragAndDrop)
2222
+ return errorResult("drag_and_drop is not supported by this environment");
2223
+ const from = await px(x, y);
2224
+ const to = await px(destination_x, destination_y);
2225
+ await controller.dragAndDrop(from.x, from.y, to.x, to.y);
2226
+ return ack();
2227
+ }
2228
+ })
2229
+ );
2230
+ add(
2231
+ "go_back",
2232
+ () => defineLocalTool({
2233
+ name: "go_back",
2234
+ description: "Navigate to the previous page in history.",
2235
+ parameters: import_zod2.z.object({}),
2236
+ execute: async () => {
2237
+ if (!controller.goBack) return errorResult("go_back is not supported by this environment");
2238
+ await controller.goBack();
2239
+ return ack();
2240
+ }
2241
+ })
2242
+ );
2243
+ add(
2244
+ "go_forward",
2245
+ () => defineLocalTool({
2246
+ name: "go_forward",
2247
+ description: "Navigate to the next page in history.",
2248
+ parameters: import_zod2.z.object({}),
2249
+ execute: async () => {
2250
+ if (!controller.goForward)
2251
+ return errorResult("go_forward is not supported by this environment");
2252
+ await controller.goForward();
2253
+ return ack();
2254
+ }
2255
+ })
2256
+ );
2257
+ add(
2258
+ "wait",
2259
+ () => defineLocalTool({
2260
+ name: "wait",
2261
+ description: "Pause to let dynamic content load or animations finish.",
2262
+ parameters: import_zod2.z.object({
2263
+ seconds: import_zod2.z.number().optional().describe("Seconds to wait. Default 1, max 10.")
2264
+ }),
2265
+ execute: async ({ seconds }) => {
2266
+ const s = Math.min(Math.max(seconds ?? 1, 0), 10);
2267
+ await new Promise((resolve) => setTimeout(resolve, s * 1e3));
2268
+ return ack(`waited ${s}s`);
2269
+ }
2270
+ })
2271
+ );
2272
+ if (includeConfirm) {
2273
+ tools.push(
2274
+ defineLocalTool({
2275
+ name: "request_confirmation",
2276
+ description: "Ask the human operator to approve a consequential or irreversible action BEFORE performing it (e.g. submitting a form, sending a message, making a purchase, accepting terms, solving a CAPTCHA, logging in). Returns whether you are cleared to proceed.",
2277
+ parameters: import_zod2.z.object({
2278
+ reason: import_zod2.z.string().describe("What you are about to do and why confirmation is needed.")
2279
+ }),
2280
+ execute: async ({ reason }) => {
2281
+ const approved = opts.confirm ? await opts.confirm(reason) : false;
2282
+ return JSON.stringify({
2283
+ approved,
2284
+ ...approved ? { note: "Operator approved. Proceed with the action, then stop and wait for the next screenshot." } : { note: "Operator denied. Do not perform the action; choose a different approach or stop and report back." }
2285
+ });
2286
+ }
2287
+ })
2288
+ );
2289
+ }
2290
+ return tools;
2291
+ }
2292
+ function errorResult(message) {
2293
+ return JSON.stringify({ status: "error", error: message });
2294
+ }
2295
+ function buildComputerUseSystemPrompt(opts = {}) {
2296
+ const environment = opts.environment ?? "web browser";
2297
+ const confirmation = opts.requestConfirmation ?? true;
2298
+ const lines = [
2299
+ `You are an agent that controls a ${environment} by looking at screenshots and taking UI actions.`,
2300
+ "",
2301
+ "Protocol:",
2302
+ `- Before every step you receive a screenshot of the current ${environment} as an image attachment. Study it carefully.`,
2303
+ "- Choose EXACTLY ONE action and call the matching tool. Coordinates use a 0-1000 grid (top-left is 0,0; bottom-right is 1000,1000), scaled automatically to the screen.",
2304
+ "- After the tool runs, STOP and wait. You will be given a new screenshot reflecting the result; only then decide the next action.",
2305
+ "- Do not chain multiple actions in one turn and do not guess what happened \u2014 always rely on the next screenshot.",
2306
+ "- Scroll to reveal content before concluding something is missing.",
2307
+ "",
2308
+ "Finishing:",
2309
+ "- When the task is complete (or you have gathered enough information to answer), reply with a plain-text final answer and DO NOT call any tool. That ends the session.",
2310
+ "- If you get stuck or cannot proceed, explain why in plain text without calling a tool."
2311
+ ];
2312
+ if (confirmation) {
2313
+ lines.push(
2314
+ "",
2315
+ "Safety \u2014 you MUST call `request_confirmation` and wait for approval BEFORE any consequential or irreversible action, including:",
2316
+ "- Accepting terms of service, privacy policies, cookie banners, or other agreements.",
2317
+ "- Solving or bypassing CAPTCHAs or other human-verification checks.",
2318
+ "- Completing a purchase, moving money, or any financial transaction.",
2319
+ "- Sending an email or message, or posting content.",
2320
+ "- Logging into an account, or accessing/modifying sensitive personal data.",
2321
+ "- Downloading, saving, sharing, or transferring files or user data.",
2322
+ "For these, do all preparatory steps first, then call `request_confirmation` immediately BEFORE the final irreversible click. If denied, do not perform the action."
2323
+ );
2324
+ }
2325
+ if (opts.extraInstructions) {
2326
+ lines.push("", opts.extraInstructions);
2327
+ }
2328
+ return lines.join("\n");
2329
+ }
2330
+ var DEFAULT_CONTINUE_TEXT = "Here is the screen after your last action. Continue toward the goal, or give your final answer if the task is done.";
2331
+ function extractActions(result) {
2332
+ const actions = [];
2333
+ for (const ev of result.events) {
2334
+ if (ev.type === "local_tool_call") {
2335
+ const e = ev;
2336
+ actions.push({ name: e.name ?? "", input: e.args ?? {} });
2337
+ }
2338
+ }
2339
+ return actions;
2340
+ }
2341
+ function screenshotExtension(mimeType) {
2342
+ if (mimeType.includes("png")) return "png";
2343
+ if (mimeType.includes("webp")) return "webp";
2344
+ return "jpg";
2345
+ }
2346
+ async function runComputerUse(opts) {
2347
+ const maxSteps = opts.maxSteps ?? 20;
2348
+ if (maxSteps < 1) throw new Error("runComputerUse: maxSteps must be >= 1");
2349
+ const requestConfirmation = !opts.disableConfirmation;
2350
+ const tools = defineComputerUseTools(opts.controller, {
2351
+ ...opts.excludeActions ? { excludeActions: opts.excludeActions } : {},
2352
+ requestConfirmation,
2353
+ ...opts.confirm ? { confirm: opts.confirm } : {}
2354
+ });
2355
+ const systemPrompt = opts.systemPrompt ?? buildComputerUseSystemPrompt({
2356
+ ...opts.systemPromptOptions ?? {},
2357
+ requestConfirmation
2358
+ });
2359
+ const session = await opts.client.createSession({
2360
+ systemPrompt,
2361
+ ...opts.model ? { modelId: opts.model } : {},
2362
+ tools,
2363
+ ...opts.reasoningLevel !== void 0 ? { reasoningLevel: opts.reasoningLevel } : {},
2364
+ ...opts.metadata ? { metadata: opts.metadata } : {}
2365
+ });
2366
+ const steps = [];
2367
+ let finalText = "";
2368
+ let stoppedReason = "max_steps";
2369
+ try {
2370
+ for (let i = 0; i < maxSteps; i++) {
2371
+ const screenshot = await opts.controller.screenshot();
2372
+ const filename = screenshot.filename ?? `screenshot-${i + 1}.${screenshotExtension(screenshot.mimeType)}`;
2373
+ const attachment = inputFileAttachment({
2374
+ mimeType: screenshot.mimeType,
2375
+ filename,
2376
+ data: screenshot.data
2377
+ });
2378
+ const turnText = i === 0 ? opts.goal : opts.continueText ?? DEFAULT_CONTINUE_TEXT;
2379
+ const result = await session.send(turnText, {
2380
+ attachments: [attachment],
2381
+ ...opts.onAssistantDelta ? { onAssistantDelta: opts.onAssistantDelta } : {},
2382
+ ...opts.signal ? { signal: opts.signal } : {}
2383
+ });
2384
+ const actions = extractActions(result);
2385
+ const step = { step: i + 1, screenshot, result, actions };
2386
+ steps.push(step);
2387
+ finalText = result.text;
2388
+ if (opts.onStep) await opts.onStep(step);
2389
+ if (actions.length === 0) {
2390
+ stoppedReason = "completed";
2391
+ break;
2392
+ }
2393
+ }
2394
+ return { finalText, steps, sessionId: session.id, stoppedReason };
2395
+ } finally {
2396
+ await session.end().catch(() => {
2397
+ });
2398
+ }
2399
+ }
2400
+
1984
2401
  // src/version.ts
1985
- var SDK_VERSION = "0.16.0";
2402
+ var SDK_VERSION = "0.18.0";
1986
2403
  // Annotate the CommonJS export names for ESM import in node:
1987
2404
  0 && (module.exports = {
1988
2405
  AgentSession,
2406
+ COMPUTER_USE_ACTIONS,
1989
2407
  DEFAULT_BASE_URL,
1990
2408
  DEFAULT_OAUTH_BASE_URL,
1991
2409
  DEFAULT_REFRESH_SKEW_MS,
@@ -2000,9 +2418,13 @@ var SDK_VERSION = "0.16.0";
2000
2418
  MantyxScopeError,
2001
2419
  MantyxToolError,
2002
2420
  SDK_VERSION,
2421
+ buildComputerUseSystemPrompt,
2422
+ defineComputerUseTools,
2003
2423
  defineLocalA2A,
2004
2424
  defineLocalMcp,
2005
2425
  defineLocalTool,
2426
+ denormalizeCoordinate,
2427
+ extractActions,
2006
2428
  inputFileAttachment,
2007
2429
  inputFileUrlAttachment,
2008
2430
  isLocalA2ATool,
@@ -2015,6 +2437,7 @@ var SDK_VERSION = "0.16.0";
2015
2437
  parseRunOutput,
2016
2438
  planOnly,
2017
2439
  readSseStream,
2440
+ runComputerUse,
2018
2441
  toToolParametersWire,
2019
2442
  zodToJsonSchema
2020
2443
  });