pi-agent-browser-native 0.2.47 → 0.2.49
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 +63 -19
- package/README.md +52 -19
- package/dist/extensions/agent-browser/index.js +785 -0
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +71 -0
- package/dist/extensions/agent-browser/lib/argv-grammar.js +121 -0
- package/dist/extensions/agent-browser/lib/bash-guard.js +190 -0
- package/dist/extensions/agent-browser/lib/command-policy.js +85 -0
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +302 -0
- package/dist/extensions/agent-browser/lib/config-policy.js +686 -0
- package/dist/extensions/agent-browser/lib/config.js +122 -0
- package/dist/extensions/agent-browser/lib/electron/cdp.js +51 -0
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +212 -0
- package/dist/extensions/agent-browser/lib/electron/discovery.js +633 -0
- package/dist/extensions/agent-browser/lib/electron/launch.js +351 -0
- package/{extensions/agent-browser/lib/electron/text.ts → dist/extensions/agent-browser/lib/electron/text.js} +5 -5
- package/dist/extensions/agent-browser/lib/executable-path.js +20 -0
- package/dist/extensions/agent-browser/lib/fs-utils.js +18 -0
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +165 -0
- package/dist/extensions/agent-browser/lib/input-modes/job.js +519 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +440 -0
- package/dist/extensions/agent-browser/lib/input-modes/params.js +164 -0
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +119 -0
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +42 -0
- package/dist/extensions/agent-browser/lib/input-modes/types.js +21 -0
- package/dist/extensions/agent-browser/lib/input-modes.js +10 -0
- package/dist/extensions/agent-browser/lib/json-schema.js +58 -0
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +59 -0
- package/dist/extensions/agent-browser/lib/navigation-policy.js +83 -0
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +276 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +909 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +443 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +47 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/direct-anchor-download.js +141 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +112 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +158 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +54 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +762 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +491 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +40 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-artifacts.js +5 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +731 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +718 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +247 -0
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +68 -0
- package/{extensions/agent-browser/lib/parsing.ts → dist/extensions/agent-browser/lib/parsing.js} +12 -11
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +241 -0
- package/dist/extensions/agent-browser/lib/playbook.js +121 -0
- package/dist/extensions/agent-browser/lib/process.js +448 -0
- package/dist/extensions/agent-browser/lib/prompt-policy.js +91 -0
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +220 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +111 -0
- package/{extensions/agent-browser/lib/results/artifact-state.ts → dist/extensions/agent-browser/lib/results/artifact-state.js} +4 -8
- package/dist/extensions/agent-browser/lib/results/categories.js +76 -0
- package/dist/extensions/agent-browser/lib/results/confirmation.js +63 -0
- package/dist/extensions/agent-browser/lib/results/contracts.js +8 -0
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +74 -0
- package/dist/extensions/agent-browser/lib/results/envelope.js +166 -0
- package/dist/extensions/agent-browser/lib/results/network-routes.js +92 -0
- package/dist/extensions/agent-browser/lib/results/network.js +73 -0
- package/dist/extensions/agent-browser/lib/results/next-actions.js +72 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +515 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +397 -0
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +55 -0
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +46 -0
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +24 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +960 -0
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +205 -0
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +134 -0
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +159 -0
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +104 -0
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +152 -0
- package/dist/extensions/agent-browser/lib/results/presentation.js +177 -0
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +107 -0
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +50 -0
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +225 -0
- package/{extensions/agent-browser/lib/results/shared.ts → dist/extensions/agent-browser/lib/results/shared.js} +0 -1
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +208 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +78 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +331 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +40 -0
- package/dist/extensions/agent-browser/lib/results/snapshot.js +264 -0
- package/dist/extensions/agent-browser/lib/results/text.js +40 -0
- package/{extensions/agent-browser/lib/results.ts → dist/extensions/agent-browser/lib/results.js} +2 -32
- package/dist/extensions/agent-browser/lib/runtime.js +816 -0
- package/dist/extensions/agent-browser/lib/session-page-state.js +411 -0
- package/dist/extensions/agent-browser/lib/string-enum-schema.js +13 -0
- package/dist/extensions/agent-browser/lib/temp.js +498 -0
- package/dist/extensions/agent-browser/lib/web-search.js +562 -0
- package/docs/ARCHITECTURE.md +10 -10
- package/docs/COMMAND_REFERENCE.md +35 -21
- package/docs/ELECTRON.md +3 -3
- package/docs/RELEASE.md +46 -26
- package/docs/REQUIREMENTS.md +1 -1
- package/docs/SUPPORT_MATRIX.md +35 -106
- package/docs/TOOL_CONTRACT.md +23 -21
- package/package.json +12 -8
- package/scripts/agent-browser-capability-baseline.mjs +6 -3
- package/scripts/config.mjs +8 -2
- package/scripts/doctor.mjs +19 -17
- package/scripts/platform-smoke.mjs +1 -1
- package/extensions/agent-browser/index.ts +0 -952
- package/extensions/agent-browser/lib/argv-descriptor.ts +0 -90
- package/extensions/agent-browser/lib/argv-grammar.ts +0 -128
- package/extensions/agent-browser/lib/bash-guard.ts +0 -205
- package/extensions/agent-browser/lib/command-policy.ts +0 -71
- package/extensions/agent-browser/lib/command-taxonomy.ts +0 -336
- package/extensions/agent-browser/lib/config-policy.js +0 -690
- package/extensions/agent-browser/lib/config.ts +0 -209
- package/extensions/agent-browser/lib/electron/cdp.ts +0 -69
- package/extensions/agent-browser/lib/electron/cleanup.ts +0 -235
- package/extensions/agent-browser/lib/electron/discovery.ts +0 -710
- package/extensions/agent-browser/lib/electron/launch.ts +0 -499
- package/extensions/agent-browser/lib/executable-path.ts +0 -19
- package/extensions/agent-browser/lib/fs-utils.ts +0 -18
- package/extensions/agent-browser/lib/input-modes/electron.ts +0 -170
- package/extensions/agent-browser/lib/input-modes/job.ts +0 -451
- package/extensions/agent-browser/lib/input-modes/lookups.ts +0 -447
- package/extensions/agent-browser/lib/input-modes/params.ts +0 -205
- package/extensions/agent-browser/lib/input-modes/semantic-action.ts +0 -127
- package/extensions/agent-browser/lib/input-modes/shared.ts +0 -46
- package/extensions/agent-browser/lib/input-modes/types.ts +0 -225
- package/extensions/agent-browser/lib/input-modes.ts +0 -45
- package/extensions/agent-browser/lib/json-schema.ts +0 -73
- package/extensions/agent-browser/lib/launch-scoped-flags.ts +0 -67
- package/extensions/agent-browser/lib/navigation-policy.ts +0 -95
- package/extensions/agent-browser/lib/orchestration/batch-stdin.ts +0 -65
- package/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.ts +0 -257
- package/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.ts +0 -912
- package/extensions/agent-browser/lib/orchestration/browser-run/final-result.ts +0 -512
- package/extensions/agent-browser/lib/orchestration/browser-run/index.ts +0 -53
- package/extensions/agent-browser/lib/orchestration/browser-run/prepare.ts +0 -1481
- package/extensions/agent-browser/lib/orchestration/browser-run/process-output.ts +0 -564
- package/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.ts +0 -47
- package/extensions/agent-browser/lib/orchestration/browser-run/session-state.ts +0 -868
- package/extensions/agent-browser/lib/orchestration/browser-run/types.ts +0 -564
- package/extensions/agent-browser/lib/orchestration/electron-host/index.ts +0 -855
- package/extensions/agent-browser/lib/orchestration/input-plan.ts +0 -375
- package/extensions/agent-browser/lib/orchestration/output-file.ts +0 -86
- package/extensions/agent-browser/lib/pi-tool-rendering.ts +0 -252
- package/extensions/agent-browser/lib/playbook.ts +0 -142
- package/extensions/agent-browser/lib/process.ts +0 -516
- package/extensions/agent-browser/lib/prompt-policy.ts +0 -105
- package/extensions/agent-browser/lib/results/action-recommendations.ts +0 -264
- package/extensions/agent-browser/lib/results/artifact-manifest.ts +0 -111
- package/extensions/agent-browser/lib/results/categories.ts +0 -106
- package/extensions/agent-browser/lib/results/confirmation.ts +0 -76
- package/extensions/agent-browser/lib/results/contracts.ts +0 -241
- package/extensions/agent-browser/lib/results/editable-ref-evidence.ts +0 -72
- package/extensions/agent-browser/lib/results/envelope.ts +0 -195
- package/extensions/agent-browser/lib/results/network-routes.ts +0 -83
- package/extensions/agent-browser/lib/results/network.ts +0 -78
- package/extensions/agent-browser/lib/results/next-actions.ts +0 -117
- package/extensions/agent-browser/lib/results/presentation/artifacts.ts +0 -588
- package/extensions/agent-browser/lib/results/presentation/batch.ts +0 -450
- package/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.ts +0 -67
- package/extensions/agent-browser/lib/results/presentation/common.ts +0 -53
- package/extensions/agent-browser/lib/results/presentation/content.ts +0 -36
- package/extensions/agent-browser/lib/results/presentation/diagnostics.ts +0 -923
- package/extensions/agent-browser/lib/results/presentation/errors.ts +0 -227
- package/extensions/agent-browser/lib/results/presentation/large-output.ts +0 -182
- package/extensions/agent-browser/lib/results/presentation/navigation.ts +0 -184
- package/extensions/agent-browser/lib/results/presentation/registry.ts +0 -242
- package/extensions/agent-browser/lib/results/presentation/semantic-action.ts +0 -131
- package/extensions/agent-browser/lib/results/presentation/skills.ts +0 -143
- package/extensions/agent-browser/lib/results/presentation.ts +0 -257
- package/extensions/agent-browser/lib/results/recovery-actions.ts +0 -139
- package/extensions/agent-browser/lib/results/recovery-next-actions.ts +0 -71
- package/extensions/agent-browser/lib/results/selector-recovery.ts +0 -320
- package/extensions/agent-browser/lib/results/snapshot-high-value-controls.ts +0 -273
- package/extensions/agent-browser/lib/results/snapshot-refs.ts +0 -100
- package/extensions/agent-browser/lib/results/snapshot-segments.ts +0 -366
- package/extensions/agent-browser/lib/results/snapshot-spill.ts +0 -63
- package/extensions/agent-browser/lib/results/snapshot.ts +0 -329
- package/extensions/agent-browser/lib/results/text.ts +0 -40
- package/extensions/agent-browser/lib/runtime.ts +0 -988
- package/extensions/agent-browser/lib/session-page-state.ts +0 -512
- package/extensions/agent-browser/lib/string-enum-schema.ts +0 -20
- package/extensions/agent-browser/lib/temp.ts +0 -577
- package/extensions/agent-browser/lib/web-search.ts +0 -721
- /package/{extensions/agent-browser/lib/orchestration/browser-run.ts → dist/extensions/agent-browser/lib/orchestration/browser-run.js} +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Define the Pi tool input schema for the native agent_browser wrapper.
|
|
3
|
-
* Responsibilities: Keep TypeBox schema construction separate from runtime execution and input-mode compilers.
|
|
4
|
-
* Scope: Schema-only; behavioral validation lives in the mode compilers.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { JsonSchema, type JsonSchemaBuilder } from "../json-schema.js";
|
|
8
|
-
import { StringEnum as localStringEnum, type StringEnumBuilder } from "../string-enum-schema.js";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
ELECTRON_DISCOVERY_DEFAULT_MAX_RESULTS,
|
|
12
|
-
ELECTRON_DISCOVERY_MAX_RESULTS,
|
|
13
|
-
} from "../electron/discovery.js";
|
|
14
|
-
import {
|
|
15
|
-
AGENT_BROWSER_ELECTRON_HANDOFFS,
|
|
16
|
-
AGENT_BROWSER_ELECTRON_TARGET_TYPES,
|
|
17
|
-
AGENT_BROWSER_JOB_STEP_ACTIONS,
|
|
18
|
-
AGENT_BROWSER_JOB_TYPE_DELAYED_TEXT_MAX_CHARACTERS,
|
|
19
|
-
AGENT_BROWSER_QA_LOAD_STATES,
|
|
20
|
-
AGENT_BROWSER_SEMANTIC_ACTIONS,
|
|
21
|
-
AGENT_BROWSER_SEMANTIC_LOCATORS,
|
|
22
|
-
DEFAULT_SESSION_MODE,
|
|
23
|
-
SOURCE_LOOKUP_MAX_WORKSPACE_FILES,
|
|
24
|
-
} from "./types.js";
|
|
25
|
-
|
|
26
|
-
export function createAgentBrowserParamsSchema(
|
|
27
|
-
Type: JsonSchemaBuilder = JsonSchema,
|
|
28
|
-
StringEnum: StringEnumBuilder = localStringEnum,
|
|
29
|
-
) {
|
|
30
|
-
return Type.Object({
|
|
31
|
-
|
|
32
|
-
args: Type.Optional(
|
|
33
|
-
Type.Array(Type.String({ description: "Exact agent-browser CLI arguments, excluding the binary name. Do not pass --json; the wrapper injects it. First-call recipe: open → snapshot -i → click/fill @eN → snapshot -i." }), {
|
|
34
|
-
description: "Exact agent-browser CLI arguments, excluding the binary name and any shell operators. Required unless semanticAction, job, qa, sourceLookup, networkSourceLookup, or electron is provided. Do not include --json (wrapper injects it). Typical first calls: open, snapshot -i, click/fill current @refs, then snapshot -i again after navigation or DOM changes.",
|
|
35
|
-
minItems: 1,
|
|
36
|
-
}),
|
|
37
|
-
),
|
|
38
|
-
semanticAction: Type.Optional(
|
|
39
|
-
Type.Object({
|
|
40
|
-
action: StringEnum(AGENT_BROWSER_SEMANTIC_ACTIONS, {
|
|
41
|
-
description: "Intent action to compile to an existing agent-browser find command, direct selector/ref command, or upstream select when action=select.",
|
|
42
|
-
}),
|
|
43
|
-
locator: Type.Optional(StringEnum(AGENT_BROWSER_SEMANTIC_LOCATORS, {
|
|
44
|
-
description: "Upstream find locator family to use for check/click/fill actions.",
|
|
45
|
-
})),
|
|
46
|
-
value: Type.Optional(Type.String({ description: "Locator value for find actions, or a single option value for select actions. For locator=role, role may be supplied instead." })),
|
|
47
|
-
values: Type.Optional(Type.Array(Type.String({ description: "Option value for select actions." }), { description: "One or more option values for select actions.", minItems: 1 })),
|
|
48
|
-
selector: Type.Optional(Type.String({ description: "Selector or @ref for direct click/check/fill actions, or for select actions compiled to select <selector> <value...>." })),
|
|
49
|
-
text: Type.Optional(Type.String({ description: "Text/value argument for fill actions." })),
|
|
50
|
-
role: Type.Optional(Type.String({ description: "Role locator value for locator=role. May be used instead of value; when both are set they must match." })),
|
|
51
|
-
name: Type.Optional(Type.String({ description: "Accessible name filter for locator=role; compiles to --name <name>." })),
|
|
52
|
-
session: Type.Optional(Type.String({ description: "Optional upstream session name; prepends --session <name> before the compiled command." })),
|
|
53
|
-
}, { additionalProperties: false }),
|
|
54
|
-
),
|
|
55
|
-
qa: Type.Optional(
|
|
56
|
-
Type.Union([
|
|
57
|
-
Type.Object({
|
|
58
|
-
attached: Type.Literal(true, { description: "Run the QA preset against the currently attached session instead of opening qa.url." }),
|
|
59
|
-
expectedText: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String())], { description: "Text that must appear on the page." })),
|
|
60
|
-
expectedSelector: Type.Optional(Type.String({ description: "Selector or @ref that must appear on the page." })),
|
|
61
|
-
screenshotPath: Type.Optional(Type.String({ description: "Optional evidence screenshot path captured at the end of the QA preset." })),
|
|
62
|
-
checkConsole: Type.Optional(Type.Boolean({ description: "Whether to inspect console messages and fail on console errors. Defaults to false for qa.attached because upstream buffers may predate the check." })),
|
|
63
|
-
checkErrors: Type.Optional(Type.Boolean({ description: "Whether to inspect page errors and fail when errors are present. Defaults to false for qa.attached because upstream buffers may predate the check." })),
|
|
64
|
-
checkNetwork: Type.Optional(Type.Boolean({ description: "Whether to inspect network requests and fail on actionable request failures; benign icon misses warn. Defaults to false for qa.attached because upstream buffers may predate the check." })),
|
|
65
|
-
loadState: Type.Optional(StringEnum(AGENT_BROWSER_QA_LOAD_STATES, { description: "Page readiness state for the QA preset before assertions and diagnostics. Defaults to domcontentloaded; use networkidle only for pages without long-lived background requests." })),
|
|
66
|
-
}, { additionalProperties: false }),
|
|
67
|
-
Type.Object({
|
|
68
|
-
url: Type.String({ description: "URL to open for a lightweight QA preset." }),
|
|
69
|
-
attached: Type.Optional(Type.Literal(false, { description: "When omitted or false, qa.url is required and opened before checks." })),
|
|
70
|
-
expectedText: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String())], { description: "Text that must appear on the page." })),
|
|
71
|
-
expectedSelector: Type.Optional(Type.String({ description: "Selector or @ref that must appear on the page." })),
|
|
72
|
-
screenshotPath: Type.Optional(Type.String({ description: "Optional evidence screenshot path captured at the end of the QA preset." })),
|
|
73
|
-
checkConsole: Type.Optional(Type.Boolean({ description: "Whether to fail on console error messages. Defaults to true." })),
|
|
74
|
-
checkErrors: Type.Optional(Type.Boolean({ description: "Whether to fail on page errors. Defaults to true." })),
|
|
75
|
-
checkNetwork: Type.Optional(Type.Boolean({ description: "Whether to inspect network requests and fail on actionable request failures; benign icon misses warn. Defaults to true." })),
|
|
76
|
-
loadState: Type.Optional(StringEnum(AGENT_BROWSER_QA_LOAD_STATES, { description: "Page readiness state for the QA preset before assertions and diagnostics. Defaults to domcontentloaded; use networkidle only for pages without long-lived background requests." })),
|
|
77
|
-
}, { additionalProperties: false }),
|
|
78
|
-
], { description: "Lightweight QA preset. Use qa.url to open a URL, or qa.attached=true to check the current attached session without opening a URL." }),
|
|
79
|
-
),
|
|
80
|
-
sourceLookup: Type.Optional(
|
|
81
|
-
Type.Object({
|
|
82
|
-
selector: Type.Optional(Type.String({ description: "Visible selector or @ref whose DOM metadata should be inspected for source hints." })),
|
|
83
|
-
reactFiberId: Type.Optional(Type.String({ description: "React fiber id to inspect with upstream react inspect. Requires a session opened with --enable react-devtools." })),
|
|
84
|
-
componentName: Type.Optional(Type.String({ description: "Component name to correlate with react tree output and bounded local workspace search." })),
|
|
85
|
-
includeDomHints: Type.Optional(Type.Boolean({ description: "Whether selector lookups should inspect DOM HTML attributes for source-like metadata. Defaults to true." })),
|
|
86
|
-
maxWorkspaceFiles: Type.Optional(Type.Number({ description: "Maximum local source files to scan when componentName is provided. Defaults to 2000 and cannot exceed 5000.", minimum: 1, maximum: SOURCE_LOOKUP_MAX_WORKSPACE_FILES })),
|
|
87
|
-
}, { additionalProperties: false, description: "EXPERIMENTAL: local UI-to-source candidates only (confidence/evidence, not guaranteed mappings). Compiles to batch; mutually exclusive with other input modes." }),
|
|
88
|
-
),
|
|
89
|
-
networkSourceLookup: Type.Optional(
|
|
90
|
-
Type.Object({
|
|
91
|
-
filter: Type.Optional(Type.String({ description: "Optional upstream network requests filter pattern." })),
|
|
92
|
-
requestId: Type.Optional(Type.String({ description: "Optional network request id to inspect with network request <id>." })),
|
|
93
|
-
session: Type.Optional(Type.String({ description: "Optional upstream session name; prepends --session <name> before the generated batch." })),
|
|
94
|
-
url: Type.Optional(Type.String({ description: "Optional failed request URL or URL fragment to correlate with local source." })),
|
|
95
|
-
maxWorkspaceFiles: Type.Optional(Type.Number({ description: "Maximum local source files to scan for URL literals. Defaults to 2000 and cannot exceed 5000.", minimum: 1, maximum: SOURCE_LOOKUP_MAX_WORKSPACE_FILES })),
|
|
96
|
-
}, { additionalProperties: false, description: "EXPERIMENTAL: failed-request-to-source candidates only (initiator metadata and bounded workspace URL literals; not definitive blame). Compiles to batch; mutually exclusive with other input modes." }),
|
|
97
|
-
),
|
|
98
|
-
electron: Type.Optional(
|
|
99
|
-
Type.Union([
|
|
100
|
-
Type.Object({
|
|
101
|
-
action: StringEnum(["list"] as const, { description: "List discovered Electron apps." }),
|
|
102
|
-
query: Type.Optional(Type.String({ description: "Optional case-insensitive substring filter for electron.list across app name, bundle id, desktop id, and paths.", minLength: 1 })),
|
|
103
|
-
maxResults: Type.Optional(Type.Integer({ description: `Maximum electron.list apps to return. Defaults to ${ELECTRON_DISCOVERY_DEFAULT_MAX_RESULTS}; values above ${ELECTRON_DISCOVERY_MAX_RESULTS} are clamped.`, minimum: 1 })),
|
|
104
|
-
}, { additionalProperties: false }),
|
|
105
|
-
Type.Object({
|
|
106
|
-
action: StringEnum(["launch"] as const, { description: "Launch an Electron app with an isolated wrapper-owned profile." }),
|
|
107
|
-
appPath: Type.String({ description: "Electron launch target: macOS .app bundle path. Exactly one launch target is required for electron.launch.", minLength: 1 }),
|
|
108
|
-
appArgs: Type.Optional(Type.Array(Type.String({ description: "Argument passed to the Electron application.", minLength: 1 }), { description: "Optional Electron app argv. Wrapper-owned lifecycle/debug flags are rejected." })),
|
|
109
|
-
handoff: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_HANDOFFS, { description: "Post-launch handoff depth. Defaults to snapshot." })),
|
|
110
|
-
targetType: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_TARGET_TYPES, { description: "Preferred CDP target type. Defaults to page." })),
|
|
111
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded launch timeout in milliseconds.", minimum: 1 })),
|
|
112
|
-
allow: Type.Optional(Type.Array(Type.String({ description: "App identifier allowed by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned allow list for electron.launch policy checks." })),
|
|
113
|
-
deny: Type.Optional(Type.Array(Type.String({ description: "App identifier denied by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned deny list for electron.launch policy checks; deny wins over allow." })),
|
|
114
|
-
}, { additionalProperties: false }),
|
|
115
|
-
Type.Object({
|
|
116
|
-
action: StringEnum(["launch"] as const, { description: "Launch an Electron app with an isolated wrapper-owned profile." }),
|
|
117
|
-
appName: Type.String({ description: "Electron launch target: app display name discovered by electron.list. Exactly one launch target is required for electron.launch.", minLength: 1 }),
|
|
118
|
-
appArgs: Type.Optional(Type.Array(Type.String({ description: "Argument passed to the Electron application.", minLength: 1 }), { description: "Optional Electron app argv. Wrapper-owned lifecycle/debug flags are rejected." })),
|
|
119
|
-
handoff: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_HANDOFFS, { description: "Post-launch handoff depth. Defaults to snapshot." })),
|
|
120
|
-
targetType: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_TARGET_TYPES, { description: "Preferred CDP target type. Defaults to page." })),
|
|
121
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded launch timeout in milliseconds.", minimum: 1 })),
|
|
122
|
-
allow: Type.Optional(Type.Array(Type.String({ description: "App identifier allowed by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned allow list for electron.launch policy checks." })),
|
|
123
|
-
deny: Type.Optional(Type.Array(Type.String({ description: "App identifier denied by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned deny list for electron.launch policy checks; deny wins over allow." })),
|
|
124
|
-
}, { additionalProperties: false }),
|
|
125
|
-
Type.Object({
|
|
126
|
-
action: StringEnum(["launch"] as const, { description: "Launch an Electron app with an isolated wrapper-owned profile." }),
|
|
127
|
-
bundleId: Type.String({ description: "Electron launch target: macOS bundle identifier discovered by electron.list. Exactly one launch target is required for electron.launch.", minLength: 1 }),
|
|
128
|
-
appArgs: Type.Optional(Type.Array(Type.String({ description: "Argument passed to the Electron application.", minLength: 1 }), { description: "Optional Electron app argv. Wrapper-owned lifecycle/debug flags are rejected." })),
|
|
129
|
-
handoff: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_HANDOFFS, { description: "Post-launch handoff depth. Defaults to snapshot." })),
|
|
130
|
-
targetType: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_TARGET_TYPES, { description: "Preferred CDP target type. Defaults to page." })),
|
|
131
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded launch timeout in milliseconds.", minimum: 1 })),
|
|
132
|
-
allow: Type.Optional(Type.Array(Type.String({ description: "App identifier allowed by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned allow list for electron.launch policy checks." })),
|
|
133
|
-
deny: Type.Optional(Type.Array(Type.String({ description: "App identifier denied by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned deny list for electron.launch policy checks; deny wins over allow." })),
|
|
134
|
-
}, { additionalProperties: false }),
|
|
135
|
-
Type.Object({
|
|
136
|
-
action: StringEnum(["launch"] as const, { description: "Launch an Electron app with an isolated wrapper-owned profile." }),
|
|
137
|
-
executablePath: Type.String({ description: "Electron launch target: executable path. Discovery is not required when this is provided. Exactly one launch target is required for electron.launch.", minLength: 1 }),
|
|
138
|
-
appArgs: Type.Optional(Type.Array(Type.String({ description: "Argument passed to the Electron application.", minLength: 1 }), { description: "Optional Electron app argv. Wrapper-owned lifecycle/debug flags are rejected." })),
|
|
139
|
-
handoff: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_HANDOFFS, { description: "Post-launch handoff depth. Defaults to snapshot." })),
|
|
140
|
-
targetType: Type.Optional(StringEnum(AGENT_BROWSER_ELECTRON_TARGET_TYPES, { description: "Preferred CDP target type. Defaults to page." })),
|
|
141
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded launch timeout in milliseconds.", minimum: 1 })),
|
|
142
|
-
allow: Type.Optional(Type.Array(Type.String({ description: "App identifier allowed by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned allow list for electron.launch policy checks." })),
|
|
143
|
-
deny: Type.Optional(Type.Array(Type.String({ description: "App identifier denied by the caller for electron.launch.", minLength: 1 }), { description: "Optional caller-owned deny list for electron.launch policy checks; deny wins over allow." })),
|
|
144
|
-
}, { additionalProperties: false }),
|
|
145
|
-
Type.Object({
|
|
146
|
-
action: StringEnum(["status", "cleanup"] as const, { description: "Inspect or cleanup one wrapper-tracked Electron launch by launchId." }),
|
|
147
|
-
launchId: Type.String({ description: "Wrapper launch id for electron.status and electron.cleanup.", minLength: 1 }),
|
|
148
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded status/cleanup timeout in milliseconds.", minimum: 1 })),
|
|
149
|
-
}, { additionalProperties: false }),
|
|
150
|
-
Type.Object({
|
|
151
|
-
action: StringEnum(["status", "cleanup"] as const, { description: "Inspect or cleanup all wrapper-tracked Electron launches." }),
|
|
152
|
-
all: Type.Literal(true, { description: "Apply electron.status or electron.cleanup to all wrapper-owned launches." }),
|
|
153
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded status/cleanup timeout in milliseconds.", minimum: 1 })),
|
|
154
|
-
}, { additionalProperties: false }),
|
|
155
|
-
Type.Object({
|
|
156
|
-
action: StringEnum(["status", "cleanup"] as const, { description: "Inspect or cleanup the only active wrapper-tracked Electron launch." }),
|
|
157
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded status/cleanup timeout in milliseconds.", minimum: 1 })),
|
|
158
|
-
}, { additionalProperties: false }),
|
|
159
|
-
Type.Object({
|
|
160
|
-
action: StringEnum(["probe"] as const, { description: "Probe the current attached Electron managed session; launchId is accepted for launch-scoped follow-up actions." }),
|
|
161
|
-
launchId: Type.Optional(Type.String({ description: "Wrapper launch id for electron.probe follow-up targeting.", minLength: 1 })),
|
|
162
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Bounded probe timeout in milliseconds.", minimum: 1 })),
|
|
163
|
-
}, { additionalProperties: false }),
|
|
164
|
-
], { description: "Electron wrapper action. Fields are action-specific and unsupported fields are rejected." }),
|
|
165
|
-
),
|
|
166
|
-
job: Type.Optional(
|
|
167
|
-
Type.Object({
|
|
168
|
-
failFast: Type.Optional(Type.Boolean({ description: "Stop the compiled batch on the first failed job step. Defaults to true so later mutating steps do not run after setup/assertion failures." })),
|
|
169
|
-
steps: Type.Array(
|
|
170
|
-
Type.Object({
|
|
171
|
-
action: StringEnum(AGENT_BROWSER_JOB_STEP_ACTIONS, {
|
|
172
|
-
description: "Constrained one-call job step compiled to existing upstream batch commands.",
|
|
173
|
-
}),
|
|
174
|
-
url: Type.Optional(Type.String({ description: "URL for open steps, or URL pattern for assertUrl steps." })),
|
|
175
|
-
loadState: Type.Optional(StringEnum(AGENT_BROWSER_QA_LOAD_STATES, { description: "Optional readiness wait to insert immediately after an open step; use domcontentloaded/load/networkidle when the next job step needs page hydration evidence before clicking or reading." })),
|
|
176
|
-
selector: Type.Optional(Type.String({ description: "Selector or @ref for click/fill/type/select-like steps; omit when using semantic locator fields on click/fill steps." })),
|
|
177
|
-
locator: Type.Optional(StringEnum(AGENT_BROWSER_SEMANTIC_LOCATORS, { description: "Semantic locator for click/fill steps when selector is omitted." })),
|
|
178
|
-
role: Type.Optional(Type.String({ description: "Role locator value for click/fill steps when locator is role." })),
|
|
179
|
-
name: Type.Optional(Type.String({ description: "Accessible name filter for role locator click/fill steps." })),
|
|
180
|
-
text: Type.Optional(Type.String({ description: "Text for fill steps or visible text for assertText steps." })),
|
|
181
|
-
value: Type.Optional(Type.String({ description: "Single option value for select steps, or locator value for semantic click/fill steps." })),
|
|
182
|
-
values: Type.Optional(Type.Array(Type.String({ description: "Option value for select steps." }), { description: "One or more option values for select steps.", minItems: 1 })),
|
|
183
|
-
path: Type.Optional(Type.String({ description: "Artifact/download path for waitForDownload or screenshot steps." })),
|
|
184
|
-
delayMs: Type.Optional(Type.Integer({ description: `Optional per-character delay for type steps; when set, the job compiles to focus/keyboard type/wait steps instead of instant fill-like typing, capped at ${AGENT_BROWSER_JOB_TYPE_DELAYED_TEXT_MAX_CHARACTERS} characters.`, minimum: 1 })),
|
|
185
|
-
press: Type.Optional(Type.String({ description: "Optional key to press after a type step, for example Enter." })),
|
|
186
|
-
milliseconds: Type.Optional(Type.Number({ description: "Milliseconds for wait steps." })),
|
|
187
|
-
}, { additionalProperties: false }),
|
|
188
|
-
{ minItems: 1 },
|
|
189
|
-
),
|
|
190
|
-
}, { additionalProperties: false }),
|
|
191
|
-
),
|
|
192
|
-
stdin: Type.Optional(Type.String({ description: "Optional raw stdin content; only supported for batch, eval --stdin, auth save --password-stdin, and is generated internally by job, qa, sourceLookup, or networkSourceLookup mode. Do not use with electron mode." })),
|
|
193
|
-
outputPath: Type.Optional(Type.String({ description: "Optional workspace-relative or absolute file path that receives the model-facing command data/result after the browser command completes. Useful for eval/get/snapshot captures that should become durable local artifacts.", minLength: 1 })),
|
|
194
|
-
timeoutMs: Type.Optional(Type.Integer({ description: "Optional per-call wrapper subprocess watchdog in milliseconds for browser CLI args/job/qa/source lookup calls. Use for long opens or large output captures; fixed wait steps still must stay below the upstream IPC wait budget. Electron actions use electron.timeoutMs instead.", minimum: 1 })),
|
|
195
|
-
sessionMode: Type.Optional(
|
|
196
|
-
StringEnum(["auto", "fresh"] as const, {
|
|
197
|
-
description:
|
|
198
|
-
"Session handling mode. `auto` reuses the extension-managed pi-scoped session when possible. `fresh` switches that managed session to a fresh upstream launch so launch-scoped flags like --profile, --executable-path, --session-name, --cdp, --state, --auto-connect, --init-script, --enable, -p/--provider, or iOS --device apply and later auto calls follow the new browser.",
|
|
199
|
-
default: DEFAULT_SESSION_MODE,
|
|
200
|
-
}),
|
|
201
|
-
),
|
|
202
|
-
}, { additionalProperties: false });
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export const AGENT_BROWSER_PARAMS = createAgentBrowserParamsSchema();
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Compile semanticAction shorthand inputs into upstream agent-browser commands.
|
|
3
|
-
* Responsibilities: Validate shorthand locator/action fields and expose compiled-command helpers.
|
|
4
|
-
* Scope: semanticAction mode only.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { isRecord } from "../parsing.js";
|
|
8
|
-
import { getSelectValues } from "./shared.js";
|
|
9
|
-
import {
|
|
10
|
-
AGENT_BROWSER_SEMANTIC_ACTIONS,
|
|
11
|
-
AGENT_BROWSER_SEMANTIC_LOCATORS,
|
|
12
|
-
type AgentBrowserSemanticActionName,
|
|
13
|
-
type AgentBrowserSemanticLocator,
|
|
14
|
-
type CompiledAgentBrowserSemanticAction,
|
|
15
|
-
} from "./types.js";
|
|
16
|
-
|
|
17
|
-
export function getCompiledSemanticActionCommandIndex(compiled: CompiledAgentBrowserSemanticAction): number {
|
|
18
|
-
return compiled.args[0] === "--session" ? 2 : 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getCompiledSemanticActionSessionPrefix(compiled: CompiledAgentBrowserSemanticAction): string[] {
|
|
22
|
-
const commandIndex = getCompiledSemanticActionCommandIndex(compiled);
|
|
23
|
-
return commandIndex > 0 ? compiled.args.slice(0, commandIndex) : [];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function isCompiledSemanticActionFindCommand(compiled: CompiledAgentBrowserSemanticAction | undefined): boolean {
|
|
27
|
-
if (!compiled) return false;
|
|
28
|
-
return compiled.args[getCompiledSemanticActionCommandIndex(compiled)] === "find";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function compileAgentBrowserSemanticAction(input: unknown): { compiled?: CompiledAgentBrowserSemanticAction; error?: string } {
|
|
32
|
-
if (!isRecord(input)) {
|
|
33
|
-
return { error: "semanticAction must be an object." };
|
|
34
|
-
}
|
|
35
|
-
const action = input.action;
|
|
36
|
-
const locator = input.locator;
|
|
37
|
-
const value = input.value;
|
|
38
|
-
const values = input.values;
|
|
39
|
-
const selector = input.selector;
|
|
40
|
-
const text = input.text;
|
|
41
|
-
const role = input.role;
|
|
42
|
-
const name = input.name;
|
|
43
|
-
const session = input.session;
|
|
44
|
-
if (typeof action !== "string" || !AGENT_BROWSER_SEMANTIC_ACTIONS.includes(action as AgentBrowserSemanticActionName)) {
|
|
45
|
-
return { error: `semanticAction.action must be one of: ${AGENT_BROWSER_SEMANTIC_ACTIONS.join(", ")}.` };
|
|
46
|
-
}
|
|
47
|
-
if (session !== undefined && (typeof session !== "string" || session.trim().length === 0)) {
|
|
48
|
-
return { error: "semanticAction.session must be a non-empty string when provided." };
|
|
49
|
-
}
|
|
50
|
-
if (action === "select") {
|
|
51
|
-
if (locator !== undefined || role !== undefined || name !== undefined) {
|
|
52
|
-
return { error: "semanticAction.locator, role, and name are not supported for select; use selector plus value or values." };
|
|
53
|
-
}
|
|
54
|
-
if (text !== undefined) {
|
|
55
|
-
return { error: "semanticAction.text is not supported for select; use value or values for option values." };
|
|
56
|
-
}
|
|
57
|
-
if (typeof selector !== "string" || selector.trim().length === 0) {
|
|
58
|
-
return { error: "semanticAction.selector is required for select." };
|
|
59
|
-
}
|
|
60
|
-
const selectedValues = getSelectValues(input, "semanticAction");
|
|
61
|
-
if (selectedValues.error) return { error: selectedValues.error };
|
|
62
|
-
const args = typeof session === "string" ? ["--session", session, "select", selector, ...(selectedValues.values as string[])] : ["select", selector, ...(selectedValues.values as string[])];
|
|
63
|
-
return { compiled: { action: "select", selector, values: selectedValues.values, args } };
|
|
64
|
-
}
|
|
65
|
-
if (values !== undefined) {
|
|
66
|
-
return { error: "semanticAction.values is only supported for select actions." };
|
|
67
|
-
}
|
|
68
|
-
if (selector !== undefined) {
|
|
69
|
-
if (typeof selector !== "string" || selector.trim().length === 0) {
|
|
70
|
-
return { error: "semanticAction.selector must be a non-empty string when provided." };
|
|
71
|
-
}
|
|
72
|
-
if (locator !== undefined || value !== undefined || role !== undefined || name !== undefined) {
|
|
73
|
-
return { error: "semanticAction.selector cannot be combined with locator, value, role, or name; use selector for a direct click/check/fill target or locator fields for find-based actions." };
|
|
74
|
-
}
|
|
75
|
-
if (text !== undefined && typeof text !== "string") {
|
|
76
|
-
return { error: "semanticAction.text must be a string when provided." };
|
|
77
|
-
}
|
|
78
|
-
if (action === "fill" && (typeof text !== "string" || text.length === 0)) {
|
|
79
|
-
return { error: `semanticAction.text is required for ${action}.` };
|
|
80
|
-
}
|
|
81
|
-
if (action !== "fill" && text !== undefined) {
|
|
82
|
-
return { error: "semanticAction.text is only supported for fill actions." };
|
|
83
|
-
}
|
|
84
|
-
const directArgs = typeof session === "string" ? ["--session", session, action, selector] : [action, selector];
|
|
85
|
-
if (action === "fill") directArgs.push(text as string);
|
|
86
|
-
return { compiled: { action: action as AgentBrowserSemanticActionName, selector, args: directArgs } };
|
|
87
|
-
}
|
|
88
|
-
if (typeof locator !== "string" || !AGENT_BROWSER_SEMANTIC_LOCATORS.includes(locator as AgentBrowserSemanticLocator)) {
|
|
89
|
-
return { error: `semanticAction.locator must be one of: ${AGENT_BROWSER_SEMANTIC_LOCATORS.join(", ")}.` };
|
|
90
|
-
}
|
|
91
|
-
if (value !== undefined && (typeof value !== "string" || value.trim().length === 0)) {
|
|
92
|
-
return { error: "semanticAction.value must be a non-empty string when provided." };
|
|
93
|
-
}
|
|
94
|
-
if (role !== undefined && (typeof role !== "string" || role.trim().length === 0)) {
|
|
95
|
-
return { error: "semanticAction.role must be a non-empty string when provided." };
|
|
96
|
-
}
|
|
97
|
-
const locatorValue = locator === "role" && typeof role === "string" ? role : value;
|
|
98
|
-
if (typeof locatorValue !== "string" || locatorValue.trim().length === 0) {
|
|
99
|
-
return { error: locator === "role" ? "semanticAction.value or semanticAction.role must be a non-empty string for locator=role." : "semanticAction.value must be a non-empty string." };
|
|
100
|
-
}
|
|
101
|
-
if (text !== undefined && typeof text !== "string") {
|
|
102
|
-
return { error: "semanticAction.text must be a string when provided." };
|
|
103
|
-
}
|
|
104
|
-
if (action === "fill" && (typeof text !== "string" || text.length === 0)) {
|
|
105
|
-
return { error: `semanticAction.text is required for ${action}.` };
|
|
106
|
-
}
|
|
107
|
-
if (action !== "fill" && text !== undefined) {
|
|
108
|
-
return { error: "semanticAction.text is only supported for fill actions." };
|
|
109
|
-
}
|
|
110
|
-
if (role !== undefined && locator !== "role") {
|
|
111
|
-
return { error: "semanticAction.role is only supported for locator=role." };
|
|
112
|
-
}
|
|
113
|
-
if (role !== undefined && value !== undefined && role !== value) {
|
|
114
|
-
return { error: "semanticAction.role must match value when both are provided for locator=role." };
|
|
115
|
-
}
|
|
116
|
-
if (name !== undefined && (locator !== "role" || typeof name !== "string" || name.length === 0)) {
|
|
117
|
-
return { error: "semanticAction.name is only supported as a non-empty string for locator=role." };
|
|
118
|
-
}
|
|
119
|
-
const args = typeof session === "string" ? ["--session", session, "find", locator, locatorValue, action] : ["find", locator, locatorValue, action];
|
|
120
|
-
if (action === "fill") {
|
|
121
|
-
args.push(text as string);
|
|
122
|
-
}
|
|
123
|
-
if (locator === "role" && typeof name === "string") {
|
|
124
|
-
args.push("--name", name);
|
|
125
|
-
}
|
|
126
|
-
return { compiled: { action: action as AgentBrowserSemanticActionName, locator: locator as AgentBrowserSemanticLocator, args } };
|
|
127
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Hold tiny shared parsing helpers for structured agent_browser input modes.
|
|
3
|
-
* Responsibilities: Normalize common select values, batch result rows, and workspace scan limits.
|
|
4
|
-
* Scope: Generic input-mode helpers only; mode-specific policy stays in the owning module.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { isRecord } from "../parsing.js";
|
|
8
|
-
import { SOURCE_LOOKUP_DEFAULT_MAX_WORKSPACE_FILES, SOURCE_LOOKUP_MAX_WORKSPACE_FILES } from "./types.js";
|
|
9
|
-
|
|
10
|
-
export function getSelectValues(input: Record<string, unknown>, context: string): { values?: string[]; error?: string } {
|
|
11
|
-
const rawValue = input.value;
|
|
12
|
-
const rawValues = input.values;
|
|
13
|
-
if (rawValue !== undefined && rawValues !== undefined) {
|
|
14
|
-
return { error: `${context}.value and ${context}.values cannot both be provided for select.` };
|
|
15
|
-
}
|
|
16
|
-
if (rawValues !== undefined) {
|
|
17
|
-
if (!Array.isArray(rawValues) || rawValues.length === 0 || rawValues.some((value) => typeof value !== "string" || value.trim().length === 0)) {
|
|
18
|
-
return { error: `${context}.values must be a non-empty array of non-empty strings for select.` };
|
|
19
|
-
}
|
|
20
|
-
return { values: rawValues };
|
|
21
|
-
}
|
|
22
|
-
if (typeof rawValue === "string" && rawValue.trim().length > 0) {
|
|
23
|
-
return { values: [rawValue] };
|
|
24
|
-
}
|
|
25
|
-
return { error: `${context}.value or ${context}.values is required for select.` };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getBatchResultItems(data: unknown): Array<Record<string, unknown>> {
|
|
29
|
-
return Array.isArray(data) ? data.filter(isRecord) : [];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getCommandNameFromBatchItem(item: Record<string, unknown>): string | undefined {
|
|
33
|
-
const command = item.command;
|
|
34
|
-
return Array.isArray(command) && typeof command[0] === "string" ? command[0] : undefined;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function validateLookupMaxWorkspaceFiles(value: unknown, fieldName: string): { value?: number; error?: string } {
|
|
38
|
-
if (value === undefined) return { value: SOURCE_LOOKUP_DEFAULT_MAX_WORKSPACE_FILES };
|
|
39
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
40
|
-
return { error: `${fieldName} must be a positive integer when provided.` };
|
|
41
|
-
}
|
|
42
|
-
if (value > SOURCE_LOOKUP_MAX_WORKSPACE_FILES) {
|
|
43
|
-
return { error: `${fieldName} must be ${SOURCE_LOOKUP_MAX_WORKSPACE_FILES} or less.` };
|
|
44
|
-
}
|
|
45
|
-
return { value };
|
|
46
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Define structured agent_browser input-mode constants and TypeScript contracts.
|
|
3
|
-
* Responsibilities: Share schema enums and compiled input-mode result types across input-mode modules.
|
|
4
|
-
* Scope: Types and constants only; validation and compilation live in sibling modules.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export const DEFAULT_SESSION_MODE = "auto" as const;
|
|
8
|
-
|
|
9
|
-
export const AGENT_BROWSER_SEMANTIC_ACTIONS = ["check", "click", "fill", "select"] as const;
|
|
10
|
-
|
|
11
|
-
export const AGENT_BROWSER_SEMANTIC_LOCATORS = ["alt", "label", "placeholder", "role", "testid", "text", "title"] as const;
|
|
12
|
-
|
|
13
|
-
export const AGENT_BROWSER_JOB_TYPE_DELAYED_TEXT_MAX_CHARACTERS = 200;
|
|
14
|
-
export const AGENT_BROWSER_JOB_STEP_ACTIONS = ["open", "click", "fill", "type", "select", "wait", "assertText", "assertUrl", "waitForDownload", "screenshot", "snapshot"] as const;
|
|
15
|
-
|
|
16
|
-
export const AGENT_BROWSER_QA_LOAD_STATES = ["domcontentloaded", "load", "networkidle"] as const;
|
|
17
|
-
|
|
18
|
-
export const AGENT_BROWSER_ELECTRON_ACTIONS = ["list", "launch", "status", "cleanup", "probe"] as const;
|
|
19
|
-
|
|
20
|
-
export const AGENT_BROWSER_ELECTRON_HANDOFFS = ["connect", "tabs", "snapshot"] as const;
|
|
21
|
-
|
|
22
|
-
export const AGENT_BROWSER_ELECTRON_TARGET_TYPES = ["page", "webview", "any"] as const;
|
|
23
|
-
|
|
24
|
-
export const AGENT_BROWSER_ELECTRON_LIST_FIELDS = new Set(["action", "query", "maxResults"]);
|
|
25
|
-
|
|
26
|
-
export const AGENT_BROWSER_ELECTRON_PROBE_FIELDS = new Set(["action", "launchId", "timeoutMs"]);
|
|
27
|
-
|
|
28
|
-
export const AGENT_BROWSER_ELECTRON_RESERVED_APP_ARGS = ["--user-data-dir", "--remote-debugging-port", "--remote-debugging-address", "--remote-debugging-pipe"] as const;
|
|
29
|
-
|
|
30
|
-
export const SOURCE_LOOKUP_WORKSPACE_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx"]);
|
|
31
|
-
|
|
32
|
-
export const SOURCE_LOOKUP_IGNORED_DIRECTORIES = new Set([".git", "node_modules", "dist", "build", "coverage", ".next", "out", "tmp", "temp"]);
|
|
33
|
-
|
|
34
|
-
export const SOURCE_LOOKUP_DEFAULT_MAX_WORKSPACE_FILES = 2_000;
|
|
35
|
-
|
|
36
|
-
export const SOURCE_LOOKUP_MAX_WORKSPACE_FILES = 5_000;
|
|
37
|
-
|
|
38
|
-
export type AgentBrowserSemanticActionName = (typeof AGENT_BROWSER_SEMANTIC_ACTIONS)[number];
|
|
39
|
-
|
|
40
|
-
export type AgentBrowserSemanticLocator = (typeof AGENT_BROWSER_SEMANTIC_LOCATORS)[number];
|
|
41
|
-
|
|
42
|
-
export type AgentBrowserJobStepAction = (typeof AGENT_BROWSER_JOB_STEP_ACTIONS)[number];
|
|
43
|
-
|
|
44
|
-
export type AgentBrowserQaLoadState = (typeof AGENT_BROWSER_QA_LOAD_STATES)[number];
|
|
45
|
-
|
|
46
|
-
export type AgentBrowserElectronAction = (typeof AGENT_BROWSER_ELECTRON_ACTIONS)[number];
|
|
47
|
-
|
|
48
|
-
export type AgentBrowserSourceLookupStatus = "candidates-found" | "no-candidates" | "unsupported";
|
|
49
|
-
|
|
50
|
-
export type AgentBrowserNetworkSourceLookupStatus = "failed-requests-found" | "no-failed-requests" | "no-candidates";
|
|
51
|
-
|
|
52
|
-
export type CompiledAgentBrowserElectron =
|
|
53
|
-
| {
|
|
54
|
-
action: "list";
|
|
55
|
-
maxResults?: number;
|
|
56
|
-
query?: string;
|
|
57
|
-
}
|
|
58
|
-
| {
|
|
59
|
-
action: "launch";
|
|
60
|
-
allow?: string[];
|
|
61
|
-
appArgs?: string[];
|
|
62
|
-
deny?: string[];
|
|
63
|
-
appName?: string;
|
|
64
|
-
appPath?: string;
|
|
65
|
-
bundleId?: string;
|
|
66
|
-
executablePath?: string;
|
|
67
|
-
handoff: "connect" | "snapshot" | "tabs";
|
|
68
|
-
targetType: "any" | "page" | "webview";
|
|
69
|
-
timeoutMs?: number;
|
|
70
|
-
}
|
|
71
|
-
| {
|
|
72
|
-
action: "cleanup" | "status";
|
|
73
|
-
all?: boolean;
|
|
74
|
-
launchId?: string;
|
|
75
|
-
timeoutMs?: number;
|
|
76
|
-
}
|
|
77
|
-
| {
|
|
78
|
-
action: "probe";
|
|
79
|
-
launchId?: string;
|
|
80
|
-
timeoutMs?: number;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export interface AgentBrowserSemanticActionInput {
|
|
84
|
-
action: AgentBrowserSemanticActionName;
|
|
85
|
-
locator?: AgentBrowserSemanticLocator;
|
|
86
|
-
value?: string;
|
|
87
|
-
values?: string[];
|
|
88
|
-
selector?: string;
|
|
89
|
-
text?: string;
|
|
90
|
-
role?: string;
|
|
91
|
-
name?: string;
|
|
92
|
-
session?: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface CompiledAgentBrowserSemanticAction {
|
|
96
|
-
action: AgentBrowserSemanticActionName;
|
|
97
|
-
locator?: AgentBrowserSemanticLocator;
|
|
98
|
-
selector?: string;
|
|
99
|
-
values?: string[];
|
|
100
|
-
args: string[];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface CompiledAgentBrowserJobStep {
|
|
104
|
-
action: AgentBrowserJobStepAction;
|
|
105
|
-
args: string[];
|
|
106
|
-
generatedFrom?: string;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface CompiledAgentBrowserJob {
|
|
110
|
-
args: string[];
|
|
111
|
-
failFast: boolean;
|
|
112
|
-
stdin: string;
|
|
113
|
-
steps: CompiledAgentBrowserJobStep[];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface CompiledAgentBrowserQaPreset extends CompiledAgentBrowserJob {
|
|
117
|
-
checks: {
|
|
118
|
-
checkConsole: boolean;
|
|
119
|
-
checkErrors: boolean;
|
|
120
|
-
checkNetwork: boolean;
|
|
121
|
-
diagnosticsResetAtStart: boolean;
|
|
122
|
-
loadState: AgentBrowserQaLoadState;
|
|
123
|
-
expectedText: string[];
|
|
124
|
-
expectedSelector?: string;
|
|
125
|
-
screenshotPath?: string;
|
|
126
|
-
attached: boolean;
|
|
127
|
-
url?: string;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface CompiledAgentBrowserSourceLookupStep {
|
|
132
|
-
action: "dom" | "react";
|
|
133
|
-
args: string[];
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface CompiledAgentBrowserSourceLookup {
|
|
137
|
-
args: string[];
|
|
138
|
-
stdin: string;
|
|
139
|
-
steps: CompiledAgentBrowserSourceLookupStep[];
|
|
140
|
-
query: {
|
|
141
|
-
componentName?: string;
|
|
142
|
-
includeDomHints: boolean;
|
|
143
|
-
maxWorkspaceFiles: number;
|
|
144
|
-
reactFiberId?: string;
|
|
145
|
-
selector?: string;
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export interface AgentBrowserSourceLookupCandidate {
|
|
150
|
-
column?: number;
|
|
151
|
-
componentName?: string;
|
|
152
|
-
confidence: "high" | "medium" | "low";
|
|
153
|
-
evidence: string[];
|
|
154
|
-
file?: string;
|
|
155
|
-
line?: number;
|
|
156
|
-
source: "react-inspect" | "dom-attribute" | "workspace-search";
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export interface AgentBrowserSourceLookupElectronContext {
|
|
160
|
-
appName?: string;
|
|
161
|
-
appPath?: string;
|
|
162
|
-
executablePath?: string;
|
|
163
|
-
launchId?: string;
|
|
164
|
-
sessionName?: string;
|
|
165
|
-
url?: string;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface AgentBrowserSourceLookupAnalysis {
|
|
169
|
-
candidates: AgentBrowserSourceLookupCandidate[];
|
|
170
|
-
electronContext?: AgentBrowserSourceLookupElectronContext;
|
|
171
|
-
limitations: string[];
|
|
172
|
-
status: AgentBrowserSourceLookupStatus;
|
|
173
|
-
summary: string;
|
|
174
|
-
workspaceRoot?: string;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface AgentBrowserSourceLookupAnalysisContext {
|
|
178
|
-
electronContext?: AgentBrowserSourceLookupElectronContext;
|
|
179
|
-
workspaceRoot: string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export interface CompiledAgentBrowserNetworkSourceLookup {
|
|
183
|
-
args: string[];
|
|
184
|
-
stdin: string;
|
|
185
|
-
steps: Array<{ action: "network"; args: string[] }>;
|
|
186
|
-
query: {
|
|
187
|
-
filter?: string;
|
|
188
|
-
maxWorkspaceFiles: number;
|
|
189
|
-
requestId?: string;
|
|
190
|
-
session?: string;
|
|
191
|
-
url?: string;
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export interface AgentBrowserNetworkSourceLookupRequest {
|
|
196
|
-
error?: string;
|
|
197
|
-
method?: string;
|
|
198
|
-
requestId?: string;
|
|
199
|
-
status?: number;
|
|
200
|
-
url?: string;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export interface AgentBrowserNetworkSourceLookupCandidate {
|
|
204
|
-
confidence: "high" | "medium" | "low";
|
|
205
|
-
evidence: string[];
|
|
206
|
-
file?: string;
|
|
207
|
-
line?: number;
|
|
208
|
-
requestUrl?: string;
|
|
209
|
-
source: "initiator" | "workspace-search";
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface AgentBrowserNetworkSourceLookupAnalysis {
|
|
213
|
-
candidates: AgentBrowserNetworkSourceLookupCandidate[];
|
|
214
|
-
failedRequests: AgentBrowserNetworkSourceLookupRequest[];
|
|
215
|
-
limitations: string[];
|
|
216
|
-
status: AgentBrowserNetworkSourceLookupStatus;
|
|
217
|
-
summary: string;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export interface AgentBrowserQaPresetAnalysis {
|
|
221
|
-
failedChecks: string[];
|
|
222
|
-
passed: boolean;
|
|
223
|
-
summary: string;
|
|
224
|
-
warnings: string[];
|
|
225
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Re-export focused input-mode schema, compiler, and analysis modules for the agent_browser wrapper.
|
|
3
|
-
* Responsibilities: Preserve the extension entrypoint's import surface while keeping input-mode code split by concern.
|
|
4
|
-
* Scope: Barrel only; add behavior to focused files under ./input-modes/.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export { AGENT_BROWSER_PARAMS } from "./input-modes/params.js";
|
|
8
|
-
export {
|
|
9
|
-
analyzeQaPresetResults,
|
|
10
|
-
analyzeQaPresetTimeout,
|
|
11
|
-
buildQaCompactPassText,
|
|
12
|
-
compileAgentBrowserJob,
|
|
13
|
-
compileAgentBrowserQaPreset,
|
|
14
|
-
extractQaPageContext,
|
|
15
|
-
isHttpOrHttpsUrl,
|
|
16
|
-
} from "./input-modes/job.js";
|
|
17
|
-
export {
|
|
18
|
-
analyzeNetworkSourceLookupResults,
|
|
19
|
-
analyzeSourceLookupResults,
|
|
20
|
-
compileAgentBrowserNetworkSourceLookup,
|
|
21
|
-
compileAgentBrowserSourceLookup,
|
|
22
|
-
redactNetworkSourceLookupAnalysis,
|
|
23
|
-
redactNetworkSourceLookupArgs,
|
|
24
|
-
redactNetworkSourceLookupSurface,
|
|
25
|
-
redactNetworkSourceLookupUrl,
|
|
26
|
-
} from "./input-modes/lookups.js";
|
|
27
|
-
export { compileAgentBrowserElectron } from "./input-modes/electron.js";
|
|
28
|
-
export {
|
|
29
|
-
compileAgentBrowserSemanticAction,
|
|
30
|
-
getCompiledSemanticActionCommandIndex,
|
|
31
|
-
getCompiledSemanticActionSessionPrefix,
|
|
32
|
-
isCompiledSemanticActionFindCommand,
|
|
33
|
-
} from "./input-modes/semantic-action.js";
|
|
34
|
-
export type {
|
|
35
|
-
AgentBrowserNetworkSourceLookupAnalysis,
|
|
36
|
-
AgentBrowserQaPresetAnalysis,
|
|
37
|
-
AgentBrowserSourceLookupAnalysis,
|
|
38
|
-
AgentBrowserSourceLookupElectronContext,
|
|
39
|
-
CompiledAgentBrowserElectron,
|
|
40
|
-
CompiledAgentBrowserJob,
|
|
41
|
-
CompiledAgentBrowserNetworkSourceLookup,
|
|
42
|
-
CompiledAgentBrowserQaPreset,
|
|
43
|
-
CompiledAgentBrowserSemanticAction,
|
|
44
|
-
CompiledAgentBrowserSourceLookup,
|
|
45
|
-
} from "./input-modes/types.js";
|