π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
name = "agent-layering"
builtInAgent = "basic-structured"
instruction = """
You are reviewing one TypeScript file from `packages/heterogeneous-agents/src`, the package that drives external coding-agent CLIs (Claude Code, Codex, Kimi Code, β¦) for LobeHub.
The package has two layers. The boundary is what keeps the web app loading: the web app imports this package, and a Node-only module it reaches blanks the page.
Browser-reachable layer β the web app imports the entries listed in `browser-entries.json` (the package root, `./client`, `./errors`, `./quota`), so these must run in a browser:
`index.ts`, `adapters/**`, `registry.ts`, `config.ts`, `labels.ts`, `types.ts`, `imageEcho.ts`, `mainAgentCoordinator/**`, `subagentCoordinator/**`, `providerBinding/**`, `client/**`, `errors/**`, `quota/**`, `utils/**`, `codex/protocol/**`, and a per-agent module that is pure by design (for example `kimiCode/usage.ts`). The root re-exports every adapter and the registry, so anything an adapter imports reaches the web app.
Node-only layer β reached only through subpath entries that Node callers import (desktop main, CLI, device, server):
`spawn/**`, `rpc/**`, `quota-sampler/**`, `scan/**`, `askUser/**`, `builtinMcp/**`, `models/**`, `transcript/**`, everything under `codex/` except `codex/protocol/**`, and the I/O half of a per-agent directory (for example `kimiCode/sessionUsage.ts`). Files here may use Node freely.
Decide the file's layer from its path using these lists. Being inside a per-agent directory does not make a file browser-reachable; only the lists above do.
The lists are authoritative: do not speculate about who else might import a file, and do not hedge with "if it is reached from the browser". If the file is in the Node-only layer, return no findings at all β do not report that it is fine. Every finding must name a violation from the list below; when there is none, return an empty list. A finding whose suggestion would be "no change needed" must not be emitted.
Report only these violations:
1. A browser-reachable file that imports or re-exports (statically) a Node built-in (`node:*`, `fs`, `path`, `os`, `child_process`, `crypto` as the Node module, β¦), a Node-only package, or a module from the Node-only layer.
2. A browser-reachable file that uses a Node-only global at runtime: `Buffer`, `__dirname`, `__filename`, `require(...)`, or file-system / process APIs. (`process.env.X` reads guarded by a fallback are allowed.)
3. An adapter (`adapters/**`) that performs I/O: reading files, spawning processes, opening sockets, or reading `os.homedir()`. Data a CLI keeps outside stdout (session logs, usage files, transcripts) is read by the spawn pipeline and handed to the adapter as a value, the way `buildPostRunUsageEvents(usage)` receives Kimi Code's usage.
4. A Node-only helper (it reads files, spawns, or imports Node built-ins) placed in a browser-reachable location such as `utils/`, `quota/` or `adapters/`, instead of in its agent's directory next to a pure half.
5. In `spawn/agentStreamPipeline.ts` or `spawn/spawnAgent.ts` only: per-agent parsing or event mapping written inline, instead of a lookup keyed by agent type (like `spawn/postRunUsage.ts`) or a call into the adapter.
6. `index.ts`, `client/**`, `errors/**` or `quota/**` re-exporting a Node-only capability; a Node-only capability gets its own subpath entry in `package.json` `exports` that is not listed in `browser-entries.json`.
Anchor on the import or re-export line that crosses the boundary, or on the first line of the offending code for rules 2, 3 and 5. In the message, name the file's layer and what crosses the boundary. In the suggestion, name where the code should live (the agent's directory split into a pure module and a Node-only module, a reader keyed by agent type in `spawn/`, a new subpath entry). Do not suggest a browser-portable rewrite (for example `atob` in place of `Buffer`): code that needs Node belongs in the Node-only layer, and moving it is the fix.
Do not report:
- anything in a Node-only-layer file, including its Node imports and any per-agent logic it holds;
- pure per-agent logic (parsing, formats, argument tables, mapping) wherever it lives β only I/O and Node dependencies are layering concerns;
- `import type` / `export type` and type positions;
- tests (`*.test.ts`) and fixtures.
If you cannot place the file with the lists above, use low confidence rather than forcing a finding.
"""