Skip to content

feat(core): control-plane action registry for host-UI dispatch#105

Merged
vreshch merged 1 commit intomasterfrom
feature/control-plane
Apr 17, 2026
Merged

feat(core): control-plane action registry for host-UI dispatch#105
vreshch merged 1 commit intomasterfrom
feature/control-plane

Conversation

@vreshch
Copy link
Copy Markdown
Contributor

@vreshch vreshch commented Apr 17, 2026

Summary

Adds @agentage/core/control — a transport-agnostic action registry so host UIs (desktop, web dashboard, future MCP clients) can dispatch control-plane actions into the local env. First three proof-of-shape actions: cli:update, project:addFromOrigin, agent:install.

Motivation: today there's no unified way for a UI to ask "what actions can I invoke on this machine?" and dispatch them with validation, auth, idempotency, and streaming progress. The CLI daemon, web backend, and desktop IPC each have ad-hoc route handlers. This module gives all of them one shape to wire up.

Design

  • Transport-agnostic core. Registry yields InvokeEvent (acceptedprogress*result | error). REST, WS, Electron IPC, and MCP tools/call are thin adapters over this stream.
  • Typed definitions. action<I, O, P>({ manifest, validateInput?, execute })execute is an AsyncGenerator<P, O> so progress events and final result share one control flow.
  • Closed error union. ActionErrorCode = UNKNOWN_ACTION | UNKNOWN_VERSION | INVALID_INPUT | UNAUTHORIZED | DEPRECATED | DUPLICATE_INVOCATION | EXECUTION_FAILED | CANCELED, each with a retryable flag.
  • Capabilities. Flat string set with * wildcard; transport layer maps session → caps.
  • Idempotency. Keyed on action@version#idempotencyKey; replays emit DUPLICATE_INVOCATION.
  • Versioning. Multiple versions of the same action can coexist; get(name) picks the highest, get(name, version) is explicit. deprecatedSince on the manifest short-circuits invoke.
  • Cancellation. Callers pass an AbortSignal; the invoke loop checks before each yield and returns CANCELED.

Sample actions take an injected ShellExec so they're pure and testable — the host wires in core's shell adapter (or a stub).

Changes

  • packages/core/src/control/
    • types.tsActionDefinition, ActionManifest, ActionContext, InvokeRequest/Event, ActionRegistry
    • action.ts — identity builder (matches the tool() / mcp() pattern)
    • registry.tscreateRegistry() with list/get/invoke + idempotency map
    • errors.tsActionError + isActionError
    • actions/{cli-update,project-add-from-origin,agent-install}.ts — three reference actions
    • actions/types.tsShellExec DI interface
    • Tests for registry (auth, validation, versioning, idempotency, cancel, deprecated) and each sample action with stubbed shell
  • packages/core/src/index.ts — re-exports the control module from the top-level barrel

Next steps (not in this PR)

  1. cli/daemon: instantiate registry, register actions, add POST /api/actions/:name route + WS handler forwarding the InvokeEvent stream.
  2. desktop: IPC channel action:invoke that proxies to daemon (or runs its own registry for local-only actions).
  3. MCP façade: tools/listregistry.list(), tools/callregistry.invoke().

Test plan

  • npm run verify — type-check + lint + format + 145 tests + build, all green
  • Wire cli/daemon route layer against the registry (follow-up PR)
  • Dogfood cli:update end-to-end from desktop against a local daemon (follow-up)

Adds @agentage/core/control — a transport-agnostic action registry that
lets host UIs (desktop, web, MCP clients) dispatch actions into the
local env (e.g. update CLI, add project from origin, install agent).

- action() builder + createRegistry() with list/get/invoke
- Streaming InvokeEvent envelope (accepted → progress* → result|error)
- Capability-based auth, idempotency dedup, versioning, deprecation,
  cancellation via AbortSignal
- Three reference actions as factories with injected ShellExec:
  cli:update, project:addFromOrigin, agent:install
- 22 new tests; full verify green (145 tests total)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

🎉 PR Validation ✅ PASSED

Commit: 6dc9f35b816421fd018ca73da7c22484f5dfa1e7
Branch: feature/control-plane

Checks:

  • ✅ Release guard (no version/changelog changes)
  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests + coverage passed
  • ✅ Build successful

Ready to merge!


🔗 View workflow run
⏰ Generated at: 2026-04-17T22:57:56.035Z

@vreshch vreshch merged commit 90295bc into master Apr 17, 2026
2 checks passed
@vreshch vreshch deleted the feature/control-plane branch April 17, 2026 23:03
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