@kortyx/hooks
v0.17.1
Published
Lifecycle hooks and extension points for Kortyx.
Maintainers
Readme
@kortyx/hooks
Node-level hooks for model calls, human-in-the-loop interrupts, structured stream data, runtime context, and durable node/workflow state.
Most application code should import these APIs from kortyx. Use @kortyx/hooks directly when you want the hook package without the full facade.
Install
pnpm add @kortyx/hooksnpm install @kortyx/hooksKey APIs
useReason(...)for model calls, optional schema-constrained interrupt flow, and structured output.useInterrupt(...)for explicit human-in-the-loop pauses.useStructuredData(...)for UI-friendly structured stream events.useRuntimeContext(...)for request context made available to node execution.useNodeState(...)/useWorkflowState(...)for stateful node logic.
useReason({ interrupt }) defaults to required interrupt behavior. Use
interrupt.mode: "optional" when the model should decide whether to continue
with a single model call or pause for user input.
Runtime Resume Behavior
On resume, the node function is replayed from the top.
useReasonresumes from its internal checkpoint.- Code before
useReasonwill re-run unless guarded.
Workarounds:
- Keep nodes minimal and call
useReasonfirst. - Guard pre-
useReasonside effects withuseNodeState.
Documentation
License
Apache-2.0. See LICENSE.
