@aexol/spectral 0.8.2 → 0.8.6
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/CHANGELOG.md +82 -55
- package/README.md +80 -82
- package/dist/agent/agents.d.ts +37 -0
- package/dist/agent/agents.d.ts.map +1 -0
- package/dist/agent/index.d.ts +29 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +11 -11
- package/dist/cli.d.ts +17 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/commands/bind.d.ts +12 -0
- package/dist/commands/bind.d.ts.map +1 -0
- package/dist/commands/login-oauth.d.ts +15 -0
- package/dist/commands/login-oauth.d.ts.map +1 -0
- package/dist/commands/login.d.ts +37 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/logout.d.ts +8 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/serve.d.ts +112 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +5 -2
- package/dist/commands/unbind.d.ts +8 -0
- package/dist/commands/unbind.d.ts.map +1 -0
- package/dist/config.d.ts +49 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -1
- package/dist/designer/guidelines.d.ts +23 -0
- package/dist/designer/guidelines.d.ts.map +1 -0
- package/dist/designer/index.d.ts +26 -0
- package/dist/designer/index.d.ts.map +1 -0
- package/dist/designer/index.js +9 -9
- package/dist/designer/philosophies.d.ts +33 -0
- package/dist/designer/philosophies.d.ts.map +1 -0
- package/dist/designer/skills.d.ts +27 -0
- package/dist/designer/skills.d.ts.map +1 -0
- package/dist/designer/systems.d.ts +36 -0
- package/dist/designer/systems.d.ts.map +1 -0
- package/dist/extensions/aexol-mcp.d.ts +25 -0
- package/dist/extensions/aexol-mcp.d.ts.map +1 -0
- package/dist/extensions/aexol-mcp.js +12 -12
- package/dist/extensions/kanban-bridge.d.ts +24 -0
- package/dist/extensions/kanban-bridge.d.ts.map +1 -0
- package/dist/extensions/kanban-bridge.js +3 -3
- package/dist/extensions/openrouter-attribution.d.ts +12 -0
- package/dist/extensions/openrouter-attribution.d.ts.map +1 -0
- package/dist/extensions/openrouter-attribution.js +2 -2
- package/dist/extensions/spectral-vision-fallback.d.ts +23 -0
- package/dist/extensions/spectral-vision-fallback.d.ts.map +1 -0
- package/dist/extensions/spectral-vision-fallback.js +32 -23
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/mcp/agent-dir.d.ts +3 -0
- package/dist/mcp/agent-dir.d.ts.map +1 -0
- package/dist/mcp/commands.d.ts +9 -0
- package/dist/mcp/commands.d.ts.map +1 -0
- package/dist/mcp/commands.js +1 -1
- package/dist/mcp/config.d.ts +78 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +15 -15
- package/dist/mcp/consent-manager.d.ts +14 -0
- package/dist/mcp/consent-manager.d.ts.map +1 -0
- package/dist/mcp/direct-tools.d.ts +11 -0
- package/dist/mcp/direct-tools.d.ts.map +1 -0
- package/dist/mcp/errors.d.ts +100 -0
- package/dist/mcp/errors.d.ts.map +1 -0
- package/dist/mcp/glimpse-ui.d.ts +10 -0
- package/dist/mcp/glimpse-ui.d.ts.map +1 -0
- package/dist/mcp/host-html-template.d.ts +17 -0
- package/dist/mcp/host-html-template.d.ts.map +1 -0
- package/dist/mcp/host-html-template.js +3 -3
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +15 -13
- package/dist/mcp/init.d.ts +10 -0
- package/dist/mcp/init.d.ts.map +1 -0
- package/dist/mcp/init.js +4 -4
- package/dist/mcp/lifecycle.d.ts +30 -0
- package/dist/mcp/lifecycle.d.ts.map +1 -0
- package/dist/mcp/logger.d.ts +52 -0
- package/dist/mcp/logger.d.ts.map +1 -0
- package/dist/mcp/mcp-auth-flow.d.ts +69 -0
- package/dist/mcp/mcp-auth-flow.d.ts.map +1 -0
- package/dist/mcp/mcp-auth.d.ts +100 -0
- package/dist/mcp/mcp-auth.d.ts.map +1 -0
- package/dist/mcp/mcp-callback-server.d.ts +40 -0
- package/dist/mcp/mcp-callback-server.d.ts.map +1 -0
- package/dist/mcp/mcp-oauth-provider.d.ts +101 -0
- package/dist/mcp/mcp-oauth-provider.d.ts.map +1 -0
- package/dist/mcp/mcp-oauth-provider.js +1 -1
- package/dist/mcp/metadata-cache.d.ts +32 -0
- package/dist/mcp/metadata-cache.d.ts.map +1 -0
- package/dist/mcp/npx-resolver.d.ts +7 -0
- package/dist/mcp/npx-resolver.d.ts.map +1 -0
- package/dist/mcp/oauth-handler.d.ts +19 -0
- package/dist/mcp/oauth-handler.d.ts.map +1 -0
- package/dist/mcp/onboarding-state.d.ts +13 -0
- package/dist/mcp/onboarding-state.d.ts.map +1 -0
- package/dist/mcp/proxy-modes.d.ts +12 -0
- package/dist/mcp/proxy-modes.d.ts.map +1 -0
- package/dist/mcp/proxy-modes.js +2 -2
- package/dist/mcp/resource-tools.d.ts +2 -0
- package/dist/mcp/resource-tools.d.ts.map +1 -0
- package/dist/mcp/sampling-handler.d.ts +16 -0
- package/dist/mcp/sampling-handler.d.ts.map +1 -0
- package/dist/mcp/server-manager.d.ts +42 -0
- package/dist/mcp/server-manager.d.ts.map +1 -0
- package/dist/mcp/server-manager.js +2 -2
- package/dist/mcp/state-getter.d.ts +14 -0
- package/dist/mcp/state-getter.d.ts.map +1 -0
- package/dist/mcp/state-getter.js +21 -0
- package/dist/mcp/state.d.ts +41 -0
- package/dist/mcp/state.d.ts.map +1 -0
- package/dist/mcp/tool-metadata.d.ts +11 -0
- package/dist/mcp/tool-metadata.d.ts.map +1 -0
- package/dist/mcp/tool-registrar.d.ts +9 -0
- package/dist/mcp/tool-registrar.d.ts.map +1 -0
- package/dist/mcp/tool-registrar.js +1 -1
- package/dist/mcp/types.d.ts +263 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/ui-resource-handler.d.ts +10 -0
- package/dist/mcp/ui-resource-handler.d.ts.map +1 -0
- package/dist/mcp/ui-server.d.ts +37 -0
- package/dist/mcp/ui-server.d.ts.map +1 -0
- package/dist/mcp/ui-server.js +1 -1
- package/dist/mcp/ui-session.d.ts +27 -0
- package/dist/mcp/ui-session.d.ts.map +1 -0
- package/dist/mcp/ui-stream-types.d.ts +197 -0
- package/dist/mcp/ui-stream-types.d.ts.map +1 -0
- package/dist/mcp/ui-stream-types.js +5 -5
- package/dist/mcp/utils.d.ts +17 -0
- package/dist/mcp/utils.d.ts.map +1 -0
- package/dist/mcp/utils.js +10 -10
- package/dist/mcp/vitest.config.d.ts +3 -0
- package/dist/mcp/vitest.config.d.ts.map +1 -0
- package/dist/mcp-client.d.ts +58 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +3 -2
- package/dist/memory/branch.d.ts +124 -0
- package/dist/memory/branch.d.ts.map +1 -0
- package/dist/memory/commands/status.d.ts +4 -0
- package/dist/memory/commands/status.d.ts.map +1 -0
- package/dist/memory/commands/status.js +2 -2
- package/dist/memory/commands/view.d.ts +4 -0
- package/dist/memory/commands/view.d.ts.map +1 -0
- package/dist/memory/commands/view.js +2 -2
- package/dist/memory/compaction.d.ts +113 -0
- package/dist/memory/compaction.d.ts.map +1 -0
- package/dist/memory/config.d.ts +27 -0
- package/dist/memory/config.d.ts.map +1 -0
- package/dist/memory/debug-log.d.ts +12 -0
- package/dist/memory/debug-log.d.ts.map +1 -0
- package/dist/memory/hooks/compaction-hook.d.ts +4 -0
- package/dist/memory/hooks/compaction-hook.d.ts.map +1 -0
- package/dist/memory/hooks/compaction-hook.js +5 -5
- package/dist/memory/hooks/compaction-trigger.d.ts +4 -0
- package/dist/memory/hooks/compaction-trigger.d.ts.map +1 -0
- package/dist/memory/hooks/compaction-trigger.js +3 -3
- package/dist/memory/hooks/observer-trigger.d.ts +4 -0
- package/dist/memory/hooks/observer-trigger.d.ts.map +1 -0
- package/dist/memory/hooks/observer-trigger.js +4 -4
- package/dist/memory/ids.d.ts +2 -0
- package/dist/memory/ids.d.ts.map +1 -0
- package/dist/memory/index.d.ts +3 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +9 -9
- package/dist/memory/model-budget.d.ts +4 -0
- package/dist/memory/model-budget.d.ts.map +1 -0
- package/dist/memory/observer.d.ts +21 -0
- package/dist/memory/observer.d.ts.map +1 -0
- package/dist/memory/project-observations-store.d.ts +24 -0
- package/dist/memory/project-observations-store.d.ts.map +1 -0
- package/dist/memory/prompts.d.ts +11 -0
- package/dist/memory/prompts.d.ts.map +1 -0
- package/dist/memory/relevance.d.ts +4 -0
- package/dist/memory/relevance.d.ts.map +1 -0
- package/dist/memory/runtime.d.ts +40 -0
- package/dist/memory/runtime.d.ts.map +1 -0
- package/dist/memory/serialize.d.ts +26 -0
- package/dist/memory/serialize.d.ts.map +1 -0
- package/dist/memory/tokens.d.ts +8 -0
- package/dist/memory/tokens.d.ts.map +1 -0
- package/dist/memory/tools/read-project-observations.d.ts +8 -0
- package/dist/memory/tools/read-project-observations.d.ts.map +1 -0
- package/dist/memory/tools/read-project-observations.js +2 -2
- package/dist/memory/tools/recall-observation.d.ts +63 -0
- package/dist/memory/tools/recall-observation.d.ts.map +1 -0
- package/dist/memory/tools/recall-observation.js +2 -2
- package/dist/memory/tools/write-project-observation.d.ts +9 -0
- package/dist/memory/tools/write-project-observation.d.ts.map +1 -0
- package/dist/memory/tools/write-project-observation.js +2 -2
- package/dist/memory/types.d.ts +65 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/preflight.d.ts +27 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +4 -2
- package/dist/relay/auto-research.d.ts +64 -0
- package/dist/relay/auto-research.d.ts.map +1 -0
- package/dist/relay/auto-research.js +184 -79
- package/dist/relay/client.d.ts +126 -0
- package/dist/relay/client.d.ts.map +1 -0
- package/dist/relay/dispatcher.d.ts +216 -0
- package/dist/relay/dispatcher.d.ts.map +1 -0
- package/dist/relay/dispatcher.js +33 -6
- package/dist/relay/machine-store.d.ts +68 -0
- package/dist/relay/machine-store.d.ts.map +1 -0
- package/dist/relay/models-fetch.d.ts +75 -0
- package/dist/relay/models-fetch.d.ts.map +1 -0
- package/dist/relay/registration.d.ts +81 -0
- package/dist/relay/registration.d.ts.map +1 -0
- package/dist/sdk/agent-core/agent-loop.d.ts +24 -0
- package/dist/sdk/agent-core/agent-loop.d.ts.map +1 -0
- package/dist/sdk/agent-core/agent.d.ts +125 -0
- package/dist/sdk/agent-core/agent.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/agent-harness.d.ts +92 -0
- package/dist/sdk/agent-core/harness/agent-harness.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/compaction/branch-summarization.d.ts +53 -0
- package/dist/sdk/agent-core/harness/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/compaction/compaction.d.ts +95 -0
- package/dist/sdk/agent-core/harness/compaction/compaction.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/compaction/utils.d.ts +25 -0
- package/dist/sdk/agent-core/harness/compaction/utils.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/env/nodejs.d.ts +51 -0
- package/dist/sdk/agent-core/harness/env/nodejs.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/messages.d.ts +51 -0
- package/dist/sdk/agent-core/harness/messages.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/prompt-templates.d.ts +48 -0
- package/dist/sdk/agent-core/harness/prompt-templates.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/session/jsonl-repo.d.ts +26 -0
- package/dist/sdk/agent-core/harness/session/jsonl-repo.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/session/jsonl-storage.d.ts +33 -0
- package/dist/sdk/agent-core/harness/session/jsonl-storage.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/session/memory-repo.d.ts +18 -0
- package/dist/sdk/agent-core/harness/session/memory-repo.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/session/memory-storage.d.ts +25 -0
- package/dist/sdk/agent-core/harness/session/memory-storage.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/session/repo-utils.d.ts +11 -0
- package/dist/sdk/agent-core/harness/session/repo-utils.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/session/session.d.ts +32 -0
- package/dist/sdk/agent-core/harness/session/session.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/session/uuid.d.ts +2 -0
- package/dist/sdk/agent-core/harness/session/uuid.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/skills.d.ts +44 -0
- package/dist/sdk/agent-core/harness/skills.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/system-prompt.d.ts +3 -0
- package/dist/sdk/agent-core/harness/system-prompt.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/types.d.ts +601 -0
- package/dist/sdk/agent-core/harness/types.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/utils/shell-output.d.ts +14 -0
- package/dist/sdk/agent-core/harness/utils/shell-output.d.ts.map +1 -0
- package/dist/sdk/agent-core/harness/utils/truncate.d.ts +70 -0
- package/dist/sdk/agent-core/harness/utils/truncate.d.ts.map +1 -0
- package/dist/sdk/agent-core/index.d.ts +20 -0
- package/dist/sdk/agent-core/index.d.ts.map +1 -0
- package/dist/sdk/agent-core/node.d.ts +3 -0
- package/dist/sdk/agent-core/node.d.ts.map +1 -0
- package/dist/sdk/agent-core/proxy.d.ts +69 -0
- package/dist/sdk/agent-core/proxy.d.ts.map +1 -0
- package/dist/sdk/agent-core/types.d.ts +393 -0
- package/dist/sdk/agent-core/types.d.ts.map +1 -0
- package/dist/sdk/ai/api-registry.d.ts +20 -0
- package/dist/sdk/ai/api-registry.d.ts.map +1 -0
- package/dist/sdk/ai/cli.d.ts +3 -0
- package/dist/sdk/ai/cli.d.ts.map +1 -0
- package/dist/sdk/ai/env-api-keys.d.ts +18 -0
- package/dist/sdk/ai/env-api-keys.d.ts.map +1 -0
- package/dist/sdk/ai/image-models.d.ts +10 -0
- package/dist/sdk/ai/image-models.d.ts.map +1 -0
- package/dist/sdk/ai/image-models.generated.d.ts +440 -0
- package/dist/sdk/ai/image-models.generated.d.ts.map +1 -0
- package/dist/sdk/ai/images-api-registry.d.ts +14 -0
- package/dist/sdk/ai/images-api-registry.d.ts.map +1 -0
- package/dist/sdk/ai/images.d.ts +4 -0
- package/dist/sdk/ai/images.d.ts.map +1 -0
- package/dist/sdk/ai/index.d.ts +21 -0
- package/dist/sdk/ai/index.d.ts.map +1 -0
- package/dist/sdk/ai/models.d.ts +18 -0
- package/dist/sdk/ai/models.d.ts.map +1 -0
- package/dist/sdk/ai/models.generated.d.ts +17349 -0
- package/dist/sdk/ai/models.generated.d.ts.map +1 -0
- package/dist/sdk/ai/oauth.d.ts +2 -0
- package/dist/sdk/ai/oauth.d.ts.map +1 -0
- package/dist/sdk/ai/providers/anthropic.d.ts +54 -0
- package/dist/sdk/ai/providers/anthropic.d.ts.map +1 -0
- package/dist/sdk/ai/providers/faux.d.ts +56 -0
- package/dist/sdk/ai/providers/faux.d.ts.map +1 -0
- package/dist/sdk/ai/providers/github-copilot-headers.d.ts +8 -0
- package/dist/sdk/ai/providers/github-copilot-headers.d.ts.map +1 -0
- package/dist/sdk/ai/providers/openai-completions.d.ts +19 -0
- package/dist/sdk/ai/providers/openai-completions.d.ts.map +1 -0
- package/dist/sdk/ai/providers/openai-prompt-cache.d.ts +3 -0
- package/dist/sdk/ai/providers/openai-prompt-cache.d.ts.map +1 -0
- package/dist/sdk/ai/providers/register-builtins.d.ts +15 -0
- package/dist/sdk/ai/providers/register-builtins.d.ts.map +1 -0
- package/dist/sdk/ai/providers/simple-options.d.ts +8 -0
- package/dist/sdk/ai/providers/simple-options.d.ts.map +1 -0
- package/dist/sdk/ai/providers/transform-messages.d.ts +8 -0
- package/dist/sdk/ai/providers/transform-messages.d.ts.map +1 -0
- package/dist/sdk/ai/session-resources.d.ts +4 -0
- package/dist/sdk/ai/session-resources.d.ts.map +1 -0
- package/dist/sdk/ai/stream.d.ts +8 -0
- package/dist/sdk/ai/stream.d.ts.map +1 -0
- package/dist/sdk/ai/types.d.ts +488 -0
- package/dist/sdk/ai/types.d.ts.map +1 -0
- package/dist/sdk/ai/utils/diagnostics.d.ts +19 -0
- package/dist/sdk/ai/utils/diagnostics.d.ts.map +1 -0
- package/dist/sdk/ai/utils/event-stream.d.ts +21 -0
- package/dist/sdk/ai/utils/event-stream.d.ts.map +1 -0
- package/dist/sdk/ai/utils/hash.d.ts +3 -0
- package/dist/sdk/ai/utils/hash.d.ts.map +1 -0
- package/dist/sdk/ai/utils/headers.d.ts +2 -0
- package/dist/sdk/ai/utils/headers.d.ts.map +1 -0
- package/dist/sdk/ai/utils/json-parse.d.ts +16 -0
- package/dist/sdk/ai/utils/json-parse.d.ts.map +1 -0
- package/dist/sdk/ai/utils/node-http-proxy.d.ts +10 -0
- package/dist/sdk/ai/utils/node-http-proxy.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/anthropic.d.ts +25 -0
- package/dist/sdk/ai/utils/oauth/anthropic.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/device-code.d.ts +19 -0
- package/dist/sdk/ai/utils/oauth/device-code.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/github-copilot.d.ts +30 -0
- package/dist/sdk/ai/utils/oauth/github-copilot.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/index.d.ts +58 -0
- package/dist/sdk/ai/utils/oauth/index.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/oauth-page.d.ts +3 -0
- package/dist/sdk/ai/utils/oauth/oauth-page.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/openai-codex.d.ts +34 -0
- package/dist/sdk/ai/utils/oauth/openai-codex.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/openai-codex.js +2 -2
- package/dist/sdk/ai/utils/oauth/pkce.d.ts +13 -0
- package/dist/sdk/ai/utils/oauth/pkce.d.ts.map +1 -0
- package/dist/sdk/ai/utils/oauth/types.d.ts +64 -0
- package/dist/sdk/ai/utils/oauth/types.d.ts.map +1 -0
- package/dist/sdk/ai/utils/overflow.d.ts +56 -0
- package/dist/sdk/ai/utils/overflow.d.ts.map +1 -0
- package/dist/sdk/ai/utils/sanitize-unicode.d.ts +22 -0
- package/dist/sdk/ai/utils/sanitize-unicode.d.ts.map +1 -0
- package/dist/sdk/ai/utils/typebox-helpers.d.ts +17 -0
- package/dist/sdk/ai/utils/typebox-helpers.d.ts.map +1 -0
- package/dist/sdk/ai/utils/validation.d.ts +18 -0
- package/dist/sdk/ai/utils/validation.d.ts.map +1 -0
- package/dist/sdk/coding-agent/cli.d.ts +3 -0
- package/dist/sdk/coding-agent/cli.d.ts.map +1 -0
- package/dist/sdk/coding-agent/config.d.ts +71 -0
- package/dist/sdk/coding-agent/config.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/agent-session-runtime.d.ts +117 -0
- package/dist/sdk/coding-agent/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/agent-session-services.d.ts +86 -0
- package/dist/sdk/coding-agent/core/agent-session-services.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/agent-session.d.ts +626 -0
- package/dist/sdk/coding-agent/core/agent-session.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/agent-session.js +3 -3
- package/dist/sdk/coding-agent/core/auth-guidance.d.ts +5 -0
- package/dist/sdk/coding-agent/core/auth-guidance.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/auth-storage.d.ts +145 -0
- package/dist/sdk/coding-agent/core/auth-storage.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/auth-storage.js +2 -2
- package/dist/sdk/coding-agent/core/bash-executor.d.ts +32 -0
- package/dist/sdk/coding-agent/core/bash-executor.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/bash-executor.js +1 -1
- package/dist/sdk/coding-agent/core/compaction/branch-summarization.d.ts +88 -0
- package/dist/sdk/coding-agent/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/compaction/branch-summarization.js +1 -1
- package/dist/sdk/coding-agent/core/compaction/compaction.d.ts +142 -0
- package/dist/sdk/coding-agent/core/compaction/compaction.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/compaction/compaction.js +1 -1
- package/dist/sdk/coding-agent/core/compaction/index.d.ts +7 -0
- package/dist/sdk/coding-agent/core/compaction/index.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/compaction/utils.d.ts +38 -0
- package/dist/sdk/coding-agent/core/compaction/utils.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/defaults.d.ts +3 -0
- package/dist/sdk/coding-agent/core/defaults.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/diagnostics.d.ts +15 -0
- package/dist/sdk/coding-agent/core/diagnostics.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/event-bus.d.ts +9 -0
- package/dist/sdk/coding-agent/core/event-bus.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/exec.d.ts +29 -0
- package/dist/sdk/coding-agent/core/exec.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/extensions/index.d.ts +12 -0
- package/dist/sdk/coding-agent/core/extensions/index.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/extensions/loader.d.ts +24 -0
- package/dist/sdk/coding-agent/core/extensions/loader.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/extensions/loader.js +18 -21
- package/dist/sdk/coding-agent/core/extensions/runner.d.ts +161 -0
- package/dist/sdk/coding-agent/core/extensions/runner.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/extensions/runner.js +1 -1
- package/dist/sdk/coding-agent/core/extensions/types.d.ts +1181 -0
- package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/extensions/wrapper.d.ts +20 -0
- package/dist/sdk/coding-agent/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/http-dispatcher.d.ts +21 -0
- package/dist/sdk/coding-agent/core/http-dispatcher.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/index.d.ts +12 -0
- package/dist/sdk/coding-agent/core/index.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/keybindings.d.ts +371 -0
- package/dist/sdk/coding-agent/core/keybindings.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/messages.d.ts +77 -0
- package/dist/sdk/coding-agent/core/messages.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/model-registry.d.ts +150 -0
- package/dist/sdk/coding-agent/core/model-registry.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/model-resolver-utils.d.ts +7 -0
- package/dist/sdk/coding-agent/core/model-resolver-utils.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/model-resolver.d.ts +110 -0
- package/dist/sdk/coding-agent/core/model-resolver.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/output-guard.d.ts +6 -0
- package/dist/sdk/coding-agent/core/output-guard.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/package-manager.d.ts +204 -0
- package/dist/sdk/coding-agent/core/package-manager.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/package-manager.js +14 -14
- package/dist/sdk/coding-agent/core/prompt-templates.d.ts +52 -0
- package/dist/sdk/coding-agent/core/prompt-templates.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/provider-display-names.d.ts +2 -0
- package/dist/sdk/coding-agent/core/provider-display-names.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/resolve-config-value.d.ts +23 -0
- package/dist/sdk/coding-agent/core/resolve-config-value.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/resource-loader.d.ts +194 -0
- package/dist/sdk/coding-agent/core/resource-loader.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/sdk.d.ts +107 -0
- package/dist/sdk/coding-agent/core/sdk.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/sdk.js +2 -2
- package/dist/sdk/coding-agent/core/session-cwd.d.ts +19 -0
- package/dist/sdk/coding-agent/core/session-cwd.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/session-manager.d.ts +333 -0
- package/dist/sdk/coding-agent/core/session-manager.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/settings-manager.d.ts +209 -0
- package/dist/sdk/coding-agent/core/settings-manager.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/skills.d.ts +60 -0
- package/dist/sdk/coding-agent/core/skills.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/slash-commands.d.ts +14 -0
- package/dist/sdk/coding-agent/core/slash-commands.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/source-info.d.ts +18 -0
- package/dist/sdk/coding-agent/core/source-info.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/system-prompt.d.ts +28 -0
- package/dist/sdk/coding-agent/core/system-prompt.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/system-prompt.js +7 -7
- package/dist/sdk/coding-agent/core/telemetry.d.ts +3 -0
- package/dist/sdk/coding-agent/core/telemetry.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/theme.d.ts +28 -0
- package/dist/sdk/coding-agent/core/theme.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/timings.d.ts +8 -0
- package/dist/sdk/coding-agent/core/timings.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/bash.d.ts +63 -0
- package/dist/sdk/coding-agent/core/tools/bash.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/bash.js +3 -3
- package/dist/sdk/coding-agent/core/tools/edit-diff.d.ts +87 -0
- package/dist/sdk/coding-agent/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/edit.d.ts +39 -0
- package/dist/sdk/coding-agent/core/tools/edit.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/sdk/coding-agent/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/find.d.ts +35 -0
- package/dist/sdk/coding-agent/core/tools/find.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/grep.d.ts +37 -0
- package/dist/sdk/coding-agent/core/tools/grep.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/index.d.ts +40 -0
- package/dist/sdk/coding-agent/core/tools/index.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/ls.d.ts +37 -0
- package/dist/sdk/coding-agent/core/tools/ls.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/output-accumulator.d.ts +52 -0
- package/dist/sdk/coding-agent/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/output-accumulator.js +1 -1
- package/dist/sdk/coding-agent/core/tools/path-utils.d.ts +8 -0
- package/dist/sdk/coding-agent/core/tools/path-utils.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/read.d.ts +35 -0
- package/dist/sdk/coding-agent/core/tools/read.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/read.js +18 -10
- package/dist/sdk/coding-agent/core/tools/render-diff.d.ts +17 -0
- package/dist/sdk/coding-agent/core/tools/render-diff.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/render-utils.d.ts +21 -0
- package/dist/sdk/coding-agent/core/tools/render-utils.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/truncate.d.ts +70 -0
- package/dist/sdk/coding-agent/core/tools/truncate.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/tools/write.d.ts +26 -0
- package/dist/sdk/coding-agent/core/tools/write.d.ts.map +1 -0
- package/dist/sdk/coding-agent/index.d.ts +29 -0
- package/dist/sdk/coding-agent/index.d.ts.map +1 -0
- package/dist/sdk/coding-agent/main.d.ts +2 -0
- package/dist/sdk/coding-agent/main.d.ts.map +1 -0
- package/dist/sdk/coding-agent/migrations.d.ts +33 -0
- package/dist/sdk/coding-agent/migrations.d.ts.map +1 -0
- package/dist/sdk/coding-agent/migrations.js +4 -4
- package/dist/sdk/coding-agent/modes/index.d.ts +8 -0
- package/dist/sdk/coding-agent/modes/index.d.ts.map +1 -0
- package/dist/sdk/coding-agent/modes/print-mode.d.ts +28 -0
- package/dist/sdk/coding-agent/modes/print-mode.d.ts.map +1 -0
- package/dist/sdk/coding-agent/modes/print-mode.js +2 -2
- package/dist/sdk/coding-agent/modes/rpc/jsonl.d.ts +17 -0
- package/dist/sdk/coding-agent/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/sdk/coding-agent/modes/rpc/rpc-client.d.ts +224 -0
- package/dist/sdk/coding-agent/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/sdk/coding-agent/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/sdk/coding-agent/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/sdk/coding-agent/modes/rpc/rpc-types.d.ts +419 -0
- package/dist/sdk/coding-agent/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/ansi.d.ts +2 -0
- package/dist/sdk/coding-agent/utils/ansi.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/changelog.d.ts +21 -0
- package/dist/sdk/coding-agent/utils/changelog.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/child-process.d.ts +15 -0
- package/dist/sdk/coding-agent/utils/child-process.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/clipboard-image.d.ts +11 -0
- package/dist/sdk/coding-agent/utils/clipboard-image.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/clipboard-image.js +1 -1
- package/dist/sdk/coding-agent/utils/clipboard-native.d.ts +8 -0
- package/dist/sdk/coding-agent/utils/clipboard-native.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/clipboard.d.ts +2 -0
- package/dist/sdk/coding-agent/utils/clipboard.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/exif-orientation.d.ts +5 -0
- package/dist/sdk/coding-agent/utils/exif-orientation.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/frontmatter.d.ts +8 -0
- package/dist/sdk/coding-agent/utils/frontmatter.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/fs-watch.d.ts +5 -0
- package/dist/sdk/coding-agent/utils/fs-watch.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/git.d.ts +26 -0
- package/dist/sdk/coding-agent/utils/git.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/html.d.ts +7 -0
- package/dist/sdk/coding-agent/utils/html.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/image-convert.d.ts +9 -0
- package/dist/sdk/coding-agent/utils/image-convert.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/image-resize.d.ts +36 -0
- package/dist/sdk/coding-agent/utils/image-resize.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/mime.d.ts +3 -0
- package/dist/sdk/coding-agent/utils/mime.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/paths.d.ts +31 -0
- package/dist/sdk/coding-agent/utils/paths.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/photon.d.ts +13 -0
- package/dist/sdk/coding-agent/utils/photon.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/shell.d.ts +30 -0
- package/dist/sdk/coding-agent/utils/shell.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/sleep.d.ts +5 -0
- package/dist/sdk/coding-agent/utils/sleep.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/spectral-user-agent.d.ts +2 -0
- package/dist/sdk/coding-agent/utils/spectral-user-agent.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/spectral-user-agent.js +3 -0
- package/dist/sdk/coding-agent/utils/syntax-highlight.d.ts +12 -0
- package/dist/sdk/coding-agent/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/tools-manager.d.ts +3 -0
- package/dist/sdk/coding-agent/utils/tools-manager.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/version-check.d.ts +15 -0
- package/dist/sdk/coding-agent/utils/version-check.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/version-check.js +7 -7
- package/dist/sdk/coding-agent/utils/windows-self-update.d.ts +3 -0
- package/dist/sdk/coding-agent/utils/windows-self-update.d.ts.map +1 -0
- package/dist/sdk/coding-agent/utils/windows-self-update.js +1 -1
- package/dist/server/agent-bridge.d.ts +308 -0
- package/dist/server/agent-bridge.d.ts.map +1 -0
- package/dist/server/agent-bridge.js +58 -58
- package/dist/server/handlers/errors.d.ts +26 -0
- package/dist/server/handlers/errors.d.ts.map +1 -0
- package/dist/server/handlers/mcp-status.d.ts +21 -0
- package/dist/server/handlers/mcp-status.d.ts.map +1 -0
- package/dist/server/handlers/mcp-status.js +52 -0
- package/dist/server/handlers/paths-autocomplete.d.ts +45 -0
- package/dist/server/handlers/paths-autocomplete.d.ts.map +1 -0
- package/dist/server/handlers/projects.d.ts +58 -0
- package/dist/server/handlers/projects.d.ts.map +1 -0
- package/dist/server/handlers/queue.d.ts +27 -0
- package/dist/server/handlers/queue.d.ts.map +1 -0
- package/dist/server/handlers/sessions.d.ts +50 -0
- package/dist/server/handlers/sessions.d.ts.map +1 -0
- package/dist/server/handlers/sessions.js +1 -1
- package/dist/server/handlers/settings.d.ts +30 -0
- package/dist/server/handlers/settings.d.ts.map +1 -0
- package/dist/server/handlers/settings.js +123 -0
- package/dist/server/paths.d.ts +51 -0
- package/dist/server/paths.d.ts.map +1 -0
- package/dist/server/paths.js +2 -2
- package/dist/server/session-stream.d.ts +379 -0
- package/dist/server/session-stream.d.ts.map +1 -0
- package/dist/server/session-stream.js +43 -34
- package/dist/server/shutdown.d.ts +102 -0
- package/dist/server/shutdown.d.ts.map +1 -0
- package/dist/server/shutdown.js +3 -3
- package/dist/server/storage.d.ts +287 -0
- package/dist/server/storage.d.ts.map +1 -0
- package/dist/server/storage.js +6 -6
- package/dist/server/title-generator.d.ts +25 -0
- package/dist/server/title-generator.d.ts.map +1 -0
- package/dist/server/wire.d.ts +448 -0
- package/dist/server/wire.d.ts.map +1 -0
- package/dist/server/wire.js +1 -1
- package/dist/studio-binding.d.ts +44 -0
- package/dist/studio-binding.d.ts.map +1 -0
- package/dist/studio-binding.js +1 -1
- package/package.json +11 -1
- package/dist/sdk/coding-agent/utils/pi-user-agent.js +0 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure REST handlers for `/api/sessions/*`.
|
|
3
|
+
*
|
|
4
|
+
* Same shape as projects handlers — see that file's header for the contract.
|
|
5
|
+
*
|
|
6
|
+
* Note: session deletion does not tear down the in-flight spectral stream itself.
|
|
7
|
+
* The Batch 3 dispatcher must call `manager.disposeSessionStream(id)` BEFORE
|
|
8
|
+
* invoking `handleDeleteSession` so the FK cascade doesn't leave a zombie
|
|
9
|
+
* bridge driving events at a row that no longer exists. This matches the
|
|
10
|
+
* ordering the old Hono route used.
|
|
11
|
+
*/
|
|
12
|
+
import type { SessionStreamManager } from "../session-stream.js";
|
|
13
|
+
import type { SessionStore } from "../storage.js";
|
|
14
|
+
import type { WireSessionDetail, WireSessionMemoryDetails, WireSessionMemoryStatus, WireSessionSummary } from "../wire.js";
|
|
15
|
+
export interface CreateSessionInputRaw {
|
|
16
|
+
projectId?: unknown;
|
|
17
|
+
title?: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface UpdateSessionInputRaw {
|
|
20
|
+
title?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export declare function handleCreateSession(store: SessionStore, body: CreateSessionInputRaw): WireSessionSummary;
|
|
23
|
+
export declare function handleGetSessionDetail(store: SessionStore, id: string): WireSessionDetail;
|
|
24
|
+
export declare function handleUpdateSession(store: SessionStore, id: string, body: UpdateSessionInputRaw): WireSessionSummary;
|
|
25
|
+
export declare function handleDeleteSession(store: SessionStore, id: string): void;
|
|
26
|
+
export declare function handleGetSessionMemoryStatus(store: SessionStore, manager: SessionStreamManager, id: string): WireSessionMemoryStatus;
|
|
27
|
+
export declare function handleGetSessionMemoryDetails(store: SessionStore, manager: SessionStreamManager, id: string): WireSessionMemoryDetails;
|
|
28
|
+
export declare function handleCompactSession(store: SessionStore, manager: SessionStreamManager, id: string): Promise<{
|
|
29
|
+
ok: true;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Remember & delete: compact the session (which persists observations as
|
|
33
|
+
* project memory via the compaction hook), then delete the session.
|
|
34
|
+
*
|
|
35
|
+
* This gives the user a way to keep a session's reflections as durable
|
|
36
|
+
* cross-session memory even for short sessions that never hit the compaction
|
|
37
|
+
* threshold naturally.
|
|
38
|
+
*/
|
|
39
|
+
export declare function handleRememberAndDeleteSession(store: SessionStore, manager: SessionStreamManager, id: string): Promise<{
|
|
40
|
+
ok: true;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Fork a session: create a new session copying all messages from the
|
|
44
|
+
* source, with the `fork_compact_source_id` flag set so the
|
|
45
|
+
* SessionStreamManager compacts after the first assistant turn.
|
|
46
|
+
*/
|
|
47
|
+
export declare function handleForkSession(store: SessionStore, id: string, body: {
|
|
48
|
+
title?: unknown;
|
|
49
|
+
}): WireSessionSummary;
|
|
50
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAG3H,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,qBAAqB,GAC1B,kBAAkB,CAQpB;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,YAAY,EACnB,EAAE,EAAE,MAAM,GACT,iBAAiB,CAInB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,qBAAqB,GAC1B,kBAAkB,CAOpB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAGzE;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,oBAAoB,EAC7B,EAAE,EAAE,MAAM,GACT,uBAAuB,CAIzB;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,oBAAoB,EAC7B,EAAE,EAAE,MAAM,GACT,wBAAwB,CAI1B;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,oBAAoB,EAC7B,EAAE,EAAE,MAAM,GACT,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,CAUvB;AAED;;;;;;;GAOG;AACH,wBAAsB,8BAA8B,CAClD,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,oBAAoB,EAC7B,EAAE,EAAE,MAAM,GACT,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,CAUvB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,YAAY,EACnB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxB,kBAAkB,CAKpB"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Same shape as projects handlers — see that file's header for the contract.
|
|
5
5
|
*
|
|
6
|
-
* Note: session deletion does not tear down the in-flight
|
|
6
|
+
* Note: session deletion does not tear down the in-flight spectral stream itself.
|
|
7
7
|
* The Batch 3 dispatcher must call `manager.disposeSessionStream(id)` BEFORE
|
|
8
8
|
* invoking `handleDeleteSession` so the FK cascade doesn't leave a zombie
|
|
9
9
|
* bridge driving events at a row that no longer exists. This matches the
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure REST handler for `GET /api/settings` and `PUT /api/settings`.
|
|
3
|
+
*
|
|
4
|
+
* Settings are stored in the machine's global `settings.json` under the
|
|
5
|
+
* `"observational-memory"` namespace (see `src/memory/config.ts`).
|
|
6
|
+
*
|
|
7
|
+
* GET /api/settings → returns full observational-memory config
|
|
8
|
+
* PUT /api/settings → updates a single key via `{ key, value }` body
|
|
9
|
+
*
|
|
10
|
+
* All paths are machine-level — no session context needed.
|
|
11
|
+
*/
|
|
12
|
+
export interface PutSettingsInput {
|
|
13
|
+
key?: unknown;
|
|
14
|
+
value?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface PutSettingsOutput {
|
|
17
|
+
ok: true;
|
|
18
|
+
key: string;
|
|
19
|
+
value: number;
|
|
20
|
+
}
|
|
21
|
+
export interface GetSettingsOutput {
|
|
22
|
+
observationThresholdTokens: number;
|
|
23
|
+
compactionThresholdTokens: number;
|
|
24
|
+
reflectionThresholdTokens: number;
|
|
25
|
+
passive: boolean;
|
|
26
|
+
debugLog: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function handleGetSettings(cwd: string): GetSettingsOutput;
|
|
29
|
+
export declare function handlePutSettings(cwd: string, body: PutSettingsInput): PutSettingsOutput;
|
|
30
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAaH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,IAAI,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,0BAA0B,EAAE,MAAM,CAAC;IACnC,yBAAyB,EAAE,MAAM,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAsFD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAShE;AAMD,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,gBAAgB,GACrB,iBAAiB,CA0BnB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure REST handler for `GET /api/settings` and `PUT /api/settings`.
|
|
3
|
+
*
|
|
4
|
+
* Settings are stored in the machine's global `settings.json` under the
|
|
5
|
+
* `"observational-memory"` namespace (see `src/memory/config.ts`).
|
|
6
|
+
*
|
|
7
|
+
* GET /api/settings → returns full observational-memory config
|
|
8
|
+
* PUT /api/settings → updates a single key via `{ key, value }` body
|
|
9
|
+
*
|
|
10
|
+
* All paths are machine-level — no session context needed.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import lockfile from "proper-lockfile";
|
|
15
|
+
import { getAgentDir } from "../../sdk/coding-agent/index.js";
|
|
16
|
+
import { loadConfig } from "../../memory/config.js";
|
|
17
|
+
import { BadRequestError } from "./errors.js";
|
|
18
|
+
/** Recognised setting keys (dot-separated path within the config object). */
|
|
19
|
+
const ALLOWED_KEYS = new Set([
|
|
20
|
+
"observationThresholdTokens",
|
|
21
|
+
"compactionThresholdTokens",
|
|
22
|
+
"reflectionThresholdTokens",
|
|
23
|
+
]);
|
|
24
|
+
/** Sane bounds for token thresholds. */
|
|
25
|
+
const MIN_TOKENS = 1_000;
|
|
26
|
+
const MAX_TOKENS = 1_000_000;
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// File helpers (inlined to avoid pulling in the full SettingsManager)
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
function acquireLockSyncWithRetry(path) {
|
|
31
|
+
const maxAttempts = 10;
|
|
32
|
+
const delayMs = 20;
|
|
33
|
+
let lastError;
|
|
34
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
35
|
+
try {
|
|
36
|
+
return lockfile.lockSync(path, { realpath: false });
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const code = typeof error === "object" && error !== null && "code" in error
|
|
40
|
+
? String(error.code)
|
|
41
|
+
: undefined;
|
|
42
|
+
if (code !== "ELOCKED" || attempt === maxAttempts) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
lastError = error;
|
|
46
|
+
const start = Date.now();
|
|
47
|
+
while (Date.now() - start < delayMs) {
|
|
48
|
+
// busy-wait; synchronous by design
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
throw lastError ?? new Error("Failed to acquire settings lock");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Atomically read-modify-write the global `settings.json` under the
|
|
56
|
+
* `"observational-memory"` namespace.
|
|
57
|
+
*/
|
|
58
|
+
function withObservationalMemoryLock(fn) {
|
|
59
|
+
const path = join(getAgentDir(), "settings.json");
|
|
60
|
+
const dir = dirname(path);
|
|
61
|
+
let release;
|
|
62
|
+
try {
|
|
63
|
+
const fileExists = existsSync(path);
|
|
64
|
+
if (fileExists) {
|
|
65
|
+
release = acquireLockSyncWithRetry(path);
|
|
66
|
+
}
|
|
67
|
+
const raw = fileExists ? readFileSync(path, "utf-8") : "{}";
|
|
68
|
+
const parsed = JSON.parse(raw);
|
|
69
|
+
const ns = (parsed["observational-memory"] ?? {});
|
|
70
|
+
const next = fn(ns);
|
|
71
|
+
if (next !== undefined) {
|
|
72
|
+
parsed["observational-memory"] = { ...ns, ...next };
|
|
73
|
+
if (!existsSync(dir)) {
|
|
74
|
+
mkdirSync(dir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
if (!release) {
|
|
77
|
+
release = acquireLockSyncWithRetry(path);
|
|
78
|
+
}
|
|
79
|
+
writeFileSync(path, JSON.stringify(parsed, null, 2), "utf-8");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
if (release) {
|
|
84
|
+
release();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// GET handler
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
export function handleGetSettings(cwd) {
|
|
92
|
+
const config = loadConfig(cwd);
|
|
93
|
+
return {
|
|
94
|
+
observationThresholdTokens: config.observationThresholdTokens,
|
|
95
|
+
compactionThresholdTokens: config.compactionThresholdTokens,
|
|
96
|
+
reflectionThresholdTokens: config.reflectionThresholdTokens,
|
|
97
|
+
passive: config.passive,
|
|
98
|
+
debugLog: config.debugLog,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// PUT handler
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
export function handlePutSettings(cwd, body) {
|
|
105
|
+
// Validate key
|
|
106
|
+
if (typeof body.key !== "string" || !ALLOWED_KEYS.has(body.key)) {
|
|
107
|
+
throw new BadRequestError(`settings key must be one of: ${[...ALLOWED_KEYS].join(", ")}`);
|
|
108
|
+
}
|
|
109
|
+
const key = body.key;
|
|
110
|
+
// Validate value
|
|
111
|
+
if (typeof body.value !== "number" || !Number.isInteger(body.value)) {
|
|
112
|
+
throw new BadRequestError("settings value must be an integer");
|
|
113
|
+
}
|
|
114
|
+
if (body.value < MIN_TOKENS || body.value > MAX_TOKENS) {
|
|
115
|
+
throw new BadRequestError(`token threshold must be between ${MIN_TOKENS.toLocaleString()} and ${MAX_TOKENS.toLocaleString()}`);
|
|
116
|
+
}
|
|
117
|
+
const value = body.value;
|
|
118
|
+
// Persist
|
|
119
|
+
withObservationalMemoryLock((current) => {
|
|
120
|
+
return { ...current, [key]: value };
|
|
121
|
+
});
|
|
122
|
+
return { ok: true, key, value };
|
|
123
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem path helpers for project management.
|
|
3
|
+
*
|
|
4
|
+
* Projects in `spectral serve` are user-owned directories on disk. We accept
|
|
5
|
+
* paths typed by the user from the browser, so two small concerns:
|
|
6
|
+
*
|
|
7
|
+
* - Tilde expansion: `~/foo/bar` is the natural way to refer to a path
|
|
8
|
+
* inside `$HOME`. Node's `path` module does not expand tildes; we do it
|
|
9
|
+
* ourselves with a leading-segment check (NOT a global string replace —
|
|
10
|
+
* `~user/...` and embedded `~` are intentionally left alone).
|
|
11
|
+
* - Validation: the path must exist, must be a directory, and must be
|
|
12
|
+
* readable. We do NOT attempt to verify writability — spectral may want to
|
|
13
|
+
* create files inside it, but failure modes there surface naturally
|
|
14
|
+
* through spectral's tools, and a write probe here would create stray files.
|
|
15
|
+
*
|
|
16
|
+
* Both helpers are synchronous because they're called on hot HTTP paths
|
|
17
|
+
* (POST /api/projects) where blocking is acceptable: the operation is rare
|
|
18
|
+
* and the user is waiting on the response anyway. `node:fs` sync calls in
|
|
19
|
+
* this regime are simpler than juggling promises through validation.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Expand a leading `~` or `~/` to the user's home directory and return an
|
|
23
|
+
* absolute, normalized path.
|
|
24
|
+
*
|
|
25
|
+
* Behavior:
|
|
26
|
+
* - `~` → `$HOME`
|
|
27
|
+
* - `~/foo` → `$HOME/foo`
|
|
28
|
+
* - `/abs/path` → `/abs/path` (unchanged, normalized)
|
|
29
|
+
* - `relative` → resolved against `$HOME` (NOT process.cwd, since the
|
|
30
|
+
* server runs from `$HOME` and "relative to home" matches the user's
|
|
31
|
+
* mental model when typing into a form)
|
|
32
|
+
* - `~user/...` → returned as-is and resolved against `$HOME`. We do NOT
|
|
33
|
+
* attempt to look up other users' home directories — out of scope.
|
|
34
|
+
*/
|
|
35
|
+
export declare function expandPath(input: string): string;
|
|
36
|
+
export interface ProjectPathValidation {
|
|
37
|
+
ok: boolean;
|
|
38
|
+
/** Absolute, normalized path (set when ok=true and also for some errors). */
|
|
39
|
+
path: string;
|
|
40
|
+
/** Human-friendly error message (set when ok=false). */
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Validate a user-supplied project path.
|
|
45
|
+
*
|
|
46
|
+
* Returns `{ok:true, path}` for a real, accessible directory. On failure,
|
|
47
|
+
* `error` carries a message suitable for surfacing to the user. The expanded
|
|
48
|
+
* path is included in both cases so callers can echo it back in errors.
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateProjectPath(input: string): ProjectPathValidation;
|
|
51
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/server/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAehD;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,OAAO,CAAC;IACZ,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAmBxE"}
|
package/dist/server/paths.js
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* ourselves with a leading-segment check (NOT a global string replace —
|
|
10
10
|
* `~user/...` and embedded `~` are intentionally left alone).
|
|
11
11
|
* - Validation: the path must exist, must be a directory, and must be
|
|
12
|
-
* readable. We do NOT attempt to verify writability —
|
|
12
|
+
* readable. We do NOT attempt to verify writability — spectral may want to
|
|
13
13
|
* create files inside it, but failure modes there surface naturally
|
|
14
|
-
* through
|
|
14
|
+
* through spectral's tools, and a write probe here would create stray files.
|
|
15
15
|
*
|
|
16
16
|
* Both helpers are synchronous because they're called on hot HTTP paths
|
|
17
17
|
* (POST /api/projects) where blocking is acceptable: the operation is rare
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-scoped streaming layer for `spectral serve`.
|
|
3
|
+
*
|
|
4
|
+
* Background: prior to this module each WebSocket owned its own `AgentBridge`
|
|
5
|
+
* instance and the routes layer enforced single-writer-wins (4001 eviction)
|
|
6
|
+
* to keep that bridge unique per session. That model lost data on browser
|
|
7
|
+
* refresh — the WS close torn down the spectral process mid-stream, and a re-open
|
|
8
|
+
* couldn't recover what hadn't yet hit `agent_end` (and thus SQLite).
|
|
9
|
+
*
|
|
10
|
+
* New model:
|
|
11
|
+
* - Pi lifecycle is per **Spectral session**, not per WS.
|
|
12
|
+
* - 0..N WebSockets may attach to the same session simultaneously. Each
|
|
13
|
+
* gets the same broadcast stream of events.
|
|
14
|
+
* - When a WS detaches (close, error, refresh), the spectral process keeps
|
|
15
|
+
* running. Closing every tab does NOT cancel the in-flight turn —
|
|
16
|
+
* it runs to completion and persists on `agent_end` as before.
|
|
17
|
+
* - On `attach`, the manager hands back a replay payload: full DB history
|
|
18
|
+
* plus a snapshot of the currently in-flight turn (if any). The client
|
|
19
|
+
* replays the snapshot through the same reducer it uses for live events
|
|
20
|
+
* and continues streaming naturally.
|
|
21
|
+
* - Persistence shape is unchanged: only the final assistant message is
|
|
22
|
+
* written to SQLite on `agent_end`. In-flight events live in memory only.
|
|
23
|
+
* A server crash mid-turn discards the in-flight state — acceptable
|
|
24
|
+
* for MVP.
|
|
25
|
+
*
|
|
26
|
+
* Failure modes:
|
|
27
|
+
* - spectral throws synchronously in `prompt()` → bridge surfaces as `error`
|
|
28
|
+
* event; manager broadcasts and clears `currentTurn`.
|
|
29
|
+
* - One subscriber's `ws.send` throws → caught, logged, removed from the
|
|
30
|
+
* subscriber set; broadcast continues to the rest.
|
|
31
|
+
* - `agent_end` arrives without a current turn (defensive) → broadcast
|
|
32
|
+
* anyway so any late attachers don't get stuck.
|
|
33
|
+
*
|
|
34
|
+
* TODO (future): idle GC. A `SessionStream` with `subscribers.size === 0`
|
|
35
|
+
* and no current turn could be disposed after some grace window (e.g. 5
|
|
36
|
+
* minutes) to release spectral resources for chronically-idle sessions. Skipped
|
|
37
|
+
* for now — streams accumulate for the lifetime of the server process.
|
|
38
|
+
*/
|
|
39
|
+
import { type AgentBridgeOptions } from "./agent-bridge.js";
|
|
40
|
+
import type { SessionStore } from "./storage.js";
|
|
41
|
+
import type { ImageAttachment, InProgressTurnSnapshot, ServerEvent, WireMessage, WireSessionMemoryDetails } from "./wire.js";
|
|
42
|
+
/**
|
|
43
|
+
* Anything we can `send` and `close` on. The `ws` library's WebSocket fits;
|
|
44
|
+
* tests can pass a stub. Kept minimal so we don't drag the `ws` types in.
|
|
45
|
+
*/
|
|
46
|
+
export interface Subscriber {
|
|
47
|
+
/** Send a JSON-serialized event. Implementations should be best-effort. */
|
|
48
|
+
send(event: ServerEvent): void;
|
|
49
|
+
/** True when the subscriber is no longer reachable (closed/closing). */
|
|
50
|
+
isOpen(): boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Bridge-shaped object — `AgentBridge` is the only real impl; tests duck-type
|
|
54
|
+
* via this interface. Identical contract to `BridgeLike` in `routes.ts` but
|
|
55
|
+
* defined here too so `session-stream.ts` doesn't depend on `routes.ts`.
|
|
56
|
+
*/
|
|
57
|
+
export interface BridgeLike {
|
|
58
|
+
start(): Promise<void>;
|
|
59
|
+
prompt(text: string, images?: ImageAttachment[]): Promise<void>;
|
|
60
|
+
dispose(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Manually compact the session context via spectral's built-in compaction.
|
|
63
|
+
* Fires compaction_start / compaction_end events through the bridge's
|
|
64
|
+
* emit callback. Used by the Fork & Compact flow after the first
|
|
65
|
+
* assistant turn of a forked session completes.
|
|
66
|
+
*/
|
|
67
|
+
compact?(customInstructions?: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Optional sticky reasoning effort. Maps frontend effort strings
|
|
70
|
+
* (xhigh|high|medium|low|minimal|none) to spectral ThinkingLevel.
|
|
71
|
+
*/
|
|
72
|
+
setReasoningEffort?(effort: string | undefined): void;
|
|
73
|
+
/**
|
|
74
|
+
* Optional sticky model selection. Phase 3 (Available Models whitelist).
|
|
75
|
+
* Real AgentBridge implements this; test stubs may omit it (the manager
|
|
76
|
+
* skips the call when undefined, which is exactly what tests want).
|
|
77
|
+
* Returns true when the model is in effect; false when the bridge
|
|
78
|
+
* surfaced an error (the manager will then drop the prompt).
|
|
79
|
+
*/
|
|
80
|
+
setModel?(modelId: string | null | undefined): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Return the modelId of the first available model from the backend
|
|
83
|
+
* whitelist (preserving backend sortOrder). Used as defense-in-depth
|
|
84
|
+
* default when neither the envelope nor SQLite supply a modelId.
|
|
85
|
+
* Returns `undefined` when no models are available.
|
|
86
|
+
*/
|
|
87
|
+
getFirstAvailableModelId?(): string | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Return current session context usage from spectral's built-in estimator.
|
|
90
|
+
* Returns `undefined` when the bridge hasn't started yet or the model
|
|
91
|
+
* has no context window configured.
|
|
92
|
+
*/
|
|
93
|
+
getContextUsage?(): {
|
|
94
|
+
tokens: number | null;
|
|
95
|
+
contextWindow: number;
|
|
96
|
+
percent: number | null;
|
|
97
|
+
} | undefined;
|
|
98
|
+
getSessionBranch?(): Array<{
|
|
99
|
+
type: string;
|
|
100
|
+
id: string;
|
|
101
|
+
timestamp?: string;
|
|
102
|
+
message?: unknown;
|
|
103
|
+
content?: unknown;
|
|
104
|
+
customType?: string;
|
|
105
|
+
summary?: unknown;
|
|
106
|
+
fromId?: string;
|
|
107
|
+
data?: unknown;
|
|
108
|
+
details?: unknown;
|
|
109
|
+
firstKeptEntryId?: string;
|
|
110
|
+
}>;
|
|
111
|
+
getMemoryActivity?(): {
|
|
112
|
+
phase: "idle" | "observing" | "compacting" | "reflecting" | "pruning";
|
|
113
|
+
inFlight: {
|
|
114
|
+
observer: boolean;
|
|
115
|
+
compaction: boolean;
|
|
116
|
+
reflection: boolean;
|
|
117
|
+
pruner: boolean;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Factory signature shared with `routes.ts`. */
|
|
122
|
+
export type BridgeFactory = (args: AgentBridgeOptions) => BridgeLike;
|
|
123
|
+
export interface SessionMemoryStatus {
|
|
124
|
+
mode: "active" | "passive";
|
|
125
|
+
phase: "idle" | "observing" | "compacting" | "reflecting" | "pruning";
|
|
126
|
+
inFlight: {
|
|
127
|
+
observer: boolean;
|
|
128
|
+
compaction: boolean;
|
|
129
|
+
reflection: boolean;
|
|
130
|
+
pruner: boolean;
|
|
131
|
+
};
|
|
132
|
+
reflections: {
|
|
133
|
+
count: number;
|
|
134
|
+
tokens: number;
|
|
135
|
+
};
|
|
136
|
+
observations: {
|
|
137
|
+
committedCount: number;
|
|
138
|
+
committedTokens: number;
|
|
139
|
+
pendingCount: number;
|
|
140
|
+
pendingTokens: number;
|
|
141
|
+
};
|
|
142
|
+
thresholds: {
|
|
143
|
+
observation: number;
|
|
144
|
+
compaction: number;
|
|
145
|
+
reflection: number;
|
|
146
|
+
};
|
|
147
|
+
progress: {
|
|
148
|
+
sinceObservationBoundTokens: number;
|
|
149
|
+
sinceLastCompactionTokens: number;
|
|
150
|
+
observationPoolTokens: number;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export interface AttachResult {
|
|
154
|
+
history: WireMessage[];
|
|
155
|
+
currentTurn: InProgressTurnSnapshot | null;
|
|
156
|
+
/** Resolves when the underlying spectral session is ready (or rejects on start failure). */
|
|
157
|
+
ready: Promise<void>;
|
|
158
|
+
/** True when this session was created via "Fork & Compact" and has not yet
|
|
159
|
+
* triggered its first compaction. The dispatcher includes this in
|
|
160
|
+
* `session_ready` so the frontend can adapt the send button. */
|
|
161
|
+
forkCompactPending: boolean;
|
|
162
|
+
/** Cumulative context tokens used across the session (null initially, updated on first token_usage). */
|
|
163
|
+
contextWindowUsed: number | null;
|
|
164
|
+
/** Model's total context window in tokens (null if model metadata not yet available). */
|
|
165
|
+
contextWindowMax: number | null;
|
|
166
|
+
}
|
|
167
|
+
export interface SessionStreamManagerOptions {
|
|
168
|
+
store: SessionStore;
|
|
169
|
+
/**
|
|
170
|
+
* Fallback cwd used ONLY when a session has no resolvable project (which
|
|
171
|
+
* shouldn't happen in normal operation since FK enforces it). Sessions
|
|
172
|
+
* with a valid project always run spectral against `project.path`.
|
|
173
|
+
*/
|
|
174
|
+
cwd: string;
|
|
175
|
+
/**
|
|
176
|
+
* Backend base URL — threaded into every AgentBridge so spectral proxies all
|
|
177
|
+
* inference through `${backendUrl}/v1` instead of reading
|
|
178
|
+
* `~/.spectral/agent/auth.json`. Required in production; tests that supply a
|
|
179
|
+
* `bridgeFactory` may pass any non-empty placeholder.
|
|
180
|
+
*/
|
|
181
|
+
backendUrl: string;
|
|
182
|
+
/**
|
|
183
|
+
* Machine JWT — used as the Bearer credential spectral sends to the backend
|
|
184
|
+
* proxy on every inference call. See `backendUrl` for context.
|
|
185
|
+
*/
|
|
186
|
+
machineJwt: string;
|
|
187
|
+
bridgeFactory?: BridgeFactory;
|
|
188
|
+
agentDir?: string;
|
|
189
|
+
}
|
|
190
|
+
export declare class SessionStreamManager {
|
|
191
|
+
private readonly store;
|
|
192
|
+
private readonly cwd;
|
|
193
|
+
private readonly backendUrl;
|
|
194
|
+
private readonly machineJwt;
|
|
195
|
+
private readonly bridgeFactory;
|
|
196
|
+
private readonly agentDir;
|
|
197
|
+
private readonly streams;
|
|
198
|
+
private disposed;
|
|
199
|
+
constructor(opts: SessionStreamManagerOptions);
|
|
200
|
+
/**
|
|
201
|
+
* Attach a subscriber to a session. Lazily creates the underlying spectral
|
|
202
|
+
* session on first attach. The caller is responsible for sending the
|
|
203
|
+
* initial `session_ready` frame using the returned replay payload (this
|
|
204
|
+
* keeps wire-protocol concerns in the routes layer).
|
|
205
|
+
*
|
|
206
|
+
* Throws if the session id is unknown in SQLite (caller should turn this
|
|
207
|
+
* into a wire-level error frame + close).
|
|
208
|
+
*/
|
|
209
|
+
attach(sessionId: string, subscriber: Subscriber): AttachResult;
|
|
210
|
+
/**
|
|
211
|
+
* Detach a subscriber. Idempotent. Does NOT dispose the underlying spectral
|
|
212
|
+
* session — even when subscribers reach zero, the in-flight turn must
|
|
213
|
+
* complete and persist.
|
|
214
|
+
*/
|
|
215
|
+
detach(sessionId: string, subscriber: Subscriber): void;
|
|
216
|
+
/** True if the session has an in-flight turn (manager-side; not WS-side). */
|
|
217
|
+
hasActiveTurn(sessionId: string): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Return the set of session IDs that currently have an in-flight turn.
|
|
220
|
+
* Cheap O(streams) scan used by the list-project / list-sessions endpoints
|
|
221
|
+
* to enrich responses with `hasActiveTurn` markers so the frontend can
|
|
222
|
+
* render a yellow pulsating dot next to active sessions/projects.
|
|
223
|
+
*/
|
|
224
|
+
getActiveTurnSessionIds(): Set<string>;
|
|
225
|
+
getSessionMemoryStatus(sessionId: string): SessionMemoryStatus;
|
|
226
|
+
getSessionMemoryDetails(sessionId: string): WireSessionMemoryDetails;
|
|
227
|
+
compactSession(sessionId: string): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* Persist a user message and forward it to spectral. Resolves after the user
|
|
230
|
+
* message is persisted + spectral is invoked (NOT after the turn completes —
|
|
231
|
+
* the turn lifetime is observed via the broadcast stream).
|
|
232
|
+
*
|
|
233
|
+
* Broadcast ordering:
|
|
234
|
+
* 1. user message persisted to SQLite
|
|
235
|
+
* 2. `user_message_appended` broadcast to all subscribers (including
|
|
236
|
+
* the originating tab)
|
|
237
|
+
* 3. new `currentTurn` opened
|
|
238
|
+
* 4. `bridge.prompt()` invoked (events arrive asynchronously and are
|
|
239
|
+
* buffered + broadcast as they come)
|
|
240
|
+
*
|
|
241
|
+
* Sticky model selection (Phase 3 — Available Models whitelist):
|
|
242
|
+
* - When `modelId` is provided, we apply it via `bridge.setModel()` and
|
|
243
|
+
* persist to SQLite for cross-restart recovery, BEFORE invoking
|
|
244
|
+
* `bridge.prompt()`. If `setModel` fails (unknown model, registry
|
|
245
|
+
* unavailable, agent-side error) the bridge has already emitted an
|
|
246
|
+
* `error` wire event and we drop the prompt to avoid running it
|
|
247
|
+
* against the wrong model.
|
|
248
|
+
* - When `modelId` is omitted, we look up SQLite. If a previous turn
|
|
249
|
+
* persisted a value, we reapply it on this turn (this is the
|
|
250
|
+
* cross-restart recovery path: a fresh server process has lost spectral's
|
|
251
|
+
* in-memory model state, so we re-pin from durable storage).
|
|
252
|
+
* - When neither envelope nor SQLite have a value, we leave model
|
|
253
|
+
* selection to spectral's own settings file (pre-Phase-3 behaviour).
|
|
254
|
+
*/
|
|
255
|
+
prompt(sessionId: string, content: string, modelId?: string, images?: ImageAttachment[], reasoningEffort?: string): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Tear down everything. Best-effort: disposes every bridge, drops all
|
|
258
|
+
* subscribers. After this the manager is unusable.
|
|
259
|
+
*/
|
|
260
|
+
dispose(): void;
|
|
261
|
+
/** Test/inspection helper: how many streams are currently tracked. */
|
|
262
|
+
streamCount(): number;
|
|
263
|
+
/**
|
|
264
|
+
* Count of sessions with an in-flight turn (i.e. a `currentTurn` set).
|
|
265
|
+
* Used by `gracefulShutdown` to decide whether to keep waiting before
|
|
266
|
+
* tearing down — a non-zero count means at least one assistant response
|
|
267
|
+
* is mid-stream and we'd rather let it finish (within the grace window)
|
|
268
|
+
* than orphan a half-streamed message in the UI.
|
|
269
|
+
*
|
|
270
|
+
* Cheap O(streams) scan; we only call it ~50× during a 5 s graceful
|
|
271
|
+
* shutdown so the linear walk is fine.
|
|
272
|
+
*/
|
|
273
|
+
activeTurnCount(): number;
|
|
274
|
+
/**
|
|
275
|
+
* Cancel the in-flight turn for a session (user pressed Stop in the UI).
|
|
276
|
+
* Disposes the agent bridge and broadcasts `agent_end` so all subscribers
|
|
277
|
+
* see the turn close. The stream itself is kept alive — the next user
|
|
278
|
+
* message (via `prompt()`) will lazily create a fresh bridge.
|
|
279
|
+
*
|
|
280
|
+
* Idempotent: if no stream exists for the session, or no turn is in
|
|
281
|
+
* flight, this is a no-op.
|
|
282
|
+
*/
|
|
283
|
+
cancelTurn(sessionId: string): void;
|
|
284
|
+
/**
|
|
285
|
+
* Tear down a single session's stream — disposes the agent bridge and clears
|
|
286
|
+
* subscribers. Idempotent. Called by the routes layer right before
|
|
287
|
+
* `DELETE /api/sessions/:id` so the SQL cascade doesn't leave a zombie
|
|
288
|
+
* spectral process driving events at a session that no longer exists.
|
|
289
|
+
*
|
|
290
|
+
* Does NOT remove the session from the store — that's the caller's job.
|
|
291
|
+
*/
|
|
292
|
+
disposeSessionStream(sessionId: string): void;
|
|
293
|
+
/**
|
|
294
|
+
* Tear down every stream whose session belongs to the given list of ids.
|
|
295
|
+
* Used by the project-delete path: the route layer reads the project's
|
|
296
|
+
* session ids from `deleteProject()` and passes them here BEFORE the SQL
|
|
297
|
+
* cascade fires, so no spectral process ever observes the FK cascade.
|
|
298
|
+
*/
|
|
299
|
+
disposeProjectStreams(sessionIds: readonly string[]): void;
|
|
300
|
+
/**
|
|
301
|
+
* Set the autonomous iterative loop state for a session.
|
|
302
|
+
*
|
|
303
|
+
* When `active` is true, the manager replays `originalPrompt` after each
|
|
304
|
+
* `agent_end` event — the agent sees its own file changes from prior
|
|
305
|
+
* iterations and iteratively improves its solution (Ralph Wiggum pattern).
|
|
306
|
+
* The loop stops when the agent emits `<LOOP_DONE>` in its response or the
|
|
307
|
+
* safety iteration limit is reached.
|
|
308
|
+
*/
|
|
309
|
+
setLoopActive(sessionId: string, active: boolean, originalPrompt?: string, maxIterations?: number, goal?: string): void;
|
|
310
|
+
/**
|
|
311
|
+
* Fork & Compact: trigger compaction after the first assistant turn of a
|
|
312
|
+
* forked session. Uses spectral's built-in `compact()` which generates a summary
|
|
313
|
+
* of older context, retaining the most recent ~20K tokens (including the
|
|
314
|
+
* user's new message + the assistant's response).
|
|
315
|
+
*
|
|
316
|
+
* Custom instructions reference the most recent user message so the LLM
|
|
317
|
+
* summary prioritizes information relevant to the current task.
|
|
318
|
+
*/
|
|
319
|
+
private triggerForkCompact;
|
|
320
|
+
/**
|
|
321
|
+
* Send the next prompt for an autonomous loop iteration, waiting for any
|
|
322
|
+
* in-flight observational-memory compaction to finish first so the LLM
|
|
323
|
+
* sees the compacted context.
|
|
324
|
+
*
|
|
325
|
+
* The compaction-trigger extension fires on agent_end (via setTimeout),
|
|
326
|
+
* so we poll stream.compacting briefly. If compaction hasn't started after
|
|
327
|
+
* a short grace period, we check whether the context window exceeds the
|
|
328
|
+
* threshold and proactively trigger compaction via the bridge (which
|
|
329
|
+
* invokes spectral's full pipeline, including the session_before_compact hook
|
|
330
|
+
* where the observational memory extension provides its summary).
|
|
331
|
+
*
|
|
332
|
+
* A duplicate call from the extension's delayed compaction trigger is
|
|
333
|
+
* harmless — spectral throws "Already compacted" which the extension catches.
|
|
334
|
+
*/
|
|
335
|
+
/**
|
|
336
|
+
* Send the next prompt for an autonomous loop iteration, compacting first
|
|
337
|
+
* if the context window exceeds the threshold.
|
|
338
|
+
*
|
|
339
|
+
* Instead of polling for the extension's delayed compaction-trigger (which
|
|
340
|
+
* fires via setTimeout), we proactively call bridge.compact() directly.
|
|
341
|
+
* bridge.compact() → session.compact() → fires session_before_compact
|
|
342
|
+
* (where the extension's compaction-hook provides the observational-memory
|
|
343
|
+
* summary), then appends the compaction entry, reloads the compacted
|
|
344
|
+
* context into agent.state.messages, and emits compaction_start/end.
|
|
345
|
+
*
|
|
346
|
+
* The extension's trigger still fires (via setTimeout), but by the time
|
|
347
|
+
* its callback runs, bridge.compact() has already appended the compaction
|
|
348
|
+
* entry → prepareCompaction() returns undefined → "Already compacted"
|
|
349
|
+
* → the trigger's onError handler catches it harmlessly.
|
|
350
|
+
*/
|
|
351
|
+
private buildLoopPrompt;
|
|
352
|
+
private sendNextLoopIteration;
|
|
353
|
+
private createStream;
|
|
354
|
+
private handleBridgeEvent;
|
|
355
|
+
/**
|
|
356
|
+
* Flush the current in-flight turn's events to SQLite for crash recovery.
|
|
357
|
+
* Only the events accumulated since the last flush are written — we append
|
|
358
|
+
* them to the already-stored JSONL via INSERT OR REPLACE. Called every
|
|
359
|
+
* `BATCH_FLUSH_INTERVAL` events from `handleBridgeEvent`.
|
|
360
|
+
*
|
|
361
|
+
* Errors are caught, logged, and swallowed: batch persistence is a
|
|
362
|
+
* best-effort hardening, never a failure path that should block the stream.
|
|
363
|
+
*/
|
|
364
|
+
private flushInFlightTurn;
|
|
365
|
+
private broadcast;
|
|
366
|
+
/**
|
|
367
|
+
* Push the current prompt queue state to all subscribers of a session.
|
|
368
|
+
* Called after every queue mutation (enqueue, remove, clear, dequeue).
|
|
369
|
+
* Safe to call when no stream exists or no subscribers — silently no-ops.
|
|
370
|
+
*/
|
|
371
|
+
pushQueueState(sessionId: string): void;
|
|
372
|
+
/**
|
|
373
|
+
* Auto-dequeue the next prompt from the persistent queue and start a
|
|
374
|
+
* new turn. Called from the `agent_end` handler when no loop is active.
|
|
375
|
+
* Returns true if a prompt was dequeued and a turn started.
|
|
376
|
+
*/
|
|
377
|
+
private maybeAutoDequeue;
|
|
378
|
+
}
|
|
379
|
+
//# sourceMappingURL=session-stream.d.ts.map
|