pi-agent-browser-native 0.2.58 → 0.2.60
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
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.2.60 - 2026-06-24
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Removed a dead `as never` cast and unreachable try/catch from the `agent_browser` collapsed-output "to expand" keybinding hint. `app.tools.expand` is a host-registered keybinding id (coding-agent augments pi-tui's `Keybindings` via declaration merging), so the id is resolved cast-free via `getKeybindings().getKeys(...)` with the stock `ctrl+o` fallback preserved for bare-node test contexts. No behavior change; the `pi-coding-agent` package stays type-only in the entrypoint import path so startup tax is unchanged.
|
|
10
|
+
|
|
11
|
+
### Validation
|
|
12
|
+
|
|
13
|
+
- Ran `npm run verify` (default gate: docs, typecheck, 575/575 unit, command-reference baseline + live drift), `npm run verify -- startup-profile --samples 3` (median 50.1ms, < 250ms budget), `npm run verify -- real-upstream`, `npm run verify -- lifecycle`, `npm run verify -- dogfood`, `npm run verify -- pre-pr`, and `npm run doctor` against the local checkout.
|
|
14
|
+
- Ran an independent reviewer subagent over the diff; no blockers found and the compaction-orphan audit claim was confirmed disproven against Pi 0.80.2 source.
|
|
15
|
+
|
|
16
|
+
## 0.2.59 - 2026-06-24
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Shortened the always-on `agent_browser` prompt guidance by over 1KB while preserving the native-tool trigger, open → `snapshot -i` workflow, `sessionMode=fresh`, artifact verification, and extraction rules.
|
|
21
|
+
- Moved the quick live-search guidance onto `agent_browser_web_search` so browser-search routing stays available without duplicating that guidance in the main browser tool prompt.
|
|
22
|
+
|
|
23
|
+
### Validation
|
|
24
|
+
|
|
25
|
+
- Ran `npm run verify -- release`, `npm run doctor`, and `npm run verify -- startup-profile --samples 3` against the local checkout.
|
|
26
|
+
- Ran tmux-driven Pi checkout smoke with `pi --approve --model zai/glm-5.2:high --no-extensions --no-skills --session-dir <tmp> -e .`, confirming the model chose `agent_browser` for `open` + `snapshot -i`, chose `agent_browser_web_search` for live search, and closed the managed browser session.
|
|
27
|
+
- Ran an independent reviewer subagent over the diff; no blockers found.
|
|
28
|
+
|
|
5
29
|
## 0.2.58 - 2026-06-23
|
|
6
30
|
|
|
7
31
|
### Changed
|
|
@@ -73,16 +73,13 @@ function colorizeToolOutputLines(outputText, theme, isError) {
|
|
|
73
73
|
return isError ? theme.fg("error", line) : theme.fg("toolOutput", line);
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
+
// ponytail: "app.tools.expand" is a host-registered keybinding id (coding-agent augments pi-tui's
|
|
77
|
+
// Keybindings via declaration merging); getKeys returns [] before the host registers its ids
|
|
78
|
+
// (bare-node tests), so fall back to the stock ctrl+o. pi-tui is already a runtime import at
|
|
79
|
+
// the entrypoint, so getKeybindings() adds no startup tax.
|
|
76
80
|
function formatExpandHint(theme) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (key)
|
|
80
|
-
return `${theme.fg("dim", key)} ${theme.fg("muted", "to expand")}`;
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
// Fall through to the built-in default key when coding-agent keybindings are unavailable.
|
|
84
|
-
}
|
|
85
|
-
return `${theme.fg("dim", "ctrl+o")} ${theme.fg("muted", "to expand")}`;
|
|
81
|
+
const key = getKeybindings().getKeys("app.tools.expand")[0] ?? "ctrl+o";
|
|
82
|
+
return `${theme.fg("dim", key)} ${theme.fg("muted", "to expand")}`;
|
|
86
83
|
}
|
|
87
84
|
function formatVisualTruncationNotice(remainingLines, totalLines, theme, width) {
|
|
88
85
|
const notice = `${theme.fg("muted", `... (${remainingLines} more lines, ${totalLines} total, `)}${formatExpandHint(theme)}${theme.fg("muted", ")")}`;
|
|
@@ -8,10 +8,10 @@ import { LAUNCH_SCOPED_FLAG_LABEL } from "./launch-scoped-flags.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const PROJECT_RULE_PROMPT = "Project rule: when browser automation is needed, prefer the native `agent_browser` tool. Do not run direct `agent-browser` bash commands unless the user explicitly asks for a bash-oriented workflow or browser-integration debugging.";
|
|
10
10
|
export const TOOL_PROMPT_GUIDELINES_PREFIX = [
|
|
11
|
-
"Use agent_browser
|
|
11
|
+
"Use agent_browser for real browser or live web content.",
|
|
12
12
|
];
|
|
13
13
|
export function buildInstalledDocsGuideline(paths) {
|
|
14
|
-
return `For
|
|
14
|
+
return `For detailed agent_browser docs, read targeted sections: ${paths.readmePath} (setup), ${paths.commandReferencePath} (commands), ${paths.toolContractPath} (result/details). Do not load the full command reference unless needed.`;
|
|
15
15
|
}
|
|
16
16
|
export const QUICK_START_GUIDELINES = [
|
|
17
17
|
`Quick start mental model: use exactly one of args (exact agent-browser CLI args after the binary), semanticAction (a thin shorthand compiled to find argv for locator actions, direct selector/ref click/check/fill, or select argv for native dropdowns), job (a constrained short-workflow schema compiled to batch --bail by default; set failFast:false only when later diagnostics should continue after a failed step), qa (a lightweight fail-fast QA preset built on batch --bail with bounded visible expected-text checks, including qa.attached for current sessions), electron (desktop Electron list/launch/status/cleanup/probe), or the experimental sourceLookup / networkSourceLookup helpers (candidates only; each compiled to batch); stdin is only for batch, eval --stdin, auth save --password-stdin, and wrapper-generated batch stdin from job, qa, sourceLookup, or networkSourceLookup, and is rejected with electron; sessionMode=fresh switches the extension-managed pi-scoped session to a fresh upstream launch when you need new launch-scoped flags (${LAUNCH_SCOPED_FLAG_LABEL}) to apply. Use outputPath for durable eval/get/snapshot captures. Do not pass --json in args; the wrapper injects it.`,
|
|
@@ -24,7 +24,7 @@ export const QUICK_START_GUIDELINES = [
|
|
|
24
24
|
"For artifact-producing commands, read the visible artifact block and details.artifactVerification before using files: check requested path, absolute path, existence, size bytes, artifact kind, optional mediaType, status, optional limitation, and verified/missing/pending/unverified counts. details.artifacts contains per-file metadata; record start rows are pending/openRecording until record stop writes the target. The wrapper creates parent directories for direct artifact paths and can save simple loopback HTTP(S) anchor downloads directly to the requested path before upstream download fallback. Browser close does not delete explicit saved files; if close reports details.artifactCleanup, use host file tools to remove paths listed in explicitArtifactPaths (when non-empty) after inspection. If close fails with details.promptGuard.reason=requested-artifacts-missing-before-close, save the exact required artifact path before closing. For annotated screenshots inside batch, put --annotate in top-level args (for example { args: [\"--annotate\", \"batch\"], stdin: \"[[\\\"screenshot\\\",\\\"/tmp/page.png\\\"]]\" }) rather than inside the screenshot step; if annotation labels crowd a dense page, use a scoped or non-annotated screenshot plus snapshot refs instead.",
|
|
25
25
|
"When details.nextActions is present, prefer those exact native agent_browser follow-up payloads over prose guidance; they may include args, stdin, sessionMode, networkSourceLookup, safety notes, or artifactPath for saved files.",
|
|
26
26
|
];
|
|
27
|
-
export const WEB_SEARCH_PROMPT_GUIDELINE = "Use agent_browser_web_search for quick live search/URL discovery; prefer it over
|
|
27
|
+
export const WEB_SEARCH_PROMPT_GUIDELINE = "Use agent_browser_web_search for quick live search/URL discovery; prefer it over public search-engine forms that can hit anti-bot/CAPTCHA-gated pages. Use agent_browser after you have a target URL; one query, one follow-up max; stop on HTTP 429.";
|
|
28
28
|
export const SHARED_BROWSER_PLAYBOOK_GUIDELINES = [
|
|
29
29
|
"Standard workflow: open the page, snapshot -i, interact using current @refs from that snapshot, and re-snapshot after navigation, scrolling, rerendering, or other major DOM changes because refs are page-scoped; the wrapper fails mutation-prone stale/recycled refs before upstream can silently target a different current-page element. On dense pages, use wrapper-side snapshot -i --search <text> or snapshot -i --filter role=<role> to render matching refs while preserving the full ref map in details.refSnapshot, add snapshot --viewport when scroll position or above/below-fold context matters, and add snapshot --diff when a quick before/after ref-map delta would prevent reading a full spill file.",
|
|
30
30
|
"For ordinary forms from one snapshot, batch multiple fill @refs before the submit/click step to avoid serial tool calls; if a fill may autosubmit, navigate, or rerender later fields, split the flow and refresh refs first.",
|
|
@@ -60,8 +60,7 @@ export const SHARED_BROWSER_PLAYBOOK_GUIDELINES = [
|
|
|
60
60
|
"Do not call --help or other exploratory inspection commands unless the user explicitly asks for them or debugging the browser integration is necessary.",
|
|
61
61
|
];
|
|
62
62
|
export const TOOL_PROMPT_GUIDELINES_SUFFIX = [
|
|
63
|
-
"Prefer agent_browser over bash for
|
|
64
|
-
"Do not fall back to osascript, AppleScript, or generic browser-driving bash commands when agent_browser can do the job.",
|
|
63
|
+
"Prefer agent_browser over bash, osascript, AppleScript, or generic browser-driving shell for sites, docs, clicking, filling, screenshots, eval, and batch workflows.",
|
|
65
64
|
"Pass exact agent-browser CLI arguments in agent_browser args when you are not using semanticAction, job, or qa, excluding the binary name and --json (agent_browser injects --json automatically).",
|
|
66
65
|
"Use agent_browser stdin only for eval --stdin, batch, auth save --password-stdin, or wrapper-generated job/qa batches instead of shell heredocs or password args; other command/stdin combinations are rejected before launch.",
|
|
67
66
|
`Let the agent_browser extension-managed session handle the common path unless you explicitly need a fresh launch for launch-scoped flags (${LAUNCH_SCOPED_FLAG_LABEL}).`,
|
|
@@ -86,12 +85,12 @@ export function buildSharedBrowserPlaybookGuidelines(options) {
|
|
|
86
85
|
}
|
|
87
86
|
/** Tier A: always-on tool promptGuidelines (keep small; Tier B lives in SHARED_BROWSER_PLAYBOOK_GUIDELINES and docs). */
|
|
88
87
|
export const RUNTIME_PROMPT_GUIDELINES = [
|
|
89
|
-
"Use agent_browser with
|
|
90
|
-
"For agent_browser,
|
|
91
|
-
"Use agent_browser
|
|
92
|
-
"For agent_browser artifacts,
|
|
93
|
-
"When agent_browser details.nextActions
|
|
94
|
-
"For agent_browser extraction, prefer get title/url/text/html/value/attr/count or eval --stdin
|
|
88
|
+
"Use agent_browser with one input mode: args, semanticAction, job, qa, sourceLookup/networkSourceLookup, or electron. stdin only for batch/eval/auth/wrapper batch; electron rejects stdin; never pass --json.",
|
|
89
|
+
"For agent_browser, use open → snapshot -i → current @refs or semanticAction → re-snapshot after navigation/scroll/rerender. Batch same-snapshot forms; split before navigation/submits. Stop before order/post/purchase/submit.",
|
|
90
|
+
"Use agent_browser sessionMode=fresh for launch-scoped flags; never put --session-mode in args. Use requested/configured profiles only; on profile failures run profiles/doctor. Profile content is model-visible.",
|
|
91
|
+
"For agent_browser artifacts, use exact user paths and verify details.artifactVerification/details.artifacts before claiming success. Save details.promptGuard-required artifacts before close; record stop needs ffmpeg; close keeps files; waited:timeout is not proof.",
|
|
92
|
+
"When agent_browser details.nextActions exists, use exact payloads over guessed selectors/prose. Dense snapshots: check Omitted high-value controls/highValueControlRefIds. Dashboards: verify scroll with screenshot/snapshot.",
|
|
93
|
+
"For agent_browser extraction, prefer get title/url/text/html/value/attr/count or eval --stdin returning a plain value, not console.log. Batch three-plus known reads; selector visibility warnings mean use visible @refs/nextActions.",
|
|
95
94
|
];
|
|
96
95
|
export function buildBrowserExecutablePathGuideline(executablePath) {
|
|
97
96
|
if (!executablePath)
|
|
@@ -115,8 +114,6 @@ export function buildToolPromptGuidelines(options) {
|
|
|
115
114
|
...RUNTIME_PROMPT_GUIDELINES,
|
|
116
115
|
...(browserExecutablePathGuideline ? [browserExecutablePathGuideline] : []),
|
|
117
116
|
...(browserDefaultProfileGuideline ? [browserDefaultProfileGuideline] : []),
|
|
118
|
-
...(options.includeWebSearch ? [WEB_SEARCH_PROMPT_GUIDELINE] : []),
|
|
119
117
|
TOOL_PROMPT_GUIDELINES_SUFFIX[0],
|
|
120
|
-
TOOL_PROMPT_GUIDELINES_SUFFIX[1],
|
|
121
118
|
];
|
|
122
119
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Scope: Live web search only; browser automation remains in the `agent_browser` tool.
|
|
5
5
|
*/
|
|
6
6
|
import { JsonSchema } from "./json-schema.js";
|
|
7
|
+
import { WEB_SEARCH_PROMPT_GUIDELINE } from "./playbook.js";
|
|
7
8
|
import { StringEnum as localStringEnum } from "./string-enum-schema.js";
|
|
8
9
|
import { DEFAULT_WEB_SEARCH_PROVIDER, WEB_SEARCH_PROVIDERS, resolvePreferredWebSearchCredential, } from "./config.js";
|
|
9
10
|
export const AGENT_BROWSER_WEB_SEARCH_TOOL_NAME = "agent_browser_web_search";
|
|
@@ -505,7 +506,7 @@ export function createAgentBrowserWebSearchTool(configState, options = {}) {
|
|
|
505
506
|
description: `Search the web with Exa or Brave when configured. Returns up to ${MAX_SEARCH_RESULT_COUNT} concise web results.`,
|
|
506
507
|
promptSnippet: "Search the live web with Exa or Brave for current or external information.",
|
|
507
508
|
promptGuidelines: [
|
|
508
|
-
|
|
509
|
+
WEB_SEARCH_PROMPT_GUIDELINE,
|
|
509
510
|
"agent_browser_web_search chooses Exa or Brave from configured keys; when both are available, Exa is preferred by default unless webSearch.preferredProvider says otherwise. Use provider only when the user/config calls for a specific provider.",
|
|
510
511
|
"Prefer agent_browser_web_search over opening or typing into public search engine result pages with agent_browser when a quick result list is enough; browser-automated search forms are often anti-bot/CAPTCHA-gated, and this tool is the fallback for discovery rather than a CAPTCHA bypass.",
|
|
511
512
|
"Do not issue parallel or repeated agent_browser_web_search calls; use one high-signal query, inspect the results, then only run a focused follow-up if needed. If the provider returns HTTP 429, stop searching and tell the user the API plan/rate limit needs time or a plan change.",
|
package/package.json
CHANGED