lsd-pi 1.3.2 → 1.3.7
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/dist/cli.js +2 -1
- package/dist/lsd-settings-manager.d.ts +2 -0
- package/dist/lsd-settings-manager.js +5 -0
- package/dist/resource-loader.js +33 -3
- package/dist/resources/extensions/browser-tools/tools/codegen.js +5 -5
- package/dist/resources/extensions/browser-tools/tools/navigation.js +107 -178
- package/dist/resources/extensions/browser-tools/tools/network-mock.js +112 -167
- package/dist/resources/extensions/browser-tools/tools/pages.js +182 -234
- package/dist/resources/extensions/browser-tools/tools/refs.js +202 -461
- package/dist/resources/extensions/browser-tools/tools/session.js +176 -323
- package/dist/resources/extensions/browser-tools/tools/state-persistence.js +91 -154
- package/dist/resources/extensions/browser-tools/utils.js +1 -1
- package/dist/resources/extensions/cache-timer/index.js +3 -2
- package/dist/resources/extensions/slash-commands/extension-manifest.json +2 -2
- package/dist/resources/extensions/slash-commands/fast.js +73 -0
- package/dist/resources/extensions/slash-commands/index.js +2 -0
- package/dist/resources/extensions/slash-commands/plan.js +37 -12
- package/dist/resources/extensions/subagent/background-job-manager.js +13 -0
- package/dist/resources/extensions/subagent/in-process-runner.js +387 -0
- package/dist/resources/extensions/subagent/index.js +278 -626
- package/dist/resources/extensions/subagent/legacy-runner.js +503 -0
- package/dist/resources/extensions/voice/index.js +96 -36
- package/dist/resources/extensions/voice/push-to-talk.js +26 -0
- package/dist/welcome-screen.js +2 -2
- package/package.json +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +19 -0
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +16 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/src/agent.ts +32 -2
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts +34 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.js +32 -4
- package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.js +127 -16
- package/packages/pi-ai/dist/providers/openai-codex-responses.test.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.d.ts +8 -1
- package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.d.ts +2 -0
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.js +67 -0
- package/packages/pi-ai/dist/providers/openai-responses.fast-mode.test.js.map +1 -0
- package/packages/pi-ai/dist/providers/openai-responses.js +21 -3
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/simple-options.js +2 -0
- package/packages/pi-ai/dist/providers/simple-options.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +5 -0
- package/packages/pi-ai/dist/types.d.ts.map +1 -1
- package/packages/pi-ai/dist/types.js.map +1 -1
- package/packages/pi-ai/src/providers/openai-codex-responses.test.ts +143 -20
- package/packages/pi-ai/src/providers/openai-codex-responses.ts +47 -4
- package/packages/pi-ai/src/providers/openai-responses.fast-mode.test.ts +73 -0
- package/packages/pi-ai/src/providers/openai-responses.ts +26 -3
- package/packages/pi-ai/src/providers/simple-options.ts +2 -0
- package/packages/pi-ai/src/types.ts +5 -0
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.js +2 -0
- package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +4 -2
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.collapse-tool-calls.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.collapse-tool-calls.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.collapse-tool-calls.test.js +35 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.collapse-tool-calls.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +12 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.js +35 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.fast-mode.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js +24 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/slash-commands.js +1 -0
- package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +6 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tool-priority.d.ts +4 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.js +18 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.js +27 -0
- package/packages/pi-coding-agent/dist/core/tool-priority.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts +5 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.js +21 -0
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.test.js +16 -1
- package/packages/pi-coding-agent/dist/core/tools/edit-diff.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.js +34 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/tool-summary-line.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.d.ts +45 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.js +314 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.js +122 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/btw-overlay.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts +7 -5
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js +86 -28
- package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts +4 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +23 -10
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +8 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +52 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +19 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +127 -14
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.d.ts +14 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.js +93 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/tool-summary-line.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.js +328 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +123 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/extension-ui-controller.js +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/extension-ui-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js +7 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts +4 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-state.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +9 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +103 -23
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +41 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +4 -4
- package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/keybindings.ts +4 -1
- package/packages/pi-coding-agent/src/core/sdk.ts +4 -2
- package/packages/pi-coding-agent/src/core/settings-manager.collapse-tool-calls.test.ts +46 -0
- package/packages/pi-coding-agent/src/core/settings-manager.fast-mode.test.ts +46 -0
- package/packages/pi-coding-agent/src/core/settings-manager.ts +36 -0
- package/packages/pi-coding-agent/src/core/slash-commands.ts +1 -0
- package/packages/pi-coding-agent/src/core/system-prompt.ts +6 -1
- package/packages/pi-coding-agent/src/core/tool-priority.test.ts +30 -0
- package/packages/pi-coding-agent/src/core/tool-priority.ts +17 -0
- package/packages/pi-coding-agent/src/core/tools/edit-diff.test.ts +20 -0
- package/packages/pi-coding-agent/src/core/tools/edit-diff.ts +26 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/tool-summary-line.test.ts +41 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/btw-overlay.test.ts +172 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/btw-overlay.ts +402 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +105 -28
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +21 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +63 -6
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1262 -1138
- package/packages/pi-coding-agent/src/modes/interactive/components/tool-summary-line.ts +120 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/__tests__/chat-controller.collapsed-tool-summary.test.ts +396 -0
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +530 -398
- package/packages/pi-coding-agent/src/modes/interactive/controllers/extension-ui-controller.ts +1 -1
- package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +7 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-state.ts +4 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +109 -23
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +60 -1
- package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +4 -4
- package/packages/pi-tui/dist/components/editor.js +3 -3
- package/packages/pi-tui/dist/components/editor.js.map +1 -1
- package/packages/pi-tui/src/components/editor.ts +3 -3
- package/pkg/dist/modes/interactive/theme/themes.js +4 -4
- package/pkg/dist/modes/interactive/theme/themes.js.map +1 -1
- package/pkg/package.json +1 -1
- package/src/resources/extensions/browser-tools/tools/codegen.ts +5 -5
- package/src/resources/extensions/browser-tools/tools/navigation.ts +118 -196
- package/src/resources/extensions/browser-tools/tools/network-mock.ts +114 -205
- package/src/resources/extensions/browser-tools/tools/pages.ts +183 -237
- package/src/resources/extensions/browser-tools/tools/refs.ts +193 -507
- package/src/resources/extensions/browser-tools/tools/session.ts +182 -321
- package/src/resources/extensions/browser-tools/tools/state-persistence.ts +94 -172
- package/src/resources/extensions/browser-tools/utils.ts +1 -1
- package/src/resources/extensions/cache-timer/index.ts +3 -2
- package/src/resources/extensions/slash-commands/extension-manifest.json +2 -2
- package/src/resources/extensions/slash-commands/fast.ts +89 -0
- package/src/resources/extensions/slash-commands/index.ts +2 -0
- package/src/resources/extensions/slash-commands/plan.ts +42 -12
- package/src/resources/extensions/subagent/background-job-manager.ts +28 -0
- package/src/resources/extensions/subagent/in-process-runner.ts +534 -0
- package/src/resources/extensions/subagent/index.ts +489 -799
- package/src/resources/extensions/subagent/legacy-runner.ts +607 -0
- package/src/resources/extensions/voice/index.ts +308 -238
- package/src/resources/extensions/voice/push-to-talk.ts +42 -0
- package/src/resources/extensions/voice/tests/push-to-talk.test.ts +109 -0
|
@@ -452,15 +452,15 @@ export class Editor implements Component, Focusable {
|
|
|
452
452
|
const remaining = width - visibleWidth(indicator);
|
|
453
453
|
result.push(this.borderColor(indicator + "─".repeat(Math.max(0, remaining))));
|
|
454
454
|
} else if (this.bottomHint) {
|
|
455
|
-
// Embed hint right
|
|
455
|
+
// Embed hint at far right in bottom border: ─────────────── hint ─
|
|
456
456
|
// Apply borderColor only to the dashes so the hint's own styling is preserved.
|
|
457
457
|
const hintVisible = visibleWidth(this.bottomHint);
|
|
458
458
|
const minDashes = 1;
|
|
459
459
|
const separatorWidth = 1; // single space on each side of hint
|
|
460
460
|
const totalFixed = hintVisible + separatorWidth * 2 + minDashes * 2;
|
|
461
461
|
if (width >= totalFixed) {
|
|
462
|
-
const
|
|
463
|
-
const
|
|
462
|
+
const rightDashes = minDashes;
|
|
463
|
+
const leftDashes = Math.max(minDashes, width - hintVisible - separatorWidth * 2 - rightDashes);
|
|
464
464
|
const line =
|
|
465
465
|
this.borderColor("─".repeat(leftDashes)) +
|
|
466
466
|
" " +
|
|
@@ -69,8 +69,8 @@ const dark = {
|
|
|
69
69
|
mdQuoteBorder: "gray",
|
|
70
70
|
mdHr: "gray",
|
|
71
71
|
mdListBullet: "accent",
|
|
72
|
-
toolDiffAdded: "
|
|
73
|
-
toolDiffRemoved: "
|
|
72
|
+
toolDiffAdded: "#4ade80",
|
|
73
|
+
toolDiffRemoved: "#fb7185",
|
|
74
74
|
toolDiffContext: "gray",
|
|
75
75
|
syntaxComment: "#6A9955",
|
|
76
76
|
syntaxKeyword: "#569CD6",
|
|
@@ -157,8 +157,8 @@ const light = {
|
|
|
157
157
|
mdQuoteBorder: "mediumGray",
|
|
158
158
|
mdHr: "mediumGray",
|
|
159
159
|
mdListBullet: "green",
|
|
160
|
-
toolDiffAdded: "
|
|
161
|
-
toolDiffRemoved: "
|
|
160
|
+
toolDiffAdded: "#15803d",
|
|
161
|
+
toolDiffRemoved: "#b91c1c",
|
|
162
162
|
toolDiffContext: "mediumGray",
|
|
163
163
|
syntaxComment: "#008000",
|
|
164
164
|
syntaxKeyword: "#0000FF",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,MAAM,IAAI,GAAc;IACvB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE;QACL,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,SAAS;QACd,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,SAAS;QAClB,UAAU,EAAE,SAAS;QACrB,QA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e,EAAE,SAAS;QAC1B,WAAW,EAAE,YAAY;QACzB,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,UAAU;QACxB,aAAa,EAAE,WAAW;QAE1B,QAAQ,EAAE,QAAQ;KAClB;IACD,MAAM,EAAE;QACP,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;KACjB;CACD,CAAC;AAEF,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAM,CAAC,MAAM,aAAa,GAA8B,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC","sourcesContent":["/**\n * Built-in theme definitions.\n *\n * Each theme is a self-contained record of color values. Variable references\n * (e.g. \"accent\") are resolved against the `vars` map at load time by the\n * theme engine in theme.ts.\n *\n * To add a new built-in theme, add an entry to `builtinThemes` below.\n */\n\n// Re-use the ThemeJson type from the schema defined in theme.ts.\n// We import only the type to avoid circular runtime dependencies.\nimport type { ThemeJson } from \"./theme.js\";\n\n// ---------------------------------------------------------------------------\n// Dark theme\n// ---------------------------------------------------------------------------\n\nconst dark: ThemeJson = {\n\tname: \"dark\",\n\tvars: {\n\t\tcyan: \"#4a8cf7\",\n\t\tblue: \"#4a8cf7\",\n\t\tgreen: \"#b5bd68\",\n\t\tred: \"#cc6666\",\n\t\tyellow: \"#facc15\",\n\t\tviolet: \"#a78bfa\",\n\t\tgray: \"#bec8d6\",\n\t\tdimGray: \"#8793a3\",\n\t\tdarkGray: \"#505050\",\n\t\taccent: \"#60a5fa\",\n\t\tblueMuted: \"#1e3a8a\",\n\t\tblueLow: \"#2563eb\",\n\t\tblueMedium: \"#4a8cf7\",\n\t\tblueHigh: \"#60a5fa\",\n\t\tblueXhigh: \"#93c5fd\",\n\t\tselectedBg: \"#323640\",\n\t\tuserMsgBg: \"#272727\",\n\t\ttoolPendingBg: \"#1e2230\",\n\t\ttoolSuccessBg: \"#1a2330\",\n\t\ttoolErrorBg: \"#2a1e30\",\n\t\tcustomMsgBg: \"#2d2838\",\n\t},\n\tcolors: {\n\t\taccent: \"accent\",\n\t\tborder: \"blue\",\n\t\tborderAccent: \"cyan\",\n\t\tborderMuted: \"blue\",\n\t\tsuccess: \"green\",\n\t\terror: \"red\",\n\t\twarning: \"yellow\",\n\t\tviolet: \"violet\",\n\t\tmuted: \"gray\",\n\t\tdim: \"dimGray\",\n\t\ttext: \"\",\n\t\tthinkingText: \"gray\",\n\n\t\tselectedBg: \"selectedBg\",\n\t\tuserMessageBg: \"userMsgBg\",\n\t\tuserMessageText: \"\",\n\t\tcustomMessageBg: \"customMsgBg\",\n\t\tcustomMessageText: \"\",\n\t\tcustomMessageLabel: \"#9575cd\",\n\t\ttoolPendingBg: \"toolPendingBg\",\n\t\ttoolSuccessBg: \"toolSuccessBg\",\n\t\ttoolErrorBg: \"toolErrorBg\",\n\t\ttoolTitle: \"\",\n\t\ttoolOutput: \"gray\",\n\n\t\tmdHeading: \"#f0c674\",\n\t\tmdLink: \"#5a8aaa\",\n\t\tmdLinkUrl: \"dimGray\",\n\t\tmdCode: \"accent\",\n\t\tmdCodeBlock: \"green\",\n\t\tmdCodeBlockBorder: \"gray\",\n\t\tmdQuote: \"gray\",\n\t\tmdQuoteBorder: \"gray\",\n\t\tmdHr: \"gray\",\n\t\tmdListBullet: \"accent\",\n\n\t\ttoolDiffAdded: \"#4ade80\",\n\t\ttoolDiffRemoved: \"#fb7185\",\n\t\ttoolDiffContext: \"gray\",\n\n\t\tsyntaxComment: \"#6A9955\",\n\t\tsyntaxKeyword: \"#569CD6\",\n\t\tsyntaxFunction: \"#DCDCAA\",\n\t\tsyntaxVariable: \"#9CDCFE\",\n\t\tsyntaxString: \"#CE9178\",\n\t\tsyntaxNumber: \"#B5CEA8\",\n\t\tsyntaxType: \"#4EC9B0\",\n\t\tsyntaxOperator: \"#D4D4D4\",\n\t\tsyntaxPunctuation: \"#D4D4D4\",\n\n\t\tthinkingOff: \"blueMuted\",\n\t\tthinkingMinimal: \"blueLow\",\n\t\tthinkingLow: \"blueMedium\",\n\t\tthinkingMedium: \"blueHigh\",\n\t\tthinkingHigh: \"blueXhigh\",\n\t\tthinkingXhigh: \"cyan\",\n\n\t\tbashMode: \"accent\",\n\t},\n\texport: {\n\t\tpageBg: \"#18181e\",\n\t\tcardBg: \"#1e1e24\",\n\t\tinfoBg: \"#3c3728\",\n\t},\n};\n\n// ---------------------------------------------------------------------------\n// Light theme\n// ---------------------------------------------------------------------------\n\nconst light: ThemeJson = {\n\tname: \"light\",\n\tvars: {\n\t\tteal: \"#3b82f6\",\n\t\tblue: \"#547da7\",\n\t\tgreen: \"#588458\",\n\t\tred: \"#aa5555\",\n\t\tyellow: \"#eab308\",\n\t\twarning: \"#7a5a00\",\n\t\tviolet: \"#8b5cf6\",\n\t\tmediumGray: \"#6c6c6c\",\n\t\tdimGray: \"#767676\",\n\t\tlightGray: \"#b0b0b0\",\n\t\tblueMuted: \"#6b8fb8\",\n\t\tblueLow: \"#547da7\",\n\t\tblueMedium: \"#3b82f6\",\n\t\tblueHigh: \"#2563eb\",\n\t\tblueXhigh: \"#1d4ed8\",\n\t\tselectedBg: \"#d0d0e0\",\n\t\tuserMsgBg: \"#e8e8e8\",\n\t\ttoolPendingBg: \"#e8eaf0\",\n\t\ttoolSuccessBg: \"#e8f0f0\",\n\t\ttoolErrorBg: \"#f0e8ee\",\n\t\tcustomMsgBg: \"#ede7f6\",\n\t},\n\tcolors: {\n\t\taccent: \"teal\",\n\t\tborder: \"blue\",\n\t\tborderAccent: \"teal\",\n\t\tborderMuted: \"lightGray\",\n\t\tsuccess: \"green\",\n\t\terror: \"red\",\n\t\twarning: \"warning\",\n\t\tviolet: \"violet\",\n\t\tmuted: \"mediumGray\",\n\t\tdim: \"dimGray\",\n\t\ttext: \"\",\n\t\tthinkingText: \"mediumGray\",\n\n\t\tselectedBg: \"selectedBg\",\n\t\tuserMessageBg: \"userMsgBg\",\n\t\tuserMessageText: \"\",\n\t\tcustomMessageBg: \"customMsgBg\",\n\t\tcustomMessageText: \"\",\n\t\tcustomMessageLabel: \"#7e57c2\",\n\t\ttoolPendingBg: \"toolPendingBg\",\n\t\ttoolSuccessBg: \"toolSuccessBg\",\n\t\ttoolErrorBg: \"toolErrorBg\",\n\t\ttoolTitle: \"\",\n\t\ttoolOutput: \"mediumGray\",\n\n\t\tmdHeading: \"yellow\",\n\t\tmdLink: \"blue\",\n\t\tmdLinkUrl: \"dimGray\",\n\t\tmdCode: \"teal\",\n\t\tmdCodeBlock: \"green\",\n\t\tmdCodeBlockBorder: \"mediumGray\",\n\t\tmdQuote: \"mediumGray\",\n\t\tmdQuoteBorder: \"mediumGray\",\n\t\tmdHr: \"mediumGray\",\n\t\tmdListBullet: \"green\",\n\n\t\ttoolDiffAdded: \"#15803d\",\n\t\ttoolDiffRemoved: \"#b91c1c\",\n\t\ttoolDiffContext: \"mediumGray\",\n\n\t\tsyntaxComment: \"#008000\",\n\t\tsyntaxKeyword: \"#0000FF\",\n\t\tsyntaxFunction: \"#795E26\",\n\t\tsyntaxVariable: \"#001080\",\n\t\tsyntaxString: \"#A31515\",\n\t\tsyntaxNumber: \"#098658\",\n\t\tsyntaxType: \"#267F99\",\n\t\tsyntaxOperator: \"#000000\",\n\t\tsyntaxPunctuation: \"#000000\",\n\n\t\tthinkingOff: \"blueMuted\",\n\t\tthinkingMinimal: \"blueLow\",\n\t\tthinkingLow: \"blueMedium\",\n\t\tthinkingMedium: \"teal\",\n\t\tthinkingHigh: \"blueHigh\",\n\t\tthinkingXhigh: \"blueXhigh\",\n\n\t\tbashMode: \"accent\",\n\t},\n\texport: {\n\t\tpageBg: \"#f8f8f8\",\n\t\tcardBg: \"#ffffff\",\n\t\tinfoBg: \"#fffae6\",\n\t},\n};\n\n// ---------------------------------------------------------------------------\n// Export\n// ---------------------------------------------------------------------------\n\nexport const builtinThemes: Record<string, ThemeJson> = { dark, light };\n"]}
|
package/pkg/package.json
CHANGED
|
@@ -84,9 +84,10 @@ export function registerCodegenTools(pi: ExtensionAPI, deps: ToolDeps): void {
|
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
case "
|
|
87
|
+
case "browser_ref": {
|
|
88
88
|
// Refs are session-specific — add comment
|
|
89
|
-
|
|
89
|
+
const refAction = params.action ?? "click";
|
|
90
|
+
testLines.push(` // browser_ref (${refAction}): ${entry.paramsSummary} — replace with stable selector`);
|
|
90
91
|
actionCount++;
|
|
91
92
|
break;
|
|
92
93
|
}
|
|
@@ -101,9 +102,8 @@ export function registerCodegenTools(pi: ExtensionAPI, deps: ToolDeps): void {
|
|
|
101
102
|
break;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
case "
|
|
105
|
-
|
|
106
|
-
actionCount++;
|
|
105
|
+
case "browser_fill_ref_handled": {
|
|
106
|
+
// Already handled by browser_ref above
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -17,216 +17,138 @@ export function registerNavigationTools(pi: ExtensionAPI, deps: ToolDeps): void
|
|
|
17
17
|
name: "browser_navigate",
|
|
18
18
|
label: "Browser Navigate",
|
|
19
19
|
description:
|
|
20
|
-
"
|
|
20
|
+
"Navigate to a URL, go back/forward in history, or reload the page. " +
|
|
21
|
+
"Use ONLY for locally-running web apps (e.g. http://localhost:3000). " +
|
|
22
|
+
"Do NOT use for documentation sites, GitHub, or external URLs — use web_search instead.",
|
|
21
23
|
parameters: Type.Object({
|
|
22
|
-
|
|
24
|
+
action: Type.Union([
|
|
25
|
+
Type.Literal("goto"),
|
|
26
|
+
Type.Literal("go_back"),
|
|
27
|
+
Type.Literal("go_forward"),
|
|
28
|
+
Type.Literal("reload"),
|
|
29
|
+
], { description: "'goto' — navigate to url (default), 'go_back'/'go_forward' — history, 'reload' — refresh page" }),
|
|
30
|
+
url: Type.Optional(Type.String({ description: "URL to navigate to (required for goto action)." })),
|
|
23
31
|
screenshot: Type.Optional(Type.Boolean({ description: "Capture and return a screenshot (default: false)", default: false })),
|
|
24
32
|
}),
|
|
25
33
|
|
|
26
34
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
27
|
-
|
|
28
|
-
let beforeState: CompactPageState | null = null;
|
|
29
|
-
try {
|
|
30
|
-
const { page: p } = await deps.ensureBrowser();
|
|
31
|
-
beforeState = await deps.captureCompactPageState(p, { includeBodyText: true });
|
|
32
|
-
actionId = deps.beginTrackedAction("browser_navigate", params, beforeState.url).id;
|
|
33
|
-
await p.goto(params.url, { waitUntil: "domcontentloaded", timeout: 30000 });
|
|
34
|
-
await p.waitForLoadState("networkidle", { timeout: 5000 }).catch(() => { /* networkidle timeout — non-fatal, page may still be usable */ });
|
|
35
|
-
await new Promise(resolve => setTimeout(resolve, 300));
|
|
36
|
-
|
|
37
|
-
const title = await p.title();
|
|
38
|
-
const url = p.url();
|
|
39
|
-
const viewport = p.viewportSize();
|
|
40
|
-
const vpText = viewport ? `${viewport.width}x${viewport.height}` : "unknown";
|
|
41
|
-
const afterState = await deps.captureCompactPageState(p, { includeBodyText: true });
|
|
42
|
-
const summary = deps.formatCompactStateSummary(afterState);
|
|
43
|
-
const jsErrors = deps.getRecentErrors(p.url());
|
|
44
|
-
const diff = diffCompactStates(beforeState, afterState);
|
|
45
|
-
setLastActionBeforeState(beforeState);
|
|
46
|
-
setLastActionAfterState(afterState);
|
|
47
|
-
deps.finishTrackedAction(actionId, {
|
|
48
|
-
status: "success",
|
|
49
|
-
afterUrl: afterState.url,
|
|
50
|
-
warningSummary: jsErrors.trim() || undefined,
|
|
51
|
-
diffSummary: diff.summary,
|
|
52
|
-
changed: diff.changed,
|
|
53
|
-
beforeState,
|
|
54
|
-
afterState,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
let screenshotContent: any[] = [];
|
|
58
|
-
if (params.screenshot) {
|
|
59
|
-
try {
|
|
60
|
-
let buf = await p.screenshot({ type: "jpeg", quality: 80, scale: "css" });
|
|
61
|
-
buf = await deps.constrainScreenshot(p, buf, "image/jpeg", 80);
|
|
62
|
-
screenshotContent = [{ type: "image", data: buf.toString("base64"), mimeType: "image/jpeg" }];
|
|
63
|
-
} catch { /* non-fatal — screenshot is optional, navigation result is still valid */ }
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
content: [
|
|
68
|
-
{ type: "text", text: `Navigated to: ${url}\nTitle: ${title}\nViewport: ${vpText}\nAction: ${actionId}${jsErrors}\n\nDiff:\n${deps.formatDiffText(diff)}\n\nPage summary:\n${summary}` },
|
|
69
|
-
...screenshotContent,
|
|
70
|
-
],
|
|
71
|
-
details: { title, url, status: "loaded", viewport: vpText, actionId, diff },
|
|
72
|
-
};
|
|
73
|
-
} catch (err: any) {
|
|
74
|
-
if (actionId !== null) {
|
|
75
|
-
deps.finishTrackedAction(actionId, { status: "error", afterUrl: deps.getActivePageOrNull()?.url() ?? "", error: err.message, beforeState: beforeState ?? undefined });
|
|
76
|
-
}
|
|
77
|
-
const errorShot = await deps.captureErrorScreenshot(deps.getActivePageOrNull());
|
|
78
|
-
const content: any[] = [{ type: "text", text: `Navigation failed: ${err.message}` }];
|
|
79
|
-
if (errorShot) {
|
|
80
|
-
content.push({ type: "image", data: errorShot.data, mimeType: errorShot.mimeType });
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
content,
|
|
84
|
-
details: { status: "error", error: err.message, actionId },
|
|
85
|
-
isError: true,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// -------------------------------------------------------------------------
|
|
92
|
-
// browser_go_back
|
|
93
|
-
// -------------------------------------------------------------------------
|
|
94
|
-
pi.registerTool({
|
|
95
|
-
name: "browser_go_back",
|
|
96
|
-
label: "Browser Go Back",
|
|
97
|
-
description: "Navigate back in browser history. Returns a compact page summary after navigation.",
|
|
98
|
-
parameters: Type.Object({}),
|
|
99
|
-
|
|
100
|
-
async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) {
|
|
101
|
-
try {
|
|
102
|
-
const { page: p } = await deps.ensureBrowser();
|
|
103
|
-
const response = await p.goBack({ waitUntil: "domcontentloaded", timeout: 10000 });
|
|
104
|
-
|
|
105
|
-
if (!response) {
|
|
106
|
-
return {
|
|
107
|
-
content: [{ type: "text", text: "No previous page in history." }],
|
|
108
|
-
details: {},
|
|
109
|
-
isError: true,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
await p.waitForLoadState("networkidle", { timeout: 5000 }).catch(() => { /* networkidle timeout — non-fatal, page may still be usable */ });
|
|
114
|
-
|
|
115
|
-
const title = await p.title();
|
|
116
|
-
const url = p.url();
|
|
117
|
-
const summary = await deps.postActionSummary(p);
|
|
118
|
-
const jsErrors = deps.getRecentErrors(p.url());
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
content: [{ type: "text", text: `Navigated back to: ${url}\nTitle: ${title}${jsErrors}\n\nPage summary:\n${summary}` }],
|
|
122
|
-
details: { title, url },
|
|
123
|
-
};
|
|
124
|
-
} catch (err: any) {
|
|
125
|
-
const errorShot = await deps.captureErrorScreenshot(deps.getActivePageOrNull());
|
|
126
|
-
const content: any[] = [{ type: "text", text: `Go back failed: ${err.message}` }];
|
|
127
|
-
if (errorShot) {
|
|
128
|
-
content.push({ type: "image", data: errorShot.data, mimeType: errorShot.mimeType });
|
|
129
|
-
}
|
|
130
|
-
return { content, details: { error: err.message }, isError: true };
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// -------------------------------------------------------------------------
|
|
136
|
-
// browser_go_forward
|
|
137
|
-
// -------------------------------------------------------------------------
|
|
138
|
-
pi.registerTool({
|
|
139
|
-
name: "browser_go_forward",
|
|
140
|
-
label: "Browser Go Forward",
|
|
141
|
-
description: "Navigate forward in browser history. Returns a compact page summary after navigation.",
|
|
142
|
-
parameters: Type.Object({}),
|
|
35
|
+
const action = params.action ?? "goto";
|
|
143
36
|
|
|
144
|
-
async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) {
|
|
145
37
|
try {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
};
|
|
38
|
+
if (action === "goto") {
|
|
39
|
+
return await gotoAction(params);
|
|
40
|
+
} else if (action === "go_back") {
|
|
41
|
+
return await goBackForward("back");
|
|
42
|
+
} else if (action === "go_forward") {
|
|
43
|
+
return await goBackForward("forward");
|
|
44
|
+
} else {
|
|
45
|
+
return await reloadAction();
|
|
155
46
|
}
|
|
156
|
-
|
|
157
|
-
await p.waitForLoadState("networkidle", { timeout: 5000 }).catch(() => { /* networkidle timeout — non-fatal, page may still be usable */ });
|
|
158
|
-
|
|
159
|
-
const title = await p.title();
|
|
160
|
-
const url = p.url();
|
|
161
|
-
const summary = await deps.postActionSummary(p);
|
|
162
|
-
const jsErrors = deps.getRecentErrors(p.url());
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
content: [{ type: "text", text: `Navigated forward to: ${url}\nTitle: ${title}${jsErrors}\n\nPage summary:\n${summary}` }],
|
|
166
|
-
details: { title, url },
|
|
167
|
-
};
|
|
168
47
|
} catch (err: any) {
|
|
169
48
|
const errorShot = await deps.captureErrorScreenshot(deps.getActivePageOrNull());
|
|
170
|
-
const content: any[] = [{ type: "text", text: `
|
|
171
|
-
if (errorShot) {
|
|
172
|
-
content.push({ type: "image", data: errorShot.data, mimeType: errorShot.mimeType });
|
|
173
|
-
}
|
|
49
|
+
const content: any[] = [{ type: "text" as const, text: `Navigation '${action}' failed: ${err.message}` }];
|
|
50
|
+
if (errorShot) content.push({ type: "image" as const, data: errorShot.data, mimeType: errorShot.mimeType });
|
|
174
51
|
return { content, details: { error: err.message }, isError: true };
|
|
175
52
|
}
|
|
176
53
|
},
|
|
177
54
|
});
|
|
178
55
|
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
56
|
+
// ── action implementations ──
|
|
57
|
+
|
|
58
|
+
async function gotoAction(params: { url?: string; screenshot?: boolean }) {
|
|
59
|
+
if (!params.url) {
|
|
60
|
+
return { content: [{ type: "text" as const, text: "Goto requires a 'url' parameter." }], details: { error: "missing_url" }, isError: true };
|
|
61
|
+
}
|
|
62
|
+
let actionId: number | null = null;
|
|
63
|
+
let beforeState: CompactPageState | null = null;
|
|
64
|
+
const { page: p } = await deps.ensureBrowser();
|
|
65
|
+
beforeState = await deps.captureCompactPageState(p, { includeBodyText: true });
|
|
66
|
+
actionId = deps.beginTrackedAction("browser_navigate", params, beforeState.url).id;
|
|
67
|
+
await p.goto(params.url, { waitUntil: "domcontentloaded", timeout: 30000 });
|
|
68
|
+
await p.waitForLoadState("networkidle", { timeout: 5000 }).catch(() => { /* non-fatal */ });
|
|
69
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
70
|
+
|
|
71
|
+
const title = await p.title();
|
|
72
|
+
const url = p.url();
|
|
73
|
+
const viewport = p.viewportSize();
|
|
74
|
+
const vpText = viewport ? `${viewport.width}x${viewport.height}` : "unknown";
|
|
75
|
+
const afterState = await deps.captureCompactPageState(p, { includeBodyText: true });
|
|
76
|
+
const summary = deps.formatCompactStateSummary(afterState);
|
|
77
|
+
const jsErrors = deps.getRecentErrors(p.url());
|
|
78
|
+
const diff = diffCompactStates(beforeState, afterState);
|
|
79
|
+
setLastActionBeforeState(beforeState);
|
|
80
|
+
setLastActionAfterState(afterState);
|
|
81
|
+
deps.finishTrackedAction(actionId, {
|
|
82
|
+
status: "success", afterUrl: afterState.url, warningSummary: jsErrors.trim() || undefined,
|
|
83
|
+
diffSummary: diff.summary, changed: diff.changed, beforeState, afterState,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
let screenshotContent: any[] = [];
|
|
87
|
+
if (params.screenshot) {
|
|
189
88
|
try {
|
|
190
|
-
|
|
191
|
-
await
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
89
|
+
let buf = await p.screenshot({ type: "jpeg", quality: 80, scale: "css" });
|
|
90
|
+
buf = await deps.constrainScreenshot(p, buf, "image/jpeg", 80);
|
|
91
|
+
screenshotContent = [{ type: "image" as const, data: buf.toString("base64"), mimeType: "image/jpeg" }];
|
|
92
|
+
} catch { /* non-fatal */ }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
content: [
|
|
97
|
+
{ type: "text" as const, text: `Navigated to: ${url}\nTitle: ${title}\nViewport: ${vpText}\nAction: ${actionId}${jsErrors}\n\nDiff:\n${deps.formatDiffText(diff)}\n\nPage summary:\n${summary}` },
|
|
98
|
+
...screenshotContent,
|
|
99
|
+
],
|
|
100
|
+
details: { title, url, status: "loaded", viewport: vpText, actionId, diff },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function goBackForward(direction: "back" | "forward") {
|
|
105
|
+
const { page: p } = await deps.ensureBrowser();
|
|
106
|
+
const response = direction === "back"
|
|
107
|
+
? await p.goBack({ waitUntil: "domcontentloaded", timeout: 10000 })
|
|
108
|
+
: await p.goForward({ waitUntil: "domcontentloaded", timeout: 10000 });
|
|
109
|
+
|
|
110
|
+
if (!response) {
|
|
111
|
+
return {
|
|
112
|
+
content: [{ type: "text" as const, text: `No ${direction} page in history.` }],
|
|
113
|
+
details: {},
|
|
114
|
+
isError: true,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await p.waitForLoadState("networkidle", { timeout: 5000 }).catch(() => { /* non-fatal */ });
|
|
119
|
+
const title = await p.title();
|
|
120
|
+
const url = p.url();
|
|
121
|
+
const summary = await deps.postActionSummary(p);
|
|
122
|
+
const jsErrors = deps.getRecentErrors(p.url());
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
content: [{ type: "text" as const, text: `Navigated ${direction} to: ${url}\nTitle: ${title}${jsErrors}\n\nPage summary:\n${summary}` }],
|
|
126
|
+
details: { title, url },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function reloadAction() {
|
|
131
|
+
const { page: p } = await deps.ensureBrowser();
|
|
132
|
+
await p.reload({ waitUntil: "domcontentloaded", timeout: 30000 });
|
|
133
|
+
await p.waitForLoadState("networkidle", { timeout: 5000 }).catch(() => { /* non-fatal */ });
|
|
134
|
+
|
|
135
|
+
const title = await p.title();
|
|
136
|
+
const url = p.url();
|
|
137
|
+
const viewport = p.viewportSize();
|
|
138
|
+
const vpText = viewport ? `${viewport.width}x${viewport.height}` : "unknown";
|
|
139
|
+
const summary = await deps.postActionSummary(p);
|
|
140
|
+
const jsErrors = deps.getRecentErrors(p.url());
|
|
141
|
+
|
|
142
|
+
let screenshotContent: any[] = [];
|
|
143
|
+
try {
|
|
144
|
+
let buf = await p.screenshot({ type: "jpeg", quality: 80, scale: "css" });
|
|
145
|
+
buf = await deps.constrainScreenshot(p, buf, "image/jpeg", 80);
|
|
146
|
+
screenshotContent = [{ type: "image" as const, data: buf.toString("base64"), mimeType: "image/jpeg" }];
|
|
147
|
+
} catch { /* non-fatal */ }
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
content: [{ type: "text" as const, text: `Reloaded: ${url}\nTitle: ${title}\nViewport: ${vpText}${jsErrors}\n\nPage summary:\n${summary}` }, ...screenshotContent],
|
|
151
|
+
details: { title, url, viewport: vpText },
|
|
152
|
+
};
|
|
153
|
+
}
|
|
232
154
|
}
|