Repository navigation
Add code for electron debugging - #1226
Conversation
WalkthroughAdds README command updates and three new playground modules: a static multi-turn electron_messages dataset, a mulmoVision agent that builds MulmoCast beats, and an Electron-based GraphAI runner wiring agents, tools, and a streaming console filter; the runner auto-invokes on load. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant R as Electron Runner
participant G as GraphAI
participant L as LLM Agent
participant T as Tools Agent
participant P as PuppeteerAgent
participant M as MulmoVisionAgent
U->>R: Provide messages (URL, "スライドにして!", "続けて")
R->>G: Build graph (agents, tools, messages)
G->>L: LLM generates assistant output (system enforces JP + parallel tools)
L-->>T: Tool call: puppeteerAgent--openUrl(url)
T->>P: openUrl request
P-->>T: Page content (tool result)
T-->>L: Return tool result
L-->>T: Tool call: mulmoVisionAgent--createSectionDividerSlide(args)
T->>M: Create Section Divider beat
M-->>T: Successfully created (+beat)
T-->>L: Return tool result
L-->>T: Tool call: mulmoVisionAgent--createAgendaSlide(args)
T->>M: Create Agenda beat
M-->>T: Successfully created (+beat)
T-->>L: Return tool result
L-->>G: Final assistant outputs (possibly empty)
G-->>R: Aggregated result
R-->>U: Logs / console stream
sequenceDiagram
autonumber
participant R as Runner
participant G as GraphAI
participant N1 as messages(node)
participant N2 as prompt(node)
participant N3 as tools/passthrough(node)
participant N4 as llm(node)
R->>G: Build with graphChatWithSearch + consoleStreamAgentFilter
G->>N1: Seed `messages` from electron_messages
G->>N2: Seed prompt/agent/model
G->>N3: Provide tools & passthrough
G->>N4: Invoke LLM (streams via consoleStreamAgentFilter)
N4-->>G: Final output
G-->>R: Results logged
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (11)
llm_agents/playground/README.md (2)
4-6: Add language to fenced code blocks to satisfy markdownlint (MD040).Use bash language hints.
-``` +```bash npx tsx src/tools/run_tools.ts -``` +```
9-11: Add language to fenced code blocks to satisfy markdownlint (MD040).Same fix for the logger example.
-``` +```bash npx tsx src/loggers/samples.ts -``` +```llm_agents/playground/src/tools/mulmo_vision_agent.ts (2)
6-9: Validate inputs (arg/func) to prevent crashes on malformed tool calls.Minimal guards improve resilience.
-const mulmoVisionAgent: AgentFunction = async ({ namedInputs }) => { - const { arg, func } = namedInputs; - const { talkTrack, ...newArg } = arg; +const mulmoVisionAgent: AgentFunction = async ({ namedInputs }) => { + const { arg, func } = (namedInputs ?? {}) as { arg?: Record<string, unknown>; func?: string }; + if (!arg || typeof arg !== "object") throw new Error("mulmoVisionAgent: missing or invalid 'arg'"); + if (!func || typeof func !== "string") throw new Error("mulmoVisionAgent: missing or invalid 'func'"); + const { talkTrack, ...newArg } = arg as { talkTrack?: string };
31-37: Align sample shape with actual return structure.Keep samples representative for playgrounds/tests.
samples: [ { - params: {}, - inputs: {}, - result: {}, + params: {}, + inputs: { namedInputs: { arg: { title: "demo" }, func: "createAgendaSlide" } }, + result: { content: "Successfully created", data: { id: "uuid", speaker: "Presenter" } }, }, ],llm_agents/playground/src/tools/electron_messages.ts (2)
37-41: Consider truncating the scraped page content to reduce context/token bloat.Store a short excerpt plus URL; fetch on demand during the run.
120-124: Remove trailing empty assistant message.It’s dropped later by filtering; delete here to keep fixtures lean.
- { - role: "assistant", - content: "", - time: 1757814254043, - },llm_agents/playground/src/tools/run_tools_electron.ts (5)
125-125: Avoid side effects: don’t auto-run on import.Gate behind import.meta.main or an env flag to keep this debug runner opt-in.
-main4(); +if ((import.meta as any)?.main || process.env.RUN_TOOLS_ELECTRON === "1") { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + main4(); +}
25-49: Remove unused graph definition or wire it up.Currently dead code; confuses readers.
-const graph = { - version: 0.5, - nodes: { - messages: { - value: [], - }, - text: { - value: "", - }, - llmAgent: {}, - llmModel: {}, - tools: { - isResult: true, - agent: "toolsAgent", - inputs: { - messages: ":messages", - userInput: { text: ":text" }, - tools: [...tools, ...mulmoVisionAgent.tools], - llmAgent: ":llmAgent", - llmModel: ":llmModel", - stream: true, - }, - }, - }, -}; +// (removed unused 'graph' definition)
10-10: Drop unused import toolsSequentialAgent.-import { toolsAgent, toolsSequentialAgent } from "../../../tools_agent/src/index"; +import { toolsAgent } from "../../../tools_agent/src/index";
89-96: Minor: filterMessage parameter setTime is unused.Simplify signature or pass true if timestamps are needed.
-const filterMessage = (setTime = false) => { - return (message) => { - const { role, content, tool_calls, tool_call_id, name, extra } = message; - if (setTime) { - return { extra, role, content, tool_calls, tool_call_id, name, time: message.time ?? Date.now() }; - } - return { extra, role, content, tool_calls, tool_call_id, name }; - }; -}; +const filterMessage = () => (message: any) => { + const { role, content, tool_calls, tool_call_id, name, extra } = message; + return { extra, role, content, tool_calls, tool_call_id, name }; +};
19-23: Streaming logs may expose sensitive content.If sharing logs, consider redacting or logging deltas only.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
llm_agents/playground/README.md(1 hunks)llm_agents/playground/src/tools/electron_messages.ts(1 hunks)llm_agents/playground/src/tools/mulmo_vision_agent.ts(1 hunks)llm_agents/playground/src/tools/run_tools_electron.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
llm_agents/playground/src/tools/run_tools_electron.ts (2)
agent_filters/stream_agent_filter/lib/stream.js (1)
streamAgentFilter(6-15)llm_agents/playground/src/tools/electron_messages.ts (1)
messages(1-125)
🪛 markdownlint-cli2 (0.17.2)
llm_agents/playground/README.md
9-9: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build (22.x)
- GitHub Check: build (24.x)
🔇 Additional comments (3)
llm_agents/playground/src/tools/run_tools_electron.ts (1)
117-119: Confirm Anthropic model ID is supported by the agent SDK.
llm_agents/playground/src/tools/run_tools_electron.ts injects "claude-sonnet-4-20250514" (≈lines 117–119); the repo's Anthropic agent depends on @anthropic-ai/sdk ^0.60.0 (llm_agents/anthropic_agent/package.json) and there are no other local references to that model ID. Verify this model string is accepted by your SDK/version or replace it with a supported model ID.llm_agents/playground/src/tools/electron_messages.ts (1)
21-24: Verify puppeteerAgent (openUrl) is registered in tools/common and active at runtime.
Found a call at llm_agents/playground/src/tools/electron_messages.ts (lines 21–34): name "puppeteerAgent--openUrl" / agent "puppeteerAgent" / func "openUrl"; repo search did not locate a registration or definition for "puppeteerAgent" or "openUrl" — register the tool in tools/common or ensure it's included in the active tools set.llm_agents/playground/README.md (1)
5-10: Confirm tsx is available in this workspaceEnsure tsx is installed (listed in package.json deps/devDeps or present at node_modules/.bin/tsx); otherwise running "npx tsx ..." will fail with "tsx: command not found". Verify locally (examples): grep -n '"tsx"' package.json package-lock.json yarn.lock pnpm-lock.yaml || npm ls tsx || pnpm ls tsx || yarn why tsx. If missing, add as a devDependency (npm install -D tsx or pnpm add -D tsx) or update the README to document how to run the scripts.
| const { talkTrack, ...newArg } = arg; | ||
|
|
||
| const beat = { | ||
| id: crypto.randomUUID(), |
There was a problem hiding this comment.
crypto.randomUUID may be undefined in Node/Electron main; add a safe fallback.
Avoid runtime ReferenceError outside browser contexts.
-import { functionNameToTemplateName, tools, convertTools } from "mulmocast-vision/lib/browser";
+import { functionNameToTemplateName, tools, convertTools } from "mulmocast-vision/lib/browser";
+import { randomUUID as nodeRandomUUID } from "crypto";
+
+const safeRandomUUID = () => globalThis.crypto?.randomUUID?.() ?? nodeRandomUUID();
@@
- id: crypto.randomUUID(),
+ id: safeRandomUUID(),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| id: crypto.randomUUID(), | |
| import { functionNameToTemplateName, tools, convertTools } from "mulmocast-vision/lib/browser"; | |
| import { randomUUID as nodeRandomUUID } from "crypto"; | |
| const safeRandomUUID = () => globalThis.crypto?.randomUUID?.() ?? nodeRandomUUID(); | |
| id: safeRandomUUID(), |
🤖 Prompt for AI Agents
In llm_agents/playground/src/tools/mulmo_vision_agent.ts around line 11, the
direct use of crypto.randomUUID can throw ReferenceError in Node/Electron main
where window.crypto may be undefined; replace the direct call with a safe
fallback: detect whether globalThis.crypto?.randomUUID is a function and use it,
otherwise fall back to a Node-safe generator (e.g. import/require Node's
crypto.randomUUID if available, or use a UUID v4 implementation such as the
'uuid' package or a small crypto.randomBytes-based v4 generator) so the code
never assumes browser-only globals.
| export const graphChatWithSearch: GraphData = { | ||
| version: 0.5, | ||
| nodes: { |
There was a problem hiding this comment.
GraphData type is used but not imported — compile error.
Import the type from graphai.
-import { GraphAI } from "graphai";
+import { GraphAI, type GraphData } from "graphai";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export const graphChatWithSearch: GraphData = { | |
| version: 0.5, | |
| nodes: { | |
| import { GraphAI, type GraphData } from "graphai"; | |
| export const graphChatWithSearch: GraphData = { | |
| version: 0.5, | |
| nodes: { |
🤖 Prompt for AI Agents
In llm_agents/playground/src/tools/run_tools_electron.ts around lines 53 to 55,
the GraphData type is referenced but not imported which causes a compile error;
add an import for GraphData from the graphai package at the top of the file
(alongside other imports) so the exported constant can be typed correctly, e.g.
import { GraphData } from 'graphai', and then save/rebuild to confirm the
compilation error is resolved.
Summary by CodeRabbit