feat: Phase 1 — CAS thread storage types + helpers
- Add StartNode, StateNode, ContentMerkleNode types to workflow-protocol - Add collectRefs() to workflow-cas — extracts CAS hashes from StateNode payload - Add findReachableHashes() to workflow-cas — recursive mark traversal via refs[] - Tests: 7 pass (collect-refs + reachable) Refs #155, closes #156 小橘 <xiaoju@shazhou.work>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// ── CAS thread chain nodes (RFC: CAS-based thread storage) ──────────
|
||||
|
||||
export type StartNodePayload = {
|
||||
name: string;
|
||||
hash: string;
|
||||
maxRounds: number;
|
||||
depth: number;
|
||||
};
|
||||
|
||||
export type StartNode = {
|
||||
type: "start";
|
||||
payload: StartNodePayload;
|
||||
refs: string[];
|
||||
};
|
||||
|
||||
export type StateNodePayload = {
|
||||
role: string;
|
||||
meta: Record<string, unknown>;
|
||||
start: string;
|
||||
content: string;
|
||||
ancestors: string[];
|
||||
compact: string | null;
|
||||
timestamp: number;
|
||||
};
|
||||
|
||||
export type StateNode = {
|
||||
type: "state";
|
||||
payload: StateNodePayload;
|
||||
refs: string[];
|
||||
};
|
||||
|
||||
export type ContentMerkleNode = {
|
||||
type: "content";
|
||||
payload: string;
|
||||
refs: string[];
|
||||
};
|
||||
@@ -1,40 +1,46 @@
|
||||
// ── Types ──────────────────────────────────────────────────────────
|
||||
|
||||
export type {
|
||||
Result,
|
||||
CasStore,
|
||||
WorkflowRoleSchema,
|
||||
WorkflowRoleDescriptor,
|
||||
WorkflowDescriptor,
|
||||
RoleMeta,
|
||||
RoleOutput,
|
||||
StartStep,
|
||||
RoleStep,
|
||||
ThreadContext,
|
||||
ModeratorContext,
|
||||
AgentContext,
|
||||
ExtractContext,
|
||||
WorkflowCompletion,
|
||||
WorkflowResult,
|
||||
LlmProvider,
|
||||
ProviderConfig,
|
||||
ResolvedModel,
|
||||
WorkflowConfig,
|
||||
ExtractFn,
|
||||
AgentFn,
|
||||
AgentBinding,
|
||||
WorkflowRuntime,
|
||||
WorkflowFn,
|
||||
RoleDefinition,
|
||||
Moderator,
|
||||
WorkflowDefinition,
|
||||
AdvanceOutcome,
|
||||
ContentMerkleNode,
|
||||
StartNode,
|
||||
StateNode,
|
||||
} from "./cas-types.js";
|
||||
|
||||
export type {
|
||||
AdvanceOutcome,
|
||||
AgentBinding,
|
||||
AgentContext,
|
||||
AgentFn,
|
||||
CasStore,
|
||||
ExtractContext,
|
||||
ExtractFn,
|
||||
LlmProvider,
|
||||
Moderator,
|
||||
ModeratorContext,
|
||||
ProviderConfig,
|
||||
ResolvedModel,
|
||||
Result,
|
||||
RoleDefinition,
|
||||
RoleMeta,
|
||||
RoleOutput,
|
||||
RoleStep,
|
||||
StartStep,
|
||||
ThreadContext,
|
||||
WorkflowCompletion,
|
||||
WorkflowConfig,
|
||||
WorkflowDefinition,
|
||||
WorkflowDescriptor,
|
||||
WorkflowFn,
|
||||
WorkflowResult,
|
||||
WorkflowRoleDescriptor,
|
||||
WorkflowRoleSchema,
|
||||
WorkflowRuntime,
|
||||
} from "./types.js";
|
||||
|
||||
// ── Constants ──────────────────────────────────────────────────────
|
||||
|
||||
export { START, END } from "./types.js";
|
||||
export { END, START } from "./types.js";
|
||||
|
||||
// ── Constructor functions ──────────────────────────────────────────
|
||||
|
||||
export { ok, err } from "./result.js";
|
||||
export { err, ok } from "./result.js";
|
||||
|
||||
Reference in New Issue
Block a user