bashirweb 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/backend.d.ts +33 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +166 -0
- package/dist/backend.js.map +1 -0
- package/dist/bashirweb.d.ts +249 -0
- package/dist/bashirweb.d.ts.map +1 -0
- package/dist/bashirweb.js +470 -0
- package/dist/bashirweb.js.map +1 -0
- package/dist/browser-console.d.ts +42 -0
- package/dist/browser-console.d.ts.map +1 -0
- package/dist/browser-console.js +51 -0
- package/dist/browser-console.js.map +1 -0
- package/dist/browser-operator.d.ts +134 -0
- package/dist/browser-operator.d.ts.map +1 -0
- package/dist/browser-operator.js +253 -0
- package/dist/browser-operator.js.map +1 -0
- package/dist/browser-tools.d.ts +24 -0
- package/dist/browser-tools.d.ts.map +1 -0
- package/dist/browser-tools.js +316 -0
- package/dist/browser-tools.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +598 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/local.d.ts +61 -0
- package/dist/local.d.ts.map +1 -0
- package/dist/local.js +200 -0
- package/dist/local.js.map +1 -0
- package/dist/page-actions.d.ts +11 -0
- package/dist/page-actions.d.ts.map +1 -0
- package/dist/page-actions.js +146 -0
- package/dist/page-actions.js.map +1 -0
- package/dist/remote.d.ts +260 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +299 -0
- package/dist/remote.js.map +1 -0
- package/dist/serve.d.ts +21 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/serve.js +79 -0
- package/dist/serve.js.map +1 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +439 -0
- package/dist/tools.js.map +1 -0
- package/dist/trace-viewer.d.ts +17 -0
- package/dist/trace-viewer.d.ts.map +1 -0
- package/dist/trace-viewer.js +235 -0
- package/dist/trace-viewer.js.map +1 -0
- package/dist/workflow-host.d.ts +20 -0
- package/dist/workflow-host.d.ts.map +1 -0
- package/dist/workflow-host.js +216 -0
- package/dist/workflow-host.js.map +1 -0
- package/package.json +53 -3
- package/README.md +0 -3
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { ConfigurationError, EventBus, REDACTED, redactUrl, VERSION, configFromEnv, findConfigFile, loadConfigFile, resolveConfig, } from '@dream_engine/core';
|
|
2
|
+
import { loginTo } from '@dream_engine/browser';
|
|
3
|
+
import { McpServer, AgentEngine, TaskStore, createLocalModel, ResourceRegistry, PromptRegistry, } from '@dream_engine/agent';
|
|
4
|
+
import { validateWorkflow } from '@dream_engine/workflow';
|
|
5
|
+
import { LocalRuntime } from './local.js';
|
|
6
|
+
import { RemoteClient, RemotePage, RemoteSession } from './remote.js';
|
|
7
|
+
import { createAgentTools } from './tools.js';
|
|
8
|
+
/**
|
|
9
|
+
* The BashirWeb SDK entry point. One API for local and remote runtimes.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const bw = await new BashirWeb().initialize();
|
|
13
|
+
* const page = await bw.open('https://example.com');
|
|
14
|
+
* await page.smart.click('More information');
|
|
15
|
+
* await bw.shutdown();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class BashirWeb {
|
|
19
|
+
options;
|
|
20
|
+
events = new EventBus();
|
|
21
|
+
config = null;
|
|
22
|
+
localRuntime = null;
|
|
23
|
+
remote = null;
|
|
24
|
+
toolRegistry = null;
|
|
25
|
+
initializing = null;
|
|
26
|
+
openRemotePages = new Set();
|
|
27
|
+
aiClient = null;
|
|
28
|
+
agentEngineInstance = null;
|
|
29
|
+
constructor(options = {}) {
|
|
30
|
+
this.options = options;
|
|
31
|
+
}
|
|
32
|
+
/** Resolves configuration and prepares the runtime. Safe to call more than once. */
|
|
33
|
+
initialize() {
|
|
34
|
+
this.initializing ??= this.doInitialize().catch((error) => {
|
|
35
|
+
this.initializing = null;
|
|
36
|
+
throw error;
|
|
37
|
+
});
|
|
38
|
+
return this.initializing;
|
|
39
|
+
}
|
|
40
|
+
async doInitialize() {
|
|
41
|
+
const o = this.options;
|
|
42
|
+
const file = o.configFile === false ? undefined : (o.configFile ?? findConfigFile());
|
|
43
|
+
const fileConfig = file ? await loadConfigFile(file) : undefined;
|
|
44
|
+
const runtimeLayer = {
|
|
45
|
+
runtime: { ...(o.runtime ? { mode: o.runtime } : {}), ...(o.endpoint ? { endpoint: o.endpoint } : {}), ...(o.token ? { token: o.token } : {}) },
|
|
46
|
+
};
|
|
47
|
+
this.config = resolveConfig(fileConfig, o.env === false ? undefined : configFromEnv(), o.config, runtimeLayer);
|
|
48
|
+
if (this.config.runtime.mode === 'remote') {
|
|
49
|
+
this.remote = new RemoteClient(this.config.runtime.endpoint, this.config.runtime.token);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.localRuntime = new LocalRuntime({
|
|
53
|
+
config: this.config,
|
|
54
|
+
events: this.events,
|
|
55
|
+
...(o.logger ? { logger: o.logger } : {}),
|
|
56
|
+
...(o.approvalHandler ? { approvalHandler: o.approvalHandler } : {}),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
ready() {
|
|
62
|
+
if (!this.config)
|
|
63
|
+
throw new ConfigurationError('BashirWeb is not initialized; call `await bw.initialize()` first');
|
|
64
|
+
return this.config;
|
|
65
|
+
}
|
|
66
|
+
get runtime() {
|
|
67
|
+
return this.ready().runtime.mode;
|
|
68
|
+
}
|
|
69
|
+
/** The full local runtime (browser manager, sessions, search service, workflow engine). Local runtime only. */
|
|
70
|
+
get local() {
|
|
71
|
+
this.ready();
|
|
72
|
+
if (!this.localRuntime)
|
|
73
|
+
throw new ConfigurationError('This feature is only available with runtime "local"');
|
|
74
|
+
return this.localRuntime;
|
|
75
|
+
}
|
|
76
|
+
get client() {
|
|
77
|
+
this.ready();
|
|
78
|
+
if (!this.remote)
|
|
79
|
+
throw new ConfigurationError('Not a remote runtime');
|
|
80
|
+
return this.remote;
|
|
81
|
+
}
|
|
82
|
+
/** Resolved configuration with secrets redacted. */
|
|
83
|
+
getConfig() {
|
|
84
|
+
const c = structuredClone(this.ready());
|
|
85
|
+
if (c.runtime.token)
|
|
86
|
+
c.runtime.token = REDACTED;
|
|
87
|
+
c.server.tokens = c.server.tokens.map(() => REDACTED);
|
|
88
|
+
// Credentials embedded in any URL value (search.postgresUrl, endpoints, source URLs).
|
|
89
|
+
const scrub = (v) => {
|
|
90
|
+
if (typeof v === 'string')
|
|
91
|
+
return /^[a-z][a-z0-9+.-]*:\/\//i.test(v) ? redactUrl(v) : v;
|
|
92
|
+
if (Array.isArray(v))
|
|
93
|
+
return v.map(scrub);
|
|
94
|
+
if (v && typeof v === 'object') {
|
|
95
|
+
for (const [k, x] of Object.entries(v))
|
|
96
|
+
v[k] = scrub(x);
|
|
97
|
+
}
|
|
98
|
+
return v;
|
|
99
|
+
};
|
|
100
|
+
return scrub(c);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Optional local model client (Ollama / OpenAI-compatible server you run yourself).
|
|
104
|
+
* Throws ConfigurationError unless `ai.enabled` is true. Nothing else in BashirWeb requires it.
|
|
105
|
+
* The bearer token for OpenAI-compatible servers is read from BASHIRWEB_AI_API_KEY (never from config files).
|
|
106
|
+
*/
|
|
107
|
+
get ai() {
|
|
108
|
+
const config = this.ready();
|
|
109
|
+
if (!this.aiClient) {
|
|
110
|
+
const apiKey = process.env.BASHIRWEB_AI_API_KEY;
|
|
111
|
+
this.aiClient = createLocalModel(config.ai, apiKey ? { apiKey } : {});
|
|
112
|
+
if (!this.aiClient)
|
|
113
|
+
throw new ConfigurationError('AI is disabled. Set ai.enabled, ai.provider and ai.model to use a local model (optional).');
|
|
114
|
+
}
|
|
115
|
+
return this.aiClient;
|
|
116
|
+
}
|
|
117
|
+
getVersion() {
|
|
118
|
+
return VERSION;
|
|
119
|
+
}
|
|
120
|
+
async health() {
|
|
121
|
+
this.ready();
|
|
122
|
+
if (this.remote) {
|
|
123
|
+
const h = await this.remote.request('GET', 'health');
|
|
124
|
+
return { status: h.status, runtime: 'remote', version: VERSION, checks: { ...h.checks, serverVersion: h.version } };
|
|
125
|
+
}
|
|
126
|
+
const h = await this.local.health();
|
|
127
|
+
return { ...h, runtime: 'local', version: VERSION };
|
|
128
|
+
}
|
|
129
|
+
/** Searches the local index and/or configured sources. */
|
|
130
|
+
async search(query, options = {}) {
|
|
131
|
+
this.ready();
|
|
132
|
+
if (this.remote) {
|
|
133
|
+
const { signal, ...rest } = options;
|
|
134
|
+
return this.remote.request('POST', 'v1/search', { query, ...rest }, signal);
|
|
135
|
+
}
|
|
136
|
+
return this.local.search.search(query, options);
|
|
137
|
+
}
|
|
138
|
+
/** Returns query suggestions derived from recent search history. */
|
|
139
|
+
async suggest(prefix, limit = 8) {
|
|
140
|
+
this.ready();
|
|
141
|
+
if (this.remote)
|
|
142
|
+
return this.remote.request('GET', 'v1/search/suggest', { prefix, limit });
|
|
143
|
+
return this.local.search.suggest(prefix, limit);
|
|
144
|
+
}
|
|
145
|
+
/** Returns recent search history (most recent first). */
|
|
146
|
+
async searchHistory(limit = 20) {
|
|
147
|
+
this.ready();
|
|
148
|
+
if (this.remote)
|
|
149
|
+
return this.remote.request('GET', 'v1/search/history', { limit });
|
|
150
|
+
return this.local.search.searchHistory(limit);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Fetches a URL and extracts its content (title, text, Markdown, metadata, tables, links, JSON-LD...).
|
|
154
|
+
* Plain HTTP by default (network policy and robots.txt apply); `render: true` loads it in the browser first.
|
|
155
|
+
*/
|
|
156
|
+
async extract(url, options = {}) {
|
|
157
|
+
this.ready();
|
|
158
|
+
if (this.remote) {
|
|
159
|
+
const { fetch: _meta, ...doc } = await this.remote.request('POST', 'v1/extract', { url, format: 'json', ...(options.render ? { render: true } : {}) }, options.signal);
|
|
160
|
+
return doc;
|
|
161
|
+
}
|
|
162
|
+
if (options.render) {
|
|
163
|
+
const page = await this.local.openPage(url);
|
|
164
|
+
try {
|
|
165
|
+
return await page.extract({ format: 'json' });
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
await page.close();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return (await this.local.search.fetchDocument(url, options.signal ? { signal: options.signal } : {})).document;
|
|
172
|
+
}
|
|
173
|
+
/** Crawls and indexes pages, resolving with the crawl report. */
|
|
174
|
+
async crawl(options) {
|
|
175
|
+
this.ready();
|
|
176
|
+
if (this.remote) {
|
|
177
|
+
const { signal, onPage, respectRobots: _r, ...rest } = options;
|
|
178
|
+
if (onPage)
|
|
179
|
+
throw new ConfigurationError('onPage callbacks are not supported with the remote runtime');
|
|
180
|
+
const job = await this.remote.request('POST', 'v1/crawl', rest, signal);
|
|
181
|
+
return this.remote.waitForJob(job.id, signal);
|
|
182
|
+
}
|
|
183
|
+
return this.local.search.crawl(options).done;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Starts a crawl and returns the running {@link CrawlJob} immediately, so you can
|
|
187
|
+
* `pause()`/`resume()` it at a page boundary or `cancel()` it early. Await `job.done`
|
|
188
|
+
* for the final report. Local runtime only (the remote runtime streams progress over WebSocket).
|
|
189
|
+
*/
|
|
190
|
+
startCrawl(options) {
|
|
191
|
+
this.ready();
|
|
192
|
+
if (this.remote)
|
|
193
|
+
throw new ConfigurationError('startCrawl is not available with the remote runtime; use crawl() or the WebSocket progress stream');
|
|
194
|
+
return this.local.search.crawler.start(options);
|
|
195
|
+
}
|
|
196
|
+
/** Opens a page (optionally navigating to `url`). Close it with `page.close()`. */
|
|
197
|
+
async open(url, options = {}) {
|
|
198
|
+
this.ready();
|
|
199
|
+
if (this.remote) {
|
|
200
|
+
const client = this.remote;
|
|
201
|
+
let session;
|
|
202
|
+
let owned = false;
|
|
203
|
+
if (options.session)
|
|
204
|
+
session = new RemoteSession(client, options.session, {});
|
|
205
|
+
else {
|
|
206
|
+
const info = await client.request('POST', 'v1/sessions', {});
|
|
207
|
+
session = new RemoteSession(client, info.id, info);
|
|
208
|
+
owned = true;
|
|
209
|
+
}
|
|
210
|
+
const created = await client.request('POST', `v1/sessions/${encodeURIComponent(session.id)}/pages`, url ? { url } : {});
|
|
211
|
+
const page = new RemotePage(client, session.id, created.pageId, async () => {
|
|
212
|
+
this.openRemotePages.delete(page);
|
|
213
|
+
if (owned)
|
|
214
|
+
await session.destroy().catch(() => undefined);
|
|
215
|
+
});
|
|
216
|
+
this.openRemotePages.add(page);
|
|
217
|
+
return page;
|
|
218
|
+
}
|
|
219
|
+
return this.local.openPage(url, options);
|
|
220
|
+
}
|
|
221
|
+
/** Opens a full-featured local page (all BashirPage APIs). Local runtime only. */
|
|
222
|
+
openPage(url, options = {}) {
|
|
223
|
+
return this.local.openPage(url, options);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Logs into a site using credentials you authorise, in a session. Local runtime only.
|
|
227
|
+
*
|
|
228
|
+
* Opens a page (in the given session or a fresh context), fills the login form with the
|
|
229
|
+
* supplied credentials, submits it, and waits for the login to complete. If a CAPTCHA
|
|
230
|
+
* challenge is detected, it is handed to `options.onCaptcha` — you solve it in the browser
|
|
231
|
+
* — and the login continues. BashirWeb never solves CAPTCHAs automatically.
|
|
232
|
+
*
|
|
233
|
+
* The authenticated session (cookies and storage) is retained on the returned page, so you
|
|
234
|
+
* can continue using it as the logged-in user.
|
|
235
|
+
*
|
|
236
|
+
* @returns the login result and the authenticated page for further use.
|
|
237
|
+
*/
|
|
238
|
+
async login(options) {
|
|
239
|
+
const { session, ...loginOptions } = options;
|
|
240
|
+
const page = await this.openPage(undefined, session ? { session } : {});
|
|
241
|
+
const result = await loginTo(page, loginOptions);
|
|
242
|
+
return { result, page };
|
|
243
|
+
}
|
|
244
|
+
/** Browser management (local runtime only). */
|
|
245
|
+
get browser() {
|
|
246
|
+
const m = this.local.browsers;
|
|
247
|
+
return {
|
|
248
|
+
launch: (c) => m.launch(c),
|
|
249
|
+
launchPersistent: (dir, c) => m.launchPersistent(dir, c),
|
|
250
|
+
connect: (e) => m.connect(e),
|
|
251
|
+
list: () => m.list(),
|
|
252
|
+
devices: () => m.devices(),
|
|
253
|
+
device: (n) => m.device(n),
|
|
254
|
+
newApiRequest: (o) => m.newApiRequest(o),
|
|
255
|
+
closeAll: () => m.closeAll(),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Files BashirWeb wrote under the data directory (downloads, screenshots, traces, HAR, videos, PDFs,
|
|
260
|
+
* coverage, storage states): list, stats, delete and prune by `artifacts.*` retention and quotas.
|
|
261
|
+
* Local runtime only.
|
|
262
|
+
*/
|
|
263
|
+
get artifacts() {
|
|
264
|
+
const a = this.local.services.artifacts;
|
|
265
|
+
if (!a)
|
|
266
|
+
throw new ConfigurationError('Artifact management is not available');
|
|
267
|
+
return a;
|
|
268
|
+
}
|
|
269
|
+
/** Connects to an existing browser over CDP/WebSocket. Local runtime only. */
|
|
270
|
+
connect(endpoint) {
|
|
271
|
+
return this.local.browsers.connect(endpoint);
|
|
272
|
+
}
|
|
273
|
+
/** Session management. */
|
|
274
|
+
get sessions() {
|
|
275
|
+
const self = this;
|
|
276
|
+
return {
|
|
277
|
+
async create(options = {}) {
|
|
278
|
+
self.ready();
|
|
279
|
+
if (self.remote) {
|
|
280
|
+
const info = await self.remote.request('POST', 'v1/sessions', {
|
|
281
|
+
...(options.name ? { name: options.name } : {}),
|
|
282
|
+
...(options.ttl ? { ttl: options.ttl } : {}),
|
|
283
|
+
...(options.idleTimeout ? { idleTimeout: options.idleTimeout } : {}),
|
|
284
|
+
});
|
|
285
|
+
return new RemoteSession(self.remote, info.id, info);
|
|
286
|
+
}
|
|
287
|
+
return self.local.sessions.create(options);
|
|
288
|
+
},
|
|
289
|
+
async list() {
|
|
290
|
+
self.ready();
|
|
291
|
+
if (self.remote)
|
|
292
|
+
return (await self.remote.request('GET', 'v1/sessions')).sessions;
|
|
293
|
+
return self.local.sessions.list();
|
|
294
|
+
},
|
|
295
|
+
async destroy(id) {
|
|
296
|
+
self.ready();
|
|
297
|
+
if (self.remote)
|
|
298
|
+
await self.remote.request('DELETE', `v1/sessions/${encodeURIComponent(id)}`);
|
|
299
|
+
else
|
|
300
|
+
await self.local.sessions.destroy(id);
|
|
301
|
+
},
|
|
302
|
+
/** Persists storage state (cookies, localStorage). Local runtime only. */
|
|
303
|
+
save: (id) => self.local.sessions.save(id),
|
|
304
|
+
/** Restores a saved session. Local runtime only. */
|
|
305
|
+
restore: (id, options) => self.local.sessions.restore(id, options),
|
|
306
|
+
listSaved: () => self.local.sessions.listSaved(),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/** Workflow management and execution. */
|
|
310
|
+
get workflows() {
|
|
311
|
+
const self = this;
|
|
312
|
+
return {
|
|
313
|
+
validate: (definition) => validateWorkflow(definition),
|
|
314
|
+
async run(workflow, options = {}) {
|
|
315
|
+
self.ready();
|
|
316
|
+
if (self.remote) {
|
|
317
|
+
const { signal, session, inputs } = options;
|
|
318
|
+
const job = await self.remote.request('POST', 'v1/workflows/run', { ...(typeof workflow === 'string' ? { id: workflow } : { definition: workflow }), ...(inputs ? { inputs } : {}), ...(session ? { session } : {}) }, signal);
|
|
319
|
+
return self.remote.waitForJob(job.id, signal);
|
|
320
|
+
}
|
|
321
|
+
const { run } = await self.local.startWorkflow(workflow, options);
|
|
322
|
+
return run.done;
|
|
323
|
+
},
|
|
324
|
+
/** Starts a run and returns a handle with `cancel()` and `done`. Local runtime only. */
|
|
325
|
+
start: async (workflow, options = {}) => (await self.local.startWorkflow(workflow, options)).run,
|
|
326
|
+
resume: (runId, options = {}) => self.local.resumeWorkflow(runId, options),
|
|
327
|
+
save: (definition) => self.local.workflows.save(definition),
|
|
328
|
+
get: (id, version) => self.local.workflows.get(id, version),
|
|
329
|
+
list: () => self.local.workflows.list(),
|
|
330
|
+
versions: (id) => self.local.workflows.versions(id),
|
|
331
|
+
delete: (id) => self.local.workflows.delete(id),
|
|
332
|
+
export: (id, version) => self.local.workflows.export(id, version),
|
|
333
|
+
import: (json) => self.local.workflows.import(json),
|
|
334
|
+
history: (options) => self.local.workflows.history(options),
|
|
335
|
+
getRun: (runId) => self.local.workflows.getRun(runId),
|
|
336
|
+
cancel: (runId) => self.local.workflows.cancel(runId),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/** Local search index management (local runtime only). */
|
|
340
|
+
get index() {
|
|
341
|
+
const svc = () => this.local.search;
|
|
342
|
+
return {
|
|
343
|
+
addUrl: (url, options) => svc().indexUrl(url, options),
|
|
344
|
+
addHtml: (html, url) => svc().indexHtml(html, url),
|
|
345
|
+
query: (query, options) => svc().index.query(query, options),
|
|
346
|
+
remove: (url) => svc().index.remove(url),
|
|
347
|
+
stats: () => svc().stats(),
|
|
348
|
+
crawlHistory: (limit) => svc().history(limit),
|
|
349
|
+
clearCache: () => svc().clearCache(),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
/** Agent tools with structured results (local: executed in-process; remote: executed by the server). */
|
|
353
|
+
get agent() {
|
|
354
|
+
const self = this;
|
|
355
|
+
return {
|
|
356
|
+
async listTools() {
|
|
357
|
+
self.ready();
|
|
358
|
+
if (self.remote)
|
|
359
|
+
return (await self.remote.request('GET', 'v1/tools')).tools;
|
|
360
|
+
return self.tools().list();
|
|
361
|
+
},
|
|
362
|
+
async call(name, args = {}, signal) {
|
|
363
|
+
self.ready();
|
|
364
|
+
if (self.remote)
|
|
365
|
+
return self.remote.request('POST', `v1/tools/${encodeURIComponent(name)}`, args, signal);
|
|
366
|
+
return self.tools().call(name, args, signal ? { signal } : {});
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/** The local agent tool registry. Local runtime only. */
|
|
371
|
+
tools() {
|
|
372
|
+
this.toolRegistry ??= createAgentTools(this.local);
|
|
373
|
+
return this.toolRegistry;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The agent engine (Phase 10): plans goals into tool-call sequences, executes them
|
|
377
|
+
* with persisted task state, supports resume after interruption, and records an
|
|
378
|
+
* audit log. Tasks are persisted under `dataDir/agent` so they survive restarts.
|
|
379
|
+
* Local runtime only.
|
|
380
|
+
*/
|
|
381
|
+
agentEngine() {
|
|
382
|
+
this.ready();
|
|
383
|
+
this.agentEngineInstance ??= new AgentEngine(this.tools(), new TaskStore(this.local.paths.agent));
|
|
384
|
+
return this.agentEngineInstance;
|
|
385
|
+
}
|
|
386
|
+
/** An MCP server exposing the agent tools, resources and prompts (serve over stdio with `.serve()`). Local runtime only. */
|
|
387
|
+
mcp() {
|
|
388
|
+
const config = this.ready();
|
|
389
|
+
const resources = this.mcpResources();
|
|
390
|
+
const prompts = this.mcpPrompts();
|
|
391
|
+
return new McpServer(this.tools(), {
|
|
392
|
+
name: 'bashirweb',
|
|
393
|
+
version: VERSION,
|
|
394
|
+
instructions: 'BashirWeb browser automation and web search tools. Describe elements by their visible label or role.',
|
|
395
|
+
resources,
|
|
396
|
+
prompts,
|
|
397
|
+
authToken: config.mcp.authToken,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
/** Built-in MCP resources: runtime status and search-index statistics. */
|
|
401
|
+
mcpResources() {
|
|
402
|
+
const registry = new ResourceRegistry();
|
|
403
|
+
registry.register({ uri: 'bashirweb://version', name: 'version', description: 'BashirWeb version and runtime mode.', mimeType: 'text/markdown' }, () => ({
|
|
404
|
+
uri: 'bashirweb://version',
|
|
405
|
+
mimeType: 'text/markdown',
|
|
406
|
+
text: `# BashirWeb\n\n- **Version:** ${VERSION}\n- **Runtime:** ${this.localRuntime ? 'local' : 'remote'}\n`,
|
|
407
|
+
}));
|
|
408
|
+
registry.register({ uri: 'bashirweb://health', name: 'health', description: 'Current health status and runtime checks.', mimeType: 'text/markdown' }, async () => {
|
|
409
|
+
const h = await this.health();
|
|
410
|
+
const lines = Object.entries(h.checks).map(([k, v]) => `- **${k}:** ${JSON.stringify(v)}`);
|
|
411
|
+
return {
|
|
412
|
+
uri: 'bashirweb://health',
|
|
413
|
+
mimeType: 'text/markdown',
|
|
414
|
+
text: `# Health\n\n**Status:** ${h.status} (${h.runtime})\n\n${lines.join('\n')}`,
|
|
415
|
+
};
|
|
416
|
+
});
|
|
417
|
+
registry.register({ uri: 'bashirweb://index/stats', name: 'index-stats', description: 'Search index statistics.', mimeType: 'application/json' }, async () => ({ uri: 'bashirweb://index/stats', mimeType: 'application/json', text: JSON.stringify(await this.local.search.stats(), null, 2) }));
|
|
418
|
+
return registry;
|
|
419
|
+
}
|
|
420
|
+
/** Built-in MCP prompts: reusable task templates for the agent. */
|
|
421
|
+
mcpPrompts() {
|
|
422
|
+
const registry = new PromptRegistry();
|
|
423
|
+
registry.register({
|
|
424
|
+
name: 'summarize',
|
|
425
|
+
description: 'Summarise a web page or search result set.',
|
|
426
|
+
arguments: [{ name: 'topic', description: 'What to summarise.', required: true }],
|
|
427
|
+
}, (args) => [
|
|
428
|
+
{
|
|
429
|
+
role: 'user',
|
|
430
|
+
content: {
|
|
431
|
+
type: 'text',
|
|
432
|
+
text: `Use the available web_search and web_extract tools to gather information about "${args.topic}". Then produce a concise, factual summary with sources.`,
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
]);
|
|
436
|
+
registry.register({
|
|
437
|
+
name: 'compare',
|
|
438
|
+
description: 'Compare two topics using search results.',
|
|
439
|
+
arguments: [
|
|
440
|
+
{ name: 'a', description: 'First topic.', required: true },
|
|
441
|
+
{ name: 'b', description: 'Second topic.', required: true },
|
|
442
|
+
],
|
|
443
|
+
}, (args) => [
|
|
444
|
+
{
|
|
445
|
+
role: 'user',
|
|
446
|
+
content: {
|
|
447
|
+
type: 'text',
|
|
448
|
+
text: `Compare "${args.a}" and "${args.b}". Use web_search to find information on both, then produce a structured comparison highlighting key differences and similarities.`,
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
]);
|
|
452
|
+
return registry;
|
|
453
|
+
}
|
|
454
|
+
/** Closes browsers, sessions and databases. */
|
|
455
|
+
async shutdown() {
|
|
456
|
+
for (const p of [...this.openRemotePages])
|
|
457
|
+
await p.close().catch(() => undefined);
|
|
458
|
+
await this.localRuntime?.close();
|
|
459
|
+
this.localRuntime = null;
|
|
460
|
+
this.remote = null;
|
|
461
|
+
this.config = null;
|
|
462
|
+
this.toolRegistry = null;
|
|
463
|
+
this.initializing = null;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/** Creates and initializes a BashirWeb instance. */
|
|
467
|
+
export async function createBashirWeb(options = {}) {
|
|
468
|
+
return new BashirWeb(options).initialize();
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=bashirweb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bashirweb.js","sourceRoot":"","sources":["../src/bashirweb.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,aAAa,EACb,cAAc,EACd,cAAc,EACd,aAAa,GAId,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAiBhD,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,gBAAgB,EAKhB,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;A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,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;CACF;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAA4B,EAAE;IAClE,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { serializeError, type SerializedError } from '@dream_engine/core';
|
|
2
|
+
import type { AgentTask } from '@dream_engine/agent';
|
|
3
|
+
/**
|
|
4
|
+
* A live console for the Agent 1 browser operator. Receives step events and
|
|
5
|
+
* renders them as a streaming text log. Each entry records the step index, tool,
|
|
6
|
+
* status, reasoning, and a short summary.
|
|
7
|
+
*
|
|
8
|
+
* The console never logs secrets — tool arguments and results are summarised
|
|
9
|
+
* rather than dumped verbatim.
|
|
10
|
+
*/
|
|
11
|
+
export interface ConsoleEntry {
|
|
12
|
+
index: number;
|
|
13
|
+
tool: string;
|
|
14
|
+
status: 'ok' | 'failed' | 'skipped';
|
|
15
|
+
reasoning: string;
|
|
16
|
+
summary: string;
|
|
17
|
+
at: string;
|
|
18
|
+
}
|
|
19
|
+
export type ConsoleSink = (line: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Collects and formats step events from the browser operator into a readable
|
|
22
|
+
* console stream. Can be wired to any text sink (stdout, a web UI, a file).
|
|
23
|
+
*/
|
|
24
|
+
export declare class BrowserConsole {
|
|
25
|
+
private log;
|
|
26
|
+
private sink?;
|
|
27
|
+
constructor(sink?: ConsoleSink);
|
|
28
|
+
/** Attaches a text sink for live output. */
|
|
29
|
+
onOutput(sink: ConsoleSink): void;
|
|
30
|
+
/** Records a step event and emits a formatted line. */
|
|
31
|
+
record(index: number, tool: string, status: 'ok' | 'failed' | 'skipped', reasoning: string, summary: string): void;
|
|
32
|
+
/** Records a task-level event (start, pause, resume, complete, fail). */
|
|
33
|
+
taskEvent(task: AgentTask, message: string): void;
|
|
34
|
+
/** Returns all recorded entries. */
|
|
35
|
+
get entries(): readonly ConsoleEntry[];
|
|
36
|
+
/** Clears all recorded entries. */
|
|
37
|
+
clear(): void;
|
|
38
|
+
/** Renders the full console as a single text block. */
|
|
39
|
+
render(): string;
|
|
40
|
+
}
|
|
41
|
+
export { serializeError, type SerializedError };
|
|
42
|
+
//# sourceMappingURL=browser-console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-console.d.ts","sourceRoot":"","sources":["../src/browser-console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;;GAOG;AAEH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAEjD;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,IAAI,CAAC,CAAc;gBAEf,IAAI,CAAC,EAAE,WAAW;IAI9B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAIjC,uDAAuD;IACvD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAWlH,yEAAyE;IACzE,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAKjD,oCAAoC;IACpC,IAAI,OAAO,IAAI,SAAS,YAAY,EAAE,CAErC;IAED,mCAAmC;IACnC,KAAK,IAAI,IAAI;IAIb,uDAAuD;IACvD,MAAM,IAAI,MAAM;CAQjB;AAED,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { serializeError } from '@dream_engine/core';
|
|
2
|
+
/**
|
|
3
|
+
* Collects and formats step events from the browser operator into a readable
|
|
4
|
+
* console stream. Can be wired to any text sink (stdout, a web UI, a file).
|
|
5
|
+
*/
|
|
6
|
+
export class BrowserConsole {
|
|
7
|
+
log = [];
|
|
8
|
+
sink;
|
|
9
|
+
constructor(sink) {
|
|
10
|
+
this.sink = sink;
|
|
11
|
+
}
|
|
12
|
+
/** Attaches a text sink for live output. */
|
|
13
|
+
onOutput(sink) {
|
|
14
|
+
this.sink = sink;
|
|
15
|
+
}
|
|
16
|
+
/** Records a step event and emits a formatted line. */
|
|
17
|
+
record(index, tool, status, reasoning, summary) {
|
|
18
|
+
const entry = { index, tool, status, reasoning, summary, at: new Date().toISOString() };
|
|
19
|
+
this.log.push(entry);
|
|
20
|
+
const symbol = status === 'ok' ? '✓' : status === 'failed' ? '✗' : '·';
|
|
21
|
+
const line = `[${entry.at}] ${symbol} step ${index}: ${tool} — ${summary}`;
|
|
22
|
+
if (reasoning) {
|
|
23
|
+
this.sink?.(` ↳ ${reasoning.slice(0, 120)}`);
|
|
24
|
+
}
|
|
25
|
+
this.sink?.(line);
|
|
26
|
+
}
|
|
27
|
+
/** Records a task-level event (start, pause, resume, complete, fail). */
|
|
28
|
+
taskEvent(task, message) {
|
|
29
|
+
const symbol = task.status === 'completed' ? '✓' : task.status === 'paused' ? '⏸' : task.status === 'failed' ? '✗' : task.status === 'cancelled' ? '✕' : '→';
|
|
30
|
+
this.sink?.(`[${new Date().toISOString()}] ${symbol} [${task.id}] ${task.status}: ${message}`);
|
|
31
|
+
}
|
|
32
|
+
/** Returns all recorded entries. */
|
|
33
|
+
get entries() {
|
|
34
|
+
return [...this.log];
|
|
35
|
+
}
|
|
36
|
+
/** Clears all recorded entries. */
|
|
37
|
+
clear() {
|
|
38
|
+
this.log = [];
|
|
39
|
+
}
|
|
40
|
+
/** Renders the full console as a single text block. */
|
|
41
|
+
render() {
|
|
42
|
+
return this.log
|
|
43
|
+
.map((e) => {
|
|
44
|
+
const symbol = e.status === 'ok' ? '✓' : e.status === 'failed' ? '✗' : '·';
|
|
45
|
+
return `[${e.at}] ${symbol} step ${e.index}: ${e.tool} — ${e.summary}`;
|
|
46
|
+
})
|
|
47
|
+
.join('\n');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export { serializeError };
|
|
51
|
+
//# sourceMappingURL=browser-console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-console.js","sourceRoot":"","sources":["../src/browser-console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAwB,MAAM,oBAAoB,CAAC;AAuB1E;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,GAAG,GAAmB,EAAE,CAAC;IACzB,IAAI,CAAe;IAE3B,YAAY,IAAkB;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,4CAA4C;IAC5C,QAAQ,CAAC,IAAiB;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,uDAAuD;IACvD,MAAM,CAAC,KAAa,EAAE,IAAY,EAAE,MAAmC,EAAE,SAAiB,EAAE,OAAe;QACzG,MAAM,KAAK,GAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW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