Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Merge remote-tracking branch 'origin/prototype/claude-agent-provider' into prototype/claude-agent-provider
Elian Doran8eb6f5d5ef5f
diff --cc apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsxindex a274b771e9,602122df4b..67345a178a--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx@@@ -345,11 -338,11 +345,11 @@@ export default function ChatInputBar(>{currentModels.map(model => (<FormListItem- key={model.id}- onClick={() => handleModelSelect(model.id)}- checked={chat.selectedModel === model.id}+ key={`${model.provider}:${model.id}`}+ onClick={() => handleModelSelect(model.id, model.provider)}+ checked={isSelectedModel(model)}>- {model.name} <small>({model.costDescription})</small>+ {model.name}{model.costDescription && <> <small>({model.costDescription})</small></>}</FormListItem>))}{legacyModels.length > 0 && (@@@ -361,11 -354,11 +361,11 @@@>{legacyModels.map(model => (<FormListItem- key={model.id}- onClick={() => handleModelSelect(model.id)}- checked={chat.selectedModel === model.id}+ key={`${model.provider}:${model.id}`}+ onClick={() => handleModelSelect(model.id, model.provider)}+ checked={isSelectedModel(model)}>- {model.name} <small>({model.costDescription})</small>+ {model.name}{model.costDescription && <> <small>({model.costDescription})</small></>}</FormListItem>))}</FormDropdownSubmenu>diff --cc apps/server/src/services/llm/providers/claude_agent.spec.tsindex bfb718fa01,9ed17af7e0..3af1ecddf0--- a/apps/server/src/services/llm/providers/claude_agent.spec.ts+++ b/apps/server/src/services/llm/providers/claude_agent.spec.ts@@@ -24,11 -28,36 +28,36 @@@ vi.mock("../../data_dir.js", async () =vi.mock("../../port.js", () => ({ default: 8080 }));-const buildNoteHintMock = vi.hoisted(() => vi.fn((noteId: string) => `NOTE_META(${noteId})`));+const buildNoteHintMock = vi.hoisted(() => vi.fn((noteId: string): string | null => `NOTE_META(${noteId})`));vi.mock("./note_hint.js", () => ({ buildNoteHint: buildNoteHintMock }));+ // BYO binary resolution shells out to the user's `claude`; stub it so tests+ // don't depend on a real install. Returns a path by default; can be made to+ // throw (missing binary) per-test.+ const resolveClaudeBinaryMock = vi.hoisted(() => vi.fn(() => "/usr/bin/claude"));+ vi.mock("./claude_binary.js", () => ({ resolveClaudeBinaryPath: resolveClaudeBinaryMock }));++ // Attachment resolution reads bytes out of Becca, which the core mock above+ // omits — stub it so the multimodal tests drive block construction directly.+ const resolveAttachmentPartMock = vi.hoisted(() => vi.fn());+ vi.mock("./attachment_content.js", () => ({ resolveAttachmentPart: resolveAttachmentPartMock }));+const { buildSeededPrompt, ClaudeAgentProvider, hashTranscript } = await import("./claude_agent.js");+ /** Drain the query prompt into the single user message it streams (multimodal path). */+ async function drainPrompt(prompt: unknown): Promise<{ role: string; content: unknown[] }> {+ const iterator = (prompt as AsyncIterable<unknown>)?.[Symbol.asyncIterator];+ if (typeof prompt === "string" || typeof iterator !== "function") {+ throw new Error("expected a streamed multimodal prompt, got a plain string");+ }+ const messages: { message: { role: string; content: unknown[] } }[] = [];+ for await (const message of prompt as AsyncIterable<{ message: { role: string; content: unknown[] } }>) {+ messages.push(message);+ }+ expect(messages).toHaveLength(1);+ return messages[0].message;+ }+/** Make query() replay the given SDK messages and record its invocation. */function scriptAgent(messages: unknown[]) {queryMock.mockImplementation(() => (async function* () {