pi-agent-browser-native 0.2.77 → 0.3.0
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 +27 -0
- package/README.md +8 -17
- package/dist/extensions/agent-browser/index.js +127 -19
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +0 -5
- package/dist/extensions/agent-browser/lib/argv-grammar.js +4 -5
- package/dist/extensions/agent-browser/lib/command-policy.js +0 -5
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +0 -6
- package/dist/extensions/agent-browser/lib/config-policy.js +0 -5
- package/dist/extensions/agent-browser/lib/config.js +0 -6
- package/dist/extensions/agent-browser/lib/electron/cdp.js +6 -7
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -7
- package/dist/extensions/agent-browser/lib/electron/discovery.js +0 -7
- package/dist/extensions/agent-browser/lib/electron/launch.js +0 -7
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/params.js +1 -6
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +0 -5
- package/dist/extensions/agent-browser/lib/input-modes/types.js +0 -5
- package/dist/extensions/agent-browser/lib/json-schema.js +0 -5
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +4 -5
- package/dist/extensions/agent-browser/lib/managed-session-capabilities.js +0 -2
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +0 -3
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +30 -13
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +0 -5
- package/dist/extensions/agent-browser/lib/managed-session-state-policy.js +1 -7
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +0 -5
- package/dist/extensions/agent-browser/lib/navigation-policy.js +0 -5
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +41 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +17 -11
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/direct-anchor-download.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +1 -1
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +22 -5
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +35 -7
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +17 -1
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +35 -18
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +4 -1
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +42 -1
- package/dist/extensions/agent-browser/lib/parsing.js +0 -7
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +4 -1
- package/dist/extensions/agent-browser/lib/playbook.js +3 -10
- package/dist/extensions/agent-browser/lib/process-identity.js +0 -5
- package/dist/extensions/agent-browser/lib/process.js +0 -7
- package/dist/extensions/agent-browser/lib/prompt-policy.js +171 -27
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +1 -8
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +6 -7
- package/dist/extensions/agent-browser/lib/results/categories.js +1 -8
- package/dist/extensions/agent-browser/lib/results/confirmation.js +0 -7
- package/dist/extensions/agent-browser/lib/results/contracts.js +0 -7
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +0 -7
- package/dist/extensions/agent-browser/lib/results/envelope.js +0 -7
- package/dist/extensions/agent-browser/lib/results/network.js +0 -7
- package/dist/extensions/agent-browser/lib/results/next-actions.js +0 -30
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +1 -7
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/managed-list-filter.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +0 -5
- package/dist/extensions/agent-browser/lib/results/presentation.js +0 -5
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +0 -7
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +0 -7
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +0 -7
- package/dist/extensions/agent-browser/lib/results/snapshot.js +0 -7
- package/dist/extensions/agent-browser/lib/results/text.js +0 -7
- package/dist/extensions/agent-browser/lib/runtime.js +4 -14
- package/dist/extensions/agent-browser/lib/session-page-state.js +0 -7
- package/dist/extensions/agent-browser/lib/string-enum-schema.js +0 -5
- package/dist/extensions/agent-browser/lib/temp.js +0 -7
- package/dist/extensions/agent-browser/lib/web-search.js +0 -5
- package/docs/ARCHITECTURE.md +16 -16
- package/docs/COMMAND_REFERENCE.md +8 -7
- package/docs/ELECTRON.md +3 -19
- package/docs/RELEASE.md +5 -17
- package/docs/REQUIREMENTS.md +4 -4
- package/docs/SUPPORT_MATRIX.md +17 -17
- package/docs/TOOL_CONTRACT.md +18 -16
- package/docs/platform-smoke.md +1 -1
- package/package.json +5 -6
- package/scripts/doctor.mjs +1 -1
- package/dist/extensions/agent-browser/lib/electron/text.js +0 -13
- package/dist/extensions/agent-browser/lib/input-modes.js +0 -10
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-artifacts.js +0 -5
- package/dist/extensions/agent-browser/lib/results/artifact-state.js +0 -13
- package/dist/extensions/agent-browser/lib/results.js +0 -14
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Derive operator prompt constraints for browser-run preflight guards and legacy bash policy.
|
|
3
|
-
* Responsibilities: Parse the latest user message into requested artifact paths and legacy bash allowance.
|
|
4
|
-
* Scope: Pure prompt-text policy; enforcement lives in orchestration prompt-guards and the extension entrypoint.
|
|
5
|
-
*/
|
|
6
1
|
const BROWSER_PROMPT_PATTERNS = [
|
|
7
2
|
/\b(?:agent[_ -]?browser|browser automation|eval\s+--stdin|screenshot|snapshot|tab\s+list)\b/i,
|
|
8
3
|
/\b(?:react\s+(?:tree|inspect|renders|suspense)|web\s+vitals|core\s+web\s+vitals|pushstate)\b/i,
|
|
@@ -17,41 +12,190 @@ const LEGACY_BASH_ALLOW_PATTERNS = [
|
|
|
17
12
|
/\bagent-browser\s+--(?:help|version)\b/i,
|
|
18
13
|
/\bdebug(?:ging)?\b.*\b(?:agent[_ -]?browser|agent_browser|browser integration)\b/i,
|
|
19
14
|
];
|
|
20
|
-
const PROMPT_ARTIFACT_PATH_PATTERN = /(?:^|[\s"'`(:])((?:\/[^\s"'`),;]+|[A-Za-z]:[\\/][^\s"'`),;]+|\.{1,2}[\\/][^\s"'`),;]+|[^\s"'`),;:\\/]+(?:[\\/][^\s"'`)
|
|
21
|
-
|
|
15
|
+
const PROMPT_ARTIFACT_PATH_PATTERN = /(?:^|[\s"'`(:])((?:\/[^\s"'`),;]+|[A-Za-z]:[\\/][^\s"'`),;]+|\.{1,2}[\\/][^\s"'`),;]+|[^\s"'`()[\],;:\\/]+(?:[\\/][^\s"'`()[\],;\\/]+)+|[^\s"'`()[\],;:\\/]+)\.(?:png|jpe?g|webp|gif|webm|mp4|har|pdf|trace|json))(?=[\s"'`),;.!?]|$)/gi;
|
|
16
|
+
const PROMPT_ARTIFACT_COLON_OUTPUT_INTENT_PATTERN = /\b(?:capture|create|export|generate|output|record|render|save|screenshot|start|take|write)\s+(?:(?:a|an|another|the)\s+)?(?:short\s+)?(?:(?:full[- ]page|page|screen)\s+)?(?:image|page|recordings?|screenshots?|screen|video)\s*:\s*$/i;
|
|
17
|
+
const PROMPT_ARTIFACT_OUTPUT_INTENT_PATTERN = /\b(?:capture|create|export|generate|output|record|render|save|screenshot|start|take|write)\s+(?:(?:a|an|another|the|this)\s+)?(?:short\s+)?(?:(?:full[- ]page|page|screen)\s+)?(?:image|page|recordings?|screenshots?|screen|video)\s+(?:directly\s+)?(?:\b(?:at|as|to)\b\s*[:=-]?|\bhere\b(?:\s+(?:if|when)\s+(?:recordings?\s+)?(?:(?:are|is)\s+)?available)?\s*[:=-]?)\s*$|\b(?:export|output|save|write)\s+(?:it\s+)?(?:at|as|to)\s*[:=-]?\s*$/i;
|
|
18
|
+
const PROMPT_ARTIFACT_UNSAFE_OUTPUT_PREFIX_PATTERN = /n['’]t\b|\b(?:cannot|disallowed|forbidden|maybe|needed|never|no|not|optional(?:ly)?|perhaps|prohibited|rather|refrain|unable|without)\b|\b(?:he|i|it|she|they|we|you)\s+(?:can|could|may|might)\b/i;
|
|
19
|
+
const PROMPT_ARTIFACT_AFFIRMATIVE_PREFIX_PATTERN = /^(?:(?:and(?:\s+then)?|then)(?:\s+please)?|please|you|(?:be|make)\s+sure\s+to|(?:can|could|will|would)\s+you(?:\s+please)?|(?:i|we)\s+(?:need|want)\s+you\s+to|you\s+(?:must|should))$/i;
|
|
20
|
+
const PROMPT_ARTIFACT_AFFIRMATIVE_LEAD_IN_PATTERN = /^(?:please\s+)?(?:capture|create|export|generate|output|record|render|save|screenshot|start|take|write)\b.*(?:[,\-:–—]|\b(?:and|then))\s*$/i;
|
|
21
|
+
const PROMPT_ARTIFACT_LIST_CONNECTOR_PATTERN = /^[\s"'`()\[\]{},;:.*!?\/&+>-]*(?:(?:and|or)[\s"'`()\[\]{},;:.*!?\/&+>-]*)?$/i;
|
|
22
|
+
const PROMPT_ARTIFACT_LIST_PREFIX_PATTERN = /^\s*(?:(?:[-*+]|\d+[.)])\s*)/;
|
|
23
|
+
const PROMPT_ARTIFACT_OPTIONAL_RECORDING_PATTERN = /\b(?:if|when)\s+(?:recordings?\s+)?(?:(?:are|is)\s+)?available\b/i;
|
|
24
|
+
const PROMPT_ARTIFACT_STANDALONE_OPTIONAL_RECORDING_PATTERN = /^\s*(?:if|when)\s+(?:recordings?\s+)?(?:(?:are|is)\s+)?available[.:;]?\s*$/i;
|
|
25
|
+
const PROMPT_ARTIFACT_EXPLICIT_OPTIONAL_PATTERN = /\b(?:optionally|if\s+(?:convenient|desired|needed|possible|you\s+can|you\s+want\s+to)|when\s+(?:convenient|desired|needed|possible)|only\s+if\s+you\s+(?:can|want\s+to))\b/i;
|
|
26
|
+
const PROMPT_ARTIFACT_REFERENCE_INTENT_PATTERN = /\btake\s+the\s+(?:image|recording|screenshot|video)\s+(?:at|from)\b/i;
|
|
27
|
+
const PROMPT_ARTIFACT_CLAUSE_BOUNDARY_PATTERN = /(?:[;.!?](?:\s|$)|\b(?:but|instead)\b)/i;
|
|
28
|
+
function getPromptArtifactKind(path) {
|
|
22
29
|
const lowerPath = path.toLowerCase();
|
|
23
30
|
if (/\.(?:webm|mp4)$/.test(lowerPath))
|
|
24
31
|
return "recording";
|
|
25
32
|
if (/\.(?:png|jpe?g|webp|gif)$/.test(lowerPath))
|
|
26
33
|
return "screenshot";
|
|
27
|
-
const lowerLine = line.toLowerCase();
|
|
28
|
-
if (lowerLine.includes("screenshot"))
|
|
29
|
-
return "screenshot";
|
|
30
|
-
if (/\b(?:screen\s+recording|recording|webm|video)\b/.test(lowerLine))
|
|
31
|
-
return "recording";
|
|
32
34
|
return undefined;
|
|
33
35
|
}
|
|
36
|
+
function getPromptArtifactIntentClause(context) {
|
|
37
|
+
return context.split(PROMPT_ARTIFACT_CLAUSE_BOUNDARY_PATTERN).at(-1) ?? context;
|
|
38
|
+
}
|
|
39
|
+
function getPromptArtifactTrailingClause(context) {
|
|
40
|
+
return context.split(PROMPT_ARTIFACT_CLAUSE_BOUNDARY_PATTERN)[0] ?? context;
|
|
41
|
+
}
|
|
42
|
+
function hasPromptArtifactOutputIntent(context) {
|
|
43
|
+
const clause = getPromptArtifactIntentClause(context)
|
|
44
|
+
.replace(/\[[^\]\r\n]*\]\(\s*$/, "")
|
|
45
|
+
.replace(/[([{\"'`]+\s*$/, "");
|
|
46
|
+
const intentMatch = clause.match(PROMPT_ARTIFACT_OUTPUT_INTENT_PATTERN) ?? clause.match(PROMPT_ARTIFACT_COLON_OUTPUT_INTENT_PATTERN);
|
|
47
|
+
if (!intentMatch)
|
|
48
|
+
return false;
|
|
49
|
+
const prefix = clause.slice(0, intentMatch.index ?? 0);
|
|
50
|
+
const governingPrefix = prefix.split(/\b(?:before|unless|until)\b/i).at(-1) ?? prefix;
|
|
51
|
+
if (PROMPT_ARTIFACT_UNSAFE_OUTPUT_PREFIX_PATTERN.test(governingPrefix))
|
|
52
|
+
return false;
|
|
53
|
+
const normalizedPrefix = governingPrefix.trim();
|
|
54
|
+
return normalizedPrefix.length === 0
|
|
55
|
+
|| PROMPT_ARTIFACT_AFFIRMATIVE_PREFIX_PATTERN.test(normalizedPrefix)
|
|
56
|
+
|| PROMPT_ARTIFACT_AFFIRMATIVE_LEAD_IN_PATTERN.test(governingPrefix);
|
|
57
|
+
}
|
|
58
|
+
function stripPromptArtifactListPrefix(context) {
|
|
59
|
+
return context.replace(PROMPT_ARTIFACT_LIST_PREFIX_PATTERN, "");
|
|
60
|
+
}
|
|
61
|
+
function normalizePromptArtifactPath(path) {
|
|
62
|
+
return path.replace(/^[([{]+/, "");
|
|
63
|
+
}
|
|
64
|
+
function isLikelyInboundPromptArtifact(path) {
|
|
65
|
+
return /(?:^|[\\/])pi-(?:attachment|clipboard|paste|upload)-/i.test(path);
|
|
66
|
+
}
|
|
34
67
|
function extractPromptRequestedArtifacts(prompt) {
|
|
35
68
|
const artifacts = [];
|
|
36
|
-
const seen = new
|
|
37
|
-
|
|
69
|
+
const seen = new Map();
|
|
70
|
+
const lines = prompt.split(/\r?\n/);
|
|
71
|
+
let inCodeFence = false;
|
|
72
|
+
let listArtifactIndexes = [];
|
|
73
|
+
let listContinuation;
|
|
74
|
+
let pendingRecordingAvailability = false;
|
|
75
|
+
for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
|
|
76
|
+
const line = lines[lineIndex] ?? "";
|
|
77
|
+
if (/^\s*(?:`{3,}|~{3,})/.test(line)) {
|
|
78
|
+
inCodeFence = !inCodeFence;
|
|
79
|
+
listArtifactIndexes = [];
|
|
80
|
+
listContinuation = undefined;
|
|
81
|
+
pendingRecordingAvailability = false;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (inCodeFence)
|
|
85
|
+
continue;
|
|
38
86
|
PROMPT_ARTIFACT_PATH_PATTERN.lastIndex = 0;
|
|
87
|
+
const pathMatches = [];
|
|
39
88
|
for (const match of line.matchAll(PROMPT_ARTIFACT_PATH_PATTERN)) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const kind = inferPromptArtifactKind(line, path);
|
|
44
|
-
if (!kind)
|
|
89
|
+
const rawPath = match[1]?.trim();
|
|
90
|
+
const path = rawPath ? normalizePromptArtifactPath(rawPath) : undefined;
|
|
91
|
+
if (!path || !rawPath)
|
|
45
92
|
continue;
|
|
46
|
-
const
|
|
47
|
-
|
|
93
|
+
const start = (match.index ?? 0) + match[0].indexOf(rawPath) + rawPath.indexOf(path);
|
|
94
|
+
pathMatches.push({ end: start + path.length, path, start });
|
|
95
|
+
}
|
|
96
|
+
if (pathMatches.length === 0 && PROMPT_ARTIFACT_STANDALONE_OPTIONAL_RECORDING_PATTERN.test(line)) {
|
|
97
|
+
if (listContinuation?.kind === "recording") {
|
|
98
|
+
for (const artifactIndex of listArtifactIndexes) {
|
|
99
|
+
if (artifacts[artifactIndex]?.kind === "recording")
|
|
100
|
+
artifacts[artifactIndex].required = false;
|
|
101
|
+
}
|
|
102
|
+
listContinuation = { ...listContinuation, required: false };
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
pendingRecordingAvailability = true;
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (pathMatches.length === 0 && pendingRecordingAvailability && /\brecordings?\b/i.test(line) && hasPromptArtifactOutputIntent(line))
|
|
110
|
+
continue;
|
|
111
|
+
const pendingRecordingAvailabilityForLine = pathMatches.length > 0 && pendingRecordingAvailability;
|
|
112
|
+
pendingRecordingAvailability = false;
|
|
113
|
+
const pathlessLine = stripPromptArtifactListPrefix(line.replace(PROMPT_ARTIFACT_PATH_PATTERN, ""));
|
|
114
|
+
const remainder = pathlessLine.replace(/[\s"'`()\[\],;:.*!?>-]+/g, "").toLowerCase();
|
|
115
|
+
const listSyntax = pathlessLine
|
|
116
|
+
.replace(PROMPT_ARTIFACT_OPTIONAL_RECORDING_PATTERN, "")
|
|
117
|
+
.replace(PROMPT_ARTIFACT_EXPLICIT_OPTIONAL_PATTERN, "");
|
|
118
|
+
const isPathList = pathMatches.length > 0 && PROMPT_ARTIFACT_LIST_CONNECTOR_PATTERN.test(listSyntax);
|
|
119
|
+
const groupOptional = new Map();
|
|
120
|
+
const candidates = [];
|
|
121
|
+
let nextGroup = 0;
|
|
122
|
+
let previousGroup;
|
|
123
|
+
let previousKind;
|
|
124
|
+
let previousPathEnd = 0;
|
|
125
|
+
for (let matchIndex = 0; matchIndex < pathMatches.length; matchIndex += 1) {
|
|
126
|
+
const { end, path, start } = pathMatches[matchIndex];
|
|
127
|
+
const localContext = stripPromptArtifactListPrefix(line.slice(previousPathEnd, start));
|
|
128
|
+
const intentContext = matchIndex === 0 && (isPathList || !remainder || ["file", "output", "path"].includes(remainder))
|
|
129
|
+
? `${lines[lineIndex - 1] ?? ""}\n${localContext}`
|
|
130
|
+
: localContext;
|
|
131
|
+
const kind = getPromptArtifactKind(path);
|
|
132
|
+
const directIntent = hasPromptArtifactOutputIntent(intentContext);
|
|
133
|
+
const sameLineContinuation = kind === previousKind && previousGroup !== undefined && PROMPT_ARTIFACT_LIST_CONNECTOR_PATTERN.test(localContext);
|
|
134
|
+
const priorLineContinuation = matchIndex === 0 && isPathList && kind === listContinuation?.kind && PROMPT_ARTIFACT_LIST_CONNECTOR_PATTERN.test(localContext);
|
|
135
|
+
let group;
|
|
136
|
+
if (directIntent) {
|
|
137
|
+
group = nextGroup++;
|
|
138
|
+
groupOptional.set(group, pendingRecordingAvailabilityForLine || PROMPT_ARTIFACT_OPTIONAL_RECORDING_PATTERN.test(getPromptArtifactIntentClause(intentContext)));
|
|
139
|
+
}
|
|
140
|
+
else if (sameLineContinuation) {
|
|
141
|
+
group = previousGroup;
|
|
142
|
+
}
|
|
143
|
+
else if (priorLineContinuation) {
|
|
144
|
+
group = nextGroup++;
|
|
145
|
+
groupOptional.set(group, listContinuation?.required === false);
|
|
146
|
+
}
|
|
147
|
+
const referenceReading = directIntent && PROMPT_ARTIFACT_REFERENCE_INTENT_PATTERN.test(getPromptArtifactIntentClause(intentContext));
|
|
148
|
+
const trailingContext = getPromptArtifactTrailingClause(line.slice(end, pathMatches[matchIndex + 1]?.start ?? line.length));
|
|
149
|
+
const explicitlyOptional = directIntent && (PROMPT_ARTIFACT_EXPLICIT_OPTIONAL_PATTERN.test(getPromptArtifactIntentClause(intentContext))
|
|
150
|
+
|| PROMPT_ARTIFACT_EXPLICIT_OPTIONAL_PATTERN.test(trailingContext));
|
|
151
|
+
if (!kind || group === undefined || referenceReading || explicitlyOptional || isLikelyInboundPromptArtifact(path)) {
|
|
152
|
+
previousGroup = undefined;
|
|
153
|
+
previousKind = undefined;
|
|
154
|
+
previousPathEnd = end;
|
|
48
155
|
continue;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
156
|
+
}
|
|
157
|
+
candidates.push({ continuedFromPriorLine: priorLineContinuation && !directIntent, group, kind, matchIndex, path });
|
|
158
|
+
previousGroup = group;
|
|
159
|
+
previousKind = kind;
|
|
160
|
+
previousPathEnd = end;
|
|
161
|
+
}
|
|
162
|
+
for (const candidate of candidates) {
|
|
163
|
+
const match = pathMatches[candidate.matchIndex];
|
|
164
|
+
const nextStart = pathMatches[candidate.matchIndex + 1]?.start ?? line.length;
|
|
165
|
+
if (PROMPT_ARTIFACT_OPTIONAL_RECORDING_PATTERN.test(getPromptArtifactTrailingClause(line.slice(match.end, nextStart)))) {
|
|
166
|
+
groupOptional.set(candidate.group, true);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const lineArtifactIndexes = [];
|
|
170
|
+
for (const candidate of candidates) {
|
|
171
|
+
const required = candidate.kind === "screenshot" || groupOptional.get(candidate.group) !== true;
|
|
172
|
+
const key = `${candidate.kind}:${candidate.path}`;
|
|
173
|
+
let artifactIndex = seen.get(key);
|
|
174
|
+
if (artifactIndex === undefined) {
|
|
175
|
+
artifactIndex = artifacts.length;
|
|
176
|
+
seen.set(key, artifactIndex);
|
|
177
|
+
artifacts.push({ kind: candidate.kind, path: candidate.path, required });
|
|
178
|
+
}
|
|
179
|
+
else if (required) {
|
|
180
|
+
artifacts[artifactIndex].required = true;
|
|
181
|
+
}
|
|
182
|
+
lineArtifactIndexes.push(artifactIndex);
|
|
183
|
+
}
|
|
184
|
+
const lastCandidate = candidates.at(-1);
|
|
185
|
+
if (isPathList && lastCandidate?.matchIndex === pathMatches.length - 1) {
|
|
186
|
+
const lastArtifact = artifacts[lineArtifactIndexes.at(-1)];
|
|
187
|
+
listContinuation = { kind: lastArtifact.kind, required: lastArtifact.required };
|
|
188
|
+
if (candidates[0]?.continuedFromPriorLine) {
|
|
189
|
+
for (const artifactIndex of lineArtifactIndexes)
|
|
190
|
+
listArtifactIndexes.push(artifactIndex);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
listArtifactIndexes = lineArtifactIndexes;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
listArtifactIndexes = [];
|
|
198
|
+
listContinuation = undefined;
|
|
55
199
|
}
|
|
56
200
|
}
|
|
57
201
|
return artifacts;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Build generic nextAction recommendations from result categories, artifacts, Electron lifecycle state, and recovery context.
|
|
3
|
-
* Responsibilities: Preserve stable action ids/order while keeping recommendation policy out of generic shared helpers.
|
|
4
|
-
* Scope: Generic result-level recommendations only; feature-specific diagnostics append their own actions in the extension entrypoint.
|
|
5
|
-
* Usage: Called by presentation and extension result assembly.
|
|
6
|
-
* Invariants/Assumptions: Action ids are public machine-readable contracts; preserve first-observed order.
|
|
7
|
-
*/
|
|
8
1
|
import { isOpenNavigationCommand, isPageMutationCommand } from "../command-taxonomy.js";
|
|
9
|
-
import { isPendingRecordingArtifact } from "./artifact-
|
|
2
|
+
import { isPendingRecordingArtifact } from "./artifact-manifest.js";
|
|
10
3
|
import { buildNextToolAction } from "./next-actions.js";
|
|
11
4
|
import { AGENT_BROWSER_RECOVERY_NEXT_ACTION_IDS, buildRecoveryNextActions, } from "./recovery-actions.js";
|
|
12
5
|
function buildArtifactAction(path) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Own persistent session artifact manifest merge, retention, and validation logic.
|
|
3
|
-
* Responsibilities: Parse manifest bounds, recognize manifest entries, merge new artifact rows, and format retention summaries.
|
|
4
|
-
* Scope: Manifest accounting only; artifact detection and presentation live in presentation modules.
|
|
5
|
-
* Usage: Imported by presentation and snapshot artifact persistence paths.
|
|
6
|
-
* Invariants/Assumptions: Explicit-path artifacts are host-owned while persistent-session spill files are bounded by the manifest cap.
|
|
7
|
-
*/
|
|
8
1
|
import { isRecord } from "../parsing.js";
|
|
2
|
+
export function isPendingRecordingCommand(command, subcommand, kind) {
|
|
3
|
+
return command === "record" && (subcommand === "start" || subcommand === "restart") && kind === "video";
|
|
4
|
+
}
|
|
5
|
+
export function isPendingRecordingArtifact(artifact) {
|
|
6
|
+
return isPendingRecordingCommand(artifact.command, artifact.subcommand, artifact.kind);
|
|
7
|
+
}
|
|
9
8
|
export const SESSION_ARTIFACT_MANIFEST_VERSION = 1;
|
|
10
9
|
export const SESSION_ARTIFACT_MANIFEST_MAX_ENTRIES_ENV = "PI_AGENT_BROWSER_SESSION_ARTIFACT_MANIFEST_MAX_ENTRIES";
|
|
11
10
|
export const DEFAULT_SESSION_ARTIFACT_MANIFEST_MAX_ENTRIES = 100;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Purpose: Classify successful and failed agent-browser outcomes into stable result categories.
|
|
3
|
-
* Responsibilities: Map artifacts, inspection calls, errors, refs, selectors, downloads, drift, and timeouts to small enums.
|
|
4
|
-
* Scope: Category policy only; next-action recommendations and presentation formatting live elsewhere.
|
|
5
|
-
* Usage: Called by presentation and extension result assembly before details are exposed to Pi.
|
|
6
|
-
* Invariants/Assumptions: Category strings are public machine-readable contracts covered by tests and docs.
|
|
7
|
-
*/
|
|
8
|
-
import { isPendingRecordingArtifact } from "./artifact-state.js";
|
|
1
|
+
import { isPendingRecordingArtifact } from "./artifact-manifest.js";
|
|
9
2
|
function hasUnverifiedFileArtifact(artifacts) {
|
|
10
3
|
return (artifacts ?? []).some((artifact) => !isPendingRecordingArtifact(artifact) && artifact.exists !== true);
|
|
11
4
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Detect upstream guarded-action confirmation-needed result shapes without creating wrapper-owned confirmation state.
|
|
3
|
-
* Responsibilities: Recognize confirmation-required markers, extract the pending upstream confirmation id, and optionally surface a short upstream action label.
|
|
4
|
-
* Scope: Pure result-shape detection shared by presentation and error derivation; command execution, approval state, and redaction stay in their existing modules.
|
|
5
|
-
* Usage: Imported by result presentation to render recovery commands and by envelope error handling to avoid hiding actionable confirmation payloads behind generic failure text.
|
|
6
|
-
* Invariants/Assumptions: Detection must be conservative: a confirmation marker and a non-empty upstream id are both required before a result is treated as actionable.
|
|
7
|
-
*/
|
|
8
1
|
import { isRecord } from "../parsing.js";
|
|
9
2
|
const CONFIRMATION_REQUIRED_FIELD_NAMES = [
|
|
10
3
|
"confirmation_required",
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Define stable result-rendering data contracts shared across focused result modules.
|
|
3
|
-
* Responsibilities: Keep upstream envelope, presentation, artifact, category, and network shapes in one type-only surface.
|
|
4
|
-
* Scope: Types only; runtime classifiers, manifests, network rules, and text helpers live in neighboring modules.
|
|
5
|
-
* Usage: Imported with `import type` by result modules and re-exported by the public results facade.
|
|
6
|
-
* Invariants/Assumptions: This file has no runtime policy so adding fields cannot hide behavior in a catch-all module.
|
|
7
|
-
*/
|
|
8
1
|
export {};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Detect whether upstream ref metadata or snapshot text proves an element is editable.
|
|
3
|
-
* Responsibilities: Parse structured ref flags and snapshot-line contenteditable/editable markers into a conservative boolean/unknown signal.
|
|
4
|
-
* Scope: Editable evidence only; callers decide how to rank controls or build recovery actions from the signal.
|
|
5
|
-
* Usage: Imported by snapshot compaction and selector/fill recovery diagnostics.
|
|
6
|
-
* Invariants/Assumptions: Explicit false evidence wins over positive hints; unknown remains undefined.
|
|
7
|
-
*/
|
|
8
1
|
const EDITABLE_REF_EVIDENCE_KEYS = ["editable", "contentEditable", "contenteditable", "isContentEditable"];
|
|
9
2
|
const EDITABLE_FALSE_TEXT_PATTERN = /\b(?:contenteditable|editable)\s*=\s*["']?(?:false|0)["']?/i;
|
|
10
3
|
const EDITABLE_ASSIGNMENT_TEXT_PATTERN = /\b(contenteditable|editable)\s*=\s*("[^"]*"|'[^']*'|[^\s,\]]+)/gi;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Parse upstream agent-browser output and turn failure envelopes into actionable error text.
|
|
3
|
-
* Responsibilities: Read inline or spilled stdout, parse observed JSON envelope shapes, normalize batch arrays, and extract the most useful error text from nested upstream failures.
|
|
4
|
-
* Scope: Envelope parsing and error derivation only; content rendering and snapshot compaction live in separate modules.
|
|
5
|
-
* Usage: Imported by the public `lib/results.ts` facade and by tests through that facade.
|
|
6
|
-
* Invariants/Assumptions: Upstream `agent-browser --json` responses follow the observed `{ success, data, error }` envelope shape or the array shape returned by `batch --json`.
|
|
7
|
-
*/
|
|
8
1
|
import { readFile } from "node:fs/promises";
|
|
9
2
|
import { isRecord } from "../parsing.js";
|
|
10
3
|
import { detectConfirmationRequired } from "./confirmation.js";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Classify failed network requests into actionable vs benign diagnostics.
|
|
3
|
-
* Responsibilities: Recognize failed request rows, de-prioritize browser icon misses, and summarize failure counts.
|
|
4
|
-
* Scope: Network diagnostic classification only.
|
|
5
|
-
* Usage: QA preset analysis and presentation network summaries.
|
|
6
|
-
* Invariants/Assumptions: Browser favicon/apple-touch icon misses are warnings; API/document/script failures are actionable.
|
|
7
|
-
*/
|
|
8
1
|
import { isRecord } from "../parsing.js";
|
|
9
2
|
export function getStringRecordField(value, key) {
|
|
10
3
|
const field = value[key];
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Own machine-readable agent_browser next-action contracts and merge policy.
|
|
3
|
-
* Responsibilities: Define the stable nextAction shape, build basic argv follow-ups, and provide deterministic action-list collection helpers.
|
|
4
|
-
* Scope: Result follow-up action mechanics only; command-specific recovery and artifact policies live in neighboring modules.
|
|
5
|
-
* Usage: Imported by result presentation helpers and the extension entrypoint when attaching details.nextActions.
|
|
6
|
-
* Invariants/Assumptions: Action ids are stable machine-readable contracts; dedupe preserves first occurrence order.
|
|
7
|
-
*/
|
|
8
1
|
export function withOptionalNamespaceArgs(namespace, args) {
|
|
9
2
|
return namespace && args[0] !== "--namespace" ? ["--namespace", namespace, ...args] : args;
|
|
10
3
|
}
|
|
@@ -65,26 +58,3 @@ export function alignPageChangeSummaryNextActionIds(summary, nextActions) {
|
|
|
65
58
|
const alignedIds = summary.nextActionIds.filter((id) => nextActionIds.has(id));
|
|
66
59
|
return alignedIds.length > 0 ? { ...summary, nextActionIds: alignedIds } : { ...summary, nextActionIds: undefined };
|
|
67
60
|
}
|
|
68
|
-
export class AgentBrowserNextActionCollector {
|
|
69
|
-
actions;
|
|
70
|
-
constructor(initialActions = undefined) {
|
|
71
|
-
this.actions = initialActions ? [...initialActions] : [];
|
|
72
|
-
}
|
|
73
|
-
append(actions) {
|
|
74
|
-
if (!actions || actions.length === 0)
|
|
75
|
-
return;
|
|
76
|
-
this.actions.push(...actions);
|
|
77
|
-
}
|
|
78
|
-
appendUnique(actions) {
|
|
79
|
-
appendUniqueAgentBrowserNextActions(this.actions, actions);
|
|
80
|
-
}
|
|
81
|
-
replace(actions) {
|
|
82
|
-
this.actions = actions ? [...actions] : [];
|
|
83
|
-
}
|
|
84
|
-
removeWhere(predicate) {
|
|
85
|
-
this.actions = this.actions.filter((action) => !predicate(action));
|
|
86
|
-
}
|
|
87
|
-
toArray() {
|
|
88
|
-
return this.actions.length > 0 ? [...this.actions] : undefined;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Own file artifact detection, verification, manifest merging, and inline image attachment for tool presentation.
|
|
3
|
-
* Responsibilities: Build artifact metadata, verification summaries, saved-file details, artifact retention notices, and safe image content.
|
|
4
|
-
* Scope: Artifact and image presentation only.
|
|
5
|
-
*/
|
|
6
1
|
import { readFile, stat } from "node:fs/promises";
|
|
7
2
|
import { extname, resolve } from "node:path";
|
|
8
3
|
import { isRecord, parsePositiveInteger } from "../../parsing.js";
|
|
9
|
-
import { formatSessionArtifactRetentionSummary, mergeSessionArtifactManifest, } from "../artifact-manifest.js";
|
|
10
|
-
import { isPendingRecordingArtifact, isPendingRecordingCommand } from "../artifact-state.js";
|
|
4
|
+
import { formatSessionArtifactRetentionSummary, isPendingRecordingArtifact, isPendingRecordingCommand, mergeSessionArtifactManifest, } from "../artifact-manifest.js";
|
|
11
5
|
import { classifyAgentBrowserSuccessCategory } from "../categories.js";
|
|
12
6
|
const IMAGE_EXTENSION_TO_MIME_TYPE = {
|
|
13
7
|
".gif": "image/gif",
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Build browser profile/config recovery hints for launch/setup failures.
|
|
3
|
-
* Responsibilities: Recognize local Chrome/profile setup errors, avoid self-loop diagnostics, and emit canonical next actions.
|
|
4
|
-
* Scope: Error presentation only; upstream profile discovery and doctor execution remain normal agent_browser commands.
|
|
5
|
-
*/
|
|
6
1
|
import { isOpenNavigationCommand } from "../../command-taxonomy.js";
|
|
7
2
|
import { getStartupScopedFlags } from "../../runtime.js";
|
|
8
3
|
import { buildNextToolAction } from "../next-actions.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Share small presentation formatting and redaction helpers across result presentation modules.
|
|
3
|
-
* Responsibilities: Normalize scalar fields, stringify model-facing values, and apply sensitive-text redaction.
|
|
4
|
-
* Scope: Leaf helpers only; command-family formatting lives in sibling modules.
|
|
5
|
-
*/
|
|
6
1
|
import { containsManagedSessionRestoreKey } from "../../managed-session-capabilities.js";
|
|
7
2
|
import { redactSensitiveText, redactSensitiveValue } from "../../runtime.js";
|
|
8
3
|
import { stringifyUnknown, truncateText } from "../text.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Share small ToolPresentation content helpers used by batch and compaction code.
|
|
3
|
-
* Responsibilities: Extract text/image/path fields and format batch step command labels.
|
|
4
|
-
* Scope: Pure ToolPresentation content helpers only.
|
|
5
|
-
*/
|
|
6
1
|
export function isStringArray(value) {
|
|
7
2
|
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
8
3
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Render diagnostic command families and safe redacted diagnostic data.
|
|
3
|
-
* Responsibilities: Format sessions, profiles, auth/cookies/storage, network diagnostics, console/errors, stream/dashboard/chat, and build network follow-up actions.
|
|
4
|
-
* Scope: Diagnostic/result-state command presentation only; core orchestration stays in presentation.ts.
|
|
5
|
-
*/
|
|
6
1
|
import { isRecord } from "../../parsing.js";
|
|
7
2
|
import { isSensitiveFieldName, redactSensitiveText, redactSensitiveValue } from "../../runtime.js";
|
|
8
3
|
import { classifyNetworkRequestFailure, isApiLikeNetworkRequest, isNetworkArtifactNoiseRequest, summarizeNetworkFailures } from "../network.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Compact oversized model-facing tool output into bounded previews and spill artifacts.
|
|
3
|
-
* Responsibilities: Write full output to persistent/session temp storage, update artifact manifests, and preserve safe previews.
|
|
4
|
-
* Scope: Large-output compaction only.
|
|
5
|
-
*/
|
|
6
1
|
import { writePersistentSessionArtifactFile, writeSecureTempFile, } from "../../temp.js";
|
|
7
2
|
import { buildEvictedSessionArtifactEntries } from "../artifact-manifest.js";
|
|
8
3
|
import { countLines, truncateText } from "../text.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Remove wrapper-owned managed session and state capabilities from caller-visible list results.
|
|
3
|
-
* Responsibilities: Recognize managed list rows recursively and preserve the surrounding upstream result shape.
|
|
4
|
-
* Scope: Presentation filtering only; command authorization lives in managed-session-state-policy.ts.
|
|
5
|
-
*/
|
|
6
1
|
import { containsManagedSessionRestoreKey, isWrapperManagedSessionName } from "../../managed-session-capabilities.js";
|
|
7
2
|
import { isRecord } from "../../parsing.js";
|
|
8
3
|
function isWrapperManagedSessionListItem(item) {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Format scalar extraction results, navigation summaries, and page-change summaries.
|
|
3
|
-
* Responsibilities: Keep navigation/extraction presentation separate from core tool result orchestration.
|
|
4
|
-
* Scope: Navigation and get/eval extraction formatting only.
|
|
5
|
-
*/
|
|
6
1
|
import { isNavigationObservableCommandName, isPageChangeSummaryCommand } from "../../command-taxonomy.js";
|
|
7
2
|
import { isRecord } from "../../parsing.js";
|
|
8
3
|
import { detectConfirmationRequired } from "../confirmation.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Map successful semanticAction results to the same presentation signals as direct ref commands.
|
|
3
|
-
* Responsibilities: Resolve presentation command names, compact action prose, and navigation-summary probe gates.
|
|
4
|
-
* Scope: semanticAction success presentation only.
|
|
5
|
-
*/
|
|
6
1
|
import { getCompiledSemanticActionCommandIndex, isCompiledSemanticActionFindCommand, } from "../../input-modes/semantic-action.js";
|
|
7
2
|
import { isRecord } from "../../parsing.js";
|
|
8
3
|
import { formatNavigationSummary, getNavigationSummary, isNavigationObservableCommand, } from "./navigation.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Render upstream agent-browser skills output as native pi tool guidance.
|
|
3
|
-
* Responsibilities: Format skills list/path/get results and translate agent-browser shell snippets to agent_browser tool calls.
|
|
4
|
-
* Scope: Skills command presentation only.
|
|
5
|
-
*/
|
|
6
1
|
import { isRecord } from "../../parsing.js";
|
|
7
2
|
import { getStringField, redactModelFacingText, stringifyModelFacing } from "./common.js";
|
|
8
3
|
function formatSkillsListText(skills) {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Purpose: Render parsed agent-browser results into concise pi-facing summaries, text content, and optional inline image attachments.
|
|
3
|
-
* Responsibilities: Orchestrate specialized presentation modules, attach inline images within size limits, and keep generic record formatting distinct from envelope parsing.
|
|
4
|
-
* Scope: Presentation shaping only; upstream stdout parsing and snapshot compaction internals live in separate modules.
|
|
5
|
-
*/
|
|
6
1
|
import { isRecord } from "../parsing.js";
|
|
7
2
|
import { extractCommandTokens } from "../runtime.js";
|
|
8
3
|
import { buildAgentBrowserNextActions } from "./action-recommendations.js";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Centralize recovery-oriented nextAction ids and action construction.
|
|
3
|
-
* Responsibilities: Build tab/about:blank/no-active-page/connected-session follow-ups and rich-input recovery ids.
|
|
4
|
-
* Scope: Recovery action contracts only; result category classification and artifact follow-ups live elsewhere.
|
|
5
|
-
* Usage: Imported by shared result action builders and the extension entrypoint.
|
|
6
|
-
* Invariants/Assumptions: Ids are public machine-readable contracts mirrored by docs and tests.
|
|
7
|
-
*/
|
|
8
1
|
import { buildNextToolAction, withOptionalSessionArgs } from "./next-actions.js";
|
|
9
2
|
export const AGENT_BROWSER_RECOVERY_NEXT_ACTION_IDS = {
|
|
10
3
|
aboutBlankListTabs: "list-tabs-for-about-blank-recovery",
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Build session-aware recovery nextActions that combine result category policy with known session/tab context.
|
|
3
|
-
* Responsibilities: Prefix recovery argv with the active session and adapt tab/about:blank/no-active/stale-ref contexts into stable nextAction lists.
|
|
4
|
-
* Scope: Recovery nextAction assembly only; diagnostic detection and action-list merge ordering stay in the extension entrypoint.
|
|
5
|
-
* Usage: Imported by the extension entrypoint when adding recovery nextActions to tool details.
|
|
6
|
-
* Invariants/Assumptions: Action ids and argv ordering are public contracts; session prefixing must not double-prefix explicit --session args.
|
|
7
|
-
*/
|
|
8
1
|
import { buildAgentBrowserNextActions } from "./action-recommendations.js";
|
|
9
2
|
import { withOptionalSessionArgs } from "./next-actions.js";
|
|
10
3
|
export function buildConnectedSessionNextActions(sessionName) {
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Own pure selector-miss recovery diagnostics for visible refs and rich editable inputs.
|
|
3
|
-
* Responsibilities: Parse find/semantic action targets, match current snapshot refs, build public diagnostics, text, and safe nextActions.
|
|
4
|
-
* Scope: Selector recovery policy only; subprocess snapshot probing and result orchestration stay in the extension entrypoint.
|
|
5
|
-
* Usage: The extension entrypoint supplies command tokens plus snapshot data after a selector-not-found failure.
|
|
6
|
-
* Invariants/Assumptions: Public fill recovery must never echo or auto-submit the user-provided fill text; guarded semanticAction fill pre-resolution may execute only one exact current editable ref.
|
|
7
|
-
*/
|
|
8
1
|
import { isRecord } from "../parsing.js";
|
|
9
2
|
import { extractRefSnapshotFromData } from "../session-page-state.js";
|
|
10
3
|
import { getEditableRefEvidence } from "./editable-ref-evidence.js";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Select the omitted snapshot refs most likely to be actionable controls.
|
|
3
|
-
* Responsibilities: Classify editable, surface, primary-action, and role-based control refs with deterministic diversity and top-up rules.
|
|
4
|
-
* Scope: High-value control ranking only; snapshot parsing, noise filtering, and presentation text live in neighboring modules.
|
|
5
|
-
* Usage: Snapshot presentation passes already-visible, non-noise omitted refs and receives the bounded high-value subset to surface.
|
|
6
|
-
* Invariants/Assumptions: Ranking must preserve scarce control categories before filling dominant buckets so dense desktop hosts stay navigable.
|
|
7
|
-
*/
|
|
8
1
|
import { compareRefIds } from "./text.js";
|
|
9
2
|
const SNAPSHOT_HIGH_VALUE_EDITABLE_REF_FILL_TARGET_LINES = 4;
|
|
10
3
|
const SNAPSHOT_HIGH_VALUE_SURFACE_REF_FILL_TARGET_LINES = 3;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Own canonical parsing and enrichment of refs from agent-browser snapshot payloads.
|
|
3
|
-
* Responsibilities: Read structured refs, correlate them with raw snapshot lines, and infer editable/ref role evidence once for consumers.
|
|
4
|
-
* Scope: Snapshot ref metadata only; section preview, high-value ranking, and presentation assembly live in neighboring modules.
|
|
5
|
-
* Usage: Imported by snapshot presentation and recovery diagnostics that need consistent ref/name/role/editable evidence.
|
|
6
|
-
* Invariants/Assumptions: Snapshot text parsing is best-effort and must tolerate upstream formatting changes by preserving structured ref data when line parsing fails.
|
|
7
|
-
*/
|
|
8
1
|
import { isRecord } from "../parsing.js";
|
|
9
2
|
import { getEditableRefEvidence } from "./editable-ref-evidence.js";
|
|
10
3
|
import { compareRefIds, normalizeWhitespace } from "./text.js";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Parse raw agent-browser snapshot text into previewable sections.
|
|
3
|
-
* Responsibilities: Identify signal lines, rank content segments, build structured previews, and provide raw-outline fallback previews.
|
|
4
|
-
* Scope: Snapshot text/section planning only; ref enrichment, high-value control ranking, spill files, and final presentation live elsewhere.
|
|
5
|
-
* Usage: Snapshot presentation uses this module before selecting displayed refs.
|
|
6
|
-
* Invariants/Assumptions: Parsing is best-effort and must stay resilient to upstream snapshot text format changes.
|
|
7
|
-
*/
|
|
8
1
|
import { normalizeWhitespace, truncateText } from "./text.js";
|
|
9
2
|
const SNAPSHOT_MAX_ADDITIONAL_SECTIONS = 2;
|
|
10
3
|
const SNAPSHOT_FALLBACK_PREVIEW_MAX_LINES = 12;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Persist full compacted snapshot payloads when model-facing output is shortened.
|
|
3
|
-
* Responsibilities: Write persistent or secure-temp snapshot spill files and merge spill retention metadata into the session artifact manifest.
|
|
4
|
-
* Scope: Snapshot spill artifact lifecycle only; preview planning and presentation text live in snapshot.ts and sibling modules.
|
|
5
|
-
* Usage: Snapshot presentation calls these helpers after deciding a snapshot is too large for inline output.
|
|
6
|
-
* Invariants/Assumptions: Explicit full-output paths are reported but not deleted here; retention state mirrors the backing storage scope.
|
|
7
|
-
*/
|
|
8
1
|
import { writePersistentSessionArtifactFile, writeSecureTempFile } from "../temp.js";
|
|
9
2
|
import { buildEvictedSessionArtifactEntries, formatSessionArtifactRetentionSummary, mergeSessionArtifactManifest, } from "./artifact-manifest.js";
|
|
10
3
|
const SNAPSHOT_SPILL_FILE_PREFIX = "pi-agent-browser-snapshot";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Compact large agent-browser snapshots into actionable pi-facing previews while preserving access to the raw payload when budgets allow.
|
|
3
|
-
* Responsibilities: Parse the current raw snapshot text format, detect when structured parsing is trustworthy, derive primary/additional content sections, rank high-value refs, and fall back to raw-outline previews when the upstream snapshot text format is unfamiliar.
|
|
4
|
-
* Scope: Snapshot-specific rendering only; generic envelope parsing, non-snapshot summaries, and image attachment live in neighboring modules.
|
|
5
|
-
* Usage: Imported by the focused presentation module for snapshot content and summary rendering.
|
|
6
|
-
* Invariants/Assumptions: Snapshot compaction should stay helpful even if upstream snapshot text formatting shifts, so structured parsing is best-effort and always has a resilient raw-outline fallback.
|
|
7
|
-
*/
|
|
8
1
|
import { isRecord } from "../parsing.js";
|
|
9
2
|
import { isHighValueControlEntry, selectHighValueControlEntries } from "./snapshot-high-value-controls.js";
|
|
10
3
|
import { buildFallbackSnapshotOutline, buildRefLineOrderMap, buildSegmentPreview, buildSnapshotSegments, canUseStructuredSnapshotPreview, chooseAdditionalSegments, choosePrimarySegment, getMeaningfulSegmentLines, getSnapshotRolePriority, isChromeSectionName, isNoiseName, parseSnapshotLines, } from "./snapshot-segments.js";
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Hold tiny text and ref-id helpers shared by result renderers.
|
|
3
|
-
* Responsibilities: Convert unknown values to text, count lines, normalize whitespace, truncate labels, and sort ref ids naturally.
|
|
4
|
-
* Scope: Generic pure utilities only; no agent-browser command policy belongs here.
|
|
5
|
-
* Usage: Imported by envelope, presentation, snapshot, and diagnostic helpers.
|
|
6
|
-
* Invariants/Assumptions: Helpers are deterministic and side-effect free.
|
|
7
|
-
*/
|
|
8
1
|
export function stringifyUnknown(value) {
|
|
9
2
|
if (typeof value === "string")
|
|
10
3
|
return value;
|