@elizaos/plugin-computeruse 2.0.0-alpha.9 → 2.0.3-beta.2

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -0
  3. package/package.json +126 -103
  4. package/dist/actions/click-coordinates.d.ts +0 -3
  5. package/dist/actions/click-coordinates.d.ts.map +0 -1
  6. package/dist/actions/click-coordinates.js +0 -139
  7. package/dist/actions/click-coordinates.js.map +0 -1
  8. package/dist/actions/click.d.ts +0 -3
  9. package/dist/actions/click.d.ts.map +0 -1
  10. package/dist/actions/click.js +0 -144
  11. package/dist/actions/click.js.map +0 -1
  12. package/dist/actions/drag.d.ts +0 -3
  13. package/dist/actions/drag.d.ts.map +0 -1
  14. package/dist/actions/drag.js +0 -145
  15. package/dist/actions/drag.js.map +0 -1
  16. package/dist/actions/get-applications.d.ts +0 -3
  17. package/dist/actions/get-applications.d.ts.map +0 -1
  18. package/dist/actions/get-applications.js +0 -105
  19. package/dist/actions/get-applications.js.map +0 -1
  20. package/dist/actions/get-window-tree.d.ts +0 -3
  21. package/dist/actions/get-window-tree.d.ts.map +0 -1
  22. package/dist/actions/get-window-tree.js +0 -133
  23. package/dist/actions/get-window-tree.js.map +0 -1
  24. package/dist/actions/open-application.d.ts +0 -3
  25. package/dist/actions/open-application.d.ts.map +0 -1
  26. package/dist/actions/open-application.js +0 -117
  27. package/dist/actions/open-application.js.map +0 -1
  28. package/dist/actions/press-key.d.ts +0 -3
  29. package/dist/actions/press-key.d.ts.map +0 -1
  30. package/dist/actions/press-key.js +0 -115
  31. package/dist/actions/press-key.js.map +0 -1
  32. package/dist/actions/screenshot.d.ts +0 -3
  33. package/dist/actions/screenshot.d.ts.map +0 -1
  34. package/dist/actions/screenshot.js +0 -99
  35. package/dist/actions/screenshot.js.map +0 -1
  36. package/dist/actions/scroll.d.ts +0 -3
  37. package/dist/actions/scroll.d.ts.map +0 -1
  38. package/dist/actions/scroll.js +0 -137
  39. package/dist/actions/scroll.js.map +0 -1
  40. package/dist/actions/type.d.ts +0 -3
  41. package/dist/actions/type.d.ts.map +0 -1
  42. package/dist/actions/type.js +0 -163
  43. package/dist/actions/type.js.map +0 -1
  44. package/dist/index.d.ts +0 -8
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/index.js +0 -66
  47. package/dist/index.js.map +0 -1
  48. package/dist/providers/available-apps.d.ts +0 -3
  49. package/dist/providers/available-apps.d.ts.map +0 -1
  50. package/dist/providers/available-apps.js +0 -28
  51. package/dist/providers/available-apps.js.map +0 -1
  52. package/dist/providers/computeruse-state.d.ts +0 -3
  53. package/dist/providers/computeruse-state.d.ts.map +0 -1
  54. package/dist/providers/computeruse-state.js +0 -36
  55. package/dist/providers/computeruse-state.js.map +0 -1
  56. package/dist/service-registry.d.ts +0 -7
  57. package/dist/service-registry.d.ts.map +0 -1
  58. package/dist/service-registry.js +0 -2
  59. package/dist/service-registry.js.map +0 -1
  60. package/dist/services/computeruse-service.d.ts +0 -36
  61. package/dist/services/computeruse-service.d.ts.map +0 -1
  62. package/dist/services/computeruse-service.js +0 -391
  63. package/dist/services/computeruse-service.js.map +0 -1
  64. package/dist/types.d.ts +0 -41
  65. package/dist/types.d.ts.map +0 -1
  66. package/dist/types.js +0 -11
  67. package/dist/types.js.map +0 -1
  68. package/dist/utils/params.d.ts +0 -5
  69. package/dist/utils/params.d.ts.map +0 -1
  70. package/dist/utils/params.js +0 -13
  71. package/dist/utils/params.js.map +0 -1
@@ -1,391 +0,0 @@
1
- import { logger, Service } from "@elizaos/core";
2
- import { computerUseConfigSchema, } from "../types.js";
3
- export class ComputerUseService extends Service {
4
- static serviceType = "computeruse";
5
- capabilityDescription = "Enables the agent to control a computer UI locally (when supported) or via a ComputerUse MCP server";
6
- computeruseConfig;
7
- backendName = null;
8
- initialized = false;
9
- // Lazy-loaded to avoid importing native bindings unless actually used.
10
- localDesktop = null;
11
- constructor(runtime) {
12
- super(runtime);
13
- this.computeruseConfig = computerUseConfigSchema.parse({
14
- COMPUTERUSE_ENABLED: String(process.env.COMPUTERUSE_ENABLED ?? "false"),
15
- COMPUTERUSE_MODE: String(process.env.COMPUTERUSE_MODE ?? "auto"),
16
- COMPUTERUSE_MCP_SERVER: String(process.env.COMPUTERUSE_MCP_SERVER ?? "computeruse"),
17
- });
18
- }
19
- static async start(runtime) {
20
- const service = new ComputerUseService(runtime);
21
- return service;
22
- }
23
- async stop() {
24
- this.localDesktop = null;
25
- this.backendName = null;
26
- this.initialized = false;
27
- }
28
- getMode() {
29
- return this.computeruseConfig.COMPUTERUSE_MODE;
30
- }
31
- getBackendName() {
32
- return this.backendName;
33
- }
34
- getMcpServerName() {
35
- return this.computeruseConfig.COMPUTERUSE_MCP_SERVER;
36
- }
37
- isEnabled() {
38
- return this.computeruseConfig.COMPUTERUSE_ENABLED;
39
- }
40
- async ensureReady() {
41
- if (this.initialized)
42
- return;
43
- this.initialized = true;
44
- await this.initializeBackend();
45
- }
46
- async initializeBackend() {
47
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED) {
48
- logger.info("[computeruse] disabled (COMPUTERUSE_ENABLED=false)");
49
- this.backendName = null;
50
- return;
51
- }
52
- // ── Sandbox mode: force MCP to prevent local desktop control ──────
53
- const runtimeRecord = this.runtime;
54
- const isSandboxMode = Boolean(runtimeRecord?.sandboxMode);
55
- if (isSandboxMode) {
56
- logger.info("[computeruse] sandbox mode active — forcing MCP backend (local desktop control disabled)");
57
- this.computeruseConfig.COMPUTERUSE_MODE = "mcp";
58
- await this.ensureMcpBackend();
59
- this.backendName = "mcp";
60
- return;
61
- }
62
- // ── End sandbox mode override ─────────────────────────────────────
63
- const mode = this.computeruseConfig.COMPUTERUSE_MODE;
64
- if (mode === "local") {
65
- await this.ensureLocalBackend();
66
- this.backendName = "local";
67
- return;
68
- }
69
- if (mode === "mcp") {
70
- await this.ensureMcpBackend();
71
- this.backendName = "mcp";
72
- return;
73
- }
74
- // auto - try local on all platforms, fall back to MCP
75
- try {
76
- await this.ensureLocalBackend();
77
- this.backendName = "local";
78
- return;
79
- }
80
- catch (err) {
81
- const msg = err instanceof Error ? err.message : String(err);
82
- logger.warn(`[computeruse] local backend unavailable, falling back to mcp: ${msg}`);
83
- }
84
- await this.ensureMcpBackend();
85
- this.backendName = "mcp";
86
- }
87
- async ensureLocalBackend() {
88
- if (this.localDesktop)
89
- return;
90
- // Import only when needed (native optional deps).
91
- try {
92
- const loadModule = Function("moduleName", "return import(moduleName)");
93
- const mod = (await loadModule("@elizaos/computeruse"));
94
- if (typeof mod.Desktop !== "function") {
95
- throw new Error("Desktop API is not available in @elizaos/computeruse");
96
- }
97
- this.localDesktop = new mod.Desktop();
98
- }
99
- catch (err) {
100
- const msg = err instanceof Error ? err.message : String(err);
101
- const platform = process.platform;
102
- if (platform === "darwin") {
103
- throw new Error(`macOS native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-darwin-* is installed.`);
104
- }
105
- else if (platform === "linux") {
106
- throw new Error(`Linux native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-linux-* is installed.`);
107
- }
108
- throw err;
109
- }
110
- }
111
- async ensureMcpBackend() {
112
- const mcp = await this.waitForMcpService();
113
- const serverName = this.computeruseConfig.COMPUTERUSE_MCP_SERVER;
114
- const servers = mcp.getServers();
115
- const exists = servers.some((s) => s.name === serverName);
116
- if (!exists) {
117
- throw new Error(`MCP server "${serverName}" not configured. Add it under runtime/character settings "mcp.servers".`);
118
- }
119
- }
120
- async waitForMcpService() {
121
- // Services are registered during runtime initialization; depending on plugin order,
122
- // "mcp" may not be available during another service's start hook.
123
- for (let attempt = 0; attempt < 20; attempt++) {
124
- const mcp = this.runtime.getService("mcp");
125
- if (mcp)
126
- return mcp;
127
- await new Promise((resolve) => setTimeout(resolve, 50));
128
- }
129
- throw new Error("MCP service not available. Add @elizaos/plugin-mcp and configure a computeruse server.");
130
- }
131
- getMcp() {
132
- const mcp = this.runtime.getService("mcp");
133
- if (!mcp) {
134
- throw new Error("MCP service not available");
135
- }
136
- return mcp;
137
- }
138
- parseProcessScopedSelector(rawSelector, processHint) {
139
- const selector = rawSelector.trim();
140
- const match = selector.match(/^\s*process:([^\s>]+)\s*(?:>>\s*(.*))?$/);
141
- if (match) {
142
- const process = match[1]?.trim();
143
- const inner = (match[2] ?? "").trim();
144
- if (!process) {
145
- throw new Error("Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'");
146
- }
147
- return { process, selector: inner };
148
- }
149
- const process = processHint?.trim();
150
- if (!process) {
151
- throw new Error("Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'");
152
- }
153
- return { process, selector };
154
- }
155
- async openApplication(appName) {
156
- await this.ensureReady();
157
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
158
- throw new Error("ComputerUse is disabled");
159
- if (this.backendName === "local") {
160
- await this.ensureLocalBackend();
161
- this.localDesktop?.openApplication(appName);
162
- return;
163
- }
164
- if (this.backendName === "mcp") {
165
- const mcp = this.getMcp();
166
- await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "open_application", {
167
- app_name: appName,
168
- verify_element_exists: "",
169
- verify_element_not_exists: "",
170
- include_tree_after_action: false,
171
- });
172
- return;
173
- }
174
- throw new Error("ComputerUse backend not initialized");
175
- }
176
- async click(selector, timeoutMs, process) {
177
- await this.ensureReady();
178
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
179
- throw new Error("ComputerUse is disabled");
180
- if (this.backendName === "local") {
181
- await this.ensureLocalBackend();
182
- const el = await this.localDesktop?.locator(selector).first(timeoutMs);
183
- if (!el)
184
- throw new Error(`Element not found: ${selector}`);
185
- await el.click();
186
- return;
187
- }
188
- if (this.backendName === "mcp") {
189
- const mcp = this.getMcp();
190
- const parsed = this.parseProcessScopedSelector(selector, process);
191
- await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "click_element", {
192
- process: parsed.process,
193
- selector: parsed.selector,
194
- timeout_ms: timeoutMs,
195
- verify_element_exists: "",
196
- verify_element_not_exists: "",
197
- highlight_before_action: false,
198
- ui_diff_before_after: false,
199
- });
200
- return;
201
- }
202
- throw new Error("ComputerUse backend not initialized");
203
- }
204
- async typeText(selector, text, timeoutMs, clearBeforeTyping, process) {
205
- await this.ensureReady();
206
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
207
- throw new Error("ComputerUse is disabled");
208
- if (this.backendName === "local") {
209
- await this.ensureLocalBackend();
210
- const el = await this.localDesktop?.locator(selector).first(timeoutMs);
211
- if (!el)
212
- throw new Error(`Element not found: ${selector}`);
213
- el.typeText(text, { clearBeforeTyping });
214
- return;
215
- }
216
- if (this.backendName === "mcp") {
217
- const mcp = this.getMcp();
218
- const parsed = this.parseProcessScopedSelector(selector, process);
219
- await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "type_into_element", {
220
- process: parsed.process,
221
- selector: parsed.selector,
222
- text_to_type: text,
223
- timeout_ms: timeoutMs,
224
- clear_before_typing: clearBeforeTyping,
225
- highlight_before_action: false,
226
- ui_diff_before_after: false,
227
- });
228
- return;
229
- }
230
- throw new Error("ComputerUse backend not initialized");
231
- }
232
- async getWindowTree(process, title, maxDepth) {
233
- await this.ensureReady();
234
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
235
- throw new Error("ComputerUse is disabled");
236
- if (this.backendName === "local") {
237
- await this.ensureLocalBackend();
238
- const tree = this.localDesktop?.getWindowTree(process, title, undefined);
239
- return JSON.stringify(tree ?? null, null, 2);
240
- }
241
- if (this.backendName === "mcp") {
242
- const mcp = this.getMcp();
243
- const toolArgs = {
244
- process,
245
- include_tree_after_action: true,
246
- };
247
- if (title !== undefined)
248
- toolArgs.title = title;
249
- if (maxDepth !== undefined)
250
- toolArgs.tree_max_depth = maxDepth;
251
- const res = await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "get_window_tree", toolArgs);
252
- const texts = res.content
253
- .filter((c) => c.type === "text")
254
- .map((c) => c.text)
255
- .filter((t) => typeof t === "string");
256
- return texts.join("\n");
257
- }
258
- throw new Error("ComputerUse backend not initialized");
259
- }
260
- async clickCoordinates(x, y, button = "left", numClicks = 1) {
261
- await this.ensureReady();
262
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
263
- throw new Error("ComputerUse is disabled");
264
- if (this.backendName === "local") {
265
- await this.ensureLocalBackend();
266
- this.localDesktop?.clickAtCoordinates(x, y);
267
- return;
268
- }
269
- if (this.backendName === "mcp") {
270
- const mcp = this.getMcp();
271
- await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "click_at_coordinates", { x, y, button, num_clicks: numClicks });
272
- return;
273
- }
274
- throw new Error("ComputerUse backend not initialized");
275
- }
276
- async pressKey(keys) {
277
- await this.ensureReady();
278
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
279
- throw new Error("ComputerUse is disabled");
280
- if (this.backendName === "local") {
281
- await this.ensureLocalBackend();
282
- this.localDesktop?.pressKey(keys);
283
- return;
284
- }
285
- if (this.backendName === "mcp") {
286
- const mcp = this.getMcp();
287
- await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "press_key", { key: keys });
288
- return;
289
- }
290
- throw new Error("ComputerUse backend not initialized");
291
- }
292
- async scroll(direction = "down", amount = 3, x, y) {
293
- await this.ensureReady();
294
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
295
- throw new Error("ComputerUse is disabled");
296
- if (this.backendName === "local") {
297
- await this.ensureLocalBackend();
298
- // Local backend: click at position first if specified, then scroll via key presses
299
- if (x !== undefined && y !== undefined) {
300
- this.localDesktop?.clickAtCoordinates(x, y);
301
- }
302
- const scrollKey = direction === "up" ? "scrollup" : "scrolldown";
303
- for (let i = 0; i < amount; i++) {
304
- this.localDesktop?.pressKey(scrollKey);
305
- }
306
- return;
307
- }
308
- if (this.backendName === "mcp") {
309
- const mcp = this.getMcp();
310
- const toolArgs = { direction, amount };
311
- if (x !== undefined)
312
- toolArgs.x = x;
313
- if (y !== undefined)
314
- toolArgs.y = y;
315
- await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "scroll", toolArgs);
316
- return;
317
- }
318
- throw new Error("ComputerUse backend not initialized");
319
- }
320
- async drag(startX, startY, endX, endY) {
321
- await this.ensureReady();
322
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
323
- throw new Error("ComputerUse is disabled");
324
- if (this.backendName === "local") {
325
- await this.ensureLocalBackend();
326
- // The Desktop native API does not expose a drag method.
327
- // Local backend can only click the start position; full drag requires MCP.
328
- logger.warn("[computeruse] Local drag is limited to click-at-start. Use MCP for full drag.");
329
- this.localDesktop?.clickAtCoordinates(startX, startY);
330
- return;
331
- }
332
- if (this.backendName === "mcp") {
333
- const mcp = this.getMcp();
334
- await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "drag", { start_x: startX, start_y: startY, end_x: endX, end_y: endY });
335
- return;
336
- }
337
- throw new Error("ComputerUse backend not initialized");
338
- }
339
- async screenshot() {
340
- await this.ensureReady();
341
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
342
- throw new Error("ComputerUse is disabled");
343
- if (this.backendName === "local") {
344
- await this.ensureLocalBackend();
345
- const result = this.localDesktop?.captureMonitor(0);
346
- if (result && typeof result === "object" && "toBase64" in result) {
347
- return result.toBase64();
348
- }
349
- return String(result ?? "");
350
- }
351
- if (this.backendName === "mcp") {
352
- const mcp = this.getMcp();
353
- const res = await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "capture_screenshot", {});
354
- const texts = res.content
355
- .filter((c) => c.type === "text")
356
- .map((c) => c.text)
357
- .filter((t) => typeof t === "string");
358
- return texts.join("");
359
- }
360
- throw new Error("ComputerUse backend not initialized");
361
- }
362
- async getApplications() {
363
- await this.ensureReady();
364
- if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
365
- throw new Error("ComputerUse is disabled");
366
- if (this.backendName === "local") {
367
- await this.ensureLocalBackend();
368
- const apps = this.localDesktop?.applications() ?? [];
369
- // Normalize into human-readable names.
370
- const names = [];
371
- for (const app of apps) {
372
- const n = app.name();
373
- if (typeof n === "string" && n.trim().length > 0)
374
- names.push(n);
375
- }
376
- return names;
377
- }
378
- if (this.backendName === "mcp") {
379
- const mcp = this.getMcp();
380
- const res = await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "get_applications_and_windows_list", {});
381
- // Return text-only summary for now; structured parsing is done in actions/providers if needed.
382
- const texts = res.content
383
- .filter((c) => c.type === "text")
384
- .map((c) => c.text)
385
- .filter((t) => typeof t === "string");
386
- return texts.length > 0 ? texts : ["(see MCP tool output)"];
387
- }
388
- throw new Error("ComputerUse backend not initialized");
389
- }
390
- }
391
- //# sourceMappingURL=computeruse-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"computeruse-service.js","sourceRoot":"","sources":["../../src/services/computeruse-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAGN,uBAAuB,GAEvB,MAAM,aAAa,CAAC;AA0CrB,MAAM,OAAO,kBAAmB,SAAQ,OAAO;IAC9C,MAAM,CAAC,WAAW,GAAG,aAAa,CAAC;IACnC,qBAAqB,GACpB,qGAAqG,CAAC;IAE/F,iBAAiB,CAAoB;IACrC,WAAW,GAAkC,IAAI,CAAC;IAClD,WAAW,GAAG,KAAK,CAAC;IAE5B,uEAAuE;IAC/D,YAAY,GAA4B,IAAI,CAAC;IAErD,YAAY,OAAuB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,iBAAiB,GAAG,uBAAuB,CAAC,KAAK,CAAC;YACtD,mBAAmB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC;YACvE,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,M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,CAAC","sourcesContent":["import type { IAgentRuntime } from \"@elizaos/core\";\nimport { logger, Service } from \"@elizaos/core\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n\ttype ComputerUseBackendName,\n\ttype ComputerUseConfig,\n\tcomputerUseConfigSchema,\n\ttype JsonObject,\n} from \"../types.js\";\n\n// Runtime service shape (from @elizaos/plugin-mcp), referenced structurally to avoid a hard dep.\ninterface McpServiceLike extends Service {\n\tcallTool(\n\t\tserverName: string,\n\t\ttoolName: string,\n\t\ttoolArguments?: Readonly<JsonObject>,\n\t): Promise<CallToolResult>;\n\tgetServers(): ReadonlyArray<{ name: string; status: string }>;\n}\n\ninterface LocalDesktopElementLike {\n\tclick(): Promise<void> | void;\n\ttypeText(\n\t\ttext: string,\n\t\toptions?: { clearBeforeTyping?: boolean },\n\t): Promise<void> | void;\n}\n\ninterface LocalDesktopLocatorLike {\n\tfirst(timeoutMs: number): Promise<LocalDesktopElementLike | null | undefined>;\n}\n\ninterface LocalDesktopApplicationLike {\n\tname(): string;\n}\n\ninterface LocalDesktopLike {\n\topenApplication(appName: string): Promise<void> | void;\n\tlocator(selector: string): LocalDesktopLocatorLike;\n\tgetWindowTree(process: string, title?: string, format?: unknown): unknown;\n\tclickAtCoordinates(x: number, y: number): Promise<void> | void;\n\tpressKey(keys: string): Promise<void> | void;\n\tcaptureMonitor(index: number): unknown;\n\tapplications(): LocalDesktopApplicationLike[];\n}\n\ntype LocalDesktopModuleLike = {\n\tDesktop?: new () => LocalDesktopLike;\n};\n\nexport class ComputerUseService extends Service {\n\tstatic serviceType = \"computeruse\";\n\tcapabilityDescription =\n\t\t\"Enables the agent to control a computer UI locally (when supported) or via a ComputerUse MCP server\";\n\n\tprivate computeruseConfig: ComputerUseConfig;\n\tprivate backendName: ComputerUseBackendName | null = null;\n\tprivate initialized = false;\n\n\t// Lazy-loaded to avoid importing native bindings unless actually used.\n\tprivate localDesktop: LocalDesktopLike | null = null;\n\n\tconstructor(runtime?: IAgentRuntime) {\n\t\tsuper(runtime);\n\t\tthis.computeruseConfig = computerUseConfigSchema.parse({\n\t\t\tCOMPUTERUSE_ENABLED: String(process.env.COMPUTERUSE_ENABLED ?? \"false\"),\n\t\t\tCOMPUTERUSE_MODE: String(process.env.COMPUTERUSE_MODE ?? \"auto\"),\n\t\t\tCOMPUTERUSE_MCP_SERVER: String(\n\t\t\t\tprocess.env.COMPUTERUSE_MCP_SERVER ?? \"computeruse\",\n\t\t\t),\n\t\t});\n\t}\n\n\tstatic async start(runtime: IAgentRuntime): Promise<ComputerUseService> {\n\t\tconst service = new ComputerUseService(runtime);\n\t\treturn service;\n\t}\n\n\tasync stop(): Promise<void> {\n\t\tthis.localDesktop = null;\n\t\tthis.backendName = null;\n\t\tthis.initialized = false;\n\t}\n\n\tgetMode(): ComputerUseConfig[\"COMPUTERUSE_MODE\"] {\n\t\treturn this.computeruseConfig.COMPUTERUSE_MODE;\n\t}\n\n\tgetBackendName(): ComputerUseBackendName | null {\n\t\treturn this.backendName;\n\t}\n\n\tgetMcpServerName(): string {\n\t\treturn this.computeruseConfig.COMPUTERUSE_MCP_SERVER;\n\t}\n\n\tisEnabled(): boolean {\n\t\treturn this.computeruseConfig.COMPUTERUSE_ENABLED;\n\t}\n\n\tasync ensureReady(): Promise<void> {\n\t\tif (this.initialized) return;\n\t\tthis.initialized = true;\n\t\tawait this.initializeBackend();\n\t}\n\n\tprivate async initializeBackend(): Promise<void> {\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED) {\n\t\t\tlogger.info(\"[computeruse] disabled (COMPUTERUSE_ENABLED=false)\");\n\t\t\tthis.backendName = null;\n\t\t\treturn;\n\t\t}\n\n\t\t// ── Sandbox mode: force MCP to prevent local desktop control ──────\n\t\tconst runtimeRecord = this.runtime as unknown as { sandboxMode?: unknown };\n\t\tconst isSandboxMode = Boolean(runtimeRecord?.sandboxMode);\n\t\tif (isSandboxMode) {\n\t\t\tlogger.info(\n\t\t\t\t\"[computeruse] sandbox mode active — forcing MCP backend (local desktop control disabled)\",\n\t\t\t);\n\t\t\tthis.computeruseConfig.COMPUTERUSE_MODE = \"mcp\";\n\t\t\tawait this.ensureMcpBackend();\n\t\t\tthis.backendName = \"mcp\";\n\t\t\treturn;\n\t\t}\n\t\t// ── End sandbox mode override ─────────────────────────────────────\n\n\t\tconst mode = this.computeruseConfig.COMPUTERUSE_MODE;\n\t\tif (mode === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tthis.backendName = \"local\";\n\t\t\treturn;\n\t\t}\n\t\tif (mode === \"mcp\") {\n\t\t\tawait this.ensureMcpBackend();\n\t\t\tthis.backendName = \"mcp\";\n\t\t\treturn;\n\t\t}\n\n\t\t// auto - try local on all platforms, fall back to MCP\n\t\ttry {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tthis.backendName = \"local\";\n\t\t\treturn;\n\t\t} catch (err) {\n\t\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\t\tlogger.warn(\n\t\t\t\t`[computeruse] local backend unavailable, falling back to mcp: ${msg}`,\n\t\t\t);\n\t\t}\n\n\t\tawait this.ensureMcpBackend();\n\t\tthis.backendName = \"mcp\";\n\t}\n\n\tprivate async ensureLocalBackend(): Promise<void> {\n\t\tif (this.localDesktop) return;\n\n\t\t// Import only when needed (native optional deps).\n\t\ttry {\n\t\t\tconst loadModule = Function(\n\t\t\t\t\"moduleName\",\n\t\t\t\t\"return import(moduleName)\",\n\t\t\t) as (moduleName: string) => Promise<unknown>;\n\t\t\tconst mod = (await loadModule(\n\t\t\t\t\"@elizaos/computeruse\",\n\t\t\t)) as LocalDesktopModuleLike;\n\t\t\tif (typeof mod.Desktop !== \"function\") {\n\t\t\t\tthrow new Error(\"Desktop API is not available in @elizaos/computeruse\");\n\t\t\t}\n\t\t\tthis.localDesktop = new mod.Desktop();\n\t\t} catch (err) {\n\t\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\t\tconst platform = process.platform;\n\t\t\tif (platform === \"darwin\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`macOS native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-darwin-* is installed.`,\n\t\t\t\t);\n\t\t\t} else if (platform === \"linux\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Linux native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-linux-* is installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async ensureMcpBackend(): Promise<void> {\n\t\tconst mcp = await this.waitForMcpService();\n\n\t\tconst serverName = this.computeruseConfig.COMPUTERUSE_MCP_SERVER;\n\t\tconst servers = mcp.getServers();\n\t\tconst exists = servers.some((s) => s.name === serverName);\n\t\tif (!exists) {\n\t\t\tthrow new Error(\n\t\t\t\t`MCP server \"${serverName}\" not configured. Add it under runtime/character settings \"mcp.servers\".`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate async waitForMcpService(): Promise<McpServiceLike> {\n\t\t// Services are registered during runtime initialization; depending on plugin order,\n\t\t// \"mcp\" may not be available during another service's start hook.\n\t\tfor (let attempt = 0; attempt < 20; attempt++) {\n\t\t\tconst mcp = this.runtime.getService<McpServiceLike>(\"mcp\");\n\t\t\tif (mcp) return mcp;\n\t\t\tawait new Promise<void>((resolve) => setTimeout(resolve, 50));\n\t\t}\n\t\tthrow new Error(\n\t\t\t\"MCP service not available. Add @elizaos/plugin-mcp and configure a computeruse server.\",\n\t\t);\n\t}\n\n\tprivate getMcp(): McpServiceLike {\n\t\tconst mcp = this.runtime.getService<McpServiceLike>(\"mcp\");\n\t\tif (!mcp) {\n\t\t\tthrow new Error(\"MCP service not available\");\n\t\t}\n\t\treturn mcp;\n\t}\n\n\tprivate parseProcessScopedSelector(\n\t\trawSelector: string,\n\t\tprocessHint?: string,\n\t): { process: string; selector: string } {\n\t\tconst selector = rawSelector.trim();\n\t\tconst match = selector.match(/^\\s*process:([^\\s>]+)\\s*(?:>>\\s*(.*))?$/);\n\t\tif (match) {\n\t\t\tconst process = match[1]?.trim();\n\t\t\tconst inner = (match[2] ?? \"\").trim();\n\t\t\tif (!process) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { process, selector: inner };\n\t\t}\n\n\t\tconst process = processHint?.trim();\n\t\tif (!process) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'\",\n\t\t\t);\n\t\t}\n\t\treturn { process, selector };\n\t}\n\n\tasync openApplication(appName: string): Promise<void> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tthis.localDesktop?.openApplication(appName);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tawait mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"open_application\",\n\t\t\t\t{\n\t\t\t\t\tapp_name: appName,\n\t\t\t\t\tverify_element_exists: \"\",\n\t\t\t\t\tverify_element_not_exists: \"\",\n\t\t\t\t\tinclude_tree_after_action: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync click(\n\t\tselector: string,\n\t\ttimeoutMs: number,\n\t\tprocess?: string,\n\t): Promise<void> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tconst el = await this.localDesktop?.locator(selector).first(timeoutMs);\n\t\t\tif (!el) throw new Error(`Element not found: ${selector}`);\n\t\t\tawait el.click();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tconst parsed = this.parseProcessScopedSelector(selector, process);\n\t\t\tawait mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"click_element\",\n\t\t\t\t{\n\t\t\t\t\tprocess: parsed.process,\n\t\t\t\t\tselector: parsed.selector,\n\t\t\t\t\ttimeout_ms: timeoutMs,\n\t\t\t\t\tverify_element_exists: \"\",\n\t\t\t\t\tverify_element_not_exists: \"\",\n\t\t\t\t\thighlight_before_action: false,\n\t\t\t\t\tui_diff_before_after: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync typeText(\n\t\tselector: string,\n\t\ttext: string,\n\t\ttimeoutMs: number,\n\t\tclearBeforeTyping: boolean,\n\t\tprocess?: string,\n\t): Promise<void> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tconst el = await this.localDesktop?.locator(selector).first(timeoutMs);\n\t\t\tif (!el) throw new Error(`Element not found: ${selector}`);\n\t\t\tel.typeText(text, { clearBeforeTyping });\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tconst parsed = this.parseProcessScopedSelector(selector, process);\n\t\t\tawait mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"type_into_element\",\n\t\t\t\t{\n\t\t\t\t\tprocess: parsed.process,\n\t\t\t\t\tselector: parsed.selector,\n\t\t\t\t\ttext_to_type: text,\n\t\t\t\t\ttimeout_ms: timeoutMs,\n\t\t\t\t\tclear_before_typing: clearBeforeTyping,\n\t\t\t\t\thighlight_before_action: false,\n\t\t\t\t\tui_diff_before_after: false,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync getWindowTree(\n\t\tprocess: string,\n\t\ttitle?: string,\n\t\tmaxDepth?: number,\n\t): Promise<string> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tconst tree = this.localDesktop?.getWindowTree(process, title, undefined);\n\t\t\treturn JSON.stringify(tree ?? null, null, 2);\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tconst toolArgs: JsonObject = {\n\t\t\t\tprocess,\n\t\t\t\tinclude_tree_after_action: true,\n\t\t\t};\n\t\t\tif (title !== undefined) toolArgs.title = title;\n\t\t\tif (maxDepth !== undefined) toolArgs.tree_max_depth = maxDepth;\n\t\t\tconst res = await mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"get_window_tree\",\n\t\t\t\ttoolArgs,\n\t\t\t);\n\t\t\tconst texts = res.content\n\t\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.filter((t) => typeof t === \"string\");\n\t\t\treturn texts.join(\"\\n\");\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync clickCoordinates(\n\t\tx: number,\n\t\ty: number,\n\t\tbutton: string = \"left\",\n\t\tnumClicks: number = 1,\n\t): Promise<void> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tthis.localDesktop?.clickAtCoordinates(x, y);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tawait mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"click_at_coordinates\",\n\t\t\t\t{ x, y, button, num_clicks: numClicks },\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync pressKey(keys: string): Promise<void> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tthis.localDesktop?.pressKey(keys);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tawait mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"press_key\",\n\t\t\t\t{ key: keys },\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync scroll(\n\t\tdirection: string = \"down\",\n\t\tamount: number = 3,\n\t\tx?: number,\n\t\ty?: number,\n\t): Promise<void> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\t// Local backend: click at position first if specified, then scroll via key presses\n\t\t\tif (x !== undefined && y !== undefined) {\n\t\t\t\tthis.localDesktop?.clickAtCoordinates(x, y);\n\t\t\t}\n\t\t\tconst scrollKey = direction === \"up\" ? \"scrollup\" : \"scrolldown\";\n\t\t\tfor (let i = 0; i < amount; i++) {\n\t\t\t\tthis.localDesktop?.pressKey(scrollKey);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tconst toolArgs: JsonObject = { direction, amount };\n\t\t\tif (x !== undefined) toolArgs.x = x;\n\t\t\tif (y !== undefined) toolArgs.y = y;\n\t\t\tawait mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"scroll\",\n\t\t\t\ttoolArgs,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync drag(\n\t\tstartX: number,\n\t\tstartY: number,\n\t\tendX: number,\n\t\tendY: number,\n\t): Promise<void> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\t// The Desktop native API does not expose a drag method.\n\t\t\t// Local backend can only click the start position; full drag requires MCP.\n\t\t\tlogger.warn(\n\t\t\t\t\"[computeruse] Local drag is limited to click-at-start. Use MCP for full drag.\",\n\t\t\t);\n\t\t\tthis.localDesktop?.clickAtCoordinates(startX, startY);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tawait mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"drag\",\n\t\t\t\t{ start_x: startX, start_y: startY, end_x: endX, end_y: endY },\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync screenshot(): Promise<string> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tconst result = this.localDesktop?.captureMonitor(0);\n\t\t\tif (result && typeof result === \"object\" && \"toBase64\" in result) {\n\t\t\t\treturn (result as { toBase64(): string }).toBase64();\n\t\t\t}\n\t\t\treturn String(result ?? \"\");\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tconst res = await mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"capture_screenshot\",\n\t\t\t\t{},\n\t\t\t);\n\t\t\tconst texts = res.content\n\t\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.filter((t) => typeof t === \"string\");\n\t\t\treturn texts.join(\"\");\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n\n\tasync getApplications(): Promise<string[]> {\n\t\tawait this.ensureReady();\n\t\tif (!this.computeruseConfig.COMPUTERUSE_ENABLED)\n\t\t\tthrow new Error(\"ComputerUse is disabled\");\n\n\t\tif (this.backendName === \"local\") {\n\t\t\tawait this.ensureLocalBackend();\n\t\t\tconst apps = this.localDesktop?.applications() ?? [];\n\t\t\t// Normalize into human-readable names.\n\t\t\tconst names: string[] = [];\n\t\t\tfor (const app of apps) {\n\t\t\t\tconst n = app.name();\n\t\t\t\tif (typeof n === \"string\" && n.trim().length > 0) names.push(n);\n\t\t\t}\n\t\t\treturn names;\n\t\t}\n\n\t\tif (this.backendName === \"mcp\") {\n\t\t\tconst mcp = this.getMcp();\n\t\t\tconst res = await mcp.callTool(\n\t\t\t\tthis.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n\t\t\t\t\"get_applications_and_windows_list\",\n\t\t\t\t{},\n\t\t\t);\n\t\t\t// Return text-only summary for now; structured parsing is done in actions/providers if needed.\n\t\t\tconst texts = res.content\n\t\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.filter((t) => typeof t === \"string\");\n\t\t\treturn texts.length > 0 ? texts : [\"(see MCP tool output)\"];\n\t\t}\n\n\t\tthrow new Error(\"ComputerUse backend not initialized\");\n\t}\n}\n"]}
package/dist/types.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { z } from "zod";
2
- export type JsonPrimitive = string | number | boolean | null;
3
- export type JsonValue = JsonPrimitive | JsonValue[] | {
4
- [key: string]: JsonValue;
5
- };
6
- export type JsonObject = {
7
- [key: string]: JsonValue;
8
- };
9
- export type ComputerUseMode = "auto" | "local" | "mcp";
10
- export declare const computerUseConfigSchema: z.ZodObject<{
11
- COMPUTERUSE_ENABLED: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodString>>, z.ZodTransform<boolean, string>>;
12
- COMPUTERUSE_MODE: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
13
- auto: "auto";
14
- local: "local";
15
- mcp: "mcp";
16
- }>>>;
17
- COMPUTERUSE_MCP_SERVER: z.ZodDefault<z.ZodOptional<z.ZodString>>;
18
- }, z.core.$strip>;
19
- export type ComputerUseConfig = z.infer<typeof computerUseConfigSchema>;
20
- export type ComputerUseBackendName = "local" | "mcp";
21
- export interface ComputerUseOpenApplicationInput {
22
- readonly name: string;
23
- }
24
- export interface ComputerUseClickInput {
25
- readonly process?: string;
26
- readonly selector: string;
27
- readonly timeoutMs: number;
28
- }
29
- export interface ComputerUseTypeInput {
30
- readonly process?: string;
31
- readonly selector: string;
32
- readonly text: string;
33
- readonly timeoutMs: number;
34
- readonly clearBeforeTyping: boolean;
35
- }
36
- export interface ComputerUseGetWindowTreeInput {
37
- readonly process: string;
38
- readonly title?: string;
39
- readonly maxDepth?: number;
40
- }
41
- //# sourceMappingURL=types.d.ts.map
@@ -1 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E,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B"}
package/dist/types.js DELETED
@@ -1,11 +0,0 @@
1
- import { z } from "zod";
2
- export const computerUseConfigSchema = z.object({
3
- COMPUTERUSE_ENABLED: z
4
- .string()
5
- .optional()
6
- .default("false")
7
- .transform((val) => val === "true"),
8
- COMPUTERUSE_MODE: z.enum(["auto", "local", "mcp"]).optional().default("auto"),
9
- COMPUTERUSE_MCP_SERVER: z.string().optional().default("computeruse"),
10
- });
11
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,mBAAmB,EAAE,CAAC;SACpB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,OAAO,CAAC;SAChB,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC;IACpC,gBAAgB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7E,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;CACpE,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue =\n\t| JsonPrimitive\n\t| JsonValue[]\n\t| { [key: string]: JsonValue };\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type ComputerUseMode = \"auto\" | \"local\" | \"mcp\";\n\nexport const computerUseConfigSchema = z.object({\n\tCOMPUTERUSE_ENABLED: z\n\t\t.string()\n\t\t.optional()\n\t\t.default(\"false\")\n\t\t.transform((val) => val === \"true\"),\n\tCOMPUTERUSE_MODE: z.enum([\"auto\", \"local\", \"mcp\"]).optional().default(\"auto\"),\n\tCOMPUTERUSE_MCP_SERVER: z.string().optional().default(\"computeruse\"),\n});\n\nexport type ComputerUseConfig = z.infer<typeof computerUseConfigSchema>;\n\nexport type ComputerUseBackendName = \"local\" | \"mcp\";\n\nexport interface ComputerUseOpenApplicationInput {\n\treadonly name: string;\n}\n\nexport interface ComputerUseClickInput {\n\treadonly process?: string;\n\treadonly selector: string;\n\treadonly timeoutMs: number;\n}\n\nexport interface ComputerUseTypeInput {\n\treadonly process?: string;\n\treadonly selector: string;\n\treadonly text: string;\n\treadonly timeoutMs: number;\n\treadonly clearBeforeTyping: boolean;\n}\n\nexport interface ComputerUseGetWindowTreeInput {\n\treadonly process: string;\n\treadonly title?: string;\n\treadonly maxDepth?: number;\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { ActionParameters } from "@elizaos/core";
2
- export declare function getStringParam(params: ActionParameters | undefined, name: string): string | undefined;
3
- export declare function getNumberParam(params: ActionParameters | undefined, name: string): number | undefined;
4
- export declare function getBooleanParam(params: ActionParameters | undefined, name: string): boolean | undefined;
5
- //# sourceMappingURL=params.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/utils/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,wBAAgB,cAAc,CAC7B,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAGpB;AAED,wBAAgB,cAAc,CAC7B,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAGpB;AAED,wBAAgB,eAAe,CAC9B,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,GACV,OAAO,GAAG,SAAS,CAGrB"}
@@ -1,13 +0,0 @@
1
- export function getStringParam(params, name) {
2
- const val = params?.[name];
3
- return typeof val === "string" ? val : undefined;
4
- }
5
- export function getNumberParam(params, name) {
6
- const val = params?.[name];
7
- return typeof val === "number" ? val : undefined;
8
- }
9
- export function getBooleanParam(params, name) {
10
- const val = params?.[name];
11
- return typeof val === "boolean" ? val : undefined;
12
- }
13
- //# sourceMappingURL=params.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"params.js","sourceRoot":"","sources":["../../src/utils/params.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAC7B,MAAoC,EACpC,IAAY;IAEZ,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,cAAc,CAC7B,MAAoC,EACpC,IAAY;IAEZ,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,eAAe,CAC9B,MAAoC,EACpC,IAAY;IAEZ,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC","sourcesContent":["import type { ActionParameters } from \"@elizaos/core\";\n\nexport function getStringParam(\n\tparams: ActionParameters | undefined,\n\tname: string,\n): string | undefined {\n\tconst val = params?.[name];\n\treturn typeof val === \"string\" ? val : undefined;\n}\n\nexport function getNumberParam(\n\tparams: ActionParameters | undefined,\n\tname: string,\n): number | undefined {\n\tconst val = params?.[name];\n\treturn typeof val === \"number\" ? val : undefined;\n}\n\nexport function getBooleanParam(\n\tparams: ActionParameters | undefined,\n\tname: string,\n): boolean | undefined {\n\tconst val = params?.[name];\n\treturn typeof val === \"boolean\" ? val : undefined;\n}\n"]}