Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): add Claude Code subscription provider via Agent SDK (prototype)

Elian Doran5ec57f6dd0f0
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index e6d44941e4..3582711bba 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -3077,6 +3077,7 @@
"base_url": "Base URL",
"base_url_description": "Optional. Override the default API endpoint — useful for self-hosted models (Ollama, LM Studio, vLLM) or proxies.",
"base_url_invalid": "Base URL must be a valid http:// or https:// URL",
+ "claude_agent_description": "Uses your Claude Pro/Max subscription through Claude Code — no API key needed. Sign in once by running \"claude /login\" on the machine where the Trilium server runs. To let the AI access your notes, also enable the MCP server below.",
"cancel": "Cancel",
"mcp_title": "MCP (Model Context Protocol)",
"mcp_enabled": "MCP server",
diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
index a5e4b6ce16..7289adc135 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
@@ -1,10 +1,11 @@
import { createPortal } from "preact/compat";
import { useMemo, useRef, useState } from "preact/hooks";
-import Modal from "../../../react/Modal";
+
+import { t } from "../../../../services/i18n";
import FormGroup from "../../../react/FormGroup";
import FormSelect from "../../../react/FormSelect";
import FormTextBox from "../../../react/FormTextBox";
-import { t } from "../../../../services/i18n";
+import Modal from "../../../react/Modal";
export interface LlmProviderConfig {
id: string;
@@ -18,12 +19,16 @@ export interface ProviderType {
id: string;
name: string;
defaultBaseUrl: string;
+ /** When false, the provider needs no API key or base URL (e.g. subscription-based auth). */
+ usesApiKey?: boolean;
}
export const PROVIDER_TYPES: ProviderType[] = [
{ id: "anthropic", name: "Anthropic", defaultBaseUrl: "https://api.anthropic.com/v1" },
{ id: "openai", name: "OpenAI", defaultBaseUrl: "https://api.openai.com/v1" },
- { id: "google", name: "Google Gemini", defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta" }
+ { id: "google", name: "Google Gemini", defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta" },
+ // Uses the Claude Agent SDK on the server; auth belongs to Claude Code (`claude /login`).
+ { id: "claude-agent", name: "Claude Code (Pro/Max subscription)", defaultBaseUrl: "", usesApiKey: false }
];
function isValidBaseUrl(value: string): boolean {
@@ -54,9 +59,10 @@ export default function AddProviderModal({ show, onHidden, onSave }: AddProvider
() => PROVIDER_TYPES.find(p => p.id === selectedProvider),
[selectedProvider]
);
+ const usesApiKey = providerType?.usesApiKey !== false;
const trimmedBaseUrl = baseUrl.trim();
const baseUrlIsValid = isValidBaseUrl(trimmedBaseUrl);
- const canSubmit = !!apiKey.trim() && baseUrlIsValid;
+ const canSubmit = usesApiKey ? !!apiKey.trim() && baseUrlIsValid : true;
function handleSubmit() {
if (!canSubmit) {
@@ -67,8 +73,8 @@ export default function AddProviderModal({ show, onHidden, onSave }: AddProvider
id: `${selectedProvider}_${Date.now()}`,
name: providerType?.name || selectedProvider,
provider: selectedProvider,
- apiKey: apiKey.trim(),
- ...(trimmedBaseUrl && { baseURL: trimmedBaseUrl })
+ apiKey: usesApiKey ? apiKey.trim() : "",
+ ...(usesApiKey && trimmedBaseUrl && { baseURL: trimmedBaseUrl })
};
onSave(newProvider);
@@ -118,32 +124,38 @@ export default function AddProviderModal({ show, onHidden, onSave }: AddProvider
/>
</FormGroup>
- <FormGroup
- name="base-url"
- label={t("llm.base_url")}
- description={
- !baseUrlIsValid
- ? <span className="text-danger">{t("llm.base_url_invalid")}</span>
- : t("llm.base_url_description")
- }
- >
- <FormTextBox
- type="text"
- currentValue={baseUrl}
- onChange={setBaseUrl}
- placeholder={providerType?.defaultBaseUrl}
- />
- </FormGroup>
+ {usesApiKey ? (
+ <>
+ <FormGroup
+ name="base-url"
+ label={t("llm.base_url")}
+ description={
+ !baseUrlIsValid
+ ? <span className="text-danger">{t("llm.base_url_invalid")}</span>
+ : t("llm.base_url_description")
+ }
+ >
+ <FormTextBox
+ type="text"
+ currentValue={baseUrl}
+ onChange={setBaseUrl}
+ placeholder={providerType?.defaultBaseUrl}
+ />
+ </FormGroup>
- <FormGroup name="api-key" label={t("llm.api_key")}>
- <FormTextBox
- type="password"
- currentValue={apiKey}
- onChange={setApiKey}
- placeholder={t("llm.api_key_placeholder")}
- autoFocus
- />
- </FormGroup>
+ <FormGroup name="api-key" label={t("llm.api_key")}>
+ <FormTextBox
+ type="password"
+ currentValue={apiKey}
+ onChange={setApiKey}
+ placeholder={t("llm.api_key_placeholder")}
+ autoFocus
+ />
+ </FormGroup>
+ </>
+ ) : (
+ <p>{t("llm.claude_agent_description")}</p>
+ )}
</Modal>,
document.body
);
diff --git a/apps/server/package.json b/apps/server/package.json
index f62225af65..bdce37b746 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -35,6 +35,7 @@
"@ai-sdk/anthropic": "4.0.9",
"@ai-sdk/google": "4.0.9",
"@ai-sdk/openai": "4.0.8",
+ "@anthropic-ai/claude-agent-sdk": "^0.3.207",
"@modelcontextprotocol/sdk": "^1.12.1",
"ai": "7.0.17",
"better-sqlite3": "12.11.1",
diff --git a/apps/server/src/routes/api/llm_chat.ts b/apps/server/src/routes/api/llm_chat.ts
index aa303ad47f..66ef7f524f 100644
--- a/apps/server/src/routes/api/llm_chat.ts
+++ b/apps/server/src/routes/api/llm_chat.ts
@@ -1,10 +1,10 @@
-import type { LlmMessage } from "@triliumnext/commons";
+import type { LlmMessage, LlmStreamChunk } from "@triliumnext/commons";
+import { getLog } from "@triliumnext/core";
import type { Request, Response } from "express";
import { generateChatTitle } from "../../services/llm/chat_title.js";
import { getAllModels, getProviderByType, hasConfiguredProviders, type LlmProviderConfig } from "../../services/llm/index.js";
import { streamToChunks } from "../../services/llm/stream.js";
-import { getLog } from "@triliumnext/core";
import { safeExtractMessageAndStackFromError } from "../../services/utils.js";
interface ChatRequest {
@@ -51,7 +51,6 @@ async function streamChat(req: Request, res: Response) {
}
const provider = getProviderByType(config.provider || "anthropic");
- const result = provider.chat(messages, config);
// Get pricing and display name for the model
const modelId = config.model || provider.getAvailableModels().find(m => m.isDefault)?.id;
@@ -62,7 +61,20 @@ async function streamChat(req: Request, res: Response) {
const pricing = provider.getModelPricing(modelId);
const modelDisplayName = provider.getAvailableModels().find(m => m.id === modelId)?.name || modelId;
- for await (const chunk of streamToChunks(result, { model: modelDisplayName, pricing })) {
+
+ let chunks: AsyncIterable<LlmStreamChunk>;
+ if (provider.chatChunks) {
+ // Chunk-native provider (e.g. Claude Agent): it owns its own agentic
+ // loop and produces LlmStreamChunks directly. Abort the underlying
+ // agent turn when the client disconnects mid-stream.
+ const abortController = new AbortController();
+ res.on("close", () => abortController.abort());
+ chunks = provider.chatChunks(messages, config, abortController.signal);
+ } else {
+ chunks = streamToChunks(provider.chat(messages, config), { model: modelDisplayName, pricing });
+ }
+
+ for await (const chunk of chunks) {
if (chunk.type === "error") {
getLog().error(`LLM chat stream error (model ${modelDisplayName}): ${chunk.error}`);
}
diff --git a/apps/server/src/services/llm/index.ts b/apps/server/src/services/llm/index.ts
index d09b61ffd8..5a0bf0d314 100644
--- a/apps/server/src/services/llm/index.ts
+++ b/apps/server/src/services/llm/index.ts
@@ -1,6 +1,7 @@
import { getLog, options as optionService } from "@triliumnext/core";
import { AnthropicProvider } from "./providers/anthropic.js";
+import { ClaudeAgentProvider } from "./providers/claude_agent.js";
import { GoogleProvider } from "./providers/google.js";
import { OpenAiProvider } from "./providers/openai.js";
import type { LlmProvider, ModelInfo } from "./types.js";
@@ -22,7 +23,10 @@ export interface LlmProviderSetup {
const providerFactories: Record<string, (apiKey: string, baseURL?: string) => LlmProvider> = {
anthropic: (apiKey, baseURL) => new AnthropicProvider(apiKey, baseURL),
openai: (apiKey, baseURL) => new OpenAiProvider(apiKey, baseURL),
- google: (apiKey, baseURL) => new GoogleProvider(apiKey, baseURL)
+ google: (apiKey, baseURL) => new GoogleProvider(apiKey, baseURL),
+ // Claude Pro/Max subscription via the Claude Agent SDK — no API key;
+ // authentication is handled by Claude Code itself (`claude /login`).
+ "claude-agent": () => new ClaudeAgentProvider()
};
/** Cache of instantiated providers by their config ID */
diff --git a/apps/server/src/services/llm/providers/claude_agent.spec.ts b/apps/server/src/services/llm/providers/claude_agent.spec.ts
new file mode 100644
index 0000000000..790a636fe0
--- /dev/null
+++ b/apps/server/src/services/llm/providers/claude_agent.spec.ts
@@ -0,0 +1,310 @@
+import type { LlmStreamChunk } from "@triliumnext/commons";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const queryMock = vi.hoisted(() => vi.fn());
+const getOptionOrNullMock = vi.hoisted(() => vi.fn());
+
+vi.mock("@anthropic-ai/claude-agent-sdk", () => ({
+ query: queryMock
+}));
+
+vi.mock("@triliumnext/core", () => ({
+ getLog: () => ({ info: vi.fn(), error: vi.fn() }),
+ options: { getOptionOrNull: getOptionOrNullMock }
+}));
+
+vi.mock("../../data_dir.js", async () => {
+ const os = await import("os");
+ const path = await import("path");
+ return { default: { TRILIUM_DATA_DIR: path.join(os.tmpdir(), "trilium-claude-agent-spec") } };
+});
+
+vi.mock("../../port.js", () => ({ default: 8080 }));
+
+const { buildSeededPrompt, ClaudeAgentProvider, hashTranscript } = await import("./claude_agent.js");
+
+/** Make query() replay the given SDK messages and record its invocation. */
+function scriptAgent(messages: unknown[]) {
+ queryMock.mockImplementation(() => (async function* () {
+ for (const message of messages) {
+ yield message;
+ }
+ })());
+}
+
+async function collect(iterable: AsyncIterable<LlmStreamChunk>): Promise<LlmStreamChunk[]> {
+ const chunks: LlmStreamChunk[] = [];
+ for await (const chunk of iterable) {
+ chunks.push(chunk);
+ }
+ return chunks;
+}
+
+function textDelta(text: string) {
+ return {
+ type: "stream_event",
+ parent_tool_use_id: null,
+ session_id: "sess-1",
+ event: { type: "content_block_delta", index: 0, delta: { type: "text_delta", text } }
+ };
+}
+
+function successResult(sessionId = "sess-1") {
+ return {
+ type: "result",
+ subtype: "success",
+ is_error: false,
+ result: "ok",
+ session_id: sessionId,
+ total_cost_usd: 0.05,
+ usage: { input_tokens: 100, output_tokens: 40 }
+ };
+}
+
+describe("ClaudeAgentProvider.chatChunks", () => {
+ beforeEach(() => {
+ queryMock.mockReset();
+ getOptionOrNullMock.mockReset();
+ getOptionOrNullMock.mockReturnValue("true"); // mcpEnabled
+ });
+
+ it("maps stream events, tool calls, results, and usage to chunks in order", async () => {
+ scriptAgent([
+ { type: "system", subtype: "init", session_id: "sess-1" },
+ textDelta("Hello "),
+ {
+ type: "stream_event",
+ parent_tool_use_id: null,
+ session_id: "sess-1",
+ event: {
+ type: "content_block_start",
+ index: 1,
+ content_block: { type: "tool_use", id: "toolu_1", name: "mcp__trilium__search_notes" }
+ }
+ },
+ {
+ type: "stream_event",
+ parent_tool_use_id: null,
+ session_id: "sess-1",
+ event: { type: "content_block_delta", index: 1, delta: { type: "input_json_delta", partial_json: '{"query":' } }
+ },
+ {
+ type: "assistant",
+ parent_tool_use_id: null,
+ session_id: "sess-1",
+ message: {
+ content: [
+ { type: "text", text: "Hello " },
+ { type: "tool_use", id: "toolu_1", name: "mcp__trilium__search_notes", input: { query: "x" } }
+ ]
+ }
+ },
+ {
+ type: "user",
+ parent_tool_use_id: null,
+ session_id: "sess-1",
+ message: {
+ content: [
+ { type: "tool_result", tool_use_id: "toolu_1", content: [{ type: "text", text: "3 notes found" }] },
+ // A result for an unknown (e.g. replayed) tool call must be dropped.
+ { type: "tool_result", tool_use_id: "toolu_stale", content: "old" }
+ ]
+ }
+ },
+ textDelta("world"),
+ successResult()
+ ]);
+
+ const provider = new ClaudeAgentProvider();
+ const chunks = await collect(provider.chatChunks([{ role: "user", content: "hi" }], {}));
+
+ expect(chunks).toEqual([
+ { type: "text", content: "Hello " },
+ { type: "tool_input_start", toolCallId: "toolu_1", toolName: "search_notes" },
+ { type: "tool_input_delta", toolCallId: "toolu_1", delta: '{"query":' },
+ { type: "tool_use", toolCallId: "toolu_1", toolName: "search_notes", toolInput: { query: "x" } },
+ { type: "tool_result", toolCallId: "toolu_1", toolName: "search_notes", result: "3 notes found", isError: false },
+ { type: "text", content: "world" },
+ {
+ type: "usage",
+ usage: { promptTokens: 100, completionTokens: 40, totalTokens: 140, cost: 0.05, model: "claude-sonnet-5" }
+ },
+ { type: "done" }
+ ]);
+ });
+
+ it("ignores subagent traffic (non-null parent_tool_use_id)", async () => {
+ scriptAgent([
+ { ...textDelta("subagent text"), parent_tool_use_id: "toolu_parent" },
+ successResult()
+ ]);
+
+ const provider = new ClaudeAgentProvider();
+ const chunks = await collect(provider.chatChunks([{ role: "user", content: "hi" }], {}));
+
+ expect(chunks.filter(c => c.type === "text")).toEqual([]);
+ });
+
+ it("starts a fresh session with the plain prompt and resumes it when the transcript matches", async () => {
+ const provider = new ClaudeAgentProvider();
+ const config = { chatNoteId: "note-resume" };
+
+ // Turn 1 — no history, no mapping: plain prompt, no resume.
+ scriptAgent([textDelta("first reply"), successResult("sess-A")]);
+ await collect(provider.chatChunks([{ role: "user", content: "first question" }], config));
+
+ expect(queryMock).toHaveBeenCalledTimes(1);
+ const firstCall = queryMock.mock.calls[0][0];
+ expect(firstCall.prompt).toBe("first question");
+ expect(firstCall.options.resume).toBeUndefined();
+
+ // Turn 2 — transcript = turn 1 + streamed reply: resume with only the new message.
+ scriptAgent([textDelta("second reply"), successResult("sess-A")]);
+ await collect(provider.chatChunks([
+ { role: "user", content: "first question" },
+ { role: "assistant", content: "first reply" },
+ { role: "user", content: "second question" }
+ ], config));
+
+ const secondCall = queryMock.mock.calls[1][0];
+ expect(secondCall.prompt).toBe("second question");
+ expect(secondCall.options.resume).toBe("sess-A");
+ });
+
+ it("reseeds a fresh session from the transcript when the history diverged", async () => {
+ const provider = new ClaudeAgentProvider();
+ const config = { chatNoteId: "note-diverged" };
+
+ scriptAgent([textDelta("reply"), successResult("sess-B")]);
+ await collect(provider.chatChunks([{ role: "user", content: "original" }], config));
+
+ // The user edited the first message — the stored hash no longer matches.
+ scriptAgent([textDelta("re-reply"), successResult("sess-C")]);
+ await collect(provider.chatChunks([
+ { role: "user", content: "edited" },
+ { role: "assistant", content: "reply" },
+ { role: "user", content: "follow-up" }
+ ], config));
+
+ const secondCall = queryMock.mock.calls[1][0];
+ expect(secondCall.options.resume).toBeUndefined();
+ expect(secondCall.prompt).toContain("<conversation_history>");
+ expect(secondCall.prompt).toContain("User: edited");
+ expect(secondCall.prompt).toContain("Assistant: reply");
+ expect(secondCall.prompt).toContain("follow-up");
+ });
+
+ it("points the agent at Trilium's MCP server and disables built-in tools", async () => {
+ scriptAgent([successResult()]);
+ const provider = new ClaudeAgentProvider();
+ await collect(provider.chatChunks([{ role: "user", content: "hi" }], {}));
+
+ const options = queryMock.mock.calls[0][0].options;
+ expect(options.tools).toEqual([]);
+ expect(options.allowedTools).toEqual(["mcp__trilium"]);
+ expect(options.mcpServers.trilium.url).toBe("http://127.0.0.1:8080/mcp");
+ expect(options.permissionMode).toBe("dontAsk");
+ expect(options.settingSources).toEqual([]);
+ });
+
+ it("omits MCP wiring when the MCP server is disabled, and enables web search on request", async () => {
+ getOptionOrNullMock.mockReturnValue(null);
+ scriptAgent([successResult()]);
+ const provider = new ClaudeAgentProvider();
+ await collect(provider.chatChunks([{ role: "user", content: "hi" }], { enableWebSearch: true }));
+
+ const options = queryMock.mock.calls[0][0].options;
+ expect(options.mcpServers).toBeUndefined();
+ expect(options.tools).toEqual(["WebSearch", "WebFetch"]);
+ expect(options.allowedTools).toEqual(["WebSearch", "WebFetch"]);
+ });
+
+ it("surfaces authentication failures with a login hint", async () => {
+ scriptAgent([
+ {
+ type: "assistant",
+ parent_tool_use_id: null,
+ session_id: "sess-1",
+ error: "authentication_failed",
+ message: { content: [] }
+ },
+ { ...successResult(), subtype: "error_during_execution", is_error: true, errors: ["auth failed"] }
+ ]);
+
+ const provider = new ClaudeAgentProvider();
+ const chunks = await collect(provider.chatChunks([{ role: "user", content: "hi" }], {}));
+
+ const errors = chunks.filter(c => c.type === "error");
+ expect(errors[0].error).toContain("claude /login");
+ });
+
+ it("emits an error chunk when the agent subprocess fails", async () => {
+ queryMock.mockImplementation(() => (async function* () {
+ yield textDelta("partial");
+ throw new Error("spawn claude ENOENT");
+ })());
+
+ const provider = new ClaudeAgentProvider();
+ const chunks = await collect(provider.chatChunks([{ role: "user", content: "hi" }], {}));
+
+ const errors = chunks.filter(c => c.type === "error");
+ expect(errors).toHaveLength(1);
+ expect(errors[0].error).toContain("Failed to start Claude Code");
+ });
+
+ it("rejects a conversation that does not end with a user message", async () => {
+ const provider = new ClaudeAgentProvider();
+ const chunks = await collect(provider.chatChunks([{ role: "assistant", content: "hi" }], {}));
+ expect(chunks).toEqual([{ type: "error", error: "The last message must be a user message." }]);
+ expect(queryMock).not.toHaveBeenCalled();
+ });
+});
+
+describe("generateTitle", () => {
+ beforeEach(() => {
+ queryMock.mockReset();
+ getOptionOrNullMock.mockReset();
+ getOptionOrNullMock.mockReturnValue(null);
+ });
+
+ it("returns the agent's one-shot result with surrounding quotes stripped", async () => {
+ scriptAgent([{ ...successResult(), result: '"Meeting Notes Summary"' }]);
+ const provider = new ClaudeAgentProvider();
+ await expect(provider.generateTitle("summarize my meeting notes")).resolves.toBe("Meeting Notes Summary");
+
+ const options = queryMock.mock.calls[0][0].options;
+ expect(options.maxTurns).toBe(1);
+ expect(options.persistSession).toBe(false);
+ });
+
+ it("returns an empty string when the agent fails", async () => {
+ queryMock.mockImplementation(() => (async function* () {
+ throw new Error("not logged in");
+ yield undefined;
+ })());
+ const provider = new ClaudeAgentProvider();
+ await expect(provider.generateTitle("hello")).resolves.toBe("");
+ });
+});
+
+describe("transcript helpers", () => {
+ it("hashTranscript is stable across content shapes and sensitive to edits", () => {
+ const stringForm = hashTranscript([{ role: "user", content: "hello" }]);
+ const partsForm = hashTranscript([{ role: "user", content: [{ type: "text", text: "hello" }] }]);
+ expect(stringForm).toBe(partsForm);
+ expect(hashTranscript([{ role: "user", content: "hello!" }])).not.toBe(stringForm);
+ });
+
+ it("buildSeededPrompt replays the transcript with role labels", () => {
+ const prompt = buildSeededPrompt(
+ [
+ { role: "user", content: "q1" },
+ { role: "assistant", content: "a1" }
+ ],
+ "q2"
+ );
+ expect(prompt).toContain("User: q1");
+ expect(prompt).toContain("Assistant: a1");
+ expect(prompt.endsWith("q2")).toBe(true);
+ });
+});
diff --git a/apps/server/src/services/llm/providers/claude_agent.ts b/apps/server/src/services/llm/providers/claude_agent.ts
new file mode 100644
index 0000000000..e036cb5eb5
--- /dev/null
+++ b/apps/server/src/services/llm/providers/claude_agent.ts
@@ -0,0 +1,434 @@
+/**
+ * Claude Agent provider — drives the Claude Agent SDK (Claude Code as a
+ * subprocess) instead of calling the Anthropic API directly. This lets users
+ * with a Claude Pro/Max subscription use the in-app chat without an API key:
+ * authentication is owned entirely by Claude Code (`claude /login` once on the
+ * machine running the server), and billing goes to the subscription.
+ *
+ * Unlike the AI-SDK providers, the Agent SDK runs its own agentic loop and is
+ * session-based (it owns conversation history). This provider therefore:
+ * - implements `chatChunks()` (chunk-native streaming) instead of `chat()`,
+ * - maps chat notes to agent sessions and sends only the newest user message
+ * when the transcript still matches (`resume`), falling back to seeding a
+ * fresh session from the transcript when it diverged or was lost,
+ * - exposes note tools by pointing the agent at Trilium's own MCP server,
+ * with every built-in Claude Code tool (file access, bash, …) disabled.
+ */
+
+import { type Options as AgentOptions, query, type SDKAssistantMessage, type SDKMessage } from "@anthropic-ai/claude-agent-sdk";
+import type { LlmMessage, LlmMessagePart, LlmStreamChunk } from "@triliumnext/commons";
+import { getLog, options as optionService } from "@triliumnext/core";
+import { createHash } from "crypto";
+import fs from "fs";
+import path from "path";
+
+import dataDirs from "../../data_dir.js";
+import port from "../../port.js";
+import type { LlmProvider, LlmProviderConfig, ModelInfo, ModelPricing, StreamResult } from "../types.js";
+import { buildModelList } from "./base_provider.js";
+
+/**
+ * Models offered under a Claude subscription. Pricing is zero because usage is
+ * covered by the subscription — the per-turn `usage` chunk still reports the
+ * API-equivalent cost as informational metadata from the agent's result.
+ */
+const { models: AVAILABLE_MODELS, pricing: MODEL_PRICING } = buildModelList([
+ {
+ id: "claude-sonnet-5",
+ name: "Claude Sonnet 5 (subscription)",
+ pricing: { input: 0, output: 0 },
+ contextWindow: 1000000,
+ isDefault: true
+ },
+ {
+ id: "claude-opus-4-8",
+ name: "Claude Opus 4.8 (subscription)",
+ pricing: { input: 0, output: 0 },
+ contextWindow: 1000000
+ },
+ {
+ id: "claude-haiku-4-5-20251001",
+ name: "Claude Haiku 4.5 (subscription)",
+ pricing: { input: 0, output: 0 },
+ contextWindow: 200000
+ }
+]);
+
+const TITLE_MODEL = "claude-haiku-4-5-20251001";
+
+/** Upper bound on assistant↔tool round-trips within one chat turn. */
+const MAX_TURNS = 25;
+
+/** Session mappings kept per chat note; bounded to avoid unbounded growth. */
+const MAX_TRACKED_SESSIONS = 200;
+
+interface SessionEntry {
+ sessionId: string;
+ /** Hash of the transcript as it stood when the session last responded. */
+ transcriptHash: string;
+}
+
+/**
+ * chatNoteId → agent session. In-memory only: agent sessions live on this
+ * host (under ~/.claude), so the mapping must not sync across devices. Losing
+ * it (e.g. on restart) is fine — the provider reseeds a fresh session from
+ * the transcript the client sends.
+ */
+const sessionsByChatNote = new Map<string, SessionEntry>();
+
+function rememberSession(chatNoteId: string, entry: SessionEntry) {
+ // Refresh insertion order so the oldest mapping is evicted first.
+ sessionsByChatNote.delete(chatNoteId);
+ sessionsByChatNote.set(chatNoteId, entry);
+ if (sessionsByChatNote.size > MAX_TRACKED_SESSIONS) {
+ const oldest = sessionsByChatNote.keys().next().value;
+ if (oldest !== undefined) {
+ sessionsByChatNote.delete(oldest);
+ }
+ }
+}
+
+export class ClaudeAgentProvider implements LlmProvider {
+ name = "claude-agent";
+
+ getModelPricing(model: string): ModelPricing | undefined {
+ return MODEL_PRICING[model];
+ }
+
+ getAvailableModels(): ModelInfo[] {
+ return AVAILABLE_MODELS;
+ }
+
+ /** Not used — the route prefers {@link chatChunks} when implemented. */
+ chat(): StreamResult {
+ throw new Error("The Claude Agent provider streams chunks directly; use chatChunks().");
+ }
+
+ async *chatChunks(messages: LlmMessage[], config: LlmProviderConfig, signal?: AbortSignal): AsyncIterable<LlmStreamChunk> {
+ const conversation = messages.filter(m => m.role !== "system");
+ const lastMessage = conversation[conversation.length - 1];
+ if (!lastMessage || lastMessage.role !== "user") {
+ yield { type: "error", error: "The last message must be a user message." };
+ return;
+ }
+
+ const history = conversation.slice(0, -1);
+ const lastText = flattenContent(lastMessage.content);
+ const historyHash = hashTranscript(history);
+
+ // Resume the existing agent session only when the transcript the client
+ // sent still matches what that session last saw; any divergence (edited
+ // history, lost mapping, server restart) reseeds a fresh session.
+ const stored = config.chatNoteId ? sessionsByChatNote.get(config.chatNoteId) : undefined;
+ const resume = stored && stored.transcriptHash === historyHash ? stored.sessionId : undefined;
+ const prompt = (resume || history.length === 0)
+ ? lastText
+ : buildSeededPrompt(history, lastText);
+
+ const abortController = new AbortController();
+ const onAbort = () => abortController.abort();
+ signal?.addEventListener("abort", onAbort, { once: true });
+
+ const model = config.model || AVAILABLE_MODELS.find(m => m.isDefault)?.id;
+ let sessionId: string | undefined;
+ let assistantText = "";
+ // tool_use id → name, for labelling results; also serves as the guard
+ // that only results belonging to *this* turn's tool calls are emitted.
+ const toolNamesById = new Map<string, string>();
+ // streaming block index → tool_use id, for input-delta attribution
+ const toolIdsByBlockIndex = new Map<number, string>();
+
+ try {
+ const response = query({
+ prompt,
+ options: {
+ ...this.buildBaseOptions(config),
+ model,
+ resume,
+ includePartialMessages: true,
+ maxTurns: MAX_TURNS,
+ abortController
+ }
+ });
+
+ for await (const message of response) {
+ sessionId = takeSessionId(message) ?? sessionId;
+
+ switch (message.type) {
+ case "stream_event": {
+ if (message.parent_tool_use_id !== null) {
+ break; // subagent traffic — not part of the visible reply
+ }
+ const event = message.event;
+ if (event.type === "content_block_start" && event.content_block.type === "tool_use") {
+ toolIdsByBlockIndex.set(event.index, event.content_block.id);
+ toolNamesById.set(event.content_block.id, event.content_block.name);
+ yield {
+ type: "tool_input_start",
+ toolCallId: event.content_block.id,
+ toolName: friendlyToolName(event.content_block.name)
+ };
+ } else if (event.type === "content_block_delta") {
+ if (event.delta.type === "text_delta") {
+ assistantText += event.delta.text;
+ yield { type: "text", content: event.delta.text };
+ } else if (event.delta.type === "thinking_delta") {
+ yield { type: "thinking", content: event.delta.thinking };
+ } else if (event.delta.type === "input_json_delta") {
+ const toolCallId = toolIdsByBlockIndex.get(event.index);
+ if (toolCallId) {
+ yield { type: "tool_input_delta", toolCallId, delta: event.delta.partial_json };
+ }
+ }
+ }
+ break;
+ }
+
+ case "assistant": {
+ if (message.parent_tool_use_id !== null) {
+ break;
+ }
+ const authError = describeAssistantError(message);
+ if (authError) {
+ yield { type: "error", error: authError };
+ break;
+ }
+ // Text/thinking already streamed via stream_events; only
+ // the completed tool calls are emitted from the full message.
+ for (const block of message.message.content) {
+ if (block.type === "tool_use") {
+ toolNamesById.set(block.id, block.name);
+ yield {
+ type: "tool_use",
+ toolCallId: block.id,
+ toolName: friendlyToolName(block.name),
+ toolInput: (block.input ?? {}) as Record<string, unknown>
+ };
+ }
+ }
+ break;
+ }
+
+ case "user": {
+ if (message.parent_tool_use_id !== null) {
+ break;
+ }
+ const content = message.message.content;
+ if (!Array.isArray(content)) {
+ break;
+ }
+ for (const block of content) {
+ // Only surface results for tool calls made this turn —
+ // this also filters any replayed history on resume.
+ if (block.type === "tool_result" && block.tool_use_id && toolNamesById.has(block.tool_use_id)) {
+ yield {
+ type: "tool_result",
+ toolCallId: block.tool_use_id,
+ toolName: friendlyToolName(toolNamesById.get(block.tool_use_id) ?? "tool"),
+ result: flattenToolResult(block.content),
+ isError: block.is_error === true
+ };
+ }
+ }
+ break;
+ }
+
+ case "result": {
+ if (message.subtype !== "success") {
+ const errors = "errors" in message && message.errors.length > 0
+ ? message.errors.join("; ")
+ : `Agent stopped: ${message.subtype}`;
+ yield { type: "error", error: errors };
+ }
+ yield {
+ type: "usage",
+ usage: {
+ promptTokens: message.usage.input_tokens,
+ completionTokens: message.usage.output_tokens,
+ totalTokens: message.usage.input_tokens + message.usage.output_tokens,
+ // API-equivalent cost; informational under a subscription.
+ cost: message.total_cost_usd,
+ model
+ }
+ };
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ if (config.chatNoteId && sessionId) {
+ rememberSession(config.chatNoteId, {
+ sessionId,
+ transcriptHash: hashTranscript([
+ ...conversation,
+ { role: "assistant", content: assistantText }
+ ])
+ });
+ }
+
+ yield { type: "done" };
+ } catch (error) {
+ yield { type: "error", error: describeAgentError(error) };
+ } finally {
+ signal?.removeEventListener("abort", onAbort);
+ abortController.abort();
+ }
+ }
+
+ async generateTitle(firstMessage: string): Promise<string> {
+ try {
+ const response = query({
+ prompt: `Generate a short title (at most 5 words) summarizing this chat message. Reply with only the title, no quotes or punctuation around it:\n\n${firstMessage.substring(0, 500)}`,
+ options: {
+ ...this.buildBaseOptions({ enableNoteTools: false }),
+ model: TITLE_MODEL,
+ maxTurns: 1,
+ persistSession: false
+ }
+ });
+
+ for await (const message of response) {
+ if (message.type === "result" && message.subtype === "success") {
+ return message.result.trim().replace(/^["']|["']$/g, "").substring(0, 100);
+ }
+ }
+ } catch (error) {
+ getLog().error(`Claude Agent title generation failed: ${describeAgentError(error)}`);
+ }
+ return "";
+ }
+
+ /** Options shared by every agent invocation, independent of the turn. */
+ private buildBaseOptions(config: Pick<LlmProviderConfig, "enableNoteTools" | "enableWebSearch" | "systemPrompt">): AgentOptions {
+ // Built-in Claude Code tools (file access, bash, …) stay disabled — the
+ // agent runs on the server host and must only ever touch notes. Web
+ // search is the one opt-in exception.
+ const builtinTools = config.enableWebSearch ? ["WebSearch", "WebFetch"] : [];
+ const allowedTools = [...builtinTools];
+
+ const options: AgentOptions = {
+ cwd: getAgentCwd(),
+ systemPrompt: config.systemPrompt
+ || "You are an AI assistant integrated into Trilium Notes, a hierarchical note-taking application. Help the user with their notes: answer questions, find and summarize information, and use the available note tools when they are relevant. Be concise and helpful.",
+ tools: builtinTools,
+ settingSources: [],
+ strictMcpConfig: true,
+ permissionMode: "dontAsk"
+ };
+
+ if (config.enableNoteTools !== false) {
+ if (optionService.getOptionOrNull("mcpEnabled") === "true") {
+ options.mcpServers = {
+ trilium: {
+ type: "http",
+ url: `http://127.0.0.1:${port}/mcp`,
+ alwaysLoad: true
+ }
+ };
+ // Bare server prefix auto-allows every tool from that server.
+ allowedTools.push("mcp__trilium");
+ } else {
+ getLog().info("Claude Agent provider: note tools requested but the MCP server is disabled — enable it in Options → AI / LLM to let the agent access notes.");
+ }
+ }
+
+ options.allowedTools = allowedTools;
+ return options;
+ }
+}
+
+/**
+ * Directory the agent subprocess runs in. Claude Code keys its on-disk session
+ * storage by cwd, so a stable, dedicated directory keeps Trilium's sessions
+ * grouped and away from any real project.
+ */
+let agentCwd: string | undefined;
+function getAgentCwd(): string {
+ if (!agentCwd) {
+ agentCwd = path.join(dataDirs.TRILIUM_DATA_DIR, "claude-agent");
+ fs.mkdirSync(agentCwd, { recursive: true });
+ }
+ return agentCwd;
+}
+
+/** Flatten possibly-multimodal message content to plain text. */
+function flattenContent(content: string | LlmMessagePart[]): string {
+ if (typeof content === "string") {
+ return content;
+ }
+ return content
+ .map(part => {
+ if (part.type === "text") {
+ return part.text;
+ }
+ // Attachment parts are resolved server-side for API providers; the
+ // agent path is text-only for now.
+ return `[attached ${part.type === "image" ? "image" : "file"}${"filename" in part ? `: ${part.filename}` : ""}]`;
+ })
+ .join("\n");
+}
+
+/**
+ * Stable hash of a transcript (roles + text only). Used to detect whether the
+ * history the client sent still matches what the mapped agent session saw.
+ */
+export function hashTranscript(messages: LlmMessage[]): string {
+ const normalized = messages.map(m => [m.role, flattenContent(m.content).trim()]);
+ return createHash("sha256").update(JSON.stringify(normalized)).digest("hex");
+}
+
+/**
+ * First prompt of a reseeded session: replays the retained transcript as
+ * context so the agent can continue a conversation whose session was lost or
+ * diverged (edited history, server restart).
+ */
+export function buildSeededPrompt(history: LlmMessage[], lastText: string): string {
+ const transcript = history
+ .map(m => `${m.role === "user" ? "User" : "Assistant"}: ${flattenContent(m.content)}`)
+ .join("\n\n");
+ return `<conversation_history>\nThis is the prior conversation between the user and you. Continue it naturally; do not mention this replay.\n\n${transcript}\n</conversation_history>\n\n${lastText}`;
+}
+
+/** Strip the MCP prefix so the client shows "search_notes", not "mcp__trilium__search_notes". */
+function friendlyToolName(name: string): string {
+ return name.replace(/^mcp__trilium__/, "");
+}
+
+function flattenToolResult(content: unknown): string {
+ if (typeof content === "string") {
+ return content;
+ }
+ if (Array.isArray(content)) {
+ return content
+ .map(block => (block && typeof block === "object" && "text" in block ? String(block.text) : ""))
+ .filter(Boolean)
+ .join("\n");
+ }
+ return content == null ? "" : JSON.stringify(content);
+}
+
+function takeSessionId(message: SDKMessage): string | undefined {
+ return "session_id" in message && typeof message.session_id === "string" ? message.session_id : undefined;
+}
+
+/** Map SDK-level assistant errors to actionable messages. */
+function describeAssistantError(message: SDKAssistantMessage): string | undefined {
+ if (!message.error) {
+ return undefined;
+ }
+ if (message.error === "authentication_failed" || message.error === "oauth_org_not_allowed") {
+ return "Claude Code is not authenticated. Run `claude /login` on the machine running the Trilium server to sign in with your Claude subscription (or an API key).";
+ }
+ return `Claude Agent error: ${message.error}`;
+}
+
+function describeAgentError(error: unknown): string {
+ const text = error instanceof Error ? error.message : String(error);
+ if (/ENOENT|spawn/i.test(text)) {
+ return `Failed to start Claude Code: ${text}`;
+ }
+ return text;
+}
diff --git a/apps/server/src/services/llm/types.ts b/apps/server/src/services/llm/types.ts
index 3924d8601c..f5da030311 100644
--- a/apps/server/src/services/llm/types.ts
+++ b/apps/server/src/services/llm/types.ts
@@ -4,7 +4,7 @@
* should be imported from @triliumnext/commons.
*/
-import type { LlmChatConfig, LlmMessage } from "@triliumnext/commons";
+import type { LlmChatConfig, LlmMessage, LlmStreamChunk } from "@triliumnext/commons";
import type { streamText } from "ai";
/**
@@ -64,6 +64,20 @@ export interface LlmProvider {
config: LlmProviderConfig
): StreamResult;
+ /**
+ * Chunk-native alternative to {@link chat} for providers that don't go
+ * through the AI SDK (e.g. the Claude Agent provider, which runs its own
+ * agentic loop in a subprocess). When implemented, the chat route streams
+ * these chunks directly and skips the AI SDK conversion entirely.
+ *
+ * @param signal aborts the underlying agent turn when the client disconnects
+ */
+ chatChunks?(
+ messages: LlmMessage[],
+ config: LlmProviderConfig,
+ signal?: AbortSignal
+ ): AsyncIterable<LlmStreamChunk>;
+
/**
* Get pricing for a model. Returns undefined if pricing is not available.
*/
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 24470cd46a..dda165c356 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -617,6 +617,9 @@ importers:
'@ai-sdk/openai':
specifier: 4.0.8
version: 4.0.8([email protected])
+ '@anthropic-ai/claude-agent-sdk':
+ specifier: ^0.3.207
+ version: 0.3.207(@anthropic-ai/[email protected]([email protected]))(@modelcontextprotocol/[email protected]([email protected]))([email protected])
'@modelcontextprotocol/sdk':
specifier: ^1.12.1
version: 1.29.0([email protected])
@@ -1779,6 +1782,67 @@ packages:
resolution: {integrity: sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ==}
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-08xSo1FDx8h0aLhL5tvcRxa2SMmcUV3aDWeZiEJVTclyiDAs61BgTjAxCg+SZcu1CndjJO8cfO0yM5dhamxz3g==}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-1o7K4EYqyCixZ/oeOZSh7AzSy6TM86xoOuf4VuORjPSS31hBnoqY0NGZd27+2VDs9LGtsdksmsTqcNGx9xd1hA==}
+ cpu: [x64]
+ os: [darwin]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-oPj+g2DslhH4Y9nCTs7al4t9wZv78FZwLFQwOCg99BXuz1o0ZOpKmxyvR7J9eBR+GPszeMMS8gYplQTiZC9o2w==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-X4uezYOifDiNTTmmugfRCdg3nNamrr1LFRY9hg30vWYTShL+bbN+nfC3KaFfSYCl4GTtsEEUbYdOTC2F3bBpcA==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-uRv+D5oG/7EYr41FAJ9IPo2pZYBe2ZMaA6nSHCeizsgPxCSMtl5bNppmU21+jZJvo4hivObEgkGFERAhdGqygg==}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-Kg6BPH8Ee0ny/oEUWJmvT1jCRBne4jVpRSOMsJcYp1Fav1rMEgpU219oJJs+LWwx4ifuuLtNWedqJNnVw7mnKg==}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-9fWpUzfkXlPAg2tf8JpQe7w9avFaomAUbfAwyAmykQgSIf66LwaJjvI5hNqhNqczRKyfsXPn3ei2S5HKlmFP+Q==}
+ cpu: [arm64]
+ os: [win32]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-YPjVT0q6aXEM2MgN4CI6/9fqiTXwETji+4NoPOzCYuqAkhXZqp30Jsk7/NHqYGNNSfURKrsuAoliKB0rsbpbjg==}
+ cpu: [x64]
+ os: [win32]
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-y0PkQRmQBi96MHiN5Xzfq+GaddxCZCqI/cXEQBLYBLXGa4i1nDSlulQqkMBj2RorrrSGQJ6Wdw+uhu6OfHNPzA==}
+ engines: {node: '>=18.0.0'}
+ peerDependencies:
+ '@anthropic-ai/sdk': '>=0.93.0'
+ '@modelcontextprotocol/sdk': ^1.29.0
+ zod: '>=4.0.0'
+
+ '@anthropic-ai/[email protected]':
+ resolution: {integrity: sha512-1hUqKi+uJQoS5X90+InwHbFAXMvgq0DnsC5hVLEeSRaODiU5WvmqDAcVCmGS2wC0pN9Z8jtWCbWw7JLzeDdm/Q==}
+ hasBin: true
+ peerDependencies:
+ zod: '>=4.0.0'
+ peerDependenciesMeta:
+ zod:
+ optional: true
+
resolution: {integrity: sha512-NB7yqrO7qvInsqJdqz6C6mDU+2oiKmbBbk3czMS0E7KkGxLRy538tEHCsB5TKqmaxxXpi6/U120TnGl8NsDePg==}
@@ -5418,6 +5482,9 @@ packages:
'@ssddanbrown/[email protected]':
resolution: {integrity: sha512-7WIMIh8Ssc54TooGCY57WU2rKEqZZrcV2tZSVRPtd0gKYsrDEKCSLWpQjUWEx7bdgh3NKHUjq1O4ugIzI/+dwQ==}
+ '@stablelib/[email protected]':
+ resolution: {integrity: sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==}
+
'@standard-schema/[email protected]':
resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
@@ -8774,6 +8841,9 @@ packages:
resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==}
+ resolution: {integrity: sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==}
+
resolution: {integrity: sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==}
@@ -9992,6 +10062,10 @@ packages:
resolution: {integrity: sha512-fi0NG4bPjCHunUJffmLd0gxssIgkNmArMvis4iNah6Owg1MCJjWhEcDLmsK6iGkJq3tHwbDkTlce70/tmXN4cQ==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
+ resolution: {integrity: sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==}
+ engines: {node: '>=16'}
+
resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}
@@ -12437,6 +12511,9 @@ packages:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
+ resolution: {integrity: sha512-BbHGOQK9olHPMvQNHWul6MYlrRTAOKn03rOe4A8O3CLWhNf4YHBqq2HJKKC+sfqpxiBY52pNeesD6jIiLDz8jg==}
+
resolution: {integrity: sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==}
engines: {node: '>= 0.6'}
@@ -12878,6 +12955,9 @@ packages:
resolution: {integrity: sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ==}
+ resolution: {integrity: sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==}
+
resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==}
engines: {node: '>=18.12'}
@@ -13883,6 +13963,52 @@ snapshots:
package-manager-detector: 1.6.0
tinyexec: 1.1.2
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ '@anthropic-ai/[email protected]':
+ optional: true
+
+ dependencies:
+ '@anthropic-ai/sdk': 0.111.0([email protected])
+ '@modelcontextprotocol/sdk': 1.29.0([email protected])
+ zod: 4.4.3
+ optionalDependencies:
+ '@anthropic-ai/claude-agent-sdk-darwin-arm64': 0.3.207
+ '@anthropic-ai/claude-agent-sdk-darwin-x64': 0.3.207
+ '@anthropic-ai/claude-agent-sdk-linux-arm64': 0.3.207
+ '@anthropic-ai/claude-agent-sdk-linux-arm64-musl': 0.3.207
+ '@anthropic-ai/claude-agent-sdk-linux-x64': 0.3.207
+ '@anthropic-ai/claude-agent-sdk-linux-x64-musl': 0.3.207
+ '@anthropic-ai/claude-agent-sdk-win32-arm64': 0.3.207
+ '@anthropic-ai/claude-agent-sdk-win32-x64': 0.3.207
+
+ dependencies:
+ json-schema-to-ts: 3.1.1
+ standardwebhooks: 1.0.0
+ optionalDependencies:
+ zod: 4.4.3
+
'@arnog/[email protected]': {}
'@asamuzakjp/[email protected]':
@@ -18400,6 +18526,8 @@ snapshots:
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.10
+ '@stablelib/[email protected]': {}
+
'@standard-schema/[email protected]': {}
@@ -23329,6 +23457,8 @@ snapshots:
+
@@ -24677,6 +24807,11 @@ snapshots:
+ dependencies:
+ '@babel/runtime': 7.29.2
+ ts-algebra: 2.0.0
+
@@ -27514,6 +27649,11 @@ snapshots:
+ dependencies:
+ '@stablelib/base64': 1.0.1
+ fast-sha256: 1.3.0
+
@@ -28039,6 +28179,8 @@ snapshots:
dependencies:
utf8-byte-length: 1.0.5
+
dependencies:
typescript: 6.0.3