@oh-my-pi/pi-coding-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1629 -0
- package/README.md +1041 -0
- package/docs/compaction.md +403 -0
- package/docs/config-usage.md +113 -0
- package/docs/custom-tools.md +541 -0
- package/docs/extension-loading.md +1004 -0
- package/docs/hooks.md +867 -0
- package/docs/rpc.md +1040 -0
- package/docs/sdk.md +994 -0
- package/docs/session-tree-plan.md +441 -0
- package/docs/session.md +240 -0
- package/docs/skills.md +290 -0
- package/docs/theme.md +670 -0
- package/docs/tree.md +197 -0
- package/docs/tui.md +341 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +124 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/custom-tools/question/index.ts +84 -0
- package/examples/custom-tools/subagent/README.md +172 -0
- package/examples/custom-tools/subagent/agents/planner.md +37 -0
- package/examples/custom-tools/subagent/agents/scout.md +50 -0
- package/examples/custom-tools/subagent/agents/worker.md +24 -0
- package/examples/custom-tools/subagent/agents.ts +156 -0
- package/examples/custom-tools/subagent/commands/implement-and-review.md +10 -0
- package/examples/custom-tools/subagent/commands/implement.md +10 -0
- package/examples/custom-tools/subagent/commands/scout-and-plan.md +9 -0
- package/examples/custom-tools/subagent/index.ts +1002 -0
- package/examples/custom-tools/todo/index.ts +212 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +49 -0
- package/examples/hooks/confirm-destructive.ts +59 -0
- package/examples/hooks/custom-compaction.ts +116 -0
- package/examples/hooks/dirty-repo-guard.ts +52 -0
- package/examples/hooks/file-trigger.ts +41 -0
- package/examples/hooks/git-checkpoint.ts +53 -0
- package/examples/hooks/handoff.ts +150 -0
- package/examples/hooks/permission-gate.ts +34 -0
- package/examples/hooks/protected-paths.ts +30 -0
- package/examples/hooks/qna.ts +119 -0
- package/examples/hooks/snake.ts +343 -0
- package/examples/hooks/status-line.ts +40 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +44 -0
- package/examples/sdk/04-skills.ts +44 -0
- package/examples/sdk/05-tools.ts +90 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +36 -0
- package/examples/sdk/08-slash-commands.ts +42 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +55 -0
- package/examples/sdk/10-settings.ts +38 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +95 -0
- package/examples/sdk/README.md +154 -0
- package/package.json +89 -0
- package/src/bun-imports.d.ts +16 -0
- package/src/capability/context-file.ts +40 -0
- package/src/capability/extension.ts +48 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +616 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +52 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +56 -0
- package/src/capability/settings.ts +35 -0
- package/src/capability/skill.ts +49 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/system-prompt.ts +35 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +166 -0
- package/src/cli/args.ts +259 -0
- package/src/cli/file-processor.ts +121 -0
- package/src/cli/list-models.ts +104 -0
- package/src/cli/plugin-cli.ts +661 -0
- package/src/cli/session-picker.ts +41 -0
- package/src/cli/update-cli.ts +274 -0
- package/src/cli.ts +10 -0
- package/src/config.ts +391 -0
- package/src/core/agent-session.ts +2178 -0
- package/src/core/auth-storage.ts +258 -0
- package/src/core/bash-executor.ts +197 -0
- package/src/core/compaction/branch-summarization.ts +315 -0
- package/src/core/compaction/compaction.ts +664 -0
- package/src/core/compaction/index.ts +7 -0
- package/src/core/compaction/utils.ts +153 -0
- package/src/core/custom-commands/bundled/review/index.ts +156 -0
- package/src/core/custom-commands/index.ts +15 -0
- package/src/core/custom-commands/loader.ts +226 -0
- package/src/core/custom-commands/types.ts +112 -0
- package/src/core/custom-tools/index.ts +22 -0
- package/src/core/custom-tools/loader.ts +248 -0
- package/src/core/custom-tools/types.ts +185 -0
- package/src/core/custom-tools/wrapper.ts +29 -0
- package/src/core/exec.ts +139 -0
- package/src/core/export-html/index.ts +159 -0
- package/src/core/export-html/template.css +774 -0
- package/src/core/export-html/template.generated.ts +2 -0
- package/src/core/export-html/template.html +45 -0
- package/src/core/export-html/template.js +1185 -0
- package/src/core/export-html/template.macro.ts +24 -0
- package/src/core/file-mentions.ts +54 -0
- package/src/core/hooks/index.ts +16 -0
- package/src/core/hooks/loader.ts +288 -0
- package/src/core/hooks/runner.ts +434 -0
- package/src/core/hooks/tool-wrapper.ts +98 -0
- package/src/core/hooks/types.ts +770 -0
- package/src/core/index.ts +53 -0
- package/src/core/logger.ts +112 -0
- package/src/core/mcp/client.ts +185 -0
- package/src/core/mcp/config.ts +248 -0
- package/src/core/mcp/index.ts +45 -0
- package/src/core/mcp/loader.ts +99 -0
- package/src/core/mcp/manager.ts +235 -0
- package/src/core/mcp/tool-bridge.ts +156 -0
- package/src/core/mcp/transports/http.ts +316 -0
- package/src/core/mcp/transports/index.ts +6 -0
- package/src/core/mcp/transports/stdio.ts +252 -0
- package/src/core/mcp/types.ts +228 -0
- package/src/core/messages.ts +211 -0
- package/src/core/model-registry.ts +334 -0
- package/src/core/model-resolver.ts +494 -0
- package/src/core/plugins/doctor.ts +67 -0
- package/src/core/plugins/index.ts +38 -0
- package/src/core/plugins/installer.ts +189 -0
- package/src/core/plugins/loader.ts +339 -0
- package/src/core/plugins/manager.ts +672 -0
- package/src/core/plugins/parser.ts +105 -0
- package/src/core/plugins/paths.ts +37 -0
- package/src/core/plugins/types.ts +190 -0
- package/src/core/sdk.ts +900 -0
- package/src/core/session-manager.ts +1837 -0
- package/src/core/settings-manager.ts +860 -0
- package/src/core/skills.ts +352 -0
- package/src/core/slash-commands.ts +132 -0
- package/src/core/system-prompt.ts +442 -0
- package/src/core/timings.ts +25 -0
- package/src/core/title-generator.ts +110 -0
- package/src/core/tools/ask.ts +193 -0
- package/src/core/tools/bash-interceptor.ts +120 -0
- package/src/core/tools/bash.ts +91 -0
- package/src/core/tools/context.ts +32 -0
- package/src/core/tools/edit-diff.ts +487 -0
- package/src/core/tools/edit.ts +140 -0
- package/src/core/tools/exa/company.ts +59 -0
- package/src/core/tools/exa/index.ts +63 -0
- package/src/core/tools/exa/linkedin.ts +59 -0
- package/src/core/tools/exa/mcp-client.ts +368 -0
- package/src/core/tools/exa/render.ts +200 -0
- package/src/core/tools/exa/researcher.ts +90 -0
- package/src/core/tools/exa/search.ts +338 -0
- package/src/core/tools/exa/types.ts +167 -0
- package/src/core/tools/exa/websets.ts +248 -0
- package/src/core/tools/find.ts +244 -0
- package/src/core/tools/grep.ts +584 -0
- package/src/core/tools/index.ts +283 -0
- package/src/core/tools/ls.ts +142 -0
- package/src/core/tools/lsp/client.ts +767 -0
- package/src/core/tools/lsp/clients/biome-client.ts +207 -0
- package/src/core/tools/lsp/clients/index.ts +49 -0
- package/src/core/tools/lsp/clients/lsp-linter-client.ts +98 -0
- package/src/core/tools/lsp/config.ts +845 -0
- package/src/core/tools/lsp/edits.ts +110 -0
- package/src/core/tools/lsp/index.ts +1364 -0
- package/src/core/tools/lsp/render.ts +560 -0
- package/src/core/tools/lsp/rust-analyzer.ts +145 -0
- package/src/core/tools/lsp/types.ts +495 -0
- package/src/core/tools/lsp/utils.ts +526 -0
- package/src/core/tools/notebook.ts +182 -0
- package/src/core/tools/output.ts +198 -0
- package/src/core/tools/path-utils.ts +61 -0
- package/src/core/tools/read.ts +507 -0
- package/src/core/tools/renderers.ts +820 -0
- package/src/core/tools/review.ts +275 -0
- package/src/core/tools/rulebook.ts +124 -0
- package/src/core/tools/task/agents.ts +158 -0
- package/src/core/tools/task/artifacts.ts +114 -0
- package/src/core/tools/task/commands.ts +157 -0
- package/src/core/tools/task/discovery.ts +217 -0
- package/src/core/tools/task/executor.ts +531 -0
- package/src/core/tools/task/index.ts +548 -0
- package/src/core/tools/task/model-resolver.ts +176 -0
- package/src/core/tools/task/parallel.ts +38 -0
- package/src/core/tools/task/render.ts +502 -0
- package/src/core/tools/task/subprocess-tool-registry.ts +89 -0
- package/src/core/tools/task/types.ts +142 -0
- package/src/core/tools/truncate.ts +265 -0
- package/src/core/tools/web-fetch.ts +2511 -0
- package/src/core/tools/web-search/auth.ts +199 -0
- package/src/core/tools/web-search/index.ts +583 -0
- package/src/core/tools/web-search/providers/anthropic.ts +198 -0
- package/src/core/tools/web-search/providers/exa.ts +196 -0
- package/src/core/tools/web-search/providers/perplexity.ts +195 -0
- package/src/core/tools/web-search/render.ts +372 -0
- package/src/core/tools/web-search/types.ts +180 -0
- package/src/core/tools/write.ts +63 -0
- package/src/core/ttsr.ts +211 -0
- package/src/core/utils.ts +187 -0
- package/src/discovery/agents-md.ts +75 -0
- package/src/discovery/builtin.ts +647 -0
- package/src/discovery/claude.ts +623 -0
- package/src/discovery/cline.ts +104 -0
- package/src/discovery/codex.ts +571 -0
- package/src/discovery/cursor.ts +266 -0
- package/src/discovery/gemini.ts +368 -0
- package/src/discovery/github.ts +120 -0
- package/src/discovery/helpers.test.ts +127 -0
- package/src/discovery/helpers.ts +249 -0
- package/src/discovery/index.ts +84 -0
- package/src/discovery/mcp-json.ts +127 -0
- package/src/discovery/vscode.ts +99 -0
- package/src/discovery/windsurf.ts +219 -0
- package/src/index.ts +192 -0
- package/src/main.ts +507 -0
- package/src/migrations.ts +156 -0
- package/src/modes/cleanup.ts +23 -0
- package/src/modes/index.ts +48 -0
- package/src/modes/interactive/components/armin.ts +382 -0
- package/src/modes/interactive/components/assistant-message.ts +86 -0
- package/src/modes/interactive/components/bash-execution.ts +199 -0
- package/src/modes/interactive/components/bordered-loader.ts +41 -0
- package/src/modes/interactive/components/branch-summary-message.ts +42 -0
- package/src/modes/interactive/components/compaction-summary-message.ts +45 -0
- package/src/modes/interactive/components/custom-editor.ts +122 -0
- package/src/modes/interactive/components/diff.ts +147 -0
- package/src/modes/interactive/components/dynamic-border.ts +25 -0
- package/src/modes/interactive/components/extensions/extension-dashboard.ts +296 -0
- package/src/modes/interactive/components/extensions/extension-list.ts +479 -0
- package/src/modes/interactive/components/extensions/index.ts +9 -0
- package/src/modes/interactive/components/extensions/inspector-panel.ts +313 -0
- package/src/modes/interactive/components/extensions/state-manager.ts +558 -0
- package/src/modes/interactive/components/extensions/types.ts +191 -0
- package/src/modes/interactive/components/hook-editor.ts +117 -0
- package/src/modes/interactive/components/hook-input.ts +64 -0
- package/src/modes/interactive/components/hook-message.ts +96 -0
- package/src/modes/interactive/components/hook-selector.ts +91 -0
- package/src/modes/interactive/components/model-selector.ts +560 -0
- package/src/modes/interactive/components/oauth-selector.ts +136 -0
- package/src/modes/interactive/components/plugin-settings.ts +481 -0
- package/src/modes/interactive/components/queue-mode-selector.ts +56 -0
- package/src/modes/interactive/components/session-selector.ts +220 -0
- package/src/modes/interactive/components/settings-defs.ts +597 -0
- package/src/modes/interactive/components/settings-selector.ts +545 -0
- package/src/modes/interactive/components/show-images-selector.ts +45 -0
- package/src/modes/interactive/components/status-line/index.ts +4 -0
- package/src/modes/interactive/components/status-line/presets.ts +94 -0
- package/src/modes/interactive/components/status-line/segments.ts +350 -0
- package/src/modes/interactive/components/status-line/separators.ts +55 -0
- package/src/modes/interactive/components/status-line/types.ts +81 -0
- package/src/modes/interactive/components/status-line-segment-editor.ts +357 -0
- package/src/modes/interactive/components/status-line.ts +384 -0
- package/src/modes/interactive/components/theme-selector.ts +62 -0
- package/src/modes/interactive/components/thinking-selector.ts +64 -0
- package/src/modes/interactive/components/tool-execution.ts +946 -0
- package/src/modes/interactive/components/tree-selector.ts +877 -0
- package/src/modes/interactive/components/ttsr-notification.ts +82 -0
- package/src/modes/interactive/components/user-message-selector.ts +159 -0
- package/src/modes/interactive/components/user-message.ts +18 -0
- package/src/modes/interactive/components/visual-truncate.ts +50 -0
- package/src/modes/interactive/components/welcome.ts +228 -0
- package/src/modes/interactive/interactive-mode.ts +2669 -0
- package/src/modes/interactive/theme/dark.json +102 -0
- package/src/modes/interactive/theme/defaults/dark-arctic.json +111 -0
- package/src/modes/interactive/theme/defaults/dark-catppuccin.json +106 -0
- package/src/modes/interactive/theme/defaults/dark-cyberpunk.json +109 -0
- package/src/modes/interactive/theme/defaults/dark-dracula.json +105 -0
- package/src/modes/interactive/theme/defaults/dark-forest.json +103 -0
- package/src/modes/interactive/theme/defaults/dark-github.json +112 -0
- package/src/modes/interactive/theme/defaults/dark-gruvbox.json +119 -0
- package/src/modes/interactive/theme/defaults/dark-monochrome.json +101 -0
- package/src/modes/interactive/theme/defaults/dark-monokai.json +105 -0
- package/src/modes/interactive/theme/defaults/dark-nord.json +104 -0
- package/src/modes/interactive/theme/defaults/dark-ocean.json +108 -0
- package/src/modes/interactive/theme/defaults/dark-one.json +107 -0
- package/src/modes/interactive/theme/defaults/dark-retro.json +99 -0
- package/src/modes/interactive/theme/defaults/dark-rose-pine.json +95 -0
- package/src/modes/interactive/theme/defaults/dark-solarized.json +96 -0
- package/src/modes/interactive/theme/defaults/dark-sunset.json +106 -0
- package/src/modes/interactive/theme/defaults/dark-synthwave.json +102 -0
- package/src/modes/interactive/theme/defaults/dark-tokyo-night.json +108 -0
- package/src/modes/interactive/theme/defaults/index.ts +67 -0
- package/src/modes/interactive/theme/defaults/light-arctic.json +106 -0
- package/src/modes/interactive/theme/defaults/light-catppuccin.json +105 -0
- package/src/modes/interactive/theme/defaults/light-cyberpunk.json +103 -0
- package/src/modes/interactive/theme/defaults/light-forest.json +107 -0
- package/src/modes/interactive/theme/defaults/light-github.json +114 -0
- package/src/modes/interactive/theme/defaults/light-gruvbox.json +115 -0
- package/src/modes/interactive/theme/defaults/light-monochrome.json +100 -0
- package/src/modes/interactive/theme/defaults/light-ocean.json +106 -0
- package/src/modes/interactive/theme/defaults/light-one.json +105 -0
- package/src/modes/interactive/theme/defaults/light-retro.json +105 -0
- package/src/modes/interactive/theme/defaults/light-solarized.json +101 -0
- package/src/modes/interactive/theme/defaults/light-sunset.json +106 -0
- package/src/modes/interactive/theme/defaults/light-synthwave.json +105 -0
- package/src/modes/interactive/theme/defaults/light-tokyo-night.json +118 -0
- package/src/modes/interactive/theme/light.json +99 -0
- package/src/modes/interactive/theme/theme-schema.json +424 -0
- package/src/modes/interactive/theme/theme.ts +2211 -0
- package/src/modes/print-mode.ts +163 -0
- package/src/modes/rpc/rpc-client.ts +527 -0
- package/src/modes/rpc/rpc-mode.ts +494 -0
- package/src/modes/rpc/rpc-types.ts +203 -0
- package/src/prompts/architect-plan.md +10 -0
- package/src/prompts/branch-summary-preamble.md +3 -0
- package/src/prompts/branch-summary.md +28 -0
- package/src/prompts/browser.md +71 -0
- package/src/prompts/compaction-summary.md +34 -0
- package/src/prompts/compaction-turn-prefix.md +16 -0
- package/src/prompts/compaction-update-summary.md +41 -0
- package/src/prompts/explore.md +82 -0
- package/src/prompts/implement-with-critic.md +11 -0
- package/src/prompts/implement.md +11 -0
- package/src/prompts/init.md +30 -0
- package/src/prompts/plan.md +54 -0
- package/src/prompts/reviewer.md +81 -0
- package/src/prompts/summarization-system.md +3 -0
- package/src/prompts/system-prompt.md +27 -0
- package/src/prompts/task.md +56 -0
- package/src/prompts/title-system.md +8 -0
- package/src/prompts/tools/ask.md +24 -0
- package/src/prompts/tools/bash.md +23 -0
- package/src/prompts/tools/edit.md +9 -0
- package/src/prompts/tools/find.md +6 -0
- package/src/prompts/tools/grep.md +12 -0
- package/src/prompts/tools/lsp.md +14 -0
- package/src/prompts/tools/output.md +23 -0
- package/src/prompts/tools/read.md +25 -0
- package/src/prompts/tools/web-fetch.md +8 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +10 -0
- package/src/utils/changelog.ts +99 -0
- package/src/utils/clipboard.ts +265 -0
- package/src/utils/fuzzy.ts +108 -0
- package/src/utils/mime.ts +30 -0
- package/src/utils/shell-snapshot.ts +218 -0
- package/src/utils/shell.ts +364 -0
- package/src/utils/tools-manager.ts +265 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core modules shared between all run modes.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
AgentSession,
|
|
7
|
+
type AgentSessionConfig,
|
|
8
|
+
type AgentSessionEvent,
|
|
9
|
+
type AgentSessionEventListener,
|
|
10
|
+
type ModelCycleResult,
|
|
11
|
+
type PromptOptions,
|
|
12
|
+
type SessionStats,
|
|
13
|
+
} from "./agent-session";
|
|
14
|
+
export { type BashExecutorOptions, type BashResult, executeBash } from "./bash-executor";
|
|
15
|
+
export type { CompactionResult } from "./compaction/index";
|
|
16
|
+
export {
|
|
17
|
+
type CustomTool,
|
|
18
|
+
type CustomToolAPI,
|
|
19
|
+
type CustomToolFactory,
|
|
20
|
+
type CustomToolsLoadResult,
|
|
21
|
+
type CustomToolUIContext,
|
|
22
|
+
discoverAndLoadCustomTools,
|
|
23
|
+
type ExecResult,
|
|
24
|
+
type LoadedCustomTool,
|
|
25
|
+
loadCustomTools,
|
|
26
|
+
type RenderResultOptions,
|
|
27
|
+
} from "./custom-tools/index";
|
|
28
|
+
export {
|
|
29
|
+
type HookAPI,
|
|
30
|
+
type HookContext,
|
|
31
|
+
type HookError,
|
|
32
|
+
type HookEvent,
|
|
33
|
+
type HookFactory,
|
|
34
|
+
HookRunner,
|
|
35
|
+
type HookUIContext,
|
|
36
|
+
loadHooks,
|
|
37
|
+
} from "./hooks/index";
|
|
38
|
+
export {
|
|
39
|
+
createMCPManager,
|
|
40
|
+
discoverAndLoadMCPTools,
|
|
41
|
+
loadAllMCPConfigs,
|
|
42
|
+
type MCPConfigFile,
|
|
43
|
+
type MCPLoadResult,
|
|
44
|
+
MCPManager,
|
|
45
|
+
type MCPServerConfig,
|
|
46
|
+
type MCPServerConnection,
|
|
47
|
+
type MCPToolDefinition,
|
|
48
|
+
type MCPToolDetails,
|
|
49
|
+
type MCPToolsLoadResult,
|
|
50
|
+
type MCPTransport,
|
|
51
|
+
} from "./mcp/index";
|
|
52
|
+
|
|
53
|
+
export * as utils from "./utils";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized file logger for omp.
|
|
3
|
+
*
|
|
4
|
+
* Logs to ~/.omp/logs/ with size-based rotation, supporting concurrent omp instances.
|
|
5
|
+
* Each log entry includes process.pid for traceability.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import winston from "winston";
|
|
12
|
+
import DailyRotateFile from "winston-daily-rotate-file";
|
|
13
|
+
import { CONFIG_DIR_NAME } from "../config";
|
|
14
|
+
|
|
15
|
+
/** Get the logs directory (~/.omp/logs/) */
|
|
16
|
+
function getLogsDir(): string {
|
|
17
|
+
return join(homedir(), CONFIG_DIR_NAME, "logs");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Ensure logs directory exists */
|
|
21
|
+
function ensureLogsDir(): string {
|
|
22
|
+
const logsDir = getLogsDir();
|
|
23
|
+
if (!existsSync(logsDir)) {
|
|
24
|
+
mkdirSync(logsDir, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
return logsDir;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Custom format that includes pid and flattens metadata */
|
|
30
|
+
const logFormat = winston.format.combine(
|
|
31
|
+
winston.format.timestamp({ format: "YYYY-MM-DDTHH:mm:ss.SSSZ" }),
|
|
32
|
+
winston.format.printf(({ timestamp, level, message, ...meta }) => {
|
|
33
|
+
const entry: Record<string, unknown> = {
|
|
34
|
+
timestamp,
|
|
35
|
+
level,
|
|
36
|
+
pid: process.pid,
|
|
37
|
+
message,
|
|
38
|
+
};
|
|
39
|
+
// Flatten metadata into entry
|
|
40
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
41
|
+
if (key !== "level" && key !== "timestamp" && key !== "message") {
|
|
42
|
+
entry[key] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return JSON.stringify(entry);
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
/** Size-based rotating file transport */
|
|
50
|
+
const fileTransport = new DailyRotateFile({
|
|
51
|
+
dirname: ensureLogsDir(),
|
|
52
|
+
filename: "omp.%DATE%.log",
|
|
53
|
+
datePattern: "YYYY-MM-DD",
|
|
54
|
+
maxSize: "10m",
|
|
55
|
+
maxFiles: 5,
|
|
56
|
+
zippedArchive: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/** The winston logger instance */
|
|
60
|
+
const winstonLogger = winston.createLogger({
|
|
61
|
+
level: "debug",
|
|
62
|
+
format: logFormat,
|
|
63
|
+
transports: [fileTransport],
|
|
64
|
+
// Don't exit on error - logging failures shouldn't crash the app
|
|
65
|
+
exitOnError: false,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/** Logger type exposed to plugins and internal code */
|
|
69
|
+
export interface Logger {
|
|
70
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
71
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
72
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Centralized logger for omp.
|
|
77
|
+
*
|
|
78
|
+
* Logs to ~/.omp/logs/omp.YYYY-MM-DD.log with size-based rotation.
|
|
79
|
+
* Safe for concurrent access from multiple omp instances.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import { logger } from "../core/logger";
|
|
84
|
+
*
|
|
85
|
+
* logger.error("MCP request failed", { url, method });
|
|
86
|
+
* logger.warn("Theme file invalid, using fallback", { path });
|
|
87
|
+
* logger.debug("LSP fallback triggered", { reason });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export const logger: Logger = {
|
|
91
|
+
error(message: string, context?: Record<string, unknown>): void {
|
|
92
|
+
try {
|
|
93
|
+
winstonLogger.error(message, context);
|
|
94
|
+
} catch {
|
|
95
|
+
// Silently ignore logging failures
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
warn(message: string, context?: Record<string, unknown>): void {
|
|
99
|
+
try {
|
|
100
|
+
winstonLogger.warn(message, context);
|
|
101
|
+
} catch {
|
|
102
|
+
// Silently ignore logging failures
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
debug(message: string, context?: Record<string, unknown>): void {
|
|
106
|
+
try {
|
|
107
|
+
winstonLogger.debug(message, context);
|
|
108
|
+
} catch {
|
|
109
|
+
// Silently ignore logging failures
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client.
|
|
3
|
+
*
|
|
4
|
+
* Handles connection initialization, tool listing, and tool calling.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createHttpTransport } from "./transports/http";
|
|
8
|
+
import { createStdioTransport } from "./transports/stdio";
|
|
9
|
+
import type {
|
|
10
|
+
MCPHttpServerConfig,
|
|
11
|
+
MCPInitializeParams,
|
|
12
|
+
MCPInitializeResult,
|
|
13
|
+
MCPServerCapabilities,
|
|
14
|
+
MCPServerConfig,
|
|
15
|
+
MCPServerConnection,
|
|
16
|
+
MCPSseServerConfig,
|
|
17
|
+
MCPStdioServerConfig,
|
|
18
|
+
MCPToolCallParams,
|
|
19
|
+
MCPToolCallResult,
|
|
20
|
+
MCPToolDefinition,
|
|
21
|
+
MCPToolsListResult,
|
|
22
|
+
MCPTransport,
|
|
23
|
+
} from "./types";
|
|
24
|
+
|
|
25
|
+
/** MCP protocol version we support */
|
|
26
|
+
const PROTOCOL_VERSION = "2025-03-26";
|
|
27
|
+
|
|
28
|
+
/** Default connection timeout in ms */
|
|
29
|
+
const CONNECTION_TIMEOUT_MS = 30_000;
|
|
30
|
+
|
|
31
|
+
/** Client info sent during initialization */
|
|
32
|
+
const CLIENT_INFO = {
|
|
33
|
+
name: "omp-coding-agent",
|
|
34
|
+
version: "1.0.0",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Wrap a promise with a timeout */
|
|
38
|
+
function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promise<T> {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const timer = setTimeout(() => reject(new Error(message)), ms);
|
|
41
|
+
promise.then(
|
|
42
|
+
(value) => {
|
|
43
|
+
clearTimeout(timer);
|
|
44
|
+
resolve(value);
|
|
45
|
+
},
|
|
46
|
+
(error) => {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
reject(error);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Create a transport for the given server config.
|
|
56
|
+
*/
|
|
57
|
+
async function createTransport(config: MCPServerConfig): Promise<MCPTransport> {
|
|
58
|
+
const serverType = config.type ?? "stdio";
|
|
59
|
+
|
|
60
|
+
switch (serverType) {
|
|
61
|
+
case "stdio":
|
|
62
|
+
return createStdioTransport(config as MCPStdioServerConfig);
|
|
63
|
+
case "http":
|
|
64
|
+
case "sse":
|
|
65
|
+
return createHttpTransport(config as MCPHttpServerConfig | MCPSseServerConfig);
|
|
66
|
+
default:
|
|
67
|
+
throw new Error(`Unknown server type: ${serverType}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Initialize connection with MCP server.
|
|
73
|
+
*/
|
|
74
|
+
async function initializeConnection(transport: MCPTransport): Promise<MCPInitializeResult> {
|
|
75
|
+
const params: MCPInitializeParams = {
|
|
76
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
77
|
+
capabilities: {
|
|
78
|
+
roots: { listChanged: false },
|
|
79
|
+
},
|
|
80
|
+
clientInfo: CLIENT_INFO,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const result = await transport.request<MCPInitializeResult>(
|
|
84
|
+
"initialize",
|
|
85
|
+
params as unknown as Record<string, unknown>,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Send initialized notification
|
|
89
|
+
await transport.notify("notifications/initialized");
|
|
90
|
+
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Connect to an MCP server.
|
|
96
|
+
* Has a 30 second timeout to prevent blocking startup.
|
|
97
|
+
*/
|
|
98
|
+
export async function connectToServer(name: string, config: MCPServerConfig): Promise<MCPServerConnection> {
|
|
99
|
+
const timeoutMs = config.timeout ?? CONNECTION_TIMEOUT_MS;
|
|
100
|
+
|
|
101
|
+
const connect = async (): Promise<MCPServerConnection> => {
|
|
102
|
+
const transport = await createTransport(config);
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const initResult = await initializeConnection(transport);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
name,
|
|
109
|
+
config,
|
|
110
|
+
transport,
|
|
111
|
+
serverInfo: initResult.serverInfo,
|
|
112
|
+
capabilities: initResult.capabilities,
|
|
113
|
+
};
|
|
114
|
+
} catch (error) {
|
|
115
|
+
await transport.close();
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return withTimeout(connect(), timeoutMs, `Connection to MCP server "${name}" timed out after ${timeoutMs}ms`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* List tools from a connected server.
|
|
125
|
+
*/
|
|
126
|
+
export async function listTools(connection: MCPServerConnection): Promise<MCPToolDefinition[]> {
|
|
127
|
+
// Check if server supports tools
|
|
128
|
+
if (!connection.capabilities.tools) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Return cached tools if available
|
|
133
|
+
if (connection.tools) {
|
|
134
|
+
return connection.tools;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const allTools: MCPToolDefinition[] = [];
|
|
138
|
+
let cursor: string | undefined;
|
|
139
|
+
|
|
140
|
+
do {
|
|
141
|
+
const params: Record<string, unknown> = {};
|
|
142
|
+
if (cursor) {
|
|
143
|
+
params.cursor = cursor;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const result = await connection.transport.request<MCPToolsListResult>("tools/list", params);
|
|
147
|
+
allTools.push(...result.tools);
|
|
148
|
+
cursor = result.nextCursor;
|
|
149
|
+
} while (cursor);
|
|
150
|
+
|
|
151
|
+
// Cache tools
|
|
152
|
+
connection.tools = allTools;
|
|
153
|
+
|
|
154
|
+
return allTools;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Call a tool on a connected server.
|
|
159
|
+
*/
|
|
160
|
+
export async function callTool(
|
|
161
|
+
connection: MCPServerConnection,
|
|
162
|
+
toolName: string,
|
|
163
|
+
args: Record<string, unknown> = {},
|
|
164
|
+
): Promise<MCPToolCallResult> {
|
|
165
|
+
const params: MCPToolCallParams = {
|
|
166
|
+
name: toolName,
|
|
167
|
+
arguments: args,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return connection.transport.request<MCPToolCallResult>("tools/call", params as unknown as Record<string, unknown>);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Disconnect from a server.
|
|
175
|
+
*/
|
|
176
|
+
export async function disconnectServer(connection: MCPServerConnection): Promise<void> {
|
|
177
|
+
await connection.transport.close();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Check if a server supports tools.
|
|
182
|
+
*/
|
|
183
|
+
export function serverSupportsTools(capabilities: MCPServerCapabilities): boolean {
|
|
184
|
+
return capabilities.tools !== undefined;
|
|
185
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP configuration loader.
|
|
3
|
+
*
|
|
4
|
+
* Uses the capability system to load MCP servers from multiple sources.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { mcpCapability } from "../../capability/mcp";
|
|
8
|
+
import type { MCPServer } from "../../discovery";
|
|
9
|
+
import { load } from "../../discovery";
|
|
10
|
+
import type { MCPServerConfig } from "./types";
|
|
11
|
+
|
|
12
|
+
/** Options for loading MCP configs */
|
|
13
|
+
export interface LoadMCPConfigsOptions {
|
|
14
|
+
/** Whether to load project-level config (default: true) */
|
|
15
|
+
enableProjectConfig?: boolean;
|
|
16
|
+
/** Whether to filter out Exa MCP servers (default: true) */
|
|
17
|
+
filterExa?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Result of loading MCP configs */
|
|
21
|
+
export interface LoadMCPConfigsResult {
|
|
22
|
+
/** Loaded server configs */
|
|
23
|
+
configs: Record<string, MCPServerConfig>;
|
|
24
|
+
/** Extracted Exa API keys (if any were filtered) */
|
|
25
|
+
exaApiKeys: string[];
|
|
26
|
+
/** Source metadata for each server */
|
|
27
|
+
sources: Record<string, import("../../capability/types").SourceMeta>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Convert canonical MCPServer to legacy MCPServerConfig.
|
|
32
|
+
*/
|
|
33
|
+
function convertToLegacyConfig(server: MCPServer): MCPServerConfig {
|
|
34
|
+
// Determine transport type
|
|
35
|
+
const transport = server.transport ?? (server.command ? "stdio" : server.url ? "http" : "stdio");
|
|
36
|
+
|
|
37
|
+
if (transport === "stdio") {
|
|
38
|
+
const config: MCPServerConfig = {
|
|
39
|
+
type: "stdio" as const,
|
|
40
|
+
command: server.command ?? "",
|
|
41
|
+
};
|
|
42
|
+
if (server.args) config.args = server.args;
|
|
43
|
+
if (server.env) config.env = server.env;
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (transport === "http") {
|
|
48
|
+
const config: MCPServerConfig = {
|
|
49
|
+
type: "http" as const,
|
|
50
|
+
url: server.url ?? "",
|
|
51
|
+
};
|
|
52
|
+
if (server.headers) config.headers = server.headers;
|
|
53
|
+
return config;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (transport === "sse") {
|
|
57
|
+
const config: MCPServerConfig = {
|
|
58
|
+
type: "sse" as const,
|
|
59
|
+
url: server.url ?? "",
|
|
60
|
+
};
|
|
61
|
+
if (server.headers) config.headers = server.headers;
|
|
62
|
+
return config;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Fallback to stdio
|
|
66
|
+
return {
|
|
67
|
+
type: "stdio" as const,
|
|
68
|
+
command: server.command ?? "",
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Load all MCP server configs from standard locations.
|
|
74
|
+
* Uses the capability system for multi-source discovery.
|
|
75
|
+
*
|
|
76
|
+
* @param cwd Working directory (project root)
|
|
77
|
+
* @param options Load options
|
|
78
|
+
*/
|
|
79
|
+
export async function loadAllMCPConfigs(cwd: string, options?: LoadMCPConfigsOptions): Promise<LoadMCPConfigsResult> {
|
|
80
|
+
const enableProjectConfig = options?.enableProjectConfig ?? true;
|
|
81
|
+
const filterExa = options?.filterExa ?? true;
|
|
82
|
+
|
|
83
|
+
// Load MCP servers via capability system
|
|
84
|
+
const result = await load<MCPServer>(mcpCapability.id, { cwd });
|
|
85
|
+
|
|
86
|
+
// Filter out project-level configs if disabled
|
|
87
|
+
const servers = enableProjectConfig
|
|
88
|
+
? result.items
|
|
89
|
+
: result.items.filter((server) => server._source.level !== "project");
|
|
90
|
+
|
|
91
|
+
// Convert to legacy format and preserve source metadata
|
|
92
|
+
const configs: Record<string, MCPServerConfig> = {};
|
|
93
|
+
const sources: Record<string, import("../../capability/types").SourceMeta> = {};
|
|
94
|
+
for (const server of servers) {
|
|
95
|
+
configs[server.name] = convertToLegacyConfig(server);
|
|
96
|
+
sources[server.name] = server._source;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const exaApiKeys: string[] = [];
|
|
100
|
+
|
|
101
|
+
if (filterExa) {
|
|
102
|
+
const filterResult = filterExaMCPServers(configs, sources);
|
|
103
|
+
return { configs: filterResult.configs, exaApiKeys: filterResult.exaApiKeys, sources: filterResult.sources };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return { configs, exaApiKeys, sources };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Pattern to match Exa MCP servers */
|
|
110
|
+
const EXA_MCP_URL_PATTERN = /mcp\.exa\.ai/i;
|
|
111
|
+
const EXA_API_KEY_PATTERN = /exaApiKey=([^&\s]+)/i;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Check if a server config is an Exa MCP server.
|
|
115
|
+
*/
|
|
116
|
+
export function isExaMCPServer(name: string, config: MCPServerConfig): boolean {
|
|
117
|
+
// Check by server name
|
|
118
|
+
if (name.toLowerCase() === "exa") {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Check by URL for HTTP/SSE servers
|
|
123
|
+
if (config.type === "http" || config.type === "sse") {
|
|
124
|
+
const httpConfig = config as { url?: string };
|
|
125
|
+
if (httpConfig.url && EXA_MCP_URL_PATTERN.test(httpConfig.url)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Check by args for stdio servers (e.g., mcp-remote to exa)
|
|
131
|
+
if (!config.type || config.type === "stdio") {
|
|
132
|
+
const stdioConfig = config as { args?: string[] };
|
|
133
|
+
if (stdioConfig.args?.some((arg) => EXA_MCP_URL_PATTERN.test(arg))) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Extract Exa API key from an MCP server config.
|
|
143
|
+
*/
|
|
144
|
+
export function extractExaApiKey(config: MCPServerConfig): string | undefined {
|
|
145
|
+
// Check URL for HTTP/SSE servers
|
|
146
|
+
if (config.type === "http" || config.type === "sse") {
|
|
147
|
+
const httpConfig = config as { url?: string };
|
|
148
|
+
if (httpConfig.url) {
|
|
149
|
+
const match = EXA_API_KEY_PATTERN.exec(httpConfig.url);
|
|
150
|
+
if (match) return match[1];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Check args for stdio servers
|
|
155
|
+
if (!config.type || config.type === "stdio") {
|
|
156
|
+
const stdioConfig = config as { args?: string[] };
|
|
157
|
+
if (stdioConfig.args) {
|
|
158
|
+
for (const arg of stdioConfig.args) {
|
|
159
|
+
const match = EXA_API_KEY_PATTERN.exec(arg);
|
|
160
|
+
if (match) return match[1];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Check env vars
|
|
166
|
+
if ("env" in config && config.env) {
|
|
167
|
+
const envConfig = config as { env: Record<string, string> };
|
|
168
|
+
if (envConfig.env.EXA_API_KEY) {
|
|
169
|
+
return envConfig.env.EXA_API_KEY;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Result of filtering Exa MCP servers */
|
|
177
|
+
export interface ExaFilterResult {
|
|
178
|
+
/** Configs with Exa servers removed */
|
|
179
|
+
configs: Record<string, MCPServerConfig>;
|
|
180
|
+
/** Extracted Exa API keys (if any) */
|
|
181
|
+
exaApiKeys: string[];
|
|
182
|
+
/** Source metadata for remaining servers */
|
|
183
|
+
sources: Record<string, import("../../capability/types").SourceMeta>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Filter out Exa MCP servers and extract their API keys.
|
|
188
|
+
* Since we have native Exa integration, we don't need the MCP server.
|
|
189
|
+
*/
|
|
190
|
+
export function filterExaMCPServers(
|
|
191
|
+
configs: Record<string, MCPServerConfig>,
|
|
192
|
+
sources: Record<string, import("../../capability/types").SourceMeta>,
|
|
193
|
+
): ExaFilterResult {
|
|
194
|
+
const filtered: Record<string, MCPServerConfig> = {};
|
|
195
|
+
const filteredSources: Record<string, import("../../capability/types").SourceMeta> = {};
|
|
196
|
+
const exaApiKeys: string[] = [];
|
|
197
|
+
|
|
198
|
+
for (const [name, config] of Object.entries(configs)) {
|
|
199
|
+
if (isExaMCPServer(name, config)) {
|
|
200
|
+
// Extract API key before filtering
|
|
201
|
+
const apiKey = extractExaApiKey(config);
|
|
202
|
+
if (apiKey) {
|
|
203
|
+
exaApiKeys.push(apiKey);
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
filtered[name] = config;
|
|
207
|
+
if (sources[name]) {
|
|
208
|
+
filteredSources[name] = sources[name];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return { configs: filtered, exaApiKeys, sources: filteredSources };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Validate server config has required fields.
|
|
218
|
+
*/
|
|
219
|
+
export function validateServerConfig(name: string, config: MCPServerConfig): string[] {
|
|
220
|
+
const errors: string[] = [];
|
|
221
|
+
|
|
222
|
+
const serverType = config.type ?? "stdio";
|
|
223
|
+
|
|
224
|
+
// Check for conflicting transport fields
|
|
225
|
+
const hasCommand = "command" in config && config.command;
|
|
226
|
+
const hasUrl = "url" in config && (config as { url?: string }).url;
|
|
227
|
+
if (hasCommand && hasUrl) {
|
|
228
|
+
errors.push(
|
|
229
|
+
`Server "${name}": both "command" and "url" are set - server should be either stdio (command) OR http/sse (url), not both`,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (serverType === "stdio") {
|
|
234
|
+
const stdioConfig = config as { command?: string };
|
|
235
|
+
if (!stdioConfig.command) {
|
|
236
|
+
errors.push(`Server "${name}": stdio server requires "command" field`);
|
|
237
|
+
}
|
|
238
|
+
} else if (serverType === "http" || serverType === "sse") {
|
|
239
|
+
const httpConfig = config as { url?: string };
|
|
240
|
+
if (!httpConfig.url) {
|
|
241
|
+
errors.push(`Server "${name}": ${serverType} server requires "url" field`);
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
errors.push(`Server "${name}": unknown server type "${serverType}"`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return errors;
|
|
248
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) support.
|
|
3
|
+
*
|
|
4
|
+
* Provides per-project .mcp.json configuration for connecting to
|
|
5
|
+
* MCP servers via stdio or HTTP transports.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Client
|
|
9
|
+
export { callTool, connectToServer, disconnectServer, listTools, serverSupportsTools } from "./client";
|
|
10
|
+
|
|
11
|
+
// Config
|
|
12
|
+
export type { ExaFilterResult, LoadMCPConfigsOptions, LoadMCPConfigsResult } from "./config";
|
|
13
|
+
export {
|
|
14
|
+
extractExaApiKey,
|
|
15
|
+
filterExaMCPServers,
|
|
16
|
+
isExaMCPServer,
|
|
17
|
+
loadAllMCPConfigs,
|
|
18
|
+
validateServerConfig,
|
|
19
|
+
} from "./config";
|
|
20
|
+
// Loader (for SDK integration)
|
|
21
|
+
export type { MCPToolsLoadOptions, MCPToolsLoadResult } from "./loader";
|
|
22
|
+
export { discoverAndLoadMCPTools } from "./loader";
|
|
23
|
+
// Manager
|
|
24
|
+
export type { MCPDiscoverOptions, MCPLoadResult } from "./manager";
|
|
25
|
+
export { createMCPManager, MCPManager } from "./manager";
|
|
26
|
+
// Tool bridge
|
|
27
|
+
export type { MCPToolDetails } from "./tool-bridge";
|
|
28
|
+
export { createMCPTool, createMCPToolName, createMCPTools, parseMCPToolName } from "./tool-bridge";
|
|
29
|
+
// Transports
|
|
30
|
+
export { createHttpTransport, HttpTransport } from "./transports/http";
|
|
31
|
+
export { createStdioTransport, StdioTransport } from "./transports/stdio";
|
|
32
|
+
// Types
|
|
33
|
+
export type {
|
|
34
|
+
MCPConfigFile,
|
|
35
|
+
MCPContent,
|
|
36
|
+
MCPHttpServerConfig,
|
|
37
|
+
MCPServerCapabilities,
|
|
38
|
+
MCPServerConfig,
|
|
39
|
+
MCPServerConnection,
|
|
40
|
+
MCPSseServerConfig,
|
|
41
|
+
MCPStdioServerConfig,
|
|
42
|
+
MCPToolDefinition,
|
|
43
|
+
MCPToolWithServer,
|
|
44
|
+
MCPTransport,
|
|
45
|
+
} from "./types";
|