assistme 0.3.1 → 0.3.3
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/PLAN.md +14 -3
- package/dist/{chunk-UWE5WVQI.js → chunk-KX7ITO55.js} +20 -11
- package/dist/index.js +1889 -583
- package/dist/{job-runner-N4XAAWLJ.js → job-runner-P2L6MOOX.js} +1 -1
- package/package.json +5 -3
- package/src/agent/job-runner.ts +9 -13
- package/src/agent/mcp-servers.ts +6 -952
- package/src/agent/memory.ts +2 -11
- package/src/agent/processor.ts +25 -108
- package/src/agent/scheduler.ts +2 -3
- package/src/agent/session.ts +20 -36
- package/src/agent/skills.ts +167 -61
- package/src/agent/system-prompt.ts +126 -0
- package/src/browser/chrome-launcher.ts +557 -0
- package/src/browser/controller.ts +1448 -0
- package/src/browser/types.ts +76 -0
- package/src/commands/credential.ts +190 -0
- package/src/commands/job.ts +14 -45
- package/src/commands/memory.ts +16 -29
- package/src/commands/schedule.ts +15 -37
- package/src/commands/start.ts +11 -43
- package/src/credentials/credential-store.test.ts +162 -0
- package/src/credentials/credential-store.ts +266 -0
- package/src/credentials/encryption.test.ts +98 -0
- package/src/credentials/encryption.ts +82 -0
- package/src/credentials/index.ts +15 -0
- package/src/credentials/local-store.ts +89 -0
- package/src/db/action.ts +19 -0
- package/src/db/api-client.ts +3 -32
- package/src/db/auth-store.ts +41 -0
- package/src/db/auth.ts +38 -0
- package/src/db/conversation.ts +39 -0
- package/src/db/event.ts +52 -0
- package/src/db/job-poll.ts +18 -0
- package/src/db/session.ts +60 -0
- package/src/db/supabase.ts +40 -383
- package/src/db/task.ts +69 -0
- package/src/db/types.ts +54 -0
- package/src/index.ts +2 -0
- package/src/mcp/agent-tools-server.ts +1047 -0
- package/src/mcp/browser-server.ts +241 -0
- package/src/tools/browser.ts +29 -1208
- package/src/tools/index.ts +31 -265
- package/src/tools/web.ts +0 -73
package/src/tools/index.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BrowserController,
|
|
3
|
+
getBrowser,
|
|
4
|
+
ensureBrowserAvailable,
|
|
5
|
+
type SnapshotResult,
|
|
6
|
+
type ActionSpec,
|
|
7
|
+
} from "./browser.js";
|
|
2
8
|
import {
|
|
3
9
|
readFileContent,
|
|
4
10
|
writeFileContent,
|
|
@@ -8,268 +14,6 @@ import {
|
|
|
8
14
|
} from "./filesystem.js";
|
|
9
15
|
import { executeShell } from "./shell.js";
|
|
10
16
|
|
|
11
|
-
interface ToolDefinition {
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
input_schema: {
|
|
15
|
-
type: "object";
|
|
16
|
-
properties: Record<string, unknown>;
|
|
17
|
-
required?: string[];
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getToolDefinitions(): ToolDefinition[] {
|
|
22
|
-
return [
|
|
23
|
-
// ── File System Tools ───────────────────────────────────────
|
|
24
|
-
{
|
|
25
|
-
name: "read_file",
|
|
26
|
-
description:
|
|
27
|
-
"Read the contents of a file. Returns line-numbered content. Use offset/limit for large files.",
|
|
28
|
-
input_schema: {
|
|
29
|
-
type: "object",
|
|
30
|
-
properties: {
|
|
31
|
-
path: { type: "string", description: "File path relative to workspace" },
|
|
32
|
-
offset: { type: "number", description: "Start line (0-indexed)" },
|
|
33
|
-
limit: { type: "number", description: "Max lines to read" },
|
|
34
|
-
},
|
|
35
|
-
required: ["path"],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "write_file",
|
|
40
|
-
description: "Write content to a file. Creates parent directories if needed.",
|
|
41
|
-
input_schema: {
|
|
42
|
-
type: "object",
|
|
43
|
-
properties: {
|
|
44
|
-
path: { type: "string", description: "File path relative to workspace" },
|
|
45
|
-
content: { type: "string", description: "Content to write" },
|
|
46
|
-
},
|
|
47
|
-
required: ["path", "content"],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "search_files",
|
|
52
|
-
description: "Search for files matching a glob pattern (e.g. '**/*.ts').",
|
|
53
|
-
input_schema: {
|
|
54
|
-
type: "object",
|
|
55
|
-
properties: {
|
|
56
|
-
pattern: { type: "string", description: "Glob pattern" },
|
|
57
|
-
directory: { type: "string", description: "Directory (relative to workspace)" },
|
|
58
|
-
},
|
|
59
|
-
required: ["pattern"],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "search_content",
|
|
64
|
-
description: "Search file contents for a regex pattern. Returns matching lines.",
|
|
65
|
-
input_schema: {
|
|
66
|
-
type: "object",
|
|
67
|
-
properties: {
|
|
68
|
-
pattern: { type: "string", description: "Regex pattern" },
|
|
69
|
-
file_glob: { type: "string", description: "File glob filter (default: **/*)" },
|
|
70
|
-
directory: { type: "string", description: "Directory (relative to workspace)" },
|
|
71
|
-
},
|
|
72
|
-
required: ["pattern"],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "list_directory",
|
|
77
|
-
description: "List files and directories in a path.",
|
|
78
|
-
input_schema: {
|
|
79
|
-
type: "object",
|
|
80
|
-
properties: {
|
|
81
|
-
path: { type: "string", description: "Directory path (default: workspace root)" },
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "execute_command",
|
|
87
|
-
description: "Execute a shell command in the workspace directory.",
|
|
88
|
-
input_schema: {
|
|
89
|
-
type: "object",
|
|
90
|
-
properties: {
|
|
91
|
-
command: { type: "string", description: "Shell command" },
|
|
92
|
-
cwd: { type: "string", description: "Working directory (relative)" },
|
|
93
|
-
},
|
|
94
|
-
required: ["command"],
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
// ── Browser Tools (CDP - controls user's real Chrome) ───────
|
|
99
|
-
{
|
|
100
|
-
name: "browser_connect",
|
|
101
|
-
description:
|
|
102
|
-
"Connect to the user's real Chrome browser via CDP. Chrome will be auto-launched if not already running. This shares the user's actual browser session including all logins and cookies.",
|
|
103
|
-
input_schema: {
|
|
104
|
-
type: "object",
|
|
105
|
-
properties: {
|
|
106
|
-
tab_index: {
|
|
107
|
-
type: "number",
|
|
108
|
-
description:
|
|
109
|
-
"Tab index to connect to (default: 0, the first tab). Use browser_list_tabs to see available tabs.",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: "browser_navigate",
|
|
116
|
-
description:
|
|
117
|
-
"Navigate the user's browser to a URL. Opens the page in the currently connected tab, using the user's real browser with all their cookies and logins.",
|
|
118
|
-
input_schema: {
|
|
119
|
-
type: "object",
|
|
120
|
-
properties: {
|
|
121
|
-
url: { type: "string", description: "URL to navigate to" },
|
|
122
|
-
},
|
|
123
|
-
required: ["url"],
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
name: "browser_read_page",
|
|
128
|
-
description:
|
|
129
|
-
"Read the text content of the currently open page in the user's browser. Returns the page title, URL, and main text content. Use this to understand what's on the page.",
|
|
130
|
-
input_schema: { type: "object", properties: {} },
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "browser_screenshot",
|
|
134
|
-
description:
|
|
135
|
-
"Take a screenshot of the current browser page. Returns a base64-encoded PNG image. Use this when you need to visually understand the page layout, verify an action worked, or see dynamic content.",
|
|
136
|
-
input_schema: { type: "object", properties: {} },
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "browser_click",
|
|
140
|
-
description:
|
|
141
|
-
"Click on an element in the user's browser using a CSS selector. Use browser_get_elements first to find clickable elements.",
|
|
142
|
-
input_schema: {
|
|
143
|
-
type: "object",
|
|
144
|
-
properties: {
|
|
145
|
-
selector: {
|
|
146
|
-
type: "string",
|
|
147
|
-
description:
|
|
148
|
-
"CSS selector of the element to click (e.g. '#submit-btn', 'a.nav-link', 'button:nth-of-type(2)')",
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
required: ["selector"],
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
name: "browser_type",
|
|
156
|
-
description:
|
|
157
|
-
"Type text into an input field in the user's browser. Focuses the element and sets its value.",
|
|
158
|
-
input_schema: {
|
|
159
|
-
type: "object",
|
|
160
|
-
properties: {
|
|
161
|
-
selector: {
|
|
162
|
-
type: "string",
|
|
163
|
-
description: "CSS selector of the input element",
|
|
164
|
-
},
|
|
165
|
-
text: {
|
|
166
|
-
type: "string",
|
|
167
|
-
description: "Text to type into the element",
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
required: ["selector", "text"],
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
name: "browser_press_key",
|
|
175
|
-
description:
|
|
176
|
-
"Press a keyboard key in the browser. Supports: Enter, Tab, Escape, Backspace, ArrowDown, ArrowUp, or any single character.",
|
|
177
|
-
input_schema: {
|
|
178
|
-
type: "object",
|
|
179
|
-
properties: {
|
|
180
|
-
key: { type: "string", description: "Key to press" },
|
|
181
|
-
},
|
|
182
|
-
required: ["key"],
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: "browser_scroll",
|
|
187
|
-
description: "Scroll the page up or down.",
|
|
188
|
-
input_schema: {
|
|
189
|
-
type: "object",
|
|
190
|
-
properties: {
|
|
191
|
-
direction: {
|
|
192
|
-
type: "string",
|
|
193
|
-
description: "'down' or 'up'",
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
required: ["direction"],
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: "browser_get_elements",
|
|
201
|
-
description:
|
|
202
|
-
"Find all interactive elements (links, buttons, inputs, etc.) on the current page. Returns their tag, text, selector, and attributes. Use this to understand what you can interact with.",
|
|
203
|
-
input_schema: { type: "object", properties: {} },
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
name: "browser_evaluate",
|
|
207
|
-
description:
|
|
208
|
-
"Execute JavaScript in the browser page context. Use for advanced interactions or data extraction that other tools can't handle.",
|
|
209
|
-
input_schema: {
|
|
210
|
-
type: "object",
|
|
211
|
-
properties: {
|
|
212
|
-
expression: {
|
|
213
|
-
type: "string",
|
|
214
|
-
description: "JavaScript expression to evaluate",
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
required: ["expression"],
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
name: "browser_list_tabs",
|
|
222
|
-
description:
|
|
223
|
-
"List all open tabs in the user's browser. Shows title, URL, and which tab is currently connected.",
|
|
224
|
-
input_schema: { type: "object", properties: {} },
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
name: "browser_switch_tab",
|
|
228
|
-
description: "Switch to a different browser tab by index.",
|
|
229
|
-
input_schema: {
|
|
230
|
-
type: "object",
|
|
231
|
-
properties: {
|
|
232
|
-
index: {
|
|
233
|
-
type: "number",
|
|
234
|
-
description: "Tab index (from browser_list_tabs)",
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
required: ["index"],
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: "browser_new_tab",
|
|
242
|
-
description: "Open a new tab in the user's browser, optionally navigating to a URL.",
|
|
243
|
-
input_schema: {
|
|
244
|
-
type: "object",
|
|
245
|
-
properties: {
|
|
246
|
-
url: { type: "string", description: "URL to open (default: blank)" },
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
name: "browser_request_user_action",
|
|
252
|
-
description:
|
|
253
|
-
"Request the user to perform an action in their browser that the AI cannot do. Use this when: (1) a page requires login/authentication, (2) a CAPTCHA needs solving, (3) two-factor auth is needed, (4) any action requiring the user's personal credentials. The user will see a notification on the web UI and in the terminal.",
|
|
254
|
-
input_schema: {
|
|
255
|
-
type: "object",
|
|
256
|
-
properties: {
|
|
257
|
-
message: {
|
|
258
|
-
type: "string",
|
|
259
|
-
description:
|
|
260
|
-
"Clear description of what the user needs to do. E.g.: 'Please log in to amazon.com in your browser. The login page is currently open in the active tab.'",
|
|
261
|
-
},
|
|
262
|
-
wait_seconds: {
|
|
263
|
-
type: "number",
|
|
264
|
-
description: "How long to wait for the user to complete the action (default: 60)",
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
required: ["message"],
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
17
|
/**
|
|
274
18
|
* After navigation, detect if the page requires login and automatically prompt
|
|
275
19
|
* the user to log in. Waits for login completion and returns context about the
|
|
@@ -425,12 +169,34 @@ export async function executeTool(name: string, input: Record<string, unknown>):
|
|
|
425
169
|
case "browser_scroll":
|
|
426
170
|
await ensureConnected(browser);
|
|
427
171
|
return (input.direction as string) === "up" ? browser.scrollUp() : browser.scrollDown();
|
|
428
|
-
case "
|
|
172
|
+
case "browser_select":
|
|
429
173
|
await ensureConnected(browser);
|
|
430
|
-
return browser.
|
|
174
|
+
return browser.selectOption(input.selector as string, input.option as string);
|
|
431
175
|
case "browser_evaluate":
|
|
432
176
|
await ensureConnected(browser);
|
|
433
177
|
return browser.evaluate(input.expression as string);
|
|
178
|
+
case "browser_snapshot": {
|
|
179
|
+
await ensureConnected(browser);
|
|
180
|
+
const snap = await browser.snapshot(input.annotate as boolean | undefined);
|
|
181
|
+
// Return is handled specially in MCP server (image + text)
|
|
182
|
+
// For the generic executeTool path, return the ref table text
|
|
183
|
+
return BrowserController.formatRefTable(snap) + "\n__SNAPSHOT_IMAGE__:" + snap.image;
|
|
184
|
+
}
|
|
185
|
+
case "browser_act": {
|
|
186
|
+
await ensureConnected(browser);
|
|
187
|
+
const actions = input.actions as ActionSpec[];
|
|
188
|
+
const wantScreenshot = (input.screenshot as boolean) || false;
|
|
189
|
+
const actResult = await browser.act(actions, wantScreenshot);
|
|
190
|
+
|
|
191
|
+
let response = actResult.results
|
|
192
|
+
.map((r) => `${r.success ? "OK" : "FAIL"}: ${r.result}`)
|
|
193
|
+
.join("\n");
|
|
194
|
+
|
|
195
|
+
if (actResult.screenshot) {
|
|
196
|
+
response += "\n__ACT_SCREENSHOT__:" + actResult.screenshot;
|
|
197
|
+
}
|
|
198
|
+
return response;
|
|
199
|
+
}
|
|
434
200
|
case "browser_list_tabs":
|
|
435
201
|
return browser.listTabs();
|
|
436
202
|
case "browser_switch_tab":
|
package/src/tools/web.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const MAX_CONTENT = 30_000; // 30KB content cap
|
|
2
|
-
|
|
3
|
-
export async function webFetch(
|
|
4
|
-
url: string,
|
|
5
|
-
_prompt?: string
|
|
6
|
-
): Promise<string> {
|
|
7
|
-
try {
|
|
8
|
-
const controller = new AbortController();
|
|
9
|
-
const timeoutId = setTimeout(() => controller.abort(), 15_000);
|
|
10
|
-
|
|
11
|
-
const response = await fetch(url, {
|
|
12
|
-
signal: controller.signal,
|
|
13
|
-
headers: {
|
|
14
|
-
"User-Agent": "AssistMe-CLI/0.1.0",
|
|
15
|
-
Accept: "text/html,application/json,text/plain",
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
clearTimeout(timeoutId);
|
|
20
|
-
|
|
21
|
-
if (!response.ok) {
|
|
22
|
-
return `HTTP ${response.status}: ${response.statusText}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const contentType = response.headers.get("content-type") || "";
|
|
26
|
-
let content: string;
|
|
27
|
-
|
|
28
|
-
if (contentType.includes("application/json")) {
|
|
29
|
-
const json = await response.json();
|
|
30
|
-
content = JSON.stringify(json, null, 2);
|
|
31
|
-
} else {
|
|
32
|
-
content = await response.text();
|
|
33
|
-
|
|
34
|
-
// Basic HTML to text conversion
|
|
35
|
-
if (contentType.includes("text/html")) {
|
|
36
|
-
content = htmlToText(content);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (content.length > MAX_CONTENT) {
|
|
41
|
-
content =
|
|
42
|
-
content.slice(0, MAX_CONTENT) + "\n\n[Content truncated]";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return content;
|
|
46
|
-
} catch (err) {
|
|
47
|
-
return `Fetch error: ${err instanceof Error ? err.message : String(err)}`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function htmlToText(html: string): string {
|
|
52
|
-
return html
|
|
53
|
-
// Remove scripts and styles
|
|
54
|
-
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "")
|
|
55
|
-
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "")
|
|
56
|
-
// Convert common elements
|
|
57
|
-
.replace(/<br\s*\/?>/gi, "\n")
|
|
58
|
-
.replace(/<\/p>/gi, "\n\n")
|
|
59
|
-
.replace(/<\/div>/gi, "\n")
|
|
60
|
-
.replace(/<\/h[1-6]>/gi, "\n\n")
|
|
61
|
-
.replace(/<li>/gi, "- ")
|
|
62
|
-
.replace(/<\/li>/gi, "\n")
|
|
63
|
-
// Remove remaining tags
|
|
64
|
-
.replace(/<[^>]+>/g, "")
|
|
65
|
-
// Clean up whitespace
|
|
66
|
-
.replace(/ /g, " ")
|
|
67
|
-
.replace(/&/g, "&")
|
|
68
|
-
.replace(/</g, "<")
|
|
69
|
-
.replace(/>/g, ">")
|
|
70
|
-
.replace(/"/g, '"')
|
|
71
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
72
|
-
.trim();
|
|
73
|
-
}
|