@uncaged/nerve-core
v0.5.0
Published
Shared types and configuration parser for the [nerve](../../README.md) observation engine.
Readme
@uncaged/nerve-core
Shared types and configuration parser for the nerve observation engine.
What's Inside
- Type definitions —
Signal,SenseConfig,SenseInfo,SenseReflexConfig,ReflexConfig(sense-only),WorkflowConfig,NerveConfig, and related types - Config parser —
parseNerveConfig(yaml)validates and parsesnerve.yamlintoNerveConfig(rejects reflex entries that declare aworkflowkey; reflexes only schedule senses) - Sense → workflow routing —
parseSenseWorkflowDirective,routeSenseComputeOutput, and typesParsedSenseWorkflowDirective,SenseComputeRoute - 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,SenseResult, 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, Signal, Result } from "@uncaged/nerve-core";
const result: Result<NerveConfig> = parseNerveConfig(yamlString);
if (result.ok) {
console.log(result.value.senses);
}Sense return → signal vs workflow
import { parseSenseWorkflowDirective, routeSenseComputeOutput } from "@uncaged/nerve-core";
const directive = parseSenseWorkflowDirective("my-workflow|8|Hello from sense");
if (directive.ok) {
console.log(directive.value.workflowName, directive.value.maxRounds, directive.value.prompt);
}
const route = routeSenseComputeOutput({
metric: 42,
workflow: "my-workflow|8|Run now",
});
if (route.kind === "launch") {
// engine starts workflow; no Signal to the bus for this return
console.log(route.launch);
} else {
// normal signal with payload
console.log(route.payload);
}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-coreLicense
MIT
