Skip to content

docs(mcp): serveApp is a host-process API; a routed CLI command spawns agent-bundle serve-app (#558) - #560

Merged
ScriptedAlchemy merged 4 commits into
mainfrom
docs/serve-app-consumer-shape
Sep 4, 2026
Merged

docs(mcp): serveApp is a host-process API; a routed CLI command spawns agent-bundle serve-app (#558)#560
ScriptedAlchemy merged 4 commits into
mainfrom
docs/serve-app-consumer-shape

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Tracks #558.

What

Corrects the serveApp documentation from #537, which showed a plugin's routed CLI route doing const { serveApp } = await import('agent-bundle/api'). That shape does not build inside a plugin (constraints and options laid out in #558):

Proven by the first consumer: ScriptedAlchemy/cargo-hauler#83 (merged as 395cee062, agent-bundle pinned at c2ffe5e; nothing in validate-artifact-modules.ts, cli-bins.ts, rslib.ts, serve-app/**, or api.ts has changed on main since) shipped hauler dashboard as a plain routed command that spawns agent-bundle serve-app hauler/dashboard --tool hauler_status --allow call-tool … as a child process, and had to document it as a checkout-only command.

Docs changes (en + zh)

  • guide/authoring/mcp.mdx, "Serving an App standalone": serveApp is a host-process API (the first-party CLI, the Workbench, tests, a plugin's own package.json scripts or a hand-written .mjs run from the checkout); a routed CLI command inside the artifact cannot import it today, with the exact failure modes above; the sample is replaced by the pattern that builds — framework CLI resolved by path from the bin of node_modules/agent-bundle, serve-app argv, the child's stdout relayed to stderr with url parsed from the MCP App <app> at <url> line, route signal → child SIGTERM, exit code relayed through config.exitCode: 'result' — stated as a checkout-only command, with Let a plugin CLI route serve its own MCP App without bundling the framework #558 linked.
  • reference/api.mdx (agent-bundle/api row) and reference/cli.mdx (serve-app): one-clause corrections pointing at the guide section.
  • docs/entry-conventions.md (agent-bundle serve-app) and docs/framework-mode.md: the same correction in the internal docs.
  • packages/agent-bundle/src/api.ts: the serveApp JSDoc — the source of the generated Type API page /api/functions/api.serveApp — no longer says a routed CLI route can call it. Comment-only, no behavior change, hence skip-changeset.
  • .changeset/514-serve-app.md (the pending feat(cli): serve a built MCP App standalone — agent-bundle serve-app and serveApp in agent-bundle/api (#514) #537 release note): its last clause promised the same route shape; now says the CLI route spawns agent-bundle serve-app (Let a plugin CLI route serve its own MCP App without bundling the framework #558). Pending changeset text, not CHANGELOG.md.

Verification

  • pnpm docs:site:build ✓ — typecheck, TypeDoc, Rspress build, dead-link/anchor/image checks, language parity.
  • The new sample was extracted verbatim from the en page into examples/host-test/src/cli/dashboard.ts (not committed; the example already has routed CLI routes and @agent-bundle/runtime): tsc ✓; agent-bundle build ✓ for claude/codex/cursor/portable with artifact validation passing (no AB6005), and the emitted bins carry no residual agent-bundle import. node dist/bin/host-test.js dashboard --help lists the command; node dist/bin/host-test.js dashboard --no-open --json resolved the framework CLI from node_modules/agent-bundle, spawned serve-app, relayed the child's — expected, host-test has no hauler server — AB5000 diagnostic on stderr, and returned {"exitCode":1,"message":"agent-bundle serve-app exited with 1","url":null} with process exit code 1 through config.exitCode: 'result'. Success path: the sample's spawn/parse code, verbatim except for the App and tool names, was run from a /tmp script against examples/mcp-app's built artifact (serve-app status/status --tool show-status): the URL was parsed from the MCP App status/status at http://127.0.0.1:37915/ (…) line, GET on it returned 200 with <title>status/status</title>, and aborting the signal sent SIGTERM to the child, which exited 0 with the port released. The same argv shape is what cargo-hauler#83 verified live on 641e230.
  • The zh code block is byte-identical to the en block apart from comment lines (checked by script).
  • pnpm typecheck ✓ · pnpm lint ✓ · pnpm test:unit 3364/3372 with two load-induced 5 s timeouts (inspect-state.test.ts, rendered-skills.test.ts) that pass in isolation (19/19); the only package-source change is a JSDoc comment.

Review threads (Codex, reviewed 06317fb)

No PR comments are posted from this side; each thread is answered here.

  • P2 website/docs/en/guide/authoring/mcp.mdx:746 — accumulate stdout before parsing the served URL. Accepted. d6c4971 buffers the child's stdout to whole lines before matching (a write can arrive split across data events), in the en and zh samples alike; the success-path run above exercises the buffered parse.

Self-review

No reviewer subagent was spawned (the task ran with subagents disallowed); author self-review against origin/main, findings and dispositions:

  • The sample passes --target portable where feat(cli): serve a built MCP App standalone — agent-bundle serve-app and serveApp in agent-bundle/api (#514) #537's sample passed cursor → deliberate: portable is serve-app's default and the one target every build produces; cargo-hauler exposes the choice as --target, which the sample omits for brevity.
  • The sample derives the checkout root from import.meta.url (dist/bin/<plugin>.js → two levels up), which is right for the package bin but not for the artifact-hosted bin/<plugin>.mjs, whose parent is the artifact target root → covered by the guard: the artifact-hosted copy finds no artifact/agent-bundle.manifest.json there and returns the checkout-only message instead of spawning; the prose states the command is checkout-only.
  • reference/cli.mdx still documents serve-app in full; only the "programmatic form" sentence changed, so no CLI behavior is described differently.
  • Generated Type API: the serveApp JSDoc now names AB6005 and Let a plugin CLI route serve its own MCP App without bundling the framework #558; the TypeDoc build passed and the rendered page carries the text.

No PR comments are posted from this side; notes live here.

…s agent-bundle serve-app (#558)

The #537 docs showed a plugin route doing await import('agent-bundle/api'). That does not build: routed CLI bins are self-contained, so the bundler inlines the compiler and fails on its runtime-relative module references, and the external or non-literal escapes are AB6005. State the real audience of serveApp (CLI, Workbench, tests, a plugin's own scripts), name the constraint, and show the child-process spawn pattern cargo-hauler shipped, with #558 linked.
@ScriptedAlchemy ScriptedAlchemy added documentation Improvements or additions to documentation skip-changeset PR changes a publishable package but ships no observable change; changeset not required labels Sep 4, 2026
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 64cdb5c

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 changesets to release 1 package
Name Type
agent-bundle Patch

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 Sep 4, 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-09-04T22:07:08.149070Z 06317fb 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 Sep 4, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@560
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@560
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/rsc-markdown-stream@560
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@560

commit: 64cdb5c

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06317fbf3d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread website/docs/en/guide/authoring/mcp.mdx Outdated
ScriptedAlchemy and others added 2 commits September 4, 2026 22:13
…hboard sample

A child stdout write can arrive split across data events; buffer to newlines before matching, as cargo-hauler's route does. Addresses the Codex P2 thread on #560.
@ScriptedAlchemy
ScriptedAlchemy enabled auto-merge (squash) September 4, 2026 22:19
@ScriptedAlchemy
ScriptedAlchemy merged commit 4e610e6 into main Sep 4, 2026
14 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the docs/serve-app-consumer-shape branch September 4, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation skip-changeset PR changes a publishable package but ships no observable change; changeset not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant