@mastra/code-sdk 0.0.0-client-tool-results-20260912062135
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.md +32 -0
- package/README.md +37 -0
- package/dist/acp/agent.d.ts +35 -0
- package/dist/acp/agent.d.ts.map +1 -0
- package/dist/acp/agent.js +161 -0
- package/dist/acp/agent.js.map +1 -0
- package/dist/acp/event-mapper.d.ts +22 -0
- package/dist/acp/event-mapper.d.ts.map +1 -0
- package/dist/acp/event-mapper.js +214 -0
- package/dist/acp/event-mapper.js.map +1 -0
- package/dist/acp/index.d.ts +8 -0
- package/dist/acp/index.d.ts.map +1 -0
- package/dist/acp/index.js +65 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/server.d.ts +7 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +35 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/acp.d.ts +2 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +2 -0
- package/dist/agents/context-audit.d.ts +84 -0
- package/dist/agents/context-audit.d.ts.map +1 -0
- package/dist/agents/context-audit.js +118 -0
- package/dist/agents/context-audit.js.map +1 -0
- package/dist/agents/credential-resolver.d.ts +63 -0
- package/dist/agents/credential-resolver.d.ts.map +1 -0
- package/dist/agents/credential-resolver.js +97 -0
- package/dist/agents/credential-resolver.js.map +1 -0
- package/dist/agents/custom-provider-source.d.ts +35 -0
- package/dist/agents/custom-provider-source.d.ts.map +1 -0
- package/dist/agents/custom-provider-source.js +25 -0
- package/dist/agents/custom-provider-source.js.map +1 -0
- package/dist/agents/instructions.d.ts +29 -0
- package/dist/agents/instructions.d.ts.map +1 -0
- package/dist/agents/instructions.js +58 -0
- package/dist/agents/instructions.js.map +1 -0
- package/dist/agents/mastracode-gateway.d.ts +74 -0
- package/dist/agents/mastracode-gateway.d.ts.map +1 -0
- package/dist/agents/mastracode-gateway.js +431 -0
- package/dist/agents/mastracode-gateway.js.map +1 -0
- package/dist/agents/memory.d.ts +30 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/memory.js +171 -0
- package/dist/agents/memory.js.map +1 -0
- package/dist/agents/model.d.ts +81 -0
- package/dist/agents/model.d.ts.map +1 -0
- package/dist/agents/model.js +155 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/modes/build.d.ts +10 -0
- package/dist/agents/modes/build.d.ts.map +1 -0
- package/dist/agents/modes/build.js +49 -0
- package/dist/agents/modes/build.js.map +1 -0
- package/dist/agents/modes/explore.d.ts +10 -0
- package/dist/agents/modes/explore.d.ts.map +1 -0
- package/dist/agents/modes/explore.js +42 -0
- package/dist/agents/modes/explore.js.map +1 -0
- package/dist/agents/modes/plan.d.ts +6 -0
- package/dist/agents/modes/plan.d.ts.map +1 -0
- package/dist/agents/modes/plan.js +42 -0
- package/dist/agents/modes/plan.js.map +1 -0
- package/dist/agents/prompts/agent-instructions.d.ts +70 -0
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
- package/dist/agents/prompts/agent-instructions.js +211 -0
- package/dist/agents/prompts/agent-instructions.js.map +1 -0
- package/dist/agents/prompts/build.d.ts +12 -0
- package/dist/agents/prompts/build.d.ts.map +1 -0
- package/dist/agents/prompts/build.js +76 -0
- package/dist/agents/prompts/build.js.map +1 -0
- package/dist/agents/prompts/fast.d.ts +5 -0
- package/dist/agents/prompts/fast.d.ts.map +1 -0
- package/dist/agents/prompts/fast.js +26 -0
- package/dist/agents/prompts/fast.js.map +1 -0
- package/dist/agents/prompts/index.d.ts +50 -0
- package/dist/agents/prompts/index.d.ts.map +1 -0
- package/dist/agents/prompts/index.js +119 -0
- package/dist/agents/prompts/index.js.map +1 -0
- package/dist/agents/prompts/model.d.ts +5 -0
- package/dist/agents/prompts/model.d.ts.map +1 -0
- package/dist/agents/prompts/model.js +23 -0
- package/dist/agents/prompts/model.js.map +1 -0
- package/dist/agents/prompts/plan.d.ts +6 -0
- package/dist/agents/prompts/plan.d.ts.map +1 -0
- package/dist/agents/prompts/plan.js +111 -0
- package/dist/agents/prompts/plan.js.map +1 -0
- package/dist/agents/prompts/tool-guidance.d.ts +18 -0
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
- package/dist/agents/prompts/tool-guidance.js +180 -0
- package/dist/agents/prompts/tool-guidance.js.map +1 -0
- package/dist/agents/sandbox-filesystem.d.ts +117 -0
- package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
- package/dist/agents/sandbox-filesystem.js +356 -0
- package/dist/agents/sandbox-filesystem.js.map +1 -0
- package/dist/agents/subagents/execute.d.ts +3 -0
- package/dist/agents/subagents/execute.d.ts.map +1 -0
- package/dist/agents/subagents/execute.js +27 -0
- package/dist/agents/subagents/execute.js.map +1 -0
- package/dist/agents/subagents/explore.d.ts +3 -0
- package/dist/agents/subagents/explore.d.ts.map +1 -0
- package/dist/agents/subagents/explore.js +18 -0
- package/dist/agents/subagents/explore.js.map +1 -0
- package/dist/agents/subagents/plan.d.ts +3 -0
- package/dist/agents/subagents/plan.d.ts.map +1 -0
- package/dist/agents/subagents/plan.js +18 -0
- package/dist/agents/subagents/plan.js.map +1 -0
- package/dist/agents/thread-caveman-state.d.ts +17 -0
- package/dist/agents/thread-caveman-state.d.ts.map +1 -0
- package/dist/agents/thread-caveman-state.js +107 -0
- package/dist/agents/thread-caveman-state.js.map +1 -0
- package/dist/agents/tool-availability.d.ts +10 -0
- package/dist/agents/tool-availability.d.ts.map +1 -0
- package/dist/agents/tool-availability.js +96 -0
- package/dist/agents/tool-availability.js.map +1 -0
- package/dist/agents/tools.d.ts +36 -0
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +117 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/agents/workflow-builder-agent.d.ts +2 -0
- package/dist/agents/workflow-builder-agent.d.ts.map +1 -0
- package/dist/agents/workflow-builder-agent.js +80 -0
- package/dist/agents/workflow-builder-agent.js.map +1 -0
- package/dist/agents/workspace.d.ts +32 -0
- package/dist/agents/workspace.d.ts.map +1 -0
- package/dist/agents/workspace.js +208 -0
- package/dist/agents/workspace.js.map +1 -0
- package/dist/analytics.d.ts +18 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +163 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auth/authorization-input.d.ts +16 -0
- package/dist/auth/authorization-input.d.ts.map +1 -0
- package/dist/auth/authorization-input.js +42 -0
- package/dist/auth/authorization-input.js.map +1 -0
- package/dist/auth/device-code.d.ts +93 -0
- package/dist/auth/device-code.d.ts.map +1 -0
- package/dist/auth/device-code.js +129 -0
- package/dist/auth/device-code.js.map +1 -0
- package/dist/auth/index.d.ts +12 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/pkce.d.ts +13 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +32 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/provider-auth-error.d.ts +12 -0
- package/dist/auth/provider-auth-error.d.ts.map +1 -0
- package/dist/auth/provider-auth-error.js +16 -0
- package/dist/auth/provider-auth-error.js.map +1 -0
- package/dist/auth/providers/anthropic.d.ts +40 -0
- package/dist/auth/providers/anthropic.d.ts.map +1 -0
- package/dist/auth/providers/anthropic.js +126 -0
- package/dist/auth/providers/anthropic.js.map +1 -0
- package/dist/auth/providers/github-copilot.d.ts +154 -0
- package/dist/auth/providers/github-copilot.d.ts.map +1 -0
- package/dist/auth/providers/github-copilot.js +340 -0
- package/dist/auth/providers/github-copilot.js.map +1 -0
- package/dist/auth/providers/kimi-coding.d.ts +38 -0
- package/dist/auth/providers/kimi-coding.d.ts.map +1 -0
- package/dist/auth/providers/kimi-coding.js +232 -0
- package/dist/auth/providers/kimi-coding.js.map +1 -0
- package/dist/auth/providers/openai-codex.d.ts +139 -0
- package/dist/auth/providers/openai-codex.d.ts.map +1 -0
- package/dist/auth/providers/openai-codex.js +519 -0
- package/dist/auth/providers/openai-codex.js.map +1 -0
- package/dist/auth/providers/xai.d.ts +64 -0
- package/dist/auth/providers/xai.d.ts.map +1 -0
- package/dist/auth/providers/xai.js +205 -0
- package/dist/auth/providers/xai.js.map +1 -0
- package/dist/auth/storage.d.ts +92 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +211 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/auth/types.d.ts +89 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/clipboard/index.d.ts +26 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +226 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -0
- package/dist/error-classification.d.ts +10 -0
- package/dist/error-classification.d.ts.map +1 -0
- package/dist/error-classification.js +22 -0
- package/dist/error-classification.js.map +1 -0
- package/dist/evals/context-builder.d.ts +41 -0
- package/dist/evals/context-builder.d.ts.map +1 -0
- package/dist/evals/context-builder.js +161 -0
- package/dist/evals/context-builder.js.map +1 -0
- package/dist/evals/index.d.ts +4 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +5 -0
- package/dist/evals/scorers/classify-command.d.ts +31 -0
- package/dist/evals/scorers/classify-command.d.ts.map +1 -0
- package/dist/evals/scorers/classify-command.js +73 -0
- package/dist/evals/scorers/classify-command.js.map +1 -0
- package/dist/evals/scorers/efficiency.d.ts +44 -0
- package/dist/evals/scorers/efficiency.d.ts.map +1 -0
- package/dist/evals/scorers/efficiency.js +259 -0
- package/dist/evals/scorers/efficiency.js.map +1 -0
- package/dist/evals/scorers/extract-tools.d.ts +25 -0
- package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
- package/dist/evals/scorers/extract-tools.js +60 -0
- package/dist/evals/scorers/extract-tools.js.map +1 -0
- package/dist/evals/scorers/index.d.ts +3 -0
- package/dist/evals/scorers/index.d.ts.map +1 -0
- package/dist/evals/scorers/index.js +3 -0
- package/dist/evals/scorers/outcome.d.ts +49 -0
- package/dist/evals/scorers/outcome.d.ts.map +1 -0
- package/dist/evals/scorers/outcome.js +347 -0
- package/dist/evals/scorers/outcome.js.map +1 -0
- package/dist/goal-manager.d.ts +78 -0
- package/dist/goal-manager.d.ts.map +1 -0
- package/dist/goal-manager.js +273 -0
- package/dist/goal-manager.js.map +1 -0
- package/dist/goal-signal.d.ts +14 -0
- package/dist/goal-signal.d.ts.map +1 -0
- package/dist/goal-signal.js +17 -0
- package/dist/goal-signal.js.map +1 -0
- package/dist/headless/cli.d.ts +42 -0
- package/dist/headless/cli.d.ts.map +1 -0
- package/dist/headless/cli.js +209 -0
- package/dist/headless/cli.js.map +1 -0
- package/dist/headless/flags.d.ts +33 -0
- package/dist/headless/flags.d.ts.map +1 -0
- package/dist/headless/flags.js +190 -0
- package/dist/headless/flags.js.map +1 -0
- package/dist/headless/format.d.ts +38 -0
- package/dist/headless/format.d.ts.map +1 -0
- package/dist/headless/format.js +89 -0
- package/dist/headless/format.js.map +1 -0
- package/dist/headless/index.d.ts +25 -0
- package/dist/headless/index.d.ts.map +1 -0
- package/dist/headless/index.js +6 -0
- package/dist/headless/policy.d.ts +17 -0
- package/dist/headless/policy.d.ts.map +1 -0
- package/dist/headless/policy.js +42 -0
- package/dist/headless/policy.js.map +1 -0
- package/dist/headless/run-mc.d.ts +7 -0
- package/dist/headless/run-mc.d.ts.map +1 -0
- package/dist/headless/run-mc.js +346 -0
- package/dist/headless/run-mc.js.map +1 -0
- package/dist/headless/types.d.ts +158 -0
- package/dist/headless/types.d.ts.map +1 -0
- package/dist/headless/types.js +19 -0
- package/dist/headless/types.js.map +1 -0
- package/dist/hooks/config.d.ts +11 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +73 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/executor.d.ts +13 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +129 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/manager.d.ts +54 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +241 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +172 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +8 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +919 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/ipc-reporter.d.ts +14 -0
- package/dist/ipc/ipc-reporter.d.ts.map +1 -0
- package/dist/ipc/ipc-reporter.js +21 -0
- package/dist/ipc/ipc-reporter.js.map +1 -0
- package/dist/knowledge-inspector.d.ts +119 -0
- package/dist/knowledge-inspector.d.ts.map +1 -0
- package/dist/knowledge-inspector.js +508 -0
- package/dist/knowledge-inspector.js.map +1 -0
- package/dist/knowledge-scope.d.ts +35 -0
- package/dist/knowledge-scope.d.ts.map +1 -0
- package/dist/knowledge-scope.js +47 -0
- package/dist/knowledge-scope.js.map +1 -0
- package/dist/lsp/client.d.ts +56 -0
- package/dist/lsp/client.d.ts.map +1 -0
- package/dist/lsp/client.js +251 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/index.d.ts +4 -0
- package/dist/lsp/index.d.ts.map +1 -0
- package/dist/lsp/index.js +4 -0
- package/dist/lsp/language.d.ts +9 -0
- package/dist/lsp/language.d.ts.map +1 -0
- package/dist/lsp/language.js +44 -0
- package/dist/lsp/language.js.map +1 -0
- package/dist/lsp/manager.d.ts +34 -0
- package/dist/lsp/manager.d.ts.map +1 -0
- package/dist/lsp/manager.js +82 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/server.d.ts +27 -0
- package/dist/lsp/server.d.ts.map +1 -0
- package/dist/lsp/server.js +159 -0
- package/dist/lsp/server.js.map +1 -0
- package/dist/lsp/workspace.d.ts +9 -0
- package/dist/lsp/workspace.d.ts.map +1 -0
- package/dist/lsp/workspace.js +55 -0
- package/dist/lsp/workspace.js.map +1 -0
- package/dist/mcp/config.d.ts +62 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +301 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/manager.d.ts +101 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +644 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/state.d.ts +35 -0
- package/dist/mcp/state.d.ts.map +1 -0
- package/dist/mcp/state.js +97 -0
- package/dist/mcp/state.js.map +1 -0
- package/dist/mcp/types.d.ts +125 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +1 -0
- package/dist/onboarding/custom-packs.d.ts +7 -0
- package/dist/onboarding/custom-packs.d.ts.map +1 -0
- package/dist/onboarding/custom-packs.js +17 -0
- package/dist/onboarding/custom-packs.js.map +1 -0
- package/dist/onboarding/custom-providers.d.ts +4 -0
- package/dist/onboarding/custom-providers.d.ts.map +1 -0
- package/dist/onboarding/custom-providers.js +30 -0
- package/dist/onboarding/custom-providers.js.map +1 -0
- package/dist/onboarding/index.d.ts +5 -0
- package/dist/onboarding/index.d.ts.map +1 -0
- package/dist/onboarding/index.js +3 -0
- package/dist/onboarding/om-settings.d.ts +25 -0
- package/dist/onboarding/om-settings.d.ts.map +1 -0
- package/dist/onboarding/om-settings.js +47 -0
- package/dist/onboarding/om-settings.js.map +1 -0
- package/dist/onboarding/packs.d.ts +49 -0
- package/dist/onboarding/packs.d.ts.map +1 -0
- package/dist/onboarding/packs.js +182 -0
- package/dist/onboarding/packs.js.map +1 -0
- package/dist/onboarding/settings.d.ts +438 -0
- package/dist/onboarding/settings.d.ts.map +1 -0
- package/dist/onboarding/settings.js +847 -0
- package/dist/onboarding/settings.js.map +1 -0
- package/dist/permissions.d.ts +55 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +137 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plugin.d.ts +144 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +30 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/dependencies.d.ts +9 -0
- package/dist/plugins/dependencies.d.ts.map +1 -0
- package/dist/plugins/dependencies.js +88 -0
- package/dist/plugins/dependencies.js.map +1 -0
- package/dist/plugins/install.d.ts +21 -0
- package/dist/plugins/install.d.ts.map +1 -0
- package/dist/plugins/install.js +190 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +19 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +258 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +98 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +456 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/manifest.d.ts +14 -0
- package/dist/plugins/manifest.d.ts.map +1 -0
- package/dist/plugins/manifest.js +50 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/package-link.d.ts +3 -0
- package/dist/plugins/package-link.d.ts.map +1 -0
- package/dist/plugins/package-link.js +61 -0
- package/dist/plugins/package-link.js.map +1 -0
- package/dist/plugins/paths.d.ts +10 -0
- package/dist/plugins/paths.d.ts.map +1 -0
- package/dist/plugins/paths.js +25 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +112 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/scaffold.d.ts +10 -0
- package/dist/plugins/scaffold.d.ts.map +1 -0
- package/dist/plugins/scaffold.js +116 -0
- package/dist/plugins/scaffold.js.map +1 -0
- package/dist/plugins/signal-lane.d.ts +58 -0
- package/dist/plugins/signal-lane.d.ts.map +1 -0
- package/dist/plugins/signal-lane.js +166 -0
- package/dist/plugins/signal-lane.js.map +1 -0
- package/dist/plugins/types.d.ts +81 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +1 -0
- package/dist/process-memory-diagnostics.d.ts +135 -0
- package/dist/process-memory-diagnostics.d.ts.map +1 -0
- package/dist/process-memory-diagnostics.js +500 -0
- package/dist/process-memory-diagnostics.js.map +1 -0
- package/dist/processors/plan-rejection-abort.d.ts +12 -0
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
- package/dist/processors/plan-rejection-abort.js +54 -0
- package/dist/processors/plan-rejection-abort.js.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
- package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock-gateway.js +153 -0
- package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
- package/dist/providers/amazon-bedrock.d.ts +28 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/dist/providers/amazon-bedrock.js +102 -0
- package/dist/providers/amazon-bedrock.js.map +1 -0
- package/dist/providers/claude-max.d.ts +65 -0
- package/dist/providers/claude-max.d.ts.map +1 -0
- package/dist/providers/claude-max.js +252 -0
- package/dist/providers/claude-max.js.map +1 -0
- package/dist/providers/github-copilot.d.ts +60 -0
- package/dist/providers/github-copilot.d.ts.map +1 -0
- package/dist/providers/github-copilot.js +266 -0
- package/dist/providers/github-copilot.js.map +1 -0
- package/dist/providers/kimi-coding.d.ts +15 -0
- package/dist/providers/kimi-coding.d.ts.map +1 -0
- package/dist/providers/kimi-coding.js +69 -0
- package/dist/providers/kimi-coding.js.map +1 -0
- package/dist/providers/openai-codex.d.ts +73 -0
- package/dist/providers/openai-codex.d.ts.map +1 -0
- package/dist/providers/openai-codex.js +306 -0
- package/dist/providers/openai-codex.js.map +1 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.d.ts.map +1 -0
- package/dist/providers/xai.js +71 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/schema.d.ts +200 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +92 -0
- package/dist/schema.js.map +1 -0
- package/dist/theme-palette.d.ts +17 -0
- package/dist/theme-palette.d.ts.map +1 -0
- package/dist/theme-palette.js +21 -0
- package/dist/theme-palette.js.map +1 -0
- package/dist/thinking.d.ts +33 -0
- package/dist/thinking.d.ts.map +1 -0
- package/dist/thinking.js +58 -0
- package/dist/thinking.js.map +1 -0
- package/dist/tool-names.d.ts +73 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +52 -0
- package/dist/tool-names.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/request-sandbox-access.d.ts +6 -0
- package/dist/tools/request-sandbox-access.d.ts.map +1 -0
- package/dist/tools/request-sandbox-access.js +79 -0
- package/dist/tools/request-sandbox-access.js.map +1 -0
- package/dist/tools/utils.d.ts +20 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +32 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +114 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +155 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/workflows/create-workflow.d.ts +7 -0
- package/dist/tools/workflows/create-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/create-workflow.js +81 -0
- package/dist/tools/workflows/create-workflow.js.map +1 -0
- package/dist/tools/workflows/delete-workflow.d.ts +7 -0
- package/dist/tools/workflows/delete-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/delete-workflow.js +21 -0
- package/dist/tools/workflows/delete-workflow.js.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts +7 -0
- package/dist/tools/workflows/ephemeral-memory.d.ts.map +1 -0
- package/dist/tools/workflows/ephemeral-memory.js +45 -0
- package/dist/tools/workflows/ephemeral-memory.js.map +1 -0
- package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
- package/dist/tools/workflows/extract-json-schema.d.ts.map +1 -0
- package/dist/tools/workflows/extract-json-schema.js +22 -0
- package/dist/tools/workflows/extract-json-schema.js.map +1 -0
- package/dist/tools/workflows/get-workflow.d.ts +11 -0
- package/dist/tools/workflows/get-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/get-workflow.js +34 -0
- package/dist/tools/workflows/get-workflow.js.map +1 -0
- package/dist/tools/workflows/list-available-agents.d.ts +8 -0
- package/dist/tools/workflows/list-available-agents.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-agents.js +32 -0
- package/dist/tools/workflows/list-available-agents.js.map +1 -0
- package/dist/tools/workflows/list-available-tools.d.ts +9 -0
- package/dist/tools/workflows/list-available-tools.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-tools.js +40 -0
- package/dist/tools/workflows/list-available-tools.js.map +1 -0
- package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-available-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-available-workflows.js +32 -0
- package/dist/tools/workflows/list-available-workflows.js.map +1 -0
- package/dist/tools/workflows/list-workflows.d.ts +9 -0
- package/dist/tools/workflows/list-workflows.d.ts.map +1 -0
- package/dist/tools/workflows/list-workflows.js +33 -0
- package/dist/tools/workflows/list-workflows.js.map +1 -0
- package/dist/tools/workflows/run-workflow.d.ts +9 -0
- package/dist/tools/workflows/run-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/run-workflow.js +52 -0
- package/dist/tools/workflows/run-workflow.js.map +1 -0
- package/dist/tools/workflows/save-workflow.d.ts +1015 -0
- package/dist/tools/workflows/save-workflow.d.ts.map +1 -0
- package/dist/tools/workflows/save-workflow.js +28 -0
- package/dist/tools/workflows/save-workflow.js.map +1 -0
- package/dist/tools/workflows/tool-ids.d.ts +15 -0
- package/dist/tools/workflows/tool-ids.d.ts.map +1 -0
- package/dist/tools/workflows/tool-ids.js +19 -0
- package/dist/tools/workflows/tool-ids.js.map +1 -0
- package/dist/utils/binaries.d.ts +7 -0
- package/dist/utils/binaries.d.ts.map +1 -0
- package/dist/utils/binaries.js +78 -0
- package/dist/utils/binaries.js.map +1 -0
- package/dist/utils/debug-log.d.ts +12 -0
- package/dist/utils/debug-log.d.ts.map +1 -0
- package/dist/utils/debug-log.js +59 -0
- package/dist/utils/debug-log.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +196 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gateway-sync.d.ts +26 -0
- package/dist/utils/gateway-sync.d.ts.map +1 -0
- package/dist/utils/gateway-sync.js +61 -0
- package/dist/utils/gateway-sync.js.map +1 -0
- package/dist/utils/path-security.d.ts +2 -0
- package/dist/utils/path-security.d.ts.map +1 -0
- package/dist/utils/path-security.js +10 -0
- package/dist/utils/path-security.js.map +1 -0
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.d.ts.map +1 -0
- package/dist/utils/plan-diff.js +62 -0
- package/dist/utils/plan-diff.js.map +1 -0
- package/dist/utils/plans.d.ts +59 -0
- package/dist/utils/plans.d.ts.map +1 -0
- package/dist/utils/plans.js +117 -0
- package/dist/utils/plans.js.map +1 -0
- package/dist/utils/project.d.ts +160 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +364 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/signals-pubsub.d.ts +41 -0
- package/dist/utils/signals-pubsub.d.ts.map +1 -0
- package/dist/utils/signals-pubsub.js +122 -0
- package/dist/utils/signals-pubsub.js.map +1 -0
- package/dist/utils/slash-command-loader.d.ts +52 -0
- package/dist/utils/slash-command-loader.d.ts.map +1 -0
- package/dist/utils/slash-command-loader.js +142 -0
- package/dist/utils/slash-command-loader.js.map +1 -0
- package/dist/utils/slash-command-processor.d.ts +14 -0
- package/dist/utils/slash-command-processor.d.ts.map +1 -0
- package/dist/utils/slash-command-processor.js +109 -0
- package/dist/utils/slash-command-processor.js.map +1 -0
- package/dist/utils/stdin-pipe.d.ts +33 -0
- package/dist/utils/stdin-pipe.d.ts.map +1 -0
- package/dist/utils/stdin-pipe.js +96 -0
- package/dist/utils/stdin-pipe.js.map +1 -0
- package/dist/utils/storage-factory.d.ts +50 -0
- package/dist/utils/storage-factory.d.ts.map +1 -0
- package/dist/utils/storage-factory.js +121 -0
- package/dist/utils/storage-factory.js.map +1 -0
- package/dist/utils/storage-maintenance.d.ts +103 -0
- package/dist/utils/storage-maintenance.d.ts.map +1 -0
- package/dist/utils/storage-maintenance.js +274 -0
- package/dist/utils/storage-maintenance.js.map +1 -0
- package/dist/utils/thread-lock.d.ts +26 -0
- package/dist/utils/thread-lock.d.ts.map +1 -0
- package/dist/utils/thread-lock.js +112 -0
- package/dist/utils/thread-lock.js.map +1 -0
- package/dist/utils/token-estimator.d.ts +3 -0
- package/dist/utils/token-estimator.d.ts.map +1 -0
- package/dist/utils/token-estimator.js +21 -0
- package/dist/utils/token-estimator.js.map +1 -0
- package/dist/utils/update-check.d.ts +101 -0
- package/dist/utils/update-check.d.ts.map +1 -0
- package/dist/utils/update-check.js +383 -0
- package/dist/utils/update-check.js.map +1 -0
- package/dist/voice/stt-registry.d.ts +64 -0
- package/dist/voice/stt-registry.d.ts.map +1 -0
- package/dist/voice/stt-registry.js +144 -0
- package/dist/voice/stt-registry.js.map +1 -0
- package/dist/workflows/register-primitives.d.ts +52 -0
- package/dist/workflows/register-primitives.d.ts.map +1 -0
- package/dist/workflows/register-primitives.js +40 -0
- package/dist/workflows/register-primitives.js.map +1 -0
- package/dist/workflows/service.d.ts +64 -0
- package/dist/workflows/service.d.ts.map +1 -0
- package/dist/workflows/service.js +53 -0
- package/dist/workflows/service.js.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { getLanguageId } from "./language.js";
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import path, { join } from "path";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
import { pathToFileURL } from "url";
|
|
7
|
+
//#region src/lsp/server.ts
|
|
8
|
+
/**
|
|
9
|
+
* Find the nearest project root directory
|
|
10
|
+
*/
|
|
11
|
+
function findNearestRoot(cwd, markers) {
|
|
12
|
+
let current = cwd;
|
|
13
|
+
while (current !== "/") {
|
|
14
|
+
for (const marker of markers) if (existsSync(join(current, marker))) return current;
|
|
15
|
+
const parent = join(current, "..");
|
|
16
|
+
if (parent === current) break;
|
|
17
|
+
current = parent;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Built-in LSP server definitions
|
|
23
|
+
*/
|
|
24
|
+
const BUILTIN_SERVERS = {
|
|
25
|
+
typescript: {
|
|
26
|
+
id: "typescript",
|
|
27
|
+
name: "TypeScript Language Server",
|
|
28
|
+
languageIds: [
|
|
29
|
+
"typescript",
|
|
30
|
+
"typescriptreact",
|
|
31
|
+
"javascript",
|
|
32
|
+
"javascriptreact"
|
|
33
|
+
],
|
|
34
|
+
root: (cwd) => findNearestRoot(cwd, ["tsconfig.json", "package.json"]),
|
|
35
|
+
spawn: async (root) => {
|
|
36
|
+
const requireFromRoot = createRequire(pathToFileURL(path.join(root, "package.json")));
|
|
37
|
+
let tsserver;
|
|
38
|
+
try {
|
|
39
|
+
tsserver = requireFromRoot.resolve("typescript/lib/tsserver.js");
|
|
40
|
+
} catch {
|
|
41
|
+
tsserver = void 0;
|
|
42
|
+
}
|
|
43
|
+
if (!tsserver) return;
|
|
44
|
+
const localBin = join(root, "node_modules", ".bin", "typescript-language-server");
|
|
45
|
+
const cwdBin = join(process.cwd(), "node_modules", ".bin", "typescript-language-server");
|
|
46
|
+
let tslsBinary;
|
|
47
|
+
if (existsSync(localBin)) tslsBinary = localBin;
|
|
48
|
+
else if (existsSync(cwdBin)) tslsBinary = cwdBin;
|
|
49
|
+
else tslsBinary = "npx";
|
|
50
|
+
return {
|
|
51
|
+
process: spawn(tslsBinary, tslsBinary === "npx" ? ["typescript-language-server", "--stdio"] : ["--stdio"], {
|
|
52
|
+
cwd: root,
|
|
53
|
+
stdio: [
|
|
54
|
+
"pipe",
|
|
55
|
+
"pipe",
|
|
56
|
+
"pipe"
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
initialization: { tsserver: {
|
|
60
|
+
path: tsserver,
|
|
61
|
+
logVerbosity: "off"
|
|
62
|
+
} }
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
eslint: {
|
|
67
|
+
id: "eslint",
|
|
68
|
+
name: "ESLint Language Server",
|
|
69
|
+
languageIds: [
|
|
70
|
+
"typescript",
|
|
71
|
+
"typescriptreact",
|
|
72
|
+
"javascript",
|
|
73
|
+
"javascriptreact"
|
|
74
|
+
],
|
|
75
|
+
root: (cwd) => findNearestRoot(cwd, [
|
|
76
|
+
"package.json",
|
|
77
|
+
".eslintrc.js",
|
|
78
|
+
".eslintrc.json",
|
|
79
|
+
".eslintrc.yml",
|
|
80
|
+
".eslintrc.yaml"
|
|
81
|
+
]),
|
|
82
|
+
spawn: (root) => {
|
|
83
|
+
return spawn(join(process.cwd(), "node_modules", ".bin", "eslint-lsp"), ["--stdio"], {
|
|
84
|
+
cwd: root,
|
|
85
|
+
stdio: [
|
|
86
|
+
"pipe",
|
|
87
|
+
"pipe",
|
|
88
|
+
"pipe"
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
python: {
|
|
94
|
+
id: "python",
|
|
95
|
+
name: "Python Language Server (Pyright)",
|
|
96
|
+
languageIds: ["python"],
|
|
97
|
+
root: (cwd) => findNearestRoot(cwd, [
|
|
98
|
+
"pyproject.toml",
|
|
99
|
+
"setup.py",
|
|
100
|
+
"requirements.txt",
|
|
101
|
+
".git"
|
|
102
|
+
]),
|
|
103
|
+
spawn: (root) => {
|
|
104
|
+
const localPath = join(process.cwd(), "node_modules", ".bin", "pyright-langserver");
|
|
105
|
+
return spawn(existsSync(localPath) ? localPath : "pyright-langserver", ["--stdio"], {
|
|
106
|
+
cwd: root,
|
|
107
|
+
stdio: [
|
|
108
|
+
"pipe",
|
|
109
|
+
"pipe",
|
|
110
|
+
"pipe"
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
go: {
|
|
116
|
+
id: "go",
|
|
117
|
+
name: "Go Language Server (gopls)",
|
|
118
|
+
languageIds: ["go"],
|
|
119
|
+
root: (cwd) => findNearestRoot(cwd, ["go.mod", ".git"]),
|
|
120
|
+
spawn: (root) => {
|
|
121
|
+
return spawn("gopls", ["serve"], {
|
|
122
|
+
cwd: root,
|
|
123
|
+
stdio: [
|
|
124
|
+
"pipe",
|
|
125
|
+
"pipe",
|
|
126
|
+
"pipe"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
rust: {
|
|
132
|
+
id: "rust",
|
|
133
|
+
name: "Rust Language Server (rust-analyzer)",
|
|
134
|
+
languageIds: ["rust"],
|
|
135
|
+
root: (cwd) => findNearestRoot(cwd, ["Cargo.toml", ".git"]),
|
|
136
|
+
spawn: (root) => {
|
|
137
|
+
return spawn("rust-analyzer", ["--stdio"], {
|
|
138
|
+
cwd: root,
|
|
139
|
+
stdio: [
|
|
140
|
+
"pipe",
|
|
141
|
+
"pipe",
|
|
142
|
+
"pipe"
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Get all servers that can handle a file
|
|
150
|
+
*/
|
|
151
|
+
function getServersForFile(filePath, cwd) {
|
|
152
|
+
const languageId = getLanguageId(filePath);
|
|
153
|
+
if (!languageId) return [];
|
|
154
|
+
return Object.values(BUILTIN_SERVERS).filter((server) => server.languageIds.includes(languageId) && server.root(cwd) !== null);
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { BUILTIN_SERVERS, findNearestRoot, getServersForFile };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../src/lsp/server.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path, { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { getLanguageId } from './language.js';\n\n/**\n * LSP Server definition and spawning logic\n */\nexport interface LSPServerInfo {\n id: string;\n name: string;\n languageIds: string[];\n root: (cwd: string) => string | null;\n spawn: (root: string) => ChildProcess | Promise<{ process: ChildProcess; initialization?: any } | undefined>;\n}\n\n/**\n * Find the nearest project root directory\n */\nexport function findNearestRoot(cwd: string, markers: string[]): string | null {\n let current = cwd;\n\n while (current !== '/') {\n for (const marker of markers) {\n if (existsSync(join(current, marker))) {\n return current;\n }\n }\n\n const parent = join(current, '..');\n if (parent === current) break;\n current = parent;\n }\n\n return null;\n}\n\n/**\n * Built-in LSP server definitions\n */\nexport const BUILTIN_SERVERS: Record<string, LSPServerInfo> = {\n typescript: {\n id: 'typescript',\n name: 'TypeScript Language Server',\n languageIds: ['typescript', 'typescriptreact', 'javascript', 'javascriptreact'],\n root: (cwd: string) => findNearestRoot(cwd, ['tsconfig.json', 'package.json']),\n spawn: async (root: string) => {\n // Try to resolve TypeScript from the project directory\n const requireFromRoot = createRequire(pathToFileURL(path.join(root, 'package.json')));\n let tsserver: string | undefined;\n try {\n tsserver = requireFromRoot.resolve('typescript/lib/tsserver.js');\n } catch {\n tsserver = undefined;\n }\n if (!tsserver) {\n return undefined;\n }\n\n // Resolve typescript-language-server binary directly to avoid npx hangs\n // (npx can hang indefinitely in projects with pnpm links)\n const localBin = join(root, 'node_modules', '.bin', 'typescript-language-server');\n const cwdBin = join(process.cwd(), 'node_modules', '.bin', 'typescript-language-server');\n let tslsBinary: string;\n if (existsSync(localBin)) {\n tslsBinary = localBin;\n } else if (existsSync(cwdBin)) {\n tslsBinary = cwdBin;\n } else {\n // Fall back to npx as last resort, but this may hang with pnpm links\n tslsBinary = 'npx';\n }\n\n const args = tslsBinary === 'npx' ? ['typescript-language-server', '--stdio'] : ['--stdio'];\n\n const proc = spawn(tslsBinary, args, {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n return {\n process: proc,\n initialization: {\n tsserver: {\n path: tsserver,\n logVerbosity: 'off',\n },\n },\n };\n },\n },\n\n eslint: {\n id: 'eslint',\n name: 'ESLint Language Server',\n languageIds: ['typescript', 'typescriptreact', 'javascript', 'javascriptreact'],\n root: (cwd: string) =>\n findNearestRoot(cwd, ['package.json', '.eslintrc.js', '.eslintrc.json', '.eslintrc.yml', '.eslintrc.yaml']),\n spawn: (root: string) => {\n const binaryPath = join(process.cwd(), 'node_modules', '.bin', 'eslint-lsp');\n return spawn(binaryPath, ['--stdio'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n\n python: {\n id: 'python',\n name: 'Python Language Server (Pyright)',\n languageIds: ['python'],\n root: (cwd: string) => findNearestRoot(cwd, ['pyproject.toml', 'setup.py', 'requirements.txt', '.git']),\n spawn: (root: string) => {\n // Try node_modules first, then fall back to system PATH\n const localPath = join(process.cwd(), 'node_modules', '.bin', 'pyright-langserver');\n const binaryPath = existsSync(localPath) ? localPath : 'pyright-langserver';\n return spawn(binaryPath, ['--stdio'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n\n go: {\n id: 'go',\n name: 'Go Language Server (gopls)',\n languageIds: ['go'],\n root: (cwd: string) => findNearestRoot(cwd, ['go.mod', '.git']),\n spawn: (root: string) => {\n return spawn('gopls', ['serve'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n\n rust: {\n id: 'rust',\n name: 'Rust Language Server (rust-analyzer)',\n languageIds: ['rust'],\n root: (cwd: string) => findNearestRoot(cwd, ['Cargo.toml', '.git']),\n spawn: (root: string) => {\n return spawn('rust-analyzer', ['--stdio'], {\n cwd: root,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n },\n },\n};\n\n/**\n * Get all servers that can handle a file\n */\nexport function getServersForFile(filePath: string, cwd: string): LSPServerInfo[] {\n const languageId = getLanguageId(filePath);\n if (!languageId) return [];\n\n return Object.values(BUILTIN_SERVERS).filter(\n server => server.languageIds.includes(languageId) && server.root(cwd) !== null,\n );\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,gBAAgB,KAAa,SAAkC;CAC7E,IAAI,UAAU;CAEd,OAAO,YAAY,KAAK;EACtB,KAAK,MAAM,UAAU,SACnB,IAAI,WAAW,KAAK,SAAS,MAAM,CAAC,GAClC,OAAO;EAIX,MAAM,SAAS,KAAK,SAAS,IAAI;EACjC,IAAI,WAAW,SAAS;EACxB,UAAU;CACZ;CAEA,OAAO;AACT;;;;AAKA,MAAa,kBAAiD;CAC5D,YAAY;EACV,IAAI;EACJ,MAAM;EACN,aAAa;GAAC;GAAc;GAAmB;GAAc;EAAiB;EAC9E,OAAO,QAAgB,gBAAgB,KAAK,CAAC,iBAAiB,cAAc,CAAC;EAC7E,OAAO,OAAO,SAAiB;GAE7B,MAAM,kBAAkB,cAAc,cAAc,KAAK,KAAK,MAAM,cAAc,CAAC,CAAC;GACpF,IAAI;GACJ,IAAI;IACF,WAAW,gBAAgB,QAAQ,4BAA4B;GACjE,QAAQ;IACN,WAAW,KAAA;GACb;GACA,IAAI,CAAC,UACH;GAKF,MAAM,WAAW,KAAK,MAAM,gBAAgB,QAAQ,4BAA4B;GAChF,MAAM,SAAS,KAAK,QAAQ,IAAI,GAAG,gBAAgB,QAAQ,4BAA4B;GACvF,IAAI;GACJ,IAAI,WAAW,QAAQ,GACrB,aAAa;QACR,IAAI,WAAW,MAAM,GAC1B,aAAa;QAGb,aAAa;GAUf,OAAO;IACL,SANW,MAAM,YAFN,eAAe,QAAQ,CAAC,8BAA8B,SAAS,IAAI,CAAC,SAAS,GAErD;KACnC,KAAK;KACL,OAAO;MAAC;MAAQ;MAAQ;KAAM;IAChC,CAGc;IACZ,gBAAgB,EACd,UAAU;KACR,MAAM;KACN,cAAc;IAChB,EACF;GACF;EACF;CACF;CAEA,QAAQ;EACN,IAAI;EACJ,MAAM;EACN,aAAa;GAAC;GAAc;GAAmB;GAAc;EAAiB;EAC9E,OAAO,QACL,gBAAgB,KAAK;GAAC;GAAgB;GAAgB;GAAkB;GAAiB;EAAgB,CAAC;EAC5G,QAAQ,SAAiB;GAEvB,OAAO,MADY,KAAK,QAAQ,IAAI,GAAG,gBAAgB,QAAQ,YACzC,GAAG,CAAC,SAAS,GAAG;IACpC,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;CAEA,QAAQ;EACN,IAAI;EACJ,MAAM;EACN,aAAa,CAAC,QAAQ;EACtB,OAAO,QAAgB,gBAAgB,KAAK;GAAC;GAAkB;GAAY;GAAoB;EAAM,CAAC;EACtG,QAAQ,SAAiB;GAEvB,MAAM,YAAY,KAAK,QAAQ,IAAI,GAAG,gBAAgB,QAAQ,oBAAoB;GAElF,OAAO,MADY,WAAW,SAAS,IAAI,YAAY,sBAC9B,CAAC,SAAS,GAAG;IACpC,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;CAEA,IAAI;EACF,IAAI;EACJ,MAAM;EACN,aAAa,CAAC,IAAI;EAClB,OAAO,QAAgB,gBAAgB,KAAK,CAAC,UAAU,MAAM,CAAC;EAC9D,QAAQ,SAAiB;GACvB,OAAO,MAAM,SAAS,CAAC,OAAO,GAAG;IAC/B,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;CAEA,MAAM;EACJ,IAAI;EACJ,MAAM;EACN,aAAa,CAAC,MAAM;EACpB,OAAO,QAAgB,gBAAgB,KAAK,CAAC,cAAc,MAAM,CAAC;EAClE,QAAQ,SAAiB;GACvB,OAAO,MAAM,iBAAiB,CAAC,SAAS,GAAG;IACzC,KAAK;IACL,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;EACH;CACF;AACF;;;;AAKA,SAAgB,kBAAkB,UAAkB,KAA8B;CAChF,MAAM,aAAa,cAAc,QAAQ;CACzC,IAAI,CAAC,YAAY,OAAO,CAAC;CAEzB,OAAO,OAAO,OAAO,eAAe,CAAC,CAAC,QACpC,WAAU,OAAO,YAAY,SAAS,UAAU,KAAK,OAAO,KAAK,GAAG,MAAM,IAC5E;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the workspace root by walking up from the file path
|
|
3
|
+
* looking for common workspace markers.
|
|
4
|
+
*
|
|
5
|
+
* For monorepos, this prioritizes the closest package/project root
|
|
6
|
+
* (e.g., packages/core) over the monorepo root.
|
|
7
|
+
*/
|
|
8
|
+
export declare function findWorkspaceRoot(filePath: string): string;
|
|
9
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/lsp/workspace.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiD1D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as fs$1 from "fs";
|
|
2
|
+
import * as path$1 from "path";
|
|
3
|
+
//#region src/lsp/workspace.ts
|
|
4
|
+
/**
|
|
5
|
+
* Workspace markers that indicate the root of a project
|
|
6
|
+
*/
|
|
7
|
+
const WORKSPACE_MARKERS = [
|
|
8
|
+
"package.json",
|
|
9
|
+
"tsconfig.json",
|
|
10
|
+
"pyproject.toml",
|
|
11
|
+
"go.mod",
|
|
12
|
+
".git",
|
|
13
|
+
"Cargo.toml",
|
|
14
|
+
"composer.json"
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Find the workspace root by walking up from the file path
|
|
18
|
+
* looking for common workspace markers.
|
|
19
|
+
*
|
|
20
|
+
* For monorepos, this prioritizes the closest package/project root
|
|
21
|
+
* (e.g., packages/core) over the monorepo root.
|
|
22
|
+
*/
|
|
23
|
+
function findWorkspaceRoot(filePath) {
|
|
24
|
+
let currentDir = path$1.dirname(path$1.resolve(filePath));
|
|
25
|
+
const root = path$1.parse(currentDir).root;
|
|
26
|
+
let closestProjectRoot = null;
|
|
27
|
+
let searchDir = currentDir;
|
|
28
|
+
while (searchDir !== root) {
|
|
29
|
+
const hasTsConfig = fs$1.existsSync(path$1.join(searchDir, "tsconfig.json"));
|
|
30
|
+
const hasPackageJson = fs$1.existsSync(path$1.join(searchDir, "package.json"));
|
|
31
|
+
if (hasTsConfig || hasPackageJson) {
|
|
32
|
+
closestProjectRoot = searchDir;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
const parentDir = path$1.dirname(searchDir);
|
|
36
|
+
if (parentDir === searchDir) break;
|
|
37
|
+
searchDir = parentDir;
|
|
38
|
+
}
|
|
39
|
+
if (closestProjectRoot) return closestProjectRoot;
|
|
40
|
+
currentDir = path$1.dirname(path$1.resolve(filePath));
|
|
41
|
+
while (currentDir !== root) {
|
|
42
|
+
for (const marker of WORKSPACE_MARKERS) {
|
|
43
|
+
const markerPath = path$1.join(currentDir, marker);
|
|
44
|
+
if (fs$1.existsSync(markerPath)) return currentDir;
|
|
45
|
+
}
|
|
46
|
+
const parentDir = path$1.dirname(currentDir);
|
|
47
|
+
if (parentDir === currentDir) break;
|
|
48
|
+
currentDir = parentDir;
|
|
49
|
+
}
|
|
50
|
+
return path$1.dirname(path$1.resolve(filePath));
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { findWorkspaceRoot };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","names":["path","fs"],"sources":["../../src/lsp/workspace.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\n/**\n * Workspace markers that indicate the root of a project\n */\nconst WORKSPACE_MARKERS = [\n 'package.json',\n 'tsconfig.json',\n 'pyproject.toml',\n 'go.mod',\n '.git',\n 'Cargo.toml',\n 'composer.json',\n];\n\n/**\n * Find the workspace root by walking up from the file path\n * looking for common workspace markers.\n *\n * For monorepos, this prioritizes the closest package/project root\n * (e.g., packages/core) over the monorepo root.\n */\nexport function findWorkspaceRoot(filePath: string): string {\n let currentDir = path.dirname(path.resolve(filePath));\n const root = path.parse(currentDir).root;\n\n // First, find the closest tsconfig.json or package.json\n // This handles monorepos where the actual project is in a subdirectory\n let closestProjectRoot: string | null = null;\n let searchDir = currentDir;\n\n while (searchDir !== root) {\n const hasTsConfig = fs.existsSync(path.join(searchDir, 'tsconfig.json'));\n const hasPackageJson = fs.existsSync(path.join(searchDir, 'package.json'));\n\n if (hasTsConfig || hasPackageJson) {\n closestProjectRoot = searchDir;\n break;\n }\n\n const parentDir = path.dirname(searchDir);\n if (parentDir === searchDir) {\n break;\n }\n searchDir = parentDir;\n }\n\n // If we found a project root, return it\n if (closestProjectRoot) {\n return closestProjectRoot;\n }\n\n // Otherwise, fall back to looking for any workspace marker\n currentDir = path.dirname(path.resolve(filePath));\n while (currentDir !== root) {\n for (const marker of WORKSPACE_MARKERS) {\n const markerPath = path.join(currentDir, marker);\n if (fs.existsSync(markerPath)) {\n return currentDir;\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n // Fallback to the directory containing the file\n return path.dirname(path.resolve(filePath));\n}\n"],"mappings":";;;;;;AAMA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,kBAAkB,UAA0B;CAC1D,IAAI,aAAaA,OAAK,QAAQA,OAAK,QAAQ,QAAQ,CAAC;CACpD,MAAM,OAAOA,OAAK,MAAM,UAAU,CAAC,CAAC;CAIpC,IAAI,qBAAoC;CACxC,IAAI,YAAY;CAEhB,OAAO,cAAc,MAAM;EACzB,MAAM,cAAcC,KAAG,WAAWD,OAAK,KAAK,WAAW,eAAe,CAAC;EACvE,MAAM,iBAAiBC,KAAG,WAAWD,OAAK,KAAK,WAAW,cAAc,CAAC;EAEzE,IAAI,eAAe,gBAAgB;GACjC,qBAAqB;GACrB;EACF;EAEA,MAAM,YAAYA,OAAK,QAAQ,SAAS;EACxC,IAAI,cAAc,WAChB;EAEF,YAAY;CACd;CAGA,IAAI,oBACF,OAAO;CAIT,aAAaA,OAAK,QAAQA,OAAK,QAAQ,QAAQ,CAAC;CAChD,OAAO,eAAe,MAAM;EAC1B,KAAK,MAAM,UAAU,mBAAmB;GACtC,MAAM,aAAaA,OAAK,KAAK,YAAY,MAAM;GAC/C,IAAIC,KAAG,WAAW,UAAU,GAC1B,OAAO;EAEX;EAEA,MAAM,YAAYD,OAAK,QAAQ,UAAU;EACzC,IAAI,cAAc,YAChB;EAEF,aAAa;CACf;CAGA,OAAOA,OAAK,QAAQA,OAAK,QAAQ,QAAQ,CAAC;AAC5C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server configuration loading from filesystem.
|
|
3
|
+
* Loads from, lowest to highest priority:
|
|
4
|
+
* 1. ~/.claude.json (Claude Code global — opt-in)
|
|
5
|
+
* 2. $CODEX_HOME/config.toml (Codex CLI global — opt-in)
|
|
6
|
+
* 3. .claude/settings.local.json (Claude Code project compatibility)
|
|
7
|
+
* 4. ~/.mastracode/mcp.json (Mastra Code global)
|
|
8
|
+
* 5. .mcp.json (project root — Claude Code compatible)
|
|
9
|
+
* 6. .mastracode/mcp.json (Mastra Code project)
|
|
10
|
+
*
|
|
11
|
+
* Higher-priority configs override lower ones by server name. The project root
|
|
12
|
+
* `.mcp.json` is read so a project that already keeps MCP servers there for
|
|
13
|
+
* Claude Code does not need to duplicate them under `.mastracode/`.
|
|
14
|
+
*/
|
|
15
|
+
import type { McpConfig, McpHttpOAuthConfig } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Default OAuth redirect URL for servers that do not configure one.
|
|
18
|
+
* Port 1458 is stable across sessions so persisted tokens keep the same
|
|
19
|
+
* storage fingerprint; it sits clear of the ports the Codex login flow
|
|
20
|
+
* reserves (1455/1457). When 1458 is busy the callback server falls back
|
|
21
|
+
* to the next sequential port, which stays covered by the client
|
|
22
|
+
* registration (see `@mastra/mcp`'s `getCallbackUrlCandidates`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_OAUTH_REDIRECT_URL = "http://127.0.0.1:1458/oauth/callback";
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the effective OAuth redirect URL for a server config.
|
|
27
|
+
*
|
|
28
|
+
* `callbackPort` (the Claude Code / Codex convention) takes precedence and
|
|
29
|
+
* synthesizes `http://localhost:<port>/callback`. Config-file entries are
|
|
30
|
+
* normalized by `parseOAuthConfig` (which also enforces that `callbackPort`
|
|
31
|
+
* and `redirectUrl` are mutually exclusive), but programmatically registered
|
|
32
|
+
* servers bypass the parser, so every consumer of the redirect URL must
|
|
33
|
+
* resolve it through this helper rather than reading `redirectUrl` directly.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveOAuthRedirectUrl(oauth: McpHttpOAuthConfig | undefined): string;
|
|
36
|
+
export interface ExternalMcpDiscoveryOptions {
|
|
37
|
+
claudeCodeGlobal?: boolean;
|
|
38
|
+
codexGlobal?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare function loadMcpConfig(projectDir: string, configDirName?: string, externalDiscovery?: ExternalMcpDiscoveryOptions): McpConfig;
|
|
41
|
+
export declare function getProjectMcpPath(projectDir: string, configDirName?: string): string;
|
|
42
|
+
export declare function getRootMcpPath(projectDir: string): string;
|
|
43
|
+
export declare function getGlobalMcpPath(configDirName?: string): string;
|
|
44
|
+
export declare function getClaudeSettingsPath(projectDir: string): string;
|
|
45
|
+
export declare function getClaudeGlobalMcpPath(): string;
|
|
46
|
+
export declare function getCodexGlobalMcpPath(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Expand `${VAR}` and `${VAR:-default}` references in a string from the
|
|
49
|
+
* environment, matching how Claude Code resolves values in `.mcp.json`.
|
|
50
|
+
* A referenced variable that is unset or empty falls back to its default,
|
|
51
|
+
* or to an empty string when no default is given.
|
|
52
|
+
*/
|
|
53
|
+
export declare function expandEnvVars(value: string, env?: NodeJS.ProcessEnv): string;
|
|
54
|
+
/**
|
|
55
|
+
* Classify a raw server entry as stdio, http, or skip (with reason).
|
|
56
|
+
*/
|
|
57
|
+
export declare function classifyServerEntry(raw: unknown): {
|
|
58
|
+
kind: 'stdio' | 'http' | 'skip';
|
|
59
|
+
reason?: string;
|
|
60
|
+
};
|
|
61
|
+
export declare function validateConfig(raw: unknown): McpConfig;
|
|
62
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AAEnG;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,yCAAyC,CAAC;AAYjF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,GAAG,MAAM,CAKrF;AAED,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,EAClB,aAAa,SAAqB,EAClC,iBAAiB,GAAE,2BAAgC,GAClD,SAAS,CASX;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,SAAqB,GAAG,MAAM,CAEhG;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,gBAAgB,CAAC,aAAa,SAAqB,GAAG,MAAM,CAE3E;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAG9C;AAqGD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAUzF;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CA2BtG;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAiDtD"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { DEFAULT_CONFIG_DIR } from "../constants.js";
|
|
2
|
+
import * as fs$1 from "fs";
|
|
3
|
+
import * as os$1 from "os";
|
|
4
|
+
import * as path$1 from "path";
|
|
5
|
+
import { parse } from "smol-toml";
|
|
6
|
+
//#region src/mcp/config.ts
|
|
7
|
+
/**
|
|
8
|
+
* MCP server configuration loading from filesystem.
|
|
9
|
+
* Loads from, lowest to highest priority:
|
|
10
|
+
* 1. ~/.claude.json (Claude Code global — opt-in)
|
|
11
|
+
* 2. $CODEX_HOME/config.toml (Codex CLI global — opt-in)
|
|
12
|
+
* 3. .claude/settings.local.json (Claude Code project compatibility)
|
|
13
|
+
* 4. ~/.mastracode/mcp.json (Mastra Code global)
|
|
14
|
+
* 5. .mcp.json (project root — Claude Code compatible)
|
|
15
|
+
* 6. .mastracode/mcp.json (Mastra Code project)
|
|
16
|
+
*
|
|
17
|
+
* Higher-priority configs override lower ones by server name. The project root
|
|
18
|
+
* `.mcp.json` is read so a project that already keeps MCP servers there for
|
|
19
|
+
* Claude Code does not need to duplicate them under `.mastracode/`.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Default OAuth redirect URL for servers that do not configure one.
|
|
23
|
+
* Port 1458 is stable across sessions so persisted tokens keep the same
|
|
24
|
+
* storage fingerprint; it sits clear of the ports the Codex login flow
|
|
25
|
+
* reserves (1455/1457). When 1458 is busy the callback server falls back
|
|
26
|
+
* to the next sequential port, which stays covered by the client
|
|
27
|
+
* registration (see `@mastra/mcp`'s `getCallbackUrlCandidates`).
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_OAUTH_REDIRECT_URL = "http://127.0.0.1:1458/oauth/callback";
|
|
30
|
+
const LOOPBACK_IPV4 = /^127\.(?:\d{1,3})\.(?:\d{1,3})\.(?:\d{1,3})$/;
|
|
31
|
+
function isLoopbackHostname(hostname) {
|
|
32
|
+
return hostname === "localhost" || hostname === "[::1]" || hostname === "::1" || LOOPBACK_IPV4.test(hostname);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the effective OAuth redirect URL for a server config.
|
|
36
|
+
*
|
|
37
|
+
* `callbackPort` (the Claude Code / Codex convention) takes precedence and
|
|
38
|
+
* synthesizes `http://localhost:<port>/callback`. Config-file entries are
|
|
39
|
+
* normalized by `parseOAuthConfig` (which also enforces that `callbackPort`
|
|
40
|
+
* and `redirectUrl` are mutually exclusive), but programmatically registered
|
|
41
|
+
* servers bypass the parser, so every consumer of the redirect URL must
|
|
42
|
+
* resolve it through this helper rather than reading `redirectUrl` directly.
|
|
43
|
+
*/
|
|
44
|
+
function resolveOAuthRedirectUrl(oauth) {
|
|
45
|
+
if (oauth?.callbackPort !== void 0) return `http://localhost:${oauth.callbackPort}/callback`;
|
|
46
|
+
return oauth?.redirectUrl ?? "http://127.0.0.1:1458/oauth/callback";
|
|
47
|
+
}
|
|
48
|
+
function loadMcpConfig(projectDir, configDirName = DEFAULT_CONFIG_DIR, externalDiscovery = {}) {
|
|
49
|
+
return mergeConfigs(externalDiscovery.claudeCodeGlobal ? loadClaudeGlobalConfig() : {}, externalDiscovery.codexGlobal ? loadCodexGlobalConfig() : {}, loadClaudeSettings(projectDir), loadSingleConfig(getGlobalMcpPath(configDirName)), loadSingleConfig(getRootMcpPath(projectDir)), loadSingleConfig(getProjectMcpPath(projectDir, configDirName)));
|
|
50
|
+
}
|
|
51
|
+
function getProjectMcpPath(projectDir, configDirName = DEFAULT_CONFIG_DIR) {
|
|
52
|
+
return path$1.join(projectDir, configDirName, "mcp.json");
|
|
53
|
+
}
|
|
54
|
+
function getRootMcpPath(projectDir) {
|
|
55
|
+
return path$1.join(projectDir, ".mcp.json");
|
|
56
|
+
}
|
|
57
|
+
function getGlobalMcpPath(configDirName = DEFAULT_CONFIG_DIR) {
|
|
58
|
+
return path$1.join(os$1.homedir(), configDirName, "mcp.json");
|
|
59
|
+
}
|
|
60
|
+
function getClaudeSettingsPath(projectDir) {
|
|
61
|
+
return path$1.join(projectDir, ".claude", "settings.local.json");
|
|
62
|
+
}
|
|
63
|
+
function getClaudeGlobalMcpPath() {
|
|
64
|
+
return path$1.join(os$1.homedir(), ".claude.json");
|
|
65
|
+
}
|
|
66
|
+
function getCodexGlobalMcpPath() {
|
|
67
|
+
const codexHome = process.env.CODEX_HOME || path$1.join(os$1.homedir(), ".codex");
|
|
68
|
+
return path$1.join(codexHome, "config.toml");
|
|
69
|
+
}
|
|
70
|
+
function withoutSkippedServers(config) {
|
|
71
|
+
return config.mcpServers ? { mcpServers: config.mcpServers } : {};
|
|
72
|
+
}
|
|
73
|
+
function loadClaudeGlobalConfig() {
|
|
74
|
+
try {
|
|
75
|
+
const filePath = getClaudeGlobalMcpPath();
|
|
76
|
+
if (!fs$1.existsSync(filePath)) return {};
|
|
77
|
+
return withoutSkippedServers(validateConfig({ mcpServers: JSON.parse(fs$1.readFileSync(filePath, "utf-8"))?.mcpServers }));
|
|
78
|
+
} catch {
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function stringRecord(value) {
|
|
83
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
84
|
+
const entries = Object.entries(value).filter((entry) => typeof entry[1] === "string");
|
|
85
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
86
|
+
}
|
|
87
|
+
function normalizeCodexServer(entry) {
|
|
88
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return void 0;
|
|
89
|
+
const raw = entry;
|
|
90
|
+
if (raw.enabled === false) return void 0;
|
|
91
|
+
if (typeof raw.command === "string") return {
|
|
92
|
+
command: raw.command,
|
|
93
|
+
args: Array.isArray(raw.args) && raw.args.every((arg) => typeof arg === "string") ? raw.args : void 0,
|
|
94
|
+
env: stringRecord(raw.env)
|
|
95
|
+
};
|
|
96
|
+
if (typeof raw.url === "string") {
|
|
97
|
+
const headers = stringRecord(raw.http_headers) ?? {};
|
|
98
|
+
if (typeof raw.bearer_token_env_var === "string" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(raw.bearer_token_env_var) && !Object.keys(headers).some((name) => name.toLowerCase() === "authorization")) headers.Authorization = `Bearer \${${raw.bearer_token_env_var}}`;
|
|
99
|
+
return {
|
|
100
|
+
url: raw.url,
|
|
101
|
+
headers: Object.keys(headers).length > 0 ? headers : void 0
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function loadCodexGlobalConfig() {
|
|
106
|
+
try {
|
|
107
|
+
const filePath = getCodexGlobalMcpPath();
|
|
108
|
+
if (!fs$1.existsSync(filePath)) return {};
|
|
109
|
+
const rawServers = parse(fs$1.readFileSync(filePath, "utf-8")).mcp_servers;
|
|
110
|
+
if (!rawServers || typeof rawServers !== "object" || Array.isArray(rawServers)) return {};
|
|
111
|
+
const mcpServers = {};
|
|
112
|
+
for (const [name, entry] of Object.entries(rawServers)) {
|
|
113
|
+
const normalized = normalizeCodexServer(entry);
|
|
114
|
+
if (normalized) mcpServers[name] = normalized;
|
|
115
|
+
}
|
|
116
|
+
return withoutSkippedServers(validateConfig({ mcpServers }));
|
|
117
|
+
} catch {
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function loadSingleConfig(filePath) {
|
|
122
|
+
try {
|
|
123
|
+
if (!fs$1.existsSync(filePath)) return {};
|
|
124
|
+
const raw = fs$1.readFileSync(filePath, "utf-8");
|
|
125
|
+
return validateConfig(JSON.parse(raw));
|
|
126
|
+
} catch {
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function loadClaudeSettings(projectDir) {
|
|
131
|
+
try {
|
|
132
|
+
const filePath = getClaudeSettingsPath(projectDir);
|
|
133
|
+
if (!fs$1.existsSync(filePath)) return {};
|
|
134
|
+
const raw = fs$1.readFileSync(filePath, "utf-8");
|
|
135
|
+
const parsed = JSON.parse(raw);
|
|
136
|
+
if (parsed?.mcpServers && typeof parsed.mcpServers === "object") return validateConfig({ mcpServers: parsed.mcpServers });
|
|
137
|
+
return {};
|
|
138
|
+
} catch {
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Expand `${VAR}` and `${VAR:-default}` references in a string from the
|
|
144
|
+
* environment, matching how Claude Code resolves values in `.mcp.json`.
|
|
145
|
+
* A referenced variable that is unset or empty falls back to its default,
|
|
146
|
+
* or to an empty string when no default is given.
|
|
147
|
+
*/
|
|
148
|
+
function expandEnvVars(value, env = process.env) {
|
|
149
|
+
return value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}|\$([A-Za-z_][A-Za-z0-9_]*)/g, (_match, bracedName, fallback, bareName) => {
|
|
150
|
+
const resolved = env[bracedName ?? bareName];
|
|
151
|
+
if (resolved !== void 0 && resolved !== "") return resolved;
|
|
152
|
+
return fallback ?? "";
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Expand `${VAR}` and `$VAR` references in every string-valued HTTP header so that
|
|
157
|
+
* secrets like API keys can be referenced from the environment instead of
|
|
158
|
+
* being hardcoded in `mcp.json`.
|
|
159
|
+
*/
|
|
160
|
+
function expandHeaderEnvVars(headers) {
|
|
161
|
+
const expanded = {};
|
|
162
|
+
for (const [key, value] of Object.entries(headers)) if (typeof value === "string") expanded[key] = expandEnvVars(value);
|
|
163
|
+
return expanded;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Expand `${VAR}` and `$VAR` references in every string-valued environment
|
|
167
|
+
* variable passed to a stdio server, so that secrets can be referenced from the
|
|
168
|
+
* host environment instead of being hardcoded in `mcp.json`.
|
|
169
|
+
*/
|
|
170
|
+
function expandEnvValues(env) {
|
|
171
|
+
const expanded = {};
|
|
172
|
+
for (const [key, value] of Object.entries(env)) if (typeof value === "string") expanded[key] = expandEnvVars(value);
|
|
173
|
+
return expanded;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Classify a raw server entry as stdio, http, or skip (with reason).
|
|
177
|
+
*/
|
|
178
|
+
function classifyServerEntry(raw) {
|
|
179
|
+
if (!raw || typeof raw !== "object") return {
|
|
180
|
+
kind: "skip",
|
|
181
|
+
reason: "Invalid entry: expected an object"
|
|
182
|
+
};
|
|
183
|
+
const obj = raw;
|
|
184
|
+
const hasCommand = typeof obj.command === "string";
|
|
185
|
+
const hasUrl = typeof obj.url === "string";
|
|
186
|
+
if (hasCommand && hasUrl) return {
|
|
187
|
+
kind: "skip",
|
|
188
|
+
reason: "Cannot specify both \"command\" and \"url\""
|
|
189
|
+
};
|
|
190
|
+
if (hasCommand) return { kind: "stdio" };
|
|
191
|
+
if (hasUrl) {
|
|
192
|
+
try {
|
|
193
|
+
new URL(expandEnvVars(obj.url));
|
|
194
|
+
} catch {
|
|
195
|
+
return {
|
|
196
|
+
kind: "skip",
|
|
197
|
+
reason: `Invalid URL: "${obj.url}"`
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return { kind: "http" };
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
kind: "skip",
|
|
204
|
+
reason: "Missing required field: \"command\" (stdio) or \"url\" (http)"
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function validateConfig(raw) {
|
|
208
|
+
if (!raw || typeof raw !== "object") return {};
|
|
209
|
+
const obj = raw;
|
|
210
|
+
if (!obj.mcpServers || typeof obj.mcpServers !== "object") return {};
|
|
211
|
+
const servers = {};
|
|
212
|
+
const skippedServers = [];
|
|
213
|
+
const rawServers = obj.mcpServers;
|
|
214
|
+
for (const [name, entry] of Object.entries(rawServers)) {
|
|
215
|
+
const classification = classifyServerEntry(entry);
|
|
216
|
+
if (classification.kind === "stdio") {
|
|
217
|
+
const e = entry;
|
|
218
|
+
servers[name] = {
|
|
219
|
+
command: e.command,
|
|
220
|
+
args: Array.isArray(e.args) ? e.args : void 0,
|
|
221
|
+
env: typeof e.env === "object" && e.env !== null ? expandEnvValues(e.env) : void 0
|
|
222
|
+
};
|
|
223
|
+
} else if (classification.kind === "http") {
|
|
224
|
+
const e = entry;
|
|
225
|
+
const oauthResult = parseOAuthConfig(e.oauth);
|
|
226
|
+
if (oauthResult.reason) {
|
|
227
|
+
skippedServers.push({
|
|
228
|
+
name,
|
|
229
|
+
reason: oauthResult.reason
|
|
230
|
+
});
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
servers[name] = {
|
|
234
|
+
url: expandEnvVars(e.url),
|
|
235
|
+
headers: typeof e.headers === "object" && e.headers !== null ? expandHeaderEnvVars(e.headers) : void 0,
|
|
236
|
+
oauth: oauthResult.config
|
|
237
|
+
};
|
|
238
|
+
} else skippedServers.push({
|
|
239
|
+
name,
|
|
240
|
+
reason: classification.reason
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
const result = {};
|
|
244
|
+
if (Object.keys(servers).length > 0) result.mcpServers = servers;
|
|
245
|
+
if (skippedServers.length > 0) result.skippedServers = skippedServers;
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
248
|
+
function parseOAuthConfig(raw) {
|
|
249
|
+
if (raw === void 0) return {};
|
|
250
|
+
if (!raw || typeof raw !== "object") return { reason: "Invalid OAuth config: expected an object" };
|
|
251
|
+
const obj = raw;
|
|
252
|
+
if (obj.redirectUrl !== void 0 && typeof obj.redirectUrl !== "string") return { reason: "Invalid OAuth config: \"redirectUrl\" must be a string" };
|
|
253
|
+
let callbackPortRedirectUrl;
|
|
254
|
+
if (obj.callbackPort !== void 0) {
|
|
255
|
+
if (obj.redirectUrl !== void 0) return { reason: "Invalid OAuth config: set either \"redirectUrl\" or \"callbackPort\", not both" };
|
|
256
|
+
if (typeof obj.callbackPort !== "number" || !Number.isInteger(obj.callbackPort) || obj.callbackPort < 1 || obj.callbackPort > 65535) return { reason: "Invalid OAuth config: \"callbackPort\" must be an integer between 1 and 65535" };
|
|
257
|
+
callbackPortRedirectUrl = resolveOAuthRedirectUrl({ callbackPort: obj.callbackPort });
|
|
258
|
+
}
|
|
259
|
+
const rawRedirectUrl = callbackPortRedirectUrl ?? obj.redirectUrl ?? "http://127.0.0.1:1458/oauth/callback";
|
|
260
|
+
try {
|
|
261
|
+
const redirectUrl = new URL(rawRedirectUrl);
|
|
262
|
+
const isLoopback = isLoopbackHostname(redirectUrl.hostname);
|
|
263
|
+
if (redirectUrl.protocol !== "https:" && !(redirectUrl.protocol === "http:" && isLoopback)) return { reason: "Invalid OAuth redirectUrl: must use HTTPS unless it is a loopback HTTP URL" };
|
|
264
|
+
} catch {
|
|
265
|
+
return { reason: `Invalid OAuth redirectUrl: "${rawRedirectUrl}"` };
|
|
266
|
+
}
|
|
267
|
+
if (obj.scopes !== void 0 && (!Array.isArray(obj.scopes) || obj.scopes.some((scope) => typeof scope !== "string"))) return { reason: "Invalid OAuth config: \"scopes\" must be an array of strings" };
|
|
268
|
+
return { config: {
|
|
269
|
+
redirectUrl: rawRedirectUrl,
|
|
270
|
+
clientName: typeof obj.clientName === "string" ? obj.clientName : void 0,
|
|
271
|
+
scopes: obj.scopes,
|
|
272
|
+
clientId: typeof obj.clientId === "string" ? obj.clientId : void 0,
|
|
273
|
+
clientSecret: typeof obj.clientSecret === "string" ? obj.clientSecret : void 0
|
|
274
|
+
} };
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Merge configs: claude (lowest priority) < global < project (highest).
|
|
278
|
+
* Later configs override earlier by server name.
|
|
279
|
+
* Skipped entries are accumulated, but if a higher-priority config provides
|
|
280
|
+
* a valid entry for a skipped name, the skip is removed.
|
|
281
|
+
*/
|
|
282
|
+
function mergeConfigs(...configs) {
|
|
283
|
+
const merged = {};
|
|
284
|
+
const allSkipped = [];
|
|
285
|
+
for (const config of configs) {
|
|
286
|
+
if (config.mcpServers) for (const [name, server] of Object.entries(config.mcpServers)) merged[name] = server;
|
|
287
|
+
if (config.skippedServers) allSkipped.push(...config.skippedServers);
|
|
288
|
+
}
|
|
289
|
+
const validNames = new Set(Object.keys(merged));
|
|
290
|
+
const filteredSkipped = allSkipped.filter((s) => !validNames.has(s.name));
|
|
291
|
+
const skippedMap = /* @__PURE__ */ new Map();
|
|
292
|
+
for (const s of filteredSkipped) skippedMap.set(s.name, s);
|
|
293
|
+
const result = {};
|
|
294
|
+
if (Object.keys(merged).length > 0) result.mcpServers = merged;
|
|
295
|
+
if (skippedMap.size > 0) result.skippedServers = Array.from(skippedMap.values());
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
export { DEFAULT_OAUTH_REDIRECT_URL, classifyServerEntry, expandEnvVars, getClaudeGlobalMcpPath, getClaudeSettingsPath, getCodexGlobalMcpPath, getGlobalMcpPath, getProjectMcpPath, getRootMcpPath, loadMcpConfig, resolveOAuthRedirectUrl, validateConfig };
|
|
300
|
+
|
|
301
|
+
//# sourceMappingURL=config.js.map
|