Skip to content

examples/rsc-agent-runtime: adopt the public agent-bundle/mcp-entry stdio lifecycle (RFC #50 Phase 2) - #57

Merged
ScriptedAlchemy merged 2 commits into
mainfrom
feat/rsc-runtime-phase2
Aug 31, 2026
Merged

examples/rsc-agent-runtime: adopt the public agent-bundle/mcp-entry stdio lifecycle (RFC #50 Phase 2)#57
ScriptedAlchemy merged 2 commits into
mainfrom
feat/rsc-runtime-phase2

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

Phase-2 executor task for RFC #50 (plan §1.4), scoped to examples/rsc-agent-runtime — the "framework lifecycle without framework build" witness: the public agent-bundle/mcp-entry API under a consumer-owned bundler and the v1.x MCP SDK.

  • src/mcp/stdio.ts replaces its naive run().catch bootstrap (no console guard, no SIGINT/SIGTERM, no stdin-EOF, no bounded shutdown — the RFC §1.2 asymmetry) with the public lifecycle API: redirectConsoleToStderr installs the stdout guard before the server module and SDK evaluate (both deferred via dynamic import, mirroring the generated shell's deferral), then runStdioServer owns SIGINT→130, SIGTERM→143, stdin-EOF→0, transport-close→0, the 5 s bounded shutdown, and [rsc-agent-runtime]-attributed heartbeats over the demo's own v1.30 StdioServerTransport.
  • Q1 resolution (export stability): confirmed against merged feat(build): agent-bundle owns the package build — bin/lib, entry conventions, stdio entry shell, tools hatch, mcp run (RFC #50 Phase 1) #52packages/agent-bundle/package.json ships the ./mcp-entry export with redirectConsoleToStderr / runStdioServer under exactly those names, and the option types are structural (LifecycleServer / LifecycleTransport). The v1.30 SDK's McpServer and StdioServerTransport satisfy them with zero casts (root tsc proves it). The generated shell was deliberately not used: it hard-imports the v2 SDK this demo doesn't depend on, and the entry must stay compiled by the demo's rsbuild at the stable dist/runtime/mcp/stdio.js path pinned by packaging/*/.mcp.json args and the transport/host tests. The import bundles into the entry (rsc environment bundles dependencies); agent-bundle was already a devDependency — no pnpm-lock.yaml change.
  • tests/mcp-transports.integration.test.ts gains one lifecycle test: raw JSON-RPC initialize handshake (proves handlers install before we act and that the guard handed stdout back for clean protocol frames), then stdin-EOF→exit 0, SIGINT→130, SIGTERM→143, plus the heartbeat activity line on stderr. All pre-existing assertions untouched.
  • README.md adds one sentence to the ownership-boundary paragraph noting the stdio entry consumes the framework lifecycle via agent-bundle/mcp-entry while remaining self-built. package.json build script byte-identical; no docs-contract.test.ts pins touched.
  • docs/architecture/rsc-runtime-workbench.md regenerated: one line (tests/public-api-packed.test.ts) was already stale on main from feat(build): agent-bundle owns the package build — bin/lib, entry conventions, stdio entry shell, tools hatch, mcp run (RFC #50 Phase 1) #52; this example's edits contribute nothing else.

Everything else in the example (rsbuild config, entry wiring, package-hosts.mjs, packaging/, http entry, hook CLI) stays by design per the plan; the packaging/hook unification is the recorded Phase-3 candidate (plan Q9).

Verification

  • pnpm --filter @agent-bundle/rsc-agent-runtime-demo check — 15 files, 176 tests: 170 pass, 6 documented platform skips, 0 failures (rsbuild build + package:hosts + full suite + example typecheck)
  • pnpm check:runtime-topology — green after regeneration
  • pnpm eval:spot — green
  • Root pnpm typecheck + pnpm lint — green
  • Downstream smoke: packages/workbench/tests/runtime-playground.e2e.test.ts via the integration config with prebuilt flags — green

…cp-entry lifecycle in the self-built stdio entry (RFC #50 Phase 2)

The demo's stdio MCP entry replaces its naive run().catch bootstrap (no
console guard, no signals, no stdin-EOF, no bounded shutdown) with the
framework's public lifecycle API: redirectConsoleToStderr installs the
stdout guard before the server module and v1.30 SDK evaluate (both
deferred via dynamic import, mirroring the generated shell), then
runStdioServer owns SIGINT->130, SIGTERM->143, stdin-EOF->0, bounded
shutdown, and heartbeat attribution over the demo's own SDK transport.
The entry stays compiled by the demo's rsbuild at the stable
dist/runtime/mcp/stdio.js path pinned by packaging and tests; the
structural lifecycle types accept the v1.x SDK without migration and
the import bundles into the entry (no lockfile change).

The transport suite gains a lifecycle test (handshake-then-act exit
codes plus heartbeat), the README ownership-boundary paragraph notes
the entry consumes the framework lifecycle while remaining self-built,
and the generated topology doc is regenerated (one line stale on main
since #52).
@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d00847a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T02:32:51.309856Z 4c55eaf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@57
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/rsc-runtime@57

commit: d00847a

@ScriptedAlchemy
ScriptedAlchemy merged commit 4d3a35f into main Aug 31, 2026
9 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the feat/rsc-runtime-phase2 branch September 3, 2026 05:25
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