feat(agent): agent-native wave phase 2 — fetch handler, read_state, commands bridge, git agent tools - #144
Closed
antfubot wants to merge 1 commit into
Closed
Conversation
…ommands bridge, git agent tools - createMcpFetchHandler: framework-agnostic web-standard MCP endpoint extracted from mountMcpHttp (now a thin h3 wrapper); exported from devframe/adapters/mcp for custom hosts (Next App Router, etc.) - built-in read_state(key?) MCP tool over shared state, honoring the exposeSharedState filter alongside the resource projection - hub commands gain opt-in agent exposure: agent field (description, safety, valibot args) projects handler-bearing commands into ctx.agent; DF8404 rejects agent exposure on group-only commands - valibot→JSON-Schema conversion moved to devframe/utils/valibot-json-schema (public) so SDK-free hosts can convert schemas - rpc: schema-typed handlers may be async — Thenable<InferReturnType<RS>> in the schema-typed definition branch - git plugin: status/log/show/branches/diff agent-flagged with valibot args/returns schemas (read-only surface; writes stay private) - docs: hub commands-as-tools, read_state, custom-host mounting; DF8404 page
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Phase 2 of plan 031 (stacked on #142). The MCP endpoint was h3-only, shared state was invisible to tools-only MCP clients, hub commands had no path to the agent surface, and the git plugin's read RPCs — the most obviously agent-useful data in the workbench — weren't exposed.
What
createMcpFetchHandler(ctx, options)— the MCP Streamable-HTTP endpoint as a framework-agnostic web-standardRequest → Responsehandler (sessions, origin gate, teardown included).mountMcpHttpis now a thin h3 wrapper over it. This is the enabler for serving MCP from inside non-h3 hosts (@devframes/next, phase 3).read_statetool — tool-shaped shared-state access (no key → key list, key → JSON value), honoring the sameexposeSharedStatefilter as the resource projection. Many MCP clients only consume tools; the resources stay for those that don't.agentfield on server commands (same default-deny convention asdefineRpcFunction): description-as-prompt,safety(defaultaction), optional positional valibotargs(single object unwrapped). Projections track register/update/unregister.agenton a handler-less group throws the new DF8404 (docs page included); the field never crosses the wire.devframe/utils/valibot-json-schema— the valibot→JSON-Schema conversion promoted from an MCP-adapter internal to a public util, so SDK-free hosts (the hub) can convert schemas.Thenable<InferReturnType<RS>>(explicitRS⇒ no inference risk; sync handlers stay assignable). This unblocks schema-typing genuinely-async RPCs — the limitation plan 001 previously hit.status/log/show/branches/diffagent-flagged with args/returns schemas (safety: 'read'inferred). Write ops stay agent-invisible. Cross-refs plan 029.Verification
Full gate:
pnpm lint && pnpm test && pnpm typecheck && pnpm build— 896 tests (10 new: read_state list/read/filter/deny, commands-bridge projection/re-sync/zero-arg/DF8404/wire-stripping); API snapshots updated deliberately.This PR was created with the help of an agent.