Skip to content

feat(bridge): run each task over the transport its app asks for - #54

Closed
ahmad-ajmal wants to merge 7 commits into
mainfrom
feat/transports-bridge
Closed

ahmad-ajmal wants to merge 7 commits into
mainfrom
feat/transports-bridge

Conversation

@ahmad-ajmal

Copy link
Copy Markdown
Collaborator

Stacked on #45, #46 and #48. Review only the last commit until those merge.

The bridge always told a harness to use the a2app CLI. It now follows the app's own order.

Bridge

  • For each task it uses the first of the app's transports that the run can reach, and writes the prompt for it (CLI, MCP or HTTP). The CLI prompt is unchanged except for one new line: a refusal from the app is its answer.
  • CLI needs a2app on PATH. MCP needs an app that serves it and a route that can take an MCP server for one run. HTTP needs a route that says its harness may send requests.
  • Over MCP the bridge writes a config file for that run, readable by this user only, with the app's address and the task's own credential. Only its path is on the command line. It is removed when the run ends; one left by a killed bridge is cleared a day later.
  • A2APP_TOKEN is still set on every run. Without it a stray a2app would use the app's admin credential.
  • harnesses.json routes gain transports and mcpArgs. The built-in claude route has mcpArgs; codex, gemini and aider stay CLI only.
  • An inbound or gateway route also gets the app's url, transports and mcpUrl, and which transport the prompt is for.
  • bridge, --dry-run and the log say which transport is used, and why when it is not the first one.

Plugins

  • A missing CLI is explained (starter, Hermes, CraftBot): how to install it, and that a running app can still be operated over MCP or HTTP.
  • Session texts no longer say a2app is the only way to operate an app.
  • READMEs say how a person adds an app's own MCP server. No plugin does it for them, because it puts a credential in their settings.

Account page (same file in all seven starters): under a new token it shows the app's MCP address.

Tested

  • pnpm -r build, typecheck and test; Hermes and CraftBot Python tests. Hermes' 24 dashboard tests need FastAPI and were skipped here.
  • New bridge-transport.test.mjs: choosing, prompts, route validation, and a real bridge run over MCP against a real adapter. Breaking the code in four places made it fail each time.
  • Real tasks on a scaffolded app, each done by an agent that saw only the bridge's prompt: the runs below.
  • The account page in a browser.
Run Picked Result
route with mcpArgs, app order mcp, cli, http MCP agent read the record, updated it, completed the task
same app, route without mcpArgs CLI, and the log says why same
same app, route with transports: ["http"] HTTP same

In each, the app kept the agent's own result, the credential was not in the arguments and was refused after the task, and no config file was left. The agents found two things in the prompts, both fixed: it did not say what to do when the app's screens name another transport first, and the HTTP line read as POST only.

All three also saw a module they could write to described as "read-only": an access label on main for partial access, not part of this change.

Not tested: a native claude run over MCP. claude is not logged in on this machine; its flags were checked against claude --help (2.1.50).

No protocol change. Two sentences in the spec say how the bridge hands over the credential and that it connects MCP for its own run.

…ose by that order

manifest.json may carry `transports`, an ordered list of cli, mcp and http. The
first is the app's primary channel and the rest are fallbacks; without it the
order is cli, mcp, http. Entries are kinds, never addresses. The gate checks it,
the builder may edit it, toolkit-sync keeps it, `scaffold --transport` puts one
first, and inspect reports it.

Identity gains optional `transports` and `mcpUrl` (published by adapters in a
later change). Arriving by CLI at an app that asks for another transport first
says so. Skills, AGENTS.md and the README say how to choose, and how to operate
over plain HTTP when there is no CLI.

Spec: spec/v0_2/transports.md.
…ame its app

adapter-core serves the app as an MCP server at POST /api/_a2app/mcp/<app id>.
Each tool call is one request through the adapter's own router, so the guard,
scopes, approval, idempotency, rate limits and audit are the ones HTTP callers
meet. Ten tools, the same in every app (spec/v0_2/mcp-tools.json); MCP
2026-07-28 and, without sessions, the three handshake revisions before it. The
caller is a credential, never a browser session.

HTTP callers may name the app they mean (X-A2App-App); another app answers 409
app_mismatch. The CLI names a verified remote app on every call, and reads
identity without its credential. Identity publishes `transports` and `mcpUrl`.

Conformance class D covers the binding, and the starter conformance checks it
against a running app on any stack.
Agents given only a task and an app picked the right transport each time, and
stopped at every refusal. What slowed them is fixed: tools take an entity or
operation by its own name, a declared operation is preferred over a raw write,
the HTTP routes are listed in full, what to do when a scope or an approval is
missing and the person can't be reached, and an MCP server that answers
app_mismatch is another app's.
A destructive operation may name a read-only `preview` that says what it would
do. Its answer comes with the 428, and the key covers it: when the answer
changes, nothing runs, and the caller is shown the new one. Anything else that
changes leaves the approval standing.

Two fixes for every destructive operation: a key works only for the credential
that asked, and a refused key always comes with one that works. A 428 says why
(`reason`: asked, changed, spent, mismatch).

The gate and the adapter refuse a preview that is not one. The sidecar runs an
adopted app's own read route. The CLI shows the preview before the line that
would run the call. The react-node starter's clear-done names list-done.

Spec: spec/v0_2/approvals.md.
The read-only check used the name as written and the route decodes it, so a
percent-encoded name ("clear%2Ddone") passed the check and ran. The name is
decoded once, checked, and sent as that one segment. Scopes always applied; what
was missing is the promise a harness relies on when it runs a read-only tool
without asking. Found by the Go port's comparison run.
The bridge told every harness to use the a2app CLI. It now uses the first of
the app's transports the run can reach, and writes the prompt for it.

Over MCP, the harness gets a configuration file for that one run with the app's
endpoint and the task's own credential: 0600, only its path in the arguments,
removed when the run ends. Routes in harnesses.json gain `transports` and
`mcpArgs`; the built-in claude route has the latter. An inbound route gets the
app's address, order and MCP endpoint in its body.

Plugins say what to do when the CLI is missing, and no longer call it the only
way to operate an app. The account page shows the app's MCP address beside a
new token.
@ahmad-ajmal

Copy link
Copy Markdown
Collaborator Author

Replaced by #56, with the same code. The branch is kept.

@ahmad-ajmal
ahmad-ajmal deleted the feat/transports-bridge branch December 2, 2026 11:18
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