@parcha/pi-browser 0.1.0-beta.18 → 0.1.0-beta.20
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/CHANGELOG.md +5 -0
- package/README.md +177 -39
- package/dist/coding-agent-local.js +2 -1
- package/dist/coding-agent.d.ts +42 -2
- package/dist/coding-agent.js +159 -21
- package/dist/core/clip.d.ts +31 -0
- package/dist/core/clip.js +49 -0
- package/dist/core/contract.d.ts +4 -1
- package/dist/core/contract.js +40 -7
- package/dist/core/custody.d.ts +79 -5
- package/dist/core/custody.js +66 -5
- package/dist/core/decisions.d.ts +4 -0
- package/dist/core/dial.d.ts +7 -0
- package/dist/core/dial.js +41 -0
- package/dist/core/downloads.d.ts +1 -0
- package/dist/core/downloads.js +17 -5
- package/dist/core/driving-guard.d.ts +13 -0
- package/dist/core/driving-guard.js +61 -0
- package/dist/core/driving.d.ts +61 -0
- package/dist/core/driving.js +156 -0
- package/dist/core/effects.js +33 -13
- package/dist/core/evidence.d.ts +3 -1
- package/dist/core/failures.d.ts +5 -1
- package/dist/core/failures.js +20 -4
- package/dist/core/files.d.ts +8 -0
- package/dist/core/files.js +74 -0
- package/dist/core/find.d.ts +3 -1
- package/dist/core/find.js +2 -1
- package/dist/core/guard.d.ts +9 -1
- package/dist/core/guard.js +7 -2
- package/dist/core/host.d.ts +49 -1
- package/dist/core/images.d.ts +10 -2
- package/dist/core/images.js +4 -4
- package/dist/core/lease.d.ts +1 -1
- package/dist/core/lease.js +2 -1
- package/dist/core/session-control.d.ts +2 -0
- package/dist/core/session-control.js +5 -0
- package/dist/core/tools.d.ts +70 -4
- package/dist/core/tools.js +288 -45
- package/dist/core/unanswered.d.ts +3 -0
- package/dist/core/unanswered.js +17 -0
- package/dist/core/usage.d.ts +2 -0
- package/dist/core/usage.js +6 -0
- package/dist/core/web.d.ts +1 -1
- package/dist/core/web.js +9 -7
- package/dist/driver/extension-worker.d.ts +4 -2
- package/dist/driver/extension-worker.js +16 -10
- package/dist/driver/page-driver.d.ts +8 -0
- package/dist/driver/page-driver.js +128 -0
- package/dist/driver/stagehand.d.ts +3 -1
- package/dist/driver/stagehand.js +40 -66
- package/dist/durable.d.ts +16 -4
- package/dist/durable.js +415 -82
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/live-view/index.d.ts +4 -0
- package/dist/live-view/index.js +4 -0
- package/dist/live-view/protocol.d.ts +152 -0
- package/dist/live-view/protocol.js +84 -0
- package/dist/live-view/provider.d.ts +6 -0
- package/dist/live-view/provider.js +23 -0
- package/dist/live-view/server.d.ts +50 -0
- package/dist/live-view/server.js +342 -0
- package/dist/live-view/stream.d.ts +7 -0
- package/dist/live-view/stream.js +388 -0
- package/dist/live-view/token.d.ts +6 -0
- package/dist/live-view/token.js +13 -0
- package/dist/live-view/viewer.d.ts +6 -0
- package/dist/live-view/viewer.js +350 -0
- package/dist/live-view/ws.d.ts +19 -0
- package/dist/live-view/ws.js +176 -0
- package/dist/providers/assigned.d.ts +18 -0
- package/dist/providers/assigned.js +76 -0
- package/dist/providers/cdp-call.js +12 -2
- package/dist/providers/cdp.js +37 -11
- package/dist/recorder/follow.d.ts +10 -0
- package/dist/recorder/follow.js +27 -2
- package/dist/recorder/frames.d.ts +7 -0
- package/dist/recorder/frames.js +73 -5
- package/dist/store.d.ts +22 -3
- package/dist/store.js +75 -4
- package/dist/testing/backend.d.ts +26 -0
- package/dist/testing/backend.js +21 -3
- package/dist/testing/driver.d.ts +18 -1
- package/dist/testing/driver.js +4 -0
- package/dist/web.js +2 -2
- package/package.json +10 -2
package/dist/testing/driver.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AttachTarget } from "../core/host.js";
|
|
2
|
-
import { type FakeBackend, type FakeScreenshotOptions, type FixturePage } from "./backend.js";
|
|
2
|
+
import { type FakeBackend, type FakeBox, type FakeScreenshotOptions, type FixturePage } from "./backend.js";
|
|
3
3
|
export type FakeDriver = {
|
|
4
4
|
snapshot(): Promise<string>;
|
|
5
5
|
/** A `goto` action moves the page; any other code returns what it was given. */
|
|
@@ -19,7 +19,24 @@ export type FakeDriver = {
|
|
|
19
19
|
width: number;
|
|
20
20
|
height: number;
|
|
21
21
|
}>;
|
|
22
|
+
/** Where the viewport is, and for an element (by snapshot ID or CSS selector) how many match and the box of the one that does. */
|
|
23
|
+
locate(target?: {
|
|
24
|
+
id?: string;
|
|
25
|
+
selector?: string;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
viewport: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
matches?: number;
|
|
32
|
+
box?: FakeBox | null;
|
|
33
|
+
}>;
|
|
22
34
|
page(): Promise<FixturePage>;
|
|
35
|
+
setInputFiles(selector: string, file: {
|
|
36
|
+
name: string;
|
|
37
|
+
mimeType: string;
|
|
38
|
+
buffer: Uint8Array;
|
|
39
|
+
}): Promise<void>;
|
|
23
40
|
close(): Promise<void>;
|
|
24
41
|
};
|
|
25
42
|
export type FakeDriverFactory = (target: AttachTarget) => Promise<FakeDriver>;
|
package/dist/testing/driver.js
CHANGED
|
@@ -4,7 +4,9 @@ const bind = (face, id) => ({
|
|
|
4
4
|
run: (input) => face.run(id, input),
|
|
5
5
|
url: () => face.url(id),
|
|
6
6
|
screenshot: (options) => face.screenshot(id, options),
|
|
7
|
+
locate: (target) => face.locate(id, target),
|
|
7
8
|
page: () => face.page(id),
|
|
9
|
+
setInputFiles: (selector, file) => face.setInputFiles(id, selector, file),
|
|
8
10
|
close: () => face.close(id),
|
|
9
11
|
});
|
|
10
12
|
export function fakeDriver(b) {
|
|
@@ -25,7 +27,9 @@ export function remoteDriver(url) {
|
|
|
25
27
|
run: (id, input) => rpc("run", [id, input]),
|
|
26
28
|
url: (id) => rpc("url", [id]),
|
|
27
29
|
screenshot: (id, options) => rpc("screenshot", [id, options]),
|
|
30
|
+
locate: (id, target) => rpc("locate", [id, target]),
|
|
28
31
|
page: (id) => rpc("page", [id]),
|
|
32
|
+
setInputFiles: (id, selector, file) => rpc("setInputFiles", [id, selector, { ...file, buffer: Buffer.from(file.buffer).toString("base64") }]),
|
|
29
33
|
close: (id) => rpc("close", [id]),
|
|
30
34
|
};
|
|
31
35
|
return async (target) => bind(face, await face.connect(target));
|
package/dist/web.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineExtension, defineTool } from "@earendil-works/pi-durable";
|
|
2
2
|
import { WEB_TOOLS } from "./core/contract.js";
|
|
3
3
|
import { providerKeyValues } from "./core/session-control.js";
|
|
4
|
+
import { toolUsage } from "./core/usage.js";
|
|
4
5
|
import { createWebTools } from "./core/web.js";
|
|
5
6
|
import { forModel } from "./durable-result.js";
|
|
6
|
-
const usage = (usd) => ({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: usd } });
|
|
7
7
|
export function createWebExtension(options) {
|
|
8
8
|
const tools = createWebTools({
|
|
9
9
|
name: options.providers.name ?? "provider",
|
|
@@ -19,7 +19,7 @@ export function createWebExtension(options) {
|
|
|
19
19
|
pdf: options.pdf,
|
|
20
20
|
});
|
|
21
21
|
const run = { web_fetch: tools.fetch, web_search: tools.search };
|
|
22
|
-
const result = ({ text, isError, details, usd }) => ({ ...forModel([{ type: "text", text }]), isError, details: details, usage:
|
|
22
|
+
const result = ({ text, isError, details, usd }) => ({ ...forModel([{ type: "text", text }]), isError, details: details, usage: toolUsage(usd).usage });
|
|
23
23
|
const registrations = WEB_TOOLS
|
|
24
24
|
.filter((tool) => (tool.listedWhen === "fetch" ? options.providers.fetch || options.render?.enabled || options.backups?.length : options.providers.search))
|
|
25
25
|
.map((tool) => defineTool({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/pi-browser",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-beta.20",
|
|
4
|
+
"description": "Your agent gets its own browser, and you can take over and hand it back.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
7
7
|
"pi-durable",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"types": "./dist/recorder/index.d.ts",
|
|
29
29
|
"import": "./dist/recorder/index.js"
|
|
30
30
|
},
|
|
31
|
+
"./live-view": {
|
|
32
|
+
"types": "./dist/live-view/index.d.ts",
|
|
33
|
+
"import": "./dist/live-view/index.js"
|
|
34
|
+
},
|
|
31
35
|
"./providers/browserbase": {
|
|
32
36
|
"types": "./dist/providers/browserbase.d.ts",
|
|
33
37
|
"import": "./dist/providers/browserbase.js"
|
|
@@ -36,6 +40,10 @@
|
|
|
36
40
|
"types": "./dist/providers/cdp.d.ts",
|
|
37
41
|
"import": "./dist/providers/cdp.js"
|
|
38
42
|
},
|
|
43
|
+
"./providers/assigned": {
|
|
44
|
+
"types": "./dist/providers/assigned.d.ts",
|
|
45
|
+
"import": "./dist/providers/assigned.js"
|
|
46
|
+
},
|
|
39
47
|
"./providers/kernel": {
|
|
40
48
|
"types": "./dist/providers/kernel.d.ts",
|
|
41
49
|
"import": "./dist/providers/kernel.js"
|