Skip to content
ContractSpec
Start here

Package manual · examples

·Examples and implementation patterns

example.draft-and-send-agent

CommunicationOS-shaped draft-and-send reference agent: draft a message, wait for approval, then send it through an approval-gated ContractSpec operation.

examplesexamplev3.0.4stableservernode
@lssm-tech/example.draft-and-send-agent
bun add @lssm-tech/example.draft-and-send-agent
Package source ↗Manifest ↗

Manifest declarations describe the current workspace; they do not verify registry publication or runtime execution.

Package guide

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) — one AgentSpec with a draftMessage tool (operationRef, automation-safe) and a sendMessage tool (operationRef, requiresApproval: true).
  • DraftAndSendWorkflow (src/workflow/draft-and-send.workflow.ts) — one WorkflowSpec wiring draft → approval-wait → send → receipt, executed through the Workflow DevKit runtime adapter (runWorkflowSpecWithWorkflowDevkit).
  • Operations (src/contracts/) — draftAndSend.draftMessage and the approval-gated draftAndSend.sendMessage.
  • createDraftAndSendRegistry() (src/handlers/) — an OperationSpecRegistry with both commands and trivial handlers bound.

Proof

  • src/draft-and-send.workflow.test.ts runs the full lifecycle through the Workflow DevKit adapter, issuing a real approval receipt for the send step.
  • src/mcp-smoke.test.ts starts a real MCP server (registerMcpTools) over an in-memory transport and drives one allowed sendMessage call plus denied calls (missing / tampered receipt → APPROVAL_REQUIRED).
bash
bun test

Relationships

THIS PACKAGEexample.draft-and-send-agent9 import paths

Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.

2 declarations

Declared capabilities

This manifest does not declare a capability catalogue. Use the guide, import map and source to assess the package.

Scripts

  • buildcontractspec-bun-build build
  • build:bundlecontractspec-bun-build transpile
  • build:typescontractspec-bun-build types
  • devcontractspec-bun-build dev
  • cleanrimraf dist .turbo
  • lintbun lint:fix
  • lint:fixnode ../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../scripts/biome.cjs check --write .
  • lint:checknode ../../scripts/biome.cjs check .
  • testbun test
  • preflightbun run build && bun run typecheck && bun run test
  • prebuildcontractspec-bun-build prebuild
  • typechecktsgo --noEmit