fc7fc9158c
Phase 4 of RFC #308: Stateful Sense refactor. - CLAUDE.md: updated diagram, tables, examples (no more Signal) - Cleaned stale Signal Bus / DrizzleDB / _signals / retention refs across READMEs, .cursor rules, copilot instructions, .knowledge - Removed drizzle-orm from core package.json (no longer used) - Updated pnpm-lock.yaml Refs #308
2.3 KiB
2.3 KiB
@uncaged/nerve-core
Shared types and configuration parser for the nerve observation engine.
What's Inside
- Type definitions —
SenseConfig,SenseInfo,SenseComputeFn,SenseModule,WorkflowConfig,NerveConfig,WorkflowTrigger, and related types - Config parser —
parseNerveConfig(yaml)validates and parsesnerve.yamlintoNerveConfig(top-levelreflexesis rejected; useinterval/onon each sense) - Workflow triggers —
parseWorkflowTriggervalidates structured workflow launch objects from Sense compute results or IPC - Daemon IPC protocol — request/response types (
DaemonIpcRequest,DaemonIpcResponse, …) andparseDaemonIpcRequestfor newline-delimited JSON on the CLI ↔ daemon socket - Workflow automaton types —
START/ENDsentinel constants,WorkflowMessage,StartStep,RoleStep,ModeratorContext(start+steps; emptystepson first moderator call),Moderator(singlecontextargument),WorkflowDefinition,Role,RoleResult, plusDEFAULT_ENGINE_MAX_ROUNDS - Result type —
Result<T>withok()/err()helpers for explicit error handling (no thrown exceptions for parse paths)
Usage
import { parseNerveConfig, ok, err } from "@uncaged/nerve-core";
import type { NerveConfig, Result } from "@uncaged/nerve-core";
const result: Result<NerveConfig> = parseNerveConfig(yamlString);
if (result.ok) {
console.log(result.value.senses);
}
Workflow trigger validation
import { parseWorkflowTrigger } from "@uncaged/nerve-core";
const directive = parseWorkflowTrigger({
name: "my-workflow",
maxRounds: 8,
prompt: "Hello from sense",
dryRun: false,
});
if (directive.ok) {
console.log(directive.value.name, directive.value.maxRounds, directive.value.prompt);
}
Sense modules return { state, workflow } from compute(state); when workflow is non-null it must satisfy the shape validated by parseWorkflowTrigger (the daemon validates before starting a run).
Duration Format
Config fields like throttle, timeout, and interval accept human-readable durations:
5s— 5 seconds10m— 10 minutes1h— 1 hour
Install
pnpm add @uncaged/nerve-core
License
MIT