This repository has been archived on 2026-06-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
xiaoju fc7fc9158c docs: update all docs/conventions for stateful sense, remove stale refs
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
2026-05-01 10:09:01 +00:00
..

@uncaged/nerve-core

Shared types and configuration parser for the nerve observation engine.

What's Inside

  • Type definitionsSenseConfig, SenseInfo, SenseComputeFn, SenseModule, WorkflowConfig, NerveConfig, WorkflowTrigger, and related types
  • Config parserparseNerveConfig(yaml) validates and parses nerve.yaml into NerveConfig (top-level reflexes is rejected; use interval / on on each sense)
  • Workflow triggersparseWorkflowTrigger validates structured workflow launch objects from Sense compute results or IPC
  • Daemon IPC protocol — request/response types (DaemonIpcRequest, DaemonIpcResponse, …) and parseDaemonIpcRequest for newline-delimited JSON on the CLI ↔ daemon socket
  • Workflow automaton typesSTART / END sentinel constants, WorkflowMessage, StartStep, RoleStep, ModeratorContext (start + steps; empty steps on first moderator call), Moderator (single context argument), WorkflowDefinition, Role, RoleResult, plus DEFAULT_ENGINE_MAX_ROUNDS
  • Result typeResult<T> with ok() / 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 seconds
  • 10m — 10 minutes
  • 1h — 1 hour

Install

pnpm add @uncaged/nerve-core

License

MIT