Files
united-workforce/packages/workflow-protocol
xiaoju 1e9900bed3 feat(#194): Phase 2 — Engine layer Merkle call stack wiring
- Protocol: AgentFnResult = string | { output, childThread }, RoleOutput.childThread,
  ThreadContext.bundleHash for parent state lookup
- Runtime: create-workflow normalizes AgentFnResult, propagates childThread in RoleOutput
- Engine: ExecuteThreadOptions.parentStateHash, appendStateForStep writes childThread,
  putStartNode uses parentStateHash
- workflowAsAgent: reads parent head state from threads.json, passes parentStateHash
  to child, returns { output, childThread: rootHash }
- Integration test: 4 cases verifying bidirectional Merkle links (306 lines)

Phase 2 of #194 (Merkle Call Stack). Closes #196.

小橘 <xiaoju@shazhou.work>
2026-05-12 02:10:06 +00:00
..

@uncaged/workflow-protocol

Shared workflow types, sentinel constants, and Result helpers.

What This Package Does

It defines the cross-package contract for bundles and the engine: thread/step shapes, WorkflowFn, agent/extract contexts, descriptor types, and CasStore as an interface. Implementations (CAS store, CLI, extract) depend on these types so bundles stay decoupled from Node APIs.

Key Exports

From src/index.ts:

  • Types: 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
  • Constants: START, END
  • Functions: ok, err

Dependencies

  • Peer: zod ^4 — used in type positions for schemas (ExtractFn, RoleDefinition, etc.)

No workspace packages; this is the bottom layer.

Usage

import { END, START, type WorkflowFn, type ThreadContext } from "@uncaged/workflow-protocol";

Concrete WorkflowFn implementations are built with @uncaged/workflow-runtime (createWorkflow).