@adhd/agent-mcp 2.0.1 → 2.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/AGENTS.md +236 -0
- package/CHANGELOG.md +115 -0
- package/LICENSE +21 -0
- package/README.md +201 -0
- package/docs/architecture-and-security.md +405 -0
- package/docs/marketing/.catalog/capabilities.md +143 -0
- package/docs/marketing/.catalog/consumer.md +111 -0
- package/docs/marketing/.catalog/distribution.md +223 -0
- package/docs/marketing/.catalog/doc-conformance.md +237 -0
- package/docs/marketing/.catalog/doc-ops.md +98 -0
- package/docs/marketing/.catalog/metrics.md +119 -0
- package/docs/marketing/.catalog/required-tooling.md +224 -0
- package/docs/marketing/.catalog/review.md +164 -0
- package/docs/provider-call-audit.md +254 -0
- package/llms.txt +133 -0
- package/package.json +30 -51
- package/src/__tests__/integration/harness.d.ts +871 -39
- package/src/__tests__/integration/harness.d.ts.map +1 -1
- package/src/__tests__/integration/harness.js +93 -87
- package/src/__tests__/integration/harness.js.map +1 -1
- package/src/__tests__/integration/scripted-provider.d.ts +1 -2
- package/src/__tests__/integration/scripted-provider.d.ts.map +1 -1
- package/src/__tests__/integration/scripted-provider.js +1 -3
- package/src/__tests__/integration/scripted-provider.js.map +1 -1
- package/src/config.d.ts +6 -69
- package/src/config.d.ts.map +1 -1
- package/src/config.js +1 -50
- package/src/config.js.map +1 -1
- package/src/db/client.d.ts +1516 -2
- package/src/db/client.d.ts.map +1 -1
- package/src/db/client.js +4 -2
- package/src/db/client.js.map +1 -1
- package/src/db/migrate-runner.d.ts +0 -28
- package/src/db/migrate-runner.d.ts.map +1 -1
- package/src/db/migrate-runner.js +0 -24
- package/src/db/migrate-runner.js.map +1 -1
- package/src/db/migrate.d.ts +0 -7
- package/src/db/migrate.d.ts.map +1 -1
- package/src/db/migrate.js +0 -7
- package/src/db/migrate.js.map +1 -1
- package/src/db/schema.d.ts +0 -1260
- package/src/db/schema.d.ts.map +1 -1
- package/src/db/schema.js +2 -179
- package/src/db/schema.js.map +1 -1
- package/src/index.d.ts +3 -42
- package/src/index.d.ts.map +1 -1
- package/src/index.js +32 -123
- package/src/index.js.map +1 -1
- package/src/logger.d.ts +0 -8
- package/src/logger.d.ts.map +1 -1
- package/src/logger.js +1 -12
- package/src/logger.js.map +1 -1
- package/src/scripts/agent-mcp-tail.d.ts +3 -0
- package/src/scripts/agent-mcp-tail.d.ts.map +1 -0
- package/src/scripts/agent-mcp-tail.js +227 -0
- package/src/scripts/agent-mcp-tail.js.map +1 -0
- package/src/server.d.ts +13 -34
- package/src/server.d.ts.map +1 -1
- package/src/server.js +234 -326
- package/src/server.js.map +1 -1
- package/src/store/agent-store.d.ts +3 -16
- package/src/store/agent-store.d.ts.map +1 -1
- package/src/store/agent-store.js +38 -41
- package/src/store/agent-store.js.map +1 -1
- package/src/streaming/chat-gateway.d.ts +17 -0
- package/src/streaming/chat-gateway.d.ts.map +1 -0
- package/src/streaming/chat-gateway.js +336 -0
- package/src/streaming/chat-gateway.js.map +1 -0
- package/src/streaming/event-bus.d.ts +4 -0
- package/src/streaming/event-bus.d.ts.map +1 -1
- package/src/streaming/event-bus.js +14 -1
- package/src/streaming/event-bus.js.map +1 -1
- package/src/streaming/sse-server.d.ts +3 -14
- package/src/streaming/sse-server.d.ts.map +1 -1
- package/src/streaming/sse-server.js +37 -37
- package/src/streaming/sse-server.js.map +1 -1
- package/src/utils/load-env.d.ts +0 -14
- package/src/utils/load-env.d.ts.map +1 -1
- package/src/utils/load-env.js +0 -18
- package/src/utils/load-env.js.map +1 -1
- package/drizzle/0000_nifty_sasquatch.sql +0 -55
- package/drizzle/0001_task_usage.sql +0 -16
- package/drizzle/0002_lumpy_silver_centurion.sql +0 -2
- package/drizzle/0003_nifty_shriek.sql +0 -2
- package/drizzle/0004_brief_shocker.sql +0 -4
- package/drizzle/0005_clear_lenny_balinger.sql +0 -25
- package/drizzle/0006_composed_prompts_cache.sql +0 -24
- package/drizzle/meta/0000_snapshot.json +0 -387
- package/drizzle/meta/0001_snapshot.json +0 -495
- package/drizzle/meta/0002_snapshot.json +0 -509
- package/drizzle/meta/0003_snapshot.json +0 -523
- package/drizzle/meta/0004_snapshot.json +0 -551
- package/drizzle/meta/0005_snapshot.json +0 -545
- package/drizzle/meta/0006_snapshot.json +0 -651
- package/drizzle/meta/_journal.json +0 -55
- package/src/clients/http-client.d.ts +0 -24
- package/src/clients/http-client.d.ts.map +0 -1
- package/src/clients/http-client.js +0 -98
- package/src/clients/http-client.js.map +0 -1
- package/src/clients/in-process.d.ts +0 -27
- package/src/clients/in-process.d.ts.map +0 -1
- package/src/clients/in-process.js +0 -37
- package/src/clients/in-process.js.map +0 -1
- package/src/clients/index.d.ts +0 -7
- package/src/clients/index.d.ts.map +0 -1
- package/src/clients/index.js +0 -5
- package/src/clients/index.js.map +0 -1
- package/src/clients/registry.d.ts +0 -54
- package/src/clients/registry.d.ts.map +0 -1
- package/src/clients/registry.js +0 -164
- package/src/clients/registry.js.map +0 -1
- package/src/clients/stdio-client.d.ts +0 -16
- package/src/clients/stdio-client.d.ts.map +0 -1
- package/src/clients/stdio-client.js +0 -97
- package/src/clients/stdio-client.js.map +0 -1
- package/src/clients/tool-naming.d.ts +0 -44
- package/src/clients/tool-naming.d.ts.map +0 -1
- package/src/clients/tool-naming.js +0 -65
- package/src/clients/tool-naming.js.map +0 -1
- package/src/clients/types.d.ts +0 -18
- package/src/clients/types.d.ts.map +0 -1
- package/src/clients/types.js +0 -2
- package/src/clients/types.js.map +0 -1
- package/src/engine/dag-engine.d.ts +0 -62
- package/src/engine/dag-engine.d.ts.map +0 -1
- package/src/engine/dag-engine.js +0 -158
- package/src/engine/dag-engine.js.map +0 -1
- package/src/engine/hooks.d.ts +0 -24
- package/src/engine/hooks.d.ts.map +0 -1
- package/src/engine/hooks.js +0 -50
- package/src/engine/hooks.js.map +0 -1
- package/src/engine/orchestrator.d.ts +0 -40
- package/src/engine/orchestrator.d.ts.map +0 -1
- package/src/engine/orchestrator.js +0 -507
- package/src/engine/orchestrator.js.map +0 -1
- package/src/engine/policy.d.ts +0 -66
- package/src/engine/policy.d.ts.map +0 -1
- package/src/engine/policy.js +0 -112
- package/src/engine/policy.js.map +0 -1
- package/src/engine/prompt-resolver.d.ts +0 -89
- package/src/engine/prompt-resolver.d.ts.map +0 -1
- package/src/engine/prompt-resolver.js +0 -96
- package/src/engine/prompt-resolver.js.map +0 -1
- package/src/engine/queue.d.ts +0 -29
- package/src/engine/queue.d.ts.map +0 -1
- package/src/engine/queue.js +0 -56
- package/src/engine/queue.js.map +0 -1
- package/src/plugins/index.d.ts +0 -2
- package/src/plugins/index.d.ts.map +0 -1
- package/src/plugins/index.js +0 -2
- package/src/plugins/index.js.map +0 -1
- package/src/plugins/loader.d.ts +0 -65
- package/src/plugins/loader.d.ts.map +0 -1
- package/src/plugins/loader.js +0 -222
- package/src/plugins/loader.js.map +0 -1
- package/src/plugins/usage-plugin.d.ts +0 -27
- package/src/plugins/usage-plugin.d.ts.map +0 -1
- package/src/plugins/usage-plugin.js +0 -148
- package/src/plugins/usage-plugin.js.map +0 -1
- package/src/providers/anthropic.d.ts +0 -13
- package/src/providers/anthropic.d.ts.map +0 -1
- package/src/providers/anthropic.js +0 -260
- package/src/providers/anthropic.js.map +0 -1
- package/src/providers/claudecli.d.ts +0 -153
- package/src/providers/claudecli.d.ts.map +0 -1
- package/src/providers/claudecli.js +0 -510
- package/src/providers/claudecli.js.map +0 -1
- package/src/providers/factory.d.ts +0 -10
- package/src/providers/factory.d.ts.map +0 -1
- package/src/providers/factory.js +0 -24
- package/src/providers/factory.js.map +0 -1
- package/src/providers/index.d.ts +0 -6
- package/src/providers/index.d.ts.map +0 -1
- package/src/providers/index.js +0 -5
- package/src/providers/index.js.map +0 -1
- package/src/providers/openai.d.ts +0 -14
- package/src/providers/openai.d.ts.map +0 -1
- package/src/providers/openai.js +0 -162
- package/src/providers/openai.js.map +0 -1
- package/src/providers/types.d.ts +0 -36
- package/src/providers/types.d.ts.map +0 -1
- package/src/providers/types.js +0 -2
- package/src/providers/types.js.map +0 -1
- package/src/store/composed-prompt-store.d.ts +0 -24
- package/src/store/composed-prompt-store.d.ts.map +0 -1
- package/src/store/composed-prompt-store.js +0 -75
- package/src/store/composed-prompt-store.js.map +0 -1
- package/src/store/index.d.ts +0 -5
- package/src/store/index.d.ts.map +0 -1
- package/src/store/index.js +0 -5
- package/src/store/index.js.map +0 -1
- package/src/store/session-store.d.ts +0 -45
- package/src/store/session-store.d.ts.map +0 -1
- package/src/store/session-store.js +0 -197
- package/src/store/session-store.js.map +0 -1
- package/src/store/task-store.d.ts +0 -55
- package/src/store/task-store.d.ts.map +0 -1
- package/src/store/task-store.js +0 -186
- package/src/store/task-store.js.map +0 -1
- package/src/tools/agent-crud.d.ts +0 -15
- package/src/tools/agent-crud.d.ts.map +0 -1
- package/src/tools/agent-crud.js +0 -32
- package/src/tools/agent-crud.js.map +0 -1
- package/src/tools/session.d.ts +0 -33
- package/src/tools/session.d.ts.map +0 -1
- package/src/tools/session.js +0 -73
- package/src/tools/session.js.map +0 -1
- package/src/tools/task.d.ts +0 -86
- package/src/tools/task.d.ts.map +0 -1
- package/src/tools/task.js +0 -406
- package/src/tools/task.js.map +0 -1
- package/src/tools/usage.d.ts +0 -60
- package/src/tools/usage.d.ts.map +0 -1
- package/src/tools/usage.js +0 -174
- package/src/tools/usage.js.map +0 -1
- package/src/types/agent.d.ts +0 -2
- package/src/types/agent.d.ts.map +0 -1
- package/src/types/agent.js +0 -3
- package/src/types/agent.js.map +0 -1
- package/src/types/execution.d.ts +0 -2
- package/src/types/execution.d.ts.map +0 -1
- package/src/types/execution.js +0 -3
- package/src/types/execution.js.map +0 -1
- package/src/types/index.d.ts +0 -2
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -2
- package/src/types/index.js.map +0 -1
- package/src/types/mcp.d.ts +0 -2
- package/src/types/mcp.d.ts.map +0 -1
- package/src/types/mcp.js +0 -3
- package/src/types/mcp.js.map +0 -1
- package/src/types/message.d.ts +0 -2
- package/src/types/message.d.ts.map +0 -1
- package/src/types/message.js +0 -3
- package/src/types/message.js.map +0 -1
- package/src/types/session.d.ts +0 -2
- package/src/types/session.d.ts.map +0 -1
- package/src/types/session.js +0 -3
- package/src/types/session.js.map +0 -1
- package/src/types/task.d.ts +0 -2
- package/src/types/task.d.ts.map +0 -1
- package/src/types/task.js +0 -3
- package/src/types/task.js.map +0 -1
- package/src/utils/ids.d.ts +0 -2
- package/src/utils/ids.d.ts.map +0 -1
- package/src/utils/ids.js +0 -5
- package/src/utils/ids.js.map +0 -1
- package/src/utils/logger.d.ts +0 -2
- package/src/utils/logger.d.ts.map +0 -1
- package/src/utils/logger.js +0 -5
- package/src/utils/logger.js.map +0 -1
- package/src/utils/timestamps.d.ts +0 -2
- package/src/utils/timestamps.d.ts.map +0 -1
- package/src/utils/timestamps.js +0 -4
- package/src/utils/timestamps.js.map +0 -1
- package/src/validation/agent.d.ts +0 -400
- package/src/validation/agent.d.ts.map +0 -1
- package/src/validation/agent.js +0 -251
- package/src/validation/agent.js.map +0 -1
- package/src/validation/agents.d.ts +0 -2
- package/src/validation/agents.d.ts.map +0 -1
- package/src/validation/agents.js +0 -3
- package/src/validation/agents.js.map +0 -1
- package/src/validation/errors.d.ts +0 -32
- package/src/validation/errors.d.ts.map +0 -1
- package/src/validation/errors.js +0 -42
- package/src/validation/errors.js.map +0 -1
- package/src/validation/execution.d.ts +0 -86
- package/src/validation/execution.d.ts.map +0 -1
- package/src/validation/execution.js +0 -28
- package/src/validation/execution.js.map +0 -1
- package/src/validation/index.d.ts +0 -9
- package/src/validation/index.d.ts.map +0 -1
- package/src/validation/index.js +0 -9
- package/src/validation/index.js.map +0 -1
- package/src/validation/mcp.d.ts +0 -42
- package/src/validation/mcp.d.ts.map +0 -1
- package/src/validation/mcp.js +0 -28
- package/src/validation/mcp.js.map +0 -1
- package/src/validation/message.d.ts +0 -43
- package/src/validation/message.d.ts.map +0 -1
- package/src/validation/message.js +0 -23
- package/src/validation/message.js.map +0 -1
- package/src/validation/session.d.ts +0 -49
- package/src/validation/session.d.ts.map +0 -1
- package/src/validation/session.js +0 -34
- package/src/validation/session.js.map +0 -1
- package/src/validation/task.d.ts +0 -146
- package/src/validation/task.d.ts.map +0 -1
- package/src/validation/task.js +0 -95
- package/src/validation/task.js.map +0 -1
- package/src/validation/tasks.d.ts +0 -2
- package/src/validation/tasks.d.ts.map +0 -1
- package/src/validation/tasks.js +0 -3
- package/src/validation/tasks.js.map +0 -1
- package/src/validation/usage.d.ts +0 -89
- package/src/validation/usage.d.ts.map +0 -1
- package/src/validation/usage.js +0 -98
- package/src/validation/usage.js.map +0 -1
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ClaudeCliProvider — drives the local `claude` CLI (Claude Code) as an LLM
|
|
3
|
-
* backend using a persistent subprocess with bidirectional stream-json I/O.
|
|
4
|
-
*
|
|
5
|
-
* Auth: uses whatever credentials Claude Code already has configured
|
|
6
|
-
* (subscription, API key, OAuth — whatever `claude auth status` shows).
|
|
7
|
-
*
|
|
8
|
-
* Flags applied on every invocation:
|
|
9
|
-
* --system-prompt Replace Claude Code's default prompt with the agent's prompt
|
|
10
|
-
* --mcp-config <tempfile> Writes the agent's mcpServers to a temp JSON file; path passed here
|
|
11
|
-
* --strict-mcp-config Ignore all other MCP configs; only load what we pass
|
|
12
|
-
* --input-format stream-json Accept NDJSON messages on stdin
|
|
13
|
-
* --output-format stream-json Emit NDJSON events on stdout
|
|
14
|
-
* --verbose Emit full event stream including tool calls and results
|
|
15
|
-
*
|
|
16
|
-
* --disallowedTools <name> (×N) — one pair per built-in not in allowedBuiltinTools.
|
|
17
|
-
* All Claude Code built-ins are blocked by default; only tools explicitly listed
|
|
18
|
-
* in the agent definition's allowedBuiltinTools field are permitted. MCP tools
|
|
19
|
-
* (from --mcp-config) are unaffected.
|
|
20
|
-
*
|
|
21
|
-
* ⚠️ --tools "" is NOT used — it disables MCP tools as well as built-ins.
|
|
22
|
-
* ⚠️ --bare is NOT used — it blocks --mcp-config from loading entirely.
|
|
23
|
-
*
|
|
24
|
-
* Agent-spec mode (config.systemPromptIsAgentSpec === true):
|
|
25
|
-
* The agent's systemPrompt is treated as a complete Claude Code agent markdown
|
|
26
|
-
* file (YAML frontmatter + body). Instead of --system-prompt + --disallowedTools,
|
|
27
|
-
* the provider writes it to an isolated temp project dir and passes
|
|
28
|
-
* --add-dir <tmpdir> --setting-sources project --agent <frontmatterName>
|
|
29
|
-
* so Claude *internally parses the frontmatter header* — including the `tools:`
|
|
30
|
-
* field — which then governs tool access and TAKES PRECEDENCE over the built-in
|
|
31
|
-
* disallow enumeration. `--agent` matches the frontmatter `name:`, not the
|
|
32
|
-
* filename; cwd is preserved so file/Bash tools keep their working root. Omit
|
|
33
|
-
* `tools:` in the header to inherit all tools; list `mcp__<server>__<tool>`
|
|
34
|
-
* entries to expose specific MCP tools. allowedBuiltinTools is ignored in this mode.
|
|
35
|
-
*
|
|
36
|
-
* Tool loop: when Claude Code emits a tool_use block, we execute it via the
|
|
37
|
-
* request.executeTool callback (wired by the orchestrator to the McpClientRegistry)
|
|
38
|
-
* and write a tool_result message back to stdin. This continues until Claude
|
|
39
|
-
* emits a "result" event, at which point chat() resolves with stopReason "completed".
|
|
40
|
-
*
|
|
41
|
-
* ⚠️ KNOWN ISSUE: Claude Code may crash with
|
|
42
|
-
* "Z is not an Object. (evaluating '"tool_use_id"in Z')"
|
|
43
|
-
* when a tool_result is written to stdin. This is a suspected Claude Code bug
|
|
44
|
-
* (github.com/anthropics/claude-code/issues/24594). If you hit this, the
|
|
45
|
-
* provider will throw PROVIDER_ERROR and the task will fail. Fall back to the
|
|
46
|
-
* anthropic provider with useClaudeOauth: true for a fully supported path.
|
|
47
|
-
*/
|
|
48
|
-
import { spawn } from "child_process";
|
|
49
|
-
import readline from "readline";
|
|
50
|
-
import { writeFile, unlink, mkdtemp, mkdir, rm } from "fs/promises";
|
|
51
|
-
import { tmpdir } from "os";
|
|
52
|
-
import { join } from "path";
|
|
53
|
-
import { generateId } from "../utils/ids.js";
|
|
54
|
-
import { nowIso } from "../utils/timestamps.js";
|
|
55
|
-
import { resolveToolCallName } from "../clients/tool-naming.js";
|
|
56
|
-
import { ToolError } from "../validation/errors.js";
|
|
57
|
-
import { logger } from "../logger.js";
|
|
58
|
-
import { config } from "../config.js";
|
|
59
|
-
// ─── history encoding (for multi-task sessions) ───────────────────────────────
|
|
60
|
-
/**
|
|
61
|
-
* Encodes prior session messages as a text block prepended to the current prompt.
|
|
62
|
-
* Only needed when the session has history from prior tasks — within a single task,
|
|
63
|
-
* Claude Code handles its own context via the stream-json tool loop.
|
|
64
|
-
*
|
|
65
|
-
* If there is only one non-system message, it is returned verbatim.
|
|
66
|
-
*/
|
|
67
|
-
function buildUserMessage(messages) {
|
|
68
|
-
const nonSystem = messages.filter(m => m.role !== "system");
|
|
69
|
-
if (nonSystem.length === 0)
|
|
70
|
-
return "";
|
|
71
|
-
if (nonSystem.length === 1)
|
|
72
|
-
return nonSystem[0].content ?? "";
|
|
73
|
-
const history = nonSystem.slice(0, -1);
|
|
74
|
-
const last = nonSystem[nonSystem.length - 1];
|
|
75
|
-
const lines = ["[Conversation history]"];
|
|
76
|
-
for (const msg of history) {
|
|
77
|
-
let label;
|
|
78
|
-
if (msg.role === "user") {
|
|
79
|
-
label = "User";
|
|
80
|
-
}
|
|
81
|
-
else if (msg.role === "assistant") {
|
|
82
|
-
label = "Assistant";
|
|
83
|
-
}
|
|
84
|
-
else if (msg.role === "tool") {
|
|
85
|
-
label = "Tool result";
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
label = "System";
|
|
89
|
-
}
|
|
90
|
-
const body = msg.content ??
|
|
91
|
-
(msg.toolCalls ? `[called tools: ${msg.toolCalls.map(tc => tc.tool).join(", ")}]` : "");
|
|
92
|
-
lines.push(`${label}: ${body}`);
|
|
93
|
-
}
|
|
94
|
-
lines.push("", "[Current message]", last.content ?? "");
|
|
95
|
-
return lines.join("\n");
|
|
96
|
-
}
|
|
97
|
-
// ─── built-in tool list ───────────────────────────────────────────────────────
|
|
98
|
-
/**
|
|
99
|
-
* Complete list of Claude Code built-in tool names (as of Claude Code 1.x).
|
|
100
|
-
*
|
|
101
|
-
* All of these are disallowed by default for claudecli agents. The permitted
|
|
102
|
-
* set is resolved from one of two sources in priority order:
|
|
103
|
-
*
|
|
104
|
-
* 1. compiledTools (AGENT_TOOL model) — the platform-alias array produced by
|
|
105
|
-
* `compileAgent({ platform: "claude_code" }).tools` via @adhd/agent-compiler.
|
|
106
|
-
* This is the strategic source of truth: each string is a `TOOL_PLATFORM_BINDING`
|
|
107
|
-
* alias for the `claude_code` platform, derived from AGENT_TOOL grants in the
|
|
108
|
-
* registry. When compiledTools is supplied to the constructor, it is used as
|
|
109
|
-
* the allowed set and config.allowedBuiltinTools is ignored.
|
|
110
|
-
*
|
|
111
|
-
* 2. config.allowedBuiltinTools — the per-agent legacy allowlist (still honoured
|
|
112
|
-
* when no compiled tool set is available, e.g. during the transition window
|
|
113
|
-
* before compiler-integration lands).
|
|
114
|
-
*
|
|
115
|
-
* [inv:no-third-tool-model] — claudecli must NOT maintain an independent third
|
|
116
|
-
* tool-permission list separate from AGENT_TOOL / compiled.tools.
|
|
117
|
-
*
|
|
118
|
-
* MCP tools (loaded via --mcp-config) are unaffected by this list.
|
|
119
|
-
*/
|
|
120
|
-
const CLAUDE_CODE_BUILTIN_TOOLS = [
|
|
121
|
-
"Bash",
|
|
122
|
-
"Edit",
|
|
123
|
-
"MultiEdit",
|
|
124
|
-
"Read",
|
|
125
|
-
"Write",
|
|
126
|
-
"Glob",
|
|
127
|
-
"Grep",
|
|
128
|
-
"LS",
|
|
129
|
-
"WebFetch",
|
|
130
|
-
"WebSearch",
|
|
131
|
-
"TodoRead",
|
|
132
|
-
"TodoWrite",
|
|
133
|
-
"NotebookRead",
|
|
134
|
-
"NotebookEdit",
|
|
135
|
-
"Task",
|
|
136
|
-
];
|
|
137
|
-
// ─── built-in arg computation (pure, testable seam) ──────────────────────────
|
|
138
|
-
/**
|
|
139
|
-
* Compute the effective allowed built-in set and the `--disallowedTools` argv
|
|
140
|
-
* entries that must be passed to the `claude` CLI subprocess.
|
|
141
|
-
*
|
|
142
|
-
* This is the single source of truth for [inv:no-third-tool-model]: the
|
|
143
|
-
* allowed set is resolved in priority order:
|
|
144
|
-
* 1. `compiledTools` (AGENT_TOOL / compile.tools model) — wins when present.
|
|
145
|
-
* 2. `config.allowedBuiltinTools` — legacy / transition-window fallback.
|
|
146
|
-
*
|
|
147
|
-
* Extracted here so tests can assert the REAL produced argv without spawning
|
|
148
|
-
* a subprocess. `chat()` must call this function; no divergence allowed.
|
|
149
|
-
*
|
|
150
|
-
* @param compiledTools - Platform-alias array from `compileAgent().tools`, or
|
|
151
|
-
* `undefined` when the compiler integration is not available yet.
|
|
152
|
-
* @param allowedBuiltinTools - Per-agent legacy allowlist from config.
|
|
153
|
-
* @returns `{ effectiveAllowed, disallowedArgv }` where `disallowedArgv` is the
|
|
154
|
-
* flat `["--disallowedTools", "<name>", ...]` fragment ready to push into args.
|
|
155
|
-
*/
|
|
156
|
-
export function computeClaudeBuiltinArgs(params) {
|
|
157
|
-
const effectiveAllowed = params.compiledTools !== undefined
|
|
158
|
-
? params.compiledTools // AGENT_TOOL / compiled.tools model wins
|
|
159
|
-
: (params.allowedBuiltinTools ?? []);
|
|
160
|
-
const allowed = new Set(effectiveAllowed);
|
|
161
|
-
const disallowed = CLAUDE_CODE_BUILTIN_TOOLS.filter(t => !allowed.has(t));
|
|
162
|
-
const disallowedArgv = [];
|
|
163
|
-
for (const tool of disallowed) {
|
|
164
|
-
disallowedArgv.push("--disallowedTools", tool);
|
|
165
|
-
}
|
|
166
|
-
return { effectiveAllowed, disallowedArgv };
|
|
167
|
-
}
|
|
168
|
-
// ─── agent-spec (markdown frontmatter) helpers ───────────────────────────────
|
|
169
|
-
/** Fallback identity used when an agent-spec prompt has no frontmatter `name:`. */
|
|
170
|
-
const FALLBACK_SPEC_AGENT_NAME = "agent-mcp-runner";
|
|
171
|
-
const FALLBACK_SPEC_DESCRIPTION = "agent-mcp delegated agent";
|
|
172
|
-
/**
|
|
173
|
-
* Extracts the `name:` field from the leading YAML frontmatter block of a Claude
|
|
174
|
-
* Code agent markdown system prompt. Only the first `---`-delimited block at the
|
|
175
|
-
* very top of the string is considered. Returns undefined when there is no leading
|
|
176
|
-
* frontmatter block or no `name:` key.
|
|
177
|
-
*
|
|
178
|
-
* Claude Code selects an agent (`--agent <name>`) by this frontmatter name — not
|
|
179
|
-
* the on-disk filename — so the provider must read it to build the correct flag.
|
|
180
|
-
*/
|
|
181
|
-
export function extractAgentSpecName(md) {
|
|
182
|
-
const block = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(md);
|
|
183
|
-
if (!block)
|
|
184
|
-
return undefined;
|
|
185
|
-
const nameLine = /^[ \t]*name:[ \t]*(.+?)[ \t]*$/m.exec(block[1]);
|
|
186
|
-
if (!nameLine)
|
|
187
|
-
return undefined;
|
|
188
|
-
return nameLine[1].replace(/^["']|["']$/g, "").trim() || undefined;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Ensures an agent-spec markdown carries a frontmatter `name:` so the subprocess
|
|
192
|
-
* can select it with `--agent`. Returns the markdown to write and the agent name
|
|
193
|
-
* to pass to `--agent`.
|
|
194
|
-
*
|
|
195
|
-
* - If the prompt already names the agent, it is used verbatim and the markdown is
|
|
196
|
-
* returned unchanged (the spec author's `tools:` header is the source of truth).
|
|
197
|
-
* - If a frontmatter block exists but lacks `name:`, a generated name is injected
|
|
198
|
-
* into it.
|
|
199
|
-
* - If there is no frontmatter at all, the prompt is wrapped in a minimal block
|
|
200
|
-
* (no `tools:` → Claude inherits all tools, matching pre-spec-mode behavior).
|
|
201
|
-
*/
|
|
202
|
-
export function normalizeAgentSpec(md) {
|
|
203
|
-
const existing = extractAgentSpecName(md);
|
|
204
|
-
if (existing)
|
|
205
|
-
return { content: md, agentName: existing };
|
|
206
|
-
const hasFrontmatter = /^\uFEFF?---[ \t]*\r?\n/.test(md);
|
|
207
|
-
if (hasFrontmatter) {
|
|
208
|
-
const content = md.replace(/^(\uFEFF?---[ \t]*\r?\n)/, `$1name: ${FALLBACK_SPEC_AGENT_NAME}\n`);
|
|
209
|
-
return { content, agentName: FALLBACK_SPEC_AGENT_NAME };
|
|
210
|
-
}
|
|
211
|
-
const content = `---\nname: ${FALLBACK_SPEC_AGENT_NAME}\n` +
|
|
212
|
-
`description: ${FALLBACK_SPEC_DESCRIPTION}\n---\n${md}`;
|
|
213
|
-
return { content, agentName: FALLBACK_SPEC_AGENT_NAME };
|
|
214
|
-
}
|
|
215
|
-
// ─── provider ────────────────────────────────────────────────────────────────
|
|
216
|
-
export class ClaudeCliProvider {
|
|
217
|
-
config;
|
|
218
|
-
mcpServers;
|
|
219
|
-
/**
|
|
220
|
-
* Platform-alias tool list derived from the AGENT_TOOL / compiled.tools model.
|
|
221
|
-
*
|
|
222
|
-
* When supplied (via `compileAgent({ platform: "claude_code" }).tools`), this
|
|
223
|
-
* array is the single source of truth for which Claude Code built-ins are
|
|
224
|
-
* permitted — config.allowedBuiltinTools is ignored. When absent, the provider
|
|
225
|
-
* falls back to config.allowedBuiltinTools (legacy / transition-window path).
|
|
226
|
-
*
|
|
227
|
-
* [inv:no-third-tool-model] — one tool-permission source, not two.
|
|
228
|
-
*/
|
|
229
|
-
compiledTools;
|
|
230
|
-
constructor(config, mcpServers = {}, compiledTools) {
|
|
231
|
-
this.config = config;
|
|
232
|
-
this.mcpServers = mcpServers;
|
|
233
|
-
this.compiledTools = compiledTools;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Build the subprocess environment for the claude CLI subprocess.
|
|
237
|
-
*
|
|
238
|
-
* Merges the live process.env (PATH, HOME, call-time vars) with the
|
|
239
|
-
* config snapshot (ADHD_AGENT_* vars loaded from the .env hierarchy at
|
|
240
|
-
* startup), with the config snapshot winning on conflicts. This ensures
|
|
241
|
-
* the subprocess inherits both the user's shell context and any overrides
|
|
242
|
-
* loaded via the .env hierarchy — and allows test-injected env vars (e.g.
|
|
243
|
-
* CAPTURE_FILE) to flow through to the subprocess without a module reload.
|
|
244
|
-
*/
|
|
245
|
-
buildSubprocessEnv() {
|
|
246
|
-
const result = {};
|
|
247
|
-
// Start with the live env for full context (PATH, HOME, etc.)
|
|
248
|
-
for (const [k, v] of Object.entries(process.env)) {
|
|
249
|
-
if (v !== undefined)
|
|
250
|
-
result[k] = v;
|
|
251
|
-
}
|
|
252
|
-
// Overlay the config snapshot so ADHD_AGENT_* values from .env files win
|
|
253
|
-
for (const [k, v] of Object.entries(config.subprocessEnv())) {
|
|
254
|
-
result[k] = v;
|
|
255
|
-
}
|
|
256
|
-
return result;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Write the agent's McpServerConfig map to a temp JSON file in the format
|
|
260
|
-
* Claude Code's --mcp-config flag expects. Inline JSON strings are not parsed
|
|
261
|
-
* by the CLI — a file path is required.
|
|
262
|
-
*
|
|
263
|
-
* Maps our `transport` field to Claude Code's `type`. The caller is responsible
|
|
264
|
-
* for deleting the file (use the finally block in chat()).
|
|
265
|
-
*
|
|
266
|
-
* Returns undefined if there are no servers to configure.
|
|
267
|
-
*/
|
|
268
|
-
async writeMcpConfigFile() {
|
|
269
|
-
const entries = Object.entries(this.mcpServers);
|
|
270
|
-
if (entries.length === 0)
|
|
271
|
-
return undefined;
|
|
272
|
-
const mapped = {};
|
|
273
|
-
for (const [name, cfg] of entries) {
|
|
274
|
-
if (cfg.transport === "stdio") {
|
|
275
|
-
const entry = {
|
|
276
|
-
type: "stdio",
|
|
277
|
-
command: cfg.command,
|
|
278
|
-
};
|
|
279
|
-
if (cfg.args?.length)
|
|
280
|
-
entry.args = cfg.args;
|
|
281
|
-
if (cfg.env && Object.keys(cfg.env).length)
|
|
282
|
-
entry.env = cfg.env;
|
|
283
|
-
mapped[name] = entry;
|
|
284
|
-
}
|
|
285
|
-
else if (cfg.transport === "http" || cfg.transport === "sse") {
|
|
286
|
-
const entry = {
|
|
287
|
-
type: cfg.transport,
|
|
288
|
-
url: cfg.url,
|
|
289
|
-
};
|
|
290
|
-
if (cfg.headers && Object.keys(cfg.headers).length)
|
|
291
|
-
entry.headers = cfg.headers;
|
|
292
|
-
mapped[name] = entry;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
const filePath = join(tmpdir(), `agent-mcp-claudecli-${Date.now()}.json`);
|
|
296
|
-
await writeFile(filePath, JSON.stringify({ mcpServers: mapped }), "utf8");
|
|
297
|
-
return filePath;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Writes an agent-spec markdown system prompt to an isolated temp project dir
|
|
301
|
-
* as `<dir>/.claude/agents/<name>.md`, so the subprocess can discover and
|
|
302
|
-
* parse it via `--add-dir <dir> --setting-sources project --agent <name>`.
|
|
303
|
-
*
|
|
304
|
-
* Returns the temp dir (for `--add-dir`) and the frontmatter agent name (for
|
|
305
|
-
* `--agent`). The caller MUST delete the dir in its finally block.
|
|
306
|
-
*/
|
|
307
|
-
async writeAgentSpecDir(md) {
|
|
308
|
-
const { content, agentName } = normalizeAgentSpec(md);
|
|
309
|
-
const dir = await mkdtemp(join(tmpdir(), "agent-mcp-spec-"));
|
|
310
|
-
const agentsDir = join(dir, ".claude", "agents");
|
|
311
|
-
await mkdir(agentsDir, { recursive: true });
|
|
312
|
-
// The filename does not affect selection (Claude matches the frontmatter
|
|
313
|
-
// name), but sanitize it so an exotic agent name can't escape the dir.
|
|
314
|
-
const safeFile = `${agentName.replace(/[^a-zA-Z0-9_-]/g, "_") || "agent"}.md`;
|
|
315
|
-
await writeFile(join(agentsDir, safeFile), content, "utf8");
|
|
316
|
-
return { dir, agentName };
|
|
317
|
-
}
|
|
318
|
-
async chat(request) {
|
|
319
|
-
const claudePath = this.config.claudePath ?? "claude";
|
|
320
|
-
const systemMessages = request.messages.filter(m => m.role === "system");
|
|
321
|
-
const systemPrompt = systemMessages.map(m => m.content ?? "").join("\n") || undefined;
|
|
322
|
-
const userMessage = buildUserMessage(request.messages);
|
|
323
|
-
// Write MCP config to a temp file.
|
|
324
|
-
// Note: --bare blocks ALL MCP loading including explicit --mcp-config, so
|
|
325
|
-
// we do NOT use --bare. CLAUDE.md will be injected but --system-prompt
|
|
326
|
-
// replaces the full default system prompt, keeping the agent's identity.
|
|
327
|
-
const mcpConfigPath = await this.writeMcpConfigFile();
|
|
328
|
-
// Agent-spec mode: the system prompt IS a Claude Code agent markdown file
|
|
329
|
-
// (frontmatter + body). We write it to a temp project dir and let Claude
|
|
330
|
-
// internally parse its `tools:` header, which then governs tool access and
|
|
331
|
-
// takes precedence over --disallowedTools. Requires a system prompt to wrap.
|
|
332
|
-
const specMode = this.config.systemPromptIsAgentSpec === true && !!systemPrompt;
|
|
333
|
-
let agentSpecDir;
|
|
334
|
-
let agentSpecName;
|
|
335
|
-
if (specMode && systemPrompt) {
|
|
336
|
-
const written = await this.writeAgentSpecDir(systemPrompt);
|
|
337
|
-
agentSpecDir = written.dir;
|
|
338
|
-
agentSpecName = written.agentName;
|
|
339
|
-
}
|
|
340
|
-
// Compute the disallowed built-in list via the extracted pure seam.
|
|
341
|
-
// Source of truth priority ([inv:no-third-tool-model]) is enforced inside
|
|
342
|
-
// computeClaudeBuiltinArgs — compiledTools wins over allowedBuiltinTools.
|
|
343
|
-
// Used only in the legacy (non-spec) path below; in spec mode the agent
|
|
344
|
-
// md `tools:` header is the single source of truth.
|
|
345
|
-
const { disallowedArgv } = computeClaudeBuiltinArgs({
|
|
346
|
-
compiledTools: this.compiledTools,
|
|
347
|
-
allowedBuiltinTools: this.config.allowedBuiltinTools,
|
|
348
|
-
});
|
|
349
|
-
const args = [
|
|
350
|
-
"-p",
|
|
351
|
-
"--dangerously-skip-permissions", // no interactive permission prompts
|
|
352
|
-
"--input-format", "stream-json",
|
|
353
|
-
"--output-format", "stream-json",
|
|
354
|
-
"--verbose",
|
|
355
|
-
];
|
|
356
|
-
if (specMode && agentSpecDir && agentSpecName) {
|
|
357
|
-
// Header-driven tools: Claude parses the agent md's frontmatter `tools:`
|
|
358
|
-
// and applies it as the authoritative allowlist. We must NOT pass
|
|
359
|
-
// --disallowedTools or --system-prompt here — the spec header is the
|
|
360
|
-
// single source of truth. --add-dir makes the temp `.claude/agents/<name>.md`
|
|
361
|
-
// discoverable; --setting-sources project loads it; --agent selects it by
|
|
362
|
-
// its frontmatter name (cwd is preserved, so file/Bash tools keep their root).
|
|
363
|
-
args.push("--add-dir", agentSpecDir, "--setting-sources", "project", "--agent", agentSpecName);
|
|
364
|
-
if (this.config.allowedBuiltinTools?.length) {
|
|
365
|
-
logger.warn({ agent: agentSpecName }, "claudecli: allowedBuiltinTools is ignored when systemPromptIsAgentSpec is set; the agent spec's `tools:` header governs tool access");
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
// Legacy denylist behavior: block every built-in the agent definition
|
|
370
|
-
// doesn't explicitly allow, via the compiledTools-aware seam
|
|
371
|
-
// ([inv:no-third-tool-model] — compiledTools wins over allowedBuiltinTools).
|
|
372
|
-
// MCP tools are unaffected — loaded via --mcp-config separately.
|
|
373
|
-
args.push(...disallowedArgv);
|
|
374
|
-
if (systemPrompt)
|
|
375
|
-
args.push("--system-prompt", systemPrompt);
|
|
376
|
-
}
|
|
377
|
-
if (this.config.model)
|
|
378
|
-
args.push("--model", this.config.model);
|
|
379
|
-
if (mcpConfigPath) {
|
|
380
|
-
// --strict-mcp-config prevents auto-discovered .mcp.json from loading
|
|
381
|
-
// alongside our explicit config (avoids double-spawning agent-mcp)
|
|
382
|
-
args.push("--mcp-config", mcpConfigPath, "--strict-mcp-config");
|
|
383
|
-
}
|
|
384
|
-
const subEnv = this.buildSubprocessEnv();
|
|
385
|
-
const proc = spawn(claudePath, args, {
|
|
386
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
387
|
-
env: subEnv,
|
|
388
|
-
});
|
|
389
|
-
const rl = readline.createInterface({
|
|
390
|
-
input: proc.stdout,
|
|
391
|
-
crlfDelay: Infinity,
|
|
392
|
-
});
|
|
393
|
-
// Kill subprocess on abort/timeout
|
|
394
|
-
const onAbort = () => { proc.kill("SIGTERM"); };
|
|
395
|
-
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
396
|
-
try {
|
|
397
|
-
// Write initial user message as first stream-json line
|
|
398
|
-
proc.stdin.write(JSON.stringify({
|
|
399
|
-
type: "user",
|
|
400
|
-
message: { role: "user", content: userMessage },
|
|
401
|
-
}) + "\n");
|
|
402
|
-
let procError;
|
|
403
|
-
proc.on("error", (err) => { procError = err; });
|
|
404
|
-
let finalResult = "";
|
|
405
|
-
for await (const line of rl) {
|
|
406
|
-
if (request.signal?.aborted) {
|
|
407
|
-
throw new Error("PROVIDER_ERROR: request aborted");
|
|
408
|
-
}
|
|
409
|
-
if (procError) {
|
|
410
|
-
throw new Error(`PROVIDER_ERROR: claude CLI error: ${procError.message}`);
|
|
411
|
-
}
|
|
412
|
-
let event;
|
|
413
|
-
try {
|
|
414
|
-
event = JSON.parse(line);
|
|
415
|
-
}
|
|
416
|
-
catch {
|
|
417
|
-
continue; // skip non-JSON lines (e.g. blank lines, debug output)
|
|
418
|
-
}
|
|
419
|
-
// ── Final result ─────────────────────────────────────────────
|
|
420
|
-
if (event.type === "result") {
|
|
421
|
-
const r = event;
|
|
422
|
-
if (r.is_error) {
|
|
423
|
-
throw new Error(`PROVIDER_ERROR: claude CLI returned error: ${r.result ?? "(no message)"}`);
|
|
424
|
-
}
|
|
425
|
-
finalResult = r.result ?? "";
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
// ── Tool calls ───────────────────────────────────────────────
|
|
429
|
-
if (event.type === "assistant") {
|
|
430
|
-
const assistantEvent = event;
|
|
431
|
-
const toolUseBlocks = (assistantEvent.message?.content ?? []).filter((b) => b.type === "tool_use");
|
|
432
|
-
for (const block of toolUseBlocks) {
|
|
433
|
-
let toolResultText;
|
|
434
|
-
let isError = false;
|
|
435
|
-
if (request.executeTool) {
|
|
436
|
-
// Claude Code prefixes MCP tool names with "mcp__":
|
|
437
|
-
// mcp__agent-mcp__task → agent-mcp__task → server=agent-mcp, tool=task
|
|
438
|
-
let qualifiedName = block.name;
|
|
439
|
-
if (qualifiedName.startsWith("mcp__")) {
|
|
440
|
-
qualifiedName = qualifiedName.slice(5);
|
|
441
|
-
}
|
|
442
|
-
try {
|
|
443
|
-
// Resolve qualified or bare names against the advertised set
|
|
444
|
-
// (a bare `task` → `agent-mcp__task` when unambiguous; DEBT-004).
|
|
445
|
-
const { server, tool } = resolveToolCallName(qualifiedName, (request.tools ?? []).map((t) => t.name));
|
|
446
|
-
const { result, isError: err } = await request.executeTool(server, tool, block.input);
|
|
447
|
-
toolResultText = typeof result === "string"
|
|
448
|
-
? result
|
|
449
|
-
: JSON.stringify(result);
|
|
450
|
-
isError = err;
|
|
451
|
-
}
|
|
452
|
-
catch (err) {
|
|
453
|
-
toolResultText = err instanceof Error ? err.message : String(err);
|
|
454
|
-
isError = true;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
toolResultText = "Tool execution not available (no executeTool callback)";
|
|
459
|
-
isError = true;
|
|
460
|
-
}
|
|
461
|
-
// ⚠️ tool_result injection — see module-level warning about
|
|
462
|
-
// the suspected Claude Code crash on this path.
|
|
463
|
-
proc.stdin.write(JSON.stringify({
|
|
464
|
-
type: "user",
|
|
465
|
-
message: {
|
|
466
|
-
role: "user",
|
|
467
|
-
content: [{
|
|
468
|
-
type: "tool_result",
|
|
469
|
-
tool_use_id: block.id,
|
|
470
|
-
content: [{ type: "text", text: toolResultText }],
|
|
471
|
-
is_error: isError,
|
|
472
|
-
}],
|
|
473
|
-
},
|
|
474
|
-
}) + "\n");
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
proc.stdin.end();
|
|
479
|
-
if (!finalResult) {
|
|
480
|
-
throw new ToolError("PROVIDER_AUTH_ERROR", "Claude CLI returned empty result. " +
|
|
481
|
-
"Ensure `claude auth status` shows a valid login. " +
|
|
482
|
-
"To use the Anthropic API instead, set ADHD_AGENT_ANTHROPIC_SECRET in your ~/.adhd/.env.");
|
|
483
|
-
}
|
|
484
|
-
const message = {
|
|
485
|
-
id: generateId(),
|
|
486
|
-
sessionId: "",
|
|
487
|
-
role: "assistant",
|
|
488
|
-
content: finalResult,
|
|
489
|
-
createdAt: nowIso(),
|
|
490
|
-
};
|
|
491
|
-
return { message, stopReason: "completed" };
|
|
492
|
-
}
|
|
493
|
-
finally {
|
|
494
|
-
request.signal?.removeEventListener("abort", onAbort);
|
|
495
|
-
rl.close();
|
|
496
|
-
if (proc.exitCode === null && !proc.killed) {
|
|
497
|
-
proc.kill("SIGTERM");
|
|
498
|
-
}
|
|
499
|
-
// Clean up the temp MCP config file
|
|
500
|
-
if (mcpConfigPath) {
|
|
501
|
-
unlink(mcpConfigPath).catch(() => { });
|
|
502
|
-
}
|
|
503
|
-
// Clean up the temp agent-spec project dir
|
|
504
|
-
if (agentSpecDir) {
|
|
505
|
-
rm(agentSpecDir, { recursive: true, force: true }).catch(() => { });
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
//# sourceMappingURL=claudecli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claudecli.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/providers/claudecli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;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,EAAE,CAAC;QAChD,CAAC;gBAAS,CAAC;YACP,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACtD,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACzC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC;YACD,oCAAoC;YACpC,IAAI,aAAa,EAAE,CAAC;gBAChB,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAqB,CAAC,CAAC,CAAC;YAC7D,CAAC;YACD,2CAA2C;YAC3C,IAAI,YAAY,EAAE,CAAC;gBACf,EAAE,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAqB,CAAC,CAAC,CAAC;YAC1F,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { McpServerConfig, ProviderConfig } from "../validation/index.js";
|
|
2
|
-
import type { LLMProvider } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates an LLM provider from a ProviderConfig discriminated union.
|
|
5
|
-
*
|
|
6
|
-
* @param mcpServers - The agent's MCP server configs. Only used by ClaudeCliProvider
|
|
7
|
-
* to build the --mcp-config inline JSON passed to the claude subprocess.
|
|
8
|
-
*/
|
|
9
|
-
export declare function createProvider(providerConfig: ProviderConfig, mcpServers?: Record<string, McpServerConfig>): LLMProvider;
|
|
10
|
-
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/providers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,cAAc,EAAE,cAAc,EAC9B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAC7C,WAAW,CAab"}
|
package/src/providers/factory.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { AnthropicProvider } from "./anthropic.js";
|
|
2
|
-
import { ClaudeCliProvider } from "./claudecli.js";
|
|
3
|
-
import { OpenAIProvider } from "./openai.js";
|
|
4
|
-
/**
|
|
5
|
-
* Creates an LLM provider from a ProviderConfig discriminated union.
|
|
6
|
-
*
|
|
7
|
-
* @param mcpServers - The agent's MCP server configs. Only used by ClaudeCliProvider
|
|
8
|
-
* to build the --mcp-config inline JSON passed to the claude subprocess.
|
|
9
|
-
*/
|
|
10
|
-
export function createProvider(providerConfig, mcpServers) {
|
|
11
|
-
switch (providerConfig.type) {
|
|
12
|
-
case "anthropic":
|
|
13
|
-
return new AnthropicProvider(providerConfig);
|
|
14
|
-
case "claudecli":
|
|
15
|
-
return new ClaudeCliProvider(providerConfig, mcpServers ?? {});
|
|
16
|
-
case "openai":
|
|
17
|
-
return new OpenAIProvider(providerConfig);
|
|
18
|
-
default: {
|
|
19
|
-
const exhaustive = providerConfig;
|
|
20
|
-
throw new Error(`Unknown provider type: ${exhaustive.type}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/providers/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC1B,cAA8B,EAC9B,UAA4C;IAE5C,QAAQ,cAAc,CAAC,IAAI,EAAE,CAAC;QAC1B,KAAK,WAAW;YACZ,OAAO,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAAC;QACjD,KAAK,WAAW;YACZ,OAAO,IAAI,iBAAiB,CAAC,cAAc,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;QACnE,KAAK,QAAQ;YACT,OAAO,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;QAC9C,OAAO,CAAC,CAAC,CAAC;YACN,MAAM,UAAU,GAAU,cAAc,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,0BAA2B,UAA+B,CAAC,IAAI,EAAE,CAAC,CAAC;QACvF,CAAC;IACL,CAAC;AACL,CAAC"}
|
package/src/providers/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { AnthropicProvider } from "./anthropic.js";
|
|
2
|
-
export { OpenAIProvider } from "./openai.js";
|
|
3
|
-
export { ClaudeCliProvider, computeClaudeBuiltinArgs } from "./claudecli.js";
|
|
4
|
-
export { createProvider } from "./factory.js";
|
|
5
|
-
export type { LLMProvider, ProviderChatRequest, ProviderChatResponse, ToolDefinition } from "./types.js";
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/src/providers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
import type { ProviderConfig } from "../validation/index.js";
|
|
3
|
-
import type { LLMProvider, ProviderChatRequest, ProviderChatResponse } from "./types.js";
|
|
4
|
-
export declare class OpenAIProvider implements LLMProvider {
|
|
5
|
-
protected readonly client: OpenAI;
|
|
6
|
-
private readonly providerConfig;
|
|
7
|
-
/** Resolved model id (from env or inline field). */
|
|
8
|
-
protected readonly resolvedModel: string;
|
|
9
|
-
constructor(providerConfig: Extract<ProviderConfig, {
|
|
10
|
-
type: "openai";
|
|
11
|
-
}>);
|
|
12
|
-
chat(request: ProviderChatRequest): Promise<ProviderChatResponse>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAS5B,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAEhF,OAAO,KAAK,EACR,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EAEvB,MAAM,YAAY,CAAC;AA6DpB,qBAAa,cAAe,YAAW,WAAW;IAC9C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA8C;IAC7E,oDAAoD;IACpD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;gBAE7B,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC;IA2BjE,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAmF1E"}
|