gsd-pi 2.10.12 → 2.12.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/dist/bundled-extension-paths.d.ts +2 -0
- package/dist/bundled-extension-paths.js +10 -0
- package/dist/loader.js +45 -28
- package/dist/onboarding.js +100 -0
- package/dist/resource-loader.js +12 -3
- package/dist/resources/GSD-WORKFLOW.md +661 -0
- package/dist/resources/agents/researcher.md +29 -0
- package/dist/resources/agents/scout.md +56 -0
- package/dist/resources/agents/worker.md +31 -0
- package/dist/resources/extensions/ask-user-questions.ts +289 -0
- package/dist/resources/extensions/async-jobs/async-bash-tool.ts +211 -0
- package/dist/resources/extensions/async-jobs/await-tool.ts +101 -0
- package/dist/resources/extensions/async-jobs/cancel-job-tool.ts +34 -0
- package/dist/resources/extensions/async-jobs/index.ts +133 -0
- package/dist/resources/extensions/async-jobs/job-manager.ts +211 -0
- package/dist/resources/extensions/bg-shell/index.ts +3179 -0
- package/dist/resources/extensions/browser-tools/BROWSER-TOOLS-V2-PROPOSAL.md +1277 -0
- package/dist/resources/extensions/browser-tools/capture.ts +165 -0
- package/dist/resources/extensions/browser-tools/core.d.ts +205 -0
- package/dist/resources/extensions/browser-tools/core.js +1057 -0
- package/dist/resources/extensions/browser-tools/evaluate-helpers.ts +184 -0
- package/dist/resources/extensions/browser-tools/index.ts +51 -0
- package/dist/resources/extensions/browser-tools/lifecycle.ts +270 -0
- package/dist/resources/extensions/browser-tools/package.json +24 -0
- package/dist/resources/extensions/browser-tools/refs.ts +264 -0
- package/dist/resources/extensions/browser-tools/settle.ts +197 -0
- package/dist/resources/extensions/browser-tools/state.ts +408 -0
- package/dist/resources/extensions/browser-tools/tests/browser-tools-integration.test.mjs +652 -0
- package/dist/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +614 -0
- package/dist/resources/extensions/browser-tools/tools/assertions.ts +342 -0
- package/dist/resources/extensions/browser-tools/tools/forms.ts +801 -0
- package/dist/resources/extensions/browser-tools/tools/inspection.ts +492 -0
- package/dist/resources/extensions/browser-tools/tools/intent.ts +614 -0
- package/dist/resources/extensions/browser-tools/tools/interaction.ts +865 -0
- package/dist/resources/extensions/browser-tools/tools/navigation.ts +232 -0
- package/dist/resources/extensions/browser-tools/tools/pages.ts +303 -0
- package/dist/resources/extensions/browser-tools/tools/refs.ts +541 -0
- package/dist/resources/extensions/browser-tools/tools/screenshot.ts +83 -0
- package/dist/resources/extensions/browser-tools/tools/session.ts +400 -0
- package/dist/resources/extensions/browser-tools/tools/wait.ts +247 -0
- package/dist/resources/extensions/browser-tools/utils.ts +660 -0
- package/dist/resources/extensions/context7/index.ts +428 -0
- package/dist/resources/extensions/context7/package.json +11 -0
- package/dist/resources/extensions/get-secrets-from-user.ts +625 -0
- package/dist/resources/extensions/google-search/index.ts +336 -0
- package/dist/resources/extensions/google-search/package.json +9 -0
- package/dist/resources/extensions/gsd/activity-log.ts +116 -0
- package/dist/resources/extensions/gsd/auto.ts +3732 -0
- package/dist/resources/extensions/gsd/commands.ts +544 -0
- package/dist/resources/extensions/gsd/crash-recovery.ts +105 -0
- package/dist/resources/extensions/gsd/dashboard-overlay.ts +564 -0
- package/dist/resources/extensions/gsd/dispatch-guard.ts +78 -0
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +278 -0
- package/dist/resources/extensions/gsd/doctor.ts +766 -0
- package/dist/resources/extensions/gsd/exit-command.ts +18 -0
- package/dist/resources/extensions/gsd/files.ts +857 -0
- package/dist/resources/extensions/gsd/git-service.ts +904 -0
- package/dist/resources/extensions/gsd/gitignore.ts +200 -0
- package/dist/resources/extensions/gsd/guided-flow.ts +1054 -0
- package/dist/resources/extensions/gsd/index.ts +735 -0
- package/dist/resources/extensions/gsd/metrics.ts +374 -0
- package/dist/resources/extensions/gsd/migrate/command.ts +218 -0
- package/dist/resources/extensions/gsd/migrate/index.ts +42 -0
- package/dist/resources/extensions/gsd/migrate/parser.ts +323 -0
- package/dist/resources/extensions/gsd/migrate/parsers.ts +624 -0
- package/dist/resources/extensions/gsd/migrate/preview.ts +48 -0
- package/dist/resources/extensions/gsd/migrate/transformer.ts +346 -0
- package/dist/resources/extensions/gsd/migrate/types.ts +370 -0
- package/dist/resources/extensions/gsd/migrate/validator.ts +55 -0
- package/dist/resources/extensions/gsd/migrate/writer.ts +539 -0
- package/dist/resources/extensions/gsd/native-git-bridge.ts +181 -0
- package/dist/resources/extensions/gsd/native-parser-bridge.ts +135 -0
- package/dist/resources/extensions/gsd/observability-validator.ts +408 -0
- package/dist/resources/extensions/gsd/package.json +11 -0
- package/dist/resources/extensions/gsd/paths.ts +339 -0
- package/dist/resources/extensions/gsd/post-unit-hooks.ts +449 -0
- package/dist/resources/extensions/gsd/preferences.ts +988 -0
- package/dist/resources/extensions/gsd/prompt-loader.ts +92 -0
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +25 -0
- package/dist/resources/extensions/gsd/prompts/complete-slice.md +27 -0
- package/dist/resources/extensions/gsd/prompts/discuss.md +237 -0
- package/dist/resources/extensions/gsd/prompts/doctor-heal.md +29 -0
- package/dist/resources/extensions/gsd/prompts/execute-task.md +63 -0
- package/dist/resources/extensions/gsd/prompts/guided-complete-slice.md +3 -0
- package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +5 -0
- package/dist/resources/extensions/gsd/prompts/guided-discuss-slice.md +61 -0
- package/dist/resources/extensions/gsd/prompts/guided-execute-task.md +3 -0
- package/dist/resources/extensions/gsd/prompts/guided-plan-milestone.md +29 -0
- package/dist/resources/extensions/gsd/prompts/guided-plan-slice.md +3 -0
- package/dist/resources/extensions/gsd/prompts/guided-research-slice.md +13 -0
- package/dist/resources/extensions/gsd/prompts/guided-resume-task.md +1 -0
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +78 -0
- package/dist/resources/extensions/gsd/prompts/plan-slice.md +55 -0
- package/dist/resources/extensions/gsd/prompts/queue.md +100 -0
- package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +48 -0
- package/dist/resources/extensions/gsd/prompts/replan-slice.md +39 -0
- package/dist/resources/extensions/gsd/prompts/research-milestone.md +37 -0
- package/dist/resources/extensions/gsd/prompts/research-slice.md +28 -0
- package/dist/resources/extensions/gsd/prompts/review-migration.md +66 -0
- package/dist/resources/extensions/gsd/prompts/run-uat.md +109 -0
- package/dist/resources/extensions/gsd/prompts/system.md +190 -0
- package/dist/resources/extensions/gsd/prompts/worktree-merge.md +123 -0
- package/dist/resources/extensions/gsd/roadmap-slices.ts +50 -0
- package/dist/resources/extensions/gsd/session-forensics.ts +500 -0
- package/dist/resources/extensions/gsd/skill-discovery.ts +137 -0
- package/dist/resources/extensions/gsd/state.ts +569 -0
- package/dist/resources/extensions/gsd/templates/context.md +76 -0
- package/dist/resources/extensions/gsd/templates/decisions.md +8 -0
- package/dist/resources/extensions/gsd/templates/milestone-summary.md +73 -0
- package/dist/resources/extensions/gsd/templates/plan.md +131 -0
- package/dist/resources/extensions/gsd/templates/preferences.md +23 -0
- package/dist/resources/extensions/gsd/templates/project.md +31 -0
- package/dist/resources/extensions/gsd/templates/reassessment.md +28 -0
- package/dist/resources/extensions/gsd/templates/requirements.md +81 -0
- package/dist/resources/extensions/gsd/templates/research.md +46 -0
- package/dist/resources/extensions/gsd/templates/roadmap.md +118 -0
- package/dist/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
- package/dist/resources/extensions/gsd/templates/slice-context.md +58 -0
- package/dist/resources/extensions/gsd/templates/slice-summary.md +99 -0
- package/dist/resources/extensions/gsd/templates/state.md +19 -0
- package/dist/resources/extensions/gsd/templates/task-plan.md +52 -0
- package/dist/resources/extensions/gsd/templates/task-summary.md +57 -0
- package/dist/resources/extensions/gsd/templates/uat.md +54 -0
- package/dist/resources/extensions/gsd/tests/activity-log-prune.test.ts +297 -0
- package/dist/resources/extensions/gsd/tests/activity-log-save.test.ts +127 -0
- package/dist/resources/extensions/gsd/tests/auto-draft-pause.test.ts +109 -0
- package/dist/resources/extensions/gsd/tests/auto-preflight.test.ts +45 -0
- package/dist/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +196 -0
- package/dist/resources/extensions/gsd/tests/auto-supervisor.test.mjs +53 -0
- package/dist/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
- package/dist/resources/extensions/gsd/tests/complete-milestone.test.ts +200 -0
- package/dist/resources/extensions/gsd/tests/cost-projection.test.ts +134 -0
- package/dist/resources/extensions/gsd/tests/derive-state-deps.test.ts +312 -0
- package/dist/resources/extensions/gsd/tests/derive-state-draft.test.ts +299 -0
- package/dist/resources/extensions/gsd/tests/derive-state.test.ts +660 -0
- package/dist/resources/extensions/gsd/tests/discuss-prompt.test.ts +27 -0
- package/dist/resources/extensions/gsd/tests/dispatch-guard.test.ts +91 -0
- package/dist/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +170 -0
- package/dist/resources/extensions/gsd/tests/doctor.test.ts +594 -0
- package/dist/resources/extensions/gsd/tests/draft-promotion.test.ts +169 -0
- package/dist/resources/extensions/gsd/tests/exit-command.test.ts +50 -0
- package/dist/resources/extensions/gsd/tests/git-service.test.ts +1788 -0
- package/dist/resources/extensions/gsd/tests/idle-recovery.test.ts +577 -0
- package/dist/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +580 -0
- package/dist/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
- package/dist/resources/extensions/gsd/tests/metrics-io.test.ts +176 -0
- package/dist/resources/extensions/gsd/tests/metrics.test.ts +188 -0
- package/dist/resources/extensions/gsd/tests/migrate-command.test.ts +369 -0
- package/dist/resources/extensions/gsd/tests/migrate-parser.test.ts +757 -0
- package/dist/resources/extensions/gsd/tests/migrate-transformer.test.ts +635 -0
- package/dist/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +414 -0
- package/dist/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +297 -0
- package/dist/resources/extensions/gsd/tests/migrate-writer.test.ts +398 -0
- package/dist/resources/extensions/gsd/tests/must-have-parser.test.ts +291 -0
- package/dist/resources/extensions/gsd/tests/network-error-fallback.test.ts +54 -0
- package/dist/resources/extensions/gsd/tests/next-milestone-id.test.ts +66 -0
- package/dist/resources/extensions/gsd/tests/orphaned-branch.test.ts +353 -0
- package/dist/resources/extensions/gsd/tests/parsers.test.ts +1664 -0
- package/dist/resources/extensions/gsd/tests/plan-milestone.test.ts +133 -0
- package/dist/resources/extensions/gsd/tests/plan-quality-validator.test.ts +363 -0
- package/dist/resources/extensions/gsd/tests/post-unit-hooks.test.ts +297 -0
- package/dist/resources/extensions/gsd/tests/preferences-hooks.test.ts +226 -0
- package/dist/resources/extensions/gsd/tests/queue-draft-detection.test.ts +126 -0
- package/dist/resources/extensions/gsd/tests/reassess-prompt.test.ts +142 -0
- package/dist/resources/extensions/gsd/tests/regex-hardening.test.ts +281 -0
- package/dist/resources/extensions/gsd/tests/remote-questions.test.ts +155 -0
- package/dist/resources/extensions/gsd/tests/remote-status.test.ts +99 -0
- package/dist/resources/extensions/gsd/tests/replan-slice.test.ts +493 -0
- package/dist/resources/extensions/gsd/tests/requirements.test.ts +106 -0
- package/dist/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +35 -0
- package/dist/resources/extensions/gsd/tests/resolve-ts.mjs +11 -0
- package/dist/resources/extensions/gsd/tests/roadmap-slices.test.ts +41 -0
- package/dist/resources/extensions/gsd/tests/run-uat.test.ts +316 -0
- package/dist/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
- package/dist/resources/extensions/gsd/tests/smart-entry-draft.test.ts +123 -0
- package/dist/resources/extensions/gsd/tests/test-helpers.ts +61 -0
- package/dist/resources/extensions/gsd/tests/unique-milestone-ids.test.ts +219 -0
- package/dist/resources/extensions/gsd/tests/unit-runtime.test.ts +234 -0
- package/dist/resources/extensions/gsd/tests/workspace-index.test.ts +75 -0
- package/dist/resources/extensions/gsd/tests/worktree-integration.test.ts +234 -0
- package/dist/resources/extensions/gsd/tests/worktree-manager.test.ts +141 -0
- package/dist/resources/extensions/gsd/tests/worktree.test.ts +597 -0
- package/dist/resources/extensions/gsd/tests/write-gate.test.ts +122 -0
- package/dist/resources/extensions/gsd/types.ts +296 -0
- package/dist/resources/extensions/gsd/unit-runtime.ts +184 -0
- package/dist/resources/extensions/gsd/workspace-index.ts +189 -0
- package/dist/resources/extensions/gsd/worktree-command.ts +845 -0
- package/dist/resources/extensions/gsd/worktree-manager.ts +459 -0
- package/dist/resources/extensions/gsd/{worktree.js → worktree.ts} +92 -61
- package/dist/resources/extensions/mac-tools/index.ts +852 -0
- package/dist/resources/extensions/mac-tools/swift-cli/Package.swift +22 -0
- package/dist/resources/extensions/mac-tools/swift-cli/Sources/main.swift +1318 -0
- package/dist/resources/extensions/mcporter/index.ts +429 -0
- package/dist/resources/extensions/remote-questions/config.ts +81 -0
- package/dist/resources/extensions/remote-questions/discord-adapter.ts +128 -0
- package/dist/resources/extensions/remote-questions/format.ts +163 -0
- package/dist/resources/extensions/remote-questions/manager.ts +192 -0
- package/dist/resources/extensions/remote-questions/remote-command.ts +361 -0
- package/dist/resources/extensions/remote-questions/slack-adapter.ts +92 -0
- package/dist/resources/extensions/remote-questions/status.ts +31 -0
- package/dist/resources/extensions/remote-questions/store.ts +77 -0
- package/dist/resources/extensions/remote-questions/types.ts +75 -0
- package/dist/resources/extensions/search-the-web/cache.ts +78 -0
- package/dist/resources/extensions/search-the-web/command-search-provider.ts +99 -0
- package/dist/resources/extensions/search-the-web/format.ts +258 -0
- package/dist/resources/extensions/search-the-web/http.ts +238 -0
- package/dist/resources/extensions/search-the-web/index.ts +65 -0
- package/dist/resources/extensions/search-the-web/native-search.ts +165 -0
- package/dist/resources/extensions/search-the-web/provider.ts +136 -0
- package/dist/resources/extensions/search-the-web/tavily.ts +116 -0
- package/dist/resources/extensions/search-the-web/tool-fetch-page.ts +581 -0
- package/dist/resources/extensions/search-the-web/tool-llm-context.ts +620 -0
- package/dist/resources/extensions/search-the-web/tool-search.ts +635 -0
- package/dist/resources/extensions/search-the-web/url-utils.ts +91 -0
- package/dist/resources/extensions/shared/bundled-extension-paths.ts +11 -0
- package/dist/resources/extensions/shared/confirm-ui.ts +126 -0
- package/dist/resources/extensions/shared/interview-ui.ts +613 -0
- package/dist/resources/extensions/shared/next-action-ui.ts +197 -0
- package/dist/resources/extensions/shared/progress-widget.ts +282 -0
- package/dist/resources/extensions/shared/terminal.ts +23 -0
- package/dist/resources/extensions/shared/thinking-widget.ts +107 -0
- package/dist/resources/extensions/shared/ui.ts +400 -0
- package/dist/resources/extensions/shared/wizard-ui.ts +551 -0
- package/dist/resources/extensions/slash-commands/audit.ts +88 -0
- package/dist/resources/extensions/slash-commands/clear.ts +10 -0
- package/dist/resources/extensions/slash-commands/create-extension.ts +297 -0
- package/dist/resources/extensions/slash-commands/create-slash-command.ts +234 -0
- package/dist/resources/extensions/slash-commands/index.ts +12 -0
- package/dist/resources/extensions/subagent/agents.ts +126 -0
- package/dist/resources/extensions/subagent/index.ts +1072 -0
- package/dist/resources/extensions/subagent/isolation.ts +498 -0
- package/dist/resources/extensions/ttsr/index.ts +163 -0
- package/dist/resources/extensions/ttsr/rule-loader.ts +121 -0
- package/dist/resources/extensions/ttsr/ttsr-interrupt.md +6 -0
- package/dist/resources/extensions/ttsr/ttsr-manager.ts +430 -0
- package/dist/resources/extensions/universal-config/discovery.ts +78 -0
- package/dist/resources/extensions/universal-config/format.ts +160 -0
- package/dist/resources/extensions/universal-config/index.ts +118 -0
- package/dist/resources/extensions/universal-config/package.json +11 -0
- package/dist/resources/extensions/universal-config/scanners.ts +579 -0
- package/dist/resources/extensions/universal-config/tests/discovery.test.ts +111 -0
- package/dist/resources/extensions/universal-config/tests/format.test.ts +111 -0
- package/dist/resources/extensions/universal-config/tests/scanners.test.ts +438 -0
- package/dist/resources/extensions/universal-config/tools.ts +60 -0
- package/dist/resources/extensions/universal-config/types.ts +116 -0
- package/dist/resources/extensions/voice/index.ts +271 -0
- package/dist/resources/extensions/voice/speech-recognizer.py +504 -0
- package/dist/resources/extensions/voice/speech-recognizer.swift +154 -0
- package/dist/resources/skills/debug-like-expert/SKILL.md +231 -0
- package/dist/resources/skills/debug-like-expert/references/debugging-mindset.md +253 -0
- package/dist/resources/skills/debug-like-expert/references/hypothesis-testing.md +373 -0
- package/dist/resources/skills/debug-like-expert/references/investigation-techniques.md +337 -0
- package/dist/resources/skills/debug-like-expert/references/verification-patterns.md +425 -0
- package/dist/resources/skills/debug-like-expert/references/when-to-research.md +361 -0
- package/dist/resources/skills/frontend-design/SKILL.md +45 -0
- package/dist/resources/skills/github-workflows/SKILL.md +92 -0
- package/dist/resources/skills/github-workflows/references/gh/SKILL.md +255 -0
- package/dist/resources/skills/github-workflows/references/gh/references/issue-stories.md +204 -0
- package/dist/resources/skills/github-workflows/references/gh/references/labels.md +170 -0
- package/dist/resources/skills/github-workflows/references/gh/references/milestones.md +158 -0
- package/dist/resources/skills/github-workflows/references/gh/references/projects-v2.md +177 -0
- package/dist/resources/skills/github-workflows/references/gh/scripts/experiment_cleanup.py +191 -0
- package/dist/resources/skills/github-workflows/references/gh/scripts/github_project_setup.py +799 -0
- package/dist/resources/skills/github-workflows/references/gh/tests/__init__.py +0 -0
- package/dist/resources/skills/github-workflows/references/gh/tests/test_github_project_setup.py +608 -0
- package/dist/resources/skills/swiftui/SKILL.md +208 -0
- package/dist/resources/skills/swiftui/references/animations.md +921 -0
- package/dist/resources/skills/swiftui/references/architecture.md +1561 -0
- package/dist/resources/skills/swiftui/references/layout-system.md +1186 -0
- package/dist/resources/skills/swiftui/references/navigation.md +1492 -0
- package/dist/resources/skills/swiftui/references/networking-async.md +214 -0
- package/dist/resources/skills/swiftui/references/performance.md +1706 -0
- package/dist/resources/skills/swiftui/references/platform-integration.md +204 -0
- package/dist/resources/skills/swiftui/references/state-management.md +1443 -0
- package/dist/resources/skills/swiftui/references/swiftdata.md +297 -0
- package/dist/resources/skills/swiftui/references/testing-debugging.md +247 -0
- package/dist/resources/skills/swiftui/references/uikit-appkit-interop.md +218 -0
- package/dist/resources/skills/swiftui/workflows/add-feature.md +191 -0
- package/dist/resources/skills/swiftui/workflows/build-new-app.md +311 -0
- package/dist/resources/skills/swiftui/workflows/debug-swiftui.md +192 -0
- package/dist/resources/skills/swiftui/workflows/optimize-performance.md +197 -0
- package/dist/resources/skills/swiftui/workflows/ship-app.md +203 -0
- package/dist/resources/skills/swiftui/workflows/write-tests.md +235 -0
- package/dist/wizard.js +1 -0
- package/package.json +8 -6
- package/packages/native/dist/fd/index.d.ts +1 -0
- package/packages/native/dist/fd/index.js +1 -0
- package/packages/native/dist/grep/index.d.ts +2 -1
- package/packages/native/dist/grep/index.js +1 -0
- package/packages/native/src/__tests__/fd.test.mjs +35 -0
- package/packages/native/src/__tests__/grep.test.mjs +26 -9
- package/packages/native/src/fd/index.ts +1 -0
- package/packages/native/src/grep/index.ts +3 -2
- package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent-loop.js +169 -55
- package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts +13 -1
- 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/dist/types.d.ts +91 -1
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/src/agent-loop.ts +273 -63
- package/packages/pi-agent-core/src/agent.ts +24 -0
- package/packages/pi-agent-core/src/types.ts +98 -0
- package/packages/pi-ai/dist/env-api-keys.js +2 -0
- package/packages/pi-ai/dist/env-api-keys.js.map +1 -1
- package/packages/pi-ai/dist/models.generated.d.ts +314 -0
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.js +236 -0
- package/packages/pi-ai/dist/models.generated.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +6 -0
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +2 -0
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/types.d.ts +1 -1
- 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/env-api-keys.ts +2 -0
- package/packages/pi-ai/src/models.generated.ts +236 -0
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +8 -0
- package/packages/pi-ai/src/providers/openai-completions.ts +3 -0
- package/packages/pi-ai/src/types.ts +2 -1
- package/packages/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/cli/args.js +1 -0
- package/packages/pi-coding-agent/dist/cli/args.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts +26 -0
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +137 -22
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +20 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.js +43 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/fallback-resolver.d.ts +51 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.js +119 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.js +183 -0
- package/packages/pi-coding-agent/dist/core/fallback-resolver.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/index.js +1 -0
- package/packages/pi-coding-agent/dist/core/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.js +1 -0
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +12 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +37 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/session-manager.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/session-manager.test.js +61 -0
- package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +20 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +47 -0
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/find.js +1 -0
- package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -1
- 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 +6 -15
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +18 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +46 -4
- package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -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 +25 -2
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/cli/args.ts +1 -0
- package/packages/pi-coding-agent/src/core/agent-session.ts +167 -22
- package/packages/pi-coding-agent/src/core/auth-storage.ts +45 -0
- package/packages/pi-coding-agent/src/core/fallback-resolver.test.ts +229 -0
- package/packages/pi-coding-agent/src/core/fallback-resolver.ts +165 -0
- package/packages/pi-coding-agent/src/core/index.ts +1 -0
- package/packages/pi-coding-agent/src/core/model-resolver.ts +1 -0
- package/packages/pi-coding-agent/src/core/session-manager.test.ts +65 -0
- package/packages/pi-coding-agent/src/core/session-manager.ts +51 -1
- package/packages/pi-coding-agent/src/core/settings-manager.ts +66 -0
- package/packages/pi-coding-agent/src/core/tools/find.ts +1 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +6 -16
- package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +49 -4
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +28 -2
- package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -1
- package/packages/pi-tui/dist/autocomplete.js +3 -4
- package/packages/pi-tui/dist/autocomplete.js.map +1 -1
- package/packages/pi-tui/dist/components/editor.d.ts +7 -0
- package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/editor.js +57 -50
- package/packages/pi-tui/dist/components/editor.js.map +1 -1
- package/packages/pi-tui/src/autocomplete.ts +3 -5
- package/packages/pi-tui/src/components/editor.ts +70 -49
- package/pkg/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/pkg/dist/core/export-html/ansi-to-html.js +249 -0
- package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/pkg/dist/core/export-html/index.d.ts +37 -0
- package/pkg/dist/core/export-html/index.d.ts.map +1 -0
- package/pkg/dist/core/export-html/index.js +223 -0
- package/pkg/dist/core/export-html/index.js.map +1 -0
- package/pkg/dist/core/export-html/template.css +971 -0
- package/pkg/dist/core/export-html/template.html +54 -0
- package/pkg/dist/core/export-html/template.js +1583 -0
- package/pkg/dist/core/export-html/tool-renderer.d.ts +38 -0
- package/pkg/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/pkg/dist/core/export-html/tool-renderer.js +70 -0
- package/pkg/dist/core/export-html/tool-renderer.js.map +1 -0
- package/pkg/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/pkg/dist/core/export-html/vendor/marked.min.js +6 -0
- package/scripts/postinstall.js +30 -17
- package/src/resources/extensions/bg-shell/index.ts +51 -7
- package/src/resources/extensions/gsd/activity-log.ts +61 -14
- package/src/resources/extensions/gsd/auto.ts +288 -19
- package/src/resources/extensions/gsd/commands.ts +9 -3
- package/src/resources/extensions/gsd/dashboard-overlay.ts +55 -12
- package/src/resources/extensions/gsd/docs/preferences-reference.md +25 -0
- package/src/resources/extensions/gsd/doctor.ts +60 -3
- package/src/resources/extensions/gsd/files.ts +45 -1
- package/src/resources/extensions/gsd/git-service.ts +46 -41
- package/src/resources/extensions/gsd/guided-flow.ts +81 -9
- package/src/resources/extensions/gsd/index.ts +62 -1
- package/src/resources/extensions/gsd/native-git-bridge.ts +181 -0
- package/src/resources/extensions/gsd/paths.ts +35 -4
- package/src/resources/extensions/gsd/post-unit-hooks.ts +449 -0
- package/src/resources/extensions/gsd/preferences.ts +232 -1
- package/src/resources/extensions/gsd/prompt-loader.ts +45 -3
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -3
- package/src/resources/extensions/gsd/prompts/discuss.md +10 -8
- package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
- package/src/resources/extensions/gsd/prompts/guided-complete-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-execute-task.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -2
- package/src/resources/extensions/gsd/prompts/guided-plan-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/guided-research-slice.md +3 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +9 -12
- package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -3
- package/src/resources/extensions/gsd/prompts/queue.md +3 -1
- package/src/resources/extensions/gsd/prompts/research-milestone.md +1 -1
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/src/resources/extensions/gsd/state.ts +130 -18
- package/src/resources/extensions/gsd/templates/context.md +1 -1
- package/src/resources/extensions/gsd/templates/state.md +3 -3
- package/src/resources/extensions/gsd/tests/activity-log-save.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +5 -1
- package/src/resources/extensions/gsd/tests/doctor.test.ts +115 -1
- package/src/resources/extensions/gsd/tests/draft-promotion.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/git-service.test.ts +35 -35
- package/src/resources/extensions/gsd/tests/idle-recovery.test.ts +8 -8
- package/src/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +4 -1
- package/src/resources/extensions/gsd/tests/network-error-fallback.test.ts +54 -0
- package/src/resources/extensions/gsd/tests/orphaned-branch.test.ts +5 -5
- package/src/resources/extensions/gsd/tests/post-unit-hooks.test.ts +297 -0
- package/src/resources/extensions/gsd/tests/preferences-hooks.test.ts +226 -0
- package/src/resources/extensions/gsd/tests/regex-hardening.test.ts +12 -0
- package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +6 -0
- package/src/resources/extensions/gsd/tests/worktree-integration.test.ts +4 -4
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +4 -4
- package/src/resources/extensions/gsd/tests/worktree.test.ts +19 -19
- package/src/resources/extensions/gsd/types.ts +109 -0
- package/src/resources/extensions/gsd/worktree-manager.ts +72 -13
- package/src/resources/extensions/gsd/worktree.ts +5 -4
- package/src/resources/extensions/search-the-web/command-search-provider.ts +8 -4
- package/src/resources/extensions/search-the-web/native-search.ts +32 -23
- package/src/resources/extensions/search-the-web/provider.ts +19 -2
- package/src/resources/extensions/search-the-web/tool-fetch-page.ts +62 -0
- package/src/resources/extensions/search-the-web/tool-llm-context.ts +62 -3
- package/src/resources/extensions/search-the-web/tool-search.ts +62 -3
- package/src/resources/extensions/shared/bundled-extension-paths.ts +11 -0
- package/src/resources/extensions/subagent/index.ts +2 -1
- package/src/resources/skills/github-workflows/SKILL.md +5 -0
- package/dist/resources/extensions/gsd/git-service.d.ts +0 -225
- package/dist/resources/extensions/gsd/git-service.js +0 -756
- package/dist/resources/extensions/gsd/preferences.d.ts +0 -122
- package/dist/resources/extensions/gsd/preferences.js +0 -616
- package/dist/resources/extensions/gsd/worktree.d.ts +0 -106
- package/dist/resources/extensions/remote-questions/config.d.ts +0 -14
- package/dist/resources/extensions/remote-questions/config.js +0 -68
- package/dist/resources/extensions/remote-questions/discord-adapter.d.ts +0 -17
- package/dist/resources/extensions/remote-questions/discord-adapter.js +0 -118
- package/dist/resources/extensions/remote-questions/format.d.ts +0 -38
- package/dist/resources/extensions/remote-questions/format.js +0 -119
- package/dist/resources/extensions/remote-questions/manager.d.ts +0 -23
- package/dist/resources/extensions/remote-questions/manager.js +0 -161
- package/dist/resources/extensions/remote-questions/remote-command.d.ts +0 -6
- package/dist/resources/extensions/remote-questions/remote-command.js +0 -358
- package/dist/resources/extensions/remote-questions/slack-adapter.d.ts +0 -15
- package/dist/resources/extensions/remote-questions/slack-adapter.js +0 -82
- package/dist/resources/extensions/remote-questions/status.d.ts +0 -9
- package/dist/resources/extensions/remote-questions/status.js +0 -25
- package/dist/resources/extensions/remote-questions/store.d.ts +0 -11
- package/dist/resources/extensions/remote-questions/store.js +0 -66
- package/dist/resources/extensions/remote-questions/types.d.ts +0 -68
- package/dist/resources/extensions/remote-questions/types.js +0 -4
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@gsd/pi-coding-agent";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { stat } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
formatTimelineEntries,
|
|
7
|
+
buildFailureHypothesis,
|
|
8
|
+
summarizeBrowserSession,
|
|
9
|
+
} from "../core.js";
|
|
10
|
+
import type { ToolDeps } from "../state.js";
|
|
11
|
+
import {
|
|
12
|
+
ARTIFACT_ROOT,
|
|
13
|
+
HAR_FILENAME,
|
|
14
|
+
getPageRegistry,
|
|
15
|
+
getActiveFrame,
|
|
16
|
+
getConsoleLogs,
|
|
17
|
+
getNetworkLogs,
|
|
18
|
+
getDialogLogs,
|
|
19
|
+
getActionTimeline,
|
|
20
|
+
getActiveTraceSession,
|
|
21
|
+
setActiveTraceSession,
|
|
22
|
+
getHarState,
|
|
23
|
+
setHarState,
|
|
24
|
+
getSessionStartedAt,
|
|
25
|
+
getSessionArtifactDir,
|
|
26
|
+
} from "../state.js";
|
|
27
|
+
import {
|
|
28
|
+
getActiveFrameMetadata,
|
|
29
|
+
ensureDir,
|
|
30
|
+
} from "../utils.js";
|
|
31
|
+
|
|
32
|
+
export function registerSessionTools(pi: ExtensionAPI, deps: ToolDeps): void {
|
|
33
|
+
// -------------------------------------------------------------------------
|
|
34
|
+
// browser_close
|
|
35
|
+
// -------------------------------------------------------------------------
|
|
36
|
+
pi.registerTool({
|
|
37
|
+
name: "browser_close",
|
|
38
|
+
label: "Browser Close",
|
|
39
|
+
description: "Close the browser and clean up all resources.",
|
|
40
|
+
parameters: Type.Object({}),
|
|
41
|
+
|
|
42
|
+
async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) {
|
|
43
|
+
try {
|
|
44
|
+
await deps.closeBrowser();
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: "text", text: "Browser closed." }],
|
|
47
|
+
details: {},
|
|
48
|
+
};
|
|
49
|
+
} catch (err: any) {
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: "text", text: `Close failed: ${err.message}` }],
|
|
52
|
+
details: { error: err.message },
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// -------------------------------------------------------------------------
|
|
60
|
+
// browser_trace_start
|
|
61
|
+
// -------------------------------------------------------------------------
|
|
62
|
+
pi.registerTool({
|
|
63
|
+
name: "browser_trace_start",
|
|
64
|
+
label: "Browser Trace Start",
|
|
65
|
+
description: "Start a Playwright trace for the current browser session and persist trace metadata under the session artifact directory.",
|
|
66
|
+
parameters: Type.Object({
|
|
67
|
+
name: Type.Optional(Type.String({ description: "Optional short trace session name for artifact filenames." })),
|
|
68
|
+
title: Type.Optional(Type.String({ description: "Optional trace title recorded in metadata." })),
|
|
69
|
+
}),
|
|
70
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
71
|
+
try {
|
|
72
|
+
const { context: browserContext } = await deps.ensureBrowser();
|
|
73
|
+
const activeTrace = getActiveTraceSession();
|
|
74
|
+
if (activeTrace) {
|
|
75
|
+
return {
|
|
76
|
+
content: [{ type: "text", text: `Trace already active: ${activeTrace.name}` }],
|
|
77
|
+
details: { error: "trace_already_active", activeTraceSession: activeTrace, ...deps.getSessionArtifactMetadata() },
|
|
78
|
+
isError: true,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const startedAt = Date.now();
|
|
82
|
+
const name = (params.name?.trim() || `trace-${deps.formatArtifactTimestamp(startedAt)}`).replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
83
|
+
await browserContext.tracing.start({ screenshots: true, snapshots: true, sources: true, title: params.title ?? name });
|
|
84
|
+
setActiveTraceSession({ startedAt, name, title: params.title ?? name });
|
|
85
|
+
return {
|
|
86
|
+
content: [{ type: "text", text: `Trace started: ${name}\nSession dir: ${getSessionArtifactDir()}` }],
|
|
87
|
+
details: { activeTraceSession: getActiveTraceSession(), ...deps.getSessionArtifactMetadata() },
|
|
88
|
+
};
|
|
89
|
+
} catch (err: any) {
|
|
90
|
+
return {
|
|
91
|
+
content: [{ type: "text", text: `Trace start failed: ${err.message}` }],
|
|
92
|
+
details: { error: err.message, ...deps.getSessionArtifactMetadata() },
|
|
93
|
+
isError: true,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// -------------------------------------------------------------------------
|
|
100
|
+
// browser_trace_stop
|
|
101
|
+
// -------------------------------------------------------------------------
|
|
102
|
+
pi.registerTool({
|
|
103
|
+
name: "browser_trace_stop",
|
|
104
|
+
label: "Browser Trace Stop",
|
|
105
|
+
description: "Stop the active Playwright trace and write the trace zip to disk under the session artifact directory.",
|
|
106
|
+
parameters: Type.Object({
|
|
107
|
+
name: Type.Optional(Type.String({ description: "Optional artifact basename override for the trace zip." })),
|
|
108
|
+
}),
|
|
109
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
110
|
+
try {
|
|
111
|
+
const { context: browserContext } = await deps.ensureBrowser();
|
|
112
|
+
const activeTrace = getActiveTraceSession();
|
|
113
|
+
if (!activeTrace) {
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text", text: "No active trace session to stop." }],
|
|
116
|
+
details: { error: "trace_not_active", ...deps.getSessionArtifactMetadata() },
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const traceSession = activeTrace;
|
|
121
|
+
const traceName = (params.name?.trim() || traceSession.name).replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
122
|
+
const tracePath = deps.buildSessionArtifactPath(`${traceName}.trace.zip`);
|
|
123
|
+
await browserContext.tracing.stop({ path: tracePath });
|
|
124
|
+
const fileStat = await stat(tracePath);
|
|
125
|
+
setActiveTraceSession(null);
|
|
126
|
+
return {
|
|
127
|
+
content: [{ type: "text", text: `Trace stopped: ${tracePath}` }],
|
|
128
|
+
details: {
|
|
129
|
+
path: tracePath,
|
|
130
|
+
bytes: fileStat.size,
|
|
131
|
+
elapsedMs: Date.now() - traceSession.startedAt,
|
|
132
|
+
traceName,
|
|
133
|
+
...deps.getSessionArtifactMetadata(),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
} catch (err: any) {
|
|
137
|
+
return {
|
|
138
|
+
content: [{ type: "text", text: `Trace stop failed: ${err.message}` }],
|
|
139
|
+
details: { error: err.message, ...deps.getSessionArtifactMetadata() },
|
|
140
|
+
isError: true,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// -------------------------------------------------------------------------
|
|
147
|
+
// browser_export_har
|
|
148
|
+
// -------------------------------------------------------------------------
|
|
149
|
+
pi.registerTool({
|
|
150
|
+
name: "browser_export_har",
|
|
151
|
+
label: "Browser Export HAR",
|
|
152
|
+
description: "Export the truthfully recorded session HAR from disk to a stable artifact path and return compact metadata.",
|
|
153
|
+
parameters: Type.Object({
|
|
154
|
+
filename: Type.Optional(Type.String({ description: "Optional destination filename within the session artifact directory." })),
|
|
155
|
+
}),
|
|
156
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
157
|
+
try {
|
|
158
|
+
await deps.ensureBrowser();
|
|
159
|
+
const harState = getHarState();
|
|
160
|
+
if (!harState.enabled || !harState.configuredAtContextCreation || !harState.path) {
|
|
161
|
+
return {
|
|
162
|
+
content: [{ type: "text", text: "HAR export unavailable: HAR recording was not enabled at browser context creation." }],
|
|
163
|
+
details: { error: "har_not_enabled", ...deps.getSessionArtifactMetadata() },
|
|
164
|
+
isError: true,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const sourcePath = harState.path;
|
|
168
|
+
const destinationName = (params.filename?.trim() || `export-${HAR_FILENAME}`).replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
169
|
+
const destinationPath = deps.buildSessionArtifactPath(destinationName);
|
|
170
|
+
const exportResult = sourcePath === destinationPath
|
|
171
|
+
? { path: sourcePath, bytes: (await stat(sourcePath)).size }
|
|
172
|
+
: await deps.copyArtifactFile(sourcePath, destinationPath);
|
|
173
|
+
setHarState({
|
|
174
|
+
...harState,
|
|
175
|
+
exportCount: harState.exportCount + 1,
|
|
176
|
+
lastExportedPath: exportResult.path,
|
|
177
|
+
lastExportedAt: Date.now(),
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
content: [{ type: "text", text: `HAR exported: ${exportResult.path}` }],
|
|
181
|
+
details: { path: exportResult.path, bytes: exportResult.bytes, ...deps.getSessionArtifactMetadata() },
|
|
182
|
+
};
|
|
183
|
+
} catch (err: any) {
|
|
184
|
+
return {
|
|
185
|
+
content: [{ type: "text", text: `HAR export failed: ${err.message}` }],
|
|
186
|
+
details: { error: err.message, ...deps.getSessionArtifactMetadata() },
|
|
187
|
+
isError: true,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// -------------------------------------------------------------------------
|
|
194
|
+
// browser_timeline
|
|
195
|
+
// -------------------------------------------------------------------------
|
|
196
|
+
pi.registerTool({
|
|
197
|
+
name: "browser_timeline",
|
|
198
|
+
label: "Browser Timeline",
|
|
199
|
+
description: "Return a compact structured summary of the tracked browser action timeline and optional on-disk export path.",
|
|
200
|
+
parameters: Type.Object({
|
|
201
|
+
writeToDisk: Type.Optional(Type.Boolean({ description: "Write the timeline JSON to disk under the session artifact directory." })),
|
|
202
|
+
filename: Type.Optional(Type.String({ description: "Optional JSON filename when writeToDisk is true." })),
|
|
203
|
+
}),
|
|
204
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
205
|
+
try {
|
|
206
|
+
await deps.ensureBrowser();
|
|
207
|
+
const actionTimeline = getActionTimeline();
|
|
208
|
+
const timeline = formatTimelineEntries(actionTimeline.entries, {
|
|
209
|
+
limit: actionTimeline.limit,
|
|
210
|
+
totalActions: actionTimeline.nextId - 1,
|
|
211
|
+
});
|
|
212
|
+
let artifact: { path: string; bytes: number } | null = null;
|
|
213
|
+
if (params.writeToDisk) {
|
|
214
|
+
const filename = (params.filename?.trim() || "timeline.json").replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
215
|
+
artifact = await deps.writeArtifactFile(deps.buildSessionArtifactPath(filename), JSON.stringify(timeline, null, 2));
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
content: [{ type: "text", text: artifact ? `${timeline.summary}\nArtifact: ${artifact.path}` : timeline.summary }],
|
|
219
|
+
details: { ...timeline, artifact, ...deps.getSessionArtifactMetadata() },
|
|
220
|
+
};
|
|
221
|
+
} catch (err: any) {
|
|
222
|
+
return {
|
|
223
|
+
content: [{ type: "text", text: `Timeline failed: ${err.message}` }],
|
|
224
|
+
details: { error: err.message, ...deps.getSessionArtifactMetadata() },
|
|
225
|
+
isError: true,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// -------------------------------------------------------------------------
|
|
232
|
+
// browser_session_summary
|
|
233
|
+
// -------------------------------------------------------------------------
|
|
234
|
+
pi.registerTool({
|
|
235
|
+
name: "browser_session_summary",
|
|
236
|
+
label: "Browser Session Summary",
|
|
237
|
+
description: "Return a compact structured summary of the current browser session, including pages, actions, waits/assertions, bounded-history caveats, and trace/HAR state.",
|
|
238
|
+
parameters: Type.Object({}),
|
|
239
|
+
async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) {
|
|
240
|
+
try {
|
|
241
|
+
await deps.ensureBrowser();
|
|
242
|
+
const pages = await deps.getLivePagesSnapshot();
|
|
243
|
+
const actionTimeline = getActionTimeline();
|
|
244
|
+
const pageRegistry = getPageRegistry();
|
|
245
|
+
const consoleLogs = getConsoleLogs();
|
|
246
|
+
const networkLogs = getNetworkLogs();
|
|
247
|
+
const dialogLogs = getDialogLogs();
|
|
248
|
+
const baseSummary = summarizeBrowserSession({
|
|
249
|
+
timeline: actionTimeline,
|
|
250
|
+
totalActions: actionTimeline.nextId - 1,
|
|
251
|
+
pages,
|
|
252
|
+
activePageId: pageRegistry.activePageId,
|
|
253
|
+
activeFrame: getActiveFrameMetadata(),
|
|
254
|
+
consoleEntries: consoleLogs,
|
|
255
|
+
networkEntries: networkLogs,
|
|
256
|
+
dialogEntries: dialogLogs,
|
|
257
|
+
consoleLimit: 1000,
|
|
258
|
+
networkLimit: 1000,
|
|
259
|
+
dialogLimit: 1000,
|
|
260
|
+
sessionStartedAt: getSessionStartedAt(),
|
|
261
|
+
now: Date.now(),
|
|
262
|
+
});
|
|
263
|
+
const failureHypothesis = buildFailureHypothesis({
|
|
264
|
+
timeline: actionTimeline,
|
|
265
|
+
consoleEntries: consoleLogs,
|
|
266
|
+
networkEntries: networkLogs,
|
|
267
|
+
dialogEntries: dialogLogs,
|
|
268
|
+
});
|
|
269
|
+
const activeTrace = getActiveTraceSession();
|
|
270
|
+
const traceState = activeTrace
|
|
271
|
+
? { status: "active", ...activeTrace }
|
|
272
|
+
: { status: "inactive", lastTracePath: getSessionArtifactDir() ? deps.buildSessionArtifactPath("*.trace.zip") : null };
|
|
273
|
+
const harState = getHarState();
|
|
274
|
+
const harSummary = {
|
|
275
|
+
enabled: harState.enabled,
|
|
276
|
+
configuredAtContextCreation: harState.configuredAtContextCreation,
|
|
277
|
+
path: harState.path,
|
|
278
|
+
exportCount: harState.exportCount,
|
|
279
|
+
lastExportedPath: harState.lastExportedPath,
|
|
280
|
+
lastExportedAt: harState.lastExportedAt,
|
|
281
|
+
};
|
|
282
|
+
return {
|
|
283
|
+
content: [{ type: "text", text: `${baseSummary.summary}\nFailure hypothesis: ${failureHypothesis}` }],
|
|
284
|
+
details: {
|
|
285
|
+
...baseSummary,
|
|
286
|
+
failureHypothesis,
|
|
287
|
+
trace: traceState,
|
|
288
|
+
har: harSummary,
|
|
289
|
+
...deps.getSessionArtifactMetadata(),
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
} catch (err: any) {
|
|
293
|
+
return {
|
|
294
|
+
content: [{ type: "text", text: `Session summary failed: ${err.message}` }],
|
|
295
|
+
details: { error: err.message, ...deps.getSessionArtifactMetadata() },
|
|
296
|
+
isError: true,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// -------------------------------------------------------------------------
|
|
303
|
+
// browser_debug_bundle
|
|
304
|
+
// -------------------------------------------------------------------------
|
|
305
|
+
pi.registerTool({
|
|
306
|
+
name: "browser_debug_bundle",
|
|
307
|
+
label: "Browser Debug Bundle",
|
|
308
|
+
description: "Write a timestamped debug bundle to disk with screenshot, logs, timeline, pages, session summary, and accessibility output, then return compact paths and counts.",
|
|
309
|
+
parameters: Type.Object({
|
|
310
|
+
selector: Type.Optional(Type.String({ description: "Optional CSS selector to scope the accessibility snapshot before fallback behavior applies." })),
|
|
311
|
+
name: Type.Optional(Type.String({ description: "Optional short bundle name suffix for the output directory." })),
|
|
312
|
+
}),
|
|
313
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
314
|
+
try {
|
|
315
|
+
const { page: p } = await deps.ensureBrowser();
|
|
316
|
+
const startedAt = Date.now();
|
|
317
|
+
const sessionDir = await deps.ensureSessionArtifactDir();
|
|
318
|
+
const bundleDir = path.join(ARTIFACT_ROOT, `${deps.formatArtifactTimestamp(startedAt)}-${deps.sanitizeArtifactName(params.name ?? "debug-bundle", "debug-bundle")}`);
|
|
319
|
+
await ensureDir(bundleDir);
|
|
320
|
+
const pages = await deps.getLivePagesSnapshot();
|
|
321
|
+
const actionTimeline = getActionTimeline();
|
|
322
|
+
const pageRegistry = getPageRegistry();
|
|
323
|
+
const consoleLogs = getConsoleLogs();
|
|
324
|
+
const networkLogs = getNetworkLogs();
|
|
325
|
+
const dialogLogs = getDialogLogs();
|
|
326
|
+
const timeline = formatTimelineEntries(actionTimeline.entries, {
|
|
327
|
+
limit: actionTimeline.limit,
|
|
328
|
+
totalActions: actionTimeline.nextId - 1,
|
|
329
|
+
});
|
|
330
|
+
const sessionSummary = summarizeBrowserSession({
|
|
331
|
+
timeline: actionTimeline,
|
|
332
|
+
totalActions: actionTimeline.nextId - 1,
|
|
333
|
+
pages,
|
|
334
|
+
activePageId: pageRegistry.activePageId,
|
|
335
|
+
activeFrame: getActiveFrameMetadata(),
|
|
336
|
+
consoleEntries: consoleLogs,
|
|
337
|
+
networkEntries: networkLogs,
|
|
338
|
+
dialogEntries: dialogLogs,
|
|
339
|
+
consoleLimit: 1000,
|
|
340
|
+
networkLimit: 1000,
|
|
341
|
+
dialogLimit: 1000,
|
|
342
|
+
sessionStartedAt: getSessionStartedAt(),
|
|
343
|
+
now: Date.now(),
|
|
344
|
+
});
|
|
345
|
+
const failureHypothesis = buildFailureHypothesis({
|
|
346
|
+
timeline: actionTimeline,
|
|
347
|
+
consoleEntries: consoleLogs,
|
|
348
|
+
networkEntries: networkLogs,
|
|
349
|
+
dialogEntries: dialogLogs,
|
|
350
|
+
});
|
|
351
|
+
const accessibility = await deps.captureAccessibilityMarkdown(params.selector);
|
|
352
|
+
const screenshotPath = path.join(bundleDir, "screenshot.jpg");
|
|
353
|
+
await p.screenshot({ path: screenshotPath, type: "jpeg", quality: 80, fullPage: false });
|
|
354
|
+
const screenshotStat = await stat(screenshotPath);
|
|
355
|
+
const artifacts = {
|
|
356
|
+
screenshot: { path: screenshotPath, bytes: screenshotStat.size },
|
|
357
|
+
console: await deps.writeArtifactFile(path.join(bundleDir, "console.json"), JSON.stringify(consoleLogs, null, 2)),
|
|
358
|
+
network: await deps.writeArtifactFile(path.join(bundleDir, "network.json"), JSON.stringify(networkLogs, null, 2)),
|
|
359
|
+
dialog: await deps.writeArtifactFile(path.join(bundleDir, "dialog.json"), JSON.stringify(dialogLogs, null, 2)),
|
|
360
|
+
timeline: await deps.writeArtifactFile(path.join(bundleDir, "timeline.json"), JSON.stringify(timeline, null, 2)),
|
|
361
|
+
summary: await deps.writeArtifactFile(path.join(bundleDir, "summary.json"), JSON.stringify({
|
|
362
|
+
...sessionSummary,
|
|
363
|
+
failureHypothesis,
|
|
364
|
+
trace: getActiveTraceSession(),
|
|
365
|
+
har: getHarState(),
|
|
366
|
+
sessionArtifactDir: sessionDir,
|
|
367
|
+
}, null, 2)),
|
|
368
|
+
pages: await deps.writeArtifactFile(path.join(bundleDir, "pages.json"), JSON.stringify(pages, null, 2)),
|
|
369
|
+
accessibility: await deps.writeArtifactFile(path.join(bundleDir, "accessibility.md"), accessibility.snapshot),
|
|
370
|
+
};
|
|
371
|
+
return {
|
|
372
|
+
content: [{ type: "text", text: `Debug bundle written: ${bundleDir}\n${sessionSummary.summary}\nFailure hypothesis: ${failureHypothesis}` }],
|
|
373
|
+
details: {
|
|
374
|
+
bundleDir,
|
|
375
|
+
artifacts,
|
|
376
|
+
accessibilityScope: accessibility.scope,
|
|
377
|
+
accessibilitySource: accessibility.source,
|
|
378
|
+
counts: {
|
|
379
|
+
console: consoleLogs.length,
|
|
380
|
+
network: networkLogs.length,
|
|
381
|
+
dialog: dialogLogs.length,
|
|
382
|
+
actions: timeline.retained,
|
|
383
|
+
pages: pages.length,
|
|
384
|
+
},
|
|
385
|
+
elapsedMs: Date.now() - startedAt,
|
|
386
|
+
summary: sessionSummary,
|
|
387
|
+
failureHypothesis,
|
|
388
|
+
...deps.getSessionArtifactMetadata(),
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
} catch (err: any) {
|
|
392
|
+
return {
|
|
393
|
+
content: [{ type: "text", text: `Debug bundle failed: ${err.message}` }],
|
|
394
|
+
details: { error: err.message, ...deps.getSessionArtifactMetadata() },
|
|
395
|
+
isError: true,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@gsd/pi-coding-agent";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { StringEnum } from "@gsd/pi-ai";
|
|
4
|
+
import {
|
|
5
|
+
validateWaitParams,
|
|
6
|
+
createRegionStableScript,
|
|
7
|
+
parseThreshold,
|
|
8
|
+
includesNeedle,
|
|
9
|
+
} from "../core.js";
|
|
10
|
+
import type { ToolDeps } from "../state.js";
|
|
11
|
+
import {
|
|
12
|
+
getConsoleLogs,
|
|
13
|
+
} from "../state.js";
|
|
14
|
+
|
|
15
|
+
export function registerWaitTools(pi: ExtensionAPI, deps: ToolDeps): void {
|
|
16
|
+
pi.registerTool({
|
|
17
|
+
name: "browser_wait_for",
|
|
18
|
+
label: "Browser Wait For",
|
|
19
|
+
description:
|
|
20
|
+
"Wait for a condition before continuing. Use after actions that trigger async updates — data fetches, route changes, animations, loading spinners. Choose the appropriate condition: 'selector_visible' waits for an element to appear, 'selector_hidden' waits for it to disappear, 'url_contains' waits for the URL to match, 'network_idle' waits for all network requests to finish, 'delay' waits a fixed number of milliseconds, 'text_visible' waits for text to appear in the page body, 'text_hidden' waits for text to disappear from the page body, 'request_completed' waits for a network response whose URL contains the given substring, 'console_message' waits for a console log message containing the given substring, 'element_count' waits for the number of elements matching the CSS selector in 'value' to satisfy the 'threshold' expression (e.g. '>=3', '==0', '<5'), 'region_stable' waits for the DOM region matching the CSS selector in 'value' to stop changing.",
|
|
21
|
+
parameters: Type.Object({
|
|
22
|
+
condition: StringEnum([
|
|
23
|
+
"selector_visible",
|
|
24
|
+
"selector_hidden",
|
|
25
|
+
"url_contains",
|
|
26
|
+
"network_idle",
|
|
27
|
+
"delay",
|
|
28
|
+
"text_visible",
|
|
29
|
+
"text_hidden",
|
|
30
|
+
"request_completed",
|
|
31
|
+
"console_message",
|
|
32
|
+
"element_count",
|
|
33
|
+
"region_stable",
|
|
34
|
+
] as const),
|
|
35
|
+
value: Type.Optional(
|
|
36
|
+
Type.String({
|
|
37
|
+
description:
|
|
38
|
+
"For selector_visible/selector_hidden/element_count/region_stable: CSS selector. For url_contains/request_completed: URL substring. For text_visible/text_hidden/console_message: text substring. For delay: milliseconds as a string (e.g. '1000'). Not used for network_idle.",
|
|
39
|
+
})
|
|
40
|
+
),
|
|
41
|
+
threshold: Type.Optional(
|
|
42
|
+
Type.String({
|
|
43
|
+
description:
|
|
44
|
+
"Threshold expression for element_count (e.g. '>=3', '==0', '<5', or bare '3' which defaults to >=). Only used with element_count condition.",
|
|
45
|
+
})
|
|
46
|
+
),
|
|
47
|
+
timeout: Type.Optional(
|
|
48
|
+
Type.Number({
|
|
49
|
+
description: "Maximum milliseconds to wait before failing (default: 10000)",
|
|
50
|
+
})
|
|
51
|
+
),
|
|
52
|
+
}),
|
|
53
|
+
|
|
54
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
55
|
+
try {
|
|
56
|
+
const { page: p } = await deps.ensureBrowser();
|
|
57
|
+
const target = deps.getActiveTarget();
|
|
58
|
+
const timeout = params.timeout ?? 10000;
|
|
59
|
+
|
|
60
|
+
const validation = validateWaitParams({ condition: params.condition, value: params.value, threshold: (params as any).threshold });
|
|
61
|
+
if (validation) {
|
|
62
|
+
return {
|
|
63
|
+
content: [{ type: "text", text: validation.error }],
|
|
64
|
+
details: { error: validation.error, condition: params.condition },
|
|
65
|
+
isError: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
switch (params.condition) {
|
|
70
|
+
case "selector_visible": {
|
|
71
|
+
if (!params.value) {
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: "text", text: "selector_visible requires a value (CSS selector)" }],
|
|
74
|
+
details: {},
|
|
75
|
+
isError: true,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
await target.waitForSelector(params.value, { state: "visible", timeout });
|
|
79
|
+
return {
|
|
80
|
+
content: [{ type: "text", text: `Element "${params.value}" is now visible` }],
|
|
81
|
+
details: { condition: params.condition, value: params.value },
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
case "selector_hidden": {
|
|
86
|
+
if (!params.value) {
|
|
87
|
+
return {
|
|
88
|
+
content: [{ type: "text", text: "selector_hidden requires a value (CSS selector)" }],
|
|
89
|
+
details: {},
|
|
90
|
+
isError: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
await target.waitForSelector(params.value, { state: "hidden", timeout });
|
|
94
|
+
return {
|
|
95
|
+
content: [{ type: "text", text: `Element "${params.value}" is now hidden` }],
|
|
96
|
+
details: { condition: params.condition, value: params.value },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
case "url_contains": {
|
|
101
|
+
if (!params.value) {
|
|
102
|
+
return {
|
|
103
|
+
content: [{ type: "text", text: "url_contains requires a value (URL substring)" }],
|
|
104
|
+
details: {},
|
|
105
|
+
isError: true,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
await p.waitForURL((url) => url.toString().includes(params.value!), { timeout });
|
|
109
|
+
return {
|
|
110
|
+
content: [{ type: "text", text: `URL now contains "${params.value}". Current URL: ${p.url()}` }],
|
|
111
|
+
details: { condition: params.condition, value: params.value, url: p.url() },
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
case "network_idle": {
|
|
116
|
+
await p.waitForLoadState("networkidle", { timeout });
|
|
117
|
+
return {
|
|
118
|
+
content: [{ type: "text", text: "Network is idle" }],
|
|
119
|
+
details: { condition: params.condition },
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
case "delay": {
|
|
124
|
+
const ms = parseInt(params.value ?? "1000", 10);
|
|
125
|
+
if (isNaN(ms)) {
|
|
126
|
+
return {
|
|
127
|
+
content: [{ type: "text", text: "delay requires a numeric value (milliseconds)" }],
|
|
128
|
+
details: {},
|
|
129
|
+
isError: true,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
133
|
+
return {
|
|
134
|
+
content: [{ type: "text", text: `Waited ${ms}ms` }],
|
|
135
|
+
details: { condition: params.condition, ms },
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
case "text_visible": {
|
|
140
|
+
await target.waitForFunction(
|
|
141
|
+
(needle: string) => {
|
|
142
|
+
const body = document.body?.innerText ?? "";
|
|
143
|
+
return body.toLowerCase().includes(needle.toLowerCase());
|
|
144
|
+
},
|
|
145
|
+
params.value!,
|
|
146
|
+
{ timeout }
|
|
147
|
+
);
|
|
148
|
+
return {
|
|
149
|
+
content: [{ type: "text", text: `Text "${params.value}" is now visible on the page` }],
|
|
150
|
+
details: { condition: params.condition, value: params.value },
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
case "text_hidden": {
|
|
155
|
+
await target.waitForFunction(
|
|
156
|
+
(needle: string) => {
|
|
157
|
+
const body = document.body?.innerText ?? "";
|
|
158
|
+
return !body.toLowerCase().includes(needle.toLowerCase());
|
|
159
|
+
},
|
|
160
|
+
params.value!,
|
|
161
|
+
{ timeout }
|
|
162
|
+
);
|
|
163
|
+
return {
|
|
164
|
+
content: [{ type: "text", text: `Text "${params.value}" is no longer visible on the page` }],
|
|
165
|
+
details: { condition: params.condition, value: params.value },
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
case "request_completed": {
|
|
170
|
+
const response = await deps.getActivePage().waitForResponse(
|
|
171
|
+
(resp) => resp.url().includes(params.value!),
|
|
172
|
+
{ timeout }
|
|
173
|
+
);
|
|
174
|
+
return {
|
|
175
|
+
content: [{ type: "text", text: `Request completed: ${response.url()} (status ${response.status()})` }],
|
|
176
|
+
details: { condition: params.condition, value: params.value, url: response.url(), status: response.status() },
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
case "console_message": {
|
|
181
|
+
const needle = params.value!;
|
|
182
|
+
const startTime = Date.now();
|
|
183
|
+
while (Date.now() - startTime < timeout) {
|
|
184
|
+
const match = getConsoleLogs().find((entry) => includesNeedle(entry.text, needle));
|
|
185
|
+
if (match) {
|
|
186
|
+
return {
|
|
187
|
+
content: [{ type: "text", text: `Console message matching "${needle}" found: "${match.text}"` }],
|
|
188
|
+
details: { condition: params.condition, value: needle, matchedText: match.text, matchedType: match.type },
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
192
|
+
}
|
|
193
|
+
throw new Error(`Timed out waiting for console message matching "${needle}" (${timeout}ms)`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
case "element_count": {
|
|
197
|
+
const threshold = parseThreshold((params as any).threshold ?? ">=1");
|
|
198
|
+
if (!threshold) {
|
|
199
|
+
return {
|
|
200
|
+
content: [{ type: "text", text: `element_count threshold is malformed: "${(params as any).threshold}"` }],
|
|
201
|
+
details: { error: "malformed threshold", condition: params.condition },
|
|
202
|
+
isError: true,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const selector = params.value!;
|
|
206
|
+
const op = threshold.op;
|
|
207
|
+
const n = threshold.n;
|
|
208
|
+
await target.waitForFunction(
|
|
209
|
+
({ selector, op, n }: { selector: string; op: string; n: number }) => {
|
|
210
|
+
const count = document.querySelectorAll(selector).length;
|
|
211
|
+
switch (op) {
|
|
212
|
+
case ">=": return count >= n;
|
|
213
|
+
case "<=": return count <= n;
|
|
214
|
+
case "==": return count === n;
|
|
215
|
+
case ">": return count > n;
|
|
216
|
+
case "<": return count < n;
|
|
217
|
+
default: return false;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{ selector, op, n },
|
|
221
|
+
{ timeout }
|
|
222
|
+
);
|
|
223
|
+
return {
|
|
224
|
+
content: [{ type: "text", text: `Element count for "${selector}" satisfies ${op}${n}` }],
|
|
225
|
+
details: { condition: params.condition, value: selector, threshold: `${op}${n}` },
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
case "region_stable": {
|
|
230
|
+
const script = createRegionStableScript(params.value!);
|
|
231
|
+
await target.waitForFunction(script, undefined, { timeout, polling: 200 });
|
|
232
|
+
return {
|
|
233
|
+
content: [{ type: "text", text: `Region "${params.value}" is now stable` }],
|
|
234
|
+
details: { condition: params.condition, value: params.value },
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} catch (err: any) {
|
|
239
|
+
return {
|
|
240
|
+
content: [{ type: "text", text: `Wait failed: ${err.message}` }],
|
|
241
|
+
details: { error: err.message, condition: params.condition, value: params.value },
|
|
242
|
+
isError: true,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
}
|