@lssm/example.draft-and-send-agent
v3.0.1
Published
CommunicationOS-shaped draft-and-send reference agent: draft a message, wait for approval, then send it through an approval-gated ContractSpec operation.
Readme
@lssm/example.draft-and-send-agent
CommunicationOS-shaped draft-and-send reference agent for ContractSpec.
It exercises exactly the primitives that already exist: approval-gated external
effect (execution.approval) and draft-only-by-default agent tools
(automationSafe / requiresApproval). The domain is intentionally trivial —
a message body plus a target channel — so no product-specific schema leaks into
core packages.
Surfaces
DraftAndSendAgent(src/agent/draft-and-send.agent.ts) — oneAgentSpecwith adraftMessagetool (operationRef, automation-safe) and asendMessagetool (operationRef,requiresApproval: true).DraftAndSendWorkflow(src/workflow/draft-and-send.workflow.ts) — oneWorkflowSpecwiringdraft → approval-wait → send → receipt, executed through the Workflow DevKit runtime adapter (runWorkflowSpecWithWorkflowDevkit).- Operations (
src/contracts/) —draftAndSend.draftMessageand the approval-gateddraftAndSend.sendMessage. createDraftAndSendRegistry()(src/handlers/) — anOperationSpecRegistrywith both commands and trivial handlers bound.
Proof
src/draft-and-send.workflow.test.tsruns the full lifecycle through the Workflow DevKit adapter, issuing a real approval receipt for the send step.src/mcp-smoke.test.tsstarts a real MCP server (registerMcpTools) over an in-memory transport and drives one allowedsendMessagecall plus denied calls (missing / tampered receipt →APPROVAL_REQUIRED).
bun test