pi-agent-browser-native 0.2.22 → 0.2.24
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 +16 -0
- package/README.md +207 -191
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/COMMAND_REFERENCE.md +6 -4
- package/docs/TOOL_CONTRACT.md +9 -2
- package/extensions/agent-browser/index.ts +282 -49
- package/extensions/agent-browser/lib/playbook.ts +4 -4
- package/extensions/agent-browser/lib/results/envelope.ts +14 -1
- package/extensions/agent-browser/lib/results/presentation.ts +5 -2
- package/extensions/agent-browser/lib/runtime.ts +53 -9
- package/package.json +1 -1
|
@@ -87,11 +87,29 @@ const LEGACY_BASH_ALLOW_PATTERNS = [
|
|
|
87
87
|
const BROWSER_PROMPT_PATTERNS = [
|
|
88
88
|
/\b(?:agent[_ -]?browser|browser automation|eval\s+--stdin|screenshot|snapshot|tab\s+list)\b/i,
|
|
89
89
|
/\b(?:react\s+(?:tree|inspect|renders|suspense)|web\s+vitals|core\s+web\s+vitals|pushstate)\b/i,
|
|
90
|
+
/\b(?:live\s+docs?|online\s+research|research\s+(?:online|the\s+web)|search\s+(?:online|the\s+web)|web\s+research)\b/i,
|
|
90
91
|
/\bbrowser\b.*\b(?:automation|click|fill|navigate|open|page|screenshot|site|snapshot|tab|url|visit|web(?:site| page)?)\b/i,
|
|
91
92
|
/\b(?:browse|click|fill|login|navigate|open|visit)\b.*\b(?:https?:\/\/\S+|page|site|tab|url|web(?:site| page)?)\b/i,
|
|
92
93
|
];
|
|
93
94
|
const INSPECTION_FLAGS = new Set(["--help", "-h", "--version", "-V"]);
|
|
94
|
-
const SENSITIVE_VALUE_FLAGS = new Set(["--headers", "--proxy"]);
|
|
95
|
+
const SENSITIVE_VALUE_FLAGS = new Set(["--headers", "--password", "--proxy"]);
|
|
96
|
+
const GLOBAL_VALUE_FLAGS_ALLOWING_DASH_VALUE = new Set(["--args"]);
|
|
97
|
+
const GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES = new Set([
|
|
98
|
+
"--allow-file-access",
|
|
99
|
+
"--annotate",
|
|
100
|
+
"--auto-connect",
|
|
101
|
+
"--confirm-interactive",
|
|
102
|
+
"--content-boundaries",
|
|
103
|
+
"--debug",
|
|
104
|
+
"--headed",
|
|
105
|
+
"--ignore-https-errors",
|
|
106
|
+
"--json",
|
|
107
|
+
"--no-auto-dialog",
|
|
108
|
+
"--quiet",
|
|
109
|
+
"-q",
|
|
110
|
+
"--verbose",
|
|
111
|
+
"-v",
|
|
112
|
+
]);
|
|
95
113
|
const SENSITIVE_QUERY_PARAM_PATTERN =
|
|
96
114
|
/^(?:access(?:_|-)?token|api(?:_|-)?key|auth|authorization|bearer|client(?:_|-)?secret|code|cookie|id(?:_|-)?token|key|pass(?:word)?|refresh(?:_|-)?token|secret|session(?:_|-)?id|sig(?:nature)?|token)$/i;
|
|
97
115
|
const SENSITIVE_FIELD_NAME_PATTERN =
|
|
@@ -425,6 +443,15 @@ export function redactInvocationArgs(args: string[]): string[] {
|
|
|
425
443
|
redacted.push(redactUrlToken(token));
|
|
426
444
|
}
|
|
427
445
|
|
|
446
|
+
const commandStartIndex = findCommandStartIndex(args);
|
|
447
|
+
if (commandStartIndex !== undefined && args[commandStartIndex] === "set" && args[commandStartIndex + 1] === "credentials") {
|
|
448
|
+
for (const index of [commandStartIndex + 2, commandStartIndex + 3]) {
|
|
449
|
+
if (redacted[index] !== undefined) {
|
|
450
|
+
redacted[index] = "[REDACTED]";
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
428
455
|
return redacted;
|
|
429
456
|
}
|
|
430
457
|
|
|
@@ -654,8 +681,14 @@ export function validateToolArgs(args: string[]): string | undefined {
|
|
|
654
681
|
return undefined;
|
|
655
682
|
}
|
|
656
683
|
|
|
684
|
+
function isBooleanLiteral(token: string | undefined): boolean {
|
|
685
|
+
const normalized = token?.trim().toLowerCase();
|
|
686
|
+
return normalized === "true" || normalized === "false";
|
|
687
|
+
}
|
|
688
|
+
|
|
657
689
|
function getInvalidValueFlagDetails(args: string[]): InvalidValueFlagDetails | undefined {
|
|
658
|
-
for (
|
|
690
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
691
|
+
const token = args[index];
|
|
659
692
|
if (!token.startsWith("-")) {
|
|
660
693
|
continue;
|
|
661
694
|
}
|
|
@@ -682,7 +715,7 @@ function getInvalidValueFlagDetails(args: string[]): InvalidValueFlagDetails | u
|
|
|
682
715
|
reason: "missing-value",
|
|
683
716
|
};
|
|
684
717
|
}
|
|
685
|
-
if (receivedToken.startsWith("-")) {
|
|
718
|
+
if (receivedToken.startsWith("-") && !GLOBAL_VALUE_FLAGS_ALLOWING_DASH_VALUE.has(normalizedToken)) {
|
|
686
719
|
return {
|
|
687
720
|
flag: normalizedToken,
|
|
688
721
|
index,
|
|
@@ -690,7 +723,7 @@ function getInvalidValueFlagDetails(args: string[]): InvalidValueFlagDetails | u
|
|
|
690
723
|
receivedToken,
|
|
691
724
|
};
|
|
692
725
|
}
|
|
693
|
-
|
|
726
|
+
index += 1;
|
|
694
727
|
}
|
|
695
728
|
return undefined;
|
|
696
729
|
}
|
|
@@ -794,7 +827,7 @@ function getCompatibilityWorkaround(args: string[], commandInfo: CommandInfo): C
|
|
|
794
827
|
if (isBooleanFlagEnabled(args, "--headed")) {
|
|
795
828
|
return undefined;
|
|
796
829
|
}
|
|
797
|
-
if (hasFlagToken(args, "--cdp") || hasFlagToken(args, "--provider") || hasFlagToken(args, "-p") ||
|
|
830
|
+
if (hasFlagToken(args, "--cdp") || hasFlagToken(args, "--provider") || hasFlagToken(args, "-p") || isBooleanFlagEnabled(args, "--auto-connect")) {
|
|
798
831
|
return undefined;
|
|
799
832
|
}
|
|
800
833
|
const engine = getFlagValue(args, "--engine");
|
|
@@ -831,7 +864,7 @@ export function extractExplicitSessionName(args: string[]): string | undefined {
|
|
|
831
864
|
export function getStartupScopedFlags(args: string[]): string[] {
|
|
832
865
|
return LAUNCH_SCOPED_FLAG_DEFINITIONS
|
|
833
866
|
.map((definition) => definition.flag)
|
|
834
|
-
.filter((flag) => hasFlagToken(args, flag));
|
|
867
|
+
.filter((flag) => flag === "--auto-connect" ? isBooleanFlagEnabled(args, flag) : hasFlagToken(args, flag));
|
|
835
868
|
}
|
|
836
869
|
|
|
837
870
|
export function hasLaunchScopedTabCorrectionFlag(args: string[]): boolean {
|
|
@@ -1039,7 +1072,7 @@ export function parseCommandInfo(args: string[]): CommandInfo {
|
|
|
1039
1072
|
};
|
|
1040
1073
|
}
|
|
1041
1074
|
|
|
1042
|
-
|
|
1075
|
+
function findCommandStartIndex(args: string[]): number | undefined {
|
|
1043
1076
|
for (let index = 0; index < args.length; index += 1) {
|
|
1044
1077
|
const token = args[index];
|
|
1045
1078
|
if (token.startsWith("--session=")) {
|
|
@@ -1049,10 +1082,21 @@ export function extractCommandTokens(args: string[]): string[] {
|
|
|
1049
1082
|
const normalizedToken = token.split("=", 1)[0] ?? token;
|
|
1050
1083
|
if (GLOBAL_FLAGS_WITH_VALUES.has(normalizedToken) && !token.includes("=")) {
|
|
1051
1084
|
index += 1;
|
|
1085
|
+
} else if (
|
|
1086
|
+
GLOBAL_BOOLEAN_FLAGS_WITH_OPTIONAL_VALUES.has(normalizedToken) &&
|
|
1087
|
+
!token.includes("=") &&
|
|
1088
|
+
isBooleanLiteral(args[index + 1])
|
|
1089
|
+
) {
|
|
1090
|
+
index += 1;
|
|
1052
1091
|
}
|
|
1053
1092
|
continue;
|
|
1054
1093
|
}
|
|
1055
|
-
return
|
|
1094
|
+
return index;
|
|
1056
1095
|
}
|
|
1057
|
-
return
|
|
1096
|
+
return undefined;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
export function extractCommandTokens(args: string[]): string[] {
|
|
1100
|
+
const commandStartIndex = findCommandStartIndex(args);
|
|
1101
|
+
return commandStartIndex === undefined ? [] : args.slice(commandStartIndex);
|
|
1058
1102
|
}
|
package/package.json
CHANGED