@prestyj/cli 5.4.1 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -12
- package/assets/end-notification.mp3 +0 -0
- package/assets/skills/evidence-led-ui/LICENSES.md +68 -0
- package/assets/skills/evidence-led-ui/SKILL.md +139 -0
- package/{LICENSE → assets/skills/evidence-led-ui/corpus/awesome-design-md/LICENSE} +1 -1
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/airbnb/DESIGN.md +545 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/airtable/DESIGN.md +554 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/apple/DESIGN.md +562 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/binance/DESIGN.md +634 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/bmw/DESIGN.md +544 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/bmw-m/DESIGN.md +503 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/bugatti/DESIGN.md +454 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/cal/DESIGN.md +542 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/claude/DESIGN.md +589 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/clay/DESIGN.md +541 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/clickhouse/DESIGN.md +544 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/cohere/DESIGN.md +451 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/coinbase/DESIGN.md +570 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/composio/DESIGN.md +506 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/cursor/DESIGN.md +537 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/dell-1996/DESIGN.md +632 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/elevenlabs/DESIGN.md +504 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/expo/DESIGN.md +526 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/ferrari/DESIGN.md +531 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/figma/DESIGN.md +578 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/framer/DESIGN.md +544 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/hashicorp/DESIGN.md +575 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/hp/DESIGN.md +670 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/ibm/DESIGN.md +550 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/intercom/DESIGN.md +546 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/kraken/DESIGN.md +125 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/lamborghini/DESIGN.md +288 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/linear.app/DESIGN.md +548 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/lovable/DESIGN.md +298 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mastercard/DESIGN.md +365 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/meta/DESIGN.md +683 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/minimax/DESIGN.md +746 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mintlify/DESIGN.md +852 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/miro/DESIGN.md +825 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mistral.ai/DESIGN.md +773 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mongodb/DESIGN.md +767 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/nike/DESIGN.md +575 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/nintendo-2001/DESIGN.md +649 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/notion/DESIGN.md +821 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/nvidia/DESIGN.md +640 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/ollama/DESIGN.md +539 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/opencode.ai/DESIGN.md +521 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/pinterest/DESIGN.md +597 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/playstation/DESIGN.md +661 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/posthog/DESIGN.md +690 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/raycast/DESIGN.md +669 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/renault/DESIGN.md +589 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/replicate/DESIGN.md +616 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/resend/DESIGN.md +585 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/revolut/DESIGN.md +636 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/runwayml/DESIGN.md +244 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/sanity/DESIGN.md +357 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/sentry/DESIGN.md +551 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/shopify/DESIGN.md +516 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/slack/DESIGN.md +482 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/spacex/DESIGN.md +363 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/spotify/DESIGN.md +246 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/starbucks/DESIGN.md +580 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/stripe/DESIGN.md +487 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/supabase/DESIGN.md +462 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/superhuman/DESIGN.md +448 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/tesla/DESIGN.md +286 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/theverge/DESIGN.md +339 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/together.ai/DESIGN.md +633 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/uber/DESIGN.md +636 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/vercel/DESIGN.md +736 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/vodafone/DESIGN.md +538 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/voltagent/DESIGN.md +521 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/warp/DESIGN.md +526 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/webflow/DESIGN.md +588 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/wired/DESIGN.md +497 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/wise/DESIGN.md +544 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/x.ai/DESIGN.md +465 -0
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/zapier/DESIGN.md +537 -0
- package/assets/skills/evidence-led-ui/data/corpus-manifest.json +768 -0
- package/assets/skills/evidence-led-ui/data/observations.json +47053 -0
- package/assets/skills/evidence-led-ui/references/anti-defaults.md +203 -0
- package/assets/skills/evidence-led-ui/references/archetypes.md +97 -0
- package/assets/skills/evidence-led-ui/references/craft-rulings.md +167 -0
- package/assets/skills/evidence-led-ui/references/methodology.md +72 -0
- package/assets/skills/evidence-led-ui/references/observed-patterns.md +68 -0
- package/assets/skills/evidence-led-ui/references/production-contract.md +120 -0
- package/assets/skills/evidence-led-ui/references/provenance.md +117 -0
- package/assets/skills/evidence-led-ui/references/quality-rubric.md +126 -0
- package/dist/app-sidecar.js +272 -74
- package/dist/app-sidecar.js.map +1 -1
- package/dist/chat-agents/general.d.ts +7 -0
- package/dist/chat-agents/general.d.ts.map +1 -0
- package/dist/chat-agents/general.js +16 -0
- package/dist/chat-agents/general.js.map +1 -0
- package/dist/chat-agents/general.test.d.ts +2 -0
- package/dist/chat-agents/general.test.d.ts.map +1 -0
- package/dist/chat-agents/general.test.js +50 -0
- package/dist/chat-agents/general.test.js.map +1 -0
- package/dist/chat-agents/index.d.ts +11 -0
- package/dist/chat-agents/index.d.ts.map +1 -0
- package/dist/chat-agents/index.js +89 -0
- package/dist/chat-agents/index.js.map +1 -0
- package/dist/chat-agents/jiwa.d.ts +53 -0
- package/dist/chat-agents/jiwa.d.ts.map +1 -0
- package/dist/chat-agents/jiwa.js +352 -0
- package/dist/chat-agents/jiwa.js.map +1 -0
- package/dist/chat-agents/jiwa.test.d.ts +2 -0
- package/dist/chat-agents/jiwa.test.d.ts.map +1 -0
- package/dist/chat-agents/jiwa.test.js +66 -0
- package/dist/chat-agents/jiwa.test.js.map +1 -0
- package/dist/chat-agents/memory.d.ts +53 -0
- package/dist/chat-agents/memory.d.ts.map +1 -0
- package/dist/chat-agents/memory.js +362 -0
- package/dist/chat-agents/memory.js.map +1 -0
- package/dist/chat-agents/memory.test.d.ts +2 -0
- package/dist/chat-agents/memory.test.d.ts.map +1 -0
- package/dist/chat-agents/memory.test.js +155 -0
- package/dist/chat-agents/memory.test.js.map +1 -0
- package/dist/chat-agents/research.d.ts +7 -0
- package/dist/chat-agents/research.d.ts.map +1 -0
- package/dist/chat-agents/research.js +18 -0
- package/dist/chat-agents/research.js.map +1 -0
- package/dist/chat-agents/shared.d.ts +11 -0
- package/dist/chat-agents/shared.d.ts.map +1 -0
- package/dist/chat-agents/shared.js +52 -0
- package/dist/chat-agents/shared.js.map +1 -0
- package/dist/chat-agents/specialists.test.d.ts +2 -0
- package/dist/chat-agents/specialists.test.d.ts.map +1 -0
- package/dist/chat-agents/specialists.test.js +97 -0
- package/dist/chat-agents/specialists.test.js.map +1 -0
- package/dist/chat-agents/therapist.d.ts +7 -0
- package/dist/chat-agents/therapist.d.ts.map +1 -0
- package/dist/chat-agents/therapist.js +20 -0
- package/dist/chat-agents/therapist.js.map +1 -0
- package/dist/chat-agents/types.d.ts +4 -0
- package/dist/chat-agents/types.d.ts.map +1 -0
- package/dist/chat-agents/types.js +7 -0
- package/dist/chat-agents/types.js.map +1 -0
- package/dist/cli/auth.js +1 -1
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +72 -22
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-memory-tail.test.d.ts +2 -0
- package/dist/core/agent-session-memory-tail.test.d.ts.map +1 -0
- package/dist/core/agent-session-memory-tail.test.js +122 -0
- package/dist/core/agent-session-memory-tail.test.js.map +1 -0
- package/dist/core/agent-session-subagent-policy.test.d.ts +2 -0
- package/dist/core/agent-session-subagent-policy.test.d.ts.map +1 -0
- package/dist/core/agent-session-subagent-policy.test.js +36 -0
- package/dist/core/agent-session-subagent-policy.test.js.map +1 -0
- package/dist/core/agent-session.d.ts +39 -11
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +178 -125
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agents.d.ts +1 -1
- package/dist/core/agents.d.ts.map +1 -1
- package/dist/core/agents.js +4 -2
- package/dist/core/agents.js.map +1 -1
- package/dist/core/auth-providers.js +5 -5
- package/dist/core/auth-providers.js.map +1 -1
- package/dist/core/compaction/compactor.d.ts +7 -0
- package/dist/core/compaction/compactor.d.ts.map +1 -1
- package/dist/core/compaction/compactor.js +73 -9
- package/dist/core/compaction/compactor.js.map +1 -1
- package/dist/core/compaction/compactor.test.js +31 -4
- package/dist/core/compaction/compactor.test.js.map +1 -1
- package/dist/core/event-bus.d.ts +2 -0
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/goal-worker.test.js +3 -2
- package/dist/core/goal-worker.test.js.map +1 -1
- package/dist/core/loop-breaker.d.ts +23 -16
- package/dist/core/loop-breaker.d.ts.map +1 -1
- package/dist/core/loop-breaker.js +52 -11
- package/dist/core/loop-breaker.js.map +1 -1
- package/dist/core/loop-breaker.test.js +37 -16
- package/dist/core/loop-breaker.test.js.map +1 -1
- package/dist/core/mcp/defaults.d.ts +1 -1
- package/dist/core/mcp/defaults.js +1 -1
- package/dist/core/mcp/store.d.ts +2 -2
- package/dist/core/mcp/store.test.js +1 -1
- package/dist/core/mcp/store.test.js.map +1 -1
- package/dist/core/nolan-prompt.d.ts +3 -3
- package/dist/core/nolan-prompt.d.ts.map +1 -1
- package/dist/core/nolan-prompt.js +10 -10
- package/dist/core/nolan-prompt.js.map +1 -1
- package/dist/core/nolan-prompt.test.js +17 -0
- package/dist/core/nolan-prompt.test.js.map +1 -1
- package/dist/core/progress/rebuild.d.ts +3 -3
- package/dist/core/progress/rebuild.d.ts.map +1 -1
- package/dist/core/progress/rebuild.js +33 -27
- package/dist/core/progress/rebuild.js.map +1 -1
- package/dist/core/progress/rebuild.test.js +15 -0
- package/dist/core/progress/rebuild.test.js.map +1 -1
- package/dist/core/project-discovery.d.ts +1 -1
- package/dist/core/project-discovery.d.ts.map +1 -1
- package/dist/core/project-discovery.js +5 -6
- package/dist/core/project-discovery.js.map +1 -1
- package/dist/core/project-discovery.test.js +14 -1
- package/dist/core/project-discovery.test.js.map +1 -1
- package/dist/core/radio.d.ts +3 -0
- package/dist/core/radio.d.ts.map +1 -1
- package/dist/core/radio.js +150 -21
- package/dist/core/radio.js.map +1 -1
- package/dist/core/radio.test.d.ts +2 -0
- package/dist/core/radio.test.d.ts.map +1 -0
- package/dist/core/radio.test.js +101 -0
- package/dist/core/radio.test.js.map +1 -0
- package/dist/core/session-history.test.js +1 -1
- package/dist/core/session-history.test.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-manager.test.js +18 -0
- package/dist/core/session-manager.test.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills-routing.test.d.ts +2 -0
- package/dist/core/skills-routing.test.d.ts.map +1 -0
- package/dist/core/skills-routing.test.js +70 -0
- package/dist/core/skills-routing.test.js.map +1 -0
- package/dist/core/skills.d.ts +2 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +32 -9
- package/dist/core/skills.js.map +1 -1
- package/dist/core/subagent-manager.d.ts +73 -0
- package/dist/core/subagent-manager.d.ts.map +1 -0
- package/dist/core/subagent-manager.js +412 -0
- package/dist/core/subagent-manager.js.map +1 -0
- package/dist/core/subagent-manager.test.d.ts +2 -0
- package/dist/core/subagent-manager.test.d.ts.map +1 -0
- package/dist/core/subagent-manager.test.js +103 -0
- package/dist/core/subagent-manager.test.js.map +1 -0
- package/dist/core/subagent-policy.d.ts +4 -0
- package/dist/core/subagent-policy.d.ts.map +1 -0
- package/dist/core/subagent-policy.js +19 -0
- package/dist/core/subagent-policy.js.map +1 -0
- package/dist/modes/json-mode.d.ts.map +1 -1
- package/dist/modes/json-mode.js +3 -4
- package/dist/modes/json-mode.js.map +1 -1
- package/dist/modes/subagent-worker-mode.d.ts +14 -0
- package/dist/modes/subagent-worker-mode.d.ts.map +1 -0
- package/dist/modes/subagent-worker-mode.js +191 -0
- package/dist/modes/subagent-worker-mode.js.map +1 -0
- package/dist/system-prompt.js +2 -2
- package/dist/system-prompt.js.map +1 -1
- package/dist/system-prompt.test.js +7 -5
- package/dist/system-prompt.test.js.map +1 -1
- package/dist/tools/generate-image.d.ts.map +1 -1
- package/dist/tools/generate-image.js +12 -5
- package/dist/tools/generate-image.js.map +1 -1
- package/dist/tools/generate-image.test.js +17 -0
- package/dist/tools/generate-image.test.js.map +1 -1
- package/dist/tools/goals.d.ts +3 -3
- package/dist/tools/index.d.ts +10 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/skill.d.ts.map +1 -1
- package/dist/tools/skill.js +8 -3
- package/dist/tools/skill.js.map +1 -1
- package/dist/tools/subagent-control.d.ts +6 -0
- package/dist/tools/subagent-control.d.ts.map +1 -0
- package/dist/tools/subagent-control.js +95 -0
- package/dist/tools/subagent-control.js.map +1 -0
- package/dist/tools/subagent-control.test.d.ts +2 -0
- package/dist/tools/subagent-control.test.d.ts.map +1 -0
- package/dist/tools/subagent-control.test.js +40 -0
- package/dist/tools/subagent-control.test.js.map +1 -0
- package/dist/tools/subagent-shared.d.ts +24 -0
- package/dist/tools/subagent-shared.d.ts.map +1 -0
- package/dist/tools/subagent-shared.js +53 -0
- package/dist/tools/subagent-shared.js.map +1 -0
- package/dist/tools/subagent-shared.test.d.ts +2 -0
- package/dist/tools/subagent-shared.test.d.ts.map +1 -0
- package/dist/tools/subagent-shared.test.js +29 -0
- package/dist/tools/subagent-shared.test.js.map +1 -0
- package/dist/tools/subagent.d.ts.map +1 -1
- package/dist/tools/subagent.js +21 -64
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/subagent.test.js +27 -1
- package/dist/tools/subagent.test.js.map +1 -1
- package/dist/tools/web-fetch.d.ts +1 -0
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +112 -35
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-fetch.test.js +146 -1
- package/dist/tools/web-fetch.test.js.map +1 -1
- package/dist/tools/web-search.d.ts +10 -0
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +236 -28
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools/web-search.test.js +77 -6
- package/dist/tools/web-search.test.js.map +1 -1
- package/dist/ui/App.d.ts +2 -0
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +61 -2
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/components/SkillsOverlay.d.ts.map +1 -1
- package/dist/ui/components/SkillsOverlay.js +8 -3
- package/dist/ui/components/SkillsOverlay.js.map +1 -1
- package/dist/ui/hooks/useAgentLoop.d.ts.map +1 -1
- package/dist/ui/hooks/useAgentLoop.js +7 -18
- package/dist/ui/hooks/useAgentLoop.js.map +1 -1
- package/dist/ui/hooks/useAgentLoop.test.js +27 -0
- package/dist/ui/hooks/useAgentLoop.test.js.map +1 -1
- package/dist/ui/hooks/useModeState.d.ts +4 -2
- package/dist/ui/hooks/useModeState.d.ts.map +1 -1
- package/dist/ui/hooks/useModeState.js +14 -3
- package/dist/ui/hooks/useModeState.js.map +1 -1
- package/dist/ui/login.d.ts.map +1 -1
- package/dist/ui/login.js +13 -5
- package/dist/ui/login.js.map +1 -1
- package/dist/ui/render.d.ts +14 -0
- package/dist/ui/render.d.ts.map +1 -1
- package/dist/ui/render.js +2 -0
- package/dist/ui/render.js.map +1 -1
- package/dist/ui/render.test.js +17 -0
- package/dist/ui/render.test.js.map +1 -1
- package/package.json +7 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { agentLoop, isAbortError } from "@prestyj/agent";
|
|
2
|
-
import { ProviderError,
|
|
2
|
+
import { ProviderError, } from "@prestyj/ai";
|
|
3
3
|
import { EventBus } from "./event-bus.js";
|
|
4
4
|
import { SlashCommandRegistry, createBuiltinCommands, } from "./slash-commands.js";
|
|
5
5
|
import { PROMPT_COMMANDS, getPromptCommand } from "./prompt-commands.js";
|
|
@@ -16,6 +16,7 @@ import { discoverSkills } from "./skills.js";
|
|
|
16
16
|
import { ensureAppDirs } from "../config.js";
|
|
17
17
|
import { buildSystemPrompt } from "../system-prompt.js";
|
|
18
18
|
import { createTools, createWebSearchTool, } from "../tools/index.js";
|
|
19
|
+
import { applyAsyncSubagentPolicy } from "./subagent-policy.js";
|
|
19
20
|
import { MCPClientManager, getAllMcpServers } from "./mcp/index.js";
|
|
20
21
|
import { DeferredToolCatalog } from "./mcp/deferred-catalog.js";
|
|
21
22
|
import { createToolSearchTool } from "../tools/tool-search.js";
|
|
@@ -26,7 +27,7 @@ import { generateSessionTitle } from "../utils/session-title.js";
|
|
|
26
27
|
import { enhancePrompt } from "../utils/prompt-enhancer.js";
|
|
27
28
|
import { detectProjectStack } from "./language-detector.js";
|
|
28
29
|
import { evaluateIdealReview, buildIdealReviewMessage, detectTestDrift, } from "./ideal-review.js";
|
|
29
|
-
import { evaluateLoopBreak, buildLoopBreakMessage,
|
|
30
|
+
import { evaluateLoopBreak, buildLoopBreakMessage, ToolCallProgressTracker, detectTextRepetition, } from "./loop-breaker.js";
|
|
30
31
|
import { buildRegroundingMessage } from "./regrounding.js";
|
|
31
32
|
import { wrapSteeringText, STEERING_PREFIX } from "./steering.js";
|
|
32
33
|
import crypto from "node:crypto";
|
|
@@ -79,9 +80,8 @@ export class AgentSession {
|
|
|
79
80
|
};
|
|
80
81
|
hookText = "";
|
|
81
82
|
hookConsecutiveFailures = 0;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
hookSignatureCounts = new Map();
|
|
83
|
+
hookRepeatedNoProgressCalls = 0;
|
|
84
|
+
hookProgressTracker = new ToolCallProgressTracker();
|
|
85
85
|
hookFileEditCounts = new Map();
|
|
86
86
|
hookToolCalls = new Map();
|
|
87
87
|
idealReviewInjected = false;
|
|
@@ -89,9 +89,6 @@ export class AgentSession {
|
|
|
89
89
|
regroundingInjected = false;
|
|
90
90
|
compactionOccurred = false;
|
|
91
91
|
originalRequest = "";
|
|
92
|
-
/** True after the cache has been pre-warmed for this session. Ensures we only
|
|
93
|
-
* fire the warm-up call once (before the first real turn). */
|
|
94
|
-
cachePrewarmed = false;
|
|
95
92
|
// Messages queued by the user while a run is in flight. Drained at the
|
|
96
93
|
// mid-loop steering boundary (user steering wins over the hooks), mirroring
|
|
97
94
|
// the TUI's getSteeringMessages. Each entry carries its own attachments so a
|
|
@@ -99,6 +96,11 @@ export class AgentSession {
|
|
|
99
96
|
userQueue = [];
|
|
100
97
|
processManager;
|
|
101
98
|
lspManager;
|
|
99
|
+
subAgentManager;
|
|
100
|
+
managerAbortSignal;
|
|
101
|
+
managerAbortHandler = () => {
|
|
102
|
+
void this.subAgentManager?.interruptAll();
|
|
103
|
+
};
|
|
102
104
|
mcpManager;
|
|
103
105
|
/** Deferred MCP tools awaiting discovery via tool_search (bench A win). */
|
|
104
106
|
mcpCatalog;
|
|
@@ -114,6 +116,8 @@ export class AgentSession {
|
|
|
114
116
|
maxTokens;
|
|
115
117
|
thinkingLevel;
|
|
116
118
|
customSystemPrompt;
|
|
119
|
+
/** Stable prompt prefix retained separately from the volatile uncached tail. */
|
|
120
|
+
baseSystemPrompt = "";
|
|
117
121
|
/** Shared with the tool layer so plan-mode restrictions read live state. */
|
|
118
122
|
planModeRef = { current: false };
|
|
119
123
|
/** Path of the approved plan currently being implemented, or undefined. When
|
|
@@ -121,6 +125,9 @@ export class AgentSession {
|
|
|
121
125
|
* model emits step-completion markers the UI's plan-progress widget reads. */
|
|
122
126
|
approvedPlanPath;
|
|
123
127
|
sessionId = "";
|
|
128
|
+
/** Runtime conversation identity for provider transport headers. Transient
|
|
129
|
+
* children need one even though they intentionally have no persisted session. */
|
|
130
|
+
transportSessionId = crypto.randomUUID();
|
|
124
131
|
sessionPath = "";
|
|
125
132
|
lastPersistedIndex = 0;
|
|
126
133
|
/** Current leaf entry ID in the session DAG — used to chain parentIds for branching. */
|
|
@@ -162,24 +169,34 @@ export class AgentSession {
|
|
|
162
169
|
await this.settingsManager.load();
|
|
163
170
|
this.authStorage = new AuthStorage(paths.authFile);
|
|
164
171
|
await this.authStorage.load();
|
|
165
|
-
// Session manager
|
|
166
|
-
this.sessionManager = new SessionManager(paths.sessionsDir);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
172
|
+
// Session manager. Agent-specific roots keep chat and coder histories isolated.
|
|
173
|
+
this.sessionManager = new SessionManager(this.opts.sessionRootDir ?? paths.sessionsDir);
|
|
174
|
+
const projectCustomization = this.opts.projectCustomization !== false;
|
|
175
|
+
if (projectCustomization) {
|
|
176
|
+
// Ensure project-local .ezcoder directories exist.
|
|
177
|
+
const localEzDir = path.join(this.cwd, ".ezcoder");
|
|
178
|
+
await fs.mkdir(path.join(localEzDir, "skills"), { recursive: true });
|
|
179
|
+
await fs.mkdir(path.join(localEzDir, "commands"), { recursive: true });
|
|
180
|
+
await fs.mkdir(path.join(localEzDir, "agents"), { recursive: true });
|
|
181
|
+
this.skills = await discoverSkills({
|
|
182
|
+
globalSkillsDir: paths.skillsDir,
|
|
183
|
+
projectDir: this.cwd,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
this.skills = [];
|
|
188
|
+
}
|
|
189
|
+
// Discover agents and create tools (with sub-agent support). Chat sessions
|
|
190
|
+
// can retain bundled workers without loading project/global customization.
|
|
191
|
+
const agents = projectCustomization
|
|
192
|
+
? await discoverAgents({
|
|
193
|
+
globalAgentsDir: paths.agentsDir,
|
|
194
|
+
projectDir: this.cwd,
|
|
195
|
+
})
|
|
196
|
+
: this.opts.globalSubagents
|
|
197
|
+
? await discoverAgents({ globalAgentsDir: paths.agentsDir })
|
|
198
|
+
: [];
|
|
199
|
+
const { tools: builtInTools, processManager, rebuildReadTool, lspManager, subAgentManager, } = await createTools(this.cwd, {
|
|
183
200
|
agents,
|
|
184
201
|
skills: this.skills,
|
|
185
202
|
provider: this.provider,
|
|
@@ -190,7 +207,11 @@ export class AgentSession {
|
|
|
190
207
|
// sub-agent spawns read the current parent state at execution time.
|
|
191
208
|
getProvider: () => this.provider,
|
|
192
209
|
getModel: () => this.model,
|
|
210
|
+
getThinkingLevel: () => this.thinkingLevel,
|
|
211
|
+
getBaseUrl: () => this.baseUrl,
|
|
193
212
|
getCacheKey: () => this.getPromptCacheKey(),
|
|
213
|
+
disableAsyncSubagents: this.opts.subagentWorker,
|
|
214
|
+
onSubAgentState: (snapshot) => this.eventBus.emit("subagent_state", snapshot),
|
|
194
215
|
// Plan mode: only wired when the host supplies callbacks. The ref is
|
|
195
216
|
// shared so bash/edit/write enforce read-only restrictions live.
|
|
196
217
|
...(this.opts.onEnterPlan || this.opts.onExitPlan
|
|
@@ -201,6 +222,7 @@ export class AgentSession {
|
|
|
201
222
|
}
|
|
202
223
|
: {}),
|
|
203
224
|
});
|
|
225
|
+
const tools = [...builtInTools, ...(this.opts.additionalTools ?? [])];
|
|
204
226
|
// Apply the optional tool allow-list (read-only advisory sessions). Filtering
|
|
205
227
|
// here means the excluded tools are never registered with the agent loop, so
|
|
206
228
|
// a hallucinated call can't mutate the repo — and buildSystemPrompt below is
|
|
@@ -209,6 +231,8 @@ export class AgentSession {
|
|
|
209
231
|
this.rebuildReadTool = rebuildReadTool;
|
|
210
232
|
this.processManager = processManager;
|
|
211
233
|
this.lspManager = lspManager;
|
|
234
|
+
this.subAgentManager = subAgentManager;
|
|
235
|
+
this.bindManagerCancellation(this.opts.signal);
|
|
212
236
|
// Connect MCP servers (non-blocking — failures are logged and skipped).
|
|
213
237
|
// Child sessions (subagents and goal workers run via `--json` mode) get the
|
|
214
238
|
// provider defaults only — NOT user-configured servers. The defaults now
|
|
@@ -234,7 +258,9 @@ export class AgentSession {
|
|
|
234
258
|
}
|
|
235
259
|
const basePrompt = this.customSystemPrompt ??
|
|
236
260
|
(await buildSystemPrompt(this.cwd, this.skills, false, undefined, this.tools.map((tool) => tool.name), undefined, this.provider));
|
|
237
|
-
this.
|
|
261
|
+
this.baseSystemPrompt = basePrompt;
|
|
262
|
+
this.messages = [{ role: "system", content: this.withSystemPromptTail(basePrompt) }];
|
|
263
|
+
this.syncUltraOrchestrationPrompt();
|
|
238
264
|
// Load or create session. Transient sessions (subagent spawns) never
|
|
239
265
|
// touch the session store — sessionPath stays empty and persistMessage
|
|
240
266
|
// is a no-op so their transcripts can't pollute `ezcoder continue`.
|
|
@@ -256,48 +282,46 @@ export class AgentSession {
|
|
|
256
282
|
else {
|
|
257
283
|
await this.createNewSession();
|
|
258
284
|
}
|
|
259
|
-
//
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
285
|
+
// EZ Coder owns its command registry. Other agents start with an isolated
|
|
286
|
+
// empty registry and can register their own commands in their own file.
|
|
287
|
+
if (this.opts.coderSlashCommands !== false) {
|
|
288
|
+
const builtins = createBuiltinCommands();
|
|
289
|
+
for (const cmd of builtins)
|
|
290
|
+
this.slashCommands.register(cmd);
|
|
291
|
+
// Wire up /help to show all registered + prompt + custom commands.
|
|
292
|
+
const helpCmd = this.slashCommands.get("help");
|
|
293
|
+
if (helpCmd) {
|
|
294
|
+
const registry = this.slashCommands;
|
|
295
|
+
const cwd = this.cwd;
|
|
296
|
+
helpCmd.execute = async () => {
|
|
297
|
+
const all = registry.getAll();
|
|
298
|
+
const lines = all.map((c) => ` /${c.name}${c.aliases.length ? ` (${c.aliases.map((a) => "/" + a).join(", ")})` : ""} — ${c.description}`);
|
|
299
|
+
if (PROMPT_COMMANDS.length > 0) {
|
|
300
|
+
lines.push("", "Prompt commands:");
|
|
301
|
+
for (const cmd of PROMPT_COMMANDS) {
|
|
302
|
+
lines.push(` /${cmd.name}${cmd.aliases.length ? ` (${cmd.aliases.map((a) => "/" + a).join(", ")})` : ""} — ${cmd.description}`);
|
|
303
|
+
}
|
|
278
304
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
lines.push("Custom commands:");
|
|
285
|
-
for (const cmd of customCmds) {
|
|
286
|
-
lines.push(` /${cmd.name} — ${cmd.description}`);
|
|
305
|
+
const customCmds = await loadCustomCommands(cwd);
|
|
306
|
+
if (customCmds.length > 0) {
|
|
307
|
+
lines.push("", "Custom commands:");
|
|
308
|
+
for (const cmd of customCmds)
|
|
309
|
+
lines.push(` /${cmd.name} — ${cmd.description}`);
|
|
287
310
|
}
|
|
288
|
-
|
|
289
|
-
|
|
311
|
+
return "Available commands:\n" + lines.join("\n");
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (this.opts.loadExtensions !== false) {
|
|
316
|
+
const extContext = {
|
|
317
|
+
eventBus: this.eventBus,
|
|
318
|
+
registerTool: (tool) => this.tools.push(tool),
|
|
319
|
+
registerSlashCommand: (cmd) => this.slashCommands.register(cmd),
|
|
320
|
+
cwd: this.cwd,
|
|
321
|
+
settingsManager: this.settingsManager,
|
|
290
322
|
};
|
|
323
|
+
await this.extensionLoader.loadAll(paths.extensionsDir, extContext);
|
|
291
324
|
}
|
|
292
|
-
// Load extensions
|
|
293
|
-
const extContext = {
|
|
294
|
-
eventBus: this.eventBus,
|
|
295
|
-
registerTool: (tool) => this.tools.push(tool),
|
|
296
|
-
registerSlashCommand: (cmd) => this.slashCommands.register(cmd),
|
|
297
|
-
cwd: this.cwd,
|
|
298
|
-
settingsManager: this.settingsManager,
|
|
299
|
-
};
|
|
300
|
-
await this.extensionLoader.loadAll(paths.extensionsDir, extContext);
|
|
301
325
|
this.eventBus.emit("session_start", { sessionId: this.sessionId });
|
|
302
326
|
}
|
|
303
327
|
/**
|
|
@@ -413,12 +437,17 @@ export class AgentSession {
|
|
|
413
437
|
* Process user input. Handles slash commands or runs agent loop.
|
|
414
438
|
*/
|
|
415
439
|
async prompt(content) {
|
|
416
|
-
|
|
417
|
-
const
|
|
440
|
+
const parsedInput = this.slashCommands.parse(content);
|
|
441
|
+
const coderCommands = this.opts.coderSlashCommands !== false;
|
|
442
|
+
// Non-coder agents only intercept commands registered in their own registry.
|
|
443
|
+
// Unknown `/text` stays a normal conversational prompt.
|
|
444
|
+
const parsed = parsedInput && (coderCommands || this.slashCommands.get(parsedInput.name))
|
|
445
|
+
? parsedInput
|
|
446
|
+
: null;
|
|
418
447
|
if (parsed) {
|
|
419
|
-
//
|
|
420
|
-
const builtinPromptCmd = getPromptCommand(parsed.name);
|
|
421
|
-
const customCmds = await loadCustomCommands(this.cwd);
|
|
448
|
+
// EZ Coder alone can resolve its prompt-template and project commands.
|
|
449
|
+
const builtinPromptCmd = coderCommands ? getPromptCommand(parsed.name) : undefined;
|
|
450
|
+
const customCmds = coderCommands ? await loadCustomCommands(this.cwd) : [];
|
|
422
451
|
const customPromptCmd = !builtinPromptCmd
|
|
423
452
|
? customCmds.find((c) => c.name === parsed.name)
|
|
424
453
|
: undefined;
|
|
@@ -543,9 +572,8 @@ export class AgentSession {
|
|
|
543
572
|
};
|
|
544
573
|
this.hookText = "";
|
|
545
574
|
this.hookConsecutiveFailures = 0;
|
|
546
|
-
this.
|
|
547
|
-
this.
|
|
548
|
-
this.hookSignatureCounts.clear();
|
|
575
|
+
this.hookRepeatedNoProgressCalls = 0;
|
|
576
|
+
this.hookProgressTracker.reset();
|
|
549
577
|
this.hookFileEditCounts.clear();
|
|
550
578
|
this.hookToolCalls.clear();
|
|
551
579
|
this.idealReviewInjected = false;
|
|
@@ -581,18 +609,12 @@ export class AgentSession {
|
|
|
581
609
|
if (name === "bash")
|
|
582
610
|
this.hookStats.bashCalls += 1;
|
|
583
611
|
this.hookConsecutiveFailures = event.isError ? this.hookConsecutiveFailures + 1 : 0;
|
|
584
|
-
|
|
585
|
-
const sigNext = (this.hookSignatureCounts.get(sig) ?? 0) + 1;
|
|
586
|
-
this.hookSignatureCounts.set(sig, sigNext);
|
|
587
|
-
if (sigNext > this.hookMaxSignatureRepeats)
|
|
588
|
-
this.hookMaxSignatureRepeats = sigNext;
|
|
612
|
+
this.hookRepeatedNoProgressCalls = this.hookProgressTracker.record(name, args, event.result, event.isError);
|
|
589
613
|
if ((name === "edit" || name === "write") && args) {
|
|
590
614
|
const filePath = args.file_path;
|
|
591
615
|
if (typeof filePath === "string") {
|
|
592
616
|
const fileNext = (this.hookFileEditCounts.get(filePath) ?? 0) + 1;
|
|
593
617
|
this.hookFileEditCounts.set(filePath, fileNext);
|
|
594
|
-
if (fileNext > this.hookMaxSameFileEdits)
|
|
595
|
-
this.hookMaxSameFileEdits = fileNext;
|
|
596
618
|
}
|
|
597
619
|
}
|
|
598
620
|
if (name === "edit" && !event.isError) {
|
|
@@ -637,17 +659,21 @@ export class AgentSession {
|
|
|
637
659
|
return { role: "user", content: parts };
|
|
638
660
|
});
|
|
639
661
|
}
|
|
662
|
+
if (this.opts.selfCorrectionHooks === false)
|
|
663
|
+
return null;
|
|
640
664
|
if (!this.settingsManager.get("idealReviewEnabled"))
|
|
641
665
|
return null;
|
|
642
666
|
if (!this.loopBreakInjected) {
|
|
643
667
|
const decision = evaluateLoopBreak({
|
|
644
668
|
consecutiveFailures: this.hookConsecutiveFailures,
|
|
645
|
-
|
|
646
|
-
maxSameFileEdits: this.hookMaxSameFileEdits,
|
|
669
|
+
repeatedNoProgressCalls: this.hookRepeatedNoProgressCalls,
|
|
647
670
|
textRepetitionDetected: detectTextRepetition(this.hookText),
|
|
648
671
|
});
|
|
649
672
|
if (decision.shouldBreak) {
|
|
650
673
|
this.loopBreakInjected = true;
|
|
674
|
+
log("INFO", "loop-break", "Injecting loop-break nudge", {
|
|
675
|
+
reasons: decision.reasons.join(", "),
|
|
676
|
+
});
|
|
651
677
|
this.eventBus.emit("hook", { kind: "loop_break" });
|
|
652
678
|
return [buildLoopBreakMessage(decision.reasons)];
|
|
653
679
|
}
|
|
@@ -664,6 +690,8 @@ export class AgentSession {
|
|
|
664
690
|
* otherwise finish and the change set is substantial enough to warrant it.
|
|
665
691
|
*/
|
|
666
692
|
getHookFollowUpMessages() {
|
|
693
|
+
if (this.opts.selfCorrectionHooks === false)
|
|
694
|
+
return null;
|
|
667
695
|
if (!this.settingsManager.get("idealReviewEnabled"))
|
|
668
696
|
return null;
|
|
669
697
|
if (this.idealReviewInjected)
|
|
@@ -680,6 +708,7 @@ export class AgentSession {
|
|
|
680
708
|
}
|
|
681
709
|
/** Auto-compact if needed, run agent loop with auth retry, and persist messages. */
|
|
682
710
|
async runLoop() {
|
|
711
|
+
this.refreshSystemPromptTail();
|
|
683
712
|
// One-shot cache-key marker per session so turn_end cacheRead numbers
|
|
684
713
|
// in the log can be traced back to a specific routing namespace —
|
|
685
714
|
// particularly useful when sub-agents inherit `parentKey:subagent`.
|
|
@@ -739,11 +768,13 @@ export class AgentSession {
|
|
|
739
768
|
tools: this.tools,
|
|
740
769
|
webSearch: true,
|
|
741
770
|
maxTokens: this.maxTokens,
|
|
771
|
+
maxTurns: this.opts.maxTurns,
|
|
742
772
|
thinking: this.thinkingLevel,
|
|
743
773
|
apiKey,
|
|
744
774
|
baseUrl: effectiveBaseUrl,
|
|
745
775
|
signal: this.opts.signal,
|
|
746
776
|
accountId,
|
|
777
|
+
transportSessionId: this.sessionId || this.transportSessionId,
|
|
747
778
|
projectId,
|
|
748
779
|
// Kimi For Coding gates the managed endpoint on coding-agent identity
|
|
749
780
|
// headers; attach them only when the Kimi OAuth token is in use.
|
|
@@ -790,11 +821,6 @@ export class AgentSession {
|
|
|
790
821
|
}
|
|
791
822
|
};
|
|
792
823
|
try {
|
|
793
|
-
// Fire cache pre-warm before the first turn (Anthropic + speedProfile optimized).
|
|
794
|
-
// Runs concurrently with nothing — it must complete before runAgentLoop so
|
|
795
|
-
// the cache is warm when the real request arrives. Best-effort: swallowed
|
|
796
|
-
// inside maybePrewarmCache/prewarmAnthropicCache.
|
|
797
|
-
await this.maybePrewarmCache(creds);
|
|
798
824
|
await runAgentLoop(creds.accessToken, creds.accountId, creds.projectId);
|
|
799
825
|
}
|
|
800
826
|
catch (err) {
|
|
@@ -841,6 +867,11 @@ export class AgentSession {
|
|
|
841
867
|
if (provider)
|
|
842
868
|
this.provider = provider;
|
|
843
869
|
this.model = model;
|
|
870
|
+
// Keep host-provided option closures (notably chat delegation) aligned with
|
|
871
|
+
// the live selection after an in-session model switch.
|
|
872
|
+
this.opts.provider = this.provider;
|
|
873
|
+
this.opts.model = this.model;
|
|
874
|
+
this.syncUltraOrchestrationPrompt();
|
|
844
875
|
setEstimatorModel(model);
|
|
845
876
|
// maxTokens must follow the active model — it was frozen at the boot
|
|
846
877
|
// model's `maxOutputTokens` in the constructor, so without this a session
|
|
@@ -984,7 +1015,9 @@ export class AgentSession {
|
|
|
984
1015
|
this.appMarkers = [];
|
|
985
1016
|
const basePrompt = this.customSystemPrompt ??
|
|
986
1017
|
(await buildSystemPrompt(this.cwd, this.skills, false, undefined, this.tools.map((tool) => tool.name), undefined, this.provider));
|
|
987
|
-
this.
|
|
1018
|
+
this.baseSystemPrompt = basePrompt;
|
|
1019
|
+
this.messages = [{ role: "system", content: this.withSystemPromptTail(basePrompt) }];
|
|
1020
|
+
this.syncUltraOrchestrationPrompt();
|
|
988
1021
|
// Fresh conversation — new entries must not chain onto the old DAG's leaf.
|
|
989
1022
|
this.currentLeafId = null;
|
|
990
1023
|
// Transient sessions (Nolan chat/autopilot, subagent spawns) never touch the
|
|
@@ -1099,6 +1132,22 @@ export class AgentSession {
|
|
|
1099
1132
|
return `No background process with id "${id}"`;
|
|
1100
1133
|
return this.processManager.stop(id);
|
|
1101
1134
|
}
|
|
1135
|
+
/** Replace a host-owned system prompt in place without resetting conversation history. */
|
|
1136
|
+
setCustomSystemPrompt(systemPrompt, promptCacheKeyPrefix) {
|
|
1137
|
+
this.customSystemPrompt = systemPrompt;
|
|
1138
|
+
this.baseSystemPrompt = systemPrompt;
|
|
1139
|
+
this.opts.systemPrompt = systemPrompt;
|
|
1140
|
+
if (promptCacheKeyPrefix)
|
|
1141
|
+
this.opts.promptCacheKeyPrefix = promptCacheKeyPrefix;
|
|
1142
|
+
const content = this.withSystemPromptTail(systemPrompt);
|
|
1143
|
+
if (this.messages[0]?.role === "system") {
|
|
1144
|
+
this.messages[0] = { role: "system", content };
|
|
1145
|
+
}
|
|
1146
|
+
else {
|
|
1147
|
+
this.messages.unshift({ role: "system", content });
|
|
1148
|
+
}
|
|
1149
|
+
this.syncUltraOrchestrationPrompt();
|
|
1150
|
+
}
|
|
1102
1151
|
/**
|
|
1103
1152
|
* Toggle plan mode: flips the shared ref (so tools enforce read-only
|
|
1104
1153
|
* restrictions) and rebuilds the system prompt in place so the model is told
|
|
@@ -1128,11 +1177,30 @@ export class AgentSession {
|
|
|
1128
1177
|
if (this.customSystemPrompt)
|
|
1129
1178
|
return;
|
|
1130
1179
|
const rebuilt = await buildSystemPrompt(this.cwd, this.skills, this.planModeRef.current, this.approvedPlanPath, this.tools.map((tool) => tool.name), undefined, this.provider);
|
|
1180
|
+
this.baseSystemPrompt = rebuilt;
|
|
1181
|
+
const content = this.withSystemPromptTail(rebuilt);
|
|
1182
|
+
if (this.messages[0]?.role === "system") {
|
|
1183
|
+
this.messages[0] = { role: "system", content };
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
this.messages.unshift({ role: "system", content });
|
|
1187
|
+
}
|
|
1188
|
+
this.syncUltraOrchestrationPrompt();
|
|
1189
|
+
}
|
|
1190
|
+
withSystemPromptTail(basePrompt) {
|
|
1191
|
+
if (!this.opts.getSystemPromptTail)
|
|
1192
|
+
return basePrompt;
|
|
1193
|
+
return `${basePrompt}\n\n<!-- uncached -->\n${this.opts.getSystemPromptTail()}`;
|
|
1194
|
+
}
|
|
1195
|
+
refreshSystemPromptTail() {
|
|
1196
|
+
if (!this.opts.getSystemPromptTail)
|
|
1197
|
+
return;
|
|
1198
|
+
const content = this.withSystemPromptTail(this.baseSystemPrompt);
|
|
1131
1199
|
if (this.messages[0]?.role === "system") {
|
|
1132
|
-
this.messages[0] = { role: "system", content
|
|
1200
|
+
this.messages[0] = { role: "system", content };
|
|
1133
1201
|
}
|
|
1134
1202
|
else {
|
|
1135
|
-
this.messages.unshift({ role: "system", content
|
|
1203
|
+
this.messages.unshift({ role: "system", content });
|
|
1136
1204
|
}
|
|
1137
1205
|
}
|
|
1138
1206
|
getMessages() {
|
|
@@ -1367,10 +1435,28 @@ export class AgentSession {
|
|
|
1367
1435
|
* effect on the next prompt, since the in-flight loop reads it at start. */
|
|
1368
1436
|
setThinkingLevel(level) {
|
|
1369
1437
|
this.thinkingLevel = level;
|
|
1438
|
+
this.syncUltraOrchestrationPrompt();
|
|
1439
|
+
}
|
|
1440
|
+
/** Sol/Terra Ultra delegates proactively; lower levels require an explicit request. */
|
|
1441
|
+
syncUltraOrchestrationPrompt() {
|
|
1442
|
+
if (this.opts.orchestrationPrompt === false)
|
|
1443
|
+
return;
|
|
1444
|
+
const systemMessage = this.messages[0];
|
|
1445
|
+
if (systemMessage?.role !== "system" || typeof systemMessage.content !== "string")
|
|
1446
|
+
return;
|
|
1447
|
+
systemMessage.content = applyAsyncSubagentPolicy(systemMessage.content, this.provider, this.model, this.thinkingLevel, this.tools.map((tool) => tool.name));
|
|
1370
1448
|
}
|
|
1371
1449
|
/** Replace the abort signal (e.g. after cancellation). */
|
|
1372
1450
|
setSignal(signal) {
|
|
1373
1451
|
this.opts = { ...this.opts, signal };
|
|
1452
|
+
this.bindManagerCancellation(signal);
|
|
1453
|
+
}
|
|
1454
|
+
bindManagerCancellation(signal) {
|
|
1455
|
+
this.managerAbortSignal?.removeEventListener("abort", this.managerAbortHandler);
|
|
1456
|
+
this.managerAbortSignal = signal;
|
|
1457
|
+
signal?.addEventListener("abort", this.managerAbortHandler, { once: true });
|
|
1458
|
+
if (signal?.aborted)
|
|
1459
|
+
this.managerAbortHandler();
|
|
1374
1460
|
}
|
|
1375
1461
|
/** True when speedProfile is "optimized" (1-h cache TTL + pre-warm), or the
|
|
1376
1462
|
* session was constructed with `forceLongCacheRetention` (Nolan sessions). */
|
|
@@ -1388,40 +1474,6 @@ export class AgentSession {
|
|
|
1388
1474
|
currentAuthStorageKeys() {
|
|
1389
1475
|
return getAuthStorageKeys(this.provider, this.model);
|
|
1390
1476
|
}
|
|
1391
|
-
/** Fire a cache pre-warm request for Anthropic so the first real turn is a
|
|
1392
|
-
* cache read instead of a cold write. No-op for other providers and when
|
|
1393
|
-
* speedProfile is not "optimized". Entirely best-effort — any failure is
|
|
1394
|
-
* swallowed so prewarm never blocks or aborts the real prompt. */
|
|
1395
|
-
async maybePrewarmCache(creds) {
|
|
1396
|
-
if (this.cachePrewarmed || !this.isSpeedOptimized() || this.provider !== "anthropic") {
|
|
1397
|
-
return;
|
|
1398
|
-
}
|
|
1399
|
-
this.cachePrewarmed = true;
|
|
1400
|
-
try {
|
|
1401
|
-
const userAgent = await getClaudeCliUserAgent();
|
|
1402
|
-
const systemText = typeof this.messages[0]?.content === "string" ? this.messages[0].content : "";
|
|
1403
|
-
if (!systemText)
|
|
1404
|
-
return;
|
|
1405
|
-
await prewarmAnthropicCache({
|
|
1406
|
-
apiKey: creds.accessToken,
|
|
1407
|
-
model: this.model,
|
|
1408
|
-
system: systemText,
|
|
1409
|
-
tools: this.tools.map((t) => ({
|
|
1410
|
-
name: t.name,
|
|
1411
|
-
description: t.description,
|
|
1412
|
-
parameters: t.parameters,
|
|
1413
|
-
...(t.rawInputSchema ? { rawInputSchema: t.rawInputSchema } : {}),
|
|
1414
|
-
})),
|
|
1415
|
-
baseUrl: this.baseUrl ?? creds.baseUrl,
|
|
1416
|
-
userAgent,
|
|
1417
|
-
cacheRetention: "long",
|
|
1418
|
-
signal: this.opts.signal,
|
|
1419
|
-
});
|
|
1420
|
-
}
|
|
1421
|
-
catch {
|
|
1422
|
-
// Best-effort — prewarm failure must never block the session.
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
1477
|
getPromptCacheKey() {
|
|
1426
1478
|
if (this.opts.promptCacheKey)
|
|
1427
1479
|
return this.opts.promptCacheKey;
|
|
@@ -1434,9 +1486,10 @@ export class AgentSession {
|
|
|
1434
1486
|
return this.getPromptCacheKey();
|
|
1435
1487
|
}
|
|
1436
1488
|
async dispose() {
|
|
1489
|
+
this.managerAbortSignal?.removeEventListener("abort", this.managerAbortHandler);
|
|
1437
1490
|
this.processManager?.shutdownAll();
|
|
1438
1491
|
this.lspManager?.shutdownAll();
|
|
1439
|
-
await this.mcpManager?.dispose();
|
|
1492
|
+
await Promise.all([this.subAgentManager?.shutdownAll(), this.mcpManager?.dispose()]);
|
|
1440
1493
|
await this.extensionLoader.deactivateAll();
|
|
1441
1494
|
this.eventBus.removeAllListeners();
|
|
1442
1495
|
this.messages = [];
|