fastbrowse 0.0.0 → 0.5.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/LICENSE +21 -0
- package/README.md +48 -1
- package/dist/abort.d.ts +8 -0
- package/dist/abort.js +29 -0
- package/dist/binary.d.ts +14 -0
- package/dist/binary.js +58 -0
- package/dist/callbacks.d.ts +16 -0
- package/dist/callbacks.js +103 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.js +40 -0
- package/dist/fastbrowse.d.ts +51 -0
- package/dist/fastbrowse.js +118 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/output.d.ts +76 -0
- package/dist/output.js +57 -0
- package/dist/protocol.d.ts +395 -0
- package/dist/protocol.js +26 -0
- package/dist/rpc.d.ts +18 -0
- package/dist/rpc.js +104 -0
- package/dist/run.d.ts +91 -0
- package/dist/run.js +63 -0
- package/package.json +33 -4
package/dist/run.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// What a caller passes to `run`, and the `run` request it becomes. Options are camelCase, and the wire keeps the
|
|
2
|
+
// Python models' snake_case names.
|
|
3
|
+
import { wireSchema } from './output.js';
|
|
4
|
+
/** The fields that were given. A default must survive a per-run option that is there but undefined. */
|
|
5
|
+
function given(fields) {
|
|
6
|
+
return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
7
|
+
}
|
|
8
|
+
/** The fields that hold a value. A null is dropped here, after it has replaced the default it was given to clear. */
|
|
9
|
+
function held(fields) {
|
|
10
|
+
return Object.fromEntries(Object.entries(given(fields)).filter(([, value]) => value !== null));
|
|
11
|
+
}
|
|
12
|
+
function snakeKeys(fields) {
|
|
13
|
+
return Object.fromEntries(Object.entries(fields).map(([name, value]) => [
|
|
14
|
+
name.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`),
|
|
15
|
+
value,
|
|
16
|
+
]));
|
|
17
|
+
}
|
|
18
|
+
/** The fields of a `run` request that say which browser, with a null wherever the caller gave one. */
|
|
19
|
+
function browserFields(options) {
|
|
20
|
+
return given({
|
|
21
|
+
local: options.local,
|
|
22
|
+
chrome: options.chrome && snakeKeys(options.chrome),
|
|
23
|
+
cloud_profile: options.cloudProfile,
|
|
24
|
+
cdp_url: options.cdpUrl,
|
|
25
|
+
cdp_port: options.cdpPort,
|
|
26
|
+
attach: options.attach,
|
|
27
|
+
target_match: options.targetMatch,
|
|
28
|
+
proxy_country: options.proxyCountry,
|
|
29
|
+
viewport: options.viewport,
|
|
30
|
+
cloud_allow_resizing: options.cloudAllowResizing,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** The browser every run of an instance uses, as the fields of a `run` request. */
|
|
34
|
+
export function browserParams(options) {
|
|
35
|
+
return held(browserFields(options));
|
|
36
|
+
}
|
|
37
|
+
/** The `run` request for a task: the defaults from `start`, then this run's own options over them. */
|
|
38
|
+
export function runParams(runId, task, defaults, options) {
|
|
39
|
+
return {
|
|
40
|
+
...held({ ...defaults, ...browserFields(options) }),
|
|
41
|
+
...held({
|
|
42
|
+
start: options.start,
|
|
43
|
+
inputs: options.inputs,
|
|
44
|
+
attachments: options.attachments?.map(attachment => ({
|
|
45
|
+
name: attachment.name,
|
|
46
|
+
mime_type: attachment.mimeType,
|
|
47
|
+
content: Buffer.from(attachment.content).toString('base64'),
|
|
48
|
+
})),
|
|
49
|
+
limits: options.limits && snakeKeys(options.limits),
|
|
50
|
+
authorization: options.authorization && snakeKeys(options.authorization),
|
|
51
|
+
output_schema: options.output && wireSchema(options.output),
|
|
52
|
+
downloads: options.downloads,
|
|
53
|
+
record: options.record,
|
|
54
|
+
cursor: options.cursor,
|
|
55
|
+
secrets: options.secrets?.refs,
|
|
56
|
+
// The wire carries whether a callback is held, and the callback stays here.
|
|
57
|
+
frames: options.onFrame && true,
|
|
58
|
+
until: options.until && true,
|
|
59
|
+
}),
|
|
60
|
+
run_id: runId,
|
|
61
|
+
task,
|
|
62
|
+
};
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastbrowse",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.5.20",
|
|
4
|
+
"description": "Browser automation with cited answers, structured output and code-controlled credentials and authorization.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/agent-labs-dev/fastbrowse.git",
|
|
9
|
+
"directory": "packages/sdk"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "npm run build && node --test \"test/*.test.ts\""
|
|
28
|
+
},
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"@fastbrowse/darwin-arm64": "0.5.20",
|
|
31
|
+
"@fastbrowse/darwin-x64": "0.5.20",
|
|
32
|
+
"@fastbrowse/linux-arm64": "0.5.20",
|
|
33
|
+
"@fastbrowse/linux-x64": "0.5.20",
|
|
34
|
+
"@fastbrowse/win32-x64": "0.5.20"
|
|
35
|
+
}
|
|
7
36
|
}
|