browser-debugging-daemon 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/daemon.js +931 -0
- package/dashboard/app.js +1139 -0
- package/dashboard/index.html +277 -0
- package/dashboard/styles.css +774 -0
- package/index.js +223 -0
- package/mcp_server.js +999 -0
- package/orchestrator/RunTemplateStore.js +30 -0
- package/orchestrator/TaskRunStore.js +33 -0
- package/orchestrator/TaskRunner.js +803 -0
- package/package.json +66 -0
- package/runtime/ArtifactStore.js +202 -0
- package/runtime/BrowserRuntime.js +1706 -0
- package/shared.js +358 -0
- package/subagent/BrowserSubagent.js +689 -0
- package/subagent/OpenAIPlanner.js +382 -0
package/index.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* browser-debugging-daemon SDK
|
|
3
|
+
*
|
|
4
|
+
* Programmatic access to browser automation, autonomous subagent,
|
|
5
|
+
* and task orchestration — no daemon or MCP server needed.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { BrowserAgent } from 'browser-debugging-daemon';
|
|
9
|
+
* const agent = new BrowserAgent();
|
|
10
|
+
* await agent.start();
|
|
11
|
+
* const obs = await agent.observe();
|
|
12
|
+
* await agent.click({ id: 12 });
|
|
13
|
+
* const result = await agent.delegate('Search for AI news');
|
|
14
|
+
* await agent.stop();
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { BrowserRuntime } from "./runtime/BrowserRuntime.js";
|
|
18
|
+
import { BrowserSubagent } from "./subagent/BrowserSubagent.js";
|
|
19
|
+
import { TaskRunner } from "./orchestrator/TaskRunner.js";
|
|
20
|
+
import { ArtifactStore } from "./runtime/ArtifactStore.js";
|
|
21
|
+
import {
|
|
22
|
+
clearOverlays,
|
|
23
|
+
collectInteractableElements,
|
|
24
|
+
collectPageContent,
|
|
25
|
+
refreshTarget,
|
|
26
|
+
} from "./shared.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* High-level facade that composes BrowserRuntime, BrowserSubagent,
|
|
30
|
+
* and TaskRunner behind a single API.
|
|
31
|
+
*/
|
|
32
|
+
export class BrowserAgent {
|
|
33
|
+
/**
|
|
34
|
+
* @param {object} [options]
|
|
35
|
+
* @param {string} [options.baseDir] - Directory for artifacts/state (default: auto-resolved)
|
|
36
|
+
* @param {object} [options.plannerOptions] - Options forwarded to OpenAIPlanner
|
|
37
|
+
* @param {number} [options.defaultMaxSteps] - Default max steps for delegate (default: 12)
|
|
38
|
+
* @param {number} [options.handoffTimeoutMs] - Handoff timeout for task runs (default: 300000)
|
|
39
|
+
* @param {BrowserRuntime} [options.runtime] - Inject a custom BrowserRuntime
|
|
40
|
+
* @param {BrowserSubagent} [options.subagent] - Inject a custom BrowserSubagent
|
|
41
|
+
*/
|
|
42
|
+
constructor(options = {}) {
|
|
43
|
+
const baseDir = options.baseDir || import.meta.dirname;
|
|
44
|
+
|
|
45
|
+
this.runtime = options.runtime || new BrowserRuntime(baseDir);
|
|
46
|
+
this.subagent = options.subagent || new BrowserSubagent(this.runtime, {
|
|
47
|
+
plannerOptions: options.plannerOptions,
|
|
48
|
+
defaultMaxSteps: options.defaultMaxSteps,
|
|
49
|
+
...(options.plannerOptions || {}),
|
|
50
|
+
});
|
|
51
|
+
this.taskRunner = new TaskRunner(baseDir, {
|
|
52
|
+
runtime: this.runtime,
|
|
53
|
+
subagent: this.subagent,
|
|
54
|
+
plannerOptions: options.plannerOptions,
|
|
55
|
+
handoffTimeoutMs: options.handoffTimeoutMs,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ── Browser lifecycle ──────────────────────────────────
|
|
60
|
+
|
|
61
|
+
async start(options = {}) {
|
|
62
|
+
return this.runtime.start(options);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async stop() {
|
|
66
|
+
return this.runtime.stop();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ── Browser control ────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
async goto(url) {
|
|
72
|
+
return this.runtime.goto(url);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async observe() {
|
|
76
|
+
return this.runtime.observe();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async click(id) {
|
|
80
|
+
return this.runtime.click(id);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async type(id, text, options = {}) {
|
|
84
|
+
return this.runtime.type(id, text, options);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async hover(id) {
|
|
88
|
+
return this.runtime.hover(id);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async keypress(key) {
|
|
92
|
+
return this.runtime.keypress(key);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async scroll(direction) {
|
|
96
|
+
return this.runtime.scroll(direction);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async evaluate(expression) {
|
|
100
|
+
return this.runtime.evaluate(expression);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async selectOption(id, values) {
|
|
104
|
+
return this.runtime.selectOption(id, values);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async handleDialog(options = {}) {
|
|
108
|
+
return this.runtime.handleDialog(options);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async goBack() {
|
|
112
|
+
return this.runtime.goBack();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async tabAction(action, options = {}) {
|
|
116
|
+
return this.runtime.tabAction(action, options);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async waitFor(options = {}) {
|
|
120
|
+
return this.runtime.waitFor(options);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async upload(id, options = {}) {
|
|
124
|
+
return this.runtime.upload(id, options);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async drag(fromId, toId) {
|
|
128
|
+
return this.runtime.drag(fromId, toId);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async dragFile(options = {}) {
|
|
132
|
+
return this.runtime.dragFile(options);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ── Autonomous delegation ──────────────────────────────
|
|
136
|
+
|
|
137
|
+
async delegate(taskInstruction, options = {}) {
|
|
138
|
+
return this.subagent.delegateTask(taskInstruction, options);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async verifyProgress(input) {
|
|
142
|
+
return this.subagent.verifyProgress(input);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ── Task orchestration ─────────────────────────────────
|
|
146
|
+
|
|
147
|
+
createRun(taskInstruction, options = {}) {
|
|
148
|
+
return this.taskRunner.createRun(taskInstruction, options);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
createRunFromTemplate(templateId, overrides = {}) {
|
|
152
|
+
return this.taskRunner.createRunFromTemplate(templateId, overrides);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
listRuns(limit = 20) {
|
|
156
|
+
return this.taskRunner.listRuns(limit);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
getRun(id) {
|
|
160
|
+
return this.taskRunner.getRun(id);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
replyToRun(id, instruction) {
|
|
164
|
+
return this.taskRunner.replyToRun(id, instruction);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
resumeRun(id, instruction) {
|
|
168
|
+
return this.taskRunner.resumeRun(id, instruction);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
abortRun(id, reason) {
|
|
172
|
+
return this.taskRunner.abortRun(id, reason);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ── Templates ──────────────────────────────────────────
|
|
176
|
+
|
|
177
|
+
listTemplates(limit = 100) {
|
|
178
|
+
return this.taskRunner.listTemplates(limit);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
getTemplate(id) {
|
|
182
|
+
return this.taskRunner.getTemplate(id);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
saveTemplate(templateInput) {
|
|
186
|
+
return this.taskRunner.saveTemplate(templateInput);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
deleteTemplate(id) {
|
|
190
|
+
return this.taskRunner.deleteTemplate(id);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
compareTemplateRuns(templateId, options = {}) {
|
|
194
|
+
return this.taskRunner.compareTemplateRuns(templateId, options);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ── Diagnostics ────────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
async getCdpHealth(options = {}) {
|
|
200
|
+
return this.runtime.getCdpHealth(options);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async getCdpDiagnostics(options = {}) {
|
|
204
|
+
return this.runtime.getCdpDiagnostics(options);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
getDebugState(limit = 20) {
|
|
208
|
+
return this.runtime.getDebugState(limit);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async auditTextLayout(options = {}) {
|
|
212
|
+
return this.runtime.auditTextLayout(options);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ── Advanced exports ────────────────────────────────────────
|
|
217
|
+
// Direct class access for users who need fine-grained control.
|
|
218
|
+
|
|
219
|
+
export { BrowserRuntime };
|
|
220
|
+
export { BrowserSubagent };
|
|
221
|
+
export { TaskRunner };
|
|
222
|
+
export { ArtifactStore };
|
|
223
|
+
export { clearOverlays, collectInteractableElements, collectPageContent, refreshTarget };
|