Skip to content

Add code for electron debugging - #1226

Merged
isamu merged 2 commits into
receptron:mainfrom
isamu:llmPlayground
Sep 14, 2025
Merged

isamu merged 2 commits into
receptron:mainfrom
isamu:llmPlayground

Conversation

@isamu

@isamu isamu commented Sep 14, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added an Electron-based playground runner with streaming of in‑progress responses.
    • Introduced a vision agent that generates presentation slides (section dividers, agenda) from prompts.
    • Added a multi-turn example demonstrating web browsing plus automated slide creation via tool orchestration.
  • Documentation
    • Updated run commands to use "npx tsx" instead of the previous ts-node run pattern.

@coderabbitai

coderabbitai Bot commented Sep 14, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds 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

Cohort / File(s) Summary of Changes
Documentation update
llm_agents/playground/README.md
Replaced ts-node run commands with npx tsx invocations for src/tools/run_tools.ts and src/loggers/samples.ts.
Static messages dataset
llm_agents/playground/src/tools/electron_messages.ts
Added exported messages array modeling a multi-turn, tool-augmented conversation (system/user/assistant/tool entries, tool_call/tool_call_id linkage, JP translations, timestamps).
Mulmo Vision agent
llm_agents/playground/src/tools/mulmo_vision_agent.ts
Added mulmoVisionAgent and exported mulmoVisionAgentInfo (default export). Constructs a MulmoCast “beat” (id, speaker, text, vision image payload) and returns { content: "Successfully created", data: beat }.
Electron GraphAI runner
llm_agents/playground/src/tools/run_tools_electron.ts
Added Electron runner wiring GraphAI, LLMs, tools, and Mulmo Vision. Introduced graphChatWithSearch (GraphData), consoleStreamAgentFilter (stream logging), filterMessage, and main4() which seeds messages (from electron_messages), runs the graph, logs results, and is invoked at load.

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
Loading
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my nose and tap the keys,
Slides sprout fast from URLs and breeze.
tsx hops in, streams hum bright,
Vision beats in lantern light.
A rabbit clap—tools dance tonight. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add code for electron debugging" succinctly and accurately describes the primary changes in this PR, which add an Electron-based runner and related playground tooling (run_tools_electron.ts, electron_messages.ts, and mulmo_vision_agent.ts); the README edits are minor documentation tweaks and do not contradict the title. It is short, specific enough for a teammate scanning history, and directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e31adc and ad8c8a0.

📒 Files selected for processing (1)
  • llm_agents/playground/src/tools/run_tools_electron.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • llm_agents/playground/src/tools/run_tools_electron.ts
⏰ 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)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d1d160 and 9e31adc.

📒 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 workspace

Ensure 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(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
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.

Comment on lines +53 to +55
export const graphChatWithSearch: GraphData = {
version: 0.5,
nodes: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
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.

@isamu
isamu merged commit 78dae5a into receptron:main Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant