@beeos-ai/acp-types
v0.1.0-beta.1
Published
TypeScript wire types for the BeeOS proxy ACP protocol (beeos-claw <-> web/mobile SDKs). Independent of upstream @agentclientprotocol/sdk.
Maintainers
Readme
@beeos-ai/acp-types
TypeScript wire types for the BeeOS proxy ACP protocol (agent client protocol speaker between
beeos-claw agent and web / mobile SDKs).
This package is the single source of truth for the JSON-over-WebSocket protocol that flows
between BeeOS agents and their front-end clients. It is independent of the upstream
@agentclientprotocol/sdk — BeeOS operates a proxy layer that adapts ACP for multi-tenant
cloud deployment.
Install
npm install @beeos-ai/acp-typesUsage
Consume types (client or agent side)
import type {
ServerSessionUpdate,
ClientSessionUpdate,
AgentMessageChunkUpdate,
ToolCallStartUpdate,
StreamCompleteOk,
StreamCompleteErr,
} from "@beeos-ai/acp-types";
function handle(update: ClientSessionUpdate) {
switch (update.sessionUpdate) {
case "agent_message_chunk":
// update.content is narrowed to TextBlock | ImageBlock | ResourceLinkBlock
break;
case "stream_complete":
if (update.stopReason === "error") {
// update.error is narrowed to string (required)
}
break;
// ...
}
}Produce messages (factories, type-safe, no as any)
import {
makeAgentMessageChunk,
makeToolCallStart,
makeStreamCompleteError,
} from "@beeos-ai/acp-types/factories";
const chunk = makeAgentMessageChunk("Hello", { _turnId: "run-abc" });
const err = makeStreamCompleteError("Provider timed out");Normalize snake_case payloads (legacy interop)
import { normalizeSessionUpdate } from "@beeos-ai/acp-types/normalize";
// Converts upstream snake_case keys (tool_call_id, raw_input) to camelCase
// and trims unknown fields before feeding to chat-store.
const camel = normalizeSessionUpdate(rawWireMessage);Design principles
- Protocol is a contract, not an implementation — types live in a versioned package so
beeos-claw,web, andmobiledepend on the same source. - Discriminated unions — every
sessionUpdatevariant and JSON-RPCmethodis a separate interface keyed by a string literal;switchstatements are provably exhaustive. - LSP subset —
ServerSessionUpdate ⊂ ClientSessionUpdate. The transport signature uses the narrower type, the reducer signature uses the wider one. - Zero runtime deps —
@a2ui/reactand other UI frameworks are decoupled via genericCanvasUpdateEnvelope<TMessage = unknown>; consumers instantiate with their message type. - Branded IDs —
JsonRpcId,SessionId,ToolCallId,MessageIdare nominal string types preventing accidental cross-use.
Package layout
src/
├── index.ts # public barrel
├── meta.ts # ACP_PROTOCOL_VERSION, ResponseMeta
├── ids.ts # branded IDs
├── enums.ts # ToolKind / ToolStatus / StopReason / MessageRole
├── run-outcome.ts # RunOutcomeShape for prompt termination
├── normalize.ts # runtime snake_case ↔ camelCase helper
├── content/ # ContentBlock variants (Text/Image/Audio/File/Resource/ResourceLink)
├── session-update/ # 16 sessionUpdate variants + ServerSessionUpdate / ClientSessionUpdate
├── json-rpc/ # envelope + 29 method-specific params/results + registry
└── factories/ # type-safe builders (replaces all `as unknown as ACPUpdatePayload`)Versioning
0.x— experimental; breaking changes allowed between minors.- Future
1.0— API stable; breaking changes only at majors.
Compatible with:
beeos-claw>= 0.2.41@beeos/sdk(web/mobile) via facade re-exports
License
MIT
