@openclawbrain/contracts
v0.3.1
Published
Learning-first OpenClawBrain contracts, route_fn-aware validators, and checksum helpers.
Maintainers
Readme
@openclawbrain/contracts
Canonical OpenClawBrain contracts for learning-first packs, compile payloads, and artifact validation.
This package is the starting point if you need the public payload shapes without pulling in pack loading or compilation logic.
If you want narrower public surfaces, the workspace also publishes @openclawbrain/events, @openclawbrain/event-export, @openclawbrain/workspace-metadata, and @openclawbrain/provenance.
Install
pnpm add @openclawbrain/contractsIncludes
- contract ids for runtime compile, interaction events, feedback events, manifests, activation pointers, and Wave 1 operator noun/status payloads
- runtime compile request/response types for explicit budgets, native structural compaction, and learned-route evidence
- brain-attachment policy, per-turn attribution with explicit profile-id reporting, and current-profile brain-status shapes for operator/API coordination
- init-graph schema ids, typed markdown file-role classification, and ontology-backed graph metadata
- route policy, router identity, workspace metadata, and pack provenance shapes
- optional init-seed block metadata for deterministic role/authority/recency-based route priors
- payload validators for the current
v1public shapes - canonical JSON and checksum helpers for immutable artifact payloads
Example
import {
buildNormalizedEventExport,
CONTRACT_IDS,
checksumJsonPayload,
createFeedbackEvent,
createInteractionEvent,
validateRuntimeCompileRequest
} from "@openclawbrain/contracts";
const request = {
contract: CONTRACT_IDS.runtimeCompile,
agentId: "agent-1",
userMessage: "compile feedback context",
maxContextBlocks: 3,
maxContextChars: 1600,
modeRequested: "heuristic",
compactionMode: "native"
} as const;
const errors = validateRuntimeCompileRequest(request);
const checksum = checksumJsonPayload(request);
const eventExport = buildNormalizedEventExport({
interactionEvents: [
createInteractionEvent({
eventId: "evt-1",
agentId: "agent-1",
sessionId: "session-1",
channel: "cli",
sequence: 10,
kind: "memory_compiled",
createdAt: "2026-03-06T00:10:00.000Z",
source: { runtimeOwner: "openclaw", stream: "openclaw/runtime/demo" }
})
],
feedbackEvents: [
createFeedbackEvent({
eventId: "evt-2",
agentId: "agent-1",
sessionId: "session-1",
channel: "cli",
sequence: 11,
kind: "teaching",
createdAt: "2026-03-06T00:11:00.000Z",
source: { runtimeOwner: "openclaw", stream: "openclaw/runtime/demo" },
content: "Promote the pack only after validation."
})
]
});