@elizaos/plugin-computeruse 2.0.0-alpha.1

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 (49) hide show
  1. package/dist/actions/click.d.ts +3 -0
  2. package/dist/actions/click.d.ts.map +1 -0
  3. package/dist/actions/click.js +76 -0
  4. package/dist/actions/click.js.map +1 -0
  5. package/dist/actions/get-applications.d.ts +3 -0
  6. package/dist/actions/get-applications.d.ts.map +1 -0
  7. package/dist/actions/get-applications.js +42 -0
  8. package/dist/actions/get-applications.js.map +1 -0
  9. package/dist/actions/get-window-tree.d.ts +3 -0
  10. package/dist/actions/get-window-tree.d.ts.map +1 -0
  11. package/dist/actions/get-window-tree.js +73 -0
  12. package/dist/actions/get-window-tree.js.map +1 -0
  13. package/dist/actions/open-application.d.ts +3 -0
  14. package/dist/actions/open-application.d.ts.map +1 -0
  15. package/dist/actions/open-application.js +57 -0
  16. package/dist/actions/open-application.js.map +1 -0
  17. package/dist/actions/type.d.ts +3 -0
  18. package/dist/actions/type.d.ts.map +1 -0
  19. package/dist/actions/type.js +103 -0
  20. package/dist/actions/type.js.map +1 -0
  21. package/dist/index.d.ts +8 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +50 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/providers/available-apps.d.ts +3 -0
  26. package/dist/providers/available-apps.d.ts.map +1 -0
  27. package/dist/providers/available-apps.js +22 -0
  28. package/dist/providers/available-apps.js.map +1 -0
  29. package/dist/providers/computeruse-state.d.ts +3 -0
  30. package/dist/providers/computeruse-state.d.ts.map +1 -0
  31. package/dist/providers/computeruse-state.js +35 -0
  32. package/dist/providers/computeruse-state.js.map +1 -0
  33. package/dist/service-registry.d.ts +7 -0
  34. package/dist/service-registry.d.ts.map +1 -0
  35. package/dist/service-registry.js +2 -0
  36. package/dist/service-registry.js.map +1 -0
  37. package/dist/services/computeruse-service.d.ts +31 -0
  38. package/dist/services/computeruse-service.d.ts.map +1 -0
  39. package/dist/services/computeruse-service.js +274 -0
  40. package/dist/services/computeruse-service.js.map +1 -0
  41. package/dist/types.d.ts +41 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +11 -0
  44. package/dist/types.js.map +1 -0
  45. package/dist/utils/params.d.ts +5 -0
  46. package/dist/utils/params.d.ts.map +1 -0
  47. package/dist/utils/params.js +13 -0
  48. package/dist/utils/params.js.map +1 -0
  49. package/package.json +77 -0
@@ -0,0 +1,3 @@
1
+ import type { Action } from "@elizaos/core";
2
+ export declare const computeruseClickAction: Action;
3
+ //# sourceMappingURL=click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/actions/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,sBAAsB,EAAE,MAkFpC,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { logger } from "@elizaos/core";
2
+ import { getNumberParam, getStringParam } from "../utils/params.js";
3
+ export const computeruseClickAction = {
4
+ name: "COMPUTERUSE_CLICK",
5
+ description: "Clicks a UI element on the computer using a ComputerUse selector.",
6
+ similes: ["CLICK_UI", "CLICK_ELEMENT", "TAP_UI"],
7
+ parameters: [
8
+ {
9
+ name: "process",
10
+ description: "Process name to scope the click when using MCP mode (e.g. 'chrome', 'notepad'). Optional if selector is prefixed with 'process:<name> >> ...'.",
11
+ required: false,
12
+ schema: { type: "string" },
13
+ examples: ["chrome", "notepad"],
14
+ },
15
+ {
16
+ name: "selector",
17
+ description: "ComputerUse selector string for the target element",
18
+ required: true,
19
+ schema: { type: "string" },
20
+ examples: ["role:Button && name:Submit", "role:Edit && name:Search"],
21
+ },
22
+ {
23
+ name: "timeoutMs",
24
+ description: "Timeout in milliseconds to find the element",
25
+ required: false,
26
+ schema: { type: "number", default: 5000, minimum: 0 },
27
+ examples: [5000],
28
+ },
29
+ ],
30
+ validate: async (runtime, message) => {
31
+ const service = runtime.getService("computeruse");
32
+ if (!service || !service.isEnabled())
33
+ return false;
34
+ const text = message.content?.text?.toLowerCase() ?? "";
35
+ return text.includes("click") || text.includes("tap");
36
+ },
37
+ handler: async (runtime, message, _state, options, callback) => {
38
+ const service = runtime.getService("computeruse");
39
+ if (!service) {
40
+ return { success: false, text: "ComputerUse service not available" };
41
+ }
42
+ const params = options?.parameters;
43
+ const process = getStringParam(params, "process");
44
+ const selector = getStringParam(params, "selector");
45
+ const timeoutMs = getNumberParam(params, "timeoutMs") ?? 5000;
46
+ if (!selector) {
47
+ return { success: false, text: "Missing required parameter: selector" };
48
+ }
49
+ try {
50
+ await service.click(selector, timeoutMs, process);
51
+ const response = {
52
+ text: `Clicked element: ${selector}`,
53
+ actions: ["COMPUTERUSE_CLICK"],
54
+ source: message.content?.source ?? "action",
55
+ };
56
+ await callback?.(response);
57
+ return {
58
+ success: true,
59
+ text: response.text ?? "",
60
+ values: { process, selector, timeoutMs },
61
+ data: { process, selector, timeoutMs, backend: service.getBackendName() },
62
+ };
63
+ }
64
+ catch (err) {
65
+ const msg = err instanceof Error ? err.message : String(err);
66
+ logger.error(`[computeruse] click failed: ${msg}`);
67
+ return {
68
+ success: false,
69
+ text: `ComputerUse click failed: ${msg}`,
70
+ values: { process, selector, timeoutMs },
71
+ data: { process, selector, timeoutMs, backend: service.getBackendName() },
72
+ };
73
+ }
74
+ },
75
+ };
76
+ //# sourceMappingURL=click.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/actions/click.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,CAAC,MAAM,sBAAsB,GAAW;IAC5C,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mEAAmE;IAChF,OAAO,EAAE,CAAC,UAAU,EAAE,e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CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;YACnD,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,6BAA6B,GAAG,EAAE;gBACxC,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE;gBACxC,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE;aAC1E,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type {\n Action,\n ActionResult,\n Content,\n HandlerCallback,\n HandlerOptions,\n IAgentRuntime,\n Memory,\n State,\n} from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\nimport { getNumberParam, getStringParam } from \"../utils/params.js\";\n\nexport const computeruseClickAction: Action = {\n name: \"COMPUTERUSE_CLICK\",\n description: \"Clicks a UI element on the computer using a ComputerUse selector.\",\n similes: [\"CLICK_UI\", \"CLICK_ELEMENT\", \"TAP_UI\"],\n parameters: [\n {\n name: \"process\",\n description:\n \"Process name to scope the click when using MCP mode (e.g. 'chrome', 'notepad'). Optional if selector is prefixed with 'process:<name> >> ...'.\",\n required: false,\n schema: { type: \"string\" },\n examples: [\"chrome\", \"notepad\"],\n },\n {\n name: \"selector\",\n description: \"ComputerUse selector string for the target element\",\n required: true,\n schema: { type: \"string\" },\n examples: [\"role:Button && name:Submit\", \"role:Edit && name:Search\"],\n },\n {\n name: \"timeoutMs\",\n description: \"Timeout in milliseconds to find the element\",\n required: false,\n schema: { type: \"number\", default: 5000, minimum: 0 },\n examples: [5000],\n },\n ],\n\n validate: async (runtime: IAgentRuntime, message: Memory): Promise<boolean> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service || !service.isEnabled()) return false;\n\n const text = message.content?.text?.toLowerCase() ?? \"\";\n return text.includes(\"click\") || text.includes(\"tap\");\n },\n\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: HandlerOptions,\n callback?: HandlerCallback\n ): Promise<ActionResult> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service) {\n return { success: false, text: \"ComputerUse service not available\" };\n }\n\n const params = options?.parameters;\n const process = getStringParam(params, \"process\");\n const selector = getStringParam(params, \"selector\");\n const timeoutMs = getNumberParam(params, \"timeoutMs\") ?? 5000;\n if (!selector) {\n return { success: false, text: \"Missing required parameter: selector\" };\n }\n\n try {\n await service.click(selector, timeoutMs, process);\n const response: Content = {\n text: `Clicked element: ${selector}`,\n actions: [\"COMPUTERUSE_CLICK\"],\n source: message.content?.source ?? \"action\",\n };\n await callback?.(response);\n return {\n success: true,\n text: response.text ?? \"\",\n values: { process, selector, timeoutMs },\n data: { process, selector, timeoutMs, backend: service.getBackendName() },\n };\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logger.error(`[computeruse] click failed: ${msg}`);\n return {\n success: false,\n text: `ComputerUse click failed: ${msg}`,\n values: { process, selector, timeoutMs },\n data: { process, selector, timeoutMs, backend: service.getBackendName() },\n };\n }\n },\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Action } from "@elizaos/core";
2
+ export declare const computeruseGetApplicationsAction: Action;
3
+ //# sourceMappingURL=get-applications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-applications.d.ts","sourceRoot":"","sources":["../../src/actions/get-applications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,gCAAgC,EAAE,MA8C9C,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { logger } from "@elizaos/core";
2
+ export const computeruseGetApplicationsAction = {
3
+ name: "COMPUTERUSE_GET_APPLICATIONS",
4
+ description: "Lists currently running applications on the target machine.",
5
+ similes: ["LIST_APPS", "LIST_APPLICATIONS", "SHOW_RUNNING_APPS"],
6
+ validate: async (runtime, message) => {
7
+ const service = runtime.getService("computeruse");
8
+ if (!service || !service.isEnabled())
9
+ return false;
10
+ const text = message.content?.text?.toLowerCase() ?? "";
11
+ return text.includes("applications") || text.includes("apps") || text.includes("running");
12
+ },
13
+ handler: async (runtime, message, _state, _options, callback) => {
14
+ const service = runtime.getService("computeruse");
15
+ if (!service)
16
+ return { success: false, text: "ComputerUse service not available" };
17
+ try {
18
+ const apps = await service.getApplications();
19
+ const text = Array.isArray(apps)
20
+ ? `Applications:\n${apps.map((a) => `- ${a}`).join("\n")}`
21
+ : "Applications: (see output)";
22
+ const response = {
23
+ text,
24
+ actions: ["COMPUTERUSE_GET_APPLICATIONS"],
25
+ source: message.content?.source ?? "action",
26
+ };
27
+ await callback?.(response);
28
+ return {
29
+ success: true,
30
+ text,
31
+ values: { count: apps.length },
32
+ data: { apps, backend: service.getBackendName() },
33
+ };
34
+ }
35
+ catch (err) {
36
+ const msg = err instanceof Error ? err.message : String(err);
37
+ logger.error(`[computeruse] get applications failed: ${msg}`);
38
+ return { success: false, text: `ComputerUse get applications failed: ${msg}` };
39
+ }
40
+ },
41
+ };
42
+ //# sourceMappingURL=get-applications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-applications.js","sourceRoot":"","sources":["../../src/actions/get-applications.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,MAAM,CAAC,MAAM,gCAAgC,GAAW;IACtD,IAAI,EAAE,8BAA8B;IACpC,WAAW,EAAE,6DAA6D;IAC1E,OAAO,EAAE,CAAC,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,CAAC;IAEhE,QAAQ,EAAE,KAAK,EAAE,OAAsB,EAAE,OAAe,EAAoB,EAAE;QAC5E,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAqB,aAAa,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,C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AAO,CAAC,cAAc,EAAE,EAAE;aAClD,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,CAAC,0CAA0C,GAAG,EAAE,CAAC,CAAC;YAC9D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,wCAAwC,GAAG,EAAE,EAAE,CAAC;QACjF,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type {\n Action,\n ActionResult,\n Content,\n HandlerCallback,\n HandlerOptions,\n IAgentRuntime,\n Memory,\n State,\n} from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\n\nexport const computeruseGetApplicationsAction: Action = {\n name: \"COMPUTERUSE_GET_APPLICATIONS\",\n description: \"Lists currently running applications on the target machine.\",\n similes: [\"LIST_APPS\", \"LIST_APPLICATIONS\", \"SHOW_RUNNING_APPS\"],\n\n validate: async (runtime: IAgentRuntime, message: Memory): Promise<boolean> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service || !service.isEnabled()) return false;\n\n const text = message.content?.text?.toLowerCase() ?? \"\";\n return text.includes(\"applications\") || text.includes(\"apps\") || text.includes(\"running\");\n },\n\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: HandlerOptions,\n callback?: HandlerCallback\n ): Promise<ActionResult> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service) return { success: false, text: \"ComputerUse service not available\" };\n\n try {\n const apps = await service.getApplications();\n const text = Array.isArray(apps)\n ? `Applications:\\n${apps.map((a) => `- ${a}`).join(\"\\n\")}`\n : \"Applications: (see output)\";\n const response: Content = {\n text,\n actions: [\"COMPUTERUSE_GET_APPLICATIONS\"],\n source: message.content?.source ?? \"action\",\n };\n await callback?.(response);\n return {\n success: true,\n text,\n values: { count: apps.length },\n data: { apps, backend: service.getBackendName() },\n };\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logger.error(`[computeruse] get applications failed: ${msg}`);\n return { success: false, text: `ComputerUse get applications failed: ${msg}` };\n }\n },\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Action } from "@elizaos/core";
2
+ export declare const computeruseGetWindowTreeAction: Action;
3
+ //# sourceMappingURL=get-window-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-window-tree.d.ts","sourceRoot":"","sources":["../../src/actions/get-window-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,8BAA8B,EAAE,MA8E5C,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { logger } from "@elizaos/core";
2
+ import { getNumberParam, getStringParam } from "../utils/params.js";
3
+ export const computeruseGetWindowTreeAction = {
4
+ name: "COMPUTERUSE_GET_WINDOW_TREE",
5
+ description: "Gets the UI tree for a running application (useful for understanding what is currently on screen).",
6
+ similes: ["GET_UI_TREE", "WINDOW_TREE", "DUMP_UI_TREE"],
7
+ parameters: [
8
+ {
9
+ name: "process",
10
+ description: "Process name of the target application (e.g. 'chrome', 'notepad')",
11
+ required: true,
12
+ schema: { type: "string" },
13
+ examples: ["chrome", "notepad"],
14
+ },
15
+ {
16
+ name: "title",
17
+ description: "Optional window title filter",
18
+ required: false,
19
+ schema: { type: "string" },
20
+ },
21
+ {
22
+ name: "maxDepth",
23
+ description: "Optional max tree depth (MCP mode only)",
24
+ required: false,
25
+ schema: { type: "number", minimum: 0 },
26
+ examples: [6],
27
+ },
28
+ ],
29
+ validate: async (runtime, message) => {
30
+ const service = runtime.getService("computeruse");
31
+ if (!service || !service.isEnabled())
32
+ return false;
33
+ const text = message.content?.text?.toLowerCase() ?? "";
34
+ return text.includes("window tree") || text.includes("ui tree") || text.includes("dump tree");
35
+ },
36
+ handler: async (runtime, message, _state, options, callback) => {
37
+ const service = runtime.getService("computeruse");
38
+ if (!service)
39
+ return { success: false, text: "ComputerUse service not available" };
40
+ const params = options?.parameters;
41
+ const process = getStringParam(params, "process");
42
+ const title = getStringParam(params, "title");
43
+ const maxDepth = getNumberParam(params, "maxDepth");
44
+ if (!process)
45
+ return { success: false, text: "Missing required parameter: process" };
46
+ try {
47
+ const treeText = await service.getWindowTree(process, title, maxDepth);
48
+ const response = {
49
+ text: treeText.length > 0 ? treeText : "(empty tree result)",
50
+ actions: ["COMPUTERUSE_GET_WINDOW_TREE"],
51
+ source: message.content?.source ?? "action",
52
+ };
53
+ await callback?.(response);
54
+ return {
55
+ success: true,
56
+ text: response.text ?? "",
57
+ values: { process, title, maxDepth },
58
+ data: { process, title, maxDepth, backend: service.getBackendName() },
59
+ };
60
+ }
61
+ catch (err) {
62
+ const msg = err instanceof Error ? err.message : String(err);
63
+ logger.error(`[computeruse] get window tree failed: ${msg}`);
64
+ return {
65
+ success: false,
66
+ text: `ComputerUse get window tree failed: ${msg}`,
67
+ values: { process, title, maxDepth },
68
+ data: { process, title, maxDepth, backend: service.getBackendName() },
69
+ };
70
+ }
71
+ },
72
+ };
73
+ //# sourceMappingURL=get-window-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-window-tree.js","sourceRoot":"","sources":["../../src/actions/get-window-tree.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,CAAC,MAAM,8BAA8B,GAAW;IACpD,IAAI,EAAE,6BAA6B;IACnC,WAAW,EACT,oGAAoG;IACtG,OAAO,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,cAAc,CAAC;IACvD,UAAU,EAAE;QACV;YACE,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,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gBACL,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,uCAAuC,GAAG,EAAE;gBAClD,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;gBACpC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE;aACtE,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type {\n Action,\n ActionResult,\n Content,\n HandlerCallback,\n HandlerOptions,\n IAgentRuntime,\n Memory,\n State,\n} from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\nimport { getNumberParam, getStringParam } from \"../utils/params.js\";\n\nexport const computeruseGetWindowTreeAction: Action = {\n name: \"COMPUTERUSE_GET_WINDOW_TREE\",\n description:\n \"Gets the UI tree for a running application (useful for understanding what is currently on screen).\",\n similes: [\"GET_UI_TREE\", \"WINDOW_TREE\", \"DUMP_UI_TREE\"],\n parameters: [\n {\n name: \"process\",\n description: \"Process name of the target application (e.g. 'chrome', 'notepad')\",\n required: true,\n schema: { type: \"string\" },\n examples: [\"chrome\", \"notepad\"],\n },\n {\n name: \"title\",\n description: \"Optional window title filter\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"maxDepth\",\n description: \"Optional max tree depth (MCP mode only)\",\n required: false,\n schema: { type: \"number\", minimum: 0 },\n examples: [6],\n },\n ],\n\n validate: async (runtime: IAgentRuntime, message: Memory): Promise<boolean> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service || !service.isEnabled()) return false;\n\n const text = message.content?.text?.toLowerCase() ?? \"\";\n return text.includes(\"window tree\") || text.includes(\"ui tree\") || text.includes(\"dump tree\");\n },\n\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: HandlerOptions,\n callback?: HandlerCallback\n ): Promise<ActionResult> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service) return { success: false, text: \"ComputerUse service not available\" };\n\n const params = options?.parameters;\n const process = getStringParam(params, \"process\");\n const title = getStringParam(params, \"title\");\n const maxDepth = getNumberParam(params, \"maxDepth\");\n\n if (!process) return { success: false, text: \"Missing required parameter: process\" };\n\n try {\n const treeText = await service.getWindowTree(process, title, maxDepth);\n const response: Content = {\n text: treeText.length > 0 ? treeText : \"(empty tree result)\",\n actions: [\"COMPUTERUSE_GET_WINDOW_TREE\"],\n source: message.content?.source ?? \"action\",\n };\n await callback?.(response);\n return {\n success: true,\n text: response.text ?? \"\",\n values: { process, title, maxDepth },\n data: { process, title, maxDepth, backend: service.getBackendName() },\n };\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logger.error(`[computeruse] get window tree failed: ${msg}`);\n return {\n success: false,\n text: `ComputerUse get window tree failed: ${msg}`,\n values: { process, title, maxDepth },\n data: { process, title, maxDepth, backend: service.getBackendName() },\n };\n }\n },\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Action } from "@elizaos/core";
2
+ export declare const computeruseOpenApplicationAction: Action;
3
+ //# sourceMappingURL=open-application.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-application.d.ts","sourceRoot":"","sources":["../../src/actions/open-application.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,gCAAgC,EAAE,MA4D9C,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { logger } from "@elizaos/core";
2
+ import { getStringParam } from "../utils/params.js";
3
+ export const computeruseOpenApplicationAction = {
4
+ name: "COMPUTERUSE_OPEN_APPLICATION",
5
+ description: "Opens an application on the target machine (local or MCP).",
6
+ similes: ["OPEN_APP", "LAUNCH_APP", "START_APPLICATION"],
7
+ parameters: [
8
+ {
9
+ name: "name",
10
+ description: "Application name or executable path (e.g. 'calc', 'notepad', 'chrome')",
11
+ required: true,
12
+ schema: { type: "string" },
13
+ examples: ["calc", "notepad", "chrome"],
14
+ },
15
+ ],
16
+ validate: async (runtime, message) => {
17
+ const service = runtime.getService("computeruse");
18
+ if (!service || !service.isEnabled())
19
+ return false;
20
+ const text = message.content?.text?.toLowerCase() ?? "";
21
+ return text.includes("open") || text.includes("launch") || text.includes("start");
22
+ },
23
+ handler: async (runtime, message, _state, options, callback) => {
24
+ const service = runtime.getService("computeruse");
25
+ if (!service)
26
+ return { success: false, text: "ComputerUse service not available" };
27
+ const name = getStringParam(options?.parameters, "name");
28
+ if (!name)
29
+ return { success: false, text: "Missing required parameter: name" };
30
+ try {
31
+ await service.openApplication(name);
32
+ const response = {
33
+ text: `Opened application: ${name}`,
34
+ actions: ["COMPUTERUSE_OPEN_APPLICATION"],
35
+ source: message.content?.source ?? "action",
36
+ };
37
+ await callback?.(response);
38
+ return {
39
+ success: true,
40
+ text: response.text ?? "",
41
+ values: { name },
42
+ data: { name, backend: service.getBackendName() },
43
+ };
44
+ }
45
+ catch (err) {
46
+ const msg = err instanceof Error ? err.message : String(err);
47
+ logger.error(`[computeruse] open application failed: ${msg}`);
48
+ return {
49
+ success: false,
50
+ text: `ComputerUse open application failed: ${msg}`,
51
+ values: { name },
52
+ data: { name, backend: service.getBackendName() },
53
+ };
54
+ }
55
+ },
56
+ };
57
+ //# sourceMappingURL=open-application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-application.js","sourceRoot":"","sources":["../../src/actions/open-application.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,gCAAgC,GAAW;IACtD,IAAI,EAAE,8BAA8B;IACpC,WAAW,EAAE,4DAA4D;IACzE,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,mBAAmB,CAAC;IACxD,UAAU,EAAE;QACV;YACE,IAAI,EAAE,MAAM;YACZ,WAAW,EA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CAAC;gBACzC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,QAAQ;aAC5C,CAAC;YACF,MAAM,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;YAC3B,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;gBACzB,MAAM,EAAE,EAAE,IAAI,EAAE;gBAChB,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE;aAClD,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,CAAC,0CAA0C,GAAG,EAAE,CAAC,CAAC;YAC9D,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,wCAAwC,GAAG,EAAE;gBACnD,MAAM,EAAE,EAAE,IAAI,EAAE;gBAChB,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE;aAClD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type {\n Action,\n ActionResult,\n Content,\n HandlerCallback,\n HandlerOptions,\n IAgentRuntime,\n Memory,\n State,\n} from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\nimport { getStringParam } from \"../utils/params.js\";\n\nexport const computeruseOpenApplicationAction: Action = {\n name: \"COMPUTERUSE_OPEN_APPLICATION\",\n description: \"Opens an application on the target machine (local or MCP).\",\n similes: [\"OPEN_APP\", \"LAUNCH_APP\", \"START_APPLICATION\"],\n parameters: [\n {\n name: \"name\",\n description: \"Application name or executable path (e.g. 'calc', 'notepad', 'chrome')\",\n required: true,\n schema: { type: \"string\" },\n examples: [\"calc\", \"notepad\", \"chrome\"],\n },\n ],\n\n validate: async (runtime: IAgentRuntime, message: Memory): Promise<boolean> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service || !service.isEnabled()) return false;\n\n const text = message.content?.text?.toLowerCase() ?? \"\";\n return text.includes(\"open\") || text.includes(\"launch\") || text.includes(\"start\");\n },\n\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: HandlerOptions,\n callback?: HandlerCallback\n ): Promise<ActionResult> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service) return { success: false, text: \"ComputerUse service not available\" };\n\n const name = getStringParam(options?.parameters, \"name\");\n if (!name) return { success: false, text: \"Missing required parameter: name\" };\n\n try {\n await service.openApplication(name);\n const response: Content = {\n text: `Opened application: ${name}`,\n actions: [\"COMPUTERUSE_OPEN_APPLICATION\"],\n source: message.content?.source ?? \"action\",\n };\n await callback?.(response);\n return {\n success: true,\n text: response.text ?? \"\",\n values: { name },\n data: { name, backend: service.getBackendName() },\n };\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logger.error(`[computeruse] open application failed: ${msg}`);\n return {\n success: false,\n text: `ComputerUse open application failed: ${msg}`,\n values: { name },\n data: { name, backend: service.getBackendName() },\n };\n }\n },\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Action } from "@elizaos/core";
2
+ export declare const computeruseTypeAction: Action;
3
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/actions/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,qBAAqB,EAAE,MA6GnC,CAAC"}
@@ -0,0 +1,103 @@
1
+ import { logger } from "@elizaos/core";
2
+ import { getBooleanParam, getNumberParam, getStringParam } from "../utils/params.js";
3
+ export const computeruseTypeAction = {
4
+ name: "COMPUTERUSE_TYPE",
5
+ description: "Types text into a UI element on the computer using a ComputerUse selector (optionally clearing the field).",
6
+ similes: ["TYPE_UI", "ENTER_TEXT", "FILL_FIELD"],
7
+ parameters: [
8
+ {
9
+ name: "process",
10
+ description: "Process name to scope the typing when using MCP mode (e.g. 'chrome', 'notepad'). Optional if selector is prefixed with 'process:<name> >> ...'.",
11
+ required: false,
12
+ schema: { type: "string" },
13
+ examples: ["chrome", "notepad"],
14
+ },
15
+ {
16
+ name: "selector",
17
+ description: "ComputerUse selector string for the target element",
18
+ required: true,
19
+ schema: { type: "string" },
20
+ examples: ["role:Edit && name:Search"],
21
+ },
22
+ {
23
+ name: "text",
24
+ description: "Text to type",
25
+ required: true,
26
+ schema: { type: "string" },
27
+ examples: ["hello world", "user@example.com{Enter}"],
28
+ },
29
+ {
30
+ name: "timeoutMs",
31
+ description: "Timeout in milliseconds to find the element",
32
+ required: false,
33
+ schema: { type: "number", default: 5000, minimum: 0 },
34
+ },
35
+ {
36
+ name: "clearBeforeTyping",
37
+ description: "Whether to clear existing text before typing (default: true)",
38
+ required: false,
39
+ schema: { type: "boolean", default: true },
40
+ },
41
+ ],
42
+ validate: async (runtime, message) => {
43
+ const service = runtime.getService("computeruse");
44
+ if (!service || !service.isEnabled())
45
+ return false;
46
+ const text = message.content?.text?.toLowerCase() ?? "";
47
+ return text.includes("type") || text.includes("enter") || text.includes("fill");
48
+ },
49
+ handler: async (runtime, message, _state, options, callback) => {
50
+ const service = runtime.getService("computeruse");
51
+ if (!service) {
52
+ return { success: false, text: "ComputerUse service not available" };
53
+ }
54
+ const params = options?.parameters;
55
+ const process = getStringParam(params, "process");
56
+ const selector = getStringParam(params, "selector");
57
+ const text = getStringParam(params, "text");
58
+ const timeoutMs = getNumberParam(params, "timeoutMs") ?? 5000;
59
+ const clearBeforeTyping = getBooleanParam(params, "clearBeforeTyping") ?? true;
60
+ if (!selector)
61
+ return { success: false, text: "Missing required parameter: selector" };
62
+ if (!text)
63
+ return { success: false, text: "Missing required parameter: text" };
64
+ try {
65
+ await service.typeText(selector, text, timeoutMs, clearBeforeTyping, process);
66
+ const response = {
67
+ text: `Typed into element: ${selector}`,
68
+ actions: ["COMPUTERUSE_TYPE"],
69
+ source: message.content?.source ?? "action",
70
+ };
71
+ await callback?.(response);
72
+ return {
73
+ success: true,
74
+ text: response.text ?? "",
75
+ values: { process, selector, timeoutMs, clearBeforeTyping },
76
+ data: {
77
+ process,
78
+ selector,
79
+ timeoutMs,
80
+ clearBeforeTyping,
81
+ backend: service.getBackendName(),
82
+ },
83
+ };
84
+ }
85
+ catch (err) {
86
+ const msg = err instanceof Error ? err.message : String(err);
87
+ logger.error(`[computeruse] type failed: ${msg}`);
88
+ return {
89
+ success: false,
90
+ text: `ComputerUse type failed: ${msg}`,
91
+ values: { process, selector, timeoutMs, clearBeforeTyping },
92
+ data: {
93
+ process,
94
+ selector,
95
+ timeoutMs,
96
+ clearBeforeTyping,
97
+ backend: service.getBackendName(),
98
+ },
99
+ };
100
+ }
101
+ },
102
+ };
103
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/actions/type.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAErF,MAAM,CAAC,MAAM,qBAAqB,GAAW;IAC3C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,4GAA4G;IAC9G,OAAO,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,YAAY,CAAC;IAChD,UAAU,EAAE;QACV;YACE,IAAI,EAAE,SAAS;YACf,WAAW,EACT,iJAAiJ;YACnJ,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;SAChC;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,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;gBACzB,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE;gBAC3D,IAAI,EAAE;oBACJ,OAAO;oBACP,QAAQ;oBACR,SAAS;oBACT,iBAAiB;oBACjB,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE;iBAClC;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;YAClD,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,4BAA4B,GAAG,EAAE;gBACvC,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE;gBAC3D,IAAI,EAAE;oBACJ,OAAO;oBACP,QAAQ;oBACR,SAAS;oBACT,iBAAiB;oBACjB,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE;iBAClC;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type {\n Action,\n ActionResult,\n Content,\n HandlerCallback,\n HandlerOptions,\n IAgentRuntime,\n Memory,\n State,\n} from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\nimport { getBooleanParam, getNumberParam, getStringParam } from \"../utils/params.js\";\n\nexport const computeruseTypeAction: Action = {\n name: \"COMPUTERUSE_TYPE\",\n description:\n \"Types text into a UI element on the computer using a ComputerUse selector (optionally clearing the field).\",\n similes: [\"TYPE_UI\", \"ENTER_TEXT\", \"FILL_FIELD\"],\n parameters: [\n {\n name: \"process\",\n description:\n \"Process name to scope the typing when using MCP mode (e.g. 'chrome', 'notepad'). Optional if selector is prefixed with 'process:<name> >> ...'.\",\n required: false,\n schema: { type: \"string\" },\n examples: [\"chrome\", \"notepad\"],\n },\n {\n name: \"selector\",\n description: \"ComputerUse selector string for the target element\",\n required: true,\n schema: { type: \"string\" },\n examples: [\"role:Edit && name:Search\"],\n },\n {\n name: \"text\",\n description: \"Text to type\",\n required: true,\n schema: { type: \"string\" },\n examples: [\"hello world\", \"user@example.com{Enter}\"],\n },\n {\n name: \"timeoutMs\",\n description: \"Timeout in milliseconds to find the element\",\n required: false,\n schema: { type: \"number\", default: 5000, minimum: 0 },\n },\n {\n name: \"clearBeforeTyping\",\n description: \"Whether to clear existing text before typing (default: true)\",\n required: false,\n schema: { type: \"boolean\", default: true },\n },\n ],\n\n validate: async (runtime: IAgentRuntime, message: Memory): Promise<boolean> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service || !service.isEnabled()) return false;\n\n const text = message.content?.text?.toLowerCase() ?? \"\";\n return text.includes(\"type\") || text.includes(\"enter\") || text.includes(\"fill\");\n },\n\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: HandlerOptions,\n callback?: HandlerCallback\n ): Promise<ActionResult> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service) {\n return { success: false, text: \"ComputerUse service not available\" };\n }\n\n const params = options?.parameters;\n const process = getStringParam(params, \"process\");\n const selector = getStringParam(params, \"selector\");\n const text = getStringParam(params, \"text\");\n const timeoutMs = getNumberParam(params, \"timeoutMs\") ?? 5000;\n const clearBeforeTyping = getBooleanParam(params, \"clearBeforeTyping\") ?? true;\n\n if (!selector) return { success: false, text: \"Missing required parameter: selector\" };\n if (!text) return { success: false, text: \"Missing required parameter: text\" };\n\n try {\n await service.typeText(selector, text, timeoutMs, clearBeforeTyping, process);\n const response: Content = {\n text: `Typed into element: ${selector}`,\n actions: [\"COMPUTERUSE_TYPE\"],\n source: message.content?.source ?? \"action\",\n };\n await callback?.(response);\n return {\n success: true,\n text: response.text ?? \"\",\n values: { process, selector, timeoutMs, clearBeforeTyping },\n data: {\n process,\n selector,\n timeoutMs,\n clearBeforeTyping,\n backend: service.getBackendName(),\n },\n };\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logger.error(`[computeruse] type failed: ${msg}`);\n return {\n success: false,\n text: `ComputerUse type failed: ${msg}`,\n values: { process, selector, timeoutMs, clearBeforeTyping },\n data: {\n process,\n selector,\n timeoutMs,\n clearBeforeTyping,\n backend: service.getBackendName(),\n },\n };\n }\n },\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import type { Plugin } from "@elizaos/core";
2
+ import "./service-registry.js";
3
+ import { ComputerUseService } from "./services/computeruse-service.js";
4
+ export * from "./types.js";
5
+ export { ComputerUseService };
6
+ export declare const computerusePlugin: Plugin;
7
+ export default computerusePlugin;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAY9B,eAAO,MAAM,iBAAiB,EAAE,MAyB/B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ import { logger } from "@elizaos/core";
2
+ import { z } from "zod";
3
+ import "./service-registry.js";
4
+ import { computeruseClickAction } from "./actions/click.js";
5
+ import { computeruseGetApplicationsAction } from "./actions/get-applications.js";
6
+ import { computeruseGetWindowTreeAction } from "./actions/get-window-tree.js";
7
+ import { computeruseOpenApplicationAction } from "./actions/open-application.js";
8
+ import { computeruseTypeAction } from "./actions/type.js";
9
+ import { computeruseAvailableAppsProvider } from "./providers/available-apps.js";
10
+ import { computeruseStateProvider } from "./providers/computeruse-state.js";
11
+ import { ComputerUseService } from "./services/computeruse-service.js";
12
+ export * from "./types.js";
13
+ export { ComputerUseService };
14
+ const configSchema = z.object({
15
+ COMPUTERUSE_ENABLED: z
16
+ .string()
17
+ .optional()
18
+ .default("false")
19
+ .transform((val) => val === "true"),
20
+ COMPUTERUSE_MODE: z.enum(["auto", "local", "mcp"]).optional().default("auto"),
21
+ COMPUTERUSE_MCP_SERVER: z.string().optional().default("computeruse"),
22
+ });
23
+ export const computerusePlugin = {
24
+ name: "plugin-computeruse",
25
+ description: "Computer automation plugin (local or MCP)",
26
+ config: {
27
+ COMPUTERUSE_ENABLED: process.env.COMPUTERUSE_ENABLED ?? "false",
28
+ COMPUTERUSE_MODE: process.env.COMPUTERUSE_MODE ?? "auto",
29
+ COMPUTERUSE_MCP_SERVER: process.env.COMPUTERUSE_MCP_SERVER ?? "computeruse",
30
+ },
31
+ async init(config, _runtime) {
32
+ logger.info("Initializing computeruse plugin");
33
+ const validated = await configSchema.parseAsync(config);
34
+ for (const [key, value] of Object.entries(validated)) {
35
+ process.env[key] = String(value);
36
+ }
37
+ },
38
+ services: [ComputerUseService],
39
+ actions: [
40
+ computeruseOpenApplicationAction,
41
+ computeruseClickAction,
42
+ computeruseTypeAction,
43
+ computeruseGetApplicationsAction,
44
+ computeruseGetWindowTreeAction,
45
+ ],
46
+ providers: [computeruseStateProvider, computeruseAvailableAppsProvider],
47
+ dependencies: ["mcp"],
48
+ };
49
+ export default computerusePlugin;
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AA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AAC,IAAI,CAAC,MAA8B,EAAE,QAAuB;QAChE,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACxD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACrD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,QAAQ,EAAE,CAAC,kBAAkB,CAAC;IAC9B,OAAO,EAAE;QACP,gCAAgC;QAChC,sBAAsB;QACtB,qBAAqB;QACrB,gCAAgC;QAChC,8BAA8B;KAC/B;IACD,SAAS,EAAE,CAAC,wBAAwB,EAAE,gCAAgC,CAAC;IACvE,YAAY,EAAE,CAAC,KAAK,CAAC;CACtB,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import type { IAgentRuntime, Plugin } from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport { z } from \"zod\";\nimport \"./service-registry.js\";\nimport { computeruseClickAction } from \"./actions/click.js\";\nimport { computeruseGetApplicationsAction } from \"./actions/get-applications.js\";\nimport { computeruseGetWindowTreeAction } from \"./actions/get-window-tree.js\";\nimport { computeruseOpenApplicationAction } from \"./actions/open-application.js\";\nimport { computeruseTypeAction } from \"./actions/type.js\";\nimport { computeruseAvailableAppsProvider } from \"./providers/available-apps.js\";\nimport { computeruseStateProvider } from \"./providers/computeruse-state.js\";\nimport { ComputerUseService } from \"./services/computeruse-service.js\";\n\nexport * from \"./types.js\";\nexport { ComputerUseService };\n\nconst configSchema = z.object({\n COMPUTERUSE_ENABLED: z\n .string()\n .optional()\n .default(\"false\")\n .transform((val) => val === \"true\"),\n COMPUTERUSE_MODE: z.enum([\"auto\", \"local\", \"mcp\"]).optional().default(\"auto\"),\n COMPUTERUSE_MCP_SERVER: z.string().optional().default(\"computeruse\"),\n});\n\nexport const computerusePlugin: Plugin = {\n name: \"plugin-computeruse\",\n description: \"Computer automation plugin (local or MCP)\",\n config: {\n COMPUTERUSE_ENABLED: process.env.COMPUTERUSE_ENABLED ?? \"false\",\n COMPUTERUSE_MODE: process.env.COMPUTERUSE_MODE ?? \"auto\",\n COMPUTERUSE_MCP_SERVER: process.env.COMPUTERUSE_MCP_SERVER ?? \"computeruse\",\n },\n async init(config: Record<string, string>, _runtime: IAgentRuntime): Promise<void> {\n logger.info(\"Initializing computeruse plugin\");\n const validated = await configSchema.parseAsync(config);\n for (const [key, value] of Object.entries(validated)) {\n process.env[key] = String(value);\n }\n },\n services: [ComputerUseService],\n actions: [\n computeruseOpenApplicationAction,\n computeruseClickAction,\n computeruseTypeAction,\n computeruseGetApplicationsAction,\n computeruseGetWindowTreeAction,\n ],\n providers: [computeruseStateProvider, computeruseAvailableAppsProvider],\n dependencies: [\"mcp\"],\n};\n\nexport default computerusePlugin;\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Provider } from "@elizaos/core";
2
+ export declare const computeruseAvailableAppsProvider: Provider;
3
+ //# sourceMappingURL=available-apps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"available-apps.d.ts","sourceRoot":"","sources":["../../src/providers/available-apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAG5F,eAAO,MAAM,gCAAgC,EAAE,QAsB9C,CAAC"}
@@ -0,0 +1,22 @@
1
+ export const computeruseAvailableAppsProvider = {
2
+ name: "COMPUTERUSE_AVAILABLE_APPS",
3
+ description: "Lists currently running applications (best-effort, may be summarized in MCP mode)",
4
+ get: async (runtime, _message, _state) => {
5
+ const service = runtime.getService("computeruse");
6
+ if (!service || !service.isEnabled()) {
7
+ return {
8
+ text: "ComputerUse is disabled",
9
+ values: { enabled: false },
10
+ data: { enabled: false },
11
+ };
12
+ }
13
+ const apps = await service.getApplications();
14
+ const text = `Running applications (${apps.length}):\n${apps.map((a) => `- ${a}`).join("\n")}`;
15
+ return {
16
+ text,
17
+ values: { enabled: true, count: apps.length },
18
+ data: { enabled: true, apps, count: apps.length, backend: service.getBackendName() },
19
+ };
20
+ },
21
+ };
22
+ //# sourceMappingURL=available-apps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"available-apps.js","sourceRoot":"","sources":["../../src/providers/available-apps.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gCAAgC,GAAa;IACxD,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE,mFAAmF;IAChG,GAAG,EAAE,KAAK,EAAE,OAAsB,EAAE,QAAgB,EAAE,MAAa,EAA2B,EAAE;QAC9F,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAqB,aAAa,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;YACrC,OAAO;gBACL,IAAI,EAAE,yBAAyB;gBAC/B,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;gBAC1B,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;aACzB,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,yBAAyB,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAE/F,OAAO;YACL,IAAI;YACJ,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;YAC7C,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE;SACrF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { IAgentRuntime, Memory, Provider, ProviderResult, State } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\n\nexport const computeruseAvailableAppsProvider: Provider = {\n name: \"COMPUTERUSE_AVAILABLE_APPS\",\n description: \"Lists currently running applications (best-effort, may be summarized in MCP mode)\",\n get: async (runtime: IAgentRuntime, _message: Memory, _state: State): Promise<ProviderResult> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service || !service.isEnabled()) {\n return {\n text: \"ComputerUse is disabled\",\n values: { enabled: false },\n data: { enabled: false },\n };\n }\n\n const apps = await service.getApplications();\n const text = `Running applications (${apps.length}):\\n${apps.map((a) => `- ${a}`).join(\"\\n\")}`;\n\n return {\n text,\n values: { enabled: true, count: apps.length },\n data: { enabled: true, apps, count: apps.length, backend: service.getBackendName() },\n };\n },\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Provider } from "@elizaos/core";
2
+ export declare const computeruseStateProvider: Provider;
3
+ //# sourceMappingURL=computeruse-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeruse-state.d.ts","sourceRoot":"","sources":["../../src/providers/computeruse-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAG5F,eAAO,MAAM,wBAAwB,EAAE,QAmCtC,CAAC"}
@@ -0,0 +1,35 @@
1
+ export const computeruseStateProvider = {
2
+ name: "COMPUTERUSE_STATE",
3
+ description: "Provides current ComputerUse backend/mode information",
4
+ get: async (runtime, _message, _state) => {
5
+ const service = runtime.getService("computeruse");
6
+ if (!service || !service.isEnabled()) {
7
+ return {
8
+ text: "ComputerUse is disabled",
9
+ values: { enabled: false },
10
+ data: { enabled: false },
11
+ };
12
+ }
13
+ const backend = service.getBackendName();
14
+ const mode = service.getMode();
15
+ const mcpServer = service.getMcpServerName();
16
+ return {
17
+ text: `ComputerUse enabled. Mode=${mode}. Backend=${backend ?? "none"}. Platform=${process.platform}.`,
18
+ values: {
19
+ enabled: true,
20
+ mode,
21
+ backend: backend ?? "none",
22
+ platform: process.platform,
23
+ mcpServer,
24
+ },
25
+ data: {
26
+ enabled: true,
27
+ mode,
28
+ backend,
29
+ platform: process.platform,
30
+ mcpServer,
31
+ },
32
+ };
33
+ },
34
+ };
35
+ //# sourceMappingURL=computeruse-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeruse-state.js","sourceRoot":"","sources":["../../src/providers/computeruse-state.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,wBAAwB,GAAa;IAChD,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,uDAAuD;IACpE,GAAG,EAAE,KAAK,EAAE,OAAsB,EAAE,QAAgB,EAAE,MAAa,EAA2B,EAAE;QAC9F,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAqB,aAAa,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;YACrC,OAAO;gBACL,IAAI,EAAE,yBAAyB;gBAC/B,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;gBAC1B,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;aACzB,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAE7C,OAAO;YACL,IAAI,EAAE,6BAA6B,IAAI,aAAa,OAAO,IAAI,MAAM,cAAc,OAAO,CAAC,QAAQ,GAAG;YACtG,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI;gBACb,IAAI;gBACJ,OAAO,EAAE,OAAO,IAAI,MAAM;gBAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,SAAS;aACV;YACD,IAAI,EAAE;gBACJ,OAAO,EAAE,IAAI;gBACb,IAAI;gBACJ,OAAO;gBACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,SAAS;aACV;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import type { IAgentRuntime, Memory, Provider, ProviderResult, State } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\n\nexport const computeruseStateProvider: Provider = {\n name: \"COMPUTERUSE_STATE\",\n description: \"Provides current ComputerUse backend/mode information\",\n get: async (runtime: IAgentRuntime, _message: Memory, _state: State): Promise<ProviderResult> => {\n const service = runtime.getService<ComputerUseService>(\"computeruse\");\n if (!service || !service.isEnabled()) {\n return {\n text: \"ComputerUse is disabled\",\n values: { enabled: false },\n data: { enabled: false },\n };\n }\n\n const backend = service.getBackendName();\n const mode = service.getMode();\n const mcpServer = service.getMcpServerName();\n\n return {\n text: `ComputerUse enabled. Mode=${mode}. Backend=${backend ?? \"none\"}. Platform=${process.platform}.`,\n values: {\n enabled: true,\n mode,\n backend: backend ?? \"none\",\n platform: process.platform,\n mcpServer,\n },\n data: {\n enabled: true,\n mode,\n backend,\n platform: process.platform,\n mcpServer,\n },\n };\n },\n};\n"]}
@@ -0,0 +1,7 @@
1
+ declare module "@elizaos/core" {
2
+ interface ServiceTypeRegistry {
3
+ COMPUTERUSE: "computeruse";
4
+ }
5
+ }
6
+ export declare const COMPUTERUSE_SERVICE_TYPE: "computeruse";
7
+ //# sourceMappingURL=service-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-registry.d.ts","sourceRoot":"","sources":["../src/service-registry.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,eAAe,CAAC;IAC7B,UAAU,mBAAmB;QAC3B,WAAW,EAAE,aAAa,CAAC;KAC5B;CACF;AAED,eAAO,MAAM,wBAAwB,EAAG,aAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const COMPUTERUSE_SERVICE_TYPE = "computeruse";
2
+ //# sourceMappingURL=service-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-registry.js","sourceRoot":"","sources":["../src/service-registry.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,wBAAwB,GAAG,aAAsB,CAAC","sourcesContent":["// Module augmentation: add COMPUTERUSE to the core service registry so\n// `runtime.getServiceLoadPromise(\"computeruse\")` is type-safe.\ndeclare module \"@elizaos/core\" {\n interface ServiceTypeRegistry {\n COMPUTERUSE: \"computeruse\";\n }\n}\n\nexport const COMPUTERUSE_SERVICE_TYPE = \"computeruse\" as const;\n"]}
@@ -0,0 +1,31 @@
1
+ import type { IAgentRuntime } from "@elizaos/core";
2
+ import { Service } from "@elizaos/core";
3
+ import { type ComputerUseBackendName, type ComputerUseConfig } from "../types.js";
4
+ export declare class ComputerUseService extends Service {
5
+ static serviceType: string;
6
+ capabilityDescription: string;
7
+ private computeruseConfig;
8
+ private backendName;
9
+ private initialized;
10
+ private localDesktop;
11
+ constructor(runtime?: IAgentRuntime);
12
+ static start(runtime: IAgentRuntime): Promise<ComputerUseService>;
13
+ stop(): Promise<void>;
14
+ getMode(): ComputerUseConfig["COMPUTERUSE_MODE"];
15
+ getBackendName(): ComputerUseBackendName | null;
16
+ getMcpServerName(): string;
17
+ isEnabled(): boolean;
18
+ ensureReady(): Promise<void>;
19
+ private initializeBackend;
20
+ private ensureLocalBackend;
21
+ private ensureMcpBackend;
22
+ private waitForMcpService;
23
+ private getMcp;
24
+ private parseProcessScopedSelector;
25
+ openApplication(appName: string): Promise<void>;
26
+ click(selector: string, timeoutMs: number, process?: string): Promise<void>;
27
+ typeText(selector: string, text: string, timeoutMs: number, clearBeforeTyping: boolean, process?: string): Promise<void>;
28
+ getWindowTree(process: string, title?: string, maxDepth?: number): Promise<string>;
29
+ getApplications(): Promise<string[]>;
30
+ }
31
+ //# sourceMappingURL=computeruse-service.d.ts.map
@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B,EAAE,OAAO,EAC1B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IA8BV,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiClF,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAiC3C"}
@@ -0,0 +1,274 @@
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
+ const mode = this.computeruseConfig.COMPUTERUSE_MODE;
53
+ if (mode === "local") {
54
+ await this.ensureLocalBackend();
55
+ this.backendName = "local";
56
+ return;
57
+ }
58
+ if (mode === "mcp") {
59
+ await this.ensureMcpBackend();
60
+ this.backendName = "mcp";
61
+ return;
62
+ }
63
+ // auto - try local on all platforms, fall back to MCP
64
+ try {
65
+ await this.ensureLocalBackend();
66
+ this.backendName = "local";
67
+ return;
68
+ }
69
+ catch (err) {
70
+ const msg = err instanceof Error ? err.message : String(err);
71
+ logger.warn(`[computeruse] local backend unavailable, falling back to mcp: ${msg}`);
72
+ }
73
+ await this.ensureMcpBackend();
74
+ this.backendName = "mcp";
75
+ }
76
+ async ensureLocalBackend() {
77
+ if (this.localDesktop)
78
+ return;
79
+ // Import only when needed (native optional deps).
80
+ try {
81
+ const mod = await import("@elizaos/computeruse");
82
+ this.localDesktop = new mod.Desktop();
83
+ }
84
+ catch (err) {
85
+ const msg = err instanceof Error ? err.message : String(err);
86
+ const platform = process.platform;
87
+ if (platform === "darwin") {
88
+ throw new Error(`macOS native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-darwin-* is installed.`);
89
+ }
90
+ else if (platform === "linux") {
91
+ throw new Error(`Linux native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-linux-* is installed.`);
92
+ }
93
+ throw err;
94
+ }
95
+ }
96
+ async ensureMcpBackend() {
97
+ const mcp = await this.waitForMcpService();
98
+ const serverName = this.computeruseConfig.COMPUTERUSE_MCP_SERVER;
99
+ const servers = mcp.getServers();
100
+ const exists = servers.some((s) => s.name === serverName);
101
+ if (!exists) {
102
+ throw new Error(`MCP server "${serverName}" not configured. Add it under runtime/character settings "mcp.servers".`);
103
+ }
104
+ }
105
+ async waitForMcpService() {
106
+ // Services are registered during runtime initialization; depending on plugin order,
107
+ // "mcp" may not be available during another service's start hook.
108
+ for (let attempt = 0; attempt < 20; attempt++) {
109
+ const mcp = this.runtime.getService("mcp");
110
+ if (mcp)
111
+ return mcp;
112
+ await new Promise((resolve) => setTimeout(resolve, 50));
113
+ }
114
+ throw new Error("MCP service not available. Add @elizaos/plugin-mcp and configure a computeruse server.");
115
+ }
116
+ getMcp() {
117
+ const mcp = this.runtime.getService("mcp");
118
+ if (!mcp) {
119
+ throw new Error("MCP service not available");
120
+ }
121
+ return mcp;
122
+ }
123
+ parseProcessScopedSelector(rawSelector, processHint) {
124
+ const selector = rawSelector.trim();
125
+ const match = selector.match(/^\s*process:([^\s>]+)\s*(?:>>\s*(.*))?$/);
126
+ if (match) {
127
+ const process = match[1]?.trim();
128
+ const inner = (match[2] ?? "").trim();
129
+ if (!process) {
130
+ throw new Error("Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'");
131
+ }
132
+ return { process, selector: inner };
133
+ }
134
+ const process = processHint?.trim();
135
+ if (!process) {
136
+ throw new Error("Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'");
137
+ }
138
+ return { process, selector };
139
+ }
140
+ async openApplication(appName) {
141
+ await this.ensureReady();
142
+ if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
143
+ throw new Error("ComputerUse is disabled");
144
+ if (this.backendName === "local") {
145
+ await this.ensureLocalBackend();
146
+ this.localDesktop?.openApplication(appName);
147
+ return;
148
+ }
149
+ if (this.backendName === "mcp") {
150
+ const mcp = this.getMcp();
151
+ await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "open_application", {
152
+ app_name: appName,
153
+ verify_element_exists: "",
154
+ verify_element_not_exists: "",
155
+ include_tree_after_action: false,
156
+ });
157
+ return;
158
+ }
159
+ throw new Error("ComputerUse backend not initialized");
160
+ }
161
+ async click(selector, timeoutMs, process) {
162
+ await this.ensureReady();
163
+ if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
164
+ throw new Error("ComputerUse is disabled");
165
+ if (this.backendName === "local") {
166
+ await this.ensureLocalBackend();
167
+ const el = await this.localDesktop?.locator(selector).first(timeoutMs);
168
+ if (!el)
169
+ throw new Error(`Element not found: ${selector}`);
170
+ await el.click();
171
+ return;
172
+ }
173
+ if (this.backendName === "mcp") {
174
+ const mcp = this.getMcp();
175
+ const parsed = this.parseProcessScopedSelector(selector, process);
176
+ await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "click_element", {
177
+ process: parsed.process,
178
+ selector: parsed.selector,
179
+ timeout_ms: timeoutMs,
180
+ verify_element_exists: "",
181
+ verify_element_not_exists: "",
182
+ highlight_before_action: false,
183
+ ui_diff_before_after: false,
184
+ });
185
+ return;
186
+ }
187
+ throw new Error("ComputerUse backend not initialized");
188
+ }
189
+ async typeText(selector, text, timeoutMs, clearBeforeTyping, process) {
190
+ await this.ensureReady();
191
+ if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
192
+ throw new Error("ComputerUse is disabled");
193
+ if (this.backendName === "local") {
194
+ await this.ensureLocalBackend();
195
+ const el = await this.localDesktop?.locator(selector).first(timeoutMs);
196
+ if (!el)
197
+ throw new Error(`Element not found: ${selector}`);
198
+ el.typeText(text, { clearBeforeTyping });
199
+ return;
200
+ }
201
+ if (this.backendName === "mcp") {
202
+ const mcp = this.getMcp();
203
+ const parsed = this.parseProcessScopedSelector(selector, process);
204
+ await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "type_into_element", {
205
+ process: parsed.process,
206
+ selector: parsed.selector,
207
+ text_to_type: text,
208
+ timeout_ms: timeoutMs,
209
+ clear_before_typing: clearBeforeTyping,
210
+ highlight_before_action: false,
211
+ ui_diff_before_after: false,
212
+ });
213
+ return;
214
+ }
215
+ throw new Error("ComputerUse backend not initialized");
216
+ }
217
+ async getWindowTree(process, title, maxDepth) {
218
+ await this.ensureReady();
219
+ if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
220
+ throw new Error("ComputerUse is disabled");
221
+ if (this.backendName === "local") {
222
+ await this.ensureLocalBackend();
223
+ const tree = this.localDesktop?.getWindowTree(process, title, undefined);
224
+ return JSON.stringify(tree ?? null, null, 2);
225
+ }
226
+ if (this.backendName === "mcp") {
227
+ const mcp = this.getMcp();
228
+ const toolArgs = {
229
+ process,
230
+ include_tree_after_action: true,
231
+ };
232
+ if (title !== undefined)
233
+ toolArgs.title = title;
234
+ if (maxDepth !== undefined)
235
+ toolArgs.tree_max_depth = maxDepth;
236
+ const res = await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "get_window_tree", toolArgs);
237
+ const texts = res.content
238
+ .filter((c) => c.type === "text")
239
+ .map((c) => c.text)
240
+ .filter((t) => typeof t === "string");
241
+ return texts.join("\n");
242
+ }
243
+ throw new Error("ComputerUse backend not initialized");
244
+ }
245
+ async getApplications() {
246
+ await this.ensureReady();
247
+ if (!this.computeruseConfig.COMPUTERUSE_ENABLED)
248
+ throw new Error("ComputerUse is disabled");
249
+ if (this.backendName === "local") {
250
+ await this.ensureLocalBackend();
251
+ const apps = this.localDesktop?.applications() ?? [];
252
+ // Normalize into human-readable names.
253
+ const names = [];
254
+ for (const app of apps) {
255
+ const n = app.name();
256
+ if (typeof n === "string" && n.trim().length > 0)
257
+ names.push(n);
258
+ }
259
+ return names;
260
+ }
261
+ if (this.backendName === "mcp") {
262
+ const mcp = this.getMcp();
263
+ const res = await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, "get_applications_and_windows_list", {});
264
+ // Return text-only summary for now; structured parsing is done in actions/providers if needed.
265
+ const texts = res.content
266
+ .filter((c) => c.type === "text")
267
+ .map((c) => c.text)
268
+ .filter((t) => typeof t === "string");
269
+ return texts.length > 0 ? texts : ["(see MCP tool output)"];
270
+ }
271
+ throw new Error("ComputerUse backend not initialized");
272
+ }
273
+ }
274
+ //# sourceMappingURL=computeruse-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC","sourcesContent":["import type { IAgentRuntime } from \"@elizaos/core\";\nimport { logger, Service } from \"@elizaos/core\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n type ComputerUseBackendName,\n type ComputerUseConfig,\n computerUseConfigSchema,\n type 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 callTool(\n serverName: string,\n toolName: string,\n toolArguments?: Readonly<JsonObject>\n ): Promise<CallToolResult>;\n getServers(): ReadonlyArray<{ name: string; status: string }>;\n}\n\nexport class ComputerUseService extends Service {\n static serviceType = \"computeruse\";\n capabilityDescription =\n \"Enables the agent to control a computer UI locally (when supported) or via a ComputerUse MCP server\";\n\n private computeruseConfig: ComputerUseConfig;\n private backendName: ComputerUseBackendName | null = null;\n private initialized = false;\n\n // Lazy-loaded to avoid importing native bindings unless actually used.\n private localDesktop: import(\"@elizaos/computeruse\").Desktop | null = null;\n\n constructor(runtime?: IAgentRuntime) {\n super(runtime);\n this.computeruseConfig = computerUseConfigSchema.parse({\n COMPUTERUSE_ENABLED: String(process.env.COMPUTERUSE_ENABLED ?? \"false\"),\n COMPUTERUSE_MODE: String(process.env.COMPUTERUSE_MODE ?? \"auto\"),\n COMPUTERUSE_MCP_SERVER: String(process.env.COMPUTERUSE_MCP_SERVER ?? \"computeruse\"),\n });\n }\n\n static async start(runtime: IAgentRuntime): Promise<ComputerUseService> {\n const service = new ComputerUseService(runtime);\n return service;\n }\n\n async stop(): Promise<void> {\n this.localDesktop = null;\n this.backendName = null;\n this.initialized = false;\n }\n\n getMode(): ComputerUseConfig[\"COMPUTERUSE_MODE\"] {\n return this.computeruseConfig.COMPUTERUSE_MODE;\n }\n\n getBackendName(): ComputerUseBackendName | null {\n return this.backendName;\n }\n\n getMcpServerName(): string {\n return this.computeruseConfig.COMPUTERUSE_MCP_SERVER;\n }\n\n isEnabled(): boolean {\n return this.computeruseConfig.COMPUTERUSE_ENABLED;\n }\n\n async ensureReady(): Promise<void> {\n if (this.initialized) return;\n this.initialized = true;\n await this.initializeBackend();\n }\n\n private async initializeBackend(): Promise<void> {\n if (!this.computeruseConfig.COMPUTERUSE_ENABLED) {\n logger.info(\"[computeruse] disabled (COMPUTERUSE_ENABLED=false)\");\n this.backendName = null;\n return;\n }\n\n const mode = this.computeruseConfig.COMPUTERUSE_MODE;\n if (mode === \"local\") {\n await this.ensureLocalBackend();\n this.backendName = \"local\";\n return;\n }\n if (mode === \"mcp\") {\n await this.ensureMcpBackend();\n this.backendName = \"mcp\";\n return;\n }\n\n // auto - try local on all platforms, fall back to MCP\n try {\n await this.ensureLocalBackend();\n this.backendName = \"local\";\n return;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logger.warn(`[computeruse] local backend unavailable, falling back to mcp: ${msg}`);\n }\n\n await this.ensureMcpBackend();\n this.backendName = \"mcp\";\n }\n\n private async ensureLocalBackend(): Promise<void> {\n if (this.localDesktop) return;\n\n // Import only when needed (native optional deps).\n try {\n const mod = await import(\"@elizaos/computeruse\");\n this.localDesktop = new mod.Desktop();\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n const platform = process.platform;\n if (platform === \"darwin\") {\n throw new Error(\n `macOS native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-darwin-* is installed.`\n );\n } else if (platform === \"linux\") {\n throw new Error(\n `Linux native bindings not available: ${msg}. Use MCP mode or ensure @elizaos/computeruse-linux-* is installed.`\n );\n }\n throw err;\n }\n }\n\n private async ensureMcpBackend(): Promise<void> {\n const mcp = await this.waitForMcpService();\n\n const serverName = this.computeruseConfig.COMPUTERUSE_MCP_SERVER;\n const servers = mcp.getServers();\n const exists = servers.some((s) => s.name === serverName);\n if (!exists) {\n throw new Error(\n `MCP server \"${serverName}\" not configured. Add it under runtime/character settings \"mcp.servers\".`\n );\n }\n }\n\n private async waitForMcpService(): Promise<McpServiceLike> {\n // Services are registered during runtime initialization; depending on plugin order,\n // \"mcp\" may not be available during another service's start hook.\n for (let attempt = 0; attempt < 20; attempt++) {\n const mcp = this.runtime.getService<McpServiceLike>(\"mcp\");\n if (mcp) return mcp;\n await new Promise<void>((resolve) => setTimeout(resolve, 50));\n }\n throw new Error(\n \"MCP service not available. Add @elizaos/plugin-mcp and configure a computeruse server.\"\n );\n }\n\n private getMcp(): McpServiceLike {\n const mcp = this.runtime.getService<McpServiceLike>(\"mcp\");\n if (!mcp) {\n throw new Error(\"MCP service not available\");\n }\n return mcp;\n }\n\n private parseProcessScopedSelector(\n rawSelector: string,\n processHint?: string\n ): { process: string; selector: string } {\n const selector = rawSelector.trim();\n const match = selector.match(/^\\s*process:([^\\s>]+)\\s*(?:>>\\s*(.*))?$/);\n if (match) {\n const process = match[1]?.trim();\n const inner = (match[2] ?? \"\").trim();\n if (!process) {\n throw new Error(\n \"Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'\"\n );\n }\n return { process, selector: inner };\n }\n\n const process = processHint?.trim();\n if (!process) {\n throw new Error(\n \"Missing process. Provide parameters.process or prefix selector with 'process:<name> >> ...'\"\n );\n }\n return { process, selector };\n }\n\n async openApplication(appName: string): Promise<void> {\n await this.ensureReady();\n if (!this.computeruseConfig.COMPUTERUSE_ENABLED) throw new Error(\"ComputerUse is disabled\");\n\n if (this.backendName === \"local\") {\n await this.ensureLocalBackend();\n this.localDesktop?.openApplication(appName);\n return;\n }\n\n if (this.backendName === \"mcp\") {\n const mcp = this.getMcp();\n await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, \"open_application\", {\n app_name: appName,\n verify_element_exists: \"\",\n verify_element_not_exists: \"\",\n include_tree_after_action: false,\n });\n return;\n }\n\n throw new Error(\"ComputerUse backend not initialized\");\n }\n\n async click(selector: string, timeoutMs: number, process?: string): Promise<void> {\n await this.ensureReady();\n if (!this.computeruseConfig.COMPUTERUSE_ENABLED) throw new Error(\"ComputerUse is disabled\");\n\n if (this.backendName === \"local\") {\n await this.ensureLocalBackend();\n const el = await this.localDesktop?.locator(selector).first(timeoutMs);\n if (!el) throw new Error(`Element not found: ${selector}`);\n await el.click();\n return;\n }\n\n if (this.backendName === \"mcp\") {\n const mcp = this.getMcp();\n const parsed = this.parseProcessScopedSelector(selector, process);\n await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, \"click_element\", {\n process: parsed.process,\n selector: parsed.selector,\n timeout_ms: timeoutMs,\n verify_element_exists: \"\",\n verify_element_not_exists: \"\",\n highlight_before_action: false,\n ui_diff_before_after: false,\n });\n return;\n }\n\n throw new Error(\"ComputerUse backend not initialized\");\n }\n\n async typeText(\n selector: string,\n text: string,\n timeoutMs: number,\n clearBeforeTyping: boolean,\n process?: string\n ): Promise<void> {\n await this.ensureReady();\n if (!this.computeruseConfig.COMPUTERUSE_ENABLED) throw new Error(\"ComputerUse is disabled\");\n\n if (this.backendName === \"local\") {\n await this.ensureLocalBackend();\n const el = await this.localDesktop?.locator(selector).first(timeoutMs);\n if (!el) throw new Error(`Element not found: ${selector}`);\n el.typeText(text, { clearBeforeTyping });\n return;\n }\n\n if (this.backendName === \"mcp\") {\n const mcp = this.getMcp();\n const parsed = this.parseProcessScopedSelector(selector, process);\n await mcp.callTool(this.computeruseConfig.COMPUTERUSE_MCP_SERVER, \"type_into_element\", {\n process: parsed.process,\n selector: parsed.selector,\n text_to_type: text,\n timeout_ms: timeoutMs,\n clear_before_typing: clearBeforeTyping,\n highlight_before_action: false,\n ui_diff_before_after: false,\n });\n return;\n }\n\n throw new Error(\"ComputerUse backend not initialized\");\n }\n\n async getWindowTree(process: string, title?: string, maxDepth?: number): Promise<string> {\n await this.ensureReady();\n if (!this.computeruseConfig.COMPUTERUSE_ENABLED) throw new Error(\"ComputerUse is disabled\");\n\n if (this.backendName === \"local\") {\n await this.ensureLocalBackend();\n const tree = this.localDesktop?.getWindowTree(process, title, undefined);\n return JSON.stringify(tree ?? null, null, 2);\n }\n\n if (this.backendName === \"mcp\") {\n const mcp = this.getMcp();\n const toolArgs: JsonObject = {\n process,\n include_tree_after_action: true,\n };\n if (title !== undefined) toolArgs.title = title;\n if (maxDepth !== undefined) toolArgs.tree_max_depth = maxDepth;\n const res = await mcp.callTool(\n this.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n \"get_window_tree\",\n toolArgs\n );\n const texts = res.content\n .filter((c) => c.type === \"text\")\n .map((c) => c.text)\n .filter((t) => typeof t === \"string\");\n return texts.join(\"\\n\");\n }\n\n throw new Error(\"ComputerUse backend not initialized\");\n }\n\n async getApplications(): Promise<string[]> {\n await this.ensureReady();\n if (!this.computeruseConfig.COMPUTERUSE_ENABLED) throw new Error(\"ComputerUse is disabled\");\n\n if (this.backendName === \"local\") {\n await this.ensureLocalBackend();\n const apps = this.localDesktop?.applications() ?? [];\n // Normalize into human-readable names.\n const names: string[] = [];\n for (const app of apps) {\n const n = app.name();\n if (typeof n === \"string\" && n.trim().length > 0) names.push(n);\n }\n return names;\n }\n\n if (this.backendName === \"mcp\") {\n const mcp = this.getMcp();\n const res = await mcp.callTool(\n this.computeruseConfig.COMPUTERUSE_MCP_SERVER,\n \"get_applications_and_windows_list\",\n {}\n );\n // Return text-only summary for now; structured parsing is done in actions/providers if needed.\n const texts = res.content\n .filter((c) => c.type === \"text\")\n .map((c) => c.text)\n .filter((t) => typeof t === \"string\");\n return texts.length > 0 ? texts : [\"(see MCP tool output)\"];\n }\n\n throw new Error(\"ComputerUse backend not initialized\");\n }\n}\n"]}
@@ -0,0 +1,41 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AACnF,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvD,eAAO,MAAM,uBAAuB;;;;;;;;iBAQlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,KAAK,CAAC;AAErD,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B"}
package/dist/types.js ADDED
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,mBAAmB,EAAE,CAAC;SACnB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,OAAO,CAAC;SAChB,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC;IACrC,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;CACrE,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type ComputerUseMode = \"auto\" | \"local\" | \"mcp\";\n\nexport const computerUseConfigSchema = z.object({\n COMPUTERUSE_ENABLED: z\n .string()\n .optional()\n .default(\"false\")\n .transform((val) => val === \"true\"),\n COMPUTERUSE_MODE: z.enum([\"auto\", \"local\", \"mcp\"]).optional().default(\"auto\"),\n COMPUTERUSE_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 readonly name: string;\n}\n\nexport interface ComputerUseClickInput {\n readonly process?: string;\n readonly selector: string;\n readonly timeoutMs: number;\n}\n\nexport interface ComputerUseTypeInput {\n readonly process?: string;\n readonly selector: string;\n readonly text: string;\n readonly timeoutMs: number;\n readonly clearBeforeTyping: boolean;\n}\n\nexport interface ComputerUseGetWindowTreeInput {\n readonly process: string;\n readonly title?: string;\n readonly maxDepth?: number;\n}\n"]}
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
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,CAC5B,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAGpB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAGpB;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,GACX,OAAO,GAAG,SAAS,CAGrB"}
@@ -0,0 +1,13 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.js","sourceRoot":"","sources":["../../src/utils/params.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAC5B,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;AACnD,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,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;AACnD,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,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;AACpD,CAAC","sourcesContent":["import type { ActionParameters } from \"@elizaos/core\";\n\nexport function getStringParam(\n params: ActionParameters | undefined,\n name: string\n): string | undefined {\n const val = params?.[name];\n return typeof val === \"string\" ? val : undefined;\n}\n\nexport function getNumberParam(\n params: ActionParameters | undefined,\n name: string\n): number | undefined {\n const val = params?.[name];\n return typeof val === \"number\" ? val : undefined;\n}\n\nexport function getBooleanParam(\n params: ActionParameters | undefined,\n name: string\n): boolean | undefined {\n const val = params?.[name];\n return typeof val === \"boolean\" ? val : undefined;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@elizaos/plugin-computeruse",
3
+ "description": "Computer automation plugin for ElizaOS - enables AI agents to control the local machine (when supported) or a remote ComputerUse MCP server",
4
+ "version": "2.0.0-alpha.1",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "packageType": "plugin",
10
+ "platform": "node",
11
+ "license": "MIT",
12
+ "keywords": ["plugin", "elizaos", "computeruse", "automation", "desktop", "gui", "mcp"],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/elizaos/eliza"
16
+ },
17
+ "homepage": "https://elizaos.ai",
18
+ "exports": {
19
+ "./package.json": "./package.json",
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
25
+ }
26
+ },
27
+ "files": ["dist", "README.md", "package.json"],
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "^1.21.0",
30
+ "zod": "^4.3.5"
31
+ },
32
+ "peerDependencies": {
33
+ "@elizaos/core": "workspace:*",
34
+ "@elizaos/computeruse": "workspace:*"
35
+ },
36
+ "devDependencies": {
37
+ "@elizaos/plugin-eliza-classic": "workspace:*",
38
+ "@elizaos/plugin-inmemorydb": "workspace:*",
39
+ "@elizaos/plugin-mcp": "workspace:*",
40
+ "typescript": "^5.9.3",
41
+ "@biomejs/biome": "^2.3.11",
42
+ "vitest": "^4.0.17"
43
+ },
44
+ "scripts": {
45
+ "dev": "bun --hot build.ts",
46
+ "test": "vitest run || echo 'TypeScript tests skipped - no tests found'",
47
+ "lint": "bunx @biomejs/biome check --write --unsafe .",
48
+ "typecheck": "tsc --noEmit",
49
+ "clean": "rm -rf dist .turbo",
50
+ "lint:check": "bunx @biomejs/biome check .",
51
+ "build": "bun run build.ts",
52
+ "build:ts": "bun run build.ts"
53
+ },
54
+ "agentConfig": {
55
+ "pluginType": "elizaos:plugin:1.0.0",
56
+ "pluginParameters": {
57
+ "COMPUTERUSE_ENABLED": {
58
+ "type": "boolean",
59
+ "description": "Enable ComputerUse actions/providers (default: false)",
60
+ "required": false
61
+ },
62
+ "COMPUTERUSE_MODE": {
63
+ "type": "string",
64
+ "description": "Execution mode: auto | local | mcp (default: auto)",
65
+ "required": false
66
+ },
67
+ "COMPUTERUSE_MCP_SERVER": {
68
+ "type": "string",
69
+ "description": "MCP server name to use for remote control (default: computeruse)",
70
+ "required": false
71
+ }
72
+ }
73
+ },
74
+ "publishConfig": {
75
+ "access": "public"
76
+ }
77
+ }