@spinabot/brigade 0.1.2 → 1.0.1
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/LICENSE +1 -1
- package/README.md +748 -88
- package/brigade.mjs +150 -73
- package/dist/agents/a2a-policy-canonicalize.d.ts +60 -0
- package/dist/agents/a2a-policy-canonicalize.d.ts.map +1 -0
- package/dist/agents/a2a-policy-canonicalize.js +103 -0
- package/dist/agents/a2a-policy-canonicalize.js.map +1 -0
- package/dist/agents/agent-event-bus.d.ts +221 -0
- package/dist/agents/agent-event-bus.d.ts.map +1 -0
- package/dist/agents/agent-event-bus.js +88 -0
- package/dist/agents/agent-event-bus.js.map +1 -0
- package/dist/agents/agent-events.d.ts +84 -0
- package/dist/agents/agent-events.d.ts.map +1 -0
- package/dist/agents/agent-events.js +309 -0
- package/dist/agents/agent-events.js.map +1 -0
- package/dist/agents/agent-events.types.d.ts +139 -0
- package/dist/agents/agent-events.types.d.ts.map +1 -0
- package/dist/agents/agent-events.types.js +27 -0
- package/dist/agents/agent-events.types.js.map +1 -0
- package/dist/agents/agent-loop.d.ts +145 -0
- package/dist/agents/agent-loop.d.ts.map +1 -0
- package/dist/agents/agent-loop.js +1938 -0
- package/dist/agents/agent-loop.js.map +1 -0
- package/dist/agents/agent-scope.d.ts +28 -0
- package/dist/agents/agent-scope.d.ts.map +1 -0
- package/dist/agents/agent-scope.js +39 -0
- package/dist/agents/agent-scope.js.map +1 -0
- package/dist/agents/approval-bridge.d.ts +139 -0
- package/dist/agents/approval-bridge.d.ts.map +1 -0
- package/dist/agents/approval-bridge.js +178 -0
- package/dist/agents/approval-bridge.js.map +1 -0
- package/dist/agents/carrow.d.ts +49 -0
- package/dist/agents/carrow.d.ts.map +1 -0
- package/dist/agents/carrow.js +57 -0
- package/dist/agents/carrow.js.map +1 -0
- package/dist/agents/channels/abort-triggers.d.ts +17 -0
- package/dist/agents/channels/abort-triggers.d.ts.map +1 -0
- package/dist/agents/channels/abort-triggers.js +52 -0
- package/dist/agents/channels/abort-triggers.js.map +1 -0
- package/dist/agents/channels/access-control/index.d.ts +5 -0
- package/dist/agents/channels/access-control/index.d.ts.map +1 -0
- package/dist/agents/channels/access-control/index.js +4 -0
- package/dist/agents/channels/access-control/index.js.map +1 -0
- package/dist/agents/channels/access-control/policy.d.ts +69 -0
- package/dist/agents/channels/access-control/policy.d.ts.map +1 -0
- package/dist/agents/channels/access-control/policy.js +123 -0
- package/dist/agents/channels/access-control/policy.js.map +1 -0
- package/dist/agents/channels/access-control/store.d.ts +86 -0
- package/dist/agents/channels/access-control/store.d.ts.map +1 -0
- package/dist/agents/channels/access-control/store.js +482 -0
- package/dist/agents/channels/access-control/store.js.map +1 -0
- package/dist/agents/channels/access-control/types.d.ts +52 -0
- package/dist/agents/channels/access-control/types.d.ts.map +1 -0
- package/dist/agents/channels/access-control/types.js +20 -0
- package/dist/agents/channels/access-control/types.js.map +1 -0
- package/dist/agents/channels/active-manager.d.ts +31 -0
- package/dist/agents/channels/active-manager.d.ts.map +1 -0
- package/dist/agents/channels/active-manager.js +41 -0
- package/dist/agents/channels/active-manager.js.map +1 -0
- package/dist/agents/channels/agent-switch-command.d.ts +53 -0
- package/dist/agents/channels/agent-switch-command.d.ts.map +1 -0
- package/dist/agents/channels/agent-switch-command.js +349 -0
- package/dist/agents/channels/agent-switch-command.js.map +1 -0
- package/dist/agents/channels/approval-router.d.ts +158 -0
- package/dist/agents/channels/approval-router.d.ts.map +1 -0
- package/dist/agents/channels/approval-router.js +446 -0
- package/dist/agents/channels/approval-router.js.map +1 -0
- package/dist/agents/channels/channel-entry-contract.d.ts +70 -0
- package/dist/agents/channels/channel-entry-contract.d.ts.map +1 -0
- package/dist/agents/channels/channel-entry-contract.js +48 -0
- package/dist/agents/channels/channel-entry-contract.js.map +1 -0
- package/dist/agents/channels/channel-plugin-manager.d.ts +86 -0
- package/dist/agents/channels/channel-plugin-manager.d.ts.map +1 -0
- package/dist/agents/channels/channel-plugin-manager.js +345 -0
- package/dist/agents/channels/channel-plugin-manager.js.map +1 -0
- package/dist/agents/channels/chat-type.d.ts +27 -0
- package/dist/agents/channels/chat-type.d.ts.map +1 -0
- package/dist/agents/channels/chat-type.js +33 -0
- package/dist/agents/channels/chat-type.js.map +1 -0
- package/dist/agents/channels/dedupe.d.ts +44 -0
- package/dist/agents/channels/dedupe.d.ts.map +1 -0
- package/dist/agents/channels/dedupe.js +80 -0
- package/dist/agents/channels/dedupe.js.map +1 -0
- package/dist/agents/channels/inbound-pipeline.d.ts +90 -0
- package/dist/agents/channels/inbound-pipeline.d.ts.map +1 -0
- package/dist/agents/channels/inbound-pipeline.js +721 -0
- package/dist/agents/channels/inbound-pipeline.js.map +1 -0
- package/dist/agents/channels/last-channel.d.ts +56 -0
- package/dist/agents/channels/last-channel.d.ts.map +1 -0
- package/dist/agents/channels/last-channel.js +65 -0
- package/dist/agents/channels/last-channel.js.map +1 -0
- package/dist/agents/channels/manager.d.ts +76 -0
- package/dist/agents/channels/manager.d.ts.map +1 -0
- package/dist/agents/channels/manager.js +132 -0
- package/dist/agents/channels/manager.js.map +1 -0
- package/dist/agents/channels/media-capture.d.ts +23 -0
- package/dist/agents/channels/media-capture.d.ts.map +1 -0
- package/dist/agents/channels/media-capture.js +40 -0
- package/dist/agents/channels/media-capture.js.map +1 -0
- package/dist/agents/channels/plugin-channel-manager-facade.d.ts +18 -0
- package/dist/agents/channels/plugin-channel-manager-facade.d.ts.map +1 -0
- package/dist/agents/channels/plugin-channel-manager-facade.js +52 -0
- package/dist/agents/channels/plugin-channel-manager-facade.js.map +1 -0
- package/dist/agents/channels/reply-sanitizer.d.ts +38 -0
- package/dist/agents/channels/reply-sanitizer.d.ts.map +1 -0
- package/dist/agents/channels/reply-sanitizer.js +94 -0
- package/dist/agents/channels/reply-sanitizer.js.map +1 -0
- package/dist/agents/channels/retryable-inbound.d.ts +31 -0
- package/dist/agents/channels/retryable-inbound.d.ts.map +1 -0
- package/dist/agents/channels/retryable-inbound.js +37 -0
- package/dist/agents/channels/retryable-inbound.js.map +1 -0
- package/dist/agents/channels/types.adapters.d.ts +399 -0
- package/dist/agents/channels/types.adapters.d.ts.map +1 -0
- package/dist/agents/channels/types.adapters.js +33 -0
- package/dist/agents/channels/types.adapters.js.map +1 -0
- package/dist/agents/channels/types.core.d.ts +134 -0
- package/dist/agents/channels/types.core.d.ts.map +1 -0
- package/dist/agents/channels/types.core.js +32 -0
- package/dist/agents/channels/types.core.js.map +1 -0
- package/dist/agents/channels/types.plugin.d.ts +78 -0
- package/dist/agents/channels/types.plugin.d.ts.map +1 -0
- package/dist/agents/channels/types.plugin.js +30 -0
- package/dist/agents/channels/types.plugin.js.map +1 -0
- package/dist/agents/channels/whatsapp/account-config.d.ts +50 -0
- package/dist/agents/channels/whatsapp/account-config.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/account-config.js +105 -0
- package/dist/agents/channels/whatsapp/account-config.js.map +1 -0
- package/dist/agents/channels/whatsapp/adapter.d.ts +22 -0
- package/dist/agents/channels/whatsapp/adapter.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/adapter.js +270 -0
- package/dist/agents/channels/whatsapp/adapter.js.map +1 -0
- package/dist/agents/channels/whatsapp/chunk.d.ts +26 -0
- package/dist/agents/channels/whatsapp/chunk.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/chunk.js +123 -0
- package/dist/agents/channels/whatsapp/chunk.js.map +1 -0
- package/dist/agents/channels/whatsapp/connection.d.ts +249 -0
- package/dist/agents/channels/whatsapp/connection.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/connection.js +1628 -0
- package/dist/agents/channels/whatsapp/connection.js.map +1 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.d.ts +34 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.js +168 -0
- package/dist/agents/channels/whatsapp/convex-auth-state.js.map +1 -0
- package/dist/agents/channels/whatsapp/format.d.ts +15 -0
- package/dist/agents/channels/whatsapp/format.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/format.js +66 -0
- package/dist/agents/channels/whatsapp/format.js.map +1 -0
- package/dist/agents/channels/whatsapp/inbound-extras.d.ts +30 -0
- package/dist/agents/channels/whatsapp/inbound-extras.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/inbound-extras.js +146 -0
- package/dist/agents/channels/whatsapp/inbound-extras.js.map +1 -0
- package/dist/agents/channels/whatsapp/index.d.ts +7 -0
- package/dist/agents/channels/whatsapp/index.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/index.js +7 -0
- package/dist/agents/channels/whatsapp/index.js.map +1 -0
- package/dist/agents/channels/whatsapp/media.d.ts +47 -0
- package/dist/agents/channels/whatsapp/media.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/media.js +192 -0
- package/dist/agents/channels/whatsapp/media.js.map +1 -0
- package/dist/agents/channels/whatsapp/module.d.ts +10 -0
- package/dist/agents/channels/whatsapp/module.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/module.js +17 -0
- package/dist/agents/channels/whatsapp/module.js.map +1 -0
- package/dist/agents/channels/whatsapp/plugin.d.ts +60 -0
- package/dist/agents/channels/whatsapp/plugin.d.ts.map +1 -0
- package/dist/agents/channels/whatsapp/plugin.js +238 -0
- package/dist/agents/channels/whatsapp/plugin.js.map +1 -0
- package/dist/agents/cmd-ism-guard.d.ts +47 -0
- package/dist/agents/cmd-ism-guard.d.ts.map +1 -0
- package/dist/agents/cmd-ism-guard.js +100 -0
- package/dist/agents/cmd-ism-guard.js.map +1 -0
- package/dist/agents/config-write-guard.d.ts +25 -0
- package/dist/agents/config-write-guard.d.ts.map +1 -0
- package/dist/agents/config-write-guard.js +95 -0
- package/dist/agents/config-write-guard.js.map +1 -0
- package/dist/agents/content-quality-retry.d.ts +66 -0
- package/dist/agents/content-quality-retry.d.ts.map +1 -0
- package/dist/agents/content-quality-retry.js +140 -0
- package/dist/agents/content-quality-retry.js.map +1 -0
- package/dist/agents/error-classifier.d.ts +89 -0
- package/dist/agents/error-classifier.d.ts.map +1 -0
- package/dist/agents/error-classifier.js +630 -0
- package/dist/agents/error-classifier.js.map +1 -0
- package/dist/agents/exec-gate.d.ts +113 -0
- package/dist/agents/exec-gate.d.ts.map +1 -0
- package/dist/agents/exec-gate.js +335 -0
- package/dist/agents/exec-gate.js.map +1 -0
- package/dist/agents/exec-session-allow.d.ts +30 -0
- package/dist/agents/exec-session-allow.d.ts.map +1 -0
- package/dist/agents/exec-session-allow.js +50 -0
- package/dist/agents/exec-session-allow.js.map +1 -0
- package/dist/agents/extensions/active-registry.d.ts +4 -0
- package/dist/agents/extensions/active-registry.d.ts.map +1 -0
- package/dist/agents/extensions/active-registry.js +18 -0
- package/dist/agents/extensions/active-registry.js.map +1 -0
- package/dist/agents/extensions/discovery.d.ts +84 -0
- package/dist/agents/extensions/discovery.d.ts.map +1 -0
- package/dist/agents/extensions/discovery.js +249 -0
- package/dist/agents/extensions/discovery.js.map +1 -0
- package/dist/agents/extensions/hook-runner.d.ts +67 -0
- package/dist/agents/extensions/hook-runner.d.ts.map +1 -0
- package/dist/agents/extensions/hook-runner.js +155 -0
- package/dist/agents/extensions/hook-runner.js.map +1 -0
- package/dist/agents/extensions/index.d.ts +15 -0
- package/dist/agents/extensions/index.d.ts.map +1 -0
- package/dist/agents/extensions/index.js +14 -0
- package/dist/agents/extensions/index.js.map +1 -0
- package/dist/agents/extensions/loader.d.ts +38 -0
- package/dist/agents/extensions/loader.d.ts.map +1 -0
- package/dist/agents/extensions/loader.js +142 -0
- package/dist/agents/extensions/loader.js.map +1 -0
- package/dist/agents/extensions/modules/arxiv.d.ts +28 -0
- package/dist/agents/extensions/modules/arxiv.d.ts.map +1 -0
- package/dist/agents/extensions/modules/arxiv.js +145 -0
- package/dist/agents/extensions/modules/arxiv.js.map +1 -0
- package/dist/agents/extensions/modules/brave.d.ts +28 -0
- package/dist/agents/extensions/modules/brave.d.ts.map +1 -0
- package/dist/agents/extensions/modules/brave.js +489 -0
- package/dist/agents/extensions/modules/brave.js.map +1 -0
- package/dist/agents/extensions/modules/duckduckgo.d.ts +27 -0
- package/dist/agents/extensions/modules/duckduckgo.d.ts.map +1 -0
- package/dist/agents/extensions/modules/duckduckgo.js +263 -0
- package/dist/agents/extensions/modules/duckduckgo.js.map +1 -0
- package/dist/agents/extensions/modules/exa.d.ts +19 -0
- package/dist/agents/extensions/modules/exa.d.ts.map +1 -0
- package/dist/agents/extensions/modules/exa.js +208 -0
- package/dist/agents/extensions/modules/exa.js.map +1 -0
- package/dist/agents/extensions/modules/firecrawl.d.ts +51 -0
- package/dist/agents/extensions/modules/firecrawl.d.ts.map +1 -0
- package/dist/agents/extensions/modules/firecrawl.js +280 -0
- package/dist/agents/extensions/modules/firecrawl.js.map +1 -0
- package/dist/agents/extensions/modules/github-search.d.ts +29 -0
- package/dist/agents/extensions/modules/github-search.d.ts.map +1 -0
- package/dist/agents/extensions/modules/github-search.js +197 -0
- package/dist/agents/extensions/modules/github-search.js.map +1 -0
- package/dist/agents/extensions/modules/hackernews.d.ts +17 -0
- package/dist/agents/extensions/modules/hackernews.d.ts.map +1 -0
- package/dist/agents/extensions/modules/hackernews.js +144 -0
- package/dist/agents/extensions/modules/hackernews.js.map +1 -0
- package/dist/agents/extensions/modules/index.d.ts +11 -0
- package/dist/agents/extensions/modules/index.d.ts.map +1 -0
- package/dist/agents/extensions/modules/index.js +64 -0
- package/dist/agents/extensions/modules/index.js.map +1 -0
- package/dist/agents/extensions/modules/npm-search.d.ts +15 -0
- package/dist/agents/extensions/modules/npm-search.d.ts.map +1 -0
- package/dist/agents/extensions/modules/npm-search.js +126 -0
- package/dist/agents/extensions/modules/npm-search.js.map +1 -0
- package/dist/agents/extensions/modules/ollama-search.d.ts +30 -0
- package/dist/agents/extensions/modules/ollama-search.d.ts.map +1 -0
- package/dist/agents/extensions/modules/ollama-search.js +171 -0
- package/dist/agents/extensions/modules/ollama-search.js.map +1 -0
- package/dist/agents/extensions/modules/perplexity.d.ts +19 -0
- package/dist/agents/extensions/modules/perplexity.d.ts.map +1 -0
- package/dist/agents/extensions/modules/perplexity.js +358 -0
- package/dist/agents/extensions/modules/perplexity.js.map +1 -0
- package/dist/agents/extensions/modules/searxng.d.ts +43 -0
- package/dist/agents/extensions/modules/searxng.d.ts.map +1 -0
- package/dist/agents/extensions/modules/searxng.js +191 -0
- package/dist/agents/extensions/modules/searxng.js.map +1 -0
- package/dist/agents/extensions/modules/tavily.d.ts +71 -0
- package/dist/agents/extensions/modules/tavily.d.ts.map +1 -0
- package/dist/agents/extensions/modules/tavily.js +330 -0
- package/dist/agents/extensions/modules/tavily.js.map +1 -0
- package/dist/agents/extensions/modules/web-provider-helpers.d.ts +89 -0
- package/dist/agents/extensions/modules/web-provider-helpers.d.ts.map +1 -0
- package/dist/agents/extensions/modules/web-provider-helpers.js +146 -0
- package/dist/agents/extensions/modules/web-provider-helpers.js.map +1 -0
- package/dist/agents/extensions/modules/web-search-filters.d.ts +62 -0
- package/dist/agents/extensions/modules/web-search-filters.d.ts.map +1 -0
- package/dist/agents/extensions/modules/web-search-filters.js +179 -0
- package/dist/agents/extensions/modules/web-search-filters.js.map +1 -0
- package/dist/agents/extensions/modules/wikipedia.d.ts +16 -0
- package/dist/agents/extensions/modules/wikipedia.d.ts.map +1 -0
- package/dist/agents/extensions/modules/wikipedia.js +138 -0
- package/dist/agents/extensions/modules/wikipedia.js.map +1 -0
- package/dist/agents/extensions/registry-cache.d.ts +74 -0
- package/dist/agents/extensions/registry-cache.d.ts.map +1 -0
- package/dist/agents/extensions/registry-cache.js +117 -0
- package/dist/agents/extensions/registry-cache.js.map +1 -0
- package/dist/agents/extensions/registry.d.ts +184 -0
- package/dist/agents/extensions/registry.d.ts.map +1 -0
- package/dist/agents/extensions/registry.js +512 -0
- package/dist/agents/extensions/registry.js.map +1 -0
- package/dist/agents/extensions/types.d.ts +1195 -0
- package/dist/agents/extensions/types.d.ts.map +1 -0
- package/dist/agents/extensions/types.js +28 -0
- package/dist/agents/extensions/types.js.map +1 -0
- package/dist/agents/gateway-call.d.ts +171 -0
- package/dist/agents/gateway-call.d.ts.map +1 -0
- package/dist/agents/gateway-call.js +74 -0
- package/dist/agents/gateway-call.js.map +1 -0
- package/dist/agents/heartbeat-runner.d.ts +100 -0
- package/dist/agents/heartbeat-runner.d.ts.map +1 -0
- package/dist/agents/heartbeat-runner.js +268 -0
- package/dist/agents/heartbeat-runner.js.map +1 -0
- package/dist/agents/heartbeat-scheduler.d.ts +56 -0
- package/dist/agents/heartbeat-scheduler.d.ts.map +1 -0
- package/dist/agents/heartbeat-scheduler.js +366 -0
- package/dist/agents/heartbeat-scheduler.js.map +1 -0
- package/dist/agents/heartbeat-wake.d.ts +99 -0
- package/dist/agents/heartbeat-wake.d.ts.map +1 -0
- package/dist/agents/heartbeat-wake.js +304 -0
- package/dist/agents/heartbeat-wake.js.map +1 -0
- package/dist/agents/identity-file.d.ts +26 -0
- package/dist/agents/identity-file.d.ts.map +1 -0
- package/dist/agents/identity-file.js +86 -0
- package/dist/agents/identity-file.js.map +1 -0
- package/dist/agents/identity-links.d.ts +44 -0
- package/dist/agents/identity-links.d.ts.map +1 -0
- package/dist/agents/identity-links.js +51 -0
- package/dist/agents/identity-links.js.map +1 -0
- package/dist/agents/loop/autonomous-agent.d.ts +55 -0
- package/dist/agents/loop/autonomous-agent.d.ts.map +1 -0
- package/dist/agents/loop/autonomous-agent.js +91 -0
- package/dist/agents/loop/autonomous-agent.js.map +1 -0
- package/dist/agents/loop/loop-guards.d.ts +95 -0
- package/dist/agents/loop/loop-guards.d.ts.map +1 -0
- package/dist/agents/loop/loop-guards.js +169 -0
- package/dist/agents/loop/loop-guards.js.map +1 -0
- package/dist/agents/loop/loop-runner.d.ts +72 -0
- package/dist/agents/loop/loop-runner.d.ts.map +1 -0
- package/dist/agents/loop/loop-runner.js +114 -0
- package/dist/agents/loop/loop-runner.js.map +1 -0
- package/dist/agents/memory/auto-recall.d.ts +69 -0
- package/dist/agents/memory/auto-recall.d.ts.map +1 -0
- package/dist/agents/memory/auto-recall.js +147 -0
- package/dist/agents/memory/auto-recall.js.map +1 -0
- package/dist/agents/memory/behavior-review.d.ts +68 -0
- package/dist/agents/memory/behavior-review.d.ts.map +1 -0
- package/dist/agents/memory/behavior-review.js +131 -0
- package/dist/agents/memory/behavior-review.js.map +1 -0
- package/dist/agents/memory/consolidate.d.ts +62 -0
- package/dist/agents/memory/consolidate.d.ts.map +1 -0
- package/dist/agents/memory/consolidate.js +275 -0
- package/dist/agents/memory/consolidate.js.map +1 -0
- package/dist/agents/memory/contradiction.d.ts +44 -0
- package/dist/agents/memory/contradiction.d.ts.map +1 -0
- package/dist/agents/memory/contradiction.js +86 -0
- package/dist/agents/memory/contradiction.js.map +1 -0
- package/dist/agents/memory/curator.d.ts +22 -0
- package/dist/agents/memory/curator.d.ts.map +1 -0
- package/dist/agents/memory/curator.js +52 -0
- package/dist/agents/memory/curator.js.map +1 -0
- package/dist/agents/memory/decay.d.ts +32 -0
- package/dist/agents/memory/decay.d.ts.map +1 -0
- package/dist/agents/memory/decay.js +86 -0
- package/dist/agents/memory/decay.js.map +1 -0
- package/dist/agents/memory/dream.d.ts +52 -0
- package/dist/agents/memory/dream.d.ts.map +1 -0
- package/dist/agents/memory/dream.js +192 -0
- package/dist/agents/memory/dream.js.map +1 -0
- package/dist/agents/memory/embedder-providers.d.ts +114 -0
- package/dist/agents/memory/embedder-providers.d.ts.map +1 -0
- package/dist/agents/memory/embedder-providers.js +213 -0
- package/dist/agents/memory/embedder-providers.js.map +1 -0
- package/dist/agents/memory/embedder.d.ts +84 -0
- package/dist/agents/memory/embedder.d.ts.map +1 -0
- package/dist/agents/memory/embedder.js +218 -0
- package/dist/agents/memory/embedder.js.map +1 -0
- package/dist/agents/memory/eval/asr-bench.d.ts +33 -0
- package/dist/agents/memory/eval/asr-bench.d.ts.map +1 -0
- package/dist/agents/memory/eval/asr-bench.js +129 -0
- package/dist/agents/memory/eval/asr-bench.js.map +1 -0
- package/dist/agents/memory/eval/capabilities.d.ts +97 -0
- package/dist/agents/memory/eval/capabilities.d.ts.map +1 -0
- package/dist/agents/memory/eval/capabilities.js +210 -0
- package/dist/agents/memory/eval/capabilities.js.map +1 -0
- package/dist/agents/memory/eval/gold-export.d.ts +44 -0
- package/dist/agents/memory/eval/gold-export.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-export.js +85 -0
- package/dist/agents/memory/eval/gold-export.js.map +1 -0
- package/dist/agents/memory/eval/gold-hard.d.ts +35 -0
- package/dist/agents/memory/eval/gold-hard.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-hard.js +113 -0
- package/dist/agents/memory/eval/gold-hard.js.map +1 -0
- package/dist/agents/memory/eval/gold-rich.d.ts +33 -0
- package/dist/agents/memory/eval/gold-rich.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-rich.js +82 -0
- package/dist/agents/memory/eval/gold-rich.js.map +1 -0
- package/dist/agents/memory/eval/gold-synthetic.d.ts +19 -0
- package/dist/agents/memory/eval/gold-synthetic.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold-synthetic.js +65 -0
- package/dist/agents/memory/eval/gold-synthetic.js.map +1 -0
- package/dist/agents/memory/eval/gold.d.ts +73 -0
- package/dist/agents/memory/eval/gold.d.ts.map +1 -0
- package/dist/agents/memory/eval/gold.js +174 -0
- package/dist/agents/memory/eval/gold.js.map +1 -0
- package/dist/agents/memory/eval/harness.d.ts +110 -0
- package/dist/agents/memory/eval/harness.d.ts.map +1 -0
- package/dist/agents/memory/eval/harness.js +123 -0
- package/dist/agents/memory/eval/harness.js.map +1 -0
- package/dist/agents/memory/eval/metrics.d.ts +71 -0
- package/dist/agents/memory/eval/metrics.d.ts.map +1 -0
- package/dist/agents/memory/eval/metrics.js +169 -0
- package/dist/agents/memory/eval/metrics.js.map +1 -0
- package/dist/agents/memory/event-log.d.ts +52 -0
- package/dist/agents/memory/event-log.d.ts.map +1 -0
- package/dist/agents/memory/event-log.js +65 -0
- package/dist/agents/memory/event-log.js.map +1 -0
- package/dist/agents/memory/extract.d.ts +155 -0
- package/dist/agents/memory/extract.d.ts.map +1 -0
- package/dist/agents/memory/extract.js +571 -0
- package/dist/agents/memory/extract.js.map +1 -0
- package/dist/agents/memory/governance.d.ts +45 -0
- package/dist/agents/memory/governance.d.ts.map +1 -0
- package/dist/agents/memory/governance.js +113 -0
- package/dist/agents/memory/governance.js.map +1 -0
- package/dist/agents/memory/graph-export.d.ts +59 -0
- package/dist/agents/memory/graph-export.d.ts.map +1 -0
- package/dist/agents/memory/graph-export.js +181 -0
- package/dist/agents/memory/graph-export.js.map +1 -0
- package/dist/agents/memory/graph-recall.d.ts +42 -0
- package/dist/agents/memory/graph-recall.d.ts.map +1 -0
- package/dist/agents/memory/graph-recall.js +165 -0
- package/dist/agents/memory/graph-recall.js.map +1 -0
- package/dist/agents/memory/graph.d.ts +92 -0
- package/dist/agents/memory/graph.d.ts.map +1 -0
- package/dist/agents/memory/graph.js +266 -0
- package/dist/agents/memory/graph.js.map +1 -0
- package/dist/agents/memory/host-ports.d.ts +27 -0
- package/dist/agents/memory/host-ports.d.ts.map +1 -0
- package/dist/agents/memory/host-ports.js +31 -0
- package/dist/agents/memory/host-ports.js.map +1 -0
- package/dist/agents/memory/hybrid.d.ts +46 -0
- package/dist/agents/memory/hybrid.d.ts.map +1 -0
- package/dist/agents/memory/hybrid.js +184 -0
- package/dist/agents/memory/hybrid.js.map +1 -0
- package/dist/agents/memory/index.d.ts +13 -0
- package/dist/agents/memory/index.d.ts.map +1 -0
- package/dist/agents/memory/index.js +13 -0
- package/dist/agents/memory/index.js.map +1 -0
- package/dist/agents/memory/json-scan.d.ts +14 -0
- package/dist/agents/memory/json-scan.d.ts.map +1 -0
- package/dist/agents/memory/json-scan.js +47 -0
- package/dist/agents/memory/json-scan.js.map +1 -0
- package/dist/agents/memory/links.d.ts +92 -0
- package/dist/agents/memory/links.d.ts.map +1 -0
- package/dist/agents/memory/links.js +140 -0
- package/dist/agents/memory/links.js.map +1 -0
- package/dist/agents/memory/maintenance.d.ts +18 -0
- package/dist/agents/memory/maintenance.d.ts.map +1 -0
- package/dist/agents/memory/maintenance.js +66 -0
- package/dist/agents/memory/maintenance.js.map +1 -0
- package/dist/agents/memory/memory-mcp-server.d.ts +39 -0
- package/dist/agents/memory/memory-mcp-server.d.ts.map +1 -0
- package/dist/agents/memory/memory-mcp-server.js +122 -0
- package/dist/agents/memory/memory-mcp-server.js.map +1 -0
- package/dist/agents/memory/memory-mcp.d.ts +34 -0
- package/dist/agents/memory/memory-mcp.d.ts.map +1 -0
- package/dist/agents/memory/memory-mcp.js +130 -0
- package/dist/agents/memory/memory-mcp.js.map +1 -0
- package/dist/agents/memory/plugin-runtime.d.ts +133 -0
- package/dist/agents/memory/plugin-runtime.d.ts.map +1 -0
- package/dist/agents/memory/plugin-runtime.js +149 -0
- package/dist/agents/memory/plugin-runtime.js.map +1 -0
- package/dist/agents/memory/query.d.ts +50 -0
- package/dist/agents/memory/query.d.ts.map +1 -0
- package/dist/agents/memory/query.js +94 -0
- package/dist/agents/memory/query.js.map +1 -0
- package/dist/agents/memory/records.d.ts +617 -0
- package/dist/agents/memory/records.d.ts.map +1 -0
- package/dist/agents/memory/records.js +1327 -0
- package/dist/agents/memory/records.js.map +1 -0
- package/dist/agents/memory/reembed.d.ts +42 -0
- package/dist/agents/memory/reembed.d.ts.map +1 -0
- package/dist/agents/memory/reembed.js +60 -0
- package/dist/agents/memory/reembed.js.map +1 -0
- package/dist/agents/memory/relationship-extract.d.ts +259 -0
- package/dist/agents/memory/relationship-extract.d.ts.map +1 -0
- package/dist/agents/memory/relationship-extract.js +454 -0
- package/dist/agents/memory/relationship-extract.js.map +1 -0
- package/dist/agents/memory/rerank.d.ts +37 -0
- package/dist/agents/memory/rerank.d.ts.map +1 -0
- package/dist/agents/memory/rerank.js +43 -0
- package/dist/agents/memory/rerank.js.map +1 -0
- package/dist/agents/memory/scoring.d.ts +85 -0
- package/dist/agents/memory/scoring.d.ts.map +1 -0
- package/dist/agents/memory/scoring.js +139 -0
- package/dist/agents/memory/scoring.js.map +1 -0
- package/dist/agents/memory/self-improve.d.ts +56 -0
- package/dist/agents/memory/self-improve.d.ts.map +1 -0
- package/dist/agents/memory/self-improve.js +98 -0
- package/dist/agents/memory/self-improve.js.map +1 -0
- package/dist/agents/memory/self-review.d.ts +68 -0
- package/dist/agents/memory/self-review.d.ts.map +1 -0
- package/dist/agents/memory/self-review.js +109 -0
- package/dist/agents/memory/self-review.js.map +1 -0
- package/dist/agents/memory/storage.d.ts +156 -0
- package/dist/agents/memory/storage.d.ts.map +1 -0
- package/dist/agents/memory/storage.js +359 -0
- package/dist/agents/memory/storage.js.map +1 -0
- package/dist/agents/memory/tideline.d.ts +203 -0
- package/dist/agents/memory/tideline.d.ts.map +1 -0
- package/dist/agents/memory/tideline.js +189 -0
- package/dist/agents/memory/tideline.js.map +1 -0
- package/dist/agents/memory/vault.d.ts +142 -0
- package/dist/agents/memory/vault.d.ts.map +1 -0
- package/dist/agents/memory/vault.js +787 -0
- package/dist/agents/memory/vault.js.map +1 -0
- package/dist/agents/memory/write-gate.d.ts +76 -0
- package/dist/agents/memory/write-gate.d.ts.map +1 -0
- package/dist/agents/memory/write-gate.js +140 -0
- package/dist/agents/memory/write-gate.js.map +1 -0
- package/dist/agents/mid-turn-switch.d.ts +25 -0
- package/dist/agents/mid-turn-switch.d.ts.map +1 -0
- package/dist/agents/mid-turn-switch.js +103 -0
- package/dist/agents/mid-turn-switch.js.map +1 -0
- package/dist/agents/model-fallback.d.ts +50 -0
- package/dist/agents/model-fallback.d.ts.map +1 -0
- package/dist/agents/model-fallback.js +226 -0
- package/dist/agents/model-fallback.js.map +1 -0
- package/dist/agents/model-resolution.d.ts +38 -0
- package/dist/agents/model-resolution.d.ts.map +1 -0
- package/dist/agents/model-resolution.js +155 -0
- package/dist/agents/model-resolution.js.map +1 -0
- package/dist/agents/org/a2a-adapter.d.ts +49 -0
- package/dist/agents/org/a2a-adapter.d.ts.map +1 -0
- package/dist/agents/org/a2a-adapter.js +92 -0
- package/dist/agents/org/a2a-adapter.js.map +1 -0
- package/dist/agents/org/assets/mascots/README.md +34 -0
- package/dist/agents/org/assets/mascots/Untitled-1.png +0 -0
- package/dist/agents/org/assets/mascots/brigade_biceps.png +0 -0
- package/dist/agents/org/audit-log.d.ts +22 -0
- package/dist/agents/org/audit-log.d.ts.map +1 -0
- package/dist/agents/org/audit-log.js +37 -0
- package/dist/agents/org/audit-log.js.map +1 -0
- package/dist/agents/org/auto-derive.d.ts +22 -0
- package/dist/agents/org/auto-derive.d.ts.map +1 -0
- package/dist/agents/org/auto-derive.js +66 -0
- package/dist/agents/org/auto-derive.js.map +1 -0
- package/dist/agents/org/delivery-kind.d.ts +89 -0
- package/dist/agents/org/delivery-kind.d.ts.map +1 -0
- package/dist/agents/org/delivery-kind.js +149 -0
- package/dist/agents/org/delivery-kind.js.map +1 -0
- package/dist/agents/org/derive-graph.d.ts +34 -0
- package/dist/agents/org/derive-graph.d.ts.map +1 -0
- package/dist/agents/org/derive-graph.js +266 -0
- package/dist/agents/org/derive-graph.js.map +1 -0
- package/dist/agents/org/lints.d.ts +21 -0
- package/dist/agents/org/lints.d.ts.map +1 -0
- package/dist/agents/org/lints.js +133 -0
- package/dist/agents/org/lints.js.map +1 -0
- package/dist/agents/org/pride-html.d.ts +61 -0
- package/dist/agents/org/pride-html.d.ts.map +1 -0
- package/dist/agents/org/pride-html.js +565 -0
- package/dist/agents/org/pride-html.js.map +1 -0
- package/dist/agents/org/pride-image.d.ts +101 -0
- package/dist/agents/org/pride-image.d.ts.map +1 -0
- package/dist/agents/org/pride-image.js +210 -0
- package/dist/agents/org/pride-image.js.map +1 -0
- package/dist/agents/org/pride-taunts.d.ts +47 -0
- package/dist/agents/org/pride-taunts.d.ts.map +1 -0
- package/dist/agents/org/pride-taunts.js +411 -0
- package/dist/agents/org/pride-taunts.js.map +1 -0
- package/dist/agents/org/pride-template.d.ts +272 -0
- package/dist/agents/org/pride-template.d.ts.map +1 -0
- package/dist/agents/org/pride-template.js +892 -0
- package/dist/agents/org/pride-template.js.map +1 -0
- package/dist/agents/org/pride-themes.d.ts +80 -0
- package/dist/agents/org/pride-themes.d.ts.map +1 -0
- package/dist/agents/org/pride-themes.js +7596 -0
- package/dist/agents/org/pride-themes.js.map +1 -0
- package/dist/agents/org/structured-errors.d.ts +47 -0
- package/dist/agents/org/structured-errors.d.ts.map +1 -0
- package/dist/agents/org/structured-errors.js +97 -0
- package/dist/agents/org/structured-errors.js.map +1 -0
- package/dist/agents/org/types.d.ts +139 -0
- package/dist/agents/org/types.d.ts.map +1 -0
- package/dist/agents/org/types.js +43 -0
- package/dist/agents/org/types.js.map +1 -0
- package/dist/agents/org/validate.d.ts +36 -0
- package/dist/agents/org/validate.d.ts.map +1 -0
- package/dist/agents/org/validate.js +135 -0
- package/dist/agents/org/validate.js.map +1 -0
- package/dist/agents/path-write-guard.d.ts +82 -0
- package/dist/agents/path-write-guard.d.ts.map +1 -0
- package/dist/agents/path-write-guard.js +722 -0
- package/dist/agents/path-write-guard.js.map +1 -0
- package/dist/agents/payload-mutators.d.ts +175 -0
- package/dist/agents/payload-mutators.d.ts.map +1 -0
- package/dist/agents/payload-mutators.js +994 -0
- package/dist/agents/payload-mutators.js.map +1 -0
- package/dist/agents/pending-system-events.d.ts +76 -0
- package/dist/agents/pending-system-events.d.ts.map +1 -0
- package/dist/agents/pending-system-events.js +115 -0
- package/dist/agents/pending-system-events.js.map +1 -0
- package/dist/agents/provider-attribution.d.ts +19 -0
- package/dist/agents/provider-attribution.d.ts.map +1 -0
- package/dist/agents/provider-attribution.js +62 -0
- package/dist/agents/provider-attribution.js.map +1 -0
- package/dist/agents/quality/slop-detector.d.ts +40 -0
- package/dist/agents/quality/slop-detector.d.ts.map +1 -0
- package/dist/agents/quality/slop-detector.js +108 -0
- package/dist/agents/quality/slop-detector.js.map +1 -0
- package/dist/agents/quality/slop-index.d.ts +27 -0
- package/dist/agents/quality/slop-index.d.ts.map +1 -0
- package/dist/agents/quality/slop-index.js +124 -0
- package/dist/agents/quality/slop-index.js.map +1 -0
- package/dist/agents/retry-policy.d.ts +38 -0
- package/dist/agents/retry-policy.d.ts.map +1 -0
- package/dist/agents/retry-policy.js +276 -0
- package/dist/agents/retry-policy.js.map +1 -0
- package/dist/agents/routing/account-id.d.ts +43 -0
- package/dist/agents/routing/account-id.d.ts.map +1 -0
- package/dist/agents/routing/account-id.js +103 -0
- package/dist/agents/routing/account-id.js.map +1 -0
- package/dist/agents/routing/bindings.d.ts +20 -0
- package/dist/agents/routing/bindings.d.ts.map +1 -0
- package/dist/agents/routing/bindings.js +22 -0
- package/dist/agents/routing/bindings.js.map +1 -0
- package/dist/agents/routing/dm-scope-warning.d.ts +37 -0
- package/dist/agents/routing/dm-scope-warning.d.ts.map +1 -0
- package/dist/agents/routing/dm-scope-warning.js +110 -0
- package/dist/agents/routing/dm-scope-warning.js.map +1 -0
- package/dist/agents/routing/identity-links.d.ts +45 -0
- package/dist/agents/routing/identity-links.d.ts.map +1 -0
- package/dist/agents/routing/identity-links.js +85 -0
- package/dist/agents/routing/identity-links.js.map +1 -0
- package/dist/agents/routing/resolve-route.d.ts +91 -0
- package/dist/agents/routing/resolve-route.d.ts.map +1 -0
- package/dist/agents/routing/resolve-route.js +653 -0
- package/dist/agents/routing/resolve-route.js.map +1 -0
- package/dist/agents/routing/session-key.d.ts +168 -0
- package/dist/agents/routing/session-key.d.ts.map +1 -0
- package/dist/agents/routing/session-key.js +268 -0
- package/dist/agents/routing/session-key.js.map +1 -0
- package/dist/agents/sanitize-surrogates.d.ts +30 -0
- package/dist/agents/sanitize-surrogates.d.ts.map +1 -0
- package/dist/agents/sanitize-surrogates.js +56 -0
- package/dist/agents/sanitize-surrogates.js.map +1 -0
- package/dist/agents/session-context.d.ts +80 -0
- package/dist/agents/session-context.d.ts.map +1 -0
- package/dist/agents/session-context.js +76 -0
- package/dist/agents/session-context.js.map +1 -0
- package/dist/agents/session-event-prompt.d.ts +124 -0
- package/dist/agents/session-event-prompt.d.ts.map +1 -0
- package/dist/agents/session-event-prompt.js +179 -0
- package/dist/agents/session-event-prompt.js.map +1 -0
- package/dist/agents/session-inbox.d.ts +129 -0
- package/dist/agents/session-inbox.d.ts.map +1 -0
- package/dist/agents/session-inbox.js +492 -0
- package/dist/agents/session-inbox.js.map +1 -0
- package/dist/agents/session-registry.d.ts +148 -0
- package/dist/agents/session-registry.d.ts.map +1 -0
- package/dist/agents/session-registry.js +405 -0
- package/dist/agents/session-registry.js.map +1 -0
- package/dist/agents/session-wiring.d.ts +214 -0
- package/dist/agents/session-wiring.d.ts.map +1 -0
- package/dist/agents/session-wiring.js +278 -0
- package/dist/agents/session-wiring.js.map +1 -0
- package/dist/agents/session-write-lock.d.ts +15 -0
- package/dist/agents/session-write-lock.d.ts.map +1 -0
- package/dist/agents/session-write-lock.js +15 -0
- package/dist/agents/session-write-lock.js.map +1 -0
- package/dist/agents/skills/agent-filter.d.ts +43 -0
- package/dist/agents/skills/agent-filter.d.ts.map +1 -0
- package/dist/agents/skills/agent-filter.js +89 -0
- package/dist/agents/skills/agent-filter.js.map +1 -0
- package/dist/agents/skills/discovery.d.ts +97 -0
- package/dist/agents/skills/discovery.d.ts.map +1 -0
- package/dist/agents/skills/discovery.js +136 -0
- package/dist/agents/skills/discovery.js.map +1 -0
- package/dist/agents/skills/eligibility.d.ts +118 -0
- package/dist/agents/skills/eligibility.d.ts.map +1 -0
- package/dist/agents/skills/eligibility.js +280 -0
- package/dist/agents/skills/eligibility.js.map +1 -0
- package/dist/agents/skills/grant.d.ts +70 -0
- package/dist/agents/skills/grant.d.ts.map +1 -0
- package/dist/agents/skills/grant.js +106 -0
- package/dist/agents/skills/grant.js.map +1 -0
- package/dist/agents/skills/index.d.ts +35 -0
- package/dist/agents/skills/index.d.ts.map +1 -0
- package/dist/agents/skills/index.js +88 -0
- package/dist/agents/skills/index.js.map +1 -0
- package/dist/agents/skills/install-spec.d.ts +51 -0
- package/dist/agents/skills/install-spec.d.ts.map +1 -0
- package/dist/agents/skills/install-spec.js +21 -0
- package/dist/agents/skills/install-spec.js.map +1 -0
- package/dist/agents/skills/install.d.ts +68 -0
- package/dist/agents/skills/install.d.ts.map +1 -0
- package/dist/agents/skills/install.js +206 -0
- package/dist/agents/skills/install.js.map +1 -0
- package/dist/agents/skills/org-access.d.ts +27 -0
- package/dist/agents/skills/org-access.d.ts.map +1 -0
- package/dist/agents/skills/org-access.js +87 -0
- package/dist/agents/skills/org-access.js.map +1 -0
- package/dist/agents/skills/skill-consolidate.d.ts +76 -0
- package/dist/agents/skills/skill-consolidate.d.ts.map +1 -0
- package/dist/agents/skills/skill-consolidate.js +264 -0
- package/dist/agents/skills/skill-consolidate.js.map +1 -0
- package/dist/agents/skills/skill-curator.d.ts +91 -0
- package/dist/agents/skills/skill-curator.d.ts.map +1 -0
- package/dist/agents/skills/skill-curator.js +239 -0
- package/dist/agents/skills/skill-curator.js.map +1 -0
- package/dist/agents/skills/skill-manifest.d.ts +35 -0
- package/dist/agents/skills/skill-manifest.d.ts.map +1 -0
- package/dist/agents/skills/skill-manifest.js +82 -0
- package/dist/agents/skills/skill-manifest.js.map +1 -0
- package/dist/agents/skills/skill-review.d.ts +91 -0
- package/dist/agents/skills/skill-review.d.ts.map +1 -0
- package/dist/agents/skills/skill-review.js +271 -0
- package/dist/agents/skills/skill-review.js.map +1 -0
- package/dist/agents/skills/skill-usage.d.ts +81 -0
- package/dist/agents/skills/skill-usage.d.ts.map +1 -0
- package/dist/agents/skills/skill-usage.js +208 -0
- package/dist/agents/skills/skill-usage.js.map +1 -0
- package/dist/agents/skills/status.d.ts +68 -0
- package/dist/agents/skills/status.d.ts.map +1 -0
- package/dist/agents/skills/status.js +147 -0
- package/dist/agents/skills/status.js.map +1 -0
- package/dist/agents/skills/update-config.d.ts +32 -0
- package/dist/agents/skills/update-config.d.ts.map +1 -0
- package/dist/agents/skills/update-config.js +53 -0
- package/dist/agents/skills/update-config.js.map +1 -0
- package/dist/agents/slash-commands.d.ts +25 -0
- package/dist/agents/slash-commands.d.ts.map +1 -0
- package/dist/agents/slash-commands.js +151 -0
- package/dist/agents/slash-commands.js.map +1 -0
- package/dist/agents/smart-compaction.d.ts +105 -0
- package/dist/agents/smart-compaction.d.ts.map +1 -0
- package/dist/agents/smart-compaction.js +355 -0
- package/dist/agents/smart-compaction.js.map +1 -0
- package/dist/agents/stream-wrappers.d.ts +20 -0
- package/dist/agents/stream-wrappers.d.ts.map +1 -0
- package/dist/agents/stream-wrappers.js +307 -0
- package/dist/agents/stream-wrappers.js.map +1 -0
- package/dist/agents/subagent-abort-cascade.d.ts +31 -0
- package/dist/agents/subagent-abort-cascade.d.ts.map +1 -0
- package/dist/agents/subagent-abort-cascade.js +124 -0
- package/dist/agents/subagent-abort-cascade.js.map +1 -0
- package/dist/agents/subagent-announce-delivery.d.ts +83 -0
- package/dist/agents/subagent-announce-delivery.d.ts.map +1 -0
- package/dist/agents/subagent-announce-delivery.js +159 -0
- package/dist/agents/subagent-announce-delivery.js.map +1 -0
- package/dist/agents/subagent-budget.d.ts +36 -0
- package/dist/agents/subagent-budget.d.ts.map +1 -0
- package/dist/agents/subagent-budget.js +93 -0
- package/dist/agents/subagent-budget.js.map +1 -0
- package/dist/agents/subagent-completion-bridge.d.ts +42 -0
- package/dist/agents/subagent-completion-bridge.d.ts.map +1 -0
- package/dist/agents/subagent-completion-bridge.js +338 -0
- package/dist/agents/subagent-completion-bridge.js.map +1 -0
- package/dist/agents/subagent-lifecycle-events.d.ts +31 -0
- package/dist/agents/subagent-lifecycle-events.d.ts.map +1 -0
- package/dist/agents/subagent-lifecycle-events.js +21 -0
- package/dist/agents/subagent-lifecycle-events.js.map +1 -0
- package/dist/agents/subagent-policy.d.ts +206 -0
- package/dist/agents/subagent-policy.d.ts.map +1 -0
- package/dist/agents/subagent-policy.js +295 -0
- package/dist/agents/subagent-policy.js.map +1 -0
- package/dist/agents/subagent-registry-completion.d.ts +69 -0
- package/dist/agents/subagent-registry-completion.d.ts.map +1 -0
- package/dist/agents/subagent-registry-completion.js +128 -0
- package/dist/agents/subagent-registry-completion.js.map +1 -0
- package/dist/agents/subagent-registry.d.ts +85 -0
- package/dist/agents/subagent-registry.d.ts.map +1 -0
- package/dist/agents/subagent-registry.js +215 -0
- package/dist/agents/subagent-registry.js.map +1 -0
- package/dist/agents/subagent-registry.types.d.ts +94 -0
- package/dist/agents/subagent-registry.types.d.ts.map +1 -0
- package/dist/agents/subagent-registry.types.js +19 -0
- package/dist/agents/subagent-registry.types.js.map +1 -0
- package/dist/agents/subagent-runner.d.ts +75 -0
- package/dist/agents/subagent-runner.d.ts.map +1 -0
- package/dist/agents/subagent-runner.js +358 -0
- package/dist/agents/subagent-runner.js.map +1 -0
- package/dist/agents/subagent-spawn-abort-marker.d.ts +46 -0
- package/dist/agents/subagent-spawn-abort-marker.d.ts.map +1 -0
- package/dist/agents/subagent-spawn-abort-marker.js +81 -0
- package/dist/agents/subagent-spawn-abort-marker.js.map +1 -0
- package/dist/agents/subagent-spawn.d.ts +104 -0
- package/dist/agents/subagent-spawn.d.ts.map +1 -0
- package/dist/agents/subagent-spawn.js +358 -0
- package/dist/agents/subagent-spawn.js.map +1 -0
- package/dist/agents/thinking-fallback.d.ts +49 -0
- package/dist/agents/thinking-fallback.d.ts.map +1 -0
- package/dist/agents/thinking-fallback.js +97 -0
- package/dist/agents/thinking-fallback.js.map +1 -0
- package/dist/agents/tool-guard.d.ts +71 -0
- package/dist/agents/tool-guard.d.ts.map +1 -0
- package/dist/agents/tool-guard.js +154 -0
- package/dist/agents/tool-guard.js.map +1 -0
- package/dist/agents/tool-loop-detector.d.ts +115 -0
- package/dist/agents/tool-loop-detector.d.ts.map +1 -0
- package/dist/agents/tool-loop-detector.js +0 -0
- package/dist/agents/tool-loop-detector.js.map +1 -0
- package/dist/agents/tool-summaries.d.ts +3 -0
- package/dist/agents/tool-summaries.d.ts.map +1 -0
- package/dist/agents/tool-summaries.js +78 -0
- package/dist/agents/tool-summaries.js.map +1 -0
- package/dist/agents/tools/agents-list-tool.d.ts +51 -0
- package/dist/agents/tools/agents-list-tool.d.ts.map +1 -0
- package/dist/agents/tools/agents-list-tool.js +167 -0
- package/dist/agents/tools/agents-list-tool.js.map +1 -0
- package/dist/agents/tools/browser.d.ts +144 -0
- package/dist/agents/tools/browser.d.ts.map +1 -0
- package/dist/agents/tools/browser.js +1538 -0
- package/dist/agents/tools/browser.js.map +1 -0
- package/dist/agents/tools/common.d.ts +208 -0
- package/dist/agents/tools/common.d.ts.map +1 -0
- package/dist/agents/tools/common.js +405 -0
- package/dist/agents/tools/common.js.map +1 -0
- package/dist/agents/tools/composio-tool.d.ts +179 -0
- package/dist/agents/tools/composio-tool.d.ts.map +1 -0
- package/dist/agents/tools/composio-tool.js +474 -0
- package/dist/agents/tools/composio-tool.js.map +1 -0
- package/dist/agents/tools/cron-tool.d.ts +187 -0
- package/dist/agents/tools/cron-tool.d.ts.map +1 -0
- package/dist/agents/tools/cron-tool.js +985 -0
- package/dist/agents/tools/cron-tool.js.map +1 -0
- package/dist/agents/tools/find-tool.d.ts +55 -0
- package/dist/agents/tools/find-tool.d.ts.map +1 -0
- package/dist/agents/tools/find-tool.js +163 -0
- package/dist/agents/tools/find-tool.js.map +1 -0
- package/dist/agents/tools/generate-image-tool.d.ts +77 -0
- package/dist/agents/tools/generate-image-tool.d.ts.map +1 -0
- package/dist/agents/tools/generate-image-tool.js +421 -0
- package/dist/agents/tools/generate-image-tool.js.map +1 -0
- package/dist/agents/tools/index.d.ts +14 -0
- package/dist/agents/tools/index.d.ts.map +1 -0
- package/dist/agents/tools/index.js +12 -0
- package/dist/agents/tools/index.js.map +1 -0
- package/dist/agents/tools/manage-access-tool.d.ts +64 -0
- package/dist/agents/tools/manage-access-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-access-tool.js +188 -0
- package/dist/agents/tools/manage-access-tool.js.map +1 -0
- package/dist/agents/tools/manage-agent-tool.d.ts +50 -0
- package/dist/agents/tools/manage-agent-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-agent-tool.js +232 -0
- package/dist/agents/tools/manage-agent-tool.js.map +1 -0
- package/dist/agents/tools/manage-channel-access-tool.d.ts +44 -0
- package/dist/agents/tools/manage-channel-access-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-channel-access-tool.js +144 -0
- package/dist/agents/tools/manage-channel-access-tool.js.map +1 -0
- package/dist/agents/tools/manage-memory-tool.d.ts +30 -0
- package/dist/agents/tools/manage-memory-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-memory-tool.js +309 -0
- package/dist/agents/tools/manage-memory-tool.js.map +1 -0
- package/dist/agents/tools/manage-provider-tool.d.ts +65 -0
- package/dist/agents/tools/manage-provider-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-provider-tool.js +249 -0
- package/dist/agents/tools/manage-provider-tool.js.map +1 -0
- package/dist/agents/tools/manage-skill-tool.d.ts +121 -0
- package/dist/agents/tools/manage-skill-tool.d.ts.map +1 -0
- package/dist/agents/tools/manage-skill-tool.js +722 -0
- package/dist/agents/tools/manage-skill-tool.js.map +1 -0
- package/dist/agents/tools/memory-tools.d.ts +172 -0
- package/dist/agents/tools/memory-tools.d.ts.map +1 -0
- package/dist/agents/tools/memory-tools.js +561 -0
- package/dist/agents/tools/memory-tools.js.map +1 -0
- package/dist/agents/tools/oauth-authorize-tool.d.ts +94 -0
- package/dist/agents/tools/oauth-authorize-tool.d.ts.map +1 -0
- package/dist/agents/tools/oauth-authorize-tool.js +670 -0
- package/dist/agents/tools/oauth-authorize-tool.js.map +1 -0
- package/dist/agents/tools/org-tool.d.ts +208 -0
- package/dist/agents/tools/org-tool.d.ts.map +1 -0
- package/dist/agents/tools/org-tool.js +790 -0
- package/dist/agents/tools/org-tool.js.map +1 -0
- package/dist/agents/tools/registry.d.ts +146 -0
- package/dist/agents/tools/registry.d.ts.map +1 -0
- package/dist/agents/tools/registry.js +396 -0
- package/dist/agents/tools/registry.js.map +1 -0
- package/dist/agents/tools/send-media-tool.d.ts +92 -0
- package/dist/agents/tools/send-media-tool.d.ts.map +1 -0
- package/dist/agents/tools/send-media-tool.js +512 -0
- package/dist/agents/tools/send-media-tool.js.map +1 -0
- package/dist/agents/tools/send-message-tool.d.ts +84 -0
- package/dist/agents/tools/send-message-tool.d.ts.map +1 -0
- package/dist/agents/tools/send-message-tool.js +226 -0
- package/dist/agents/tools/send-message-tool.js.map +1 -0
- package/dist/agents/tools/sessions/history.d.ts +53 -0
- package/dist/agents/tools/sessions/history.d.ts.map +1 -0
- package/dist/agents/tools/sessions/history.js +138 -0
- package/dist/agents/tools/sessions/history.js.map +1 -0
- package/dist/agents/tools/sessions/index.d.ts +92 -0
- package/dist/agents/tools/sessions/index.d.ts.map +1 -0
- package/dist/agents/tools/sessions/index.js +125 -0
- package/dist/agents/tools/sessions/index.js.map +1 -0
- package/dist/agents/tools/sessions/list.d.ts +53 -0
- package/dist/agents/tools/sessions/list.d.ts.map +1 -0
- package/dist/agents/tools/sessions/list.js +134 -0
- package/dist/agents/tools/sessions/list.js.map +1 -0
- package/dist/agents/tools/sessions/resolve-access.d.ts +34 -0
- package/dist/agents/tools/sessions/resolve-access.d.ts.map +1 -0
- package/dist/agents/tools/sessions/resolve-access.js +67 -0
- package/dist/agents/tools/sessions/resolve-access.js.map +1 -0
- package/dist/agents/tools/sessions/send.d.ts +68 -0
- package/dist/agents/tools/sessions/send.d.ts.map +1 -0
- package/dist/agents/tools/sessions/send.js +556 -0
- package/dist/agents/tools/sessions/send.js.map +1 -0
- package/dist/agents/tools/sessions/shared.d.ts +145 -0
- package/dist/agents/tools/sessions/shared.d.ts.map +1 -0
- package/dist/agents/tools/sessions/shared.js +352 -0
- package/dist/agents/tools/sessions/shared.js.map +1 -0
- package/dist/agents/tools/sessions/spawn.d.ts +71 -0
- package/dist/agents/tools/sessions/spawn.d.ts.map +1 -0
- package/dist/agents/tools/sessions/spawn.js +132 -0
- package/dist/agents/tools/sessions/spawn.js.map +1 -0
- package/dist/agents/tools/spawn-agent-tool.d.ts +87 -0
- package/dist/agents/tools/spawn-agent-tool.d.ts.map +1 -0
- package/dist/agents/tools/spawn-agent-tool.js +189 -0
- package/dist/agents/tools/spawn-agent-tool.js.map +1 -0
- package/dist/agents/tools/spawn-agents-tool.d.ts +75 -0
- package/dist/agents/tools/spawn-agents-tool.d.ts.map +1 -0
- package/dist/agents/tools/spawn-agents-tool.js +267 -0
- package/dist/agents/tools/spawn-agents-tool.js.map +1 -0
- package/dist/agents/tools/types.d.ts +55 -0
- package/dist/agents/tools/types.d.ts.map +1 -0
- package/dist/agents/tools/types.js +28 -0
- package/dist/agents/tools/types.js.map +1 -0
- package/dist/agents/tools/web-fetch-utils.d.ts +114 -0
- package/dist/agents/tools/web-fetch-utils.d.ts.map +1 -0
- package/dist/agents/tools/web-fetch-utils.js +560 -0
- package/dist/agents/tools/web-fetch-utils.js.map +1 -0
- package/dist/agents/tools/web-fetch.d.ts +97 -0
- package/dist/agents/tools/web-fetch.d.ts.map +1 -0
- package/dist/agents/tools/web-fetch.js +369 -0
- package/dist/agents/tools/web-fetch.js.map +1 -0
- package/dist/agents/tools/web-retry.d.ts +55 -0
- package/dist/agents/tools/web-retry.d.ts.map +1 -0
- package/dist/agents/tools/web-retry.js +172 -0
- package/dist/agents/tools/web-retry.js.map +1 -0
- package/dist/agents/tools/web-search.d.ts +96 -0
- package/dist/agents/tools/web-search.d.ts.map +1 -0
- package/dist/agents/tools/web-search.js +459 -0
- package/dist/agents/tools/web-search.js.map +1 -0
- package/dist/agents/tools/web-shared.d.ts +123 -0
- package/dist/agents/tools/web-shared.d.ts.map +1 -0
- package/dist/agents/tools/web-shared.js +207 -0
- package/dist/agents/tools/web-shared.js.map +1 -0
- package/dist/assets/brigade-favicon.png +0 -0
- package/dist/auth/profile-cooldown.d.ts +105 -0
- package/dist/auth/profile-cooldown.d.ts.map +1 -0
- package/dist/auth/profile-cooldown.js +466 -0
- package/dist/auth/profile-cooldown.js.map +1 -0
- package/dist/auth/profiles.d.ts +93 -0
- package/dist/auth/profiles.d.ts.map +1 -0
- package/dist/auth/profiles.js +321 -0
- package/dist/auth/profiles.js.map +1 -0
- package/dist/buildstamp.json +1 -0
- package/dist/cli/argv.d.ts +20 -0
- package/dist/cli/argv.d.ts.map +1 -0
- package/dist/cli/argv.js +47 -0
- package/dist/cli/argv.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +19 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/agent.js +297 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/agents-bindings.d.ts +80 -0
- package/dist/cli/commands/agents-bindings.d.ts.map +1 -0
- package/dist/cli/commands/agents-bindings.js +252 -0
- package/dist/cli/commands/agents-bindings.js.map +1 -0
- package/dist/cli/commands/agents-cmd.d.ts +160 -0
- package/dist/cli/commands/agents-cmd.d.ts.map +1 -0
- package/dist/cli/commands/agents-cmd.js +1199 -0
- package/dist/cli/commands/agents-cmd.js.map +1 -0
- package/dist/cli/commands/agents-config.d.ts +102 -0
- package/dist/cli/commands/agents-config.d.ts.map +1 -0
- package/dist/cli/commands/agents-config.js +294 -0
- package/dist/cli/commands/agents-config.js.map +1 -0
- package/dist/cli/commands/agents-shared.d.ts +57 -0
- package/dist/cli/commands/agents-shared.d.ts.map +1 -0
- package/dist/cli/commands/agents-shared.js +83 -0
- package/dist/cli/commands/agents-shared.js.map +1 -0
- package/dist/cli/commands/backup.d.ts +36 -0
- package/dist/cli/commands/backup.d.ts.map +1 -0
- package/dist/cli/commands/backup.js +244 -0
- package/dist/cli/commands/backup.js.map +1 -0
- package/dist/cli/commands/channels.d.ts +106 -0
- package/dist/cli/commands/channels.d.ts.map +1 -0
- package/dist/cli/commands/channels.js +830 -0
- package/dist/cli/commands/channels.js.map +1 -0
- package/dist/cli/commands/chat.d.ts +43 -0
- package/dist/cli/commands/chat.d.ts.map +1 -0
- package/dist/cli/commands/chat.js +84 -0
- package/dist/cli/commands/chat.js.map +1 -0
- package/dist/cli/commands/config-cmd.d.ts +62 -0
- package/dist/cli/commands/config-cmd.d.ts.map +1 -0
- package/dist/cli/commands/config-cmd.js +404 -0
- package/dist/cli/commands/config-cmd.js.map +1 -0
- package/dist/cli/commands/connect.d.ts +73 -0
- package/dist/cli/commands/connect.d.ts.map +1 -0
- package/dist/cli/commands/connect.js +1952 -0
- package/dist/cli/commands/connect.js.map +1 -0
- package/dist/cli/commands/cron.d.ts +58 -0
- package/dist/cli/commands/cron.d.ts.map +1 -0
- package/dist/cli/commands/cron.js +250 -0
- package/dist/cli/commands/cron.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +25 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +618 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/encrypt-cmd.d.ts +12 -0
- package/dist/cli/commands/encrypt-cmd.d.ts.map +1 -0
- package/dist/cli/commands/encrypt-cmd.js +119 -0
- package/dist/cli/commands/encrypt-cmd.js.map +1 -0
- package/dist/cli/commands/exec-cmd.d.ts +55 -0
- package/dist/cli/commands/exec-cmd.d.ts.map +1 -0
- package/dist/cli/commands/exec-cmd.js +253 -0
- package/dist/cli/commands/exec-cmd.js.map +1 -0
- package/dist/cli/commands/gateway-install.d.ts +21 -0
- package/dist/cli/commands/gateway-install.d.ts.map +1 -0
- package/dist/cli/commands/gateway-install.js +71 -0
- package/dist/cli/commands/gateway-install.js.map +1 -0
- package/dist/cli/commands/gateway-supervise.d.ts +102 -0
- package/dist/cli/commands/gateway-supervise.d.ts.map +1 -0
- package/dist/cli/commands/gateway-supervise.js +194 -0
- package/dist/cli/commands/gateway-supervise.js.map +1 -0
- package/dist/cli/commands/gateway.d.ts +58 -0
- package/dist/cli/commands/gateway.d.ts.map +1 -0
- package/dist/cli/commands/gateway.js +497 -0
- package/dist/cli/commands/gateway.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +14 -0
- package/dist/cli/commands/logs.d.ts.map +1 -0
- package/dist/cli/commands/logs.js +93 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/mcp-cmd.d.ts +4 -0
- package/dist/cli/commands/mcp-cmd.d.ts.map +1 -0
- package/dist/cli/commands/mcp-cmd.js +30 -0
- package/dist/cli/commands/mcp-cmd.js.map +1 -0
- package/dist/cli/commands/onboard-config.d.ts +23 -0
- package/dist/cli/commands/onboard-config.d.ts.map +1 -0
- package/dist/cli/commands/onboard-config.js +33 -0
- package/dist/cli/commands/onboard-config.js.map +1 -0
- package/dist/cli/commands/onboard.d.ts +48 -0
- package/dist/cli/commands/onboard.d.ts.map +1 -0
- package/dist/cli/commands/onboard.js +397 -0
- package/dist/cli/commands/onboard.js.map +1 -0
- package/dist/cli/commands/org-cmd.d.ts +87 -0
- package/dist/cli/commands/org-cmd.d.ts.map +1 -0
- package/dist/cli/commands/org-cmd.js +394 -0
- package/dist/cli/commands/org-cmd.js.map +1 -0
- package/dist/cli/commands/org-cmd.templates.d.ts +66 -0
- package/dist/cli/commands/org-cmd.templates.d.ts.map +1 -0
- package/dist/cli/commands/org-cmd.templates.js +145 -0
- package/dist/cli/commands/org-cmd.templates.js.map +1 -0
- package/dist/cli/commands/org-slash.d.ts +107 -0
- package/dist/cli/commands/org-slash.d.ts.map +1 -0
- package/dist/cli/commands/org-slash.js +263 -0
- package/dist/cli/commands/org-slash.js.map +1 -0
- package/dist/cli/commands/pairing.d.ts +33 -0
- package/dist/cli/commands/pairing.d.ts.map +1 -0
- package/dist/cli/commands/pairing.js +155 -0
- package/dist/cli/commands/pairing.js.map +1 -0
- package/dist/cli/commands/secrets-audit.d.ts +17 -0
- package/dist/cli/commands/secrets-audit.d.ts.map +1 -0
- package/dist/cli/commands/secrets-audit.js +109 -0
- package/dist/cli/commands/secrets-audit.js.map +1 -0
- package/dist/cli/commands/sessions.d.ts +22 -0
- package/dist/cli/commands/sessions.d.ts.map +1 -0
- package/dist/cli/commands/sessions.js +99 -0
- package/dist/cli/commands/sessions.js.map +1 -0
- package/dist/cli/commands/skills.d.ts +17 -0
- package/dist/cli/commands/skills.d.ts.map +1 -0
- package/dist/cli/commands/skills.js +100 -0
- package/dist/cli/commands/skills.js.map +1 -0
- package/dist/cli/commands/status.d.ts +26 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +252 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/store-cmd.d.ts +36 -0
- package/dist/cli/commands/store-cmd.d.ts.map +1 -0
- package/dist/cli/commands/store-cmd.js +405 -0
- package/dist/cli/commands/store-cmd.js.map +1 -0
- package/dist/cli/flows/web-setup.d.ts +47 -0
- package/dist/cli/flows/web-setup.d.ts.map +1 -0
- package/dist/cli/flows/web-setup.js +324 -0
- package/dist/cli/flows/web-setup.js.map +1 -0
- package/dist/cli/program/build-program.d.ts +3 -0
- package/dist/cli/program/build-program.d.ts.map +1 -0
- package/dist/cli/program/build-program.js +1326 -0
- package/dist/cli/program/build-program.js.map +1 -0
- package/dist/cli/run-main.d.ts +2 -0
- package/dist/cli/run-main.d.ts.map +1 -0
- package/dist/cli/run-main.js +63 -0
- package/dist/cli/run-main.js.map +1 -0
- package/dist/config/agent-limits.d.ts +22 -0
- package/dist/config/agent-limits.d.ts.map +1 -0
- package/dist/config/agent-limits.js +34 -0
- package/dist/config/agent-limits.js.map +1 -0
- package/dist/config/io.d.ts +378 -0
- package/dist/config/io.d.ts.map +1 -0
- package/dist/config/io.js +602 -0
- package/dist/config/io.js.map +1 -0
- package/dist/config/paths.d.ts +80 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +342 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/types.d.ts +12 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +12 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/agent-dispatcher.d.ts +91 -0
- package/dist/core/agent-dispatcher.d.ts.map +1 -0
- package/dist/core/agent-dispatcher.js +251 -0
- package/dist/core/agent-dispatcher.js.map +1 -0
- package/dist/core/agent-events-stream.d.ts +76 -0
- package/dist/core/agent-events-stream.d.ts.map +1 -0
- package/dist/core/agent-events-stream.js +185 -0
- package/dist/core/agent-events-stream.js.map +1 -0
- package/dist/core/agent-runtime-persist.d.ts +53 -0
- package/dist/core/agent-runtime-persist.d.ts.map +1 -0
- package/dist/core/agent-runtime-persist.js +114 -0
- package/dist/core/agent-runtime-persist.js.map +1 -0
- package/dist/core/auth-bridge.d.ts +8 -0
- package/dist/core/auth-bridge.d.ts.map +1 -0
- package/dist/core/auth-bridge.js +102 -0
- package/dist/core/auth-bridge.js.map +1 -0
- package/dist/core/auth-error.d.ts +49 -0
- package/dist/core/auth-error.d.ts.map +1 -0
- package/dist/core/auth-error.js.map +1 -0
- package/dist/core/brigade-config.d.ts +205 -0
- package/dist/core/brigade-config.d.ts.map +1 -0
- package/dist/core/brigade-config.js +58 -6
- package/dist/core/brigade-config.js.map +1 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +92 -246
- package/dist/core/config.js.map +1 -0
- package/dist/core/console-stream.d.ts +52 -0
- package/dist/core/console-stream.d.ts.map +1 -0
- package/dist/core/console-stream.js +49 -3
- package/dist/core/console-stream.js.map +1 -0
- package/dist/core/daemon/launchd.d.ts +19 -0
- package/dist/core/daemon/launchd.d.ts.map +1 -0
- package/dist/core/daemon/launchd.js +117 -0
- package/dist/core/daemon/launchd.js.map +1 -0
- package/dist/core/daemon/schtasks.d.ts +23 -0
- package/dist/core/daemon/schtasks.d.ts.map +1 -0
- package/dist/core/daemon/schtasks.js +139 -0
- package/dist/core/daemon/schtasks.js.map +1 -0
- package/dist/core/daemon/service.d.ts +56 -0
- package/dist/core/daemon/service.d.ts.map +1 -0
- package/dist/core/daemon/service.js +54 -0
- package/dist/core/daemon/service.js.map +1 -0
- package/dist/core/daemon/systemd.d.ts +19 -0
- package/dist/core/daemon/systemd.d.ts.map +1 -0
- package/dist/core/daemon/systemd.js +117 -0
- package/dist/core/daemon/systemd.js.map +1 -0
- package/dist/core/event-logger.d.ts +74 -0
- package/dist/core/event-logger.d.ts.map +1 -0
- package/dist/core/event-logger.js +299 -6
- package/dist/core/event-logger.js.map +1 -0
- package/dist/core/exec-approvals.d.ts +178 -0
- package/dist/core/exec-approvals.d.ts.map +1 -0
- package/dist/core/exec-approvals.js +591 -266
- package/dist/core/exec-approvals.js.map +1 -0
- package/dist/core/extension-lifecycle.d.ts +27 -0
- package/dist/core/extension-lifecycle.d.ts.map +1 -0
- package/dist/core/extension-lifecycle.js +45 -0
- package/dist/core/extension-lifecycle.js.map +1 -0
- package/dist/core/gateway-caller-impl.d.ts +42 -0
- package/dist/core/gateway-caller-impl.d.ts.map +1 -0
- package/dist/core/gateway-caller-impl.js +95 -0
- package/dist/core/gateway-caller-impl.js.map +1 -0
- package/dist/core/gateway-lock.d.ts +88 -0
- package/dist/core/gateway-lock.d.ts.map +1 -0
- package/dist/core/gateway-lock.js +204 -0
- package/dist/core/gateway-lock.js.map +1 -0
- package/dist/core/gateway-probe.d.ts +148 -0
- package/dist/core/gateway-probe.d.ts.map +1 -0
- package/dist/core/gateway-probe.js +319 -0
- package/dist/core/gateway-probe.js.map +1 -0
- package/dist/core/gateway-spawn.d.ts +40 -0
- package/dist/core/gateway-spawn.d.ts.map +1 -0
- package/dist/core/gateway-spawn.js +156 -0
- package/dist/core/gateway-spawn.js.map +1 -0
- package/dist/core/model-caps.d.ts +85 -0
- package/dist/core/model-caps.d.ts.map +1 -0
- package/dist/core/model-caps.js +88 -2
- package/dist/core/model-caps.js.map +1 -0
- package/dist/core/port-inspect.d.ts +37 -0
- package/dist/core/port-inspect.d.ts.map +1 -0
- package/dist/core/port-inspect.js +165 -0
- package/dist/core/port-inspect.js.map +1 -0
- package/dist/core/server-lanes.d.ts +25 -0
- package/dist/core/server-lanes.d.ts.map +1 -0
- package/dist/core/server-lanes.js +31 -0
- package/dist/core/server-lanes.js.map +1 -0
- package/dist/core/server-methods/cron.d.ts +104 -0
- package/dist/core/server-methods/cron.d.ts.map +1 -0
- package/dist/core/server-methods/cron.js +183 -0
- package/dist/core/server-methods/cron.js.map +1 -0
- package/dist/core/server-methods/health.d.ts +36 -0
- package/dist/core/server-methods/health.d.ts.map +1 -0
- package/dist/core/server-methods/health.js +51 -0
- package/dist/core/server-methods/health.js.map +1 -0
- package/dist/core/server-methods/org.d.ts +93 -0
- package/dist/core/server-methods/org.d.ts.map +1 -0
- package/dist/core/server-methods/org.js +95 -0
- package/dist/core/server-methods/org.js.map +1 -0
- package/dist/core/server-methods/sessions.d.ts +133 -0
- package/dist/core/server-methods/sessions.d.ts.map +1 -0
- package/dist/core/server-methods/sessions.js +209 -0
- package/dist/core/server-methods/sessions.js.map +1 -0
- package/dist/core/server.d.ts +46 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +4716 -249
- package/dist/core/server.js.map +1 -0
- package/dist/core/system-prompt.d.ts +92 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +180 -1584
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/version.d.ts +4 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +8 -13
- package/dist/core/version.js.map +1 -0
- package/dist/core/webhook-guards.d.ts +131 -0
- package/dist/core/webhook-guards.d.ts.map +1 -0
- package/dist/core/webhook-guards.js +283 -0
- package/dist/core/webhook-guards.js.map +1 -0
- package/dist/core/ws-subscription-filter.d.ts +9 -0
- package/dist/core/ws-subscription-filter.d.ts.map +1 -0
- package/dist/core/ws-subscription-filter.js +39 -0
- package/dist/core/ws-subscription-filter.js.map +1 -0
- package/dist/cron/active-service.d.ts +30 -0
- package/dist/cron/active-service.d.ts.map +1 -0
- package/dist/cron/active-service.js +48 -0
- package/dist/cron/active-service.js.map +1 -0
- package/dist/cron/isolated-agent/run-executor.d.ts +49 -0
- package/dist/cron/isolated-agent/run-executor.d.ts.map +1 -0
- package/dist/cron/isolated-agent/run-executor.js +343 -0
- package/dist/cron/isolated-agent/run-executor.js.map +1 -0
- package/dist/cron/isolated-agent/run.d.ts +27 -0
- package/dist/cron/isolated-agent/run.d.ts.map +1 -0
- package/dist/cron/isolated-agent/run.js +29 -0
- package/dist/cron/isolated-agent/run.js.map +1 -0
- package/dist/cron/normalize.d.ts +103 -0
- package/dist/cron/normalize.d.ts.map +1 -0
- package/dist/cron/normalize.js +376 -0
- package/dist/cron/normalize.js.map +1 -0
- package/dist/cron/parse.d.ts +27 -0
- package/dist/cron/parse.d.ts.map +1 -0
- package/dist/cron/parse.js +55 -0
- package/dist/cron/parse.js.map +1 -0
- package/dist/cron/reminder-context.d.ts +78 -0
- package/dist/cron/reminder-context.d.ts.map +1 -0
- package/dist/cron/reminder-context.js +167 -0
- package/dist/cron/reminder-context.js.map +1 -0
- package/dist/cron/run-log.d.ts +48 -0
- package/dist/cron/run-log.d.ts.map +1 -0
- package/dist/cron/run-log.js +225 -0
- package/dist/cron/run-log.js.map +1 -0
- package/dist/cron/schedule.d.ts +46 -0
- package/dist/cron/schedule.d.ts.map +1 -0
- package/dist/cron/schedule.js +144 -0
- package/dist/cron/schedule.js.map +1 -0
- package/dist/cron/service/jobs.d.ts +138 -0
- package/dist/cron/service/jobs.d.ts.map +1 -0
- package/dist/cron/service/jobs.js +370 -0
- package/dist/cron/service/jobs.js.map +1 -0
- package/dist/cron/service/locked.d.ts +46 -0
- package/dist/cron/service/locked.d.ts.map +1 -0
- package/dist/cron/service/locked.js +54 -0
- package/dist/cron/service/locked.js.map +1 -0
- package/dist/cron/service/ops.d.ts +124 -0
- package/dist/cron/service/ops.d.ts.map +1 -0
- package/dist/cron/service/ops.js +415 -0
- package/dist/cron/service/ops.js.map +1 -0
- package/dist/cron/service/state.d.ts +254 -0
- package/dist/cron/service/state.d.ts.map +1 -0
- package/dist/cron/service/state.js +50 -0
- package/dist/cron/service/state.js.map +1 -0
- package/dist/cron/service/store.d.ts +65 -0
- package/dist/cron/service/store.d.ts.map +1 -0
- package/dist/cron/service/store.js +350 -0
- package/dist/cron/service/store.js.map +1 -0
- package/dist/cron/service/timer.d.ts +113 -0
- package/dist/cron/service/timer.d.ts.map +1 -0
- package/dist/cron/service/timer.js +1081 -0
- package/dist/cron/service/timer.js.map +1 -0
- package/dist/cron/session-reaper.d.ts +62 -0
- package/dist/cron/session-reaper.d.ts.map +1 -0
- package/dist/cron/session-reaper.js +152 -0
- package/dist/cron/session-reaper.js.map +1 -0
- package/dist/cron/session-target.d.ts +56 -0
- package/dist/cron/session-target.d.ts.map +1 -0
- package/dist/cron/session-target.js +96 -0
- package/dist/cron/session-target.js.map +1 -0
- package/dist/cron/stagger.d.ts +34 -0
- package/dist/cron/stagger.d.ts.map +1 -0
- package/dist/cron/stagger.js +69 -0
- package/dist/cron/stagger.js.map +1 -0
- package/dist/cron/types.d.ts +287 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +22 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/cron/validate-timestamp.d.ts +33 -0
- package/dist/cron/validate-timestamp.d.ts.map +1 -0
- package/dist/cron/validate-timestamp.js +54 -0
- package/dist/cron/validate-timestamp.js.map +1 -0
- package/dist/entry.d.ts +2 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +57 -0
- package/dist/entry.js.map +1 -0
- package/dist/extension-sdk.d.ts +28 -0
- package/dist/extension-sdk.d.ts.map +1 -0
- package/dist/extension-sdk.js +26 -0
- package/dist/extension-sdk.js.map +1 -0
- package/dist/identity/device.d.ts +19 -0
- package/dist/identity/device.d.ts.map +1 -0
- package/dist/identity/device.js +88 -0
- package/dist/identity/device.js.map +1 -0
- package/dist/infra/backoff.d.ts +24 -0
- package/dist/infra/backoff.d.ts.map +1 -0
- package/dist/infra/backoff.js +48 -0
- package/dist/infra/backoff.js.map +1 -0
- package/dist/infra/errors.d.ts +35 -0
- package/dist/infra/errors.d.ts.map +1 -0
- package/dist/infra/errors.js +54 -0
- package/dist/infra/errors.js.map +1 -0
- package/dist/infra/fs/atomic-rename.d.ts +31 -0
- package/dist/infra/fs/atomic-rename.d.ts.map +1 -0
- package/dist/infra/fs/atomic-rename.js +75 -0
- package/dist/infra/fs/atomic-rename.js.map +1 -0
- package/dist/infra/json-file.d.ts +25 -0
- package/dist/infra/json-file.d.ts.map +1 -0
- package/dist/infra/json-file.js +49 -0
- package/dist/infra/json-file.js.map +1 -0
- package/dist/infra/json-utf8-bytes.d.ts +14 -0
- package/dist/infra/json-utf8-bytes.d.ts.map +1 -0
- package/dist/infra/json-utf8-bytes.js +20 -0
- package/dist/infra/json-utf8-bytes.js.map +1 -0
- package/dist/infra/net/dns-pinning.d.ts +66 -0
- package/dist/infra/net/dns-pinning.d.ts.map +1 -0
- package/dist/infra/net/dns-pinning.js +128 -0
- package/dist/infra/net/dns-pinning.js.map +1 -0
- package/dist/infra/net/fetch-guard.d.ts +85 -0
- package/dist/infra/net/fetch-guard.d.ts.map +1 -0
- package/dist/infra/net/fetch-guard.js +439 -0
- package/dist/infra/net/fetch-guard.js.map +1 -0
- package/dist/infra/prototype-keys.d.ts +19 -0
- package/dist/infra/prototype-keys.d.ts.map +1 -0
- package/dist/infra/prototype-keys.js +22 -0
- package/dist/infra/prototype-keys.js.map +1 -0
- package/dist/integrations/ollama.d.ts +67 -0
- package/dist/integrations/ollama.d.ts.map +1 -0
- package/dist/integrations/ollama.js +53 -0
- package/dist/integrations/ollama.js.map +1 -0
- package/dist/integrations/provider-discovery.d.ts +66 -0
- package/dist/integrations/provider-discovery.d.ts.map +1 -0
- package/dist/integrations/provider-discovery.js +166 -0
- package/dist/integrations/provider-discovery.js.map +1 -0
- package/dist/logging/redact.d.ts +28 -0
- package/dist/logging/redact.d.ts.map +1 -0
- package/dist/logging/redact.js +51 -0
- package/dist/logging/redact.js.map +1 -0
- package/dist/logging/subsystem-logger.d.ts +77 -0
- package/dist/logging/subsystem-logger.d.ts.map +1 -0
- package/dist/logging/subsystem-logger.js +577 -0
- package/dist/logging/subsystem-logger.js.map +1 -0
- package/dist/logging/subsystem.d.ts +13 -0
- package/dist/logging/subsystem.d.ts.map +1 -0
- package/dist/logging/subsystem.js +12 -0
- package/dist/logging/subsystem.js.map +1 -0
- package/dist/process/command-queue.d.ts +152 -0
- package/dist/process/command-queue.d.ts.map +1 -0
- package/dist/process/command-queue.js +420 -0
- package/dist/process/command-queue.js.map +1 -0
- package/dist/process/lanes.d.ts +102 -0
- package/dist/process/lanes.d.ts.map +1 -0
- package/dist/process/lanes.js +117 -0
- package/dist/process/lanes.js.map +1 -0
- package/dist/process/session-lane.d.ts +31 -0
- package/dist/process/session-lane.d.ts.map +1 -0
- package/dist/process/session-lane.js +45 -0
- package/dist/process/session-lane.js.map +1 -0
- package/dist/protocol/errors.d.ts +35 -0
- package/dist/protocol/errors.d.ts.map +1 -0
- package/dist/protocol/errors.js +36 -0
- package/dist/protocol/errors.js.map +1 -0
- package/dist/protocol/handshake.d.ts +101 -0
- package/dist/protocol/handshake.d.ts.map +1 -0
- package/dist/protocol/handshake.js +49 -0
- package/dist/protocol/handshake.js.map +1 -0
- package/dist/protocol/messages.d.ts +68 -0
- package/dist/protocol/messages.d.ts.map +1 -0
- package/dist/protocol/messages.js +20 -0
- package/dist/protocol/messages.js.map +1 -0
- package/dist/protocol/methods.d.ts +312 -0
- package/dist/protocol/methods.d.ts.map +1 -0
- package/dist/protocol/methods.js +16 -0
- package/dist/protocol/methods.js.map +1 -0
- package/dist/protocol.d.ts +598 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +12 -0
- package/dist/protocol.js.map +1 -0
- package/dist/providers/auth-methods.d.ts +82 -0
- package/dist/providers/auth-methods.d.ts.map +1 -0
- package/dist/providers/auth-methods.js +180 -0
- package/dist/providers/auth-methods.js.map +1 -0
- package/dist/providers/catalog.d.ts +85 -0
- package/dist/providers/catalog.d.ts.map +1 -0
- package/dist/providers/catalog.js +41 -0
- package/dist/providers/catalog.js.map +1 -0
- package/dist/providers/validate-key.d.ts +42 -0
- package/dist/providers/validate-key.d.ts.map +1 -0
- package/dist/providers/validate-key.js.map +1 -0
- package/dist/security/external-content.d.ts +67 -0
- package/dist/security/external-content.d.ts.map +1 -0
- package/dist/security/external-content.js +80 -0
- package/dist/security/external-content.js.map +1 -0
- package/dist/security/injection-patterns.d.ts +33 -0
- package/dist/security/injection-patterns.d.ts.map +1 -0
- package/dist/security/injection-patterns.js +97 -0
- package/dist/security/injection-patterns.js.map +1 -0
- package/dist/security/media-path-guard.d.ts +25 -0
- package/dist/security/media-path-guard.d.ts.map +1 -0
- package/dist/security/media-path-guard.js +98 -0
- package/dist/security/media-path-guard.js.map +1 -0
- package/dist/security/terminal-input-sanitizer.d.ts +30 -0
- package/dist/security/terminal-input-sanitizer.d.ts.map +1 -0
- package/dist/security/terminal-input-sanitizer.js +70 -0
- package/dist/security/terminal-input-sanitizer.js.map +1 -0
- package/dist/sessions/bootstrap-marker.d.ts +5 -0
- package/dist/sessions/bootstrap-marker.d.ts.map +1 -0
- package/dist/sessions/bootstrap-marker.js +120 -0
- package/dist/sessions/bootstrap-marker.js.map +1 -0
- package/dist/sessions/session-file-repair.d.ts +12 -0
- package/dist/sessions/session-file-repair.d.ts.map +1 -0
- package/dist/sessions/session-file-repair.js +155 -0
- package/dist/sessions/session-file-repair.js.map +1 -0
- package/dist/sessions/session-key-utils.d.ts +54 -0
- package/dist/sessions/session-key-utils.d.ts.map +1 -0
- package/dist/sessions/session-key-utils.js +133 -0
- package/dist/sessions/session-key-utils.js.map +1 -0
- package/dist/sessions/session-manager-factory.d.ts +21 -0
- package/dist/sessions/session-manager-factory.d.ts.map +1 -0
- package/dist/sessions/session-manager-factory.js +142 -0
- package/dist/sessions/session-manager-factory.js.map +1 -0
- package/dist/sessions/session-store.d.ts +154 -0
- package/dist/sessions/session-store.d.ts.map +1 -0
- package/dist/sessions/session-store.js +498 -0
- package/dist/sessions/session-store.js.map +1 -0
- package/dist/sessions/session-write-lock.d.ts +10 -0
- package/dist/sessions/session-write-lock.d.ts.map +1 -0
- package/dist/sessions/session-write-lock.js +167 -0
- package/dist/sessions/session-write-lock.js.map +1 -0
- package/dist/sessions/transcript-reader.d.ts +37 -0
- package/dist/sessions/transcript-reader.d.ts.map +1 -0
- package/dist/sessions/transcript-reader.js +136 -0
- package/dist/sessions/transcript-reader.js.map +1 -0
- package/dist/sessions/transcript-repair.d.ts +16 -0
- package/dist/sessions/transcript-repair.d.ts.map +1 -0
- package/dist/sessions/transcript-repair.js +214 -0
- package/dist/sessions/transcript-repair.js.map +1 -0
- package/dist/shared/global-singleton.d.ts +27 -0
- package/dist/shared/global-singleton.d.ts.map +1 -0
- package/dist/shared/global-singleton.js +35 -0
- package/dist/shared/global-singleton.js.map +1 -0
- package/dist/shared/string-coerce.d.ts +12 -0
- package/dist/shared/string-coerce.d.ts.map +1 -0
- package/dist/shared/string-coerce.js +12 -0
- package/dist/shared/string-coerce.js.map +1 -0
- package/dist/storage/boot.d.ts +28 -0
- package/dist/storage/boot.d.ts.map +1 -0
- package/dist/storage/boot.js +588 -0
- package/dist/storage/boot.js.map +1 -0
- package/dist/storage/config-cache.d.ts +23 -0
- package/dist/storage/config-cache.d.ts.map +1 -0
- package/dist/storage/config-cache.js +58 -0
- package/dist/storage/config-cache.js.map +1 -0
- package/dist/storage/convex/auth-store.d.ts +52 -0
- package/dist/storage/convex/auth-store.d.ts.map +1 -0
- package/dist/storage/convex/auth-store.js +282 -0
- package/dist/storage/convex/auth-store.js.map +1 -0
- package/dist/storage/convex/blob-store.d.ts +20 -0
- package/dist/storage/convex/blob-store.d.ts.map +1 -0
- package/dist/storage/convex/blob-store.js +74 -0
- package/dist/storage/convex/blob-store.js.map +1 -0
- package/dist/storage/convex/channel-store.d.ts +112 -0
- package/dist/storage/convex/channel-store.d.ts.map +1 -0
- package/dist/storage/convex/channel-store.js +267 -0
- package/dist/storage/convex/channel-store.js.map +1 -0
- package/dist/storage/convex/client.d.ts +53 -0
- package/dist/storage/convex/client.d.ts.map +1 -0
- package/dist/storage/convex/client.js +121 -0
- package/dist/storage/convex/client.js.map +1 -0
- package/dist/storage/convex/config-store.d.ts +29 -0
- package/dist/storage/convex/config-store.d.ts.map +1 -0
- package/dist/storage/convex/config-store.js +205 -0
- package/dist/storage/convex/config-store.js.map +1 -0
- package/dist/storage/convex/cron-store.d.ts +86 -0
- package/dist/storage/convex/cron-store.d.ts.map +1 -0
- package/dist/storage/convex/cron-store.js +428 -0
- package/dist/storage/convex/cron-store.js.map +1 -0
- package/dist/storage/convex/exec-approval-store.d.ts +38 -0
- package/dist/storage/convex/exec-approval-store.d.ts.map +1 -0
- package/dist/storage/convex/exec-approval-store.js +147 -0
- package/dist/storage/convex/exec-approval-store.js.map +1 -0
- package/dist/storage/convex/extension-store.d.ts +28 -0
- package/dist/storage/convex/extension-store.d.ts.map +1 -0
- package/dist/storage/convex/extension-store.js +39 -0
- package/dist/storage/convex/extension-store.js.map +1 -0
- package/dist/storage/convex/index.d.ts +35 -0
- package/dist/storage/convex/index.d.ts.map +1 -0
- package/dist/storage/convex/index.js +141 -0
- package/dist/storage/convex/index.js.map +1 -0
- package/dist/storage/convex/instance-store.d.ts +37 -0
- package/dist/storage/convex/instance-store.d.ts.map +1 -0
- package/dist/storage/convex/instance-store.js +88 -0
- package/dist/storage/convex/instance-store.js.map +1 -0
- package/dist/storage/convex/log-store.d.ts +36 -0
- package/dist/storage/convex/log-store.d.ts.map +1 -0
- package/dist/storage/convex/log-store.js +213 -0
- package/dist/storage/convex/log-store.js.map +1 -0
- package/dist/storage/convex/memory-store.d.ts +50 -0
- package/dist/storage/convex/memory-store.d.ts.map +1 -0
- package/dist/storage/convex/memory-store.js +537 -0
- package/dist/storage/convex/memory-store.js.map +1 -0
- package/dist/storage/convex/message-store.d.ts +32 -0
- package/dist/storage/convex/message-store.d.ts.map +1 -0
- package/dist/storage/convex/message-store.js +272 -0
- package/dist/storage/convex/message-store.js.map +1 -0
- package/dist/storage/convex/org-store.d.ts +46 -0
- package/dist/storage/convex/org-store.d.ts.map +1 -0
- package/dist/storage/convex/org-store.js +101 -0
- package/dist/storage/convex/org-store.js.map +1 -0
- package/dist/storage/convex/session-store.d.ts +44 -0
- package/dist/storage/convex/session-store.d.ts.map +1 -0
- package/dist/storage/convex/session-store.js +257 -0
- package/dist/storage/convex/session-store.js.map +1 -0
- package/dist/storage/convex/skill-store.d.ts +49 -0
- package/dist/storage/convex/skill-store.d.ts.map +1 -0
- package/dist/storage/convex/skill-store.js +84 -0
- package/dist/storage/convex/skill-store.js.map +1 -0
- package/dist/storage/convex/subagent-store.d.ts +28 -0
- package/dist/storage/convex/subagent-store.d.ts.map +1 -0
- package/dist/storage/convex/subagent-store.js +83 -0
- package/dist/storage/convex/subagent-store.js.map +1 -0
- package/dist/storage/convex/workspace-store.d.ts +25 -0
- package/dist/storage/convex/workspace-store.d.ts.map +1 -0
- package/dist/storage/convex/workspace-store.js +127 -0
- package/dist/storage/convex/workspace-store.js.map +1 -0
- package/dist/storage/cron-cache.d.ts +17 -0
- package/dist/storage/cron-cache.d.ts.map +1 -0
- package/dist/storage/cron-cache.js +67 -0
- package/dist/storage/cron-cache.js.map +1 -0
- package/dist/storage/encryption.d.ts +69 -0
- package/dist/storage/encryption.d.ts.map +1 -0
- package/dist/storage/encryption.js +389 -0
- package/dist/storage/encryption.js.map +1 -0
- package/dist/storage/factory-reset.d.ts +7 -0
- package/dist/storage/factory-reset.d.ts.map +1 -0
- package/dist/storage/factory-reset.js +34 -0
- package/dist/storage/factory-reset.js.map +1 -0
- package/dist/storage/facts-cache.d.ts +24 -0
- package/dist/storage/facts-cache.d.ts.map +1 -0
- package/dist/storage/facts-cache.js +110 -0
- package/dist/storage/facts-cache.js.map +1 -0
- package/dist/storage/flush.d.ts +4 -0
- package/dist/storage/flush.d.ts.map +1 -0
- package/dist/storage/flush.js +128 -0
- package/dist/storage/flush.js.map +1 -0
- package/dist/storage/instance-admin.d.ts +52 -0
- package/dist/storage/instance-admin.d.ts.map +1 -0
- package/dist/storage/instance-admin.js +91 -0
- package/dist/storage/instance-admin.js.map +1 -0
- package/dist/storage/local/auth-store.d.ts +44 -0
- package/dist/storage/local/auth-store.d.ts.map +1 -0
- package/dist/storage/local/auth-store.js +252 -0
- package/dist/storage/local/auth-store.js.map +1 -0
- package/dist/storage/local/blob-store.d.ts +14 -0
- package/dist/storage/local/blob-store.d.ts.map +1 -0
- package/dist/storage/local/blob-store.js +87 -0
- package/dist/storage/local/blob-store.js.map +1 -0
- package/dist/storage/local/channel-store.d.ts +107 -0
- package/dist/storage/local/channel-store.d.ts.map +1 -0
- package/dist/storage/local/channel-store.js +147 -0
- package/dist/storage/local/channel-store.js.map +1 -0
- package/dist/storage/local/config-store.d.ts +23 -0
- package/dist/storage/local/config-store.d.ts.map +1 -0
- package/dist/storage/local/config-store.js +98 -0
- package/dist/storage/local/config-store.js.map +1 -0
- package/dist/storage/local/cron-store.d.ts +30 -0
- package/dist/storage/local/cron-store.d.ts.map +1 -0
- package/dist/storage/local/cron-store.js +186 -0
- package/dist/storage/local/cron-store.js.map +1 -0
- package/dist/storage/local/exec-approval-store.d.ts +41 -0
- package/dist/storage/local/exec-approval-store.d.ts.map +1 -0
- package/dist/storage/local/exec-approval-store.js +78 -0
- package/dist/storage/local/exec-approval-store.js.map +1 -0
- package/dist/storage/local/extension-store.d.ts +13 -0
- package/dist/storage/local/extension-store.d.ts.map +1 -0
- package/dist/storage/local/extension-store.js +36 -0
- package/dist/storage/local/extension-store.js.map +1 -0
- package/dist/storage/local/file-watcher.d.ts +24 -0
- package/dist/storage/local/file-watcher.d.ts.map +1 -0
- package/dist/storage/local/file-watcher.js +141 -0
- package/dist/storage/local/file-watcher.js.map +1 -0
- package/dist/storage/local/index.d.ts +33 -0
- package/dist/storage/local/index.d.ts.map +1 -0
- package/dist/storage/local/index.js +143 -0
- package/dist/storage/local/index.js.map +1 -0
- package/dist/storage/local/instance-store.d.ts +30 -0
- package/dist/storage/local/instance-store.d.ts.map +1 -0
- package/dist/storage/local/instance-store.js +83 -0
- package/dist/storage/local/instance-store.js.map +1 -0
- package/dist/storage/local/log-store.d.ts +27 -0
- package/dist/storage/local/log-store.d.ts.map +1 -0
- package/dist/storage/local/log-store.js +185 -0
- package/dist/storage/local/log-store.js.map +1 -0
- package/dist/storage/local/memory-store.d.ts +39 -0
- package/dist/storage/local/memory-store.d.ts.map +1 -0
- package/dist/storage/local/memory-store.js +258 -0
- package/dist/storage/local/memory-store.js.map +1 -0
- package/dist/storage/local/message-store.d.ts +27 -0
- package/dist/storage/local/message-store.d.ts.map +1 -0
- package/dist/storage/local/message-store.js +253 -0
- package/dist/storage/local/message-store.js.map +1 -0
- package/dist/storage/local/org-store.d.ts +39 -0
- package/dist/storage/local/org-store.d.ts.map +1 -0
- package/dist/storage/local/org-store.js +155 -0
- package/dist/storage/local/org-store.js.map +1 -0
- package/dist/storage/local/session-store.d.ts +30 -0
- package/dist/storage/local/session-store.d.ts.map +1 -0
- package/dist/storage/local/session-store.js +82 -0
- package/dist/storage/local/session-store.js.map +1 -0
- package/dist/storage/local/skill-store.d.ts +40 -0
- package/dist/storage/local/skill-store.d.ts.map +1 -0
- package/dist/storage/local/skill-store.js +121 -0
- package/dist/storage/local/skill-store.js.map +1 -0
- package/dist/storage/local/subagent-store.d.ts +20 -0
- package/dist/storage/local/subagent-store.d.ts.map +1 -0
- package/dist/storage/local/subagent-store.js +71 -0
- package/dist/storage/local/subagent-store.js.map +1 -0
- package/dist/storage/local/workspace-store.d.ts +22 -0
- package/dist/storage/local/workspace-store.d.ts.map +1 -0
- package/dist/storage/local/workspace-store.js +190 -0
- package/dist/storage/local/workspace-store.js.map +1 -0
- package/dist/storage/migrate.d.ts +64 -0
- package/dist/storage/migrate.d.ts.map +1 -0
- package/dist/storage/migrate.js +585 -0
- package/dist/storage/migrate.js.map +1 -0
- package/dist/storage/runtime-context.d.ts +35 -0
- package/dist/storage/runtime-context.d.ts.map +1 -0
- package/dist/storage/runtime-context.js +145 -0
- package/dist/storage/runtime-context.js.map +1 -0
- package/dist/storage/sentinel.d.ts +28 -0
- package/dist/storage/sentinel.d.ts.map +1 -0
- package/dist/storage/sentinel.js +98 -0
- package/dist/storage/sentinel.js.map +1 -0
- package/dist/storage/session-cache.d.ts +15 -0
- package/dist/storage/session-cache.d.ts.map +1 -0
- package/dist/storage/session-cache.js +81 -0
- package/dist/storage/session-cache.js.map +1 -0
- package/dist/storage/store.d.ts +745 -0
- package/dist/storage/store.d.ts.map +1 -0
- package/dist/storage/store.js +36 -0
- package/dist/storage/store.js.map +1 -0
- package/dist/storage/strict-guard.d.ts +17 -0
- package/dist/storage/strict-guard.d.ts.map +1 -0
- package/dist/storage/strict-guard.js +200 -0
- package/dist/storage/strict-guard.js.map +1 -0
- package/dist/storage/workspace-live-mirror.d.ts +33 -0
- package/dist/storage/workspace-live-mirror.d.ts.map +1 -0
- package/dist/storage/workspace-live-mirror.js +207 -0
- package/dist/storage/workspace-live-mirror.js.map +1 -0
- package/dist/system-prompt/assembler.d.ts +113 -0
- package/dist/system-prompt/assembler.d.ts.map +1 -0
- package/dist/system-prompt/assembler.js +649 -0
- package/dist/system-prompt/assembler.js.map +1 -0
- package/dist/system-prompt/bootstrap-budget.d.ts +22 -0
- package/dist/system-prompt/bootstrap-budget.d.ts.map +1 -0
- package/dist/system-prompt/bootstrap-budget.js +83 -0
- package/dist/system-prompt/bootstrap-budget.js.map +1 -0
- package/dist/system-prompt/cache-boundary.d.ts +13 -0
- package/dist/system-prompt/cache-boundary.d.ts.map +1 -0
- package/dist/system-prompt/cache-boundary.js +56 -0
- package/dist/system-prompt/cache-boundary.js.map +1 -0
- package/dist/system-prompt/cache-stability.d.ts +3 -0
- package/dist/system-prompt/cache-stability.d.ts.map +1 -0
- package/dist/system-prompt/cache-stability.js +18 -0
- package/dist/system-prompt/cache-stability.js.map +1 -0
- package/dist/system-prompt/guidance.d.ts +147 -0
- package/dist/system-prompt/guidance.d.ts.map +1 -0
- package/dist/system-prompt/guidance.js +352 -0
- package/dist/system-prompt/guidance.js.map +1 -0
- package/dist/system-prompt/identity-defaults.d.ts +50 -0
- package/dist/system-prompt/identity-defaults.d.ts.map +1 -0
- package/dist/system-prompt/identity-defaults.js +119 -0
- package/dist/system-prompt/identity-defaults.js.map +1 -0
- package/dist/system-prompt/org/escalation-inbox.d.ts +53 -0
- package/dist/system-prompt/org/escalation-inbox.d.ts.map +1 -0
- package/dist/system-prompt/org/escalation-inbox.js +71 -0
- package/dist/system-prompt/org/escalation-inbox.js.map +1 -0
- package/dist/system-prompt/org/receiver-hint.d.ts +72 -0
- package/dist/system-prompt/org/receiver-hint.d.ts.map +1 -0
- package/dist/system-prompt/org/receiver-hint.js +116 -0
- package/dist/system-prompt/org/receiver-hint.js.map +1 -0
- package/dist/system-prompt/org/render-org-block.d.ts +42 -0
- package/dist/system-prompt/org/render-org-block.d.ts.map +1 -0
- package/dist/system-prompt/org/render-org-block.js +57 -0
- package/dist/system-prompt/org/render-org-block.js.map +1 -0
- package/dist/system-prompt/org/sub-agent-anchor.d.ts +30 -0
- package/dist/system-prompt/org/sub-agent-anchor.d.ts.map +1 -0
- package/dist/system-prompt/org/sub-agent-anchor.js +36 -0
- package/dist/system-prompt/org/sub-agent-anchor.js.map +1 -0
- package/dist/system-prompt/override.d.ts +7 -0
- package/dist/system-prompt/override.d.ts.map +1 -0
- package/dist/system-prompt/override.js +13 -0
- package/dist/system-prompt/override.js.map +1 -0
- package/dist/system-prompt/pi-injection.d.ts +5 -0
- package/dist/system-prompt/pi-injection.d.ts.map +1 -0
- package/dist/system-prompt/pi-injection.js +33 -0
- package/dist/system-prompt/pi-injection.js.map +1 -0
- package/dist/system-prompt/runtime-params.d.ts +34 -0
- package/dist/system-prompt/runtime-params.d.ts.map +1 -0
- package/dist/system-prompt/runtime-params.js +108 -0
- package/dist/system-prompt/runtime-params.js.map +1 -0
- package/dist/system-prompt/sanitize.d.ts +7 -0
- package/dist/system-prompt/sanitize.d.ts.map +1 -0
- package/dist/system-prompt/sanitize.js +31 -0
- package/dist/system-prompt/sanitize.js.map +1 -0
- package/dist/system-prompt/types.d.ts +7 -0
- package/dist/system-prompt/types.d.ts.map +1 -0
- package/dist/system-prompt/types.js +3 -0
- package/dist/system-prompt/types.js.map +1 -0
- package/dist/system-prompt/workspace-loader.d.ts +12 -0
- package/dist/system-prompt/workspace-loader.d.ts.map +1 -0
- package/dist/system-prompt/workspace-loader.js +115 -0
- package/dist/system-prompt/workspace-loader.js.map +1 -0
- package/dist/tideline/advanced.d.ts +25 -0
- package/dist/tideline/advanced.d.ts.map +1 -0
- package/dist/tideline/advanced.js +34 -0
- package/dist/tideline/advanced.js.map +1 -0
- package/dist/tideline/eval.d.ts +19 -0
- package/dist/tideline/eval.d.ts.map +1 -0
- package/dist/tideline/eval.js +24 -0
- package/dist/tideline/eval.js.map +1 -0
- package/dist/tideline/host-ports.standalone.d.ts +49 -0
- package/dist/tideline/host-ports.standalone.d.ts.map +1 -0
- package/dist/tideline/host-ports.standalone.js +61 -0
- package/dist/tideline/host-ports.standalone.js.map +1 -0
- package/dist/tideline/index.d.ts +34 -0
- package/dist/tideline/index.d.ts.map +1 -0
- package/dist/tideline/index.js +42 -0
- package/dist/tideline/index.js.map +1 -0
- package/dist/tui/approval-prompt.d.ts +73 -0
- package/dist/tui/approval-prompt.d.ts.map +1 -0
- package/dist/tui/approval-prompt.js +272 -0
- package/dist/tui/approval-prompt.js.map +1 -0
- package/dist/tui/client.d.ts +89 -0
- package/dist/tui/client.d.ts.map +1 -0
- package/dist/tui/client.js.map +1 -0
- package/dist/ui/brand-frames-cli.d.ts +19 -0
- package/dist/ui/brand-frames-cli.d.ts.map +1 -0
- package/dist/ui/brand-frames-cli.js +8 -13
- package/dist/ui/brand-frames-cli.js.map +1 -0
- package/dist/ui/brand.d.ts +41 -0
- package/dist/ui/brand.d.ts.map +1 -0
- package/dist/ui/brand.js +28 -6
- package/dist/ui/brand.js.map +1 -0
- package/dist/ui/editor.d.ts +30 -0
- package/dist/ui/editor.d.ts.map +1 -0
- package/dist/ui/editor.js +73 -0
- package/dist/ui/editor.js.map +1 -0
- package/dist/ui/format-session.d.ts +68 -0
- package/dist/ui/format-session.d.ts.map +1 -0
- package/dist/ui/format-session.js +181 -0
- package/dist/ui/format-session.js.map +1 -0
- package/dist/ui/markdown.d.ts +48 -0
- package/dist/ui/markdown.d.ts.map +1 -0
- package/dist/ui/markdown.js +60 -0
- package/dist/ui/markdown.js.map +1 -0
- package/dist/ui/onboard-storage-mode.d.ts +17 -0
- package/dist/ui/onboard-storage-mode.d.ts.map +1 -0
- package/dist/ui/onboard-storage-mode.js +638 -0
- package/dist/ui/onboard-storage-mode.js.map +1 -0
- package/dist/ui/onboarding.d.ts +97 -0
- package/dist/ui/onboarding.d.ts.map +1 -0
- package/dist/ui/onboarding.js +259 -111
- package/dist/ui/onboarding.js.map +1 -0
- package/dist/ui/searchable-select.d.ts +48 -0
- package/dist/ui/searchable-select.d.ts.map +1 -0
- package/dist/ui/searchable-select.js +108 -0
- package/dist/ui/searchable-select.js.map +1 -0
- package/dist/ui/syntax-theme.d.ts +30 -0
- package/dist/ui/syntax-theme.d.ts.map +1 -0
- package/dist/ui/syntax-theme.js +72 -0
- package/dist/ui/syntax-theme.js.map +1 -0
- package/dist/ui/terminal-cleanup.d.ts +46 -0
- package/dist/ui/terminal-cleanup.d.ts.map +1 -0
- package/dist/ui/terminal-cleanup.js +17 -5
- package/dist/ui/terminal-cleanup.js.map +1 -0
- package/dist/ui/theme.d.ts +21 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +66 -2
- package/dist/ui/theme.js.map +1 -0
- package/dist/ui/tool-result.d.ts +47 -0
- package/dist/ui/tool-result.d.ts.map +1 -0
- package/dist/ui/tool-result.js +100 -0
- package/dist/ui/tool-result.js.map +1 -0
- package/dist/utils/delivery-context.d.ts +50 -0
- package/dist/utils/delivery-context.d.ts.map +1 -0
- package/dist/utils/delivery-context.js +82 -0
- package/dist/utils/delivery-context.js.map +1 -0
- package/dist/utils/message-channel.d.ts +60 -0
- package/dist/utils/message-channel.d.ts.map +1 -0
- package/dist/utils/message-channel.js +103 -0
- package/dist/utils/message-channel.js.map +1 -0
- package/dist/utils/string-coerce.d.ts +50 -0
- package/dist/utils/string-coerce.d.ts.map +1 -0
- package/dist/utils/string-coerce.js +101 -0
- package/dist/utils/string-coerce.js.map +1 -0
- package/dist/version.d.ts +20 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +54 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace/bootstrap.d.ts +12 -0
- package/dist/workspace/bootstrap.d.ts.map +1 -0
- package/dist/workspace/bootstrap.js +123 -0
- package/dist/workspace/bootstrap.js.map +1 -0
- package/dist/workspace/fs-utils.d.ts +2 -0
- package/dist/workspace/fs-utils.d.ts.map +1 -0
- package/dist/workspace/fs-utils.js +14 -0
- package/dist/workspace/fs-utils.js.map +1 -0
- package/dist/workspace/git-init.d.ts +5 -0
- package/dist/workspace/git-init.d.ts.map +1 -0
- package/dist/workspace/git-init.js +71 -0
- package/dist/workspace/git-init.js.map +1 -0
- package/dist/workspace/state.d.ts +13 -0
- package/dist/workspace/state.d.ts.map +1 -0
- package/dist/workspace/state.js +128 -0
- package/dist/workspace/state.js.map +1 -0
- package/dist/workspace/template-loader.d.ts +15 -0
- package/dist/workspace/template-loader.d.ts.map +1 -0
- package/dist/workspace/template-loader.js +214 -0
- package/dist/workspace/template-loader.js.map +1 -0
- package/package.json +173 -68
- package/scripts/build-done.mjs +125 -0
- package/scripts/run-brigade.mjs +208 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +118 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +136 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +204 -0
- package/skills/coding-agent/SKILL.md +316 -0
- package/skills/discord/SKILL.md +197 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/gh-issues/SKILL.md +885 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/git-commit/SKILL.md +40 -0
- package/skills/github/SKILL.md +163 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +122 -0
- package/skills/lead-scout/SKILL.md +46 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/node-connect/SKILL.md +142 -0
- package/skills/notion/SKILL.md +174 -0
- package/skills/oauth-setup/SKILL.md +55 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +62 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +88 -0
- package/skills/openhue/SKILL.md +112 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +151 -0
- package/skills/share-skills/SKILL.md +72 -0
- package/skills/sherpa-onnx-tts/SKILL.md +109 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +372 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +139 -0
- package/skills/skill-creator/scripts/quick_validate.py +159 -0
- package/skills/skill-creator/scripts/test_package_skill.py +160 -0
- package/skills/skill-creator/scripts/test_quick_validate.py +72 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +65 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/taskflow/SKILL.md +149 -0
- package/skills/taskflow-inbox-triage/SKILL.md +119 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +170 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +108 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +129 -0
- package/skills/xurl/SKILL.md +461 -0
- package/templates/workspace/AGENTS.md +223 -0
- package/templates/workspace/BOOTSTRAP.md +64 -0
- package/templates/workspace/HEARTBEAT.md +15 -0
- package/templates/workspace/IDENTITY.md +31 -0
- package/templates/workspace/SOUL.md +47 -0
- package/templates/workspace/TOOLS.md +48 -0
- package/templates/workspace/USER.md +25 -0
- package/CHANGELOG.md +0 -48
- package/SECURITY.md +0 -208
- package/assets/brigade-wordmark.png +0 -0
- package/dist/cli/chat-cmd.js +0 -191
- package/dist/cli/config-cmd.js +0 -171
- package/dist/cli/connect-cmd.js +0 -487
- package/dist/cli/doctor-cmd.js +0 -387
- package/dist/cli/gateway-cmd.js +0 -155
- package/dist/cli.js +0 -328
- package/dist/core/agent.js +0 -1123
- package/dist/core/auth-label.js +0 -147
- package/dist/core/cli-error.js +0 -94
- package/dist/core/error-classifier.js +0 -354
- package/dist/core/provider-payload-mutators.js +0 -517
- package/dist/core/provider-quirks.js +0 -285
- package/dist/core/smart-compaction.js +0 -209
- package/dist/core/system-prompt-defaults.js +0 -264
- package/dist/core/system-prompt-guidance.js +0 -271
- package/dist/index.js +0 -32
- package/dist/ui/brand-frames.js +0 -36
- package/dist/ui/chat.js +0 -1008
|
@@ -0,0 +1,1952 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `brigade connect` — TUI that talks to a running `brigade gateway`.
|
|
3
|
+
*
|
|
4
|
+
* This is the thin client. The gateway owns the Pi session, runs the full
|
|
5
|
+
* 6-layer wrapper composition, and broadcasts every Pi event back to us.
|
|
6
|
+
* Our job is only to render and to forward the user's input as typed
|
|
7
|
+
* requests over the WebSocket.
|
|
8
|
+
*
|
|
9
|
+
* Feature parity with `brigade chat` for the common path (send a message,
|
|
10
|
+
* stream the reply, see tool calls, abort with Ctrl+C, switch model, set
|
|
11
|
+
* thinking level, compact, exit). Inline `/provider` onboarding is NOT
|
|
12
|
+
* available from connect mode in v1 — onboarding writes to the gateway's
|
|
13
|
+
* filesystem and is out-of-band; the user runs `brigade onboard` against
|
|
14
|
+
* the gateway machine instead.
|
|
15
|
+
*
|
|
16
|
+
* MAINTAINER NOTE: The footer at `wireConnectUi` deliberately OMITS
|
|
17
|
+
* `/provider` from the slash-command list. Do NOT add it to the connect
|
|
18
|
+
* footer "for parity with chat" — connect cannot perform provider
|
|
19
|
+
* onboarding (no gateway-side filesystem access from the TUI client), and
|
|
20
|
+
* advertising a command we can't honour confuses users. The chat-mode
|
|
21
|
+
* footer (in `src/ui/chat.ts`) DOES list `/provider` because in-process
|
|
22
|
+
* chat owns the filesystem the wizard needs to write to.
|
|
23
|
+
*/
|
|
24
|
+
import process from "node:process";
|
|
25
|
+
import { CancellableLoader, CombinedAutocompleteProvider, ProcessTerminal, Text, TUI, } from "@mariozechner/pi-tui";
|
|
26
|
+
import { BrigadeEditor } from "../../ui/editor.js";
|
|
27
|
+
import { sanitizeTerminalInput } from "../../security/terminal-input-sanitizer.js";
|
|
28
|
+
import chalk from "chalk";
|
|
29
|
+
// Brigade's `Markdown` is a thin Pi-TUI subclass that normalizes `_text_`
|
|
30
|
+
// italic spans to `*text*` so the renderer applies italic styling instead
|
|
31
|
+
// of leaking literal underscores. Same shape as Pi-TUI's `Markdown` — drop-in.
|
|
32
|
+
import { Markdown } from "../../ui/markdown.js";
|
|
33
|
+
import { renderBrandHeader } from "../../ui/brand.js";
|
|
34
|
+
import { formatCrewLabel, formatSessionLabel } from "../../ui/format-session.js";
|
|
35
|
+
import { markTuiActive, restoreTerminal } from "../../ui/terminal-cleanup.js";
|
|
36
|
+
import { brand, editorTheme, markdownTheme } from "../../ui/theme.js";
|
|
37
|
+
import { summarizeToolResult } from "../../ui/tool-result.js";
|
|
38
|
+
import { BrigadeClient } from "../../tui/client.js";
|
|
39
|
+
import { ApprovalPrompt } from "../../tui/approval-prompt.js";
|
|
40
|
+
import { computeExplain, filterGraphToSubtree, formatExplain, parseOrgSlash, renderDepartmentsOnly, } from "./org-slash.js";
|
|
41
|
+
import { renderPrideChartWithPins, BRIGADE_FOOTER_RULE, } from "../../agents/org/pride-template.js";
|
|
42
|
+
// Commander wrapper — `brigade connect` is the thin TUI client that
|
|
43
|
+
// connects to a running gateway. Same single-touch pattern the TUI /
|
|
44
|
+
// gateway commands use.
|
|
45
|
+
export function registerConnectCommand(program) {
|
|
46
|
+
program
|
|
47
|
+
.command("connect")
|
|
48
|
+
.description("Connect to a running Brigade gateway from a thin TUI client")
|
|
49
|
+
.option("-h, --host <host>", "gateway host (default: 127.0.0.1)")
|
|
50
|
+
.option("-p, --port <port>", "gateway port", (v) => parseInt(v, 10))
|
|
51
|
+
.option("--timeout <ms>", "request timeout in ms", (v) => parseInt(v, 10))
|
|
52
|
+
.action(async (opts) => {
|
|
53
|
+
await runConnectCommand({
|
|
54
|
+
host: opts.host,
|
|
55
|
+
port: opts.port,
|
|
56
|
+
requestTimeoutMs: opts.timeout,
|
|
57
|
+
});
|
|
58
|
+
await new Promise(() => { });
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Should a `state` snapshot's `sessionKey` seed the connection-bound session?
|
|
63
|
+
*
|
|
64
|
+
* Yes when unbound (normal first-snapshot seed) or when the snapshot is for
|
|
65
|
+
* the SAME agent we're bound to. No when bound to a DIFFERENT agent than the
|
|
66
|
+
* snapshot — that's the `--agent X` cross-agent-session bug: the gateway's
|
|
67
|
+
* boot snapshot (agent `main`, session `agent:main:main`) must NOT seed the
|
|
68
|
+
* session for a connection bound to `marketing-lead`, or `withBinding` emits
|
|
69
|
+
* the incoherent pair `{agentId: marketing-lead, sessionKey: agent:main:main}`
|
|
70
|
+
* and the reply gets filtered to the wrong lane. Exported for regression
|
|
71
|
+
* testing of that exact decision.
|
|
72
|
+
*/
|
|
73
|
+
export function snapshotSessionSeedable(boundAgentId, snapAgentId) {
|
|
74
|
+
if (boundAgentId === undefined)
|
|
75
|
+
return true;
|
|
76
|
+
return typeof snapAgentId === "string" && snapAgentId === boundAgentId;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Boot the connect TUI. Establishes the WebSocket connection FIRST so the
|
|
80
|
+
* user gets a clear "couldn't reach gateway" error instead of a blank chat.
|
|
81
|
+
*/
|
|
82
|
+
export async function runConnectCommand(opts = {}) {
|
|
83
|
+
// Connect runs a TUI client (raw mode, alt-screen, kitty keys) — opt into
|
|
84
|
+
// the on-exit terminal cleanup. Non-TUI commands skip this and exit silently.
|
|
85
|
+
markTuiActive();
|
|
86
|
+
const host = opts.host ?? "127.0.0.1";
|
|
87
|
+
const port = opts.port ?? 7777;
|
|
88
|
+
const url = `ws://${host}:${port}`;
|
|
89
|
+
const tui = new TUI(new ProcessTerminal());
|
|
90
|
+
tui.start();
|
|
91
|
+
// Wire SIGINT BEFORE the connect attempt so Ctrl+C during a slow connect
|
|
92
|
+
// exits cleanly instead of hanging on the open promise. Re-arm via
|
|
93
|
+
// process.once after each turn-abort so handlers never stack across
|
|
94
|
+
// re-invocations within the same process.
|
|
95
|
+
let chatHandle = null;
|
|
96
|
+
const onSigint = () => {
|
|
97
|
+
if (chatHandle) {
|
|
98
|
+
const wasRunning = chatHandle.abort();
|
|
99
|
+
if (!wasRunning) {
|
|
100
|
+
void chatHandle.close().then(() => {
|
|
101
|
+
tui.stop();
|
|
102
|
+
// tui.stop() already runs Pi-TUI's cleanup (kitty pop on
|
|
103
|
+
// the happy path); restoreTerminal() is the broader safety
|
|
104
|
+
// net (focus, mouse, alt-screen, modifyOtherKeys) plus an
|
|
105
|
+
// unconditional kitty pop in case Pi-TUI's flag tracker
|
|
106
|
+
// missed it.
|
|
107
|
+
restoreTerminal();
|
|
108
|
+
process.exit(0);
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
process.once("SIGINT", onSigint); // re-arm for the next Ctrl+C
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
tui.stop();
|
|
116
|
+
restoreTerminal();
|
|
117
|
+
process.exit(130);
|
|
118
|
+
};
|
|
119
|
+
process.once("SIGINT", onSigint);
|
|
120
|
+
const client = new BrigadeClient({
|
|
121
|
+
url,
|
|
122
|
+
requestTimeoutMs: opts.requestTimeoutMs ?? 60_000,
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
await client.connect();
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
tui.stop();
|
|
129
|
+
restoreTerminal();
|
|
130
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
131
|
+
const isRefused = /ECONNREFUSED|connect.*refused/i.test(msg);
|
|
132
|
+
const isTimeout = /ETIMEDOUT|timed?\s*out/i.test(msg);
|
|
133
|
+
const isUnknownHost = /ENOTFOUND|EAI_AGAIN|getaddrinfo|temporary failure in name resolution/i.test(msg);
|
|
134
|
+
const isUnreachable = /EHOSTUNREACH|ENETUNREACH|network is unreachable|no route to host/i.test(msg);
|
|
135
|
+
// Headline: don't interpolate the raw `msg` (it can carry ENOTFOUND-style
|
|
136
|
+
// internal codes and getaddrinfo jargon). Just say what we tried.
|
|
137
|
+
console.error(chalk.red(`✗ Couldn't reach the Brigade gateway at ${url}.`));
|
|
138
|
+
// Differentiate the most common failure modes so users don't waste
|
|
139
|
+
// time debugging the wrong cause.
|
|
140
|
+
if (isRefused) {
|
|
141
|
+
console.error(chalk.dim(` Likely cause: no gateway is running on port ${port}.`));
|
|
142
|
+
console.error(chalk.dim(` Either start one: brigade gateway --port ${port}`));
|
|
143
|
+
console.error(chalk.dim(` Or, if it's on another port: brigade connect --port <that-port>`));
|
|
144
|
+
}
|
|
145
|
+
else if (isTimeout) {
|
|
146
|
+
console.error(chalk.dim(` Likely cause: gateway is reachable but slow to handshake.`));
|
|
147
|
+
console.error(chalk.dim(` Check that ${host} resolves and the port isn't blocked by a firewall.`));
|
|
148
|
+
}
|
|
149
|
+
else if (isUnknownHost) {
|
|
150
|
+
console.error(chalk.dim(` Couldn't resolve "${host}" — check the hostname and your DNS.`));
|
|
151
|
+
}
|
|
152
|
+
else if (isUnreachable) {
|
|
153
|
+
console.error(chalk.dim(` No network route to ${host}. Check your VPN / firewall / network connection.`));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
console.error(chalk.dim(` Start the gateway first: brigade gateway --port ${port}`));
|
|
157
|
+
console.error(chalk.dim(` Or check the host/port flags: brigade connect --host ${host} --port ${port}`));
|
|
158
|
+
}
|
|
159
|
+
// Surface the raw message only when the operator opts into debug mode.
|
|
160
|
+
if (process.env.BRIGADE_DEBUG === "1") {
|
|
161
|
+
console.error(chalk.dim(` (debug: ${msg})`));
|
|
162
|
+
}
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
// Startup `--agent <id>` binding. Validate against the gateway's live
|
|
166
|
+
// agent list BEFORE engaging the UI — an unknown id would otherwise fall
|
|
167
|
+
// back to the boot agent server-side (getAgentRuntime), silently routing
|
|
168
|
+
// the operator's turns to `main` while they believe they're talking to X.
|
|
169
|
+
// Mirrors the in-TUI `/agent` validation. agents.list failure is lenient
|
|
170
|
+
// (bind anyway; the in-TUI /agent can correct) so a transient RPC hiccup
|
|
171
|
+
// doesn't block launch.
|
|
172
|
+
let initialAgentId;
|
|
173
|
+
if (opts.agentId) {
|
|
174
|
+
try {
|
|
175
|
+
const known = (await client.request("agents.list"));
|
|
176
|
+
if (!known.some((a) => a.id === opts.agentId)) {
|
|
177
|
+
tui.stop();
|
|
178
|
+
restoreTerminal();
|
|
179
|
+
const available = known.map((a) => a.id).join(", ") || "(none)";
|
|
180
|
+
console.error(chalk.red(`✗ Unknown agent "${opts.agentId}".`));
|
|
181
|
+
console.error(chalk.dim(` Available: ${available}`));
|
|
182
|
+
console.error(chalk.dim(` (run \`brigade agents list\` to see them all)`));
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
185
|
+
initialAgentId = opts.agentId;
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// Lenient: bind anyway; `/agent` inside the TUI re-validates.
|
|
189
|
+
initialAgentId = opts.agentId;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
chatHandle = await wireConnectUi(tui, client, initialAgentId);
|
|
193
|
+
return chatHandle;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Build the live chat UI on top of an already-connected client. Split out so
|
|
197
|
+
* tests can inject a pre-connected client without going through CLI flag
|
|
198
|
+
* parsing or process.exit.
|
|
199
|
+
*/
|
|
200
|
+
export async function wireConnectUi(tui, client, initialAgentId) {
|
|
201
|
+
// Static (last-frame) wordmark — `brigade connect` is the chat surface
|
|
202
|
+
// just like `brigade chat`, so we want the same still rendering here. The
|
|
203
|
+
// looping clip is reserved for onboarding's one-time wow moment.
|
|
204
|
+
renderBrandHeader(tui, { animate: false });
|
|
205
|
+
const header = new Text("", 0, 0);
|
|
206
|
+
tui.addChild(header);
|
|
207
|
+
const divider = new Text(brand.dim("─".repeat(80)), 0, 0);
|
|
208
|
+
tui.addChild(divider);
|
|
209
|
+
// Cumulative usage — accumulated from state snapshots so a reconnect picks
|
|
210
|
+
// up where we left off instead of zeroing the totals on the user's screen.
|
|
211
|
+
let lastSnapshot = null;
|
|
212
|
+
// The last text the user sent as a prompt — the replay message for a `/switch`
|
|
213
|
+
// (Carrow) mid-turn model handoff: abort the live turn, swap, re-run this on the new model.
|
|
214
|
+
let lastUserPrompt = "";
|
|
215
|
+
let isAgentRunning = false;
|
|
216
|
+
// Connection-bound agent id. Defaults to the gateway's boot agent (filled
|
|
217
|
+
// in from the first `state` snapshot) so legacy single-agent gateways keep
|
|
218
|
+
// working unchanged. The `/agent <id>` slash command rebinds the connection
|
|
219
|
+
// so subsequent prompt / abort / steer / set-model / set-thinking RPCs all
|
|
220
|
+
// target that agent without the operator having to repeat it every turn.
|
|
221
|
+
// Seeded from `--agent <id>` when supplied (already validated against
|
|
222
|
+
// agents.list in runConnectCommand); otherwise filled from the first
|
|
223
|
+
// `state` snapshot. A pre-set value is preserved by the snapshot handler's
|
|
224
|
+
// `=== undefined` guard, so the startup binding sticks.
|
|
225
|
+
let boundAgentId = initialAgentId;
|
|
226
|
+
// Wave K — connection-bound session key. Lets the operator point this
|
|
227
|
+
// TUI at a per-peer session (e.g. a channel-routed turn under
|
|
228
|
+
// `agent:main:whatsapp:<jid>`) so abort / steer / compact / set-model
|
|
229
|
+
// target THAT lane instead of the boot agent's `main`. Seeded from the
|
|
230
|
+
// first snapshot, overridden by `/session <key>`.
|
|
231
|
+
let boundSessionKey = undefined;
|
|
232
|
+
// Residual P0 (post-Wave K integration audit) — the WS broadcast filter
|
|
233
|
+
// at server.ts:903 keys on per-connection subscription Sets populated by
|
|
234
|
+
// the `subscribe` RPC. Without an explicit subscribe, the filter falls
|
|
235
|
+
// through to back-compat "deliver everything", so two operators each
|
|
236
|
+
// running /agent <id> still see each other's pi/log/approval frames.
|
|
237
|
+
// Track the last-committed sub pair so we can `unsubscribe` it before
|
|
238
|
+
// re-subscribing to the new binding (server keeps sets — leaving stale
|
|
239
|
+
// entries widens what the operator sees).
|
|
240
|
+
let lastSubscribedAgentId = undefined;
|
|
241
|
+
let lastSubscribedSessionKey = undefined;
|
|
242
|
+
// Wave N3 (bug #3) — track whether the very first `state` snapshot has
|
|
243
|
+
// already seeded the connection bindings AND fired an initial `subscribe`.
|
|
244
|
+
// Without this, the snapshot handler stamped boundAgentId/boundSessionKey
|
|
245
|
+
// but never called applySubscription(), so the gateway's per-connection
|
|
246
|
+
// filter at server.ts:903 fell through to its back-compat "deliver
|
|
247
|
+
// everything" branch — every operator on a multi-agent gateway saw every
|
|
248
|
+
// other agent's pi/log/approval frames until they manually issued /agent
|
|
249
|
+
// or /session. We now fire applySubscription() exactly once on the first
|
|
250
|
+
// non-trivial seed; subsequent snapshots are no-ops on this code path.
|
|
251
|
+
let seededSubscription = false;
|
|
252
|
+
const applySubscription = async () => {
|
|
253
|
+
try {
|
|
254
|
+
const priorParams = {};
|
|
255
|
+
if (lastSubscribedAgentId !== undefined)
|
|
256
|
+
priorParams.agentId = lastSubscribedAgentId;
|
|
257
|
+
if (lastSubscribedSessionKey !== undefined)
|
|
258
|
+
priorParams.sessionId = lastSubscribedSessionKey;
|
|
259
|
+
if (Object.keys(priorParams).length > 0) {
|
|
260
|
+
await client.request("unsubscribe", priorParams);
|
|
261
|
+
}
|
|
262
|
+
const nextParams = {};
|
|
263
|
+
if (boundAgentId !== undefined)
|
|
264
|
+
nextParams.agentId = boundAgentId;
|
|
265
|
+
if (boundSessionKey !== undefined)
|
|
266
|
+
nextParams.sessionId = boundSessionKey;
|
|
267
|
+
if (Object.keys(nextParams).length > 0) {
|
|
268
|
+
await client.request("subscribe", nextParams);
|
|
269
|
+
}
|
|
270
|
+
lastSubscribedAgentId = boundAgentId;
|
|
271
|
+
lastSubscribedSessionKey = boundSessionKey;
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
// Best-effort. Server falls back to the back-compat branch on
|
|
275
|
+
// failure (deliver everything), which matches the pre-fix surface.
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
// Wave N3 (bug #3) — defence-in-depth lane filter. Even with the
|
|
279
|
+
// server-side `subscribe` RPC engaged, a stale frame can leak during the
|
|
280
|
+
// gap between /agent or /session being typed and the gateway processing
|
|
281
|
+
// the new subscription set, or against a legacy gateway that doesn't
|
|
282
|
+
// honour subscribe at all. Drop any frame whose stamped agentId/sessionId
|
|
283
|
+
// disagrees with the operator's currently bound lane. Mirrors the
|
|
284
|
+
// upstream client-side gate pattern but adapted for Brigade's
|
|
285
|
+
// server-side subscribe (so we only drop frames that explicitly stamp a
|
|
286
|
+
// DIFFERENT lane — frames with no stamp at all fall through, preserving
|
|
287
|
+
// back-compat with older gateway builds that don't tag broadcasts yet).
|
|
288
|
+
const isOffLane = (frameAgentId, frameSessionId) => {
|
|
289
|
+
if (boundAgentId !== undefined && typeof frameAgentId === "string" && frameAgentId.length > 0) {
|
|
290
|
+
if (frameAgentId !== boundAgentId)
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
if (boundSessionKey !== undefined && typeof frameSessionId === "string" && frameSessionId.length > 0) {
|
|
294
|
+
if (frameSessionId !== boundSessionKey)
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
return false;
|
|
298
|
+
};
|
|
299
|
+
// SECURITY (render-side escape scrub). The operator's OWN input is already
|
|
300
|
+
// scrubbed at the submit chokepoint (`sanitizeTerminalInput` in
|
|
301
|
+
// `editor.onSubmit`), but every string the GATEWAY pushes — tool-result
|
|
302
|
+
// previews, assistant text, log lines, cron system-events, the bash command
|
|
303
|
+
// echoed back in an approval confirmation — is attacker-influenceable (a
|
|
304
|
+
// model/tool can be steered to emit control bytes) and reaches a `Text` /
|
|
305
|
+
// `Markdown` widget that preserves raw ANSI. Embedded ESC[ / OSC sequences
|
|
306
|
+
// would otherwise move the cursor, clear the screen, rewrite the window
|
|
307
|
+
// title, or smuggle an OSC 52 clipboard write. Funnel every server-pushed
|
|
308
|
+
// render string through this single helper before it hits a widget.
|
|
309
|
+
//
|
|
310
|
+
// `sanitizeTerminalInput` already strips CSI/OSC/leaked-paste/stray-ESC, but
|
|
311
|
+
// it does NOT strip non-ESC C0 (0x00-0x1F, minus \n/\t) or C1 (0x80-0x9F)
|
|
312
|
+
// control bytes — those can still drive a terminal on their own — so we
|
|
313
|
+
// remove them here too. Newlines and tabs are preserved (multi-line tool
|
|
314
|
+
// errors + the `brigade exec allow …` call-to-action must keep their
|
|
315
|
+
// layout). Idempotent + pure; safe to apply to already-clean text.
|
|
316
|
+
const scrubRenderable = (text) => {
|
|
317
|
+
if (!text)
|
|
318
|
+
return text;
|
|
319
|
+
// First reuse the input-side stripper (CSI/OSC/leaked-paste/stray-ESC +
|
|
320
|
+
// lone-surrogate repair), then drop remaining bare C0/C1 control bytes.
|
|
321
|
+
// eslint-disable-next-line no-control-regex
|
|
322
|
+
return sanitizeTerminalInput(text).replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
|
|
323
|
+
};
|
|
324
|
+
// Build the standard `{ agentId?, sessionKey?, ...rest }` payload shape
|
|
325
|
+
// every RPC uses. Keeps the call sites compact and ensures sessionKey
|
|
326
|
+
// is threaded uniformly so the server's per-session targeting works.
|
|
327
|
+
const withBinding = (extra = {}) => ({
|
|
328
|
+
...(boundAgentId !== undefined ? { agentId: boundAgentId } : {}),
|
|
329
|
+
...(boundSessionKey !== undefined ? { sessionKey: boundSessionKey } : {}),
|
|
330
|
+
...extra,
|
|
331
|
+
});
|
|
332
|
+
// Streaming-assistant buffers keyed by sub-agent depth (Primitive #6).
|
|
333
|
+
// Depth 0 = top-level agent's stream; depth ≥ 1 = sub-agent at that nesting
|
|
334
|
+
// level. Each depth gets its own Markdown block that grows in place as
|
|
335
|
+
// `message_update` events arrive, so a sub-agent's multi-chunk reply
|
|
336
|
+
// renders as ONE growing block (not N fresh blocks). Cleared per-depth on
|
|
337
|
+
// `tool_execution_start` (so the next message_update at that depth
|
|
338
|
+
// creates a fresh block under the tool), and wholesale on `agent_end` /
|
|
339
|
+
// abort (turn boundary).
|
|
340
|
+
const activeAssistants = new Map();
|
|
341
|
+
let activeLoader = null;
|
|
342
|
+
const pendingTools = new Map();
|
|
343
|
+
// Streaming render coalescer. Every `setText()` on the streaming Markdown
|
|
344
|
+
// widget invalidates the parser cache, so each paint re-parses the FULL
|
|
345
|
+
// growing reply (Marked + line-wrap + ANSI styling). At 60Hz that's a
|
|
346
|
+
// continuous parse stall that blocks scroll events queued in the
|
|
347
|
+
// terminal's input buffer, causing the flicker + scroll-lock the operator
|
|
348
|
+
// sees on Windows Terminal. 150ms (~6–7 paints/sec while streaming) is the
|
|
349
|
+
// chosen default — slow enough that each paint's parse cost is small
|
|
350
|
+
// relative to the gap, fast enough that streaming still feels live.
|
|
351
|
+
// Override with `BRIGADE_STREAM_RENDER_MS` (clamped to ≥16). Raise to 250–400
|
|
352
|
+
// if a slow terminal still flickers; lower to 30–60 on a fast terminal
|
|
353
|
+
// (iTerm, Alacritty, recent Kitty) for snappier streaming.
|
|
354
|
+
const streamRenderMs = Math.max(16, Number(process.env.BRIGADE_STREAM_RENDER_MS) || 150);
|
|
355
|
+
let streamRenderTimer = null;
|
|
356
|
+
const scheduleStreamingRender = () => {
|
|
357
|
+
if (streamRenderTimer)
|
|
358
|
+
return;
|
|
359
|
+
streamRenderTimer = setTimeout(() => {
|
|
360
|
+
streamRenderTimer = null;
|
|
361
|
+
tui.requestRender();
|
|
362
|
+
}, streamRenderMs);
|
|
363
|
+
if (typeof streamRenderTimer.unref === "function")
|
|
364
|
+
streamRenderTimer.unref();
|
|
365
|
+
};
|
|
366
|
+
const flushStreamingRender = () => {
|
|
367
|
+
if (streamRenderTimer) {
|
|
368
|
+
clearTimeout(streamRenderTimer);
|
|
369
|
+
streamRenderTimer = null;
|
|
370
|
+
}
|
|
371
|
+
tui.requestRender();
|
|
372
|
+
};
|
|
373
|
+
// Elapsed-time tracker for the running agent. Started on `agent_start`,
|
|
374
|
+
// cleared on `agent_end`. Read by the 1s ticker below to refresh the
|
|
375
|
+
// header so the user can see "thinking… 12s" / "thinking… 1m 4s" instead
|
|
376
|
+
// of a static "thinking…". Brigade-shape (no phrase rotation, just
|
|
377
|
+
// clean numbers).
|
|
378
|
+
let agentStartedAt = null;
|
|
379
|
+
// Whimsical phrase rotator for the loader. Rotates in the header tail
|
|
380
|
+
// every 4s while the agent is busy. Pi-TUI's CancellableLoader doesn't
|
|
381
|
+
// expose a label setter so we pipe the phrase into the header `extra`
|
|
382
|
+
// slot instead.
|
|
383
|
+
const WHIMSICAL_PHRASES = [
|
|
384
|
+
"thinking",
|
|
385
|
+
"flibbertigibbeting",
|
|
386
|
+
"kerfuffling",
|
|
387
|
+
"dillydallying",
|
|
388
|
+
"twiddling thumbs",
|
|
389
|
+
"noodling",
|
|
390
|
+
"bamboozling",
|
|
391
|
+
"moseying",
|
|
392
|
+
"hobnobbing",
|
|
393
|
+
"pondering",
|
|
394
|
+
"conjuring",
|
|
395
|
+
];
|
|
396
|
+
let whimsicalIdx = 0;
|
|
397
|
+
// Thinking-block visibility toggle. Default `false` matches today's UX
|
|
398
|
+
// (thinking blocks excluded from `extractAssistantText` filter). When
|
|
399
|
+
// flipped to `true` via the `/show-thinking` slash command, the
|
|
400
|
+
// extractor includes `{ type: "thinking" }` block text alongside the
|
|
401
|
+
// regular text blocks, dimmed so it stays distinct from the agent's
|
|
402
|
+
// final reply. Brigade uses the base Pi-TUI Editor which doesn't
|
|
403
|
+
// expose key handlers, so the toggle is surfaced through the slash-
|
|
404
|
+
// command path instead of a `Ctrl+T` binding.
|
|
405
|
+
let showThinking = false;
|
|
406
|
+
const updateHeader = (extra) => {
|
|
407
|
+
const provider = lastSnapshot?.provider ?? "?";
|
|
408
|
+
const modelId = lastSnapshot?.modelId ?? "?";
|
|
409
|
+
const tokens = lastSnapshot && (lastSnapshot.totalTokensIn + lastSnapshot.totalTokensOut) > 0
|
|
410
|
+
? ` · ${(lastSnapshot.totalTokensIn + lastSnapshot.totalTokensOut).toLocaleString()} tok`
|
|
411
|
+
: "";
|
|
412
|
+
const cost = lastSnapshot && lastSnapshot.totalCostUsd > 0
|
|
413
|
+
? ` · $${lastSnapshot.totalCostUsd.toFixed(4)}`
|
|
414
|
+
: "";
|
|
415
|
+
const usage = lastSnapshot?.contextUsagePercent ?? null;
|
|
416
|
+
let usageStr = "";
|
|
417
|
+
if (usage != null && usage >= 50) {
|
|
418
|
+
const pct = Math.round(usage);
|
|
419
|
+
const colored = pct >= 75 ? brand.amber(`${pct}% ctx`) : brand.dim(`${pct}% ctx`);
|
|
420
|
+
usageStr = ` · ${colored}`;
|
|
421
|
+
}
|
|
422
|
+
// Elapsed time during a running turn. Hidden when idle; shown as
|
|
423
|
+
// `· 12s` (under a minute) or `· 1m 4s` so the user has a sense of
|
|
424
|
+
// "is the model still working or has it stalled?".
|
|
425
|
+
let elapsed = "";
|
|
426
|
+
if (isAgentRunning && agentStartedAt != null) {
|
|
427
|
+
const ms = Date.now() - agentStartedAt;
|
|
428
|
+
elapsed = ` · ${formatElapsed(ms)}`;
|
|
429
|
+
}
|
|
430
|
+
const tail = extra ? ` · ${extra}` : "";
|
|
431
|
+
const dot = isAgentRunning ? brand.amber("●") : brand.dim("○");
|
|
432
|
+
// Brand mark — the 🦁 mascot always rides ahead of the persona name
|
|
433
|
+
// so the header reads as Brigade-branded at a glance. When the
|
|
434
|
+
// operator has set a `Name` in IDENTITY.md (e.g. "felix"/"molty"),
|
|
435
|
+
// that name takes the persona slot; otherwise fall back to the
|
|
436
|
+
// "Brigade" wordmark.
|
|
437
|
+
const personaName = lastSnapshot?.agentName?.trim();
|
|
438
|
+
const personaLabel = personaName || "Brigade";
|
|
439
|
+
// "crew <id>" badge — surfaced only when meaningful (non-default
|
|
440
|
+
// agent OR no persona name yet). Hides on a single-agent install
|
|
441
|
+
// with a persona name set so the header stays calm.
|
|
442
|
+
const crewLabel = formatCrewLabel({
|
|
443
|
+
agentId: lastSnapshot?.agentId,
|
|
444
|
+
personaName,
|
|
445
|
+
});
|
|
446
|
+
const crewSegment = crewLabel ? ` ${brand.dim(`· ${crewLabel}`)}` : "";
|
|
447
|
+
// Human-readable session label — `main` / `WhatsApp · DM` /
|
|
448
|
+
// `Slack · group · thread` / `sub-agent abc` instead of the raw
|
|
449
|
+
// `agent:<id>:<rest>` key. Falls back to the raw string when the
|
|
450
|
+
// key is unparseable so we never lose information.
|
|
451
|
+
const sessionLabel = formatSessionLabel(lastSnapshot?.sessionKey);
|
|
452
|
+
const sessionSegment = sessionLabel ? ` ${brand.dim(`· ${sessionLabel}`)}` : "";
|
|
453
|
+
header.setText(` ${dot} 🦁 ${brand.white(personaLabel)}${crewSegment}${sessionSegment} ${brand.dim(`${provider} · ${modelId}${tokens}${cost}`)}${usageStr}${brand.dim(elapsed)}${brand.dim(tail)}`);
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Tick the elapsed-time display every second while the agent is busy.
|
|
457
|
+
* Cheap (one timer per connect session, not per-turn) and unref'd so it
|
|
458
|
+
* doesn't keep the process alive past `process.exit`. Cleared in the
|
|
459
|
+
* abort/close path below.
|
|
460
|
+
*/
|
|
461
|
+
const elapsedTimer = setInterval(() => {
|
|
462
|
+
if (isAgentRunning && agentStartedAt != null) {
|
|
463
|
+
updateHeader();
|
|
464
|
+
tui.requestRender();
|
|
465
|
+
}
|
|
466
|
+
}, 1000);
|
|
467
|
+
if (typeof elapsedTimer.unref === "function")
|
|
468
|
+
elapsedTimer.unref();
|
|
469
|
+
// Rotate the whimsical phrase shown in the header tail every 4s. Restarts
|
|
470
|
+
// on each agent_start so the user sees the same phrase for the first
|
|
471
|
+
// few seconds (no jarring rotation right after they hit Enter).
|
|
472
|
+
const whimsicalTimer = setInterval(() => {
|
|
473
|
+
if (isAgentRunning && activeLoader) {
|
|
474
|
+
whimsicalIdx = (whimsicalIdx + 1) % WHIMSICAL_PHRASES.length;
|
|
475
|
+
const phrase = WHIMSICAL_PHRASES[whimsicalIdx];
|
|
476
|
+
updateHeader(phrase);
|
|
477
|
+
tui.requestRender();
|
|
478
|
+
}
|
|
479
|
+
}, 4000);
|
|
480
|
+
if (typeof whimsicalTimer.unref === "function")
|
|
481
|
+
whimsicalTimer.unref();
|
|
482
|
+
updateHeader();
|
|
483
|
+
const editor = new BrigadeEditor(tui, editorTheme);
|
|
484
|
+
tui.addChild(editor);
|
|
485
|
+
tui.setFocus(editor);
|
|
486
|
+
// Slash-command autocomplete (Pi-TUI built-in). Connect-mode list omits
|
|
487
|
+
// `/provider` (it can't run the wizard against the remote gateway's
|
|
488
|
+
// filesystem) and `/clear` (chat-only). See chat.ts for the full set.
|
|
489
|
+
// Pi-TUI's slash-command spec: `name` is the command WITHOUT the leading
|
|
490
|
+
// `/`. Pi adds the `/` itself on accept; including it here produces
|
|
491
|
+
// `//reasoning` instead of `/reasoning`.
|
|
492
|
+
const SLASH_COMMANDS = [
|
|
493
|
+
{ name: "help", description: "show all slash commands" },
|
|
494
|
+
{ name: "exit", description: "quit Brigade connect" },
|
|
495
|
+
{ name: "quit", description: "quit Brigade connect" },
|
|
496
|
+
{ name: "abort", description: "abort the in-flight turn (same as Ctrl+C)" },
|
|
497
|
+
{ name: "usage", description: "show token totals + estimated cost so far" },
|
|
498
|
+
{ name: "compact", description: "summarize older turns to free context" },
|
|
499
|
+
{
|
|
500
|
+
name: "memory",
|
|
501
|
+
description: "inspect memory — list / search <q> / inspect <id> / stats",
|
|
502
|
+
argumentHint: "[list | search <q> | inspect <id> | stats]",
|
|
503
|
+
getArgumentCompletions: (prefix) => {
|
|
504
|
+
const verbs = ["list", "search", "inspect", "stats"];
|
|
505
|
+
return verbs
|
|
506
|
+
.filter((v) => v.startsWith(prefix.toLowerCase()))
|
|
507
|
+
.map((v) => ({ value: v, label: v }));
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
name: "allow-all",
|
|
512
|
+
description: "on|off — skip shell approval prompts this session (guards still apply)",
|
|
513
|
+
argumentHint: "<on|off>",
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: "grant-skill",
|
|
517
|
+
description: "preview/approve a skill's declared commands (--yes to apply)",
|
|
518
|
+
argumentHint: "<name> [--yes]",
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: "revoke-skill",
|
|
522
|
+
description: "remove a skill's granted commands from the allowlist",
|
|
523
|
+
argumentHint: "<name>",
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: "model",
|
|
527
|
+
description: "switch to another configured model (no arg = picker)",
|
|
528
|
+
argumentHint: "[<model-id>]",
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
name: "thinking",
|
|
532
|
+
description: "set the model's reasoning effort",
|
|
533
|
+
argumentHint: "<off|low|medium|high|xhigh>",
|
|
534
|
+
getArgumentCompletions: (prefix) => {
|
|
535
|
+
const levels = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
536
|
+
return levels
|
|
537
|
+
.filter((l) => l.startsWith(prefix.toLowerCase()))
|
|
538
|
+
.map((l) => ({ value: l, label: l }));
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
name: "reasoning",
|
|
543
|
+
description: "show/hide the model's thinking blocks before replies",
|
|
544
|
+
argumentHint: "<on|off>",
|
|
545
|
+
getArgumentCompletions: (prefix) => {
|
|
546
|
+
const opts = ["on", "off"];
|
|
547
|
+
return opts
|
|
548
|
+
.filter((o) => o.startsWith(prefix.toLowerCase()))
|
|
549
|
+
.map((o) => ({ value: o, label: o }));
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
name: "agent",
|
|
554
|
+
description: "show/bind the connection's active agent id",
|
|
555
|
+
argumentHint: "[<agent-id>]",
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
name: "session",
|
|
559
|
+
description: "show/bind the connection's active session key",
|
|
560
|
+
argumentHint: "[<session-key>]",
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
name: "agents",
|
|
564
|
+
description: "list every agent the gateway knows about",
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
name: "sessions",
|
|
568
|
+
description: "list live sessions for the bound agent (or all)",
|
|
569
|
+
argumentHint: "[--all]",
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
name: "mute",
|
|
573
|
+
description: "unsubscribe from an agent id or session key",
|
|
574
|
+
argumentHint: "<agent-id|session-key>",
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: "org",
|
|
578
|
+
description: "show the Pride hierarchy chart (Higher Office / Departments)",
|
|
579
|
+
argumentHint: "[<agent-id>|--departments|--explain <from> <to>]",
|
|
580
|
+
},
|
|
581
|
+
];
|
|
582
|
+
editor.setAutocompleteProvider(new CombinedAutocompleteProvider(SLASH_COMMANDS, process.cwd()));
|
|
583
|
+
// Connect mode cannot run the provider-onboarding wizard (it writes to the
|
|
584
|
+
// gateway machine's filesystem, which we don't have). We surface that gap
|
|
585
|
+
// inline above the footer so users who notice `/provider` is missing aren't
|
|
586
|
+
// left guessing — they get the exact escape hatch.
|
|
587
|
+
tui.addChild(new Text(brand.dim(" connect-mode: /agent /agents /sessions · /model /thinking /reasoning · /abort /steer /compact · /usage /help (use 'brigade chat' on the gateway machine for /provider)"), 0, 0));
|
|
588
|
+
tui.addChild(new Text(brand.dim(" Enter to send · Ctrl+C abort · /usage /abort /reasoning · /help for full list"), 0, 0));
|
|
589
|
+
const insertBeforeEditor = (component) => {
|
|
590
|
+
const children = tui.children;
|
|
591
|
+
const editorIdx = children.indexOf(editor);
|
|
592
|
+
if (editorIdx < 0) {
|
|
593
|
+
tui.addChild(component);
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
children.splice(editorIdx, 0, component);
|
|
597
|
+
tui.requestRender();
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const removeChild = (component) => {
|
|
601
|
+
try {
|
|
602
|
+
tui.removeChild(component);
|
|
603
|
+
}
|
|
604
|
+
catch {
|
|
605
|
+
/* ignore */
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
/**
|
|
609
|
+
* Format the operator's approval choice as a multi-line confirmation
|
|
610
|
+
* stamped above the editor — replaces the inline card so the chat
|
|
611
|
+
* history shows BOTH the decision AND the command + persistence target
|
|
612
|
+
* even after the prompt itself is gone.
|
|
613
|
+
*
|
|
614
|
+
* Visual language:
|
|
615
|
+
* - Green ✓ on allow (`brand.tool`)
|
|
616
|
+
* - Red ✗ on deny (`brand.error`)
|
|
617
|
+
* - Persistent decisions ("allow always", "allow pattern") spell out
|
|
618
|
+
* the file we just wrote to so the operator can `cat` it to audit.
|
|
619
|
+
*/
|
|
620
|
+
const decisionConfirmation = (command, resolution, subagentDepth) => {
|
|
621
|
+
// When the approval originated from a sub-agent (depth > 0), prefix
|
|
622
|
+
// every line with the same `" ".repeat(depth)` indent the tool
|
|
623
|
+
// indicators use. Otherwise the confirmation lands at top-level indent
|
|
624
|
+
// while the source `⚡ bash` indicator sits 4 spaces in — visually
|
|
625
|
+
// jarring and easy to misread as "the parent approved that".
|
|
626
|
+
const depth = typeof subagentDepth === "number" && subagentDepth > 0 ? subagentDepth : 0;
|
|
627
|
+
const subIndent = depth > 0 ? " ".repeat(depth) : "";
|
|
628
|
+
// Scrub the server-pushed bash command before echoing it back (see
|
|
629
|
+
// `scrubRenderable`). The command string is attacker-influenceable
|
|
630
|
+
// (a model can request a command containing ANSI/OSC bytes) and is
|
|
631
|
+
// rendered verbatim in the confirmation stamped above the editor.
|
|
632
|
+
const cmd = `${subIndent} ${brand.dim(scrubRenderable(command).trim())}`;
|
|
633
|
+
switch (resolution.decision) {
|
|
634
|
+
case "allow-once":
|
|
635
|
+
return [
|
|
636
|
+
`${subIndent} ${brand.tool("✓")} ${brand.tool("Allowed once")} ${brand.dim("· running now…")}`,
|
|
637
|
+
cmd,
|
|
638
|
+
].join("\n");
|
|
639
|
+
case "allow-always":
|
|
640
|
+
return [
|
|
641
|
+
`${subIndent} ${brand.tool("✓")} ${brand.tool("Allowed always")} ${brand.dim("· running now…")}`,
|
|
642
|
+
cmd,
|
|
643
|
+
`${subIndent} ${brand.dim("Saved to ~/.brigade/exec-approvals.json — future calls will run without asking.")}`,
|
|
644
|
+
].join("\n");
|
|
645
|
+
case "allow-pattern": {
|
|
646
|
+
const pat = resolution.pattern?.trim() ?? "";
|
|
647
|
+
return [
|
|
648
|
+
`${subIndent} ${brand.tool("✓")} ${brand.tool("Pattern saved")} ${brand.dim("· running now…")}`,
|
|
649
|
+
cmd,
|
|
650
|
+
`${subIndent} ${brand.dim(`Pattern /${pat}/ saved to ~/.brigade/exec-approvals.json — any future command matching this regex runs without asking.`)}`,
|
|
651
|
+
].join("\n");
|
|
652
|
+
}
|
|
653
|
+
case "allow-session":
|
|
654
|
+
return [
|
|
655
|
+
`${subIndent} ${brand.amber("⚠")} ${brand.amber("Allow all this session")} ${brand.dim("· running now…")}`,
|
|
656
|
+
cmd,
|
|
657
|
+
`${subIndent} ${brand.dim("Shell commands run without asking for the rest of this session (safety guards still apply). /allow-all off to stop.")}`,
|
|
658
|
+
].join("\n");
|
|
659
|
+
case "deny":
|
|
660
|
+
return [
|
|
661
|
+
`${subIndent} ${brand.error("✗")} ${brand.error("Denied")} ${brand.dim("· refused")}`,
|
|
662
|
+
cmd,
|
|
663
|
+
].join("\n");
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* Extract the renderable text for an assistant message — mirrors
|
|
668
|
+
* chat.ts's `extractAssistantText`. See chat.ts for the full rationale.
|
|
669
|
+
*/
|
|
670
|
+
const extractAssistantText = (message) => {
|
|
671
|
+
if (!message || !Array.isArray(message.content))
|
|
672
|
+
return "";
|
|
673
|
+
const thinkingParts = [];
|
|
674
|
+
const contentParts = [];
|
|
675
|
+
for (const b of message.content) {
|
|
676
|
+
if (!b || typeof b !== "object")
|
|
677
|
+
continue;
|
|
678
|
+
if (b.type === "thinking" && typeof b.thinking === "string") {
|
|
679
|
+
const t = b.thinking.trim();
|
|
680
|
+
if (t)
|
|
681
|
+
thinkingParts.push(t);
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
// Some forwarded shapes use `text` instead of `thinking` on the
|
|
685
|
+
// thinking block (gateway re-emit quirk). Honour both.
|
|
686
|
+
if (b.type === "thinking" && typeof b.text === "string") {
|
|
687
|
+
const t = b.text.trim();
|
|
688
|
+
if (t)
|
|
689
|
+
thinkingParts.push(t);
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
if (b.type === "text" && typeof b.text === "string") {
|
|
693
|
+
const inlineThinking = [];
|
|
694
|
+
const stripped = b.text.replace(/<think>([\s\S]*?)<\/think>\s*/g, (_m, inner) => {
|
|
695
|
+
const t = inner.trim();
|
|
696
|
+
if (t)
|
|
697
|
+
inlineThinking.push(t);
|
|
698
|
+
return "";
|
|
699
|
+
});
|
|
700
|
+
thinkingParts.push(...inlineThinking);
|
|
701
|
+
if (stripped.trim())
|
|
702
|
+
contentParts.push(stripped);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
const thinkingText = thinkingParts.join("\n").trim();
|
|
706
|
+
const contentText = contentParts.join("").trim();
|
|
707
|
+
const parts = [];
|
|
708
|
+
if (showThinking && thinkingText) {
|
|
709
|
+
parts.push(`${brand.dim("[thinking]")}\n${brand.dim(thinkingText)}`);
|
|
710
|
+
}
|
|
711
|
+
if (contentText)
|
|
712
|
+
parts.push(contentText);
|
|
713
|
+
return parts.join("\n\n");
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
716
|
+
* Format an elapsed-millisecond duration into a compact label for the
|
|
717
|
+
* status line — `12s` / `1m 4s` / `2h 3m`. Brigade keeps the loader
|
|
718
|
+
* Pi-TUI provides; only the elapsed counter is new (no shimmer
|
|
719
|
+
* animation).
|
|
720
|
+
*/
|
|
721
|
+
const formatElapsed = (ms) => {
|
|
722
|
+
const total = Math.max(0, Math.floor(ms / 1000));
|
|
723
|
+
if (total < 60)
|
|
724
|
+
return `${total}s`;
|
|
725
|
+
const m = Math.floor(total / 60);
|
|
726
|
+
const s = total % 60;
|
|
727
|
+
if (m < 60)
|
|
728
|
+
return s === 0 ? `${m}m` : `${m}m ${s}s`;
|
|
729
|
+
const h = Math.floor(m / 60);
|
|
730
|
+
const mm = m % 60;
|
|
731
|
+
return mm === 0 ? `${h}h` : `${h}h ${mm}m`;
|
|
732
|
+
};
|
|
733
|
+
// No auto-kickoff. Brigade used to auto-send "Wake up, my friend!" as a
|
|
734
|
+
// synthetic first user turn on fresh-bootstrap workspaces; removed so
|
|
735
|
+
// the TUI client never auto-sends. The user types the first message
|
|
736
|
+
// themselves.
|
|
737
|
+
// State snapshots from the gateway — every mutation pushes one.
|
|
738
|
+
client.on("state", (snap) => {
|
|
739
|
+
lastSnapshot = snap;
|
|
740
|
+
// `snap.isAgentRunning` is AGENT-wide — it goes true when ANY session
|
|
741
|
+
// of this agent has a turn running (a WhatsApp chat, spawned
|
|
742
|
+
// sub-agents, a cron run). Taking it as-is flipped THIS lane into
|
|
743
|
+
// steer mode while our own session was idle, so typed messages
|
|
744
|
+
// bounced with "nothing to steer" and were lost. Only the CLEARING
|
|
745
|
+
// direction is safe from the snapshot (it reconciles a missed
|
|
746
|
+
// agent_end after a disconnect); the lane's own agent_start /
|
|
747
|
+
// agent_end events own the upward direction.
|
|
748
|
+
if (!snap.isAgentRunning)
|
|
749
|
+
isAgentRunning = false;
|
|
750
|
+
// Seed the connection-bound agent from the first snapshot the
|
|
751
|
+
// gateway pushes. The operator can override via `/agent <id>` —
|
|
752
|
+
// once set explicitly, snapshot updates no longer reset the binding.
|
|
753
|
+
if (boundAgentId === undefined && typeof snap.agentId === "string" && snap.agentId.length > 0) {
|
|
754
|
+
boundAgentId = snap.agentId;
|
|
755
|
+
}
|
|
756
|
+
// Wave K — seed the connection-bound session key from the first
|
|
757
|
+
// snapshot. Once set explicitly via `/session <key>`, snapshot
|
|
758
|
+
// updates no longer reset it (mirrors boundAgentId semantics).
|
|
759
|
+
//
|
|
760
|
+
// --agent guard (2026-06-11): do NOT inherit a session key from a
|
|
761
|
+
// snapshot whose agent differs from the one we're explicitly bound to.
|
|
762
|
+
// On `brigade connect --agent marketing-lead`, the gateway's first
|
|
763
|
+
// (boot) snapshot is for `main` with sessionKey `agent:main:main`.
|
|
764
|
+
// Seeding that here made `withBinding` send the incoherent pair
|
|
765
|
+
// {agentId: "marketing-lead", sessionKey: "agent:main:main"} — the
|
|
766
|
+
// turn routed to main's session and the off-lane / subscription filter
|
|
767
|
+
// dropped the reply (first message landed on main, "fixed" itself only
|
|
768
|
+
// once a marketing-lead snapshot arrived). Leaving boundSessionKey
|
|
769
|
+
// undefined lets the gateway resolve the bound agent's OWN default
|
|
770
|
+
// session from agentId alone. Once a snapshot for the bound agent
|
|
771
|
+
// arrives, the match passes and the real session key seeds normally.
|
|
772
|
+
if (boundSessionKey === undefined &&
|
|
773
|
+
typeof snap.sessionKey === "string" &&
|
|
774
|
+
snap.sessionKey.length > 0 &&
|
|
775
|
+
snapshotSessionSeedable(boundAgentId, snap.agentId)) {
|
|
776
|
+
boundSessionKey = snap.sessionKey;
|
|
777
|
+
}
|
|
778
|
+
// Wave N3 (bug #3) — fire the initial subscription as soon as we
|
|
779
|
+
// have a non-trivial binding from the gateway. Without this, the
|
|
780
|
+
// server-side broadcast filter falls through to "deliver
|
|
781
|
+
// everything" until the operator types /agent or /session, leaking
|
|
782
|
+
// other agents' frames into this TUI. Fires AT MOST ONCE per
|
|
783
|
+
// connection; subsequent /agent and /session bindings each fire
|
|
784
|
+
// their own applySubscription() from their handlers below.
|
|
785
|
+
if (!seededSubscription && (boundAgentId !== undefined || boundSessionKey !== undefined)) {
|
|
786
|
+
seededSubscription = true;
|
|
787
|
+
void applySubscription();
|
|
788
|
+
}
|
|
789
|
+
updateHeader();
|
|
790
|
+
});
|
|
791
|
+
// Tool-approval prompt — the gateway broadcasts an `approval-request`
|
|
792
|
+
// event when a gated tool (today: `bash`) needs operator consent. We
|
|
793
|
+
// render the inline Y/A/P/N prompt above the editor and resolve via
|
|
794
|
+
// the `approval-resolve` request. Persistence ("allow always" / "allow
|
|
795
|
+
// pattern") is handled SERVER-side in exec-gate's `applyApprovalDecision`,
|
|
796
|
+
// which calls `recordApproval()` and writes `~/.brigade/exec-approvals.json`
|
|
797
|
+
// atomically with 0o600 perms.
|
|
798
|
+
let activePrompt = null;
|
|
799
|
+
client.on("approval-request", (req) => {
|
|
800
|
+
// Wave N3 (bug #3) — defence-in-depth: drop approval prompts that
|
|
801
|
+
// don't belong to the lane this TUI is bound to. Without this, two
|
|
802
|
+
// operators each running /agent X and /agent Y would both render
|
|
803
|
+
// every approval card. Server-side subscribe should already filter
|
|
804
|
+
// this, but a race between /agent rebind + the next gated-tool
|
|
805
|
+
// frame can still leak a stale one here.
|
|
806
|
+
if (isOffLane(req.agentId, req.sessionId)) {
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
// If another prompt is somehow already showing (shouldn't happen
|
|
810
|
+
// because exec-gate is serial per-turn), tear it down first so we
|
|
811
|
+
// don't stack prompts on the screen.
|
|
812
|
+
if (activePrompt) {
|
|
813
|
+
try {
|
|
814
|
+
tui.removeChild(activePrompt);
|
|
815
|
+
}
|
|
816
|
+
catch {
|
|
817
|
+
/* ignore */
|
|
818
|
+
}
|
|
819
|
+
activePrompt = null;
|
|
820
|
+
}
|
|
821
|
+
const prompt = new ApprovalPrompt({
|
|
822
|
+
tui,
|
|
823
|
+
request: {
|
|
824
|
+
id: req.id,
|
|
825
|
+
command: req.command,
|
|
826
|
+
toolName: req.toolName,
|
|
827
|
+
cwd: req.cwd,
|
|
828
|
+
...(req.subagentLabel !== undefined ? { subagentLabel: req.subagentLabel } : {}),
|
|
829
|
+
...(req.subagentDepth !== undefined ? { subagentDepth: req.subagentDepth } : {}),
|
|
830
|
+
...(req.parentRunId !== undefined ? { parentRunId: req.parentRunId } : {}),
|
|
831
|
+
},
|
|
832
|
+
onResolve: (resolution) => {
|
|
833
|
+
// Clear the prompt and hand focus back to the editor BEFORE
|
|
834
|
+
// firing the resolve — so the next agent_start event (which
|
|
835
|
+
// will follow on allow) doesn't fight the prompt for focus.
|
|
836
|
+
if (activePrompt) {
|
|
837
|
+
try {
|
|
838
|
+
tui.removeChild(activePrompt);
|
|
839
|
+
}
|
|
840
|
+
catch {
|
|
841
|
+
/* ignore */
|
|
842
|
+
}
|
|
843
|
+
activePrompt = null;
|
|
844
|
+
}
|
|
845
|
+
tui.setFocus(editor);
|
|
846
|
+
const confirmation = decisionConfirmation(req.command, resolution, req.subagentDepth);
|
|
847
|
+
insertBeforeEditor(new Text(confirmation, 0, 0));
|
|
848
|
+
tui.requestRender();
|
|
849
|
+
void client
|
|
850
|
+
.request("approval-resolve", {
|
|
851
|
+
id: req.id,
|
|
852
|
+
decision: resolution.decision,
|
|
853
|
+
pattern: resolution.pattern,
|
|
854
|
+
})
|
|
855
|
+
.catch((err) => {
|
|
856
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
857
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`approval send failed: ${msg}`)}`, 0, 0));
|
|
858
|
+
});
|
|
859
|
+
},
|
|
860
|
+
});
|
|
861
|
+
activePrompt = prompt;
|
|
862
|
+
insertBeforeEditor(prompt);
|
|
863
|
+
tui.setFocus(prompt);
|
|
864
|
+
tui.requestRender();
|
|
865
|
+
});
|
|
866
|
+
// Server-side warnings/info (e.g. "primary failed, trying fallback") — the
|
|
867
|
+
// gateway emits these via the wrapper-chain callbacks. Mirror to the TUI
|
|
868
|
+
// so the user sees the same context they would in `brigade chat`.
|
|
869
|
+
client.on("log", (entry) => {
|
|
870
|
+
// Wave N3 (bug #3) — defensive lane drop. Stamped log entries from
|
|
871
|
+
// off-lane agents get silently dropped here, matching the same
|
|
872
|
+
// filter the server's subscribe applies.
|
|
873
|
+
if (isOffLane(entry.agentId, entry.sessionId))
|
|
874
|
+
return;
|
|
875
|
+
// Scrub the server-pushed log message before rendering (see
|
|
876
|
+
// `scrubRenderable`) — these can carry forwarded model/tool text.
|
|
877
|
+
const message = scrubRenderable(entry.message);
|
|
878
|
+
const tone = entry.level === "error"
|
|
879
|
+
? brand.error(`✗ ${message}`)
|
|
880
|
+
: entry.level === "warn"
|
|
881
|
+
? brand.dim(`⚠ ${message}`)
|
|
882
|
+
: brand.dim(`↻ ${message}`);
|
|
883
|
+
insertBeforeEditor(new Text(` ${tone}`, 0, 0));
|
|
884
|
+
});
|
|
885
|
+
// `system-event` — out-of-band notification the operator MUST see (today
|
|
886
|
+
// only emitted by the cron service's announce path). Rendered as a
|
|
887
|
+
// visible Brigade-side chat line, NOT in the dim log lane, so a cron
|
|
888
|
+
// reminder firing while the operator is connected actually surfaces.
|
|
889
|
+
// Bug #4 — when `payload.source === "cron"` we always render the cron
|
|
890
|
+
// prefix `[cron "<name>"] <summary>` and append a small delivered/not-
|
|
891
|
+
// delivered hint so the operator can tell whether the channel-side
|
|
892
|
+
// send also landed or only this TUI awareness fired.
|
|
893
|
+
client.on("system-event", (event) => {
|
|
894
|
+
// Wave N3 (bug #3) — defensive lane drop. Cron-fired events stamped
|
|
895
|
+
// for another agent shouldn't surface on this operator's connect TUI.
|
|
896
|
+
if (isOffLane(event.agentId, event.sessionId))
|
|
897
|
+
return;
|
|
898
|
+
// Scrub the server-pushed event text before rendering (see
|
|
899
|
+
// `scrubRenderable`). A cron `system-event` carries the cron run's
|
|
900
|
+
// MODEL-GENERATED reply verbatim (server enqueueSystemEvent), so this
|
|
901
|
+
// is an attacker-influenceable path even though it's not direct bash.
|
|
902
|
+
const eventText = scrubRenderable(event.text);
|
|
903
|
+
const isCron = event.source === "cron" || event.jobName !== undefined;
|
|
904
|
+
if (isCron) {
|
|
905
|
+
const name = event.jobName ?? "cron";
|
|
906
|
+
const heading = brand.amber(`🦁 [cron "${name}"]`);
|
|
907
|
+
let suffix = "";
|
|
908
|
+
if (event.delivered === true) {
|
|
909
|
+
suffix = ` ${brand.dim("· delivered")}`;
|
|
910
|
+
}
|
|
911
|
+
else if (event.delivered === false) {
|
|
912
|
+
suffix = ` ${brand.dim("· not delivered (TUI only)")}`;
|
|
913
|
+
}
|
|
914
|
+
insertBeforeEditor(new Text(`${heading} ${eventText}${suffix}`, 0, 0));
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
917
|
+
const heading = brand.amber("🦁");
|
|
918
|
+
insertBeforeEditor(new Text(`${heading} ${eventText}`, 0, 0));
|
|
919
|
+
}
|
|
920
|
+
tui.requestRender();
|
|
921
|
+
});
|
|
922
|
+
// Pi events are forwarded as `{ event: <pi event>, subagentDepth? }`.
|
|
923
|
+
// Same render logic as src/ui/chat.ts but stripped of in-process state
|
|
924
|
+
// mutations. Primitive #6: when `subagentDepth > 0`, indent child events
|
|
925
|
+
// by `2 * depth` spaces so nested sub-agent activity is visually distinct
|
|
926
|
+
// from the parent's stream.
|
|
927
|
+
client.on("pi", (payload) => {
|
|
928
|
+
const { event, subagentDepth } = payload;
|
|
929
|
+
// Wave N3 (bug #3) — defensive lane drop. The gateway already
|
|
930
|
+
// filters via subscribe; this catches the gap between an /agent or
|
|
931
|
+
// /session rebind and the gateway's next-frame view of the new
|
|
932
|
+
// binding (or a legacy gateway that doesn't filter at all).
|
|
933
|
+
if (isOffLane(payload.agentId, payload.sessionId))
|
|
934
|
+
return;
|
|
935
|
+
const depth = typeof subagentDepth === "number" ? subagentDepth : 0;
|
|
936
|
+
const subIndent = depth > 0 ? " ".repeat(depth) : "";
|
|
937
|
+
switch (event?.type) {
|
|
938
|
+
case "agent_start": {
|
|
939
|
+
isAgentRunning = true;
|
|
940
|
+
agentStartedAt = Date.now();
|
|
941
|
+
whimsicalIdx = 0; // reset so the first phrase is always "thinking"
|
|
942
|
+
editor.disableSubmit = true;
|
|
943
|
+
updateHeader(WHIMSICAL_PHRASES[0]);
|
|
944
|
+
activeLoader = new CancellableLoader(tui, (s) => brand.amber(s), (s) => brand.dim(s), "thinking");
|
|
945
|
+
insertBeforeEditor(activeLoader);
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
case "message_update":
|
|
949
|
+
case "message_end": {
|
|
950
|
+
const msg = event.message;
|
|
951
|
+
if (!msg || msg.role !== "assistant")
|
|
952
|
+
break;
|
|
953
|
+
// Scrub server-pushed assistant text before it reaches the
|
|
954
|
+
// Markdown widget (see `scrubRenderable`). The model can be
|
|
955
|
+
// steered to emit ANSI/OSC control bytes; the widget preserves
|
|
956
|
+
// raw escapes, so strip them here. The brand-coloured label
|
|
957
|
+
// prefix added below is Brigade-internal chalk and stays intact.
|
|
958
|
+
const text = scrubRenderable(extractAssistantText(msg));
|
|
959
|
+
if (!text)
|
|
960
|
+
break;
|
|
961
|
+
if (activeLoader) {
|
|
962
|
+
removeChild(activeLoader);
|
|
963
|
+
activeLoader = null;
|
|
964
|
+
}
|
|
965
|
+
// Label assistant turns with the agent's chosen name (from
|
|
966
|
+
// IDENTITY.md, exposed via state snapshot). Falls back to
|
|
967
|
+
// the runtime container name when the operator hasn't named
|
|
968
|
+
// the agent yet — same convention as the brand colour, just
|
|
969
|
+
// dynamic per-workspace.
|
|
970
|
+
const label = lastSnapshot?.agentName ?? "brigade";
|
|
971
|
+
const labelPrefix = depth > 0 ? "sub-agent" : label;
|
|
972
|
+
const renderedText = `${subIndent}${brand.agent(labelPrefix)} ${text}`;
|
|
973
|
+
// Per-depth streaming buffers: top-level (depth 0) and each sub-
|
|
974
|
+
// agent (depth ≥ 1) get their OWN Markdown block that grows in
|
|
975
|
+
// place. A child's message_update chunks now land in the child's
|
|
976
|
+
// own buffer (not appended as N fresh blocks, and not overwriting
|
|
977
|
+
// the parent's buffer).
|
|
978
|
+
const existing = activeAssistants.get(depth);
|
|
979
|
+
if (!existing) {
|
|
980
|
+
// Wave N5 (bug #6) — origin attribution. When this turn is
|
|
981
|
+
// running on a non-`main` session (e.g. a channel-routed
|
|
982
|
+
// `agent:<id>:whatsapp:direct:<peer>` lane), drop a small
|
|
983
|
+
// `↳ via <label>` chip ABOVE the assistant block so the
|
|
984
|
+
// operator can tell at a glance that the reply is the
|
|
985
|
+
// agent's answer to an inbound WhatsApp / Slack / cron
|
|
986
|
+
// message — not something they typed locally. We surface
|
|
987
|
+
// it only ONCE per (turn, depth), keyed off the first
|
|
988
|
+
// message_update arriving at this depth (when `existing`
|
|
989
|
+
// is undefined). The home session returns `undefined` from
|
|
990
|
+
// `formatSessionLabel` so the chip is silently omitted on
|
|
991
|
+
// the common path.
|
|
992
|
+
const originLabel = formatSessionLabel(payload.sessionId);
|
|
993
|
+
if (originLabel) {
|
|
994
|
+
insertBeforeEditor(new Text(`${subIndent}${brand.dim(`↳ via ${originLabel}`)}`, 0, 0));
|
|
995
|
+
}
|
|
996
|
+
const fresh = new Markdown(renderedText, 1, 0, markdownTheme);
|
|
997
|
+
activeAssistants.set(depth, fresh);
|
|
998
|
+
insertBeforeEditor(fresh);
|
|
999
|
+
}
|
|
1000
|
+
else {
|
|
1001
|
+
existing.setText(renderedText);
|
|
1002
|
+
// message_end carries the FINAL text — paint immediately so
|
|
1003
|
+
// the user never has to wait the debounce window for the
|
|
1004
|
+
// last chunk. message_update batches through the debouncer
|
|
1005
|
+
// so a 200-token reply paints ~12 times instead of ~200,
|
|
1006
|
+
// killing the flicker that blocked terminal scroll-back.
|
|
1007
|
+
if (event.type === "message_end") {
|
|
1008
|
+
flushStreamingRender();
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
scheduleStreamingRender();
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
case "tool_execution_start": {
|
|
1017
|
+
if (activeLoader) {
|
|
1018
|
+
removeChild(activeLoader);
|
|
1019
|
+
activeLoader = null;
|
|
1020
|
+
}
|
|
1021
|
+
// Close the current depth's assistant text block when a tool starts.
|
|
1022
|
+
// Otherwise the assistant block's position is locked at first stream-
|
|
1023
|
+
// chunk, and a long final answer flowing in AFTER the tools end ends
|
|
1024
|
+
// up rendered ABOVE them. Strictly chronological order — clearing
|
|
1025
|
+
// the per-depth pointer lets the next message_update at THIS depth
|
|
1026
|
+
// create a fresh block that lands below the most recent tool.
|
|
1027
|
+
// We clear ONLY this depth's buffer so a sub-agent's tool start
|
|
1028
|
+
// doesn't close the parent's open assistant block (separate streams).
|
|
1029
|
+
activeAssistants.delete(depth);
|
|
1030
|
+
// A tool starting is a turn-boundary for the open assistant
|
|
1031
|
+
// stream — flush any pending debounced paint so the assistant
|
|
1032
|
+
// block above renders its full text BEFORE the tool indicator
|
|
1033
|
+
// lands underneath.
|
|
1034
|
+
flushStreamingRender();
|
|
1035
|
+
const indicator = new Text(`${subIndent} ${brand.tool("⚡")} ${brand.tool(event.toolName)}`, 0, 0);
|
|
1036
|
+
pendingTools.set(event.toolCallId, indicator);
|
|
1037
|
+
insertBeforeEditor(indicator);
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
case "tool_execution_end": {
|
|
1041
|
+
const indicator = pendingTools.get(event.toolCallId);
|
|
1042
|
+
if (indicator) {
|
|
1043
|
+
const mark = event.isError ? brand.error("✗") : brand.tool("✓");
|
|
1044
|
+
// Append a short preview of what the tool produced so the
|
|
1045
|
+
// connect view matches `brigade chat` ("✓ bash · output").
|
|
1046
|
+
// Errors preserve newlines + use a bigger budget so the
|
|
1047
|
+
// gate's "brigade exec allow ..." call-to-action survives.
|
|
1048
|
+
const summary = summarizeToolResult(event.result, {
|
|
1049
|
+
preserveNewlines: event.isError,
|
|
1050
|
+
});
|
|
1051
|
+
// Scrub the server-pushed tool-result preview before it
|
|
1052
|
+
// reaches a Text widget (see `scrubRenderable`). Tool output
|
|
1053
|
+
// is the most direct attacker-influenceable render path —
|
|
1054
|
+
// a `bash`/`read` result can carry ANSI/OSC control bytes.
|
|
1055
|
+
// Done once here so both render branches below stay clean.
|
|
1056
|
+
const previewText = scrubRenderable(summary.preview);
|
|
1057
|
+
if (event.isError && summary.multiline) {
|
|
1058
|
+
indicator.setText(`${subIndent} ${mark} ${brand.tool(event.toolName)}`);
|
|
1059
|
+
const errIndent = `${subIndent} `;
|
|
1060
|
+
const indentedBody = previewText
|
|
1061
|
+
.split("\n")
|
|
1062
|
+
.map((line) => `${errIndent}${brand.dim(line)}`)
|
|
1063
|
+
.join("\n");
|
|
1064
|
+
insertBeforeEditor(new Text(indentedBody, 0, 0));
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
const preview = summary.hasContent ? ` ${brand.dim(`· ${previewText}`)}` : "";
|
|
1068
|
+
indicator.setText(`${subIndent} ${mark} ${brand.tool(event.toolName)}${preview}`);
|
|
1069
|
+
}
|
|
1070
|
+
tui.requestRender();
|
|
1071
|
+
pendingTools.delete(event.toolCallId);
|
|
1072
|
+
}
|
|
1073
|
+
break;
|
|
1074
|
+
}
|
|
1075
|
+
case "turn_end": {
|
|
1076
|
+
// Intentionally a no-op. Token totals (totalTokensIn / Out /
|
|
1077
|
+
// CostUsd) are accumulated SERVER-SIDE in server.ts:156-163
|
|
1078
|
+
// on every turn_end, then pushed to us via the very next
|
|
1079
|
+
// `state` event at server.ts:165. Our `state` handler above
|
|
1080
|
+
// stores that into `lastSnapshot` and calls updateHeader(),
|
|
1081
|
+
// which reads the totals from `lastSnapshot`. Doing the
|
|
1082
|
+
// accumulation HERE too would double-count.
|
|
1083
|
+
//
|
|
1084
|
+
// Kept as a labelled case so any future connect-only logic
|
|
1085
|
+
// (e.g. per-turn flash UI, telemetry hook) has a place to
|
|
1086
|
+
// land — and so the next audit doesn't flag this as missing.
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
case "compaction_start": {
|
|
1090
|
+
const pct = lastSnapshot?.contextUsagePercent != null
|
|
1091
|
+
? `${Math.round(lastSnapshot.contextUsagePercent)}%`
|
|
1092
|
+
: "high";
|
|
1093
|
+
insertBeforeEditor(new Text(` ${brand.dim(`⚡ compacting context (was ${pct})…`)}`, 0, 0));
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
case "compaction_end": {
|
|
1097
|
+
if (event.aborted) {
|
|
1098
|
+
insertBeforeEditor(new Text(` ${brand.dim("compaction aborted")}`, 0, 0));
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
// Pi's getContextUsage returns null right after compaction by
|
|
1102
|
+
// design — token estimates need a fresh LLM response. Show
|
|
1103
|
+
// that explicitly via the snapshot's percent (server pushes
|
|
1104
|
+
// a fresh snapshot post-compact).
|
|
1105
|
+
const after = lastSnapshot?.contextUsagePercent;
|
|
1106
|
+
const afterStr = after != null
|
|
1107
|
+
? `usage now ${Math.round(after)}%`
|
|
1108
|
+
: "usage refreshes after your next message";
|
|
1109
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim(`compacted · ${afterStr}`)}`, 0, 0));
|
|
1110
|
+
}
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1113
|
+
case "auto_retry_start": {
|
|
1114
|
+
// Pi auto-retries transient provider errors (rate limit, 5xx,
|
|
1115
|
+
// connection drop). Tell the user it's happening — without this,
|
|
1116
|
+
// a slow retry looks like the connection is just hanging.
|
|
1117
|
+
const attempt = event.attempt ?? 1;
|
|
1118
|
+
const max = event.maxAttempts ?? 1;
|
|
1119
|
+
const waitS = Math.round((event.delayMs ?? 0) / 100) / 10;
|
|
1120
|
+
insertBeforeEditor(new Text(` ${brand.dim(`↻ retrying (attempt ${attempt}/${max}, waiting ${waitS}s)…`)}`, 0, 0));
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
case "auto_retry_end": {
|
|
1124
|
+
if (event.success === false) {
|
|
1125
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`gave up after ${event.attempt} attempts`)}`, 0, 0));
|
|
1126
|
+
}
|
|
1127
|
+
break;
|
|
1128
|
+
}
|
|
1129
|
+
case "agent_end": {
|
|
1130
|
+
isAgentRunning = false;
|
|
1131
|
+
agentStartedAt = null;
|
|
1132
|
+
editor.disableSubmit = false;
|
|
1133
|
+
activeAssistants.clear();
|
|
1134
|
+
// Turn-end is the definitive flush point — even if every other
|
|
1135
|
+
// path missed flushing, this guarantees the last paint of the
|
|
1136
|
+
// turn lands before the editor re-enables for the operator.
|
|
1137
|
+
flushStreamingRender();
|
|
1138
|
+
if (activeLoader) {
|
|
1139
|
+
removeChild(activeLoader);
|
|
1140
|
+
activeLoader = null;
|
|
1141
|
+
}
|
|
1142
|
+
// Clear any tool indicators that never received a matching
|
|
1143
|
+
// `tool_execution_end` — a long session can accumulate these
|
|
1144
|
+
// when a model aborts mid-tool and they otherwise pin a Text
|
|
1145
|
+
// node in the children list per orphaned tool.
|
|
1146
|
+
pendingTools.clear();
|
|
1147
|
+
updateHeader();
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
// Reconnect notifications — let the user know what just happened so a
|
|
1153
|
+
// dropped/restored gateway doesn't look like phantom output.
|
|
1154
|
+
//
|
|
1155
|
+
// CRITICAL: on reconnect, request a fresh state snapshot AND aggressively
|
|
1156
|
+
// clear any "↯ tool" indicators that were waiting on a `tool_execution_end`
|
|
1157
|
+
// event we likely missed while the WS was disconnected. Without this, a
|
|
1158
|
+
// reconnect mid-tool leaves the TUI showing `↯ cron` (or any other tool)
|
|
1159
|
+
// forever even though the gateway has long since finished — the user sees
|
|
1160
|
+
// a "stuck" indicator that's purely a TUI state-staleness bug, not an
|
|
1161
|
+
// actual hang.
|
|
1162
|
+
client.on("reconnected", () => {
|
|
1163
|
+
insertBeforeEditor(new Text(` ${brand.dim("↻ reconnected to gateway")}`, 0, 0));
|
|
1164
|
+
// Re-subscription after a dropped/restored gateway. BrigadeClient opens
|
|
1165
|
+
// a BRAND-NEW socket on reconnect, so the gateway assigns a fresh
|
|
1166
|
+
// connection id whose per-connection agent/session subscription Sets are
|
|
1167
|
+
// EMPTY — and the broadcast filter falls through to "deliver everything",
|
|
1168
|
+
// losing server-side lane isolation. It also means the bound agent's
|
|
1169
|
+
// per-binding state snapshot (pushed only in response to a `subscribe`
|
|
1170
|
+
// with the agentId) is never re-sent, so a non-boot binding's header
|
|
1171
|
+
// reverts to the BOOT agent's snapshot. Re-issue the subscription below.
|
|
1172
|
+
//
|
|
1173
|
+
// First clear the last-committed sub mirror: the fresh connection has NO
|
|
1174
|
+
// prior server-side subscription, so leaving these set would make
|
|
1175
|
+
// applySubscription() fire a spurious `unsubscribe` for a sub this
|
|
1176
|
+
// connection never had. Reset → re-subscribe is the correct sequence.
|
|
1177
|
+
lastSubscribedAgentId = undefined;
|
|
1178
|
+
lastSubscribedSessionKey = undefined;
|
|
1179
|
+
// Fire-and-forget: ask the gateway for the current snapshot so the
|
|
1180
|
+
// `state` handler above updates `isAgentRunning` + the header. Errors
|
|
1181
|
+
// are swallowed — the next state push (any tool call / turn start)
|
|
1182
|
+
// will refresh anyway. The re-subscribe is appended AFTER this settles
|
|
1183
|
+
// (both success and failure) so ordering is deterministic and the
|
|
1184
|
+
// subscribe-time per-binding snapshot push lands after the get-state
|
|
1185
|
+
// reconcile.
|
|
1186
|
+
client.request("get-state").then((snap) => {
|
|
1187
|
+
if (!snap)
|
|
1188
|
+
return;
|
|
1189
|
+
lastSnapshot = snap;
|
|
1190
|
+
// Same one-way rule as the `state` handler: the agent-wide flag
|
|
1191
|
+
// may only CLEAR our lane's busy state, never set it.
|
|
1192
|
+
if (!snap.isAgentRunning)
|
|
1193
|
+
isAgentRunning = false;
|
|
1194
|
+
// If the gateway says no turn is in flight, then any tool
|
|
1195
|
+
// indicators we still hold are stale (their `tool_execution_end`
|
|
1196
|
+
// landed while we were disconnected). Mark each one as
|
|
1197
|
+
// completed-with-no-known-outcome so the TUI stops spinning.
|
|
1198
|
+
if (!snap.isAgentRunning && pendingTools.size > 0) {
|
|
1199
|
+
// Reconcile orphaned tool indicators by marking each as
|
|
1200
|
+
// completed-with-unknown-outcome. We don't know which tool's
|
|
1201
|
+
// `tool_execution_end` was missed during the disconnect, so we
|
|
1202
|
+
// can't infer the exit status; the dim ⋯ glyph signals "this
|
|
1203
|
+
// tool finished, but the TUI didn't see how" and stops the spin.
|
|
1204
|
+
for (const [, indicator] of pendingTools) {
|
|
1205
|
+
indicator.setText(` ${brand.dim("⋯ tool completed during disconnect")}`);
|
|
1206
|
+
}
|
|
1207
|
+
pendingTools.clear();
|
|
1208
|
+
}
|
|
1209
|
+
updateHeader();
|
|
1210
|
+
tui.requestRender();
|
|
1211
|
+
}, () => {
|
|
1212
|
+
/* best-effort — silently ignore */
|
|
1213
|
+
}).then(() => {
|
|
1214
|
+
// Re-subscribe the bound agent/session on the fresh connection.
|
|
1215
|
+
// Runs after get-state settles (the rejection handler above swallows
|
|
1216
|
+
// errors, so this chains in both cases) — deterministic ordering.
|
|
1217
|
+
// This also triggers the server's subscribe-time per-binding snapshot
|
|
1218
|
+
// push, restoring the correct header for a non-boot binding.
|
|
1219
|
+
void applySubscription();
|
|
1220
|
+
});
|
|
1221
|
+
});
|
|
1222
|
+
// Slash command + send wiring.
|
|
1223
|
+
editor.onSubmit = async (value) => {
|
|
1224
|
+
// SECURITY — scrub terminal escape sequences, leaked bracketed-paste markers,
|
|
1225
|
+
// and lone surrogates from input BEFORE it reaches command dispatch, the model
|
|
1226
|
+
// payload, or the echo. A hostile paste (or text the agent was told to copy
|
|
1227
|
+
// from a malicious page) can otherwise corrupt the terminal or smuggle control
|
|
1228
|
+
// bytes into the transcript. The single submit chokepoint covers every path.
|
|
1229
|
+
const trimmed = sanitizeTerminalInput(value).trim();
|
|
1230
|
+
if (!trimmed)
|
|
1231
|
+
return;
|
|
1232
|
+
// Local commands first — never reach the gateway.
|
|
1233
|
+
if (trimmed === "/exit" || trimmed === "/quit") {
|
|
1234
|
+
client.close();
|
|
1235
|
+
tui.stop();
|
|
1236
|
+
restoreTerminal();
|
|
1237
|
+
process.exit(0);
|
|
1238
|
+
}
|
|
1239
|
+
if (trimmed === "/help") {
|
|
1240
|
+
editor.setText("");
|
|
1241
|
+
insertBeforeEditor(new Markdown(`${brand.dim("commands")}\n` +
|
|
1242
|
+
`- ${chalk.bold("/exit")} or ${chalk.bold("/quit")} — disconnect & quit\n` +
|
|
1243
|
+
`- ${chalk.bold("/help")} — this list\n` +
|
|
1244
|
+
`- ${chalk.bold("/model <id>")} — switch to a configured model on the gateway\n` +
|
|
1245
|
+
`- ${chalk.bold("/thinking <level>")} — set reasoning effort (off|minimal|low|medium|high|xhigh)\n` +
|
|
1246
|
+
`- ${chalk.bold("/compact")} — summarize older turns to free up context\n` +
|
|
1247
|
+
`- ${chalk.bold("/allow-all <on|off>")} — skip shell-approval prompts for this session (safety guards still apply)\n` +
|
|
1248
|
+
`- ${chalk.bold("/grant-skill <name> [--yes]")} — preview/approve a skill's declared commands so the agent runs them without asking\n` +
|
|
1249
|
+
`- ${chalk.bold("/revoke-skill <name>")} — remove a skill's granted commands\n` +
|
|
1250
|
+
`- ${chalk.bold("/abort")} — stop the in-flight turn\n` +
|
|
1251
|
+
`- ${chalk.bold("/usage")} — show token + cost totals for this session\n` +
|
|
1252
|
+
`- ${chalk.bold("/reasoning <on|off>")} — show/hide the model's thinking blocks before replies (default: off)\n` +
|
|
1253
|
+
`- ${chalk.bold("/agent [<id>]")} — show/bind the connection's active agent\n` +
|
|
1254
|
+
`- ${chalk.bold("/session [<key>]")} — show/bind the connection's active session\n` +
|
|
1255
|
+
`- ${chalk.bold("/agents")} — list every agent the gateway knows about\n` +
|
|
1256
|
+
`- ${chalk.bold("/sessions [--all]")} — list live sessions (bound agent or all)\n` +
|
|
1257
|
+
`- ${chalk.bold("/mute <id|key>")} — unsubscribe from an agent id or session key\n` +
|
|
1258
|
+
`- ${chalk.bold("/memory")} — list recent memories\n` +
|
|
1259
|
+
`- ${chalk.bold("/memory search <q>")} — search memories by keyword\n` +
|
|
1260
|
+
`- ${chalk.bold("/memory inspect <id>")} — show a single memory by id prefix\n` +
|
|
1261
|
+
`- ${chalk.bold("/memory stats")} — show memory counts by segment / origin\n` +
|
|
1262
|
+
`- ${chalk.bold("/org")} — show the Pride hierarchy chart (Higher Office / Departments)\n` +
|
|
1263
|
+
`- ${chalk.bold("/org <agent-id>")} — show a sub-tree of the chart\n` +
|
|
1264
|
+
`- ${chalk.bold("/org --departments")} — chart without the Higher Office block\n` +
|
|
1265
|
+
`- ${chalk.bold("/org --explain <from> <to>")} — why this edge exists (or does not)\n` +
|
|
1266
|
+
`- ${chalk.bold("Ctrl+C")} — abort the current turn (same as /abort)\n` +
|
|
1267
|
+
`- ${chalk.bold("Ctrl+D")} — quit\n\n` +
|
|
1268
|
+
brand.dim("To add a new provider, run `brigade onboard` on the gateway machine."), 1, 0, markdownTheme));
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
// /session [key] — print or rebind the connection's bound session key.
|
|
1272
|
+
// Wave K — without this the TUI can only steer/abort/compact the boot
|
|
1273
|
+
// agent's `main` lane. With `/session agent:main:whatsapp:<jid>` an
|
|
1274
|
+
// operator can intervene in a runaway channel turn from the TUI.
|
|
1275
|
+
// No-arg form prints the current binding.
|
|
1276
|
+
if (trimmed === "/session" || trimmed.startsWith("/session ")) {
|
|
1277
|
+
editor.setText("");
|
|
1278
|
+
const arg = trimmed === "/session" ? "" : trimmed.slice("/session ".length).trim();
|
|
1279
|
+
if (!arg) {
|
|
1280
|
+
const cur = boundSessionKey ?? lastSnapshot?.sessionKey ?? "(unset)";
|
|
1281
|
+
insertBeforeEditor(new Text(` ${brand.dim("bound session:")} ${brand.amber(cur)}`, 0, 0));
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
boundSessionKey = arg;
|
|
1285
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("bound to session")} ${brand.amber(arg)}`, 0, 0));
|
|
1286
|
+
updateHeader();
|
|
1287
|
+
void applySubscription();
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
// /agents — list every agent the gateway has runtime state for.
|
|
1291
|
+
// Wave N5 (bug #9). Pulls from the gateway via `agents.list` so the
|
|
1292
|
+
// list is always source-of-truth (no client-side mirror to fall out
|
|
1293
|
+
// of sync with set-model writes). The currently-bound agent is
|
|
1294
|
+
// flagged with a `←` so the operator can tell at a glance which
|
|
1295
|
+
// agent their typing currently targets.
|
|
1296
|
+
if (trimmed === "/agents") {
|
|
1297
|
+
editor.setText("");
|
|
1298
|
+
let agents;
|
|
1299
|
+
try {
|
|
1300
|
+
agents = await client.request("agents.list");
|
|
1301
|
+
}
|
|
1302
|
+
catch (err) {
|
|
1303
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
if (agents.length === 0) {
|
|
1307
|
+
insertBeforeEditor(new Text(` ${brand.dim("no agents configured on the gateway")}`, 0, 0));
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
const bound = boundAgentId ?? lastSnapshot?.agentId;
|
|
1311
|
+
const lines = agents.map((a) => {
|
|
1312
|
+
const here = a.id === bound ? " " + brand.amber("← bound") : "";
|
|
1313
|
+
const bootTag = a.isBoot ? " " + brand.dim("(boot)") : "";
|
|
1314
|
+
const persona = a.personaName ? " " + brand.dim(`· ${a.personaName}`) : "";
|
|
1315
|
+
return ` ${brand.white(a.id)}${persona} ${brand.dim(`${a.provider} · ${a.modelId}`)}${bootTag}${here}`;
|
|
1316
|
+
});
|
|
1317
|
+
insertBeforeEditor(new Markdown(`${brand.dim("agents on the gateway:")}\n${lines.join("\n")}\n\n${brand.dim("usage: /agent <id> to bind")}`, 1, 0, markdownTheme));
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
// /sessions [--all] — list live (in-flight Pi) sessions. Defaults to
|
|
1321
|
+
// the bound agent's sessions; `--all` returns every agent's. Wave N5
|
|
1322
|
+
// (bug #9). Combine with /session <key> to bind to one of them.
|
|
1323
|
+
if (trimmed === "/sessions" || trimmed.startsWith("/sessions ")) {
|
|
1324
|
+
editor.setText("");
|
|
1325
|
+
const arg = trimmed === "/sessions" ? "" : trimmed.slice("/sessions ".length).trim();
|
|
1326
|
+
const wantsAll = /\b--?all\b/i.test(arg);
|
|
1327
|
+
let sessions;
|
|
1328
|
+
try {
|
|
1329
|
+
const params = wantsAll
|
|
1330
|
+
? { all: true }
|
|
1331
|
+
: boundAgentId !== undefined
|
|
1332
|
+
? { agentId: boundAgentId }
|
|
1333
|
+
: {};
|
|
1334
|
+
sessions = await client.request("sessions.list", params);
|
|
1335
|
+
}
|
|
1336
|
+
catch (err) {
|
|
1337
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
if (sessions.length === 0) {
|
|
1341
|
+
const scope = wantsAll
|
|
1342
|
+
? "no live sessions on the gateway"
|
|
1343
|
+
: `no live sessions for agent ${boundAgentId ?? lastSnapshot?.agentId ?? "main"}`;
|
|
1344
|
+
insertBeforeEditor(new Text(` ${brand.dim(scope)} ${brand.dim("(turns run between requests — try again during one)")}`, 0, 0));
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
const boundKey = boundSessionKey ?? lastSnapshot?.sessionKey;
|
|
1348
|
+
const lines = sessions.map((s) => {
|
|
1349
|
+
const friendly = formatSessionLabel(s.sessionKey) ?? brand.dim("(home)");
|
|
1350
|
+
const here = s.sessionKey === boundKey ? " " + brand.amber("← bound") : "";
|
|
1351
|
+
return ` ${brand.white(s.agentId)} ${friendly} ${brand.dim(s.sessionKey)}${here}`;
|
|
1352
|
+
});
|
|
1353
|
+
const scopeLine = wantsAll
|
|
1354
|
+
? "live sessions (all agents):"
|
|
1355
|
+
: `live sessions for agent ${boundAgentId ?? lastSnapshot?.agentId ?? "main"}:`;
|
|
1356
|
+
insertBeforeEditor(new Markdown(`${brand.dim(scopeLine)}\n${lines.join("\n")}\n\n${brand.dim("usage: /session <key> to bind · /mute <id|key> to unsubscribe")}`, 1, 0, markdownTheme));
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
// /mute <id> — drop a subscription on the gateway. Accepts EITHER
|
|
1360
|
+
// an agentId (e.g. `ops`) or a full sessionKey (e.g.
|
|
1361
|
+
// `agent:main:whatsapp:direct:+91…`). Heuristic: anything starting
|
|
1362
|
+
// with `agent:` is treated as a sessionKey; everything else is an
|
|
1363
|
+
// agentId. Wave N5 (bug #9). Wires to the existing `unsubscribe`
|
|
1364
|
+
// RPC so the per-conn filter (server.ts:861-882) stops delivering
|
|
1365
|
+
// frames tagged with that lane to this connection.
|
|
1366
|
+
if (trimmed === "/mute" || trimmed.startsWith("/mute ")) {
|
|
1367
|
+
editor.setText("");
|
|
1368
|
+
const arg = trimmed === "/mute" ? "" : trimmed.slice("/mute ".length).trim();
|
|
1369
|
+
if (!arg) {
|
|
1370
|
+
insertBeforeEditor(new Text(` ${brand.dim("usage: /mute <agent-id|session-key>")}`, 0, 0));
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
const isSessionKey = arg.toLowerCase().startsWith("agent:");
|
|
1374
|
+
const params = isSessionKey
|
|
1375
|
+
? { sessionId: arg }
|
|
1376
|
+
: { agentId: arg };
|
|
1377
|
+
try {
|
|
1378
|
+
await client.request("unsubscribe", params);
|
|
1379
|
+
// Keep our local lastSubscribed* mirror honest so a later
|
|
1380
|
+
// applySubscription() doesn't try to undo a subscribe we just
|
|
1381
|
+
// muted — only clear the mirror entry that matches the muted lane.
|
|
1382
|
+
if (isSessionKey && lastSubscribedSessionKey === arg) {
|
|
1383
|
+
lastSubscribedSessionKey = undefined;
|
|
1384
|
+
}
|
|
1385
|
+
if (!isSessionKey && lastSubscribedAgentId === arg) {
|
|
1386
|
+
lastSubscribedAgentId = undefined;
|
|
1387
|
+
}
|
|
1388
|
+
const kind = isSessionKey ? "session" : "agent";
|
|
1389
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim(`muted ${kind}`)} ${brand.amber(arg)}`, 0, 0));
|
|
1390
|
+
}
|
|
1391
|
+
catch (err) {
|
|
1392
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1393
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
|
|
1394
|
+
}
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
// /agent [id] — print or rebind the connection's bound agent. When the
|
|
1398
|
+
// gateway runs multi-agent (cfg.agents.<id> with per-agent runtime),
|
|
1399
|
+
// the operator uses this to switch which agent their typing targets
|
|
1400
|
+
// without reconnecting. No-arg form prints the current binding.
|
|
1401
|
+
if (trimmed === "/agent" || trimmed.startsWith("/agent ")) {
|
|
1402
|
+
editor.setText("");
|
|
1403
|
+
const arg = trimmed === "/agent" ? "" : trimmed.slice("/agent ".length).trim();
|
|
1404
|
+
if (!arg) {
|
|
1405
|
+
const cur = boundAgentId ?? lastSnapshot?.agentId ?? "(unset)";
|
|
1406
|
+
insertBeforeEditor(new Text(` ${brand.dim("bound agent:")} ${brand.amber(cur)}`, 0, 0));
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
let known;
|
|
1410
|
+
try {
|
|
1411
|
+
known = await client.request("agents.list");
|
|
1412
|
+
}
|
|
1413
|
+
catch (err) {
|
|
1414
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`agents.list failed: ${err instanceof Error ? err.message : String(err)}`)}`, 0, 0));
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (!known.some((a) => a.id === arg)) {
|
|
1418
|
+
const available = known.map((a) => a.id).join(", ") || "(none)";
|
|
1419
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`unknown agent "${arg}"`)}\n ${brand.dim(`available: ${available}`)}\n ${brand.dim("usage: /agent <id> — try /agents to see the full list")}`, 0, 0));
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
boundAgentId = arg;
|
|
1423
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("bound to agent")} ${brand.amber(arg)}`, 0, 0));
|
|
1424
|
+
updateHeader();
|
|
1425
|
+
void applySubscription();
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
// /org — Pride hierarchy chart. Calls the gateway's `org.snapshot`
|
|
1429
|
+
// RPC and renders the result inline. Four shapes:
|
|
1430
|
+
// /org → full chart (pre-rendered ANSI+emoji)
|
|
1431
|
+
// /org <agent-id> → re-render the subtree rooted at <id>
|
|
1432
|
+
// /org --departments → re-render without Higher Office
|
|
1433
|
+
// /org --explain <from> <to> → derived-graph edge explain
|
|
1434
|
+
// When cfg.org is absent the gateway returns ok=false with the
|
|
1435
|
+
// flat-crew redirect note; we print it verbatim (no chart frame).
|
|
1436
|
+
if (trimmed === "/org" || trimmed.startsWith("/org ")) {
|
|
1437
|
+
editor.setText("");
|
|
1438
|
+
const rawArgs = trimmed === "/org" ? "" : trimmed.slice("/org ".length);
|
|
1439
|
+
const parsed = parseOrgSlash(rawArgs);
|
|
1440
|
+
if (parsed.kind === "error") {
|
|
1441
|
+
insertBeforeEditor(new Text(` ${brand.dim(parsed.message)}`, 0, 0));
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
let snap;
|
|
1445
|
+
try {
|
|
1446
|
+
snap = await client.request("org.snapshot");
|
|
1447
|
+
}
|
|
1448
|
+
catch (err) {
|
|
1449
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1450
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
if (snap.ok === false) {
|
|
1454
|
+
insertBeforeEditor(new Markdown(snap.redirect, 1, 0, markdownTheme));
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
const graph = snap.graph;
|
|
1458
|
+
// Read department-head pins from the snapshot graph caller side
|
|
1459
|
+
// is fine for re-renders — the gateway already applied them
|
|
1460
|
+
// when computing the pre-rendered `charts.tui` for the happy
|
|
1461
|
+
// path. For client-side re-render branches (subtree /
|
|
1462
|
+
// departments) we just pass `undefined` since the pin map
|
|
1463
|
+
// isn't carried in the snapshot response today. The most-
|
|
1464
|
+
// senior fallback path inside `flattenToThreeTiers` still
|
|
1465
|
+
// produces a sensible chart.
|
|
1466
|
+
const pins = undefined;
|
|
1467
|
+
if (parsed.kind === "show") {
|
|
1468
|
+
// Pre-shape: ensure the trailing footer rule sits on its
|
|
1469
|
+
// own line so the rendered Markdown widget doesn't collapse
|
|
1470
|
+
// it into the previous block.
|
|
1471
|
+
let body = snap.charts.tui;
|
|
1472
|
+
if (!body.endsWith("\n"))
|
|
1473
|
+
body += "\n";
|
|
1474
|
+
if (!body.includes(BRIGADE_FOOTER_RULE + "\n")) {
|
|
1475
|
+
body = body.replace(BRIGADE_FOOTER_RULE, BRIGADE_FOOTER_RULE + "\n");
|
|
1476
|
+
}
|
|
1477
|
+
insertBeforeEditor(new Text(body, 0, 0));
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
if (parsed.kind === "explain") {
|
|
1481
|
+
const outcome = computeExplain(graph, parsed.from, parsed.to);
|
|
1482
|
+
insertBeforeEditor(new Text(formatExplain(outcome), 0, 0));
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
if (parsed.kind === "subtree") {
|
|
1486
|
+
const filtered = filterGraphToSubtree(graph, parsed.agentId);
|
|
1487
|
+
if (!filtered) {
|
|
1488
|
+
insertBeforeEditor(new Text(` ${brand.error(`✗ Unknown agent "${parsed.agentId}". Run /org to see the full chart.`)}`, 0, 0));
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
const body = renderPrideChartWithPins(filtered, pins, {
|
|
1492
|
+
emoji: true,
|
|
1493
|
+
ansi: true,
|
|
1494
|
+
});
|
|
1495
|
+
let withFooter = body;
|
|
1496
|
+
if (!withFooter.endsWith("\n"))
|
|
1497
|
+
withFooter += "\n";
|
|
1498
|
+
if (!withFooter.includes(BRIGADE_FOOTER_RULE + "\n")) {
|
|
1499
|
+
withFooter = withFooter.replace(BRIGADE_FOOTER_RULE, BRIGADE_FOOTER_RULE + "\n");
|
|
1500
|
+
}
|
|
1501
|
+
insertBeforeEditor(new Text(withFooter, 0, 0));
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
// parsed.kind === "departments"
|
|
1505
|
+
const body = renderDepartmentsOnly(graph, pins, {
|
|
1506
|
+
emoji: true,
|
|
1507
|
+
ansi: true,
|
|
1508
|
+
});
|
|
1509
|
+
let withFooter = body;
|
|
1510
|
+
if (!withFooter.endsWith("\n"))
|
|
1511
|
+
withFooter += "\n";
|
|
1512
|
+
if (!withFooter.includes(BRIGADE_FOOTER_RULE + "\n")) {
|
|
1513
|
+
withFooter = withFooter.replace(BRIGADE_FOOTER_RULE, BRIGADE_FOOTER_RULE + "\n");
|
|
1514
|
+
}
|
|
1515
|
+
insertBeforeEditor(new Text(withFooter, 0, 0));
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
// /abort — explicit slash-form for the same action Ctrl+C performs.
|
|
1519
|
+
// Returning true from `handle.abort()` means a turn was running; the
|
|
1520
|
+
// chat loop's SIGINT path uses the same primitive.
|
|
1521
|
+
if (trimmed === "/abort") {
|
|
1522
|
+
editor.setText("");
|
|
1523
|
+
if (!isAgentRunning) {
|
|
1524
|
+
insertBeforeEditor(new Text(` ${brand.dim("nothing to abort — agent is idle")}`, 0, 0));
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
try {
|
|
1528
|
+
await client.request("abort", withBinding());
|
|
1529
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.dim("aborted")}`, 0, 0));
|
|
1530
|
+
}
|
|
1531
|
+
catch (err) {
|
|
1532
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1533
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
|
|
1534
|
+
}
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
// /reasoning [on|off] — toggle whether the assistant's thinking blocks
|
|
1538
|
+
// render before each reply. Pi pushes thinking via `pi` events
|
|
1539
|
+
// regardless; this is purely a local view filter applied in
|
|
1540
|
+
// `extractAssistantText`.
|
|
1541
|
+
if (trimmed === "/memory" || trimmed.startsWith("/memory ")) {
|
|
1542
|
+
editor.setText("");
|
|
1543
|
+
const rest = trimmed.slice("/memory".length).trim();
|
|
1544
|
+
const sp = rest.indexOf(" ");
|
|
1545
|
+
const verb = (sp === -1 ? rest : rest.slice(0, sp)).toLowerCase();
|
|
1546
|
+
const arg = sp === -1 ? "" : rest.slice(sp + 1).trim();
|
|
1547
|
+
let action = "list";
|
|
1548
|
+
let query;
|
|
1549
|
+
let memoryId;
|
|
1550
|
+
if (verb === "search") {
|
|
1551
|
+
action = "search";
|
|
1552
|
+
query = arg;
|
|
1553
|
+
}
|
|
1554
|
+
else if (verb === "inspect") {
|
|
1555
|
+
action = "inspect";
|
|
1556
|
+
memoryId = arg;
|
|
1557
|
+
}
|
|
1558
|
+
else if (verb === "stats") {
|
|
1559
|
+
action = "stats";
|
|
1560
|
+
}
|
|
1561
|
+
else if (verb === "list" || verb === "") {
|
|
1562
|
+
action = "list";
|
|
1563
|
+
}
|
|
1564
|
+
else {
|
|
1565
|
+
// bare "/memory <terms>" → treat the whole thing as a search
|
|
1566
|
+
action = "search";
|
|
1567
|
+
query = rest;
|
|
1568
|
+
}
|
|
1569
|
+
try {
|
|
1570
|
+
const res = (await client.request("memory-query", {
|
|
1571
|
+
...withBinding(),
|
|
1572
|
+
action,
|
|
1573
|
+
...(query ? { query } : {}),
|
|
1574
|
+
...(memoryId ? { memoryId } : {}),
|
|
1575
|
+
}));
|
|
1576
|
+
const lines = [];
|
|
1577
|
+
if (res.action === "stats" && res.stats) {
|
|
1578
|
+
const s = res.stats;
|
|
1579
|
+
const segs = Object.entries(s.bySegment)
|
|
1580
|
+
.sort((a, b) => b[1] - a[1])
|
|
1581
|
+
.map(([k, v]) => `${k} ${v}`)
|
|
1582
|
+
.join(", ");
|
|
1583
|
+
lines.push(` memory — ${s.active} active (${s.total} total, ${s.archived} archived)`);
|
|
1584
|
+
lines.push(` by segment: ${segs || "—"}`);
|
|
1585
|
+
lines.push(` by origin: owner ${s.owner}, channel ${s.channel} · added last 7d: ${s.addedLast7d}`);
|
|
1586
|
+
}
|
|
1587
|
+
else if (res.facts.length === 0) {
|
|
1588
|
+
lines.push(" (no matching memories)");
|
|
1589
|
+
}
|
|
1590
|
+
else {
|
|
1591
|
+
res.facts.forEach((f, i) => {
|
|
1592
|
+
const sc = f.score !== undefined ? ` ·${f.score}` : "";
|
|
1593
|
+
const lifecycleTag = f.lifecycle && f.lifecycle !== "active"
|
|
1594
|
+
? ` ${brand.dim(`[${f.lifecycle}]`)}`
|
|
1595
|
+
: "";
|
|
1596
|
+
lines.push(` ${i + 1}. ${f.content}${lifecycleTag}`);
|
|
1597
|
+
lines.push(` ${f.segment} · ${f.origin} · ${f.memoryId}${sc}`);
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
insertBeforeEditor(new Text(`${lines.join("\n")}\n`, 0, 0));
|
|
1601
|
+
}
|
|
1602
|
+
catch (err) {
|
|
1603
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
|
|
1604
|
+
}
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
if (trimmed === "/reasoning" || trimmed.startsWith("/reasoning ")) {
|
|
1608
|
+
editor.setText("");
|
|
1609
|
+
const arg = trimmed === "/reasoning" ? "" : trimmed.slice("/reasoning ".length).trim().toLowerCase();
|
|
1610
|
+
if (arg === "on" || arg === "true" || arg === "1") {
|
|
1611
|
+
showThinking = true;
|
|
1612
|
+
}
|
|
1613
|
+
else if (arg === "off" || arg === "false" || arg === "0") {
|
|
1614
|
+
showThinking = false;
|
|
1615
|
+
}
|
|
1616
|
+
else if (arg.length === 0 || arg === "toggle") {
|
|
1617
|
+
showThinking = !showThinking;
|
|
1618
|
+
}
|
|
1619
|
+
else {
|
|
1620
|
+
insertBeforeEditor(new Text(` ${brand.dim("usage: /reasoning <on|off>")}`, 0, 0));
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
insertBeforeEditor(new Text(` ${brand.dim(showThinking ? "reasoning: on (model thinking will render before each reply)" : "reasoning: off")}`, 0, 0));
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
// /usage — render the cumulative usage block from the latest state
|
|
1627
|
+
// snapshot. All fields come from the server's SessionStateSnapshot
|
|
1628
|
+
// — no extra RPC needed.
|
|
1629
|
+
if (trimmed === "/usage") {
|
|
1630
|
+
editor.setText("");
|
|
1631
|
+
const snap = lastSnapshot;
|
|
1632
|
+
if (!snap) {
|
|
1633
|
+
insertBeforeEditor(new Text(` ${brand.dim("no usage yet — server hasn't sent a state snapshot")}`, 0, 0));
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
const tokenIn = snap.totalTokensIn.toLocaleString();
|
|
1637
|
+
const tokenOut = snap.totalTokensOut.toLocaleString();
|
|
1638
|
+
const tokenTotal = (snap.totalTokensIn + snap.totalTokensOut).toLocaleString();
|
|
1639
|
+
const costStr = snap.totalCostUsd > 0 ? `$${snap.totalCostUsd.toFixed(4)}` : "$0.0000";
|
|
1640
|
+
const ctxStr = snap.contextUsagePercent != null ? `${Math.round(snap.contextUsagePercent)}%` : "—";
|
|
1641
|
+
insertBeforeEditor(new Markdown(`${brand.dim("usage")}\n` +
|
|
1642
|
+
`- ${chalk.bold("model:")} ${snap.provider ?? "?"} · ${snap.modelId ?? "?"}\n` +
|
|
1643
|
+
`- ${chalk.bold("turns:")} ${snap.messageCount}\n` +
|
|
1644
|
+
`- ${chalk.bold("tokens:")} ${tokenIn} in · ${tokenOut} out · ${tokenTotal} total\n` +
|
|
1645
|
+
`- ${chalk.bold("cost:")} ${costStr}\n` +
|
|
1646
|
+
`- ${chalk.bold("context:")} ${ctxStr} used\n` +
|
|
1647
|
+
`- ${chalk.bold("thinking:")} ${snap.thinkingLevel}` +
|
|
1648
|
+
(snap.supportsThinking
|
|
1649
|
+
? brand.dim(` (available: ${snap.availableThinkingLevels.join(", ")})`)
|
|
1650
|
+
: brand.dim(" (model doesn't support reasoning)")), 1, 0, markdownTheme));
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
// Mid-turn submit → STEER. The gateway has the same Pi semantics; queueing
|
|
1654
|
+
// the message lets the model see it on the next iteration without abort.
|
|
1655
|
+
if (isAgentRunning) {
|
|
1656
|
+
editor.setText("");
|
|
1657
|
+
try {
|
|
1658
|
+
await client.request("steer", withBinding({ text: trimmed }));
|
|
1659
|
+
insertBeforeEditor(new Markdown(`${brand.user("you")} ${trimmed}`, 1, 0, markdownTheme));
|
|
1660
|
+
insertBeforeEditor(new Text(` ${brand.dim("↳ queued — the model will see this on its next turn")}`, 0, 0));
|
|
1661
|
+
}
|
|
1662
|
+
catch (err) {
|
|
1663
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1664
|
+
if (msg.includes("nothing to steer")) {
|
|
1665
|
+
// Stale busy flag — our lane has no live turn (it ended a beat
|
|
1666
|
+
// ago, or the busy signal came from another session before the
|
|
1667
|
+
// one-way snapshot rule existed). The operator's message must
|
|
1668
|
+
// never be lost: clear the flag and send it as a normal prompt.
|
|
1669
|
+
isAgentRunning = false;
|
|
1670
|
+
insertBeforeEditor(new Markdown(`${brand.user("you")} ${trimmed}`, 1, 0, markdownTheme));
|
|
1671
|
+
try {
|
|
1672
|
+
lastUserPrompt = trimmed; // remember it as the replay message for a later `/switch` (Carrow) handoff
|
|
1673
|
+
await client.request("prompt", withBinding({ text: trimmed }), { timeoutMs: 0 });
|
|
1674
|
+
}
|
|
1675
|
+
catch (err2) {
|
|
1676
|
+
const msg2 = err2 instanceof Error ? err2.message : String(err2);
|
|
1677
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg2)}`, 0, 0));
|
|
1678
|
+
}
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
|
|
1682
|
+
}
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
// /compact — same long-run rationale as `prompt` above; compaction
|
|
1686
|
+
// can take a while on a big transcript, beyond the default 60s.
|
|
1687
|
+
if (trimmed === "/compact") {
|
|
1688
|
+
editor.setText("");
|
|
1689
|
+
insertBeforeEditor(new Text(` ${brand.dim("Compacting…")}`, 0, 0));
|
|
1690
|
+
try {
|
|
1691
|
+
await client.request("compact", withBinding(), { timeoutMs: 0 });
|
|
1692
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("Compacted")}`, 0, 0));
|
|
1693
|
+
}
|
|
1694
|
+
catch (err) {
|
|
1695
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1696
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`Compaction failed: ${msg}`)}`, 0, 0));
|
|
1697
|
+
}
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
// /allow-all <on|off> — arm/disarm session-scoped exec approval bypass.
|
|
1701
|
+
// Skips the shell-approval PROMPT for this session only; it can't bypass
|
|
1702
|
+
// the config/path-write guards or hard-deny patterns, and clears on
|
|
1703
|
+
// gateway restart.
|
|
1704
|
+
if (trimmed === "/allow-all" || trimmed.startsWith("/allow-all ")) {
|
|
1705
|
+
editor.setText("");
|
|
1706
|
+
const arg = trimmed === "/allow-all" ? "" : trimmed.slice("/allow-all ".length).trim().toLowerCase();
|
|
1707
|
+
if (arg !== "on" && arg !== "off") {
|
|
1708
|
+
insertBeforeEditor(new Markdown(`${brand.dim("usage: /allow-all on|off")}\n` +
|
|
1709
|
+
`Skips the shell-approval prompt for THIS session. It can't bypass the safety ` +
|
|
1710
|
+
`guards (writes to brigade.json / encryption.key / auth, hard-deny patterns), ` +
|
|
1711
|
+
`doesn't affect sub-agents, and clears on gateway restart.`, 1, 0, markdownTheme));
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
const enabled = arg === "on";
|
|
1715
|
+
try {
|
|
1716
|
+
const res = (await client.request("exec-allow-all", { ...withBinding(), enabled }));
|
|
1717
|
+
insertBeforeEditor(new Text(enabled
|
|
1718
|
+
? ` ${brand.amber("⚠")} ${brand.dim(`allow-all ON for ${res?.sessionKey ?? "this session"} — shell commands run without asking (safety guards still apply). /allow-all off to disarm.`)}`
|
|
1719
|
+
: ` ${brand.amber("✓")} ${brand.dim("allow-all OFF — shell commands prompt for approval again.")}`, 0, 0));
|
|
1720
|
+
}
|
|
1721
|
+
catch (err) {
|
|
1722
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1723
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`allow-all failed: ${msg}`)}`, 0, 0));
|
|
1724
|
+
}
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
// /grant-skill <name> [--yes] — preview (default) or apply a skill's
|
|
1728
|
+
// command grant. Preview shows the commands the skill declares; --yes
|
|
1729
|
+
// pre-approves them so the agent runs its own skill without prompting.
|
|
1730
|
+
// The grant is a SNAPSHOT — editing the skill later can't widen it.
|
|
1731
|
+
if (trimmed === "/grant-skill" || trimmed.startsWith("/grant-skill ")) {
|
|
1732
|
+
editor.setText("");
|
|
1733
|
+
const rest = trimmed === "/grant-skill" ? "" : trimmed.slice("/grant-skill ".length).trim();
|
|
1734
|
+
const apply = /(^|\s)(--yes|-y)(\s|$)/.test(rest);
|
|
1735
|
+
const name = rest.replace(/(^|\s)(--yes|-y)(\s|$)/g, " ").trim();
|
|
1736
|
+
if (!name) {
|
|
1737
|
+
insertBeforeEditor(new Markdown(`${brand.dim("usage: /grant-skill <name> [--yes]")}\n` +
|
|
1738
|
+
`Preview the shell commands a skill declares; add ${chalk.bold("--yes")} to pre-approve ` +
|
|
1739
|
+
`them for this agent so it stops asking. A grant is a snapshot — editing the skill ` +
|
|
1740
|
+
`later won't widen it. Revoke with /revoke-skill.`, 1, 0, markdownTheme));
|
|
1741
|
+
return;
|
|
1742
|
+
}
|
|
1743
|
+
try {
|
|
1744
|
+
const res = (await client.request("exec-grant-skill", {
|
|
1745
|
+
...withBinding(),
|
|
1746
|
+
skillName: name,
|
|
1747
|
+
apply,
|
|
1748
|
+
}));
|
|
1749
|
+
if (!res?.found) {
|
|
1750
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`No skill named "${name}" is visible to this agent.`)}`, 0, 0));
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
if (res.emptyManifest) {
|
|
1754
|
+
insertBeforeEditor(new Markdown(`${brand.dim(`Skill "${res.skill}" declares no commands to grant.`)}\n` +
|
|
1755
|
+
`Add a ${chalk.bold("commands:")} / ${chalk.bold("command-patterns:")} block to its SKILL.md ` +
|
|
1756
|
+
`frontmatter, then re-run.`, 1, 0, markdownTheme));
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
const manifest = res.manifest ?? { commands: [], patterns: [] };
|
|
1760
|
+
const lines = [
|
|
1761
|
+
...manifest.commands.map((c) => ` • ${c}`),
|
|
1762
|
+
...manifest.patterns.map((p) => ` ~ /${p}/`),
|
|
1763
|
+
].join("\n");
|
|
1764
|
+
if (res.applied) {
|
|
1765
|
+
const granted = res.granted ?? { commands: [], patterns: [] };
|
|
1766
|
+
const n = granted.commands.length + granted.patterns.length;
|
|
1767
|
+
const refused = res.refused && res.refused.length > 0
|
|
1768
|
+
? `\n${brand.amber("refused (hard-deny):")} ${res.refused.join(", ")}`
|
|
1769
|
+
: "";
|
|
1770
|
+
insertBeforeEditor(new Markdown(`${brand.amber("✓")} Granted ${n} command(s) from ${chalk.bold(res.skill ?? name)} — ` +
|
|
1771
|
+
`the agent can now run them without prompting.\n${lines}${refused}\n` +
|
|
1772
|
+
`${brand.dim(`Revoke with /revoke-skill ${res.skill ?? name}`)}`, 1, 0, markdownTheme));
|
|
1773
|
+
}
|
|
1774
|
+
else {
|
|
1775
|
+
insertBeforeEditor(new Markdown(`${chalk.bold(res.skill ?? name)} declares these commands:\n${lines}\n\n` +
|
|
1776
|
+
`${brand.dim(`Approve them with: /grant-skill ${res.skill ?? name} --yes`)}`, 1, 0, markdownTheme));
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
catch (err) {
|
|
1780
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1781
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`grant-skill failed: ${msg}`)}`, 0, 0));
|
|
1782
|
+
}
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
// /revoke-skill <name> — remove a skill's granted commands from the allowlist.
|
|
1786
|
+
if (trimmed === "/revoke-skill" || trimmed.startsWith("/revoke-skill ")) {
|
|
1787
|
+
editor.setText("");
|
|
1788
|
+
const name = trimmed === "/revoke-skill" ? "" : trimmed.slice("/revoke-skill ".length).trim();
|
|
1789
|
+
if (!name) {
|
|
1790
|
+
insertBeforeEditor(new Markdown(`${brand.dim("usage: /revoke-skill <name>")}`, 1, 0, markdownTheme));
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
try {
|
|
1794
|
+
const res = (await client.request("exec-grant-skill", {
|
|
1795
|
+
...withBinding(),
|
|
1796
|
+
skillName: name,
|
|
1797
|
+
revoke: true,
|
|
1798
|
+
}));
|
|
1799
|
+
if (!res?.found) {
|
|
1800
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`No skill named "${name}" is visible to this agent.`)}`, 0, 0));
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim(`Revoked ${res.removed ?? 0} approval(s) from skill "${res.skill ?? name}".`)}`, 0, 0));
|
|
1804
|
+
}
|
|
1805
|
+
catch (err) {
|
|
1806
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1807
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`revoke-skill failed: ${msg}`)}`, 0, 0));
|
|
1808
|
+
}
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
// /model <id> — switch by id (the gateway resolves provider via its registry)
|
|
1812
|
+
if (trimmed === "/model" || trimmed.startsWith("/model ")) {
|
|
1813
|
+
editor.setText("");
|
|
1814
|
+
let models;
|
|
1815
|
+
try {
|
|
1816
|
+
models = await client.request("list-models");
|
|
1817
|
+
}
|
|
1818
|
+
catch (err) {
|
|
1819
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
const arg = trimmed === "/model" ? "" : trimmed.slice("/model ".length).trim();
|
|
1823
|
+
if (!arg) {
|
|
1824
|
+
const list = models
|
|
1825
|
+
.map((m) => ` ${brand.dim(m.provider)} ${brand.white(m.id)}`)
|
|
1826
|
+
.join("\n");
|
|
1827
|
+
insertBeforeEditor(new Markdown(`${brand.dim("configured models on the gateway:")}\n${list}\n\n${brand.dim("usage: /model <id>")}`, 1, 0, markdownTheme));
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
// Prefer current provider on tie.
|
|
1831
|
+
const currentProvider = lastSnapshot?.provider;
|
|
1832
|
+
const matches = models.filter((m) => m.id === arg);
|
|
1833
|
+
const target = matches.find((m) => m.provider === currentProvider) ?? matches[0];
|
|
1834
|
+
if (!target) {
|
|
1835
|
+
insertBeforeEditor(new Text(` ${brand.error(`✗ no model with id "${arg}" on the gateway.`)}`, 0, 0));
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
try {
|
|
1839
|
+
await client.request("set-model", withBinding({ provider: target.provider, modelId: target.id }));
|
|
1840
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("switched to")} ${brand.white(`${target.provider} · ${target.id}`)}`, 0, 0));
|
|
1841
|
+
}
|
|
1842
|
+
catch (err) {
|
|
1843
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1844
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
|
|
1845
|
+
}
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
// /switch <id> — Carrow cross-model handoff (vs /model = next turn): aborts an
|
|
1849
|
+
// in-flight gateway turn, swaps the model, and REPLAYS your last message on the
|
|
1850
|
+
// new one so the conversation continues across models. Idle ⇒ just sets the model.
|
|
1851
|
+
if (trimmed === "/switch" || trimmed.startsWith("/switch ")) {
|
|
1852
|
+
editor.setText("");
|
|
1853
|
+
const arg = trimmed === "/switch" ? "" : trimmed.slice("/switch ".length).trim();
|
|
1854
|
+
if (!arg) {
|
|
1855
|
+
insertBeforeEditor(new Markdown(`${brand.dim("usage: /switch <id> — Carrow mid-turn handoff (vs /model = next turn)")}`, 1, 0, markdownTheme));
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1858
|
+
let switchModels;
|
|
1859
|
+
try {
|
|
1860
|
+
switchModels = await client.request("list-models");
|
|
1861
|
+
}
|
|
1862
|
+
catch (err) {
|
|
1863
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
const switchMatches = switchModels.filter((m) => m.id === arg);
|
|
1867
|
+
const switchTarget = switchMatches.find((m) => m.provider === lastSnapshot?.provider) ?? switchMatches[0];
|
|
1868
|
+
if (!switchTarget) {
|
|
1869
|
+
insertBeforeEditor(new Text(` ${brand.error(`✗ no model with id "${arg}" on the gateway.`)}`, 0, 0));
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
try {
|
|
1873
|
+
await client.request("switch-model-mid-turn", withBinding({ provider: switchTarget.provider, modelId: switchTarget.id, replayMessage: lastUserPrompt }));
|
|
1874
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("Carrow handoff →")} ${brand.white(`${switchTarget.provider} · ${switchTarget.id}`)}`, 0, 0));
|
|
1875
|
+
}
|
|
1876
|
+
catch (err) {
|
|
1877
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
|
|
1878
|
+
}
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
// /thinking [level]
|
|
1882
|
+
if (trimmed === "/thinking" || trimmed.startsWith("/thinking ")) {
|
|
1883
|
+
editor.setText("");
|
|
1884
|
+
const arg = trimmed === "/thinking" ? "" : trimmed.slice("/thinking ".length).trim().toLowerCase();
|
|
1885
|
+
if (!arg) {
|
|
1886
|
+
const cur = lastSnapshot?.thinkingLevel ?? "?";
|
|
1887
|
+
const avail = lastSnapshot?.availableThinkingLevels ?? [];
|
|
1888
|
+
insertBeforeEditor(new Text(` ${brand.dim("thinking is")} ${brand.amber(cur)} ${brand.dim("· available:")} ${brand.dim(avail.join(" "))}`, 0, 0));
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
try {
|
|
1892
|
+
await client.request("set-thinking", withBinding({ level: arg }));
|
|
1893
|
+
insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("thinking set to")} ${brand.amber(arg)}`, 0, 0));
|
|
1894
|
+
}
|
|
1895
|
+
catch (err) {
|
|
1896
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1897
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
|
|
1898
|
+
}
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
// Default — send as a prompt. Override timeout to 0 (disabled): the
|
|
1902
|
+
// SERVER bounds turn duration via the 6-layer wrapper chain (heartbeat,
|
|
1903
|
+
// stream-timeout, length-continuation). A client-side 60s cap would
|
|
1904
|
+
// reject WHILE the server keeps processing, producing silent state
|
|
1905
|
+
// desync — next user message would interleave with the in-flight reply.
|
|
1906
|
+
insertBeforeEditor(new Markdown(`${brand.user("you")} ${trimmed}`, 1, 0, markdownTheme));
|
|
1907
|
+
editor.setText("");
|
|
1908
|
+
try {
|
|
1909
|
+
// Carry the connection's bound agentId when set so the gateway
|
|
1910
|
+
// routes this turn to that agent's session lane + runtime entry.
|
|
1911
|
+
// Legacy single-agent gateways receive the same boot agent the
|
|
1912
|
+
// snapshot reported, so behaviour is unchanged.
|
|
1913
|
+
lastUserPrompt = trimmed; // remember it as the replay message for a later `/switch` (Carrow) handoff
|
|
1914
|
+
await client.request("prompt", withBinding({ text: trimmed }), { timeoutMs: 0 });
|
|
1915
|
+
}
|
|
1916
|
+
catch (err) {
|
|
1917
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1918
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
tui.requestRender();
|
|
1922
|
+
return {
|
|
1923
|
+
abort: () => {
|
|
1924
|
+
if (!isAgentRunning)
|
|
1925
|
+
return false;
|
|
1926
|
+
void client.request("abort", withBinding()).catch(() => { });
|
|
1927
|
+
isAgentRunning = false;
|
|
1928
|
+
agentStartedAt = null;
|
|
1929
|
+
editor.disableSubmit = false;
|
|
1930
|
+
if (activeLoader) {
|
|
1931
|
+
removeChild(activeLoader);
|
|
1932
|
+
activeLoader = null;
|
|
1933
|
+
}
|
|
1934
|
+
// Hygiene on abort: clear any in-flight tool indicators (they'll
|
|
1935
|
+
// never get a tool_execution_end now) and drop the assistant-
|
|
1936
|
+
// block pointer so the NEXT turn opens a fresh block instead of
|
|
1937
|
+
// appending to the aborted one's stale Markdown component.
|
|
1938
|
+
for (const indicator of pendingTools.values()) {
|
|
1939
|
+
removeChild(indicator);
|
|
1940
|
+
}
|
|
1941
|
+
pendingTools.clear();
|
|
1942
|
+
activeAssistants.clear();
|
|
1943
|
+
insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.dim("aborted")}`, 0, 0));
|
|
1944
|
+
updateHeader();
|
|
1945
|
+
return true;
|
|
1946
|
+
},
|
|
1947
|
+
close: async () => {
|
|
1948
|
+
client.close();
|
|
1949
|
+
},
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
//# sourceMappingURL=connect.js.map
|