@elizaos/plugin-computeruse 2.0.0-alpha.9 → 2.0.0-beta.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.
- package/dist/actions/desktop-handlers.d.ts +20 -0
- package/dist/actions/desktop-handlers.d.ts.map +1 -0
- package/dist/actions/desktop.d.ts +11 -0
- package/dist/actions/desktop.d.ts.map +1 -0
- package/dist/actions/helpers.d.ts +33 -0
- package/dist/actions/helpers.d.ts.map +1 -0
- package/dist/actions/use-computer.d.ts +3 -0
- package/dist/actions/use-computer.d.ts.map +1 -0
- package/dist/approval-manager.d.ts +29 -0
- package/dist/approval-manager.d.ts.map +1 -0
- package/dist/index.d.ts +30 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7125 -59
- package/dist/index.js.map +34 -1
- package/dist/osworld/action-converter.d.ts +35 -0
- package/dist/osworld/action-converter.d.ts.map +1 -0
- package/dist/osworld/adapter.d.ts +78 -0
- package/dist/osworld/adapter.d.ts.map +1 -0
- package/dist/osworld/types.d.ts +69 -0
- package/dist/osworld/types.d.ts.map +1 -0
- package/dist/platform/a11y.d.ts +36 -0
- package/dist/platform/a11y.d.ts.map +1 -0
- package/dist/platform/browser.d.ts +61 -0
- package/dist/platform/browser.d.ts.map +1 -0
- package/dist/platform/capabilities.d.ts +10 -0
- package/dist/platform/capabilities.d.ts.map +1 -0
- package/dist/platform/desktop.d.ts +33 -0
- package/dist/platform/desktop.d.ts.map +1 -0
- package/dist/platform/driver.d.ts +27 -0
- package/dist/platform/driver.d.ts.map +1 -0
- package/dist/platform/file-ops.d.ts +10 -0
- package/dist/platform/file-ops.d.ts.map +1 -0
- package/dist/platform/helpers.d.ts +61 -0
- package/dist/platform/helpers.d.ts.map +1 -0
- package/dist/platform/nut-driver.d.ts +19 -0
- package/dist/platform/nut-driver.d.ts.map +1 -0
- package/dist/platform/permissions.d.ts +21 -0
- package/dist/platform/permissions.d.ts.map +1 -0
- package/dist/platform/screenshot.d.ts +16 -0
- package/dist/platform/screenshot.d.ts.map +1 -0
- package/dist/platform/security.d.ts +12 -0
- package/dist/platform/security.d.ts.map +1 -0
- package/dist/platform/terminal.d.ts +38 -0
- package/dist/platform/terminal.d.ts.map +1 -0
- package/dist/platform/windows-list.d.ts +36 -0
- package/dist/platform/windows-list.d.ts.map +1 -0
- package/dist/providers/computer-state.d.ts +9 -0
- package/dist/providers/computer-state.d.ts.map +1 -0
- package/dist/register-routes.d.ts +2 -0
- package/dist/register-routes.d.ts.map +1 -0
- package/dist/register-routes.js +7111 -0
- package/dist/register-routes.js.map +34 -0
- package/dist/routes/computer-use-compat-routes.d.ts +29 -0
- package/dist/routes/computer-use-compat-routes.d.ts.map +1 -0
- package/dist/routes/computer-use-routes.d.ts +3 -0
- package/dist/routes/computer-use-routes.d.ts.map +1 -0
- package/dist/routes/sandbox-routes.d.ts +53 -0
- package/dist/routes/sandbox-routes.d.ts.map +1 -0
- package/dist/services/computer-use-service.d.ts +66 -0
- package/dist/services/computer-use-service.d.ts.map +1 -0
- package/dist/services/desktop-control.d.ts +35 -0
- package/dist/services/desktop-control.d.ts.map +1 -0
- package/dist/types.d.ts +273 -39
- package/dist/types.d.ts.map +1 -1
- package/package.json +100 -103
- package/dist/actions/click-coordinates.d.ts +0 -3
- package/dist/actions/click-coordinates.d.ts.map +0 -1
- package/dist/actions/click-coordinates.js +0 -139
- package/dist/actions/click-coordinates.js.map +0 -1
- package/dist/actions/click.d.ts +0 -3
- package/dist/actions/click.d.ts.map +0 -1
- package/dist/actions/click.js +0 -144
- package/dist/actions/click.js.map +0 -1
- package/dist/actions/drag.d.ts +0 -3
- package/dist/actions/drag.d.ts.map +0 -1
- package/dist/actions/drag.js +0 -145
- package/dist/actions/drag.js.map +0 -1
- package/dist/actions/get-applications.d.ts +0 -3
- package/dist/actions/get-applications.d.ts.map +0 -1
- package/dist/actions/get-applications.js +0 -105
- package/dist/actions/get-applications.js.map +0 -1
- package/dist/actions/get-window-tree.d.ts +0 -3
- package/dist/actions/get-window-tree.d.ts.map +0 -1
- package/dist/actions/get-window-tree.js +0 -133
- package/dist/actions/get-window-tree.js.map +0 -1
- package/dist/actions/open-application.d.ts +0 -3
- package/dist/actions/open-application.d.ts.map +0 -1
- package/dist/actions/open-application.js +0 -117
- package/dist/actions/open-application.js.map +0 -1
- package/dist/actions/press-key.d.ts +0 -3
- package/dist/actions/press-key.d.ts.map +0 -1
- package/dist/actions/press-key.js +0 -115
- package/dist/actions/press-key.js.map +0 -1
- package/dist/actions/screenshot.d.ts +0 -3
- package/dist/actions/screenshot.d.ts.map +0 -1
- package/dist/actions/screenshot.js +0 -99
- package/dist/actions/screenshot.js.map +0 -1
- package/dist/actions/scroll.d.ts +0 -3
- package/dist/actions/scroll.d.ts.map +0 -1
- package/dist/actions/scroll.js +0 -137
- package/dist/actions/scroll.js.map +0 -1
- package/dist/actions/type.d.ts +0 -3
- package/dist/actions/type.d.ts.map +0 -1
- package/dist/actions/type.js +0 -163
- package/dist/actions/type.js.map +0 -1
- package/dist/providers/available-apps.d.ts +0 -3
- package/dist/providers/available-apps.d.ts.map +0 -1
- package/dist/providers/available-apps.js +0 -28
- package/dist/providers/available-apps.js.map +0 -1
- package/dist/providers/computeruse-state.d.ts +0 -3
- package/dist/providers/computeruse-state.d.ts.map +0 -1
- package/dist/providers/computeruse-state.js +0 -36
- package/dist/providers/computeruse-state.js.map +0 -1
- package/dist/service-registry.d.ts +0 -7
- package/dist/service-registry.d.ts.map +0 -1
- package/dist/service-registry.js +0 -2
- package/dist/service-registry.js.map +0 -1
- package/dist/services/computeruse-service.d.ts +0 -36
- package/dist/services/computeruse-service.d.ts.map +0 -1
- package/dist/services/computeruse-service.js +0 -391
- package/dist/services/computeruse-service.js.map +0 -1
- package/dist/types.js +0 -11
- package/dist/types.js.map +0 -1
- package/dist/utils/params.d.ts +0 -5
- package/dist/utils/params.d.ts.map +0 -1
- package/dist/utils/params.js +0 -13
- package/dist/utils/params.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"press-key.d.ts","sourceRoot":"","sources":["../../src/actions/press-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EAQN,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,yBAAyB,EAAE,MA6JvC,CAAC"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { logger } from "@elizaos/core";
|
|
2
|
-
import { getStringParam } from "../utils/params.js";
|
|
3
|
-
export const computerusePressKeyAction = {
|
|
4
|
-
name: "COMPUTERUSE_PRESS_KEY",
|
|
5
|
-
description: "Press a keyboard key or key combination (hotkey). Use for shortcuts, Enter, Tab, etc.",
|
|
6
|
-
similes: ["PRESS_KEY", "HOTKEY", "KEY_PRESS", "KEYBOARD_SHORTCUT"],
|
|
7
|
-
parameters: [
|
|
8
|
-
{
|
|
9
|
-
name: "keys",
|
|
10
|
-
description: "Key or key combination to press. Examples: 'enter', 'ctrl+c', 'alt+tab', 'ctrl+shift+s'",
|
|
11
|
-
required: true,
|
|
12
|
-
schema: { type: "string" },
|
|
13
|
-
examples: ["enter", "ctrl+c", "alt+tab", "tab", "escape"],
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
validate: async (runtime, message, state, options) => {
|
|
17
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
18
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
19
|
-
const __avKeywords = ["computeruse", "press", "key"];
|
|
20
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
21
|
-
__avKeywords.some((word) => word.length > 0 && __avText.includes(word));
|
|
22
|
-
const __avRegex = /\b(?:computeruse|press|key)\b/i;
|
|
23
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
24
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
25
|
-
const __avExpectedSource = "";
|
|
26
|
-
const __avSourceOk = __avExpectedSource
|
|
27
|
-
? __avSource === __avExpectedSource
|
|
28
|
-
: Boolean(__avSource ||
|
|
29
|
-
state ||
|
|
30
|
-
runtime?.agentId ||
|
|
31
|
-
runtime?.getService ||
|
|
32
|
-
runtime?.getSetting);
|
|
33
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
34
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
35
|
-
Object.keys(__avOptions).length > 0 ||
|
|
36
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
37
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const __avLegacyValidate = async (runtime, message, state, options) => {
|
|
41
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
42
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
43
|
-
const __avKeywords = ["computeruse", "press", "key"];
|
|
44
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
45
|
-
__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
46
|
-
const __avRegex = /\b(?:computeruse|press|key)\b/i;
|
|
47
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
48
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
49
|
-
const __avExpectedSource = "";
|
|
50
|
-
const __avSourceOk = __avExpectedSource
|
|
51
|
-
? __avSource === __avExpectedSource
|
|
52
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
53
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
54
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
55
|
-
Object.keys(__avOptions).length > 0 ||
|
|
56
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
57
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const __avLegacyValidate = async (runtime, _message) => {
|
|
61
|
-
const service = runtime.getService("computeruse");
|
|
62
|
-
return !!service && service.isEnabled();
|
|
63
|
-
};
|
|
64
|
-
try {
|
|
65
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
try {
|
|
72
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
handler: async (runtime, message, _state, options, callback) => {
|
|
79
|
-
const service = runtime.getService("computeruse");
|
|
80
|
-
if (!service) {
|
|
81
|
-
return { success: false, text: "ComputerUse service not available" };
|
|
82
|
-
}
|
|
83
|
-
const params = options?.parameters;
|
|
84
|
-
const keys = getStringParam(params, "keys");
|
|
85
|
-
if (!keys) {
|
|
86
|
-
return { success: false, text: "Missing required parameter: keys" };
|
|
87
|
-
}
|
|
88
|
-
const backend = service.getBackendName();
|
|
89
|
-
try {
|
|
90
|
-
await service.pressKey(keys);
|
|
91
|
-
const response = {
|
|
92
|
-
text: `Pressed key: ${keys}`,
|
|
93
|
-
actions: ["COMPUTERUSE_PRESS_KEY"],
|
|
94
|
-
source: message.content?.source ?? "action",
|
|
95
|
-
};
|
|
96
|
-
await callback?.(response);
|
|
97
|
-
return {
|
|
98
|
-
success: true,
|
|
99
|
-
text: response.text ?? "",
|
|
100
|
-
values: { keys },
|
|
101
|
-
data: { keys, backend },
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
106
|
-
logger.error(`[computeruse] press_key failed: ${msg}`);
|
|
107
|
-
return {
|
|
108
|
-
success: false,
|
|
109
|
-
text: `ComputerUse press key failed: ${msg}`,
|
|
110
|
-
values: { keys },
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
//# sourceMappingURL=press-key.js.map
|
|
@@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AC5B,OAAO,EAAE,CAAC,uBAAuB,CAAC;gBAClC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,QAAQ;aAC3C,CAAC;YACF,MAAM,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;YAC3B,OAAO;gBACN,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;aACvB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,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,mCAAmC,GAAG,EAAE,CAAC,CAAC;YACvD,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,iCAAiC,GAAG,EAAE;gBAC5C,MAAM,EAAE,EAAE,IAAI,EAAE;aAChB,CAAC;QACH,CAAC;IACF,CAAC;CACD,CAAC","sourcesContent":["import type {\n\tAction,\n\tActionResult,\n\tContent,\n\tHandlerCallback,\n\tHandlerOptions,\n\tIAgentRuntime,\n\tMemory,\n\tState,\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 computerusePressKeyAction: Action = {\n\tname: \"COMPUTERUSE_PRESS_KEY\",\n\tdescription:\n\t\t\"Press a keyboard key or key combination (hotkey). Use for shortcuts, Enter, Tab, etc.\",\n\tsimiles: [\"PRESS_KEY\", \"HOTKEY\", \"KEY_PRESS\", \"KEYBOARD_SHORTCUT\"],\n\tparameters: [\n\t\t{\n\t\t\tname: \"keys\",\n\t\t\tdescription:\n\t\t\t\t\"Key or key combination to press. Examples: 'enter', 'ctrl+c', 'alt+tab', 'ctrl+shift+s'\",\n\t\t\trequired: true,\n\t\t\tschema: { type: \"string\" },\n\t\t\texamples: [\"enter\", \"ctrl+c\", \"alt+tab\", \"tab\", \"escape\"],\n\t\t},\n\t],\n\n\tvalidate: async (\n\t\truntime: any,\n\t\tmessage: any,\n\t\tstate?: any,\n\t\toptions?: any,\n\t): Promise<boolean> => {\n\t\tconst __avTextRaw =\n\t\t\ttypeof message?.content?.text === \"string\" ? message.content.text : \"\";\n\t\tconst __avText = __avTextRaw.toLowerCase();\n\t\tconst __avKeywords = [\"computeruse\", \"press\", \"key\"];\n\t\tconst __avKeywordOk =\n\t\t\t__avKeywords.length > 0 &&\n\t\t\t__avKeywords.some((word) => word.length > 0 && __avText.includes(word));\n\t\tconst __avRegex = /\\b(?:computeruse|press|key)\\b/i;\n\t\tconst __avRegexOk = __avRegex.test(__avText);\n\t\tconst __avSource = String(\n\t\t\tmessage?.content?.source ?? message?.source ?? \"\",\n\t\t);\n\t\tconst __avExpectedSource = \"\";\n\t\tconst __avSourceOk = __avExpectedSource\n\t\t\t? __avSource === __avExpectedSource\n\t\t\t: Boolean(\n\t\t\t\t\t__avSource ||\n\t\t\t\t\t\tstate ||\n\t\t\t\t\t\truntime?.agentId ||\n\t\t\t\t\t\truntime?.getService ||\n\t\t\t\t\t\truntime?.getSetting,\n\t\t\t\t);\n\t\tconst __avOptions = options && typeof options === \"object\" ? options : {};\n\t\tconst __avInputOk =\n\t\t\t__avText.trim().length > 0 ||\n\t\t\tObject.keys(__avOptions as Record<string, unknown>).length > 0 ||\n\t\t\tBoolean(message?.content && typeof message.content === \"object\");\n\n\t\tif (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst __avLegacyValidate = async (\n\t\t\truntime: any,\n\t\t\tmessage: any,\n\t\t\tstate?: any,\n\t\t\toptions?: any,\n\t\t): Promise<boolean> => {\n\t\t\tconst __avTextRaw =\n\t\t\t\ttypeof message?.content?.text === \"string\" ? message.content.text : \"\";\n\t\t\tconst __avText = __avTextRaw.toLowerCase();\n\t\t\tconst __avKeywords = [\"computeruse\", \"press\", \"key\"];\n\t\t\tconst __avKeywordOk =\n\t\t\t\t__avKeywords.length > 0 &&\n\t\t\t\t__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));\n\t\t\tconst __avRegex = /\\b(?:computeruse|press|key)\\b/i;\n\t\t\tconst __avRegexOk = __avRegex.test(__avText);\n\t\t\tconst __avSource = String(\n\t\t\t\tmessage?.content?.source ?? message?.source ?? \"\",\n\t\t\t);\n\t\t\tconst __avExpectedSource = \"\";\n\t\t\tconst __avSourceOk = __avExpectedSource\n\t\t\t\t? __avSource === __avExpectedSource\n\t\t\t\t: Boolean(\n\t\t\t\t\t\t__avSource || state || runtime?.agentId || runtime?.getService,\n\t\t\t\t\t);\n\t\t\tconst __avOptions = options && typeof options === \"object\" ? options : {};\n\t\t\tconst __avInputOk =\n\t\t\t\t__avText.trim().length > 0 ||\n\t\t\t\tObject.keys(__avOptions as Record<string, unknown>).length > 0 ||\n\t\t\t\tBoolean(message?.content && typeof message.content === \"object\");\n\n\t\t\tif (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst __avLegacyValidate = async (\n\t\t\t\truntime: IAgentRuntime,\n\t\t\t\t_message: Memory,\n\t\t\t): Promise<boolean> => {\n\t\t\t\tconst service = runtime.getService<ComputerUseService>(\"computeruse\");\n\t\t\t\treturn !!service && service.isEnabled();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn Boolean(\n\t\t\t\t\tawait (__avLegacyValidate as any)(runtime, message, state, options),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\treturn Boolean(\n\t\t\t\tawait (__avLegacyValidate as any)(runtime, message, state, options),\n\t\t\t);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\n\thandler: async (\n\t\truntime: IAgentRuntime,\n\t\tmessage: Memory,\n\t\t_state?: State,\n\t\toptions?: HandlerOptions,\n\t\tcallback?: HandlerCallback,\n\t): Promise<ActionResult> => {\n\t\tconst service = runtime.getService<ComputerUseService>(\"computeruse\");\n\t\tif (!service) {\n\t\t\treturn { success: false, text: \"ComputerUse service not available\" };\n\t\t}\n\n\t\tconst params = options?.parameters;\n\t\tconst keys = getStringParam(params, \"keys\");\n\t\tif (!keys) {\n\t\t\treturn { success: false, text: \"Missing required parameter: keys\" };\n\t\t}\n\n\t\tconst backend = service.getBackendName();\n\n\t\ttry {\n\t\t\tawait service.pressKey(keys);\n\n\t\t\tconst response: Content = {\n\t\t\t\ttext: `Pressed key: ${keys}`,\n\t\t\t\tactions: [\"COMPUTERUSE_PRESS_KEY\"],\n\t\t\t\tsource: message.content?.source ?? \"action\",\n\t\t\t};\n\t\t\tawait callback?.(response);\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\ttext: response.text ?? \"\",\n\t\t\t\tvalues: { keys },\n\t\t\t\tdata: { keys, backend },\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\t\tlogger.error(`[computeruse] press_key failed: ${msg}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\ttext: `ComputerUse press key failed: ${msg}`,\n\t\t\t\tvalues: { keys },\n\t\t\t};\n\t\t}\n\t},\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/actions/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EAQN,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,2BAA2B,EAAE,MA2IzC,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { logger } from "@elizaos/core";
|
|
2
|
-
export const computeruseScreenshotAction = {
|
|
3
|
-
name: "COMPUTERUSE_SCREENSHOT",
|
|
4
|
-
description: "Capture a screenshot of the current screen.",
|
|
5
|
-
similes: ["SCREENSHOT", "CAPTURE_SCREEN", "TAKE_SCREENSHOT"],
|
|
6
|
-
parameters: [],
|
|
7
|
-
validate: async (runtime, message, state, options) => {
|
|
8
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
9
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
10
|
-
const __avKeywords = ["computeruse", "screenshot"];
|
|
11
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
12
|
-
__avKeywords.some((word) => word.length > 0 && __avText.includes(word));
|
|
13
|
-
const __avRegex = /\b(?:computeruse|screenshot)\b/i;
|
|
14
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
15
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
16
|
-
const __avExpectedSource = "";
|
|
17
|
-
const __avSourceOk = __avExpectedSource
|
|
18
|
-
? __avSource === __avExpectedSource
|
|
19
|
-
: Boolean(__avSource ||
|
|
20
|
-
state ||
|
|
21
|
-
runtime?.agentId ||
|
|
22
|
-
runtime?.getService ||
|
|
23
|
-
runtime?.getSetting);
|
|
24
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
25
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
26
|
-
Object.keys(__avOptions).length > 0 ||
|
|
27
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
28
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
const __avLegacyValidate = async (runtime, message, state, options) => {
|
|
32
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
33
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
34
|
-
const __avKeywords = ["computeruse", "screenshot"];
|
|
35
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
36
|
-
__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
37
|
-
const __avRegex = /\b(?:computeruse|screenshot)\b/i;
|
|
38
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
39
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
40
|
-
const __avExpectedSource = "";
|
|
41
|
-
const __avSourceOk = __avExpectedSource
|
|
42
|
-
? __avSource === __avExpectedSource
|
|
43
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
44
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
45
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
46
|
-
Object.keys(__avOptions).length > 0 ||
|
|
47
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
48
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
const __avLegacyValidate = async (runtime, _message) => {
|
|
52
|
-
const service = runtime.getService("computeruse");
|
|
53
|
-
return !!service && service.isEnabled();
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
try {
|
|
63
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
handler: async (runtime, message, _state, _options, callback) => {
|
|
70
|
-
const service = runtime.getService("computeruse");
|
|
71
|
-
if (!service) {
|
|
72
|
-
return { success: false, text: "ComputerUse service not available" };
|
|
73
|
-
}
|
|
74
|
-
const backend = service.getBackendName();
|
|
75
|
-
try {
|
|
76
|
-
const screenshotData = await service.screenshot();
|
|
77
|
-
const response = {
|
|
78
|
-
text: "Screenshot captured",
|
|
79
|
-
actions: ["COMPUTERUSE_SCREENSHOT"],
|
|
80
|
-
source: message.content?.source ?? "action",
|
|
81
|
-
};
|
|
82
|
-
await callback?.(response);
|
|
83
|
-
return {
|
|
84
|
-
success: true,
|
|
85
|
-
text: response.text ?? "",
|
|
86
|
-
data: { backend, screenshotLength: screenshotData.length },
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
91
|
-
logger.error(`[computeruse] screenshot failed: ${msg}`);
|
|
92
|
-
return {
|
|
93
|
-
success: false,
|
|
94
|
-
text: `ComputerUse screenshot failed: ${msg}`,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
//# sourceMappingURL=screenshot.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/actions/screenshot.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,MAAM,CAAC,MAAM,2BAA2B,GAAW;IAClD,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,6CAA6C;IAC1D,OAAO,EAAE,CAAC,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,CAAC;IAC5D,UAAU,EAAE,EAAE;IAEd,QAAQ,EAAE,KAAK,EACd,OAAY,EACZ,OAAY,EACZ,KAAW,EACX,OAAa,EACM,EAAE;QACrB,MAAM,WAAW,GAChB,OAAO,OAAO,EAAE,OAAO,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,YAAY,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,aAAa,GAClB,YAAY,CAAC,MAAM,GAAG,CA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C,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,QAAQ;aAC3C,CAAC;YACF,MAAM,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;YAC3B,OAAO;gBACN,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;gBACzB,IAAI,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,cAAc,CAAC,MAAM,EAAE;aAC1D,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,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,oCAAoC,GAAG,EAAE,CAAC,CAAC;YACxD,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,kCAAkC,GAAG,EAAE;aAC7C,CAAC;QACH,CAAC;IACF,CAAC;CACD,CAAC","sourcesContent":["import type {\n\tAction,\n\tActionResult,\n\tContent,\n\tHandlerCallback,\n\tHandlerOptions,\n\tIAgentRuntime,\n\tMemory,\n\tState,\n} from \"@elizaos/core\";\nimport { logger } from \"@elizaos/core\";\nimport type { ComputerUseService } from \"../services/computeruse-service.js\";\n\nexport const computeruseScreenshotAction: Action = {\n\tname: \"COMPUTERUSE_SCREENSHOT\",\n\tdescription: \"Capture a screenshot of the current screen.\",\n\tsimiles: [\"SCREENSHOT\", \"CAPTURE_SCREEN\", \"TAKE_SCREENSHOT\"],\n\tparameters: [],\n\n\tvalidate: async (\n\t\truntime: any,\n\t\tmessage: any,\n\t\tstate?: any,\n\t\toptions?: any,\n\t): Promise<boolean> => {\n\t\tconst __avTextRaw =\n\t\t\ttypeof message?.content?.text === \"string\" ? message.content.text : \"\";\n\t\tconst __avText = __avTextRaw.toLowerCase();\n\t\tconst __avKeywords = [\"computeruse\", \"screenshot\"];\n\t\tconst __avKeywordOk =\n\t\t\t__avKeywords.length > 0 &&\n\t\t\t__avKeywords.some((word) => word.length > 0 && __avText.includes(word));\n\t\tconst __avRegex = /\\b(?:computeruse|screenshot)\\b/i;\n\t\tconst __avRegexOk = __avRegex.test(__avText);\n\t\tconst __avSource = String(\n\t\t\tmessage?.content?.source ?? message?.source ?? \"\",\n\t\t);\n\t\tconst __avExpectedSource = \"\";\n\t\tconst __avSourceOk = __avExpectedSource\n\t\t\t? __avSource === __avExpectedSource\n\t\t\t: Boolean(\n\t\t\t\t\t__avSource ||\n\t\t\t\t\t\tstate ||\n\t\t\t\t\t\truntime?.agentId ||\n\t\t\t\t\t\truntime?.getService ||\n\t\t\t\t\t\truntime?.getSetting,\n\t\t\t\t);\n\t\tconst __avOptions = options && typeof options === \"object\" ? options : {};\n\t\tconst __avInputOk =\n\t\t\t__avText.trim().length > 0 ||\n\t\t\tObject.keys(__avOptions as Record<string, unknown>).length > 0 ||\n\t\t\tBoolean(message?.content && typeof message.content === \"object\");\n\n\t\tif (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst __avLegacyValidate = async (\n\t\t\truntime: any,\n\t\t\tmessage: any,\n\t\t\tstate?: any,\n\t\t\toptions?: any,\n\t\t): Promise<boolean> => {\n\t\t\tconst __avTextRaw =\n\t\t\t\ttypeof message?.content?.text === \"string\" ? message.content.text : \"\";\n\t\t\tconst __avText = __avTextRaw.toLowerCase();\n\t\t\tconst __avKeywords = [\"computeruse\", \"screenshot\"];\n\t\t\tconst __avKeywordOk =\n\t\t\t\t__avKeywords.length > 0 &&\n\t\t\t\t__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));\n\t\t\tconst __avRegex = /\\b(?:computeruse|screenshot)\\b/i;\n\t\t\tconst __avRegexOk = __avRegex.test(__avText);\n\t\t\tconst __avSource = String(\n\t\t\t\tmessage?.content?.source ?? message?.source ?? \"\",\n\t\t\t);\n\t\t\tconst __avExpectedSource = \"\";\n\t\t\tconst __avSourceOk = __avExpectedSource\n\t\t\t\t? __avSource === __avExpectedSource\n\t\t\t\t: Boolean(\n\t\t\t\t\t\t__avSource || state || runtime?.agentId || runtime?.getService,\n\t\t\t\t\t);\n\t\t\tconst __avOptions = options && typeof options === \"object\" ? options : {};\n\t\t\tconst __avInputOk =\n\t\t\t\t__avText.trim().length > 0 ||\n\t\t\t\tObject.keys(__avOptions as Record<string, unknown>).length > 0 ||\n\t\t\t\tBoolean(message?.content && typeof message.content === \"object\");\n\n\t\t\tif (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst __avLegacyValidate = async (\n\t\t\t\truntime: IAgentRuntime,\n\t\t\t\t_message: Memory,\n\t\t\t): Promise<boolean> => {\n\t\t\t\tconst service = runtime.getService<ComputerUseService>(\"computeruse\");\n\t\t\t\treturn !!service && service.isEnabled();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn Boolean(\n\t\t\t\t\tawait (__avLegacyValidate as any)(runtime, message, state, options),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\treturn Boolean(\n\t\t\t\tawait (__avLegacyValidate as any)(runtime, message, state, options),\n\t\t\t);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\n\thandler: async (\n\t\truntime: IAgentRuntime,\n\t\tmessage: Memory,\n\t\t_state?: State,\n\t\t_options?: HandlerOptions,\n\t\tcallback?: HandlerCallback,\n\t): Promise<ActionResult> => {\n\t\tconst service = runtime.getService<ComputerUseService>(\"computeruse\");\n\t\tif (!service) {\n\t\t\treturn { success: false, text: \"ComputerUse service not available\" };\n\t\t}\n\n\t\tconst backend = service.getBackendName();\n\n\t\ttry {\n\t\t\tconst screenshotData = await service.screenshot();\n\n\t\t\tconst response: Content = {\n\t\t\t\ttext: \"Screenshot captured\",\n\t\t\t\tactions: [\"COMPUTERUSE_SCREENSHOT\"],\n\t\t\t\tsource: message.content?.source ?? \"action\",\n\t\t\t};\n\t\t\tawait callback?.(response);\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\ttext: response.text ?? \"\",\n\t\t\t\tdata: { backend, screenshotLength: screenshotData.length },\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\t\tlogger.error(`[computeruse] screenshot failed: ${msg}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\ttext: `ComputerUse screenshot failed: ${msg}`,\n\t\t\t};\n\t\t}\n\t},\n};\n"]}
|
package/dist/actions/scroll.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../src/actions/scroll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EAQN,MAAM,eAAe,CAAC;AAKvB,eAAO,MAAM,uBAAuB,EAAE,MAiLrC,CAAC"}
|
package/dist/actions/scroll.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { logger } from "@elizaos/core";
|
|
2
|
-
import { getNumberParam, getStringParam } from "../utils/params.js";
|
|
3
|
-
export const computeruseScrollAction = {
|
|
4
|
-
name: "COMPUTERUSE_SCROLL",
|
|
5
|
-
description: "Scroll the mouse wheel at the current or specified position.",
|
|
6
|
-
similes: ["SCROLL", "SCROLL_UP", "SCROLL_DOWN", "MOUSE_SCROLL"],
|
|
7
|
-
parameters: [
|
|
8
|
-
{
|
|
9
|
-
name: "x",
|
|
10
|
-
description: "X coordinate to scroll at (optional)",
|
|
11
|
-
required: false,
|
|
12
|
-
schema: { type: "number" },
|
|
13
|
-
examples: [500],
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: "y",
|
|
17
|
-
description: "Y coordinate to scroll at (optional)",
|
|
18
|
-
required: false,
|
|
19
|
-
schema: { type: "number" },
|
|
20
|
-
examples: [500],
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: "direction",
|
|
24
|
-
description: "Scroll direction: 'up' or 'down'. Default: 'down'",
|
|
25
|
-
required: false,
|
|
26
|
-
schema: { type: "string" },
|
|
27
|
-
examples: ["up", "down"],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: "amount",
|
|
31
|
-
description: "Number of scroll clicks. Default: 3",
|
|
32
|
-
required: false,
|
|
33
|
-
schema: { type: "number", default: 3, minimum: 1 },
|
|
34
|
-
examples: [3, 5, 10],
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
validate: async (runtime, message, state, options) => {
|
|
38
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
39
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
40
|
-
const __avKeywords = ["computeruse", "scroll"];
|
|
41
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
42
|
-
__avKeywords.some((word) => word.length > 0 && __avText.includes(word));
|
|
43
|
-
const __avRegex = /\b(?:computeruse|scroll)\b/i;
|
|
44
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
45
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
46
|
-
const __avExpectedSource = "";
|
|
47
|
-
const __avSourceOk = __avExpectedSource
|
|
48
|
-
? __avSource === __avExpectedSource
|
|
49
|
-
: Boolean(__avSource ||
|
|
50
|
-
state ||
|
|
51
|
-
runtime?.agentId ||
|
|
52
|
-
runtime?.getService ||
|
|
53
|
-
runtime?.getSetting);
|
|
54
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
55
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
56
|
-
Object.keys(__avOptions).length > 0 ||
|
|
57
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
58
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
const __avLegacyValidate = async (runtime, message, state, options) => {
|
|
62
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
63
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
64
|
-
const __avKeywords = ["computeruse", "scroll"];
|
|
65
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
66
|
-
__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
67
|
-
const __avRegex = /\b(?:computeruse|scroll)\b/i;
|
|
68
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
69
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
70
|
-
const __avExpectedSource = "";
|
|
71
|
-
const __avSourceOk = __avExpectedSource
|
|
72
|
-
? __avSource === __avExpectedSource
|
|
73
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
74
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
75
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
76
|
-
Object.keys(__avOptions).length > 0 ||
|
|
77
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
78
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
const __avLegacyValidate = async (runtime, _message) => {
|
|
82
|
-
const service = runtime.getService("computeruse");
|
|
83
|
-
return !!service && service.isEnabled();
|
|
84
|
-
};
|
|
85
|
-
try {
|
|
86
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
try {
|
|
93
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
handler: async (runtime, message, _state, options, callback) => {
|
|
100
|
-
const service = runtime.getService("computeruse");
|
|
101
|
-
if (!service) {
|
|
102
|
-
return { success: false, text: "ComputerUse service not available" };
|
|
103
|
-
}
|
|
104
|
-
const params = options?.parameters;
|
|
105
|
-
const x = getNumberParam(params, "x");
|
|
106
|
-
const y = getNumberParam(params, "y");
|
|
107
|
-
const direction = getStringParam(params, "direction") ?? "down";
|
|
108
|
-
const amount = getNumberParam(params, "amount") ?? 3;
|
|
109
|
-
const backend = service.getBackendName();
|
|
110
|
-
try {
|
|
111
|
-
await service.scroll(direction, amount, x, y);
|
|
112
|
-
const posStr = x !== undefined ? `(${x}, ${y})` : "current position";
|
|
113
|
-
const response = {
|
|
114
|
-
text: `Scrolled ${direction} by ${amount} at ${posStr}`,
|
|
115
|
-
actions: ["COMPUTERUSE_SCROLL"],
|
|
116
|
-
source: message.content?.source ?? "action",
|
|
117
|
-
};
|
|
118
|
-
await callback?.(response);
|
|
119
|
-
return {
|
|
120
|
-
success: true,
|
|
121
|
-
text: response.text ?? "",
|
|
122
|
-
values: { x, y, direction, amount },
|
|
123
|
-
data: { x, y, direction, amount, backend },
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
128
|
-
logger.error(`[computeruse] scroll failed: ${msg}`);
|
|
129
|
-
return {
|
|
130
|
-
success: false,
|
|
131
|
-
text: `ComputerUse scroll failed: ${msg}`,
|
|
132
|
-
values: { x, y, direction, amount },
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
//# sourceMappingURL=scroll.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../src/actions/scroll.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,uBAAuB,GAAW;I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OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,8BAA8B,GAAG,EAAE;gBACzC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE;aACnC,CAAC;QACH,CAAC;IACF,CAAC;CACD,CAAC","sourcesContent":["import type {\n\tAction,\n\tActionResult,\n\tContent,\n\tHandlerCallback,\n\tHandlerOptions,\n\tIAgentRuntime,\n\tMemory,\n\tState,\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 computeruseScrollAction: Action = {\n\tname: \"COMPUTERUSE_SCROLL\",\n\tdescription: \"Scroll the mouse wheel at the current or specified position.\",\n\tsimiles: [\"SCROLL\", \"SCROLL_UP\", \"SCROLL_DOWN\", \"MOUSE_SCROLL\"],\n\tparameters: [\n\t\t{\n\t\t\tname: \"x\",\n\t\t\tdescription: \"X coordinate to scroll at (optional)\",\n\t\t\trequired: false,\n\t\t\tschema: { type: \"number\" },\n\t\t\texamples: [500],\n\t\t},\n\t\t{\n\t\t\tname: \"y\",\n\t\t\tdescription: \"Y coordinate to scroll at (optional)\",\n\t\t\trequired: false,\n\t\t\tschema: { type: \"number\" },\n\t\t\texamples: [500],\n\t\t},\n\t\t{\n\t\t\tname: \"direction\",\n\t\t\tdescription: \"Scroll direction: 'up' or 'down'. Default: 'down'\",\n\t\t\trequired: false,\n\t\t\tschema: { type: \"string\" },\n\t\t\texamples: [\"up\", \"down\"],\n\t\t},\n\t\t{\n\t\t\tname: \"amount\",\n\t\t\tdescription: \"Number of scroll clicks. Default: 3\",\n\t\t\trequired: false,\n\t\t\tschema: { type: \"number\", default: 3, minimum: 1 },\n\t\t\texamples: [3, 5, 10],\n\t\t},\n\t],\n\n\tvalidate: async (\n\t\truntime: any,\n\t\tmessage: any,\n\t\tstate?: any,\n\t\toptions?: any,\n\t): Promise<boolean> => {\n\t\tconst __avTextRaw =\n\t\t\ttypeof message?.content?.text === \"string\" ? message.content.text : \"\";\n\t\tconst __avText = __avTextRaw.toLowerCase();\n\t\tconst __avKeywords = [\"computeruse\", \"scroll\"];\n\t\tconst __avKeywordOk =\n\t\t\t__avKeywords.length > 0 &&\n\t\t\t__avKeywords.some((word) => word.length > 0 && __avText.includes(word));\n\t\tconst __avRegex = /\\b(?:computeruse|scroll)\\b/i;\n\t\tconst __avRegexOk = __avRegex.test(__avText);\n\t\tconst __avSource = String(\n\t\t\tmessage?.content?.source ?? message?.source ?? \"\",\n\t\t);\n\t\tconst __avExpectedSource = \"\";\n\t\tconst __avSourceOk = __avExpectedSource\n\t\t\t? __avSource === __avExpectedSource\n\t\t\t: Boolean(\n\t\t\t\t\t__avSource ||\n\t\t\t\t\t\tstate ||\n\t\t\t\t\t\truntime?.agentId ||\n\t\t\t\t\t\truntime?.getService ||\n\t\t\t\t\t\truntime?.getSetting,\n\t\t\t\t);\n\t\tconst __avOptions = options && typeof options === \"object\" ? options : {};\n\t\tconst __avInputOk =\n\t\t\t__avText.trim().length > 0 ||\n\t\t\tObject.keys(__avOptions as Record<string, unknown>).length > 0 ||\n\t\t\tBoolean(message?.content && typeof message.content === \"object\");\n\n\t\tif (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst __avLegacyValidate = async (\n\t\t\truntime: any,\n\t\t\tmessage: any,\n\t\t\tstate?: any,\n\t\t\toptions?: any,\n\t\t): Promise<boolean> => {\n\t\t\tconst __avTextRaw =\n\t\t\t\ttypeof message?.content?.text === \"string\" ? message.content.text : \"\";\n\t\t\tconst __avText = __avTextRaw.toLowerCase();\n\t\t\tconst __avKeywords = [\"computeruse\", \"scroll\"];\n\t\t\tconst __avKeywordOk =\n\t\t\t\t__avKeywords.length > 0 &&\n\t\t\t\t__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));\n\t\t\tconst __avRegex = /\\b(?:computeruse|scroll)\\b/i;\n\t\t\tconst __avRegexOk = __avRegex.test(__avText);\n\t\t\tconst __avSource = String(\n\t\t\t\tmessage?.content?.source ?? message?.source ?? \"\",\n\t\t\t);\n\t\t\tconst __avExpectedSource = \"\";\n\t\t\tconst __avSourceOk = __avExpectedSource\n\t\t\t\t? __avSource === __avExpectedSource\n\t\t\t\t: Boolean(\n\t\t\t\t\t\t__avSource || state || runtime?.agentId || runtime?.getService,\n\t\t\t\t\t);\n\t\t\tconst __avOptions = options && typeof options === \"object\" ? options : {};\n\t\t\tconst __avInputOk =\n\t\t\t\t__avText.trim().length > 0 ||\n\t\t\t\tObject.keys(__avOptions as Record<string, unknown>).length > 0 ||\n\t\t\t\tBoolean(message?.content && typeof message.content === \"object\");\n\n\t\t\tif (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst __avLegacyValidate = async (\n\t\t\t\truntime: IAgentRuntime,\n\t\t\t\t_message: Memory,\n\t\t\t): Promise<boolean> => {\n\t\t\t\tconst service = runtime.getService<ComputerUseService>(\"computeruse\");\n\t\t\t\treturn !!service && service.isEnabled();\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn Boolean(\n\t\t\t\t\tawait (__avLegacyValidate as any)(runtime, message, state, options),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\treturn Boolean(\n\t\t\t\tawait (__avLegacyValidate as any)(runtime, message, state, options),\n\t\t\t);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t},\n\n\thandler: async (\n\t\truntime: IAgentRuntime,\n\t\tmessage: Memory,\n\t\t_state?: State,\n\t\toptions?: HandlerOptions,\n\t\tcallback?: HandlerCallback,\n\t): Promise<ActionResult> => {\n\t\tconst service = runtime.getService<ComputerUseService>(\"computeruse\");\n\t\tif (!service) {\n\t\t\treturn { success: false, text: \"ComputerUse service not available\" };\n\t\t}\n\n\t\tconst params = options?.parameters;\n\t\tconst x = getNumberParam(params, \"x\");\n\t\tconst y = getNumberParam(params, \"y\");\n\t\tconst direction = getStringParam(params, \"direction\") ?? \"down\";\n\t\tconst amount = getNumberParam(params, \"amount\") ?? 3;\n\n\t\tconst backend = service.getBackendName();\n\n\t\ttry {\n\t\t\tawait service.scroll(direction, amount, x, y);\n\n\t\t\tconst posStr = x !== undefined ? `(${x}, ${y})` : \"current position\";\n\t\t\tconst response: Content = {\n\t\t\t\ttext: `Scrolled ${direction} by ${amount} at ${posStr}`,\n\t\t\t\tactions: [\"COMPUTERUSE_SCROLL\"],\n\t\t\t\tsource: message.content?.source ?? \"action\",\n\t\t\t};\n\t\t\tawait callback?.(response);\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\ttext: response.text ?? \"\",\n\t\t\t\tvalues: { x, y, direction, amount },\n\t\t\t\tdata: { x, y, direction, amount, backend },\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\t\tlogger.error(`[computeruse] scroll failed: ${msg}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\ttext: `ComputerUse scroll failed: ${msg}`,\n\t\t\t\tvalues: { x, y, direction, amount },\n\t\t\t};\n\t\t}\n\t},\n};\n"]}
|
package/dist/actions/type.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/actions/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EAQN,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,qBAAqB,EAAE,MAsNnC,CAAC"}
|
package/dist/actions/type.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
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, state, options) => {
|
|
43
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
44
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
45
|
-
const __avKeywords = ["computeruse", "type"];
|
|
46
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
47
|
-
__avKeywords.some((word) => word.length > 0 && __avText.includes(word));
|
|
48
|
-
const __avRegex = /\b(?:computeruse|type)\b/i;
|
|
49
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
50
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
51
|
-
const __avExpectedSource = "";
|
|
52
|
-
const __avSourceOk = __avExpectedSource
|
|
53
|
-
? __avSource === __avExpectedSource
|
|
54
|
-
: Boolean(__avSource ||
|
|
55
|
-
state ||
|
|
56
|
-
runtime?.agentId ||
|
|
57
|
-
runtime?.getService ||
|
|
58
|
-
runtime?.getSetting);
|
|
59
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
60
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
61
|
-
Object.keys(__avOptions).length > 0 ||
|
|
62
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
63
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
const __avLegacyValidate = async (runtime, message, state, options) => {
|
|
67
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
68
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
69
|
-
const __avKeywords = ["computeruse", "type"];
|
|
70
|
-
const __avKeywordOk = __avKeywords.length > 0 &&
|
|
71
|
-
__avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
72
|
-
const __avRegex = /\b(?:computeruse|type)\b/i;
|
|
73
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
74
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
75
|
-
const __avExpectedSource = "";
|
|
76
|
-
const __avSourceOk = __avExpectedSource
|
|
77
|
-
? __avSource === __avExpectedSource
|
|
78
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
79
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
80
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
81
|
-
Object.keys(__avOptions).length > 0 ||
|
|
82
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
83
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
const __avLegacyValidate = async (runtime, message) => {
|
|
87
|
-
const service = runtime.getService("computeruse");
|
|
88
|
-
if (!service || !service.isEnabled())
|
|
89
|
-
return false;
|
|
90
|
-
const text = message.content?.text?.toLowerCase() ?? "";
|
|
91
|
-
return (text.includes("type") ||
|
|
92
|
-
text.includes("enter") ||
|
|
93
|
-
text.includes("fill"));
|
|
94
|
-
};
|
|
95
|
-
try {
|
|
96
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
try {
|
|
103
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
handler: async (runtime, message, _state, options, callback) => {
|
|
110
|
-
const service = runtime.getService("computeruse");
|
|
111
|
-
if (!service) {
|
|
112
|
-
return { success: false, text: "ComputerUse service not available" };
|
|
113
|
-
}
|
|
114
|
-
const params = options?.parameters;
|
|
115
|
-
const process = getStringParam(params, "process");
|
|
116
|
-
const selector = getStringParam(params, "selector");
|
|
117
|
-
const text = getStringParam(params, "text");
|
|
118
|
-
const timeoutMs = getNumberParam(params, "timeoutMs") ?? 5000;
|
|
119
|
-
const clearBeforeTyping = getBooleanParam(params, "clearBeforeTyping") ?? true;
|
|
120
|
-
if (!selector)
|
|
121
|
-
return { success: false, text: "Missing required parameter: selector" };
|
|
122
|
-
if (!text)
|
|
123
|
-
return { success: false, text: "Missing required parameter: text" };
|
|
124
|
-
try {
|
|
125
|
-
await service.typeText(selector, text, timeoutMs, clearBeforeTyping, process);
|
|
126
|
-
const response = {
|
|
127
|
-
text: `Typed into element: ${selector}`,
|
|
128
|
-
actions: ["COMPUTERUSE_TYPE"],
|
|
129
|
-
source: message.content?.source ?? "action",
|
|
130
|
-
};
|
|
131
|
-
await callback?.(response);
|
|
132
|
-
return {
|
|
133
|
-
success: true,
|
|
134
|
-
text: response.text ?? "",
|
|
135
|
-
values: { process, selector, timeoutMs, clearBeforeTyping },
|
|
136
|
-
data: {
|
|
137
|
-
process,
|
|
138
|
-
selector,
|
|
139
|
-
timeoutMs,
|
|
140
|
-
clearBeforeTyping,
|
|
141
|
-
backend: service.getBackendName(),
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
147
|
-
logger.error(`[computeruse] type failed: ${msg}`);
|
|
148
|
-
return {
|
|
149
|
-
success: false,
|
|
150
|
-
text: `ComputerUse type failed: ${msg}`,
|
|
151
|
-
values: { process, selector, timeoutMs, clearBeforeTyping },
|
|
152
|
-
data: {
|
|
153
|
-
process,
|
|
154
|
-
selector,
|
|
155
|
-
timeoutMs,
|
|
156
|
-
clearBeforeTyping,
|
|
157
|
-
backend: service.getBackendName(),
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
//# sourceMappingURL=type.js.map
|