@pi-harness/pi-harness 0.1.5 → 0.1.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/README.md +1 -1
- package/apps/web/dist/assets/index-CkGv0zrr.css +2 -0
- package/apps/web/dist/assets/index-pMtwuwHh.js +20 -0
- package/apps/web/dist/index.html +2 -2
- package/apps/web/package.json +6 -6
- package/apps/web/profile/cordis.yml +1 -1
- package/apps/web/server-dist/bin.js +1 -1
- package/apps/web/src/server/bin.ts +1 -1
- package/apps/web/src/style.css +15 -8
- package/node_modules/@pi-harness/api-gateway/LICENSE +9 -0
- package/node_modules/@pi-harness/api-gateway/dist/index.d.ts +8 -0
- package/node_modules/@pi-harness/api-gateway/dist/index.d.ts.map +1 -0
- package/node_modules/@pi-harness/api-gateway/dist/index.js +1747 -0
- package/node_modules/@pi-harness/api-gateway/dist/index.js.map +1 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/agent-teams.json +31 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/anchored-standard.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/annotation.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/archify.json +31 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/at-file.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/auto-mode.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/better-sidebar.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/browser-fetch.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/browser-session.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/canvas-draw.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/change-verifier.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/cleaner.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/cli-notifier.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/code2skill.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/colleague-skill.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/context-doctor.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/context.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/cordis-group.json +16 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/cordis-logger-console.json +16 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/cordis-timer.json +16 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/cost-meter.json +31 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/dependency-checker.json +31 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/docker-sandbox.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/fail-logger.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/genui.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/git-time-capsule.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/graph-memory.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/history-compressor.json +33 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/hol-guard.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/i18n-pair.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/image-compressor.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/llm-verifier.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/mcp-client.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/mcp-panel.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/memory.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/mirage-bridge.json +33 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/mock-server.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/modlens.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/module-search.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/obsidian-sync.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/openpets.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/plan-execute.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/plugin-check.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/plugin-dev.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/plugin-finder.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/plugin-radar.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/plugin-stars.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/prompt-guard.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/prompt-library.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/readme-gen.json +31 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/recall-unread.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/reverse-skill.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/reviewer-bot.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/runtime-doctor.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/secure-audit.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/session-bookmarks.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/session-bridge.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/session-compare.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/session-export.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/session-insights.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/session-search.json +30 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/skill-catalog.json +31 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/skill-guard.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/sql-lens.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/synapse.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/tab-manager.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/taskboard.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/telemetry-blocker.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/test-harness.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/theme-studio.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/token-guard.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/turn-rewind.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/undo-savepoint.json +28 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/vision-toolkit.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/web-research.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/workspace-navigator.json +32 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/workspace-search.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace-entries/official/yaml-validator.json +29 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace.d.ts +60 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace.d.ts.map +1 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace.js +235 -0
- package/node_modules/@pi-harness/api-gateway/dist/marketplace.js.map +1 -0
- package/node_modules/@pi-harness/api-gateway/dist/workspaces.d.ts +8 -0
- package/node_modules/@pi-harness/api-gateway/dist/workspaces.d.ts.map +1 -0
- package/node_modules/@pi-harness/api-gateway/dist/workspaces.js +14 -0
- package/node_modules/@pi-harness/api-gateway/dist/workspaces.js.map +1 -0
- package/node_modules/@pi-harness/api-gateway/package.json +36 -0
- package/node_modules/@pi-harness/cli/LICENSE +9 -0
- package/node_modules/@pi-harness/cli/dist/args.d.ts +16 -0
- package/node_modules/@pi-harness/cli/dist/args.d.ts.map +1 -0
- package/node_modules/@pi-harness/cli/dist/args.js +60 -0
- package/node_modules/@pi-harness/cli/dist/args.js.map +1 -0
- package/node_modules/@pi-harness/cli/dist/bin.d.ts +3 -0
- package/node_modules/@pi-harness/cli/dist/bin.d.ts.map +1 -0
- package/node_modules/@pi-harness/cli/dist/bin.js +49 -0
- package/node_modules/@pi-harness/cli/dist/bin.js.map +1 -0
- package/node_modules/@pi-harness/cli/dist/main.d.ts +15 -0
- package/node_modules/@pi-harness/cli/dist/main.d.ts.map +1 -0
- package/node_modules/@pi-harness/cli/dist/main.js +188 -0
- package/node_modules/@pi-harness/cli/dist/main.js.map +1 -0
- package/node_modules/@pi-harness/cli/dist/node-stdio.d.ts +12 -0
- package/node_modules/@pi-harness/cli/dist/node-stdio.d.ts.map +1 -0
- package/node_modules/@pi-harness/cli/dist/node-stdio.js +112 -0
- package/node_modules/@pi-harness/cli/dist/node-stdio.js.map +1 -0
- package/node_modules/@pi-harness/cli/dist/relaunch.d.ts +5 -0
- package/node_modules/@pi-harness/cli/dist/relaunch.d.ts.map +1 -0
- package/node_modules/@pi-harness/cli/dist/relaunch.js +65 -0
- package/node_modules/@pi-harness/cli/dist/relaunch.js.map +1 -0
- package/node_modules/@pi-harness/cli/package.json +33 -0
- package/node_modules/@pi-harness/core/LICENSE +9 -0
- package/node_modules/@pi-harness/core/dist/boot.d.ts +13 -0
- package/node_modules/@pi-harness/core/dist/boot.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/boot.js +135 -0
- package/node_modules/@pi-harness/core/dist/boot.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/config.d.ts +2 -0
- package/node_modules/@pi-harness/core/dist/config.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/config.js +8 -0
- package/node_modules/@pi-harness/core/dist/config.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/context.d.ts +3 -0
- package/node_modules/@pi-harness/core/dist/context.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/context.js +2 -0
- package/node_modules/@pi-harness/core/dist/context.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/http.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/http.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/http.js +27 -0
- package/node_modules/@pi-harness/core/dist/http.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/index.d.ts +9 -0
- package/node_modules/@pi-harness/core/dist/index.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/index.js +8 -0
- package/node_modules/@pi-harness/core/dist/index.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/agent-teams.d.ts +17 -0
- package/node_modules/@pi-harness/core/dist/plugins/agent-teams.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/agent-teams.js +298 -0
- package/node_modules/@pi-harness/core/dist/plugins/agent-teams.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/anchored-standard.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/anchored-standard.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/anchored-standard.js +84 -0
- package/node_modules/@pi-harness/core/dist/plugins/anchored-standard.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/annotation.d.ts +18 -0
- package/node_modules/@pi-harness/core/dist/plugins/annotation.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/annotation.js +94 -0
- package/node_modules/@pi-harness/core/dist/plugins/annotation.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/archify.d.ts +23 -0
- package/node_modules/@pi-harness/core/dist/plugins/archify.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/archify.js +98 -0
- package/node_modules/@pi-harness/core/dist/plugins/archify.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/at-file.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/at-file.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/at-file.js +52 -0
- package/node_modules/@pi-harness/core/dist/plugins/at-file.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/auto-mode.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/auto-mode.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/auto-mode.js +114 -0
- package/node_modules/@pi-harness/core/dist/plugins/auto-mode.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/better-sidebar.d.ts +37 -0
- package/node_modules/@pi-harness/core/dist/plugins/better-sidebar.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/better-sidebar.js +89 -0
- package/node_modules/@pi-harness/core/dist/plugins/better-sidebar.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-fetch.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-fetch.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-fetch.js +167 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-fetch.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-session.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-session.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-session.js +265 -0
- package/node_modules/@pi-harness/core/dist/plugins/browser-session.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/canvas-draw.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/canvas-draw.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/canvas-draw.js +88 -0
- package/node_modules/@pi-harness/core/dist/plugins/canvas-draw.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/change-verifier.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/change-verifier.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/change-verifier.js +67 -0
- package/node_modules/@pi-harness/core/dist/plugins/change-verifier.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/cleaner.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/cleaner.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/cleaner.js +56 -0
- package/node_modules/@pi-harness/core/dist/plugins/cleaner.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/cli-notifier.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/cli-notifier.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/cli-notifier.js +110 -0
- package/node_modules/@pi-harness/core/dist/plugins/cli-notifier.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/code2skill.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/code2skill.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/code2skill.js +95 -0
- package/node_modules/@pi-harness/core/dist/plugins/code2skill.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/colleague-skill.d.ts +27 -0
- package/node_modules/@pi-harness/core/dist/plugins/colleague-skill.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/colleague-skill.js +99 -0
- package/node_modules/@pi-harness/core/dist/plugins/colleague-skill.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/context-doctor.d.ts +30 -0
- package/node_modules/@pi-harness/core/dist/plugins/context-doctor.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/context-doctor.js +95 -0
- package/node_modules/@pi-harness/core/dist/plugins/context-doctor.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/context.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/context.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/context.js +87 -0
- package/node_modules/@pi-harness/core/dist/plugins/context.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/cost-meter.d.ts +32 -0
- package/node_modules/@pi-harness/core/dist/plugins/cost-meter.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/cost-meter.js +204 -0
- package/node_modules/@pi-harness/core/dist/plugins/cost-meter.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/dependency-checker.d.ts +27 -0
- package/node_modules/@pi-harness/core/dist/plugins/dependency-checker.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/dependency-checker.js +221 -0
- package/node_modules/@pi-harness/core/dist/plugins/dependency-checker.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/docker-sandbox.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/docker-sandbox.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/docker-sandbox.js +102 -0
- package/node_modules/@pi-harness/core/dist/plugins/docker-sandbox.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/fail-logger.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/fail-logger.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/fail-logger.js +51 -0
- package/node_modules/@pi-harness/core/dist/plugins/fail-logger.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/genui.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/genui.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/genui.js +79 -0
- package/node_modules/@pi-harness/core/dist/plugins/genui.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/git-time-capsule.d.ts +9 -0
- package/node_modules/@pi-harness/core/dist/plugins/git-time-capsule.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/git-time-capsule.js +90 -0
- package/node_modules/@pi-harness/core/dist/plugins/git-time-capsule.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/graph-memory.d.ts +16 -0
- package/node_modules/@pi-harness/core/dist/plugins/graph-memory.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/graph-memory.js +382 -0
- package/node_modules/@pi-harness/core/dist/plugins/graph-memory.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/history-compressor.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/history-compressor.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/history-compressor.js +80 -0
- package/node_modules/@pi-harness/core/dist/plugins/history-compressor.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/hol-guard.d.ts +29 -0
- package/node_modules/@pi-harness/core/dist/plugins/hol-guard.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/hol-guard.js +139 -0
- package/node_modules/@pi-harness/core/dist/plugins/hol-guard.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/i18n-pair.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/i18n-pair.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/i18n-pair.js +76 -0
- package/node_modules/@pi-harness/core/dist/plugins/i18n-pair.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/image-compressor.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/image-compressor.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/image-compressor.js +150 -0
- package/node_modules/@pi-harness/core/dist/plugins/image-compressor.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/llm-verifier.d.ts +42 -0
- package/node_modules/@pi-harness/core/dist/plugins/llm-verifier.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/llm-verifier.js +128 -0
- package/node_modules/@pi-harness/core/dist/plugins/llm-verifier.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-client.d.ts +19 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-client.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-client.js +534 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-client.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-panel.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-panel.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-panel.js +180 -0
- package/node_modules/@pi-harness/core/dist/plugins/mcp-panel.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/memory.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/memory.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/memory.js +161 -0
- package/node_modules/@pi-harness/core/dist/plugins/memory.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mirage-bridge.d.ts +23 -0
- package/node_modules/@pi-harness/core/dist/plugins/mirage-bridge.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mirage-bridge.js +149 -0
- package/node_modules/@pi-harness/core/dist/plugins/mirage-bridge.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mock-server.d.ts +22 -0
- package/node_modules/@pi-harness/core/dist/plugins/mock-server.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/mock-server.js +149 -0
- package/node_modules/@pi-harness/core/dist/plugins/mock-server.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/model.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/model.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/model.js +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/model.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/models.d.ts +16 -0
- package/node_modules/@pi-harness/core/dist/plugins/models.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/models.js +27 -0
- package/node_modules/@pi-harness/core/dist/plugins/models.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/modlens.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/modlens.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/modlens.js +63 -0
- package/node_modules/@pi-harness/core/dist/plugins/modlens.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/module-search.d.ts +27 -0
- package/node_modules/@pi-harness/core/dist/plugins/module-search.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/module-search.js +174 -0
- package/node_modules/@pi-harness/core/dist/plugins/module-search.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/obsidian-sync.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/obsidian-sync.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/obsidian-sync.js +79 -0
- package/node_modules/@pi-harness/core/dist/plugins/obsidian-sync.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/openpets.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/openpets.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/openpets.js +99 -0
- package/node_modules/@pi-harness/core/dist/plugins/openpets.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plan-execute.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/plan-execute.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plan-execute.js +70 -0
- package/node_modules/@pi-harness/core/dist/plugins/plan-execute.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-check.d.ts +38 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-check.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-check.js +227 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-check.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-dev.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-dev.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-dev.js +44 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-dev.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-finder.d.ts +16 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-finder.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-finder.js +98 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-finder.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-radar.d.ts +29 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-radar.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-radar.js +146 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-radar.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-stars.d.ts +45 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-stars.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-stars.js +165 -0
- package/node_modules/@pi-harness/core/dist/plugins/plugin-stars.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-guard.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-guard.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-guard.js +114 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-guard.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-library.d.ts +25 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-library.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-library.js +142 -0
- package/node_modules/@pi-harness/core/dist/plugins/prompt-library.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/readme-gen.d.ts +25 -0
- package/node_modules/@pi-harness/core/dist/plugins/readme-gen.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/readme-gen.js +139 -0
- package/node_modules/@pi-harness/core/dist/plugins/readme-gen.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/recall-unread.d.ts +24 -0
- package/node_modules/@pi-harness/core/dist/plugins/recall-unread.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/recall-unread.js +124 -0
- package/node_modules/@pi-harness/core/dist/plugins/recall-unread.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/resources.d.ts +19 -0
- package/node_modules/@pi-harness/core/dist/plugins/resources.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/resources.js +57 -0
- package/node_modules/@pi-harness/core/dist/plugins/resources.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/reverse-skill.d.ts +23 -0
- package/node_modules/@pi-harness/core/dist/plugins/reverse-skill.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/reverse-skill.js +60 -0
- package/node_modules/@pi-harness/core/dist/plugins/reverse-skill.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/reviewer-bot.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/reviewer-bot.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/reviewer-bot.js +133 -0
- package/node_modules/@pi-harness/core/dist/plugins/reviewer-bot.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime-doctor.d.ts +33 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime-doctor.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime-doctor.js +114 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime-doctor.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime.d.ts +14 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime.js +117 -0
- package/node_modules/@pi-harness/core/dist/plugins/runtime.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/secure-audit.d.ts +31 -0
- package/node_modules/@pi-harness/core/dist/plugins/secure-audit.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/secure-audit.js +121 -0
- package/node_modules/@pi-harness/core/dist/plugins/secure-audit.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bookmarks.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bookmarks.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bookmarks.js +87 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bookmarks.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bridge.d.ts +44 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bridge.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bridge.js +265 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-bridge.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-compare.d.ts +33 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-compare.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-compare.js +150 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-compare.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-export.d.ts +9 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-export.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-export.js +93 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-export.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-insights.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-insights.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-insights.js +47 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-insights.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-search.d.ts +20 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-search.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-search.js +122 -0
- package/node_modules/@pi-harness/core/dist/plugins/session-search.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/session.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/session.js +22 -0
- package/node_modules/@pi-harness/core/dist/plugins/session.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-catalog.d.ts +26 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-catalog.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-catalog.js +97 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-catalog.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-guard.d.ts +26 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-guard.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-guard.js +139 -0
- package/node_modules/@pi-harness/core/dist/plugins/skill-guard.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/sql-lens.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/sql-lens.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/sql-lens.js +85 -0
- package/node_modules/@pi-harness/core/dist/plugins/sql-lens.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/stdio.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/stdio.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/stdio.js +22 -0
- package/node_modules/@pi-harness/core/dist/plugins/stdio.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/synapse.d.ts +38 -0
- package/node_modules/@pi-harness/core/dist/plugins/synapse.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/synapse.js +93 -0
- package/node_modules/@pi-harness/core/dist/plugins/synapse.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/tab-manager.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/tab-manager.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/tab-manager.js +135 -0
- package/node_modules/@pi-harness/core/dist/plugins/tab-manager.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/taskboard.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/taskboard.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/taskboard.js +347 -0
- package/node_modules/@pi-harness/core/dist/plugins/taskboard.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/telemetry-blocker.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/telemetry-blocker.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/telemetry-blocker.js +57 -0
- package/node_modules/@pi-harness/core/dist/plugins/telemetry-blocker.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/test-harness.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/test-harness.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/test-harness.js +64 -0
- package/node_modules/@pi-harness/core/dist/plugins/test-harness.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/theme-studio.d.ts +29 -0
- package/node_modules/@pi-harness/core/dist/plugins/theme-studio.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/theme-studio.js +141 -0
- package/node_modules/@pi-harness/core/dist/plugins/theme-studio.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/token-guard.d.ts +15 -0
- package/node_modules/@pi-harness/core/dist/plugins/token-guard.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/token-guard.js +78 -0
- package/node_modules/@pi-harness/core/dist/plugins/token-guard.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/tools.d.ts +13 -0
- package/node_modules/@pi-harness/core/dist/plugins/tools.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/tools.js +20 -0
- package/node_modules/@pi-harness/core/dist/plugins/tools.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/turn-rewind.d.ts +19 -0
- package/node_modules/@pi-harness/core/dist/plugins/turn-rewind.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/turn-rewind.js +74 -0
- package/node_modules/@pi-harness/core/dist/plugins/turn-rewind.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/undo-savepoint.d.ts +17 -0
- package/node_modules/@pi-harness/core/dist/plugins/undo-savepoint.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/undo-savepoint.js +247 -0
- package/node_modules/@pi-harness/core/dist/plugins/undo-savepoint.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/vision-toolkit.d.ts +17 -0
- package/node_modules/@pi-harness/core/dist/plugins/vision-toolkit.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/vision-toolkit.js +145 -0
- package/node_modules/@pi-harness/core/dist/plugins/vision-toolkit.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/web-research.d.ts +17 -0
- package/node_modules/@pi-harness/core/dist/plugins/web-research.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/web-research.js +275 -0
- package/node_modules/@pi-harness/core/dist/plugins/web-research.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-navigator.d.ts +36 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-navigator.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-navigator.js +150 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-navigator.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-search.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-search.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-search.js +134 -0
- package/node_modules/@pi-harness/core/dist/plugins/workspace-search.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/yaml-validator.d.ts +8 -0
- package/node_modules/@pi-harness/core/dist/plugins/yaml-validator.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/plugins/yaml-validator.js +94 -0
- package/node_modules/@pi-harness/core/dist/plugins/yaml-validator.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/profile.d.ts +9 -0
- package/node_modules/@pi-harness/core/dist/profile.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/profile.js +31 -0
- package/node_modules/@pi-harness/core/dist/profile.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/runtime.d.ts +16 -0
- package/node_modules/@pi-harness/core/dist/runtime.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/runtime.js +42 -0
- package/node_modules/@pi-harness/core/dist/runtime.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/services.d.ts +118 -0
- package/node_modules/@pi-harness/core/dist/services.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/services.js +95 -0
- package/node_modules/@pi-harness/core/dist/services.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/stdio.d.ts +36 -0
- package/node_modules/@pi-harness/core/dist/stdio.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/stdio.js +140 -0
- package/node_modules/@pi-harness/core/dist/stdio.js.map +1 -0
- package/node_modules/@pi-harness/core/dist/workspace-path.d.ts +12 -0
- package/node_modules/@pi-harness/core/dist/workspace-path.d.ts.map +1 -0
- package/node_modules/@pi-harness/core/dist/workspace-path.js +62 -0
- package/node_modules/@pi-harness/core/dist/workspace-path.js.map +1 -0
- package/node_modules/@pi-harness/core/package.json +42 -0
- package/node_modules/@pi-harness/core/profiles/default/cordis.yml +120 -0
- package/node_modules/@pi-harness/core/profiles/development/cordis.yml +47 -0
- package/node_modules/@pi-harness/host-webserver/LICENSE +9 -0
- package/node_modules/@pi-harness/host-webserver/dist/index.d.ts +29 -0
- package/node_modules/@pi-harness/host-webserver/dist/index.d.ts.map +1 -0
- package/node_modules/@pi-harness/host-webserver/dist/index.js +73 -0
- package/node_modules/@pi-harness/host-webserver/dist/index.js.map +1 -0
- package/node_modules/@pi-harness/host-webserver/package.json +35 -0
- package/node_modules/@pi-harness/web-app/LICENSE +9 -0
- package/node_modules/@pi-harness/web-app/cordis.patch.yml +12 -0
- package/node_modules/@pi-harness/web-app/dist/index.d.ts +12 -0
- package/node_modules/@pi-harness/web-app/dist/index.d.ts.map +1 -0
- package/node_modules/@pi-harness/web-app/dist/index.js +63 -0
- package/node_modules/@pi-harness/web-app/dist/index.js.map +1 -0
- package/node_modules/@pi-harness/web-app/package.json +37 -0
- package/package.json +29 -10
- package/packages/api-gateway/dist/marketplace-entries/official/agent-teams.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/anchored-standard.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/annotation.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/archify.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/at-file.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/auto-mode.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/better-sidebar.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/browser-fetch.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/browser-session.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/canvas-draw.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/change-verifier.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/cleaner.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/cli-notifier.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/code2skill.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/colleague-skill.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/context-doctor.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/context.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/cost-meter.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/dependency-checker.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/docker-sandbox.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/fail-logger.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/genui.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/git-time-capsule.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/graph-memory.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/history-compressor.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/hol-guard.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/i18n-pair.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/image-compressor.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/llm-verifier.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/mcp-client.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/mcp-panel.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/memory.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/mirage-bridge.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/mock-server.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/modlens.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/module-search.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/obsidian-sync.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/openpets.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/plan-execute.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/plugin-check.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/plugin-dev.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/plugin-finder.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/plugin-radar.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/plugin-stars.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/prompt-guard.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/prompt-library.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/readme-gen.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/recall-unread.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/reverse-skill.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/reviewer-bot.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/runtime-doctor.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/secure-audit.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/session-bookmarks.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/session-bridge.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/session-compare.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/session-export.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/session-insights.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/session-search.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/skill-catalog.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/skill-guard.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/sql-lens.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/synapse.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/tab-manager.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/taskboard.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/telemetry-blocker.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/test-harness.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/theme-studio.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/token-guard.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/turn-rewind.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/undo-savepoint.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/vision-toolkit.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/web-research.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/workspace-navigator.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/workspace-search.json +1 -1
- package/packages/api-gateway/dist/marketplace-entries/official/yaml-validator.json +1 -1
- package/packages/api-gateway/package.json +6 -10
- package/packages/api-gateway/src/marketplace-entries/official/agent-teams.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/anchored-standard.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/annotation.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/archify.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/at-file.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/auto-mode.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/better-sidebar.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/browser-fetch.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/browser-session.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/canvas-draw.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/change-verifier.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/cleaner.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/cli-notifier.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/code2skill.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/colleague-skill.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/context-doctor.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/context.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/cost-meter.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/dependency-checker.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/docker-sandbox.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/fail-logger.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/genui.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/git-time-capsule.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/graph-memory.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/history-compressor.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/hol-guard.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/i18n-pair.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/image-compressor.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/llm-verifier.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/mcp-client.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/mcp-panel.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/memory.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/mirage-bridge.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/mock-server.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/modlens.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/module-search.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/obsidian-sync.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/openpets.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/plan-execute.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/plugin-check.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/plugin-dev.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/plugin-finder.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/plugin-radar.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/plugin-stars.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/prompt-guard.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/prompt-library.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/readme-gen.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/recall-unread.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/reverse-skill.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/reviewer-bot.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/runtime-doctor.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/secure-audit.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/session-bookmarks.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/session-bridge.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/session-compare.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/session-export.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/session-insights.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/session-search.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/skill-catalog.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/skill-guard.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/sql-lens.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/synapse.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/tab-manager.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/taskboard.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/telemetry-blocker.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/test-harness.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/theme-studio.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/token-guard.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/turn-rewind.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/undo-savepoint.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/vision-toolkit.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/web-research.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/workspace-navigator.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/workspace-search.json +1 -1
- package/packages/api-gateway/src/marketplace-entries/official/yaml-validator.json +1 -1
- package/packages/api-gateway/test/release-package.test.ts +33 -0
- package/packages/bundle-web-app/cordis.patch.yml +1 -1
- package/packages/bundle-web-app/package.json +6 -9
- package/packages/cli/package.json +6 -8
- package/packages/client-web/dist/plugin-card.d.ts +8 -0
- package/packages/client-web/dist/plugin-card.d.ts.map +1 -0
- package/packages/client-web/dist/plugin-card.js +15 -0
- package/packages/client-web/dist/plugin-card.js.map +1 -0
- package/packages/client-web/dist/react-room.d.ts.map +1 -1
- package/packages/client-web/dist/react-room.js +9 -7
- package/packages/client-web/dist/react-room.js.map +1 -1
- package/packages/client-web/package.json +6 -5
- package/packages/client-web/src/plugin-card.ts +22 -0
- package/packages/client-web/src/react-room.tsx +35 -30
- package/packages/client-web/test/browser-session-view.test.ts +2 -2
- package/packages/client-web/test/plugin-card.test.ts +46 -0
- package/packages/core/package.json +6 -18
- package/packages/host-webserver/dist/index.js +1 -1
- package/packages/host-webserver/package.json +6 -8
- package/packages/host-webserver/src/index.ts +1 -1
- package/apps/web/dist/assets/index-CihATCjR.css +0 -2
- package/apps/web/dist/assets/index-gDNnM9GK.js +0 -20
|
@@ -0,0 +1,1747 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { mkdir, mkdtemp, readFile, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
3
|
+
import { basename, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { MARKETPLACE_CAPABILITIES, MARKETPLACE_CATEGORIES, MARKETPLACE_PLUGINS, attachMarketplaceStatistics, createMarketplaceStatisticsLoader, paginateMarketplace, searchMarketplace, needsMarketplacePackageInstall, sortMarketplaceByRecommendation, } from "./marketplace.js";
|
|
7
|
+
import { parseGitWorktrees } from "./workspaces.js";
|
|
8
|
+
const loadMarketplaceStatistics = createMarketplaceStatisticsLoader();
|
|
9
|
+
function sendJson(response, status, payload) {
|
|
10
|
+
const body = JSON.stringify(payload);
|
|
11
|
+
response.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store", "content-length": Buffer.byteLength(body) });
|
|
12
|
+
response.end(body);
|
|
13
|
+
}
|
|
14
|
+
async function bodyText(request) {
|
|
15
|
+
const chunks = [];
|
|
16
|
+
let length = 0;
|
|
17
|
+
for await (const chunk of request) {
|
|
18
|
+
const input = chunk;
|
|
19
|
+
const value = typeof input === "string" ? input : Buffer.from(input).toString("utf8");
|
|
20
|
+
length += Buffer.byteLength(value);
|
|
21
|
+
if (length > 64 * 1024)
|
|
22
|
+
throw new Error("Request body is too large");
|
|
23
|
+
chunks.push(value);
|
|
24
|
+
}
|
|
25
|
+
return chunks.join("");
|
|
26
|
+
}
|
|
27
|
+
function errorText(error) {
|
|
28
|
+
return error instanceof Error ? error.message : String(error);
|
|
29
|
+
}
|
|
30
|
+
function jsonSafe(value, seen = new WeakSet()) {
|
|
31
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
32
|
+
return value;
|
|
33
|
+
if (typeof value === "bigint")
|
|
34
|
+
return value.toString();
|
|
35
|
+
if (typeof value === "undefined")
|
|
36
|
+
return null;
|
|
37
|
+
if (value instanceof Error)
|
|
38
|
+
return { name: value.name, message: value.message, stack: value.stack };
|
|
39
|
+
if (value instanceof Date)
|
|
40
|
+
return value.toISOString();
|
|
41
|
+
if (typeof value !== "object")
|
|
42
|
+
return Object.prototype.toString.call(value);
|
|
43
|
+
if (seen.has(value))
|
|
44
|
+
return "[Circular]";
|
|
45
|
+
seen.add(value);
|
|
46
|
+
if (Array.isArray(value))
|
|
47
|
+
return value.map((item) => jsonSafe(item, seen));
|
|
48
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, jsonSafe(item, seen)]));
|
|
49
|
+
}
|
|
50
|
+
function createStatus(services, events) {
|
|
51
|
+
const activeModel = services.runtime.session.model ?? services.models.model;
|
|
52
|
+
const cwd = activeCwd(services);
|
|
53
|
+
return {
|
|
54
|
+
status: services.runtime.session.isStreaming ? "running" : "ready",
|
|
55
|
+
model: activeModel.provider + "/" + activeModel.id,
|
|
56
|
+
messages: services.runtime.session.messages.length,
|
|
57
|
+
events: events.length,
|
|
58
|
+
sessionId: services.runtime.session.sessionId,
|
|
59
|
+
sessionFile: services.runtime.session.sessionFile,
|
|
60
|
+
cwd,
|
|
61
|
+
agentDir: services.launch.agentDir,
|
|
62
|
+
plugins: services.loader ? [...services.loader.entries()].filter((entry) => !entry.disabled).map((entry) => entry.options.name) : [],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function activeCwd(services) {
|
|
66
|
+
const runtimeCwd = services.runtime.sessionRuntime?.cwd;
|
|
67
|
+
return typeof runtimeCwd === "string" && runtimeCwd.length > 0 ? runtimeCwd : services.launch.cwd;
|
|
68
|
+
}
|
|
69
|
+
function piConfig(services) {
|
|
70
|
+
const settings = services.runtime.session.settingsManager;
|
|
71
|
+
const global = settings.getGlobalSettings();
|
|
72
|
+
const compaction = settings.getCompactionSettings();
|
|
73
|
+
return {
|
|
74
|
+
path: join(services.launch.agentDir, "settings.json"),
|
|
75
|
+
scope: "global",
|
|
76
|
+
source: JSON.stringify(global, null, 2) + "\n",
|
|
77
|
+
settings: {
|
|
78
|
+
defaultProvider: global.defaultProvider,
|
|
79
|
+
defaultModel: global.defaultModel,
|
|
80
|
+
defaultThinkingLevel: global.defaultThinkingLevel,
|
|
81
|
+
transport: settings.getTransport(),
|
|
82
|
+
steeringMode: settings.getSteeringMode(),
|
|
83
|
+
followUpMode: settings.getFollowUpMode(),
|
|
84
|
+
hideThinkingBlock: settings.getHideThinkingBlock(),
|
|
85
|
+
compaction,
|
|
86
|
+
retry: settings.getRetrySettings(),
|
|
87
|
+
terminal: {
|
|
88
|
+
showImages: settings.getShowImages(),
|
|
89
|
+
imageAutoResize: settings.getImageAutoResize(),
|
|
90
|
+
autocompleteMaxVisible: settings.getAutocompleteMaxVisible(),
|
|
91
|
+
},
|
|
92
|
+
advanced: {
|
|
93
|
+
quietStartup: settings.getQuietStartup(),
|
|
94
|
+
projectTrust: settings.getDefaultProjectTrust(),
|
|
95
|
+
showCacheMissNotices: settings.getShowCacheMissNotices(),
|
|
96
|
+
enableAnalytics: settings.getEnableAnalytics(),
|
|
97
|
+
enableInstallTelemetry: settings.getEnableInstallTelemetry(),
|
|
98
|
+
shellPath: settings.getShellPath(),
|
|
99
|
+
doubleEscapeAction: settings.getDoubleEscapeAction(),
|
|
100
|
+
treeFilterMode: settings.getTreeFilterMode(),
|
|
101
|
+
mermaid: settings.getMermaidRenderingMode(),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function sessionMetadataFile(manager) {
|
|
107
|
+
return resolve(manager.getSessionDir(), ".pi-harness-session-meta.json");
|
|
108
|
+
}
|
|
109
|
+
async function readSessionMetadata(manager) {
|
|
110
|
+
try {
|
|
111
|
+
const parsed = JSON.parse(await readFile(sessionMetadataFile(manager), "utf8"));
|
|
112
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
113
|
+
return {};
|
|
114
|
+
return parsed;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return {};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function writeSessionMetadata(manager, metadata) {
|
|
121
|
+
await mkdir(manager.getSessionDir(), { recursive: true });
|
|
122
|
+
await writeFile(sessionMetadataFile(manager), JSON.stringify(metadata, null, 2) + "\n", "utf8");
|
|
123
|
+
}
|
|
124
|
+
function sessionPathInDirectory(path, manager) {
|
|
125
|
+
const root = resolve(manager.getSessionDir());
|
|
126
|
+
const target = resolve(path);
|
|
127
|
+
const relativePath = relative(root, target);
|
|
128
|
+
return relativePath !== "" && !isAbsolute(relativePath) && relativePath !== ".." && !relativePath.startsWith(".." + "/") && target.endsWith(".jsonl");
|
|
129
|
+
}
|
|
130
|
+
const webSessionUi = {
|
|
131
|
+
select: (_title, options) => Promise.resolve(options[0]),
|
|
132
|
+
confirm: () => Promise.resolve(true),
|
|
133
|
+
input: () => Promise.resolve(undefined),
|
|
134
|
+
notify: () => { },
|
|
135
|
+
onTerminalInput: () => () => { },
|
|
136
|
+
setStatus: () => { },
|
|
137
|
+
setWorkingMessage: () => { },
|
|
138
|
+
setWorkingVisible: () => { },
|
|
139
|
+
setWorkingIndicator: () => { },
|
|
140
|
+
setHiddenThinkingLabel: () => { },
|
|
141
|
+
setWidget: () => { },
|
|
142
|
+
setFooter: () => { },
|
|
143
|
+
setHeader: () => { },
|
|
144
|
+
setTitle: () => { },
|
|
145
|
+
};
|
|
146
|
+
async function runWebSessionChange(services, action) {
|
|
147
|
+
const runner = services.runtime.session.extensionRunner;
|
|
148
|
+
runner.setUIContext(webSessionUi, "rpc");
|
|
149
|
+
try {
|
|
150
|
+
const result = await action();
|
|
151
|
+
if (result.cancelled)
|
|
152
|
+
runner.setUIContext(undefined, "print");
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
runner.setUIContext(undefined, "print");
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function modelSummary(model, active) {
|
|
161
|
+
return {
|
|
162
|
+
provider: model.provider,
|
|
163
|
+
id: model.id,
|
|
164
|
+
name: model.name ?? model.id,
|
|
165
|
+
reasoning: model.reasoning ?? false,
|
|
166
|
+
contextWindow: model.contextWindow ?? null,
|
|
167
|
+
active,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function visibleProviderIds(runtime, activeProvider) {
|
|
171
|
+
const providers = typeof runtime.getProviders === "function" ? runtime.getProviders() : [{ id: activeProvider, name: activeProvider }];
|
|
172
|
+
return new Set(providers
|
|
173
|
+
.filter((provider) => {
|
|
174
|
+
if (provider.id === activeProvider)
|
|
175
|
+
return true;
|
|
176
|
+
if (typeof runtime.getProviderAuthStatus !== "function")
|
|
177
|
+
return false;
|
|
178
|
+
const auth = runtime.getProviderAuthStatus(provider.id);
|
|
179
|
+
if (typeof auth !== "object" || auth === null || auth.configured !== true)
|
|
180
|
+
return false;
|
|
181
|
+
if (typeof runtime.getRegisteredProviderConfig === "function")
|
|
182
|
+
return runtime.getRegisteredProviderConfig(provider.id) !== undefined;
|
|
183
|
+
return true;
|
|
184
|
+
})
|
|
185
|
+
.map((provider) => provider.id));
|
|
186
|
+
}
|
|
187
|
+
function marketplacePluginForEntry(entry) {
|
|
188
|
+
return MARKETPLACE_PLUGINS.find((plugin) => plugin.packageName === entry.options.name);
|
|
189
|
+
}
|
|
190
|
+
function pluginSummary(entry) {
|
|
191
|
+
const states = ["pending", "loading", "active", "failed", "disposed", "unloading"];
|
|
192
|
+
const marketplacePlugin = marketplacePluginForEntry(entry);
|
|
193
|
+
const rawState = entry.fiber?.state;
|
|
194
|
+
const state = typeof rawState === "number"
|
|
195
|
+
? (states[rawState] ?? String(rawState))
|
|
196
|
+
: typeof rawState === "string"
|
|
197
|
+
? rawState
|
|
198
|
+
: rawState === undefined || rawState === null
|
|
199
|
+
? "unloaded"
|
|
200
|
+
: "unknown";
|
|
201
|
+
return {
|
|
202
|
+
id: entry.options.id,
|
|
203
|
+
name: entry.options.name,
|
|
204
|
+
enabled: !entry.options.disabled,
|
|
205
|
+
state,
|
|
206
|
+
removable: entry.options.id.startsWith("marketplace-") || marketplacePlugin !== undefined,
|
|
207
|
+
category: marketplacePlugin?.category,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function pluginLoaded(services, packageName) {
|
|
211
|
+
return services.loader !== undefined && [...services.loader.entries()].some((entry) => entry.options.name === packageName && !entry.disabled);
|
|
212
|
+
}
|
|
213
|
+
function registerPluginPanels(context, services) {
|
|
214
|
+
if (services.pluginUi === undefined)
|
|
215
|
+
return () => { };
|
|
216
|
+
const disposers = [
|
|
217
|
+
services.pluginUi.register({
|
|
218
|
+
id: "console-logger-panel",
|
|
219
|
+
pluginId: "@deepseek-ai/cordis-plugin-logger-console",
|
|
220
|
+
title: "运行时日志",
|
|
221
|
+
description: "查看最近的生命周期和运行时诊断输出。",
|
|
222
|
+
icon: "▤",
|
|
223
|
+
visible: () => pluginLoaded(services, "@deepseek-ai/cordis-plugin-logger-console"),
|
|
224
|
+
read: () => ({
|
|
225
|
+
total: context.logger.buffer.length,
|
|
226
|
+
items: context.logger.buffer.slice(-40).map((message) => ({
|
|
227
|
+
time: new Date(message.ts).toISOString(),
|
|
228
|
+
level: message.type,
|
|
229
|
+
source: message.name,
|
|
230
|
+
args: message.args,
|
|
231
|
+
})),
|
|
232
|
+
}),
|
|
233
|
+
}),
|
|
234
|
+
services.pluginUi.register({
|
|
235
|
+
id: "plugin-group-panel",
|
|
236
|
+
pluginId: "@deepseek-ai/cordis-plugin-group",
|
|
237
|
+
title: "插件树",
|
|
238
|
+
description: "查看当前运行时加载的插件树和生命周期状态。",
|
|
239
|
+
icon: "⌘",
|
|
240
|
+
visible: () => pluginLoaded(services, "@deepseek-ai/cordis-plugin-group"),
|
|
241
|
+
read: () => ({
|
|
242
|
+
entries: services.loader === undefined
|
|
243
|
+
? []
|
|
244
|
+
: [...services.loader.entries()].map((entry) => ({
|
|
245
|
+
id: entry.id,
|
|
246
|
+
name: entry.options.name.replace(/^@deepseek-ai\/cordis-plugin-/i, "plugin-").replace(/^cordis:/i, "runtime:"),
|
|
247
|
+
state: pluginSummary(entry).state,
|
|
248
|
+
enabled: !entry.disabled,
|
|
249
|
+
})),
|
|
250
|
+
}),
|
|
251
|
+
}),
|
|
252
|
+
services.pluginUi.register({
|
|
253
|
+
id: "timer-service-panel",
|
|
254
|
+
pluginId: "@deepseek-ai/cordis-plugin-timer",
|
|
255
|
+
title: "定时器服务",
|
|
256
|
+
description: "确认定时器服务已注册,并查看可用的生命周期绑定 API。",
|
|
257
|
+
icon: "◷",
|
|
258
|
+
visible: () => pluginLoaded(services, "@deepseek-ai/cordis-plugin-timer"),
|
|
259
|
+
read: () => ({
|
|
260
|
+
registered: context.reflect.get("timer") !== undefined,
|
|
261
|
+
capabilities: ["timeout", "interval", "throttle", "debounce"],
|
|
262
|
+
}),
|
|
263
|
+
}),
|
|
264
|
+
];
|
|
265
|
+
return () => disposers.reverse().forEach((dispose) => dispose());
|
|
266
|
+
}
|
|
267
|
+
function runProcess(executable, args, cwd) {
|
|
268
|
+
return new Promise((resolveProcess, rejectProcess) => {
|
|
269
|
+
execFile(executable, [...args], { cwd, timeout: 120_000, maxBuffer: 2 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
270
|
+
if (error) {
|
|
271
|
+
rejectProcess(new Error(`${executable} ${args.join(" ")} failed: ${stderr || error.message}`, { cause: error }));
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
resolveProcess({ stdout, stderr });
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
async function appendMarketplaceProfile(configPath, plugin) {
|
|
279
|
+
const source = await readFile(configPath, "utf8");
|
|
280
|
+
if (source.includes(`name: ${JSON.stringify(plugin.packageName)}`))
|
|
281
|
+
return source;
|
|
282
|
+
const entryId = `marketplace-${plugin.id}`;
|
|
283
|
+
const config = JSON.stringify(plugin.profile.config);
|
|
284
|
+
const group = plugin.profile.group === true ? "\n group: true" : "";
|
|
285
|
+
const entry = `\n- id: ${entryId}\n name: ${JSON.stringify(plugin.packageName)}${group}\n config: ${config}\n`;
|
|
286
|
+
await writeFile(configPath, source.replace(/\s*$/, "") + entry, "utf8");
|
|
287
|
+
return source;
|
|
288
|
+
}
|
|
289
|
+
async function updateMarketplaceProfile(configPath, entryId, update) {
|
|
290
|
+
const source = await readFile(configPath, "utf8");
|
|
291
|
+
const escapedId = entryId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
292
|
+
const pattern = new RegExp(`^([ \\t]*)- id: ${escapedId}[ \\t]*(?:\\r?\\n|$)`, "m");
|
|
293
|
+
const match = source.match(pattern);
|
|
294
|
+
if (match === null)
|
|
295
|
+
throw new Error(`Installed plugin profile entry was not found: ${entryId}`);
|
|
296
|
+
const indent = match[1] ?? "";
|
|
297
|
+
const start = match.index ?? 0;
|
|
298
|
+
let end = source.length;
|
|
299
|
+
const linePattern = /^([ \t]*)(?=\S)/gm;
|
|
300
|
+
linePattern.lastIndex = start + match[0].length;
|
|
301
|
+
for (let line = linePattern.exec(source); line !== null; line = linePattern.exec(source)) {
|
|
302
|
+
const lineIndent = line[1] ?? "";
|
|
303
|
+
const content = source.slice(line.index + lineIndent.length);
|
|
304
|
+
if (lineIndent.length < indent.length || (lineIndent === indent && content.startsWith("- "))) {
|
|
305
|
+
end = line.index;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const originalBlock = source.slice(start, end);
|
|
310
|
+
if (update.remove === true) {
|
|
311
|
+
await writeFile(configPath, source.slice(0, start) + source.slice(end), "utf8");
|
|
312
|
+
return source;
|
|
313
|
+
}
|
|
314
|
+
const childIndent = `${indent} `;
|
|
315
|
+
const disabledPattern = new RegExp(`^${childIndent}disabled: .*\\r?\\n`, "m");
|
|
316
|
+
let block = originalBlock.replace(disabledPattern, "");
|
|
317
|
+
if (update.disabled === true) {
|
|
318
|
+
const namePattern = new RegExp(`^(${childIndent}name: .*\\r?\\n)`, "m");
|
|
319
|
+
block = block.replace(namePattern, `$1${childIndent}disabled: true\n`);
|
|
320
|
+
}
|
|
321
|
+
await writeFile(configPath, source.slice(0, start) + block + source.slice(end), "utf8");
|
|
322
|
+
return source;
|
|
323
|
+
}
|
|
324
|
+
function writeSse(response, payload) {
|
|
325
|
+
response.write(`data: ${JSON.stringify(jsonSafe(payload))}\n\n`);
|
|
326
|
+
}
|
|
327
|
+
function gitStatus(cwd) {
|
|
328
|
+
return new Promise((resolve) => {
|
|
329
|
+
execFile("git", ["status", "--short", "--untracked-files=all"], { cwd, maxBuffer: 512 * 1024 }, (error, stdout) => resolve(error ? "" : stdout));
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
function gitDiff(cwd, path) {
|
|
333
|
+
return new Promise((resolveOutput) => {
|
|
334
|
+
execFile("git", ["diff", "--no-ext-diff", "--", path], { cwd, maxBuffer: 1024 * 1024 }, (error, stdout) => resolveOutput(error && stdout.length === 0 ? "" : stdout));
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function gitCommand(cwd, args) {
|
|
338
|
+
return new Promise((resolveResult) => {
|
|
339
|
+
execFile("git", [...args], { cwd, maxBuffer: 2 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
340
|
+
const code = error && typeof error.code === "number" ? error.code : error ? 1 : 0;
|
|
341
|
+
resolveResult({ stdout, stderr, code });
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
function probeEveryApiCliAuth() {
|
|
346
|
+
const executable = process.env.EVERYAPI_CLI_PATH?.trim() || "everyapi";
|
|
347
|
+
return new Promise((resolveStatus) => {
|
|
348
|
+
execFile(executable, ["auth", "status"], { timeout: 3_000, maxBuffer: 128 * 1024 }, (error) => {
|
|
349
|
+
resolveStatus({
|
|
350
|
+
configured: false,
|
|
351
|
+
source: "everyapi-cli",
|
|
352
|
+
label: error ? "未检测到 EveryAPI CLI 登录" : "EveryAPI CLI 已登录,但 relay key 未注入当前进程",
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
async function listWorkspaces(cwd) {
|
|
358
|
+
const result = await gitCommand(cwd, ["worktree", "list", "--porcelain"]);
|
|
359
|
+
const parsed = result.code === 0 ? parseGitWorktrees(result.stdout, cwd) : [];
|
|
360
|
+
if (parsed.some((item) => item.current))
|
|
361
|
+
return parsed;
|
|
362
|
+
return [{ path: resolve(cwd), branch: "current", current: true, name: resolve(cwd).split("/").pop() ?? resolve(cwd) }, ...parsed];
|
|
363
|
+
}
|
|
364
|
+
async function isDirectory(path) {
|
|
365
|
+
try {
|
|
366
|
+
return (await stat(path)).isDirectory();
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function pickDirectory() {
|
|
373
|
+
return new Promise((resolvePath, reject) => {
|
|
374
|
+
execFile("osascript", ["-e", 'POSIX path of (choose folder with prompt "选择 Pi 工作区")'], { timeout: 120_000, maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
|
|
375
|
+
if (error) {
|
|
376
|
+
reject(new Error(stderr.trim() || "目录选择已取消"));
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const path = stdout.trim();
|
|
380
|
+
if (!path)
|
|
381
|
+
reject(new Error("目录选择已取消"));
|
|
382
|
+
else
|
|
383
|
+
resolvePath(path);
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
function workspacePaths(root, paths) {
|
|
388
|
+
if (!Array.isArray(paths) || paths.length === 0 || paths.some((path) => typeof path !== "string" || path.trim() === ""))
|
|
389
|
+
return new Error("paths must be a non-empty array of strings");
|
|
390
|
+
const normalized = [];
|
|
391
|
+
for (const path of paths) {
|
|
392
|
+
const requested = path;
|
|
393
|
+
const absolute = resolve(root, requested);
|
|
394
|
+
const relativePath = relative(root, absolute);
|
|
395
|
+
if (isAbsolute(relativePath) || relativePath === ".." || relativePath.startsWith("../"))
|
|
396
|
+
return new Error("path must stay inside the workspace");
|
|
397
|
+
normalized.push(relativePath);
|
|
398
|
+
}
|
|
399
|
+
return [...new Set(normalized)];
|
|
400
|
+
}
|
|
401
|
+
export default {
|
|
402
|
+
name: "pi-api-gateway",
|
|
403
|
+
inject: ["webServer", "piRuntime", "piModels", "piHarnessLaunch"],
|
|
404
|
+
apply(context) {
|
|
405
|
+
const services = {
|
|
406
|
+
runtime: context.reflect.get("piRuntime"),
|
|
407
|
+
models: context.reflect.get("piModels"),
|
|
408
|
+
launch: context.reflect.get("piHarnessLaunch"),
|
|
409
|
+
webServer: context.webServer,
|
|
410
|
+
loader: context.reflect.get("loader"),
|
|
411
|
+
pluginUi: context.reflect.get("piPluginUi"),
|
|
412
|
+
};
|
|
413
|
+
const disposePluginPanels = registerPluginPanels(context, services);
|
|
414
|
+
let busy = false;
|
|
415
|
+
const events = [];
|
|
416
|
+
const eventClients = new Set();
|
|
417
|
+
const handleEvent = (event) => {
|
|
418
|
+
events.push(event);
|
|
419
|
+
for (const response of eventClients) {
|
|
420
|
+
if (response.writableEnded || response.destroyed) {
|
|
421
|
+
eventClients.delete(response);
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
writeSse(response, { type: "event", event });
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
const unsubscribeEvents = services.runtime.sessionRuntime
|
|
428
|
+
? context.on("pi/session-event", handleEvent)
|
|
429
|
+
: services.runtime.session.subscribe(handleEvent);
|
|
430
|
+
const disposeStatus = services.webServer.register({
|
|
431
|
+
path: "/api/status",
|
|
432
|
+
handler(_request, response) {
|
|
433
|
+
sendJson(response, 200, createStatus(services, events));
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
const disposeConfig = services.webServer.register({
|
|
437
|
+
path: "/api/config",
|
|
438
|
+
async handler(request, response) {
|
|
439
|
+
if (request.method === "GET") {
|
|
440
|
+
sendJson(response, 200, piConfig(services));
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (request.method !== "POST") {
|
|
444
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
try {
|
|
448
|
+
const payload = JSON.parse(await bodyText(request));
|
|
449
|
+
const settings = services.runtime.session.settingsManager;
|
|
450
|
+
if (typeof payload.defaultProvider === "string" && payload.defaultProvider.trim())
|
|
451
|
+
settings.setDefaultProvider(payload.defaultProvider.trim());
|
|
452
|
+
if (typeof payload.defaultModel === "string" && payload.defaultModel.trim())
|
|
453
|
+
settings.setDefaultModel(payload.defaultModel.trim());
|
|
454
|
+
if (payload.defaultThinkingLevel === "off" ||
|
|
455
|
+
payload.defaultThinkingLevel === "minimal" ||
|
|
456
|
+
payload.defaultThinkingLevel === "low" ||
|
|
457
|
+
payload.defaultThinkingLevel === "medium" ||
|
|
458
|
+
payload.defaultThinkingLevel === "high" ||
|
|
459
|
+
payload.defaultThinkingLevel === "xhigh" ||
|
|
460
|
+
payload.defaultThinkingLevel === "max")
|
|
461
|
+
settings.setDefaultThinkingLevel(payload.defaultThinkingLevel);
|
|
462
|
+
if (payload.transport === "sse" || payload.transport === "websocket" || payload.transport === "auto")
|
|
463
|
+
settings.setTransport(payload.transport);
|
|
464
|
+
if (payload.steeringMode === "all" || payload.steeringMode === "one-at-a-time")
|
|
465
|
+
settings.setSteeringMode(payload.steeringMode);
|
|
466
|
+
if (payload.followUpMode === "all" || payload.followUpMode === "one-at-a-time")
|
|
467
|
+
settings.setFollowUpMode(payload.followUpMode);
|
|
468
|
+
if (typeof payload.hideThinkingBlock === "boolean")
|
|
469
|
+
settings.setHideThinkingBlock(payload.hideThinkingBlock);
|
|
470
|
+
if (typeof payload.retry === "object" && payload.retry !== null) {
|
|
471
|
+
const retry = payload.retry;
|
|
472
|
+
if (typeof retry.enabled === "boolean")
|
|
473
|
+
settings.setRetryEnabled(retry.enabled);
|
|
474
|
+
}
|
|
475
|
+
if (typeof payload.terminal === "object" && payload.terminal !== null) {
|
|
476
|
+
const terminal = payload.terminal;
|
|
477
|
+
if (typeof terminal.showImages === "boolean")
|
|
478
|
+
settings.setShowImages(terminal.showImages);
|
|
479
|
+
if (typeof terminal.imageAutoResize === "boolean")
|
|
480
|
+
settings.setImageAutoResize(terminal.imageAutoResize);
|
|
481
|
+
if (typeof terminal.autocompleteMaxVisible === "number" && Number.isInteger(terminal.autocompleteMaxVisible))
|
|
482
|
+
settings.setAutocompleteMaxVisible(Math.min(20, Math.max(3, terminal.autocompleteMaxVisible)));
|
|
483
|
+
}
|
|
484
|
+
if (typeof payload.advanced === "object" && payload.advanced !== null) {
|
|
485
|
+
const advanced = payload.advanced;
|
|
486
|
+
if (typeof advanced.quietStartup === "boolean")
|
|
487
|
+
settings.setQuietStartup(advanced.quietStartup);
|
|
488
|
+
if (advanced.projectTrust === "ask" || advanced.projectTrust === "always" || advanced.projectTrust === "never")
|
|
489
|
+
settings.setDefaultProjectTrust(advanced.projectTrust);
|
|
490
|
+
if (typeof advanced.showCacheMissNotices === "boolean")
|
|
491
|
+
settings.setShowCacheMissNotices(advanced.showCacheMissNotices);
|
|
492
|
+
if (typeof advanced.enableInstallTelemetry === "boolean")
|
|
493
|
+
settings.setEnableInstallTelemetry(advanced.enableInstallTelemetry);
|
|
494
|
+
if (typeof advanced.shellPath === "string")
|
|
495
|
+
settings.setShellPath(advanced.shellPath.trim() || undefined);
|
|
496
|
+
if (advanced.doubleEscapeAction === "fork" || advanced.doubleEscapeAction === "tree" || advanced.doubleEscapeAction === "none")
|
|
497
|
+
settings.setDoubleEscapeAction(advanced.doubleEscapeAction);
|
|
498
|
+
if (advanced.treeFilterMode === "default" ||
|
|
499
|
+
advanced.treeFilterMode === "no-tools" ||
|
|
500
|
+
advanced.treeFilterMode === "user-only" ||
|
|
501
|
+
advanced.treeFilterMode === "labeled-only" ||
|
|
502
|
+
advanced.treeFilterMode === "all")
|
|
503
|
+
settings.setTreeFilterMode(advanced.treeFilterMode);
|
|
504
|
+
if (advanced.mermaid === "off" || advanced.mermaid === "final" || advanced.mermaid === "streaming")
|
|
505
|
+
settings.setMermaidRenderingMode(advanced.mermaid);
|
|
506
|
+
}
|
|
507
|
+
if (typeof payload.compaction === "object" &&
|
|
508
|
+
payload.compaction !== null &&
|
|
509
|
+
typeof payload.compaction.enabled === "boolean")
|
|
510
|
+
settings.setCompactionEnabled(payload.compaction.enabled === true);
|
|
511
|
+
await settings.flush();
|
|
512
|
+
sendJson(response, 200, piConfig(services));
|
|
513
|
+
}
|
|
514
|
+
catch (error) {
|
|
515
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
const disposeConfigReload = services.webServer.register({
|
|
520
|
+
path: "/api/config/reload",
|
|
521
|
+
async handler(request, response) {
|
|
522
|
+
if (request.method !== "POST") {
|
|
523
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
await services.runtime.session.settingsManager.reload();
|
|
528
|
+
sendJson(response, 200, piConfig(services));
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
});
|
|
535
|
+
const disposeConfigSource = services.webServer.register({
|
|
536
|
+
path: "/api/config/source",
|
|
537
|
+
async handler(request, response) {
|
|
538
|
+
if (request.method !== "POST") {
|
|
539
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
const payload = JSON.parse(await bodyText(request));
|
|
544
|
+
if (typeof payload.source !== "string" || payload.source.length > 128 * 1024) {
|
|
545
|
+
sendJson(response, 400, { error: "source must be a JSON document smaller than 128 KiB" });
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const parsed = JSON.parse(payload.source);
|
|
549
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
550
|
+
sendJson(response, 400, { error: "settings source must contain a JSON object" });
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
const path = join(services.launch.agentDir, "settings.json");
|
|
554
|
+
await writeFile(path, JSON.stringify(parsed, null, 2) + "\n", "utf8");
|
|
555
|
+
await services.runtime.session.settingsManager.reload();
|
|
556
|
+
sendJson(response, 200, piConfig(services));
|
|
557
|
+
}
|
|
558
|
+
catch (error) {
|
|
559
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
const disposeModels = services.webServer.register({
|
|
564
|
+
path: "/api/models",
|
|
565
|
+
handler(_request, response) {
|
|
566
|
+
const active = services.runtime.session.model ?? services.models.model;
|
|
567
|
+
const visible = visibleProviderIds(services.models.runtime, active.provider);
|
|
568
|
+
sendJson(response, 200, jsonSafe({
|
|
569
|
+
items: services.models.runtime
|
|
570
|
+
.getModels()
|
|
571
|
+
.filter((model) => visible.has(model.provider))
|
|
572
|
+
.map((model) => modelSummary(model, model.provider === active.provider && model.id === active.id)),
|
|
573
|
+
}));
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
const disposeProviders = services.webServer.register({
|
|
577
|
+
path: "/api/providers",
|
|
578
|
+
handler(_request, response) {
|
|
579
|
+
const active = services.runtime.session.model ?? services.models.model;
|
|
580
|
+
const runtime = services.models.runtime;
|
|
581
|
+
const providers = typeof runtime.getProviders === "function" ? runtime.getProviders() : [{ id: active.provider, name: active.provider }];
|
|
582
|
+
const visibleIds = visibleProviderIds(runtime, active.provider);
|
|
583
|
+
const visible = providers.filter((provider) => visibleIds.has(provider.id));
|
|
584
|
+
sendJson(response, 200, jsonSafe({
|
|
585
|
+
items: visible.map((provider) => ({
|
|
586
|
+
provider: provider.id,
|
|
587
|
+
name: provider.name ?? provider.id,
|
|
588
|
+
active: provider.id === active.provider,
|
|
589
|
+
auth: typeof runtime.getProviderAuthStatus === "function" ? runtime.getProviderAuthStatus(provider.id) : undefined,
|
|
590
|
+
activeModel: provider.id === active.provider ? modelSummary(active, true) : undefined,
|
|
591
|
+
models: services.models.runtime
|
|
592
|
+
.getModels(provider.id)
|
|
593
|
+
.map((model) => modelSummary(model, model.provider === active.provider && model.id === active.id)),
|
|
594
|
+
})),
|
|
595
|
+
}));
|
|
596
|
+
},
|
|
597
|
+
});
|
|
598
|
+
const disposeProviderAdd = services.webServer.register({
|
|
599
|
+
path: "/api/providers/add",
|
|
600
|
+
async handler(request, response) {
|
|
601
|
+
if (request.method !== "POST") {
|
|
602
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
try {
|
|
606
|
+
const payload = JSON.parse(await bodyText(request));
|
|
607
|
+
const provider = typeof payload.provider === "string" ? payload.provider.trim() : "";
|
|
608
|
+
const name = typeof payload.name === "string" && payload.name.trim() !== "" ? payload.name.trim() : provider;
|
|
609
|
+
const baseUrl = typeof payload.baseUrl === "string" ? payload.baseUrl.trim() : "";
|
|
610
|
+
const apiKey = typeof payload.apiKey === "string" ? payload.apiKey.trim() : "";
|
|
611
|
+
const model = typeof payload.model === "string" ? payload.model.trim() : "";
|
|
612
|
+
const api = payload.api === "openai-responses" ? "openai-responses" : "openai-completions";
|
|
613
|
+
if (!/^[a-z0-9][a-z0-9._-]{1,63}$/i.test(provider)) {
|
|
614
|
+
sendJson(response, 400, { error: "provider must be 2-64 characters using letters, numbers, ., _, or -" });
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
if (!/^https?:\/\/[^\s]+$/i.test(baseUrl)) {
|
|
618
|
+
sendJson(response, 400, { error: "baseUrl must be an http(s) URL" });
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (!apiKey || !model) {
|
|
622
|
+
sendJson(response, 400, { error: "apiKey and model are required" });
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const runtime = services.models.runtime;
|
|
626
|
+
if (runtime.getProvider(provider) !== undefined) {
|
|
627
|
+
sendJson(response, 409, { error: `Provider already exists: ${provider}` });
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
runtime.registerProvider(provider, {
|
|
631
|
+
name,
|
|
632
|
+
baseUrl,
|
|
633
|
+
api,
|
|
634
|
+
models: [
|
|
635
|
+
{
|
|
636
|
+
id: model,
|
|
637
|
+
name: model,
|
|
638
|
+
api,
|
|
639
|
+
reasoning: false,
|
|
640
|
+
input: ["text"],
|
|
641
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
642
|
+
contextWindow: 128000,
|
|
643
|
+
maxTokens: 8192,
|
|
644
|
+
},
|
|
645
|
+
],
|
|
646
|
+
});
|
|
647
|
+
await runtime.setRuntimeApiKey(provider, apiKey);
|
|
648
|
+
sendJson(response, 201, {
|
|
649
|
+
provider: {
|
|
650
|
+
provider,
|
|
651
|
+
name,
|
|
652
|
+
active: false,
|
|
653
|
+
auth: runtime.getProviderAuthStatus(provider),
|
|
654
|
+
models: runtime.getModels(provider).map((item) => modelSummary(item, false)),
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
catch (error) {
|
|
659
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
});
|
|
663
|
+
const disposeProviderTest = services.webServer.register({
|
|
664
|
+
path: "/api/providers/test",
|
|
665
|
+
async handler(request, response) {
|
|
666
|
+
if (request.method !== "POST") {
|
|
667
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
try {
|
|
671
|
+
const payload = JSON.parse(await bodyText(request));
|
|
672
|
+
if (typeof payload.provider !== "string" || payload.provider.trim() === "") {
|
|
673
|
+
sendJson(response, 400, { error: "provider is required" });
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const runtime = services.models.runtime;
|
|
677
|
+
if (typeof runtime.checkAuth !== "function") {
|
|
678
|
+
sendJson(response, 501, { error: "The active model runtime does not support provider checks" });
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
const auth = await runtime.checkAuth(payload.provider);
|
|
682
|
+
if (payload.provider === "everyapi" && auth === undefined && !process.env.EVERYAPI_RELAY_KEY?.trim()) {
|
|
683
|
+
const cliAuth = await probeEveryApiCliAuth();
|
|
684
|
+
sendJson(response, 200, { provider: payload.provider, reachable: false, auth: cliAuth });
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
sendJson(response, 200, jsonSafe({ provider: payload.provider, reachable: auth !== undefined, auth }));
|
|
688
|
+
}
|
|
689
|
+
catch (error) {
|
|
690
|
+
sendJson(response, 502, { error: errorText(error) });
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
});
|
|
694
|
+
const disposeProviderRefresh = services.webServer.register({
|
|
695
|
+
path: "/api/providers/refresh",
|
|
696
|
+
async handler(request, response) {
|
|
697
|
+
if (request.method !== "POST") {
|
|
698
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
try {
|
|
702
|
+
const payload = JSON.parse(await bodyText(request));
|
|
703
|
+
if (typeof payload.provider !== "string" || payload.provider.trim() === "") {
|
|
704
|
+
sendJson(response, 400, { error: "provider is required" });
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
const runtime = services.models.runtime;
|
|
708
|
+
if (typeof runtime.getAvailable !== "function") {
|
|
709
|
+
sendJson(response, 501, { error: "The active model runtime does not support provider refresh" });
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
const models = await runtime.getAvailable(payload.provider);
|
|
713
|
+
sendJson(response, 200, jsonSafe({ provider: payload.provider, models }));
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
sendJson(response, 502, { error: errorText(error) });
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
});
|
|
720
|
+
const disposePlugins = services.webServer.register({
|
|
721
|
+
path: "/api/plugins",
|
|
722
|
+
handler(_request, response) {
|
|
723
|
+
const items = services.loader ? [...services.loader.entries()].map(pluginSummary) : [];
|
|
724
|
+
sendJson(response, 200, jsonSafe({ items }));
|
|
725
|
+
},
|
|
726
|
+
});
|
|
727
|
+
const disposePluginUi = services.webServer.register({
|
|
728
|
+
path: "/api/plugin-ui",
|
|
729
|
+
async handler(request, response) {
|
|
730
|
+
if (request.method !== "GET") {
|
|
731
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
try {
|
|
735
|
+
const items = services.pluginUi === undefined ? [] : await services.pluginUi.snapshot();
|
|
736
|
+
sendJson(response, 200, jsonSafe({ items }));
|
|
737
|
+
}
|
|
738
|
+
catch (error) {
|
|
739
|
+
sendJson(response, 500, { error: errorText(error) });
|
|
740
|
+
}
|
|
741
|
+
},
|
|
742
|
+
});
|
|
743
|
+
const disposeMarketplace = services.webServer.register({
|
|
744
|
+
path: "/api/marketplace",
|
|
745
|
+
async handler(request, response) {
|
|
746
|
+
if (request.method !== "GET") {
|
|
747
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
const url = new URL(request.url ?? "/api/marketplace", "http://localhost");
|
|
751
|
+
const query = url.searchParams.get("q") ?? "";
|
|
752
|
+
const capability = url.searchParams.get("capability") ?? "";
|
|
753
|
+
const category = url.searchParams.get("category") ?? "";
|
|
754
|
+
const page = Number(url.searchParams.get("page") ?? "0");
|
|
755
|
+
const pageSize = Number(url.searchParams.get("pageSize") ?? "24");
|
|
756
|
+
const sort = url.searchParams.get("sort") ?? "";
|
|
757
|
+
if (query.length > 120 ||
|
|
758
|
+
capability.length > 80 ||
|
|
759
|
+
category.length > 80 ||
|
|
760
|
+
!Number.isInteger(page) ||
|
|
761
|
+
page < 0 ||
|
|
762
|
+
!Number.isInteger(pageSize) ||
|
|
763
|
+
pageSize < 1 ||
|
|
764
|
+
pageSize > 100 ||
|
|
765
|
+
(sort !== "" && sort !== "recommended")) {
|
|
766
|
+
sendJson(response, 400, { error: "Invalid marketplace query" });
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
const filtered = searchMarketplace(query, capability, category);
|
|
770
|
+
const items = sort === "recommended"
|
|
771
|
+
? sortMarketplaceByRecommendation(attachMarketplaceStatistics(filtered, await loadMarketplaceStatistics(MARKETPLACE_PLUGINS)))
|
|
772
|
+
: filtered;
|
|
773
|
+
sendJson(response, 200, {
|
|
774
|
+
...paginateMarketplace(items, page, pageSize),
|
|
775
|
+
capabilities: MARKETPLACE_CAPABILITIES,
|
|
776
|
+
categories: MARKETPLACE_CATEGORIES,
|
|
777
|
+
});
|
|
778
|
+
},
|
|
779
|
+
});
|
|
780
|
+
let marketplaceMutationInFlight = false;
|
|
781
|
+
const disposeMarketplaceInstall = services.webServer.register({
|
|
782
|
+
path: "/api/marketplace/install",
|
|
783
|
+
async handler(request, response) {
|
|
784
|
+
if (request.method !== "POST") {
|
|
785
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (marketplaceMutationInFlight) {
|
|
789
|
+
sendJson(response, 409, { error: "Another marketplace plugin change is already running" });
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
const loader = services.loader;
|
|
793
|
+
const configPath = services.launch.configPath;
|
|
794
|
+
if (loader === undefined || configPath === undefined) {
|
|
795
|
+
sendJson(response, 501, { error: "Plugin installation is unavailable for this runtime" });
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
marketplaceMutationInFlight = true;
|
|
799
|
+
try {
|
|
800
|
+
const payload = JSON.parse(await bodyText(request));
|
|
801
|
+
if (typeof payload.id !== "string" || payload.id.trim() === "") {
|
|
802
|
+
sendJson(response, 400, { error: "id is required" });
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
const plugin = MARKETPLACE_PLUGINS.find((item) => item.id === payload.id);
|
|
806
|
+
if (plugin === undefined) {
|
|
807
|
+
sendJson(response, 404, { error: "Marketplace plugin was not found" });
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
const existing = [...loader.entries()].find((entry) => entry.options.name === plugin.packageName);
|
|
811
|
+
if (existing !== undefined) {
|
|
812
|
+
sendJson(response, 409, { error: "Plugin is already installed", plugin });
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
const packageJsonPath = join(services.launch.cwd, "package.json");
|
|
816
|
+
const packageLockPath = join(services.launch.cwd, "package-lock.json");
|
|
817
|
+
const packageJsonBefore = await readFile(packageJsonPath, "utf8").catch(() => undefined);
|
|
818
|
+
const packageLockBefore = await readFile(packageLockPath, "utf8").catch(() => undefined);
|
|
819
|
+
let profileBefore;
|
|
820
|
+
let entryId;
|
|
821
|
+
try {
|
|
822
|
+
if (needsMarketplacePackageInstall(plugin)) {
|
|
823
|
+
await runProcess("npm", ["install", "--save-exact", "--package-lock=false", `${plugin.packageName}@${plugin.version}`], services.launch.cwd);
|
|
824
|
+
}
|
|
825
|
+
profileBefore = await appendMarketplaceProfile(configPath, plugin);
|
|
826
|
+
if (!needsMarketplacePackageInstall(plugin)) {
|
|
827
|
+
sendJson(response, 200, { plugin, installed: false, restartRequired: true });
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
entryId = await loader.create({
|
|
831
|
+
id: `marketplace-${plugin.id}`,
|
|
832
|
+
name: plugin.packageName,
|
|
833
|
+
...(plugin.profile.group === true ? { group: true } : {}),
|
|
834
|
+
config: plugin.profile.config,
|
|
835
|
+
});
|
|
836
|
+
const entry = loader.resolve(entryId);
|
|
837
|
+
if (entry.fiber === undefined)
|
|
838
|
+
throw new Error(`Plugin ${plugin.packageName} did not create a runtime fiber`);
|
|
839
|
+
await entry.fiber.await();
|
|
840
|
+
sendJson(response, 200, { plugin, installed: true });
|
|
841
|
+
}
|
|
842
|
+
catch (error) {
|
|
843
|
+
if (entryId !== undefined)
|
|
844
|
+
await loader.remove(entryId).catch(() => { });
|
|
845
|
+
if (profileBefore !== undefined)
|
|
846
|
+
await writeFile(configPath, profileBefore, "utf8").catch(() => { });
|
|
847
|
+
if (packageJsonBefore !== undefined)
|
|
848
|
+
await writeFile(packageJsonPath, packageJsonBefore, "utf8").catch(() => { });
|
|
849
|
+
if (packageLockBefore !== undefined)
|
|
850
|
+
await writeFile(packageLockPath, packageLockBefore, "utf8").catch(() => { });
|
|
851
|
+
sendJson(response, 502, { error: errorText(error) });
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
catch (error) {
|
|
855
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
856
|
+
}
|
|
857
|
+
finally {
|
|
858
|
+
marketplaceMutationInFlight = false;
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
});
|
|
862
|
+
const disposePluginToggle = services.webServer.register({
|
|
863
|
+
path: "/api/plugins/toggle",
|
|
864
|
+
async handler(request, response) {
|
|
865
|
+
if (request.method !== "POST") {
|
|
866
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
const configPath = services.launch.configPath;
|
|
870
|
+
const loader = services.loader;
|
|
871
|
+
if (configPath === undefined || loader === undefined) {
|
|
872
|
+
sendJson(response, 501, { error: "Plugin configuration is unavailable for this runtime" });
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
if (marketplaceMutationInFlight) {
|
|
876
|
+
sendJson(response, 409, { error: "Another marketplace plugin change is already running" });
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
marketplaceMutationInFlight = true;
|
|
880
|
+
try {
|
|
881
|
+
const payload = JSON.parse(await bodyText(request));
|
|
882
|
+
if (typeof payload.id !== "string" || typeof payload.enabled !== "boolean") {
|
|
883
|
+
sendJson(response, 400, { error: "A marketplace plugin id and enabled boolean are required" });
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
const entry = [...loader.entries()].find((item) => item.id === payload.id || item.options.id === payload.id);
|
|
887
|
+
if (entry === undefined) {
|
|
888
|
+
sendJson(response, 404, { error: "Installed plugin was not found" });
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
const plugin = marketplacePluginForEntry(entry);
|
|
892
|
+
if (plugin === undefined) {
|
|
893
|
+
sendJson(response, 403, { error: "Built-in plugins cannot be changed" });
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
const profileEntryId = entry.options.id;
|
|
897
|
+
const before = await updateMarketplaceProfile(configPath, profileEntryId, { disabled: !payload.enabled });
|
|
898
|
+
try {
|
|
899
|
+
await entry.update({ disabled: !payload.enabled });
|
|
900
|
+
sendJson(response, 200, { plugin: pluginSummary(entry) });
|
|
901
|
+
}
|
|
902
|
+
catch (error) {
|
|
903
|
+
await writeFile(configPath, before, "utf8").catch(() => { });
|
|
904
|
+
sendJson(response, 502, { error: errorText(error) });
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
catch (error) {
|
|
908
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
909
|
+
}
|
|
910
|
+
finally {
|
|
911
|
+
marketplaceMutationInFlight = false;
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
});
|
|
915
|
+
const disposePluginUninstall = services.webServer.register({
|
|
916
|
+
path: "/api/plugins/uninstall",
|
|
917
|
+
async handler(request, response) {
|
|
918
|
+
if (request.method !== "POST") {
|
|
919
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
const configPath = services.launch.configPath;
|
|
923
|
+
const loader = services.loader;
|
|
924
|
+
if (configPath === undefined || loader === undefined) {
|
|
925
|
+
sendJson(response, 501, { error: "Plugin configuration is unavailable for this runtime" });
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (marketplaceMutationInFlight) {
|
|
929
|
+
sendJson(response, 409, { error: "Another marketplace plugin change is already running" });
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
marketplaceMutationInFlight = true;
|
|
933
|
+
try {
|
|
934
|
+
const payload = JSON.parse(await bodyText(request));
|
|
935
|
+
if (typeof payload.id !== "string") {
|
|
936
|
+
sendJson(response, 400, { error: "A marketplace plugin id is required" });
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
const entry = [...loader.entries()].find((item) => item.id === payload.id || item.options.id === payload.id);
|
|
940
|
+
if (entry === undefined) {
|
|
941
|
+
sendJson(response, 404, { error: "Installed plugin was not found" });
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
const plugin = marketplacePluginForEntry(entry);
|
|
945
|
+
if (plugin === undefined) {
|
|
946
|
+
sendJson(response, 403, { error: "Only marketplace plugins can be uninstalled" });
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
const profileEntryId = entry.options.id;
|
|
950
|
+
const profileBefore = await readFile(configPath, "utf8");
|
|
951
|
+
const packageJsonPath = join(services.launch.cwd, "package.json");
|
|
952
|
+
const packageLockPath = join(services.launch.cwd, "package-lock.json");
|
|
953
|
+
const packageJsonBefore = await readFile(packageJsonPath, "utf8").catch(() => undefined);
|
|
954
|
+
const packageLockBefore = await readFile(packageLockPath, "utf8").catch(() => undefined);
|
|
955
|
+
await entry.parent.remove(entry.options.id);
|
|
956
|
+
entry.parent.tree.write();
|
|
957
|
+
try {
|
|
958
|
+
await updateMarketplaceProfile(configPath, profileEntryId, { remove: true });
|
|
959
|
+
if (needsMarketplacePackageInstall(plugin))
|
|
960
|
+
await runProcess("npm", ["uninstall", "--package-lock=false", plugin.packageName], services.launch.cwd);
|
|
961
|
+
sendJson(response, 200, { uninstalled: true, id: payload.id });
|
|
962
|
+
}
|
|
963
|
+
catch (error) {
|
|
964
|
+
await writeFile(configPath, profileBefore, "utf8").catch(() => { });
|
|
965
|
+
if (packageJsonBefore !== undefined)
|
|
966
|
+
await writeFile(packageJsonPath, packageJsonBefore, "utf8").catch(() => { });
|
|
967
|
+
if (packageLockBefore !== undefined)
|
|
968
|
+
await writeFile(packageLockPath, packageLockBefore, "utf8").catch(() => { });
|
|
969
|
+
const options = entry.options;
|
|
970
|
+
await loader
|
|
971
|
+
.create({ id: entry.options.id, name: options.name, config: options.config, ...(options.group ? { group: true } : {}) })
|
|
972
|
+
.catch(() => { });
|
|
973
|
+
sendJson(response, 502, { error: errorText(error) });
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
catch (error) {
|
|
977
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
978
|
+
}
|
|
979
|
+
finally {
|
|
980
|
+
marketplaceMutationInFlight = false;
|
|
981
|
+
}
|
|
982
|
+
},
|
|
983
|
+
});
|
|
984
|
+
const disposeCommands = services.webServer.register({
|
|
985
|
+
path: "/api/commands",
|
|
986
|
+
handler(_request, response) {
|
|
987
|
+
const commands = services.runtime.session.extensionRunner.getRegisteredCommands();
|
|
988
|
+
const items = commands.map((command) => ({
|
|
989
|
+
name: command.name,
|
|
990
|
+
invocationName: command.invocationName,
|
|
991
|
+
description: command.description,
|
|
992
|
+
source: command.sourceInfo.path,
|
|
993
|
+
}));
|
|
994
|
+
sendJson(response, 200, jsonSafe({ items }));
|
|
995
|
+
},
|
|
996
|
+
});
|
|
997
|
+
const disposeWorkspaces = services.webServer.register({
|
|
998
|
+
path: "/api/workspaces",
|
|
999
|
+
async handler(_request, response) {
|
|
1000
|
+
try {
|
|
1001
|
+
sendJson(response, 200, { items: await listWorkspaces(activeCwd(services)) });
|
|
1002
|
+
}
|
|
1003
|
+
catch (error) {
|
|
1004
|
+
sendJson(response, 500, { error: errorText(error) });
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
});
|
|
1008
|
+
const disposePickDirectory = services.webServer.register({
|
|
1009
|
+
path: "/api/workspaces/pick",
|
|
1010
|
+
async handler(request, response) {
|
|
1011
|
+
if (request.method !== "POST") {
|
|
1012
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
if (process.platform !== "darwin") {
|
|
1016
|
+
sendJson(response, 501, { error: "Native directory picker is only available on macOS" });
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
try {
|
|
1020
|
+
sendJson(response, 200, { path: await pickDirectory() });
|
|
1021
|
+
}
|
|
1022
|
+
catch (error) {
|
|
1023
|
+
sendJson(response, 409, { error: errorText(error) });
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
});
|
|
1027
|
+
const disposeModel = services.webServer.register({
|
|
1028
|
+
path: "/api/model",
|
|
1029
|
+
async handler(request, response) {
|
|
1030
|
+
if (request.method !== "POST") {
|
|
1031
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
if (services.runtime.session.isStreaming) {
|
|
1035
|
+
sendJson(response, 409, { error: "Cannot change model while a prompt is running" });
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
try {
|
|
1039
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1040
|
+
if (typeof payload.provider !== "string" || typeof payload.model !== "string" || payload.provider.trim() === "" || payload.model.trim() === "") {
|
|
1041
|
+
sendJson(response, 400, { error: "provider and model are required" });
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
const model = services.models.runtime.getModel(payload.provider, payload.model);
|
|
1045
|
+
if (model === undefined) {
|
|
1046
|
+
sendJson(response, 404, { error: `Model not found: ${payload.provider}/${payload.model}` });
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
if (typeof services.runtime.session.setModel !== "function") {
|
|
1050
|
+
sendJson(response, 501, { error: "The active Pi session does not support model switching" });
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
await services.runtime.session.setModel(model);
|
|
1054
|
+
sendJson(response, 200, jsonSafe({ model: modelSummary(model, true) }));
|
|
1055
|
+
}
|
|
1056
|
+
catch (error) {
|
|
1057
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
});
|
|
1061
|
+
const disposeFiles = services.webServer.register({
|
|
1062
|
+
path: "/api/files",
|
|
1063
|
+
async handler(_request, response) {
|
|
1064
|
+
const output = await gitStatus(activeCwd(services));
|
|
1065
|
+
const items = output
|
|
1066
|
+
.split("\n")
|
|
1067
|
+
.map((line) => line.trimEnd())
|
|
1068
|
+
.filter((line) => line.length > 0)
|
|
1069
|
+
.map((line) => {
|
|
1070
|
+
const status = line.slice(0, 2).trim() || "??";
|
|
1071
|
+
return {
|
|
1072
|
+
path: line.slice(3),
|
|
1073
|
+
status,
|
|
1074
|
+
label: status === "??" ? "untracked" : status.includes("D") ? "deleted" : status.includes("A") ? "added" : "modified",
|
|
1075
|
+
};
|
|
1076
|
+
});
|
|
1077
|
+
sendJson(response, 200, { items });
|
|
1078
|
+
},
|
|
1079
|
+
});
|
|
1080
|
+
const disposeFileDiff = services.webServer.register({
|
|
1081
|
+
path: "/api/files/diff",
|
|
1082
|
+
async handler(request, response) {
|
|
1083
|
+
if (request.method !== "GET") {
|
|
1084
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
const url = new URL(request.url ?? "/api/files/diff", "http://localhost");
|
|
1088
|
+
const requested = url.searchParams.get("path");
|
|
1089
|
+
if (requested === null || requested.trim() === "") {
|
|
1090
|
+
sendJson(response, 400, { error: "path is required" });
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
const root = resolve(activeCwd(services));
|
|
1094
|
+
const absolute = resolve(root, requested);
|
|
1095
|
+
const relativePath = relative(root, absolute);
|
|
1096
|
+
if (isAbsolute(relativePath) || relativePath === ".." || relativePath.startsWith(".." + "/")) {
|
|
1097
|
+
sendJson(response, 400, { error: "path must stay inside the workspace" });
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
sendJson(response, 200, { path: relativePath, diff: await gitDiff(root, relativePath) });
|
|
1101
|
+
},
|
|
1102
|
+
});
|
|
1103
|
+
const disposeFileCommit = services.webServer.register({
|
|
1104
|
+
path: "/api/files/commit",
|
|
1105
|
+
async handler(request, response) {
|
|
1106
|
+
if (request.method !== "POST") {
|
|
1107
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
try {
|
|
1111
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1112
|
+
const paths = workspacePaths(resolve(activeCwd(services)), payload.paths);
|
|
1113
|
+
if (paths instanceof Error) {
|
|
1114
|
+
sendJson(response, 400, { error: paths.message });
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
if (typeof payload.message !== "string" || payload.message.trim() === "") {
|
|
1118
|
+
sendJson(response, 400, { error: "message is required" });
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
const root = resolve(activeCwd(services));
|
|
1122
|
+
const add = await gitCommand(root, ["add", "-A", "--", ...paths]);
|
|
1123
|
+
if (add.code !== 0) {
|
|
1124
|
+
sendJson(response, 409, { error: add.stderr.trim() || "Unable to stage workspace files" });
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
const commit = await gitCommand(root, ["commit", "-m", payload.message.trim(), "--", ...paths]);
|
|
1128
|
+
if (commit.code !== 0) {
|
|
1129
|
+
sendJson(response, 409, { error: commit.stdout.trim() || commit.stderr.trim() || "Nothing to commit" });
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
const head = await gitCommand(root, ["rev-parse", "--short", "HEAD"]);
|
|
1133
|
+
sendJson(response, 200, { committed: true, message: payload.message.trim(), commit: head.stdout.trim() });
|
|
1134
|
+
}
|
|
1135
|
+
catch (error) {
|
|
1136
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
});
|
|
1140
|
+
const disposeFileRevert = services.webServer.register({
|
|
1141
|
+
path: "/api/files/revert",
|
|
1142
|
+
async handler(request, response) {
|
|
1143
|
+
if (request.method !== "POST") {
|
|
1144
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
try {
|
|
1148
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1149
|
+
if (payload.confirm !== true) {
|
|
1150
|
+
sendJson(response, 400, { error: "confirm must be true to discard workspace changes" });
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
const root = resolve(activeCwd(services));
|
|
1154
|
+
const paths = workspacePaths(root, payload.paths);
|
|
1155
|
+
if (paths instanceof Error) {
|
|
1156
|
+
sendJson(response, 400, { error: paths.message });
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
const untracked = await gitCommand(root, ["ls-files", "--others", "--exclude-standard", "--", ...paths]);
|
|
1160
|
+
const restore = await gitCommand(root, ["restore", "--worktree", "--staged", "--", ...paths]);
|
|
1161
|
+
if (restore.code !== 0 && !restore.stderr.includes("pathspec")) {
|
|
1162
|
+
sendJson(response, 409, { error: restore.stderr.trim() || "Unable to restore workspace files" });
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
for (const path of untracked.stdout
|
|
1166
|
+
.split("\n")
|
|
1167
|
+
.map((item) => item.trim())
|
|
1168
|
+
.filter(Boolean)) {
|
|
1169
|
+
await rm(resolve(root, path), { recursive: true, force: true });
|
|
1170
|
+
}
|
|
1171
|
+
sendJson(response, 200, { reverted: true, paths });
|
|
1172
|
+
}
|
|
1173
|
+
catch (error) {
|
|
1174
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1175
|
+
}
|
|
1176
|
+
},
|
|
1177
|
+
});
|
|
1178
|
+
const disposeEvents = services.webServer.register({
|
|
1179
|
+
path: "/api/events",
|
|
1180
|
+
handler(_request, response) {
|
|
1181
|
+
response.writeHead(200, {
|
|
1182
|
+
"content-type": "text/event-stream; charset=utf-8",
|
|
1183
|
+
"cache-control": "no-cache, no-store",
|
|
1184
|
+
connection: "keep-alive",
|
|
1185
|
+
"x-accel-buffering": "no",
|
|
1186
|
+
});
|
|
1187
|
+
writeSse(response, { type: "snapshot", sessionId: services.runtime.session.sessionId, events });
|
|
1188
|
+
eventClients.add(response);
|
|
1189
|
+
const heartbeat = setInterval(() => {
|
|
1190
|
+
if (response.writableEnded || response.destroyed) {
|
|
1191
|
+
clearInterval(heartbeat);
|
|
1192
|
+
eventClients.delete(response);
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
response.write(": heartbeat\n\n");
|
|
1196
|
+
}, 15_000);
|
|
1197
|
+
response.on("close", () => {
|
|
1198
|
+
clearInterval(heartbeat);
|
|
1199
|
+
eventClients.delete(response);
|
|
1200
|
+
});
|
|
1201
|
+
},
|
|
1202
|
+
});
|
|
1203
|
+
const disposePrompt = services.webServer.register({
|
|
1204
|
+
path: "/api/prompt",
|
|
1205
|
+
async handler(request, response) {
|
|
1206
|
+
if (busy) {
|
|
1207
|
+
sendJson(response, 409, { error: "Another prompt is already running" });
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
busy = true;
|
|
1211
|
+
let unsubscribe;
|
|
1212
|
+
try {
|
|
1213
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1214
|
+
if (typeof payload.prompt !== "string" || payload.prompt.trim().length === 0) {
|
|
1215
|
+
sendJson(response, 400, { error: "Prompt must be a non-empty string" });
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
const chunks = [];
|
|
1219
|
+
unsubscribe = services.runtime.session.subscribe((event) => {
|
|
1220
|
+
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta")
|
|
1221
|
+
chunks.push(event.assistantMessageEvent.delta);
|
|
1222
|
+
});
|
|
1223
|
+
await services.runtime.prompt(payload.prompt);
|
|
1224
|
+
const last = services.runtime.session.messages.at(-1);
|
|
1225
|
+
if (last?.role === "assistant" && (last.stopReason === "error" || last.stopReason === "aborted")) {
|
|
1226
|
+
sendJson(response, 502, { error: last.errorMessage ?? "Request " + last.stopReason });
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
sendJson(response, 200, { reply: chunks.join(""), messages: services.runtime.session.messages.length });
|
|
1230
|
+
}
|
|
1231
|
+
catch (error) {
|
|
1232
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1233
|
+
}
|
|
1234
|
+
finally {
|
|
1235
|
+
unsubscribe?.();
|
|
1236
|
+
busy = false;
|
|
1237
|
+
}
|
|
1238
|
+
},
|
|
1239
|
+
});
|
|
1240
|
+
const disposeAbort = services.webServer.register({
|
|
1241
|
+
path: "/api/abort",
|
|
1242
|
+
async handler(request, response) {
|
|
1243
|
+
if (request.method !== "POST") {
|
|
1244
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
try {
|
|
1248
|
+
const wasStreaming = services.runtime.session.isStreaming;
|
|
1249
|
+
await services.runtime.abort();
|
|
1250
|
+
sendJson(response, 200, { aborted: wasStreaming });
|
|
1251
|
+
}
|
|
1252
|
+
catch (error) {
|
|
1253
|
+
sendJson(response, 500, { error: errorText(error) });
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
});
|
|
1257
|
+
const disposeSession = services.webServer.register({
|
|
1258
|
+
path: "/api/session",
|
|
1259
|
+
handler(_request, response) {
|
|
1260
|
+
const session = services.runtime.session;
|
|
1261
|
+
const sessionManager = session.sessionManager;
|
|
1262
|
+
sendJson(response, 200, jsonSafe({
|
|
1263
|
+
sessionId: session.sessionId,
|
|
1264
|
+
sessionFile: session.sessionFile,
|
|
1265
|
+
messages: session.messages,
|
|
1266
|
+
entries: typeof sessionManager?.getEntries === "function" ? sessionManager.getEntries() : [],
|
|
1267
|
+
events,
|
|
1268
|
+
}));
|
|
1269
|
+
},
|
|
1270
|
+
});
|
|
1271
|
+
const disposeNewSession = services.webServer.register({
|
|
1272
|
+
path: "/api/session/new",
|
|
1273
|
+
async handler(request, response) {
|
|
1274
|
+
if (request.method !== "POST") {
|
|
1275
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
if (services.runtime.session.isStreaming) {
|
|
1279
|
+
sendJson(response, 409, { error: "Cannot create a session while a prompt is running" });
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
try {
|
|
1283
|
+
const raw = await bodyText(request);
|
|
1284
|
+
const payload = raw.trim() ? JSON.parse(raw) : {};
|
|
1285
|
+
const currentCwd = activeCwd(services);
|
|
1286
|
+
const requestedCwd = typeof payload.cwd === "string" ? resolve(payload.cwd) : resolve(currentCwd);
|
|
1287
|
+
const workspaces = await listWorkspaces(currentCwd);
|
|
1288
|
+
const workspace = workspaces.find((item) => item.path === requestedCwd) ??
|
|
1289
|
+
(typeof payload.cwd === "string" && (await isDirectory(requestedCwd))
|
|
1290
|
+
? { path: requestedCwd, branch: "directory", current: false, name: basename(requestedCwd) || requestedCwd }
|
|
1291
|
+
: undefined);
|
|
1292
|
+
if (!workspace) {
|
|
1293
|
+
sendJson(response, 400, { error: "Workspace is not available" });
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
if (services.runtime.sessionRuntime) {
|
|
1297
|
+
let result;
|
|
1298
|
+
if (workspace.current) {
|
|
1299
|
+
result = await runWebSessionChange(services, () => services.runtime.sessionRuntime.newSession());
|
|
1300
|
+
}
|
|
1301
|
+
else {
|
|
1302
|
+
const manager = services.runtime.session.sessionManager;
|
|
1303
|
+
if (!manager || typeof manager.isPersisted !== "function" || !manager.isPersisted()) {
|
|
1304
|
+
sendJson(response, 409, { error: "Workspace switching requires JSONL session storage" });
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
const created = SessionManager.create(workspace.path, manager.getSessionDir());
|
|
1308
|
+
const sessionFile = created.newSession();
|
|
1309
|
+
if (!sessionFile)
|
|
1310
|
+
throw new Error("Unable to create a workspace session");
|
|
1311
|
+
result = await runWebSessionChange(services, () => services.runtime.sessionRuntime.switchSession(sessionFile, { cwdOverride: workspace.path }));
|
|
1312
|
+
}
|
|
1313
|
+
if (result.cancelled) {
|
|
1314
|
+
sendJson(response, 409, { error: "Session creation was cancelled by an extension" });
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
else {
|
|
1319
|
+
const session = services.runtime.session;
|
|
1320
|
+
session.sessionManager.newSession();
|
|
1321
|
+
session.agent.state.messages = [];
|
|
1322
|
+
}
|
|
1323
|
+
events.length = 0;
|
|
1324
|
+
const session = services.runtime.session;
|
|
1325
|
+
for (const client of eventClients)
|
|
1326
|
+
writeSse(client, { type: "session", sessionId: session.sessionId, events: [] });
|
|
1327
|
+
sendJson(response, 200, jsonSafe({
|
|
1328
|
+
sessionId: session.sessionId,
|
|
1329
|
+
sessionFile: session.sessionFile,
|
|
1330
|
+
messages: services.runtime.sessionRuntime ? session.messages : [],
|
|
1331
|
+
events: [],
|
|
1332
|
+
}));
|
|
1333
|
+
}
|
|
1334
|
+
catch (error) {
|
|
1335
|
+
sendJson(response, 500, { error: errorText(error) });
|
|
1336
|
+
}
|
|
1337
|
+
},
|
|
1338
|
+
});
|
|
1339
|
+
const disposeOpenSession = services.webServer.register({
|
|
1340
|
+
path: "/api/session/open",
|
|
1341
|
+
async handler(request, response) {
|
|
1342
|
+
if (request.method !== "POST") {
|
|
1343
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
if (services.runtime.session.isStreaming) {
|
|
1347
|
+
sendJson(response, 409, { error: "Cannot switch sessions while a prompt is running" });
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
try {
|
|
1351
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1352
|
+
const manager = services.runtime.session.sessionManager;
|
|
1353
|
+
if (!manager.isPersisted()) {
|
|
1354
|
+
sendJson(response, 409, { error: "Session switching requires JSONL session storage" });
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
const items = await SessionManager.list(services.launch.cwd, manager.getSessionDir());
|
|
1358
|
+
const target = items.find((item) => (typeof payload.path === "string" && item.path === payload.path) || (typeof payload.sessionId === "string" && item.id === payload.sessionId));
|
|
1359
|
+
if (target === undefined) {
|
|
1360
|
+
sendJson(response, 404, { error: "Session not found" });
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
if (services.runtime.sessionRuntime) {
|
|
1364
|
+
const result = await runWebSessionChange(services, () => services.runtime.sessionRuntime.switchSession(target.path, { cwdOverride: target.cwd }));
|
|
1365
|
+
if (result.cancelled) {
|
|
1366
|
+
sendJson(response, 409, { error: "Session switch was cancelled by an extension" });
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
else {
|
|
1371
|
+
manager.setSessionFile(target.path);
|
|
1372
|
+
if (typeof services.runtime.session.reload === "function")
|
|
1373
|
+
await services.runtime.session.reload();
|
|
1374
|
+
else
|
|
1375
|
+
services.runtime.session.agent.state.messages = manager.buildSessionContext().messages;
|
|
1376
|
+
}
|
|
1377
|
+
events.length = 0;
|
|
1378
|
+
for (const client of eventClients)
|
|
1379
|
+
writeSse(client, { type: "session", sessionId: services.runtime.session.sessionId, events: [] });
|
|
1380
|
+
sendJson(response, 200, jsonSafe({
|
|
1381
|
+
sessionId: services.runtime.session.sessionId,
|
|
1382
|
+
sessionFile: services.runtime.session.sessionFile,
|
|
1383
|
+
messages: services.runtime.session.messages,
|
|
1384
|
+
events: [],
|
|
1385
|
+
}));
|
|
1386
|
+
}
|
|
1387
|
+
catch (error) {
|
|
1388
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
});
|
|
1392
|
+
const disposeRenameSession = services.webServer.register({
|
|
1393
|
+
path: "/api/session/rename",
|
|
1394
|
+
async handler(request, response) {
|
|
1395
|
+
if (request.method !== "POST") {
|
|
1396
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
try {
|
|
1400
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1401
|
+
const manager = services.runtime.session.sessionManager;
|
|
1402
|
+
const path = typeof payload.path === "string" ? payload.path : services.runtime.session.sessionFile;
|
|
1403
|
+
const name = typeof payload.name === "string" ? payload.name.trim() : "";
|
|
1404
|
+
if (!path || !sessionPathInDirectory(path, manager)) {
|
|
1405
|
+
sendJson(response, 400, { error: "Invalid session path" });
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
if (name.length > 120) {
|
|
1409
|
+
sendJson(response, 400, { error: "Session name must be at most 120 characters" });
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
SessionManager.open(path, manager.getSessionDir()).appendSessionInfo(name);
|
|
1413
|
+
sendJson(response, 200, { path, name: name || undefined });
|
|
1414
|
+
}
|
|
1415
|
+
catch (error) {
|
|
1416
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1419
|
+
});
|
|
1420
|
+
const disposeDeleteSession = services.webServer.register({
|
|
1421
|
+
path: "/api/session/delete",
|
|
1422
|
+
async handler(request, response) {
|
|
1423
|
+
if (request.method !== "POST") {
|
|
1424
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
try {
|
|
1428
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1429
|
+
const manager = services.runtime.session.sessionManager;
|
|
1430
|
+
const path = typeof payload.path === "string" ? payload.path : "";
|
|
1431
|
+
if (payload.confirm !== true) {
|
|
1432
|
+
sendJson(response, 400, { error: "confirm must be true to delete a session" });
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
if (!sessionPathInDirectory(path, manager)) {
|
|
1436
|
+
sendJson(response, 400, { error: "Invalid session path" });
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
if (path === services.runtime.session.sessionFile) {
|
|
1440
|
+
if (services.runtime.session.isStreaming) {
|
|
1441
|
+
sendJson(response, 409, { error: "Cannot delete the active session while a prompt is running" });
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
const result = await runWebSessionChange(services, () => services.runtime.sessionRuntime.newSession());
|
|
1445
|
+
if (result.cancelled) {
|
|
1446
|
+
sendJson(response, 409, { error: "Session deletion was cancelled by an extension" });
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
events.length = 0;
|
|
1450
|
+
}
|
|
1451
|
+
await unlink(path);
|
|
1452
|
+
const metadata = await readSessionMetadata(manager);
|
|
1453
|
+
delete metadata[path];
|
|
1454
|
+
await writeSessionMetadata(manager, metadata);
|
|
1455
|
+
sendJson(response, 200, { deleted: true, path, sessionFile: services.runtime.session.sessionFile });
|
|
1456
|
+
}
|
|
1457
|
+
catch (error) {
|
|
1458
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1459
|
+
}
|
|
1460
|
+
},
|
|
1461
|
+
});
|
|
1462
|
+
const disposeSessionMetadata = services.webServer.register({
|
|
1463
|
+
path: "/api/session/metadata",
|
|
1464
|
+
async handler(request, response) {
|
|
1465
|
+
if (request.method !== "POST") {
|
|
1466
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
try {
|
|
1470
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1471
|
+
const manager = services.runtime.session.sessionManager;
|
|
1472
|
+
const path = typeof payload.path === "string" ? payload.path : "";
|
|
1473
|
+
if (!sessionPathInDirectory(path, manager)) {
|
|
1474
|
+
sendJson(response, 400, { error: "Invalid session path" });
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const metadata = await readSessionMetadata(manager);
|
|
1478
|
+
const currentMetadata = metadata[path] ?? {};
|
|
1479
|
+
const nextMetadata = {
|
|
1480
|
+
...currentMetadata,
|
|
1481
|
+
...(payload.archived === undefined ? {} : { archived: payload.archived === true }),
|
|
1482
|
+
...(payload.pinned === undefined ? {} : { pinned: payload.pinned === true }),
|
|
1483
|
+
};
|
|
1484
|
+
metadata[path] = nextMetadata;
|
|
1485
|
+
await writeSessionMetadata(manager, metadata);
|
|
1486
|
+
sendJson(response, 200, { path, metadata: metadata[path] });
|
|
1487
|
+
}
|
|
1488
|
+
catch (error) {
|
|
1489
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1490
|
+
}
|
|
1491
|
+
},
|
|
1492
|
+
});
|
|
1493
|
+
const disposeBatchSessions = services.webServer.register({
|
|
1494
|
+
path: "/api/sessions/batch",
|
|
1495
|
+
async handler(request, response) {
|
|
1496
|
+
if (request.method !== "POST") {
|
|
1497
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
try {
|
|
1501
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1502
|
+
const action = payload.action;
|
|
1503
|
+
const paths = Array.isArray(payload.paths) ? payload.paths.filter((path) => typeof path === "string") : [];
|
|
1504
|
+
const manager = services.runtime.session.sessionManager;
|
|
1505
|
+
if ((action !== "delete" && action !== "archive" && action !== "unarchive" && action !== "pin" && action !== "unpin") ||
|
|
1506
|
+
paths.length === 0 ||
|
|
1507
|
+
paths.length > 100) {
|
|
1508
|
+
sendJson(response, 400, { error: "action and 1-100 session paths are required" });
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
if (action === "delete" && payload.confirm !== true) {
|
|
1512
|
+
sendJson(response, 400, { error: "confirm must be true to delete sessions" });
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
if (paths.some((path) => !sessionPathInDirectory(path, manager))) {
|
|
1516
|
+
sendJson(response, 400, { error: "Invalid session path" });
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
if (action === "delete" && paths.includes(services.runtime.session.sessionFile ?? "")) {
|
|
1520
|
+
sendJson(response, 409, { error: "Cannot batch-delete the active session" });
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
const metadata = await readSessionMetadata(manager);
|
|
1524
|
+
for (const path of paths) {
|
|
1525
|
+
if (action === "delete") {
|
|
1526
|
+
await unlink(path);
|
|
1527
|
+
delete metadata[path];
|
|
1528
|
+
}
|
|
1529
|
+
else {
|
|
1530
|
+
const current = metadata[path] ?? {};
|
|
1531
|
+
metadata[path] = {
|
|
1532
|
+
...current,
|
|
1533
|
+
...(action === "archive" || action === "unarchive" ? { archived: action === "archive" } : {}),
|
|
1534
|
+
...(action === "pin" || action === "unpin" ? { pinned: action === "pin" } : {}),
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
await writeSessionMetadata(manager, metadata);
|
|
1539
|
+
sendJson(response, 200, { action, count: paths.length });
|
|
1540
|
+
}
|
|
1541
|
+
catch (error) {
|
|
1542
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1545
|
+
});
|
|
1546
|
+
const disposeForkSession = services.webServer.register({
|
|
1547
|
+
path: "/api/session/fork",
|
|
1548
|
+
async handler(request, response) {
|
|
1549
|
+
if (request.method !== "POST") {
|
|
1550
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
try {
|
|
1554
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1555
|
+
const manager = services.runtime.session.sessionManager;
|
|
1556
|
+
const sourcePath = typeof payload.path === "string" ? payload.path : "";
|
|
1557
|
+
if (!sessionPathInDirectory(sourcePath, manager)) {
|
|
1558
|
+
sendJson(response, 400, { error: "Invalid session path" });
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
const sessions = await SessionManager.list(services.launch.cwd, manager.getSessionDir());
|
|
1562
|
+
const source = sessions.find((item) => item.path === sourcePath);
|
|
1563
|
+
if (!source) {
|
|
1564
|
+
sendJson(response, 404, { error: "Session not found" });
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
const targetCwd = typeof payload.cwd === "string" && payload.cwd.trim() ? resolve(payload.cwd) : source.cwd || activeCwd(services);
|
|
1568
|
+
const forked = SessionManager.forkFrom(source.path, targetCwd, manager.getSessionDir());
|
|
1569
|
+
sendJson(response, 200, { sessionId: forked.getSessionId(), sessionFile: forked.getSessionFile(), cwd: targetCwd });
|
|
1570
|
+
}
|
|
1571
|
+
catch (error) {
|
|
1572
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1575
|
+
});
|
|
1576
|
+
const disposeImportSession = services.webServer.register({
|
|
1577
|
+
path: "/api/session/import",
|
|
1578
|
+
async handler(request, response) {
|
|
1579
|
+
if (request.method !== "POST") {
|
|
1580
|
+
sendJson(response, 405, { error: "Method not allowed" });
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
if (services.runtime.session.isStreaming) {
|
|
1584
|
+
sendJson(response, 409, { error: "Cannot import a session while a prompt is running" });
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1587
|
+
try {
|
|
1588
|
+
const payload = JSON.parse(await bodyText(request));
|
|
1589
|
+
const suppliedPath = typeof payload.path === "string" ? payload.path : "";
|
|
1590
|
+
const content = typeof payload.content === "string" ? payload.content : undefined;
|
|
1591
|
+
if ((!suppliedPath || !isAbsolute(suppliedPath)) && content === undefined) {
|
|
1592
|
+
sendJson(response, 400, { error: "A JSONL file path or file content is required" });
|
|
1593
|
+
return;
|
|
1594
|
+
}
|
|
1595
|
+
const manager = services.runtime.session.sessionManager;
|
|
1596
|
+
if (!manager.isPersisted()) {
|
|
1597
|
+
sendJson(response, 409, { error: "Session importing requires JSONL session storage" });
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
const targetCwd = typeof payload.cwd === "string" && payload.cwd.trim() ? resolve(payload.cwd) : activeCwd(services);
|
|
1601
|
+
const temporaryDirectory = content === undefined ? undefined : await mkdtemp(join(tmpdir(), "pi-harness-import-"));
|
|
1602
|
+
const importPath = suppliedPath ||
|
|
1603
|
+
join(temporaryDirectory, basename(typeof payload.filename === "string" && payload.filename.trim() ? payload.filename : "import.jsonl"));
|
|
1604
|
+
try {
|
|
1605
|
+
if (content !== undefined) {
|
|
1606
|
+
if (Buffer.byteLength(content, "utf8") > 10 * 1024 * 1024) {
|
|
1607
|
+
sendJson(response, 413, { error: "Imported session must be at most 10 MiB" });
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
await writeFile(importPath, content, "utf8");
|
|
1611
|
+
}
|
|
1612
|
+
const imported = SessionManager.forkFrom(importPath, targetCwd, manager.getSessionDir());
|
|
1613
|
+
const importedPath = imported.getSessionFile();
|
|
1614
|
+
if (!importedPath)
|
|
1615
|
+
throw new Error("Unable to persist imported session");
|
|
1616
|
+
const result = await runWebSessionChange(services, () => services.runtime.sessionRuntime.switchSession(importedPath, { cwdOverride: targetCwd }));
|
|
1617
|
+
if (result.cancelled) {
|
|
1618
|
+
sendJson(response, 409, { error: "Session import was cancelled by an extension" });
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
events.length = 0;
|
|
1622
|
+
sendJson(response, 200, {
|
|
1623
|
+
sessionId: services.runtime.session.sessionId,
|
|
1624
|
+
sessionFile: services.runtime.session.sessionFile,
|
|
1625
|
+
messages: services.runtime.session.messages.length,
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
finally {
|
|
1629
|
+
if (temporaryDirectory)
|
|
1630
|
+
await rm(temporaryDirectory, { recursive: true, force: true });
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
catch (error) {
|
|
1634
|
+
sendJson(response, 400, { error: errorText(error) });
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
});
|
|
1638
|
+
const disposeExportSession = services.webServer.register({
|
|
1639
|
+
path: "/api/session/export",
|
|
1640
|
+
async handler(request, response) {
|
|
1641
|
+
try {
|
|
1642
|
+
const url = new URL(request.url ?? "/api/session/export", "http://localhost");
|
|
1643
|
+
const manager = services.runtime.session.sessionManager;
|
|
1644
|
+
const path = url.searchParams.get("path") ?? services.runtime.session.sessionFile;
|
|
1645
|
+
if (!path || !sessionPathInDirectory(path, manager)) {
|
|
1646
|
+
sendJson(response, 400, { error: "Invalid session path" });
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
const content = await readFile(path, "utf8");
|
|
1650
|
+
response.writeHead(200, {
|
|
1651
|
+
"content-type": "application/x-ndjson; charset=utf-8",
|
|
1652
|
+
"content-disposition": `attachment; filename="${basename(path)}"`,
|
|
1653
|
+
"cache-control": "no-store",
|
|
1654
|
+
});
|
|
1655
|
+
response.end(content);
|
|
1656
|
+
}
|
|
1657
|
+
catch (error) {
|
|
1658
|
+
sendJson(response, 404, { error: errorText(error) });
|
|
1659
|
+
}
|
|
1660
|
+
},
|
|
1661
|
+
});
|
|
1662
|
+
const disposeSessions = services.webServer.register({
|
|
1663
|
+
path: "/api/sessions",
|
|
1664
|
+
async handler(_request, response) {
|
|
1665
|
+
try {
|
|
1666
|
+
const session = services.runtime.session;
|
|
1667
|
+
const manager = session.sessionManager;
|
|
1668
|
+
const url = new URL(_request.url ?? "/api/sessions", "http://localhost");
|
|
1669
|
+
const page = Math.max(0, Number.parseInt(url.searchParams.get("page") ?? "0", 10) || 0);
|
|
1670
|
+
const pageSize = Math.min(100, Math.max(1, Number.parseInt(url.searchParams.get("pageSize") ?? "50", 10) || 50));
|
|
1671
|
+
const includeArchived = url.searchParams.get("includeArchived") === "true";
|
|
1672
|
+
const metadata = await readSessionMetadata(manager);
|
|
1673
|
+
const items = typeof manager.isPersisted === "function" && manager.isPersisted() ? await SessionManager.list(services.launch.cwd, manager.getSessionDir()) : [];
|
|
1674
|
+
const filtered = items.filter((item) => includeArchived || metadata[item.path]?.archived !== true);
|
|
1675
|
+
const sorted = filtered.sort((a, b) => Number(metadata[b.path]?.pinned === true) - Number(metadata[a.path]?.pinned === true) || b.modified.getTime() - a.modified.getTime());
|
|
1676
|
+
const paged = sorted.slice(page * pageSize, (page + 1) * pageSize);
|
|
1677
|
+
sendJson(response, 200, jsonSafe({
|
|
1678
|
+
items: paged.map((item) => ({
|
|
1679
|
+
sessionId: item.id,
|
|
1680
|
+
path: item.path,
|
|
1681
|
+
name: item.name,
|
|
1682
|
+
cwd: item.cwd,
|
|
1683
|
+
created: item.created,
|
|
1684
|
+
modified: item.modified,
|
|
1685
|
+
messageCount: item.messageCount,
|
|
1686
|
+
firstMessage: item.firstMessage,
|
|
1687
|
+
archived: metadata[item.path]?.archived === true,
|
|
1688
|
+
pinned: metadata[item.path]?.pinned === true,
|
|
1689
|
+
})),
|
|
1690
|
+
total: sorted.length,
|
|
1691
|
+
page,
|
|
1692
|
+
pageSize,
|
|
1693
|
+
hasNext: (page + 1) * pageSize < sorted.length,
|
|
1694
|
+
}));
|
|
1695
|
+
}
|
|
1696
|
+
catch (error) {
|
|
1697
|
+
sendJson(response, 500, { error: errorText(error) });
|
|
1698
|
+
}
|
|
1699
|
+
},
|
|
1700
|
+
});
|
|
1701
|
+
context.effect(() => () => {
|
|
1702
|
+
disposeStatus();
|
|
1703
|
+
disposeConfig();
|
|
1704
|
+
disposeConfigReload();
|
|
1705
|
+
disposeConfigSource();
|
|
1706
|
+
disposeEvents();
|
|
1707
|
+
disposeModels();
|
|
1708
|
+
disposeProviders();
|
|
1709
|
+
disposeProviderTest();
|
|
1710
|
+
disposeProviderRefresh();
|
|
1711
|
+
disposeProviderAdd();
|
|
1712
|
+
disposePlugins();
|
|
1713
|
+
disposePluginUi();
|
|
1714
|
+
disposePluginPanels();
|
|
1715
|
+
disposeMarketplace();
|
|
1716
|
+
disposeMarketplaceInstall();
|
|
1717
|
+
disposePluginToggle();
|
|
1718
|
+
disposePluginUninstall();
|
|
1719
|
+
disposeCommands();
|
|
1720
|
+
disposeModel();
|
|
1721
|
+
disposeWorkspaces();
|
|
1722
|
+
disposePickDirectory();
|
|
1723
|
+
disposeFiles();
|
|
1724
|
+
disposeFileDiff();
|
|
1725
|
+
disposeFileCommit();
|
|
1726
|
+
disposeFileRevert();
|
|
1727
|
+
disposePrompt();
|
|
1728
|
+
disposeAbort();
|
|
1729
|
+
disposeSession();
|
|
1730
|
+
disposeNewSession();
|
|
1731
|
+
disposeOpenSession();
|
|
1732
|
+
disposeRenameSession();
|
|
1733
|
+
disposeDeleteSession();
|
|
1734
|
+
disposeSessionMetadata();
|
|
1735
|
+
disposeBatchSessions();
|
|
1736
|
+
disposeForkSession();
|
|
1737
|
+
disposeImportSession();
|
|
1738
|
+
disposeExportSession();
|
|
1739
|
+
disposeSessions();
|
|
1740
|
+
unsubscribeEvents();
|
|
1741
|
+
for (const response of eventClients)
|
|
1742
|
+
response.end();
|
|
1743
|
+
eventClients.clear();
|
|
1744
|
+
});
|
|
1745
|
+
},
|
|
1746
|
+
};
|
|
1747
|
+
//# sourceMappingURL=index.js.map
|