agentleFS
D-SheyD-Shey/autoharness/.agents/skills/codemode-gateway/SKILL.md

codemode-gateway

Skill10 starsChanged todayMITView on GitHub

Code Mode sandbox execution and RPC dispatch in AutoHarness gateway

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use when implementing or debugging Code Mode execution in AutoHarness Gateway:

    line 9
  2. Very specific:

    When generating TypeScript definitions, server names with hyphens or dots are converted to valid TS identifiers (e.g., git-hub -> git_hub).

    line 24
  3. Very specific:

    Run the sandbox subprocess with child_env({}) (restricted to safe system vars like PATH, SystemRoot) to prevent secret exfiltration from …

    line 27
  4. Very specific:

    Test standalone execution without tool calls: return 1 + 1 yields 2.

    line 33
  5. Very specific:

    Test async MCP dispatch: call a mock tool through mcp.mock_server.test_tool({ count: 5 }) and verify correct RPC dispatch and argument …

    line 34
  6. Distinctive:

    Test hanging async promise: verify that an unresolved Promise times out cleanly without blocking the gateway.

    line 35
  7. Very specific:

    Test hyphenated server name resolution: verify that server git-hub is callable via mcp.git_hub.

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

codemode-gateway

When to use

Use when implementing or debugging Code Mode execution in AutoHarness Gateway:

  • Connecting isolated script execution environments (Node.js/QuickJS subprocesses) with Gateway's internal MCP tool registry.
  • Proxying tool calls from sandbox scripts to MCP client instances (client.call_tool) without leaking host environment secrets or filesystem access.
  • Batching multi-step tool calls, loops, and data transformations into a single model round-trip.

Steps

  1. Define the RPC protocol over stdio:
    • Establish a line-delimited JSON-RPC channel on stdio between the Gateway host and the sandbox runner.
    • Deliver initial script payload via the first line of stdin rather than argv to avoid OS command-line length limits (Windows 32KB limit).
    • Reference: Node.js stdio stream handling (https://nodejs.org/api/process.html#processstdout).
  2. Robust async timeout and cancellation:
    • node:vm timeout only interrupts synchronous execution loops; async promises require an explicit JS-side setTimeout watchdog timer.
    • The host Python process must implement an independent watchdog timer (threading.Timer) to forcefully terminate proc.kill() if stdio reads block on hanging async promises.
    • Reference: Node.js VM context isolation (https://nodejs.org/api/vm.html).
  3. Sanitized identifier mapping:
    • When generating TypeScript definitions, server names with hyphens or dots are converted to valid TS identifiers (e.g., git-hub -> git_hub).
    • The Gateway dispatch layer must maintain a reverse resolution map (_resolve_server) so mcp.git_hub.call() resolves back to target server git-hub.
  4. Environment isolation:
    • Run the sandbox subprocess with child_env({}) (restricted to safe system vars like PATH, SystemRoot) to prevent secret exfiltration from host environment variables.
    • Reference: AutoHarness child process isolation (https://github.com/D-Shey/autoharness).
  5. Resource cleanup:
    • In Python finally blocks, ensure proc.stdin.close(), proc.stdout.close(), proc.stderr.close() and proc.wait() are executed on all exit paths.

How to verify

  1. Test standalone execution without tool calls: return 1 + 1 yields 2.
  2. Test async MCP dispatch: call a mock tool through mcp.mock_server.test_tool({ count: 5 }) and verify correct RPC dispatch and argument forwarding.
  3. Test hanging async promise: verify that an unresolved Promise times out cleanly without blocking the gateway.
  4. Test hyphenated server name resolution: verify that server git-hub is callable via mcp.git_hub.

Facts found here

  • Standard MCP gateway metadata tools in AutoHarness are defined in src/autoharness/gateway.py.
  • MCP clients implement call_tool(tool_name, arguments) returning standard MCP tool call results.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.