@kortyx/hooks 0.18.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +28 -0
- package/dist/index.d.ts +71 -4
- package/dist/index.js +326 -7
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +8 -2
- package/dist/internal.js.map +1 -1
- package/dist/{tracing-DeYHBpY1.d.ts → tracing-BI6YKHSf.d.ts} +4 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.21.0](https://github.com/kortyx-io/kortyx/compare/hooks-v0.20.0...hooks-v0.21.0) (2026-09-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **runtime:** add shared execution limits and checkpoint continuation ([#163](https://github.com/kortyx-io/kortyx/issues/163)) ([e22232c](https://github.com/kortyx-io/kortyx/commit/e22232c059fae4f7df1bd36423902bd365887942))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @kortyx/core bumped to 0.8.0
|
|
16
|
+
* @kortyx/telemetry-contracts bumped to 0.4.0
|
|
17
|
+
|
|
18
|
+
## [0.20.0](https://github.com/kortyx-io/kortyx/compare/hooks-v0.19.0...hooks-v0.20.0) (2026-09-10)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* cancel workflow trees and reflect cancellation in Studio ([#161](https://github.com/kortyx-io/kortyx/issues/161)) ([699ad18](https://github.com/kortyx-io/kortyx/commit/699ad18905955c6340c3d85b9fae7f0bffd00a0d))
|
|
24
|
+
* execute and resume workflows without chat transport ([#159](https://github.com/kortyx-io/kortyx/issues/159)) ([6decb17](https://github.com/kortyx-io/kortyx/commit/6decb1714fedc021ac9e125b6ed9f75475ed928a))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @kortyx/core bumped to 0.7.0
|
|
32
|
+
|
|
33
|
+
## [0.19.0](https://github.com/kortyx-io/kortyx/compare/hooks-v0.18.0...hooks-v0.19.0) (2026-09-09)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* add resumable child workflows and Studio inspection ([#157](https://github.com/kortyx-io/kortyx/issues/157)) ([542ba29](https://github.com/kortyx-io/kortyx/commit/542ba29b3b57217e6e5d98c1b409bbec5ce3261f))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Dependencies
|
|
42
|
+
|
|
43
|
+
* The following workspace dependencies were updated
|
|
44
|
+
* dependencies
|
|
45
|
+
* @kortyx/core bumped to 0.6.0
|
|
46
|
+
* @kortyx/telemetry-contracts bumped to 0.3.0
|
|
47
|
+
|
|
3
48
|
## [0.18.0](https://github.com/kortyx-io/kortyx/compare/hooks-v0.17.1...hooks-v0.18.0) (2026-08-02)
|
|
4
49
|
|
|
5
50
|
|
package/README.md
CHANGED
|
@@ -53,3 +53,31 @@ Workarounds:
|
|
|
53
53
|
## License
|
|
54
54
|
|
|
55
55
|
Apache-2.0. See [LICENSE](https://github.com/kortyx-io/kortyx/blob/main/LICENSE).
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## Child workflows
|
|
59
|
+
|
|
60
|
+
Call a registered workflow from a node or custom hook and continue with its
|
|
61
|
+
result:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
const result = await useWorkflow({
|
|
65
|
+
id: "research",
|
|
66
|
+
workflow: researchWorkflow,
|
|
67
|
+
input: { topic: "AI agents" },
|
|
68
|
+
});
|
|
69
|
+
return { data: { summary: result.data.summary } };
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The child defines `inputSchema` and `outputSchema` on `defineWorkflow`.
|
|
73
|
+
Inputs and returned data are inferred from those schemas and validated at
|
|
74
|
+
runtime. The result is the child's accumulated data parsed by its output
|
|
75
|
+
schema. Use `createWorkflowHooks({ research: researchWorkflow })` for typed
|
|
76
|
+
string ids. Register the same definitions with the agent.
|
|
77
|
+
|
|
78
|
+
Calls need stable ids. A child interrupt pauses the chain; resuming replays
|
|
79
|
+
the enclosing node and reuses saved child results. Keep effects before calls
|
|
80
|
+
idempotent. Fork/rollback retain nested checkpoints; use Redis for persistence
|
|
81
|
+
across server restarts. Concurrent calls are unsupported.
|
|
82
|
+
|
|
83
|
+
See [the execution and replay contract](../../docs/design-specs/child-workflows.md).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import * as _kortyx_core from '@kortyx/core';
|
|
2
|
+
import { WorkflowDefinition, TokenUsage, InterruptInput, NodeConfig, InterruptResult, GraphState } from '@kortyx/core';
|
|
3
|
+
import { K as KortyxTelemetryConfig, R as ReasonTraceAdapter, a as KortyxTraceMetadata, b as KortyxTelemetryEventType } from './tracing-BI6YKHSf.js';
|
|
4
|
+
export { E as EnsureWorkflowTopologyRequest, c as EnsureWorkflowTopologyResponse, d as KortyxTelemetryContentCapture, e as KortyxTelemetryCorrelation, f as KortyxTelemetryEvent, g as KortyxTelemetryPrompt, h as KortyxTelemetryReporter, i as KortyxTelemetryService, j as KortyxTraceAdapter, k as ReasonTraceAttributes, l as ReasonTraceSpan, m as ReasonTraceSpanEndArgs, n as ReasonTraceSpanStartArgs } from './tracing-BI6YKHSf.js';
|
|
5
|
+
import { z } from 'zod';
|
|
4
6
|
import { ProviderModelRef, KortyxReasoningOptions, KortyxResponseFormat, KortyxExecutableTool, KortyxUsage, KortyxFinishReason, KortyxProviderMetadata, KortyxWarning, KortyxToolCall, KortyxToolResult } from '@kortyx/providers';
|
|
5
7
|
import '@kortyx/telemetry-contracts';
|
|
6
8
|
|
|
9
|
+
type WorkflowCallOutcome = {
|
|
10
|
+
status: "completed";
|
|
11
|
+
data: Record<string, unknown>;
|
|
12
|
+
usage?: TokenUsage | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
status: "interrupted";
|
|
15
|
+
request: InterruptInput;
|
|
16
|
+
snapshot: unknown;
|
|
17
|
+
usage?: TokenUsage | undefined;
|
|
18
|
+
};
|
|
19
|
+
type WorkflowCallService = (args: {
|
|
20
|
+
id: string;
|
|
21
|
+
workflow: string;
|
|
22
|
+
input: unknown;
|
|
23
|
+
snapshot?: unknown;
|
|
24
|
+
definition?: WorkflowDefinition | undefined;
|
|
25
|
+
invocationId: string;
|
|
26
|
+
response?: string | string[] | undefined;
|
|
27
|
+
callerNodeExecutionId?: string | undefined;
|
|
28
|
+
}) => Promise<WorkflowCallOutcome>;
|
|
29
|
+
declare class WorkflowCallError extends Error {
|
|
30
|
+
readonly workflow: string;
|
|
31
|
+
constructor(workflow: string, message: string);
|
|
32
|
+
}
|
|
33
|
+
declare function workflowCallFingerprint(value: unknown): string;
|
|
34
|
+
type SchematizedWorkflow = WorkflowDefinition & {
|
|
35
|
+
inputSchema: z.ZodType;
|
|
36
|
+
outputSchema: z.ZodType<Record<string, unknown>>;
|
|
37
|
+
};
|
|
38
|
+
/** Bind string workflow ids to the same definitions registered with the agent. */
|
|
39
|
+
declare function createWorkflowHooks<const W extends Record<string, SchematizedWorkflow>>(workflows: W): {
|
|
40
|
+
useWorkflow: <K extends keyof W & string>(args: {
|
|
41
|
+
id: string;
|
|
42
|
+
workflow: K;
|
|
43
|
+
input: z.input<W[K]["inputSchema"]>;
|
|
44
|
+
}) => Promise<{
|
|
45
|
+
data: z.output<W[K]["outputSchema"]>;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
/** Typed references avoid caller-supplied result type assertions. */
|
|
49
|
+
declare function useWorkflow<W extends SchematizedWorkflow>(args: {
|
|
50
|
+
id: string;
|
|
51
|
+
workflow: W;
|
|
52
|
+
input: z.input<W["inputSchema"]>;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
data: z.output<W["outputSchema"]>;
|
|
55
|
+
}>;
|
|
56
|
+
declare function useWorkflow(args: {
|
|
57
|
+
id: string;
|
|
58
|
+
workflow: string;
|
|
59
|
+
input: unknown;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
data: Record<string, unknown>;
|
|
62
|
+
}>;
|
|
63
|
+
|
|
7
64
|
type HookNodeRuntimeContext = {
|
|
65
|
+
/** Transient execution control; never part of checkpointed state. */
|
|
66
|
+
abortSignal?: AbortSignal | undefined;
|
|
67
|
+
consumeExecution?: ((limit: _kortyx_core.ExecutionLimit) => void) | undefined;
|
|
8
68
|
graph: {
|
|
9
69
|
name: string;
|
|
10
70
|
node: string;
|
|
@@ -12,6 +72,8 @@ type HookNodeRuntimeContext = {
|
|
|
12
72
|
config: NodeConfig;
|
|
13
73
|
emit: (event: string, payload: unknown) => void;
|
|
14
74
|
awaitInterrupt: (args: InterruptInput) => InterruptResult;
|
|
75
|
+
callWorkflow?: WorkflowCallService;
|
|
76
|
+
workflowCallTelemetry?: KortyxTelemetryConfig | undefined;
|
|
15
77
|
};
|
|
16
78
|
type HookRuntimeContext = {
|
|
17
79
|
node: HookNodeRuntimeContext;
|
|
@@ -157,8 +219,13 @@ type StateSetter<T> = (next: T | ((prev: T) => T)) => void;
|
|
|
157
219
|
declare function useStructuredData<TData = unknown>(args: UseStructuredDataArgs<TData>): void;
|
|
158
220
|
declare function useReason<TOutput = unknown, TRequest extends InterruptInput = InterruptInput, TResponse = InterruptResult>(args: UseReasonArgs<TOutput, TRequest, TResponse>): Promise<UseReasonResult<TOutput, TResponse>>;
|
|
159
221
|
declare function useInterrupt<TRequest extends InterruptInput = InterruptInput, TResponse = InterruptResult>(args: UseInterruptArgs<TRequest, TResponse>): Promise<TResponse>;
|
|
222
|
+
/** Live execution signal for cooperative I/O. Never store it in workflow state. */
|
|
223
|
+
declare function useAbortSignal(): AbortSignal | undefined;
|
|
160
224
|
declare function useRuntimeContext<TContext extends Record<string, unknown> = Record<string, unknown>>(): TContext;
|
|
161
225
|
declare function useNodeState<T>(initialValue: T): [T, StateSetter<T>];
|
|
162
226
|
declare function useWorkflowState<T>(key: string, ...rest: [] | [T]): [T, StateSetter<T>];
|
|
163
227
|
|
|
164
|
-
|
|
228
|
+
/** Best effort lifecycle facts. Engine snapshots and interrupt tokens never leave the runtime. */
|
|
229
|
+
declare function emitWorkflowCall(telemetry: KortyxTelemetryConfig | undefined, type: KortyxTelemetryEventType, payload: Record<string, unknown>): void;
|
|
230
|
+
|
|
231
|
+
export { type HookRuntimeContext, KortyxTelemetryConfig, KortyxTelemetryEventType, KortyxTraceMetadata, ReasonTraceAdapter, type UseInterruptArgs, type UseReasonArgs, type UseReasonResult, type UseReasonStep, type UseReasonToolExecution, type UseStructuredDataArgs, WorkflowCallError, type WorkflowCallOutcome, type WorkflowCallService, createWorkflowHooks, emitWorkflowCall, runWithHookContext, useAbortSignal, useInterrupt, useNodeState, useReason, useRuntimeContext, useStructuredData, useWorkflow, useWorkflowState, workflowCallFingerprint };
|