Skip to content

Add read-only native sub-agent flow MiniApp - #69

Open
Huixin615 wants to merge 2 commits into
MiniMax-AI:mainfrom
Huixin615:feat/agent-flow
Open

Huixin615 wants to merge 2 commits into
MiniMax-AI:mainfrom
Huixin615:feat/agent-flow

Conversation

@Huixin615

@Huixin615 Huixin615 commented Oct 23, 2026 •

Copy link
Copy Markdown

Summary

Add Agent Flow, a Mini App for inspecting native task calls and sub-agent lifecycle events recorded by this plugin's Hooks.

  • Show task-call and sub-agent running intervals, tool-return status, and overlapping child execution.
  • Link a task call to a child only when their structured child session IDs match, or a Hook explicitly provides the parent session ID. The UI does not infer relationships from nearby timestamps.
  • Let the user import the plugin-generated JSONL file and select a recorded session. “View latest record” selects the newest imported session with task calls; it does not claim to identify the currently open chat.

Changes since the review of bc50fa1

The implementation that accessed Host-internal data has been removed:

  • No access to the Host runtime SQLite database, v2/sessions files, or session history.
  • No /api/sessions or /api/task endpoints derived from those stores.
  • The Mini App's Node process serves only its own static files and checks the loopback Host header. The browser reads an event file only after the user selects it.

Instead, MiniMax Code's SessionStart, PreToolUse(task), PostToolUse(task), SubagentStart, and SubagentStop Hooks send events to this plugin's recorder. The recorder writes bounded event metadata to the runtime-provided PLUGIN_DATA directory.

Data & limitations

Records contain timestamps, SHA-256 digests of opaque IDs, agent type, a task title truncated to 160 characters, and whether a tool response field was present. A task title may contain user-supplied or sensitive text. Full task instructions, tool-result bodies, and child final replies are not stored. Records stay on the user's machine until the user deletes them.

The imported file is parsed in the page's memory; the page does not scan Host sessions or automatically refresh the file. A PostToolUse event shows that a tool call returned, not that the parent Agent adopted its result. Events without an explicit association are excluded from the selected session's child view. Events from before the Hooks were installed cannot be reconstructed.

Requires MiniMax Code 3.1.4 or later and node on the Hook process's PATH. The documented macOS file location is a manual file-picker hint, not a path accessed by plugin code. Windows has not been manually tested.

Validation

  • node --test plugins/huixin615/agent-flow/tests/*.test.mjs: 10/10 passed.
  • npm run check: agent-flow: OK, repository validation passed, and 69 repository tests passed.
  • Manually tested on MiniMax Code 3.1.4/macOS: two native task calls and two sub-agent lifecycles were recorded. Each call linked to its child by an exact structured session ID match, and the child running intervals overlapped.
  • No real session records, imported event files, or runtime caches are included in this PR.

@MyPrototypeWhat MyPrototypeWhat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @Huixin615 — thanks for the first contribution. I looked at bc50fa1.

There is one repository red line that blocks merge on this revision.

Must fix

  1. Please remove direct access to the Host’s local runtime store and session history (read-only still counts)

Community plugins must not open MiniMax Code’s internal runtime database or its session store files. Disclosure in README / Data & access does not make that path allowed. The PR description and the code agree on the source; this is not a “docs say X, code does Y” gap:

  • miniapp/node/data.mjs:28-31 (dataHome): resolves MAVIS_HOME or ~/.minimax — not context.dataDir.
  • miniapp/node/data.mjs:34-50 (withDb): import('node:sqlite') then DatabaseSync(join(home, 'v2', 'sqlite', 'runtime-state.sqlite'), { readOnly: true }).
  • Queries on that store include conversation / task indexes: data.mjs:53-60 and data.mjs:71-80 (local_runtime_sessions), data.mjs:74-75 / data.mjs:143-144 (local_runtime_background_tasks).
  • Session history files are read next: data.mjs:192-226 (historyRows) opens …/v2/sessions/<historyDir>/messages.jsonl under the same home root (with path checks and a symlink reject).
  • Those history rows feed the UI: task instructions and parent-result matching (data.mjs:235-277, data.mjs:326-337), plus child final text / tool names (data.mjs:347-365 → /api/task in server.mjs:43-46).
  • server.mjs never uses context.dataDir; the live data path is entirely outside the plugin’s private directory.

So “read-only,” “no outbound network,” “no Agent turns,” and “no writes to Host files” can all be true and still leave the red line intact: the Mini App opens and queries Host-internal runtime state and session history. Please remove that whole path (SQLite open, history file reads, and any API that depends on them). After it is gone, wait for a compliant way to get this data before rebuilding, or narrow the Mini App so it does not need Host-internal stores. Please align README Data & access with whatever remains.

What the page currently surfaces from that path (worth knowing until it is removed): conversation titles and ids (/api/sessions), task instruction text, child final replies, and tool names. Anything a user pasted into a prompt or a child wrote back can appear in the local page JSON.

Optional (non-blocking; fine to park while the red line is open)

  • Loopback Host checks on GET: server.mjs:26-32 serves HTML/CSS/JS and the APIs with method checks only. Other plugins in the gallery also guard loopback Host on requests; worth matching when you have a Host-safe data path.

Happy to re-review once the Host-internal store / session-history access is gone.

@Huixin615

Copy link
Copy Markdown
Author

@MyPrototypeWhat Thanks for your review. I have updated it. Could your please take another look when you have time? Thanks you very much!

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.

2 participants