@kortyx/agent 0.15.0 → 0.18.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 CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.18.0](https://github.com/kortyx-io/kortyx/compare/agent-v0.17.0...agent-v0.18.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/runtime bumped to 0.14.0
17
+ * @kortyx/stream bumped to 0.11.0
18
+ * devDependencies
19
+ * @kortyx/hooks bumped to 0.21.0
20
+
21
+ ## [0.17.0](https://github.com/kortyx-io/kortyx/compare/agent-v0.16.0...agent-v0.17.0) (2026-09-10)
22
+
23
+
24
+ ### Features
25
+
26
+ * 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))
27
+ * 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))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @kortyx/core bumped to 0.7.0
35
+ * @kortyx/runtime bumped to 0.13.0
36
+ * @kortyx/stream bumped to 0.10.0
37
+ * devDependencies
38
+ * @kortyx/hooks bumped to 0.20.0
39
+
40
+ ## [0.16.0](https://github.com/kortyx-io/kortyx/compare/agent-v0.15.0...agent-v0.16.0) (2026-09-09)
41
+
42
+
43
+ ### Features
44
+
45
+ * 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))
46
+
47
+
48
+ ### Dependencies
49
+
50
+ * The following workspace dependencies were updated
51
+ * dependencies
52
+ * @kortyx/core bumped to 0.6.0
53
+ * @kortyx/runtime bumped to 0.12.0
54
+ * devDependencies
55
+ * @kortyx/hooks bumped to 0.19.0
56
+
3
57
  ## [0.15.0](https://github.com/kortyx-io/kortyx/compare/agent-v0.14.2...agent-v0.15.0) (2026-08-02)
4
58
 
5
59
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,92 @@
1
- import { WorkflowDefinition, GraphState } from '@kortyx/core';
1
+ import { WorkflowDefinition, ExecutionLimits, TokenUsage, ExecutionLimitReached, ExecutionBudget, GraphState } from '@kortyx/core';
2
2
  import { GetProviderFn } from '@kortyx/providers';
3
- import { CheckpointSummary, CheckpointId, SessionCheckpointRecord, RollbackSessionCheckpointResult, ForkSessionCheckpointResult, WorkflowRegistry, FrameworkAdapter, ExecutionRuntimeConfig, PendingRequestRecord } from '@kortyx/runtime';
3
+ import { PendingRequestRecord, CheckpointSummary, CheckpointId, SessionCheckpointRecord, RollbackSessionCheckpointResult, ForkSessionCheckpointResult, WorkflowRegistry, FrameworkAdapter, ExecutionRuntimeConfig } from '@kortyx/runtime';
4
4
  import { StreamChunk } from '@kortyx/stream';
5
+ import { z } from 'zod';
5
6
  import { KortyxTelemetryConfig, EnsureWorkflowTopologyRequest } from '@kortyx/hooks';
6
7
  import { C as ChatMessage } from './browser-wjeg_MwV.js';
7
8
  export { S as StreamChatFromRouteArgs, s as streamChatFromRoute } from './browser-wjeg_MwV.js';
8
9
  import { StreamEvent } from '@langchain/core/tracers/log_stream';
9
10
  import '@kortyx/stream/browser';
10
11
 
12
+ type ExecutableWorkflow = WorkflowDefinition & {
13
+ inputSchema: z.ZodType;
14
+ outputSchema: z.ZodType<Record<string, unknown>>;
15
+ };
16
+ /** Serializable identity of a waiting request. Treat tokens as private credentials. */
17
+ type ResumeHandle = {
18
+ token: string;
19
+ requestId: string;
20
+ sessionId: string;
21
+ runId: string;
22
+ };
23
+ type ResumeResponse = {
24
+ type: "text";
25
+ text: string;
26
+ } | {
27
+ type: "select";
28
+ ids: string[];
29
+ } | {
30
+ type: "cancel";
31
+ };
32
+ type ExecutionInterrupt = {
33
+ workflow: string;
34
+ node: string;
35
+ input: PendingRequestRecord["schema"] & {
36
+ options: Array<{
37
+ id: string;
38
+ label: string;
39
+ description?: string | undefined;
40
+ }>;
41
+ };
42
+ };
43
+ type ExecutionInfo = {
44
+ runId: string;
45
+ sessionId: string;
46
+ checkpointId?: string;
47
+ usage?: TokenUsage;
48
+ };
49
+ type ExecutionResult<T = Record<string, unknown>> = ExecutionInfo & ({
50
+ status: "completed";
51
+ data: T;
52
+ } | {
53
+ status: "suspended";
54
+ reason?: "limit_reached";
55
+ limit?: ExecutionLimitReached;
56
+ interrupt: ExecutionInterrupt;
57
+ resume: ResumeHandle;
58
+ } | {
59
+ status: "cancelled";
60
+ reason: string;
61
+ } | {
62
+ status: "failed";
63
+ error: {
64
+ code: string;
65
+ message: string;
66
+ };
67
+ });
68
+ type ExecuteOptions<W extends ExecutableWorkflow> = {
69
+ limits?: ExecutionLimits;
70
+ abortSignal?: AbortSignal;
71
+ workflow: W;
72
+ input: z.input<W["inputSchema"]>;
73
+ sessionId?: string;
74
+ context?: Record<string, unknown>;
75
+ };
76
+ type ResumeOptions<W extends ExecutableWorkflow> = {
77
+ limits?: ExecutionLimits;
78
+ abortSignal?: AbortSignal;
79
+ workflow: W;
80
+ resume: ResumeHandle;
81
+ response: ResumeResponse;
82
+ };
83
+ /** The command was rejected before starting work or claiming an interrupt. */
84
+ declare class ExecutionRequestError extends Error {
85
+ readonly code: string;
86
+ name: string;
87
+ constructor(code: string, message: string);
88
+ }
89
+
11
90
  /** Produces the topology-only, deterministic Contract A snapshot. */
12
91
  declare const projectWorkflowTopology: (args: {
13
92
  workflow: WorkflowDefinition;
@@ -17,6 +96,8 @@ declare const projectWorkflowTopology: (args: {
17
96
  }) => EnsureWorkflowTopologyRequest;
18
97
 
19
98
  interface AgentProcessOptions {
99
+ limits?: ExecutionLimits | undefined;
100
+ abortSignal?: AbortSignal | undefined;
20
101
  sessionId?: string | undefined;
21
102
  workflowId?: string | undefined;
22
103
  context?: Record<string, unknown> | undefined;
@@ -27,6 +108,7 @@ interface AgentProjectTopologyOptions {
27
108
  service: AgentTopologySnapshot["service"];
28
109
  }
29
110
  interface CreateAgentArgs {
111
+ limits?: ExecutionLimits | undefined;
30
112
  getProvider?: GetProviderFn | undefined;
31
113
  workflows?: WorkflowDefinition[];
32
114
  workflowsDir?: string;
@@ -36,6 +118,23 @@ interface CreateAgentArgs {
36
118
  telemetry?: ExecutionRuntimeConfig["telemetry"];
37
119
  }
38
120
  interface Agent {
121
+ execute<W extends ExecutableWorkflow>(args: ExecuteOptions<W>): Promise<ExecutionResult<z.output<W["outputSchema"]>>>;
122
+ execute(args: {
123
+ limits?: ExecutionLimits;
124
+ abortSignal?: AbortSignal;
125
+ workflow: string;
126
+ input: unknown;
127
+ sessionId?: string;
128
+ context?: Record<string, unknown>;
129
+ }): Promise<ExecutionResult>;
130
+ resume<W extends ExecutableWorkflow>(args: ResumeOptions<W>): Promise<ExecutionResult<z.output<W["outputSchema"]>>>;
131
+ resume(args: {
132
+ limits?: ExecutionLimits;
133
+ abortSignal?: AbortSignal;
134
+ workflow: string;
135
+ resume: ResumeHandle;
136
+ response: ResumeResponse;
137
+ }): Promise<ExecutionResult>;
39
138
  projectTopology?: (options: AgentProjectTopologyOptions) => Promise<AgentTopologySnapshot[]>;
40
139
  streamChat: (messages: ChatMessage[], options?: AgentProcessOptions) => Promise<AsyncIterable<StreamChunk>>;
41
140
  listCheckpoints: (sessionId: string) => Promise<CheckpointSummary[]>;
@@ -71,6 +170,7 @@ type CheckpointRequestBody = {
71
170
  declare function parseChatRequestBody(value: unknown): ChatRequestBody;
72
171
  declare function parseCheckpointRequestBody(value: unknown): CheckpointRequestBody;
73
172
  declare function handleChatRequestBody(args: {
173
+ abortSignal?: AbortSignal | undefined;
74
174
  agent: Agent;
75
175
  body: ChatRequestBody;
76
176
  }): Promise<Response>;
@@ -90,6 +190,10 @@ declare function createCheckpointRouteHandler(args: {
90
190
  type SelectWorkflowFn = (workflowId: string) => Promise<WorkflowDefinition>;
91
191
  type SaveMemoryFn = (sessionId: string, state: GraphState) => Promise<void>;
92
192
  interface CompiledGraphLike {
193
+ execution?: {
194
+ abortSignal?: AbortSignal | undefined;
195
+ budget?: ExecutionBudget | undefined;
196
+ };
93
197
  config?: Record<string, unknown>;
94
198
  streamEvents: (state: GraphState, options?: {
95
199
  version?: string;
@@ -99,7 +203,17 @@ interface CompiledGraphLike {
99
203
  configurable?: Record<string, unknown>;
100
204
  }) => Promise<unknown>;
101
205
  }
206
+ type OrchestrationOutcome = {
207
+ cancelled?: boolean;
208
+ state: GraphState;
209
+ pending?: PendingRequestRecord | undefined;
210
+ checkpointId?: string | undefined;
211
+ error?: unknown;
212
+ };
102
213
  interface OrchestrateArgs {
214
+ abortSignal?: AbortSignal | undefined;
215
+ emitOutput?: boolean | undefined;
216
+ onOutcome?: ((outcome: OrchestrationOutcome) => void) | undefined;
103
217
  sessionId?: string;
104
218
  runId: string;
105
219
  graph: CompiledGraphLike;
@@ -113,7 +227,7 @@ interface OrchestrateArgs {
113
227
  * Orchestrates runtime execution with mid-stream transitions emitted by
114
228
  * runtime events.
115
229
  */
116
- declare function orchestrateGraphStream({ sessionId, runId, graph, state, config: initialConfig, selectWorkflow, knownWorkflowIds, frameworkAdapter, }: OrchestrateArgs): Promise<NodeJS.ReadableStream>;
230
+ declare function orchestrateGraphStream({ sessionId, runId, graph, state, config: initialConfig, abortSignal: requestSignal, emitOutput, onOutcome, selectWorkflow, knownWorkflowIds, frameworkAdapter, }: OrchestrateArgs): Promise<NodeJS.ReadableStream>;
117
231
 
118
232
  interface ResumeMeta {
119
233
  token: string;
@@ -127,7 +241,13 @@ type ApplyResumeSelection = (args: {
127
241
  }) => Record<string, unknown> | null | undefined;
128
242
  declare function parseResumeMeta(msg: ChatMessage | undefined): ResumeMeta | null;
129
243
  interface TryResumeArgs {
130
- lastMessage: ChatMessage | undefined;
244
+ limits?: ExecutionLimits | undefined;
245
+ abortSignal?: AbortSignal | undefined;
246
+ lastMessage?: ChatMessage | undefined;
247
+ meta?: ResumeMeta | undefined;
248
+ emitOutput?: boolean | undefined;
249
+ onOutcome?: OrchestrateArgs["onOutcome"];
250
+ validatePending?: ((pending: PendingRequestRecord) => void | Promise<void>) | undefined;
131
251
  sessionId: string;
132
252
  config: Record<string, unknown>;
133
253
  selectWorkflow: SelectWorkflowFn;
@@ -136,7 +256,7 @@ interface TryResumeArgs {
136
256
  applyResumeSelection?: ApplyResumeSelection;
137
257
  frameworkAdapter?: FrameworkAdapter;
138
258
  }
139
- declare function tryPrepareResumeStream({ lastMessage, sessionId, config, selectWorkflow, knownWorkflowIds, defaultWorkflowId, applyResumeSelection, frameworkAdapter, }: TryResumeArgs): Promise<AsyncIterable<StreamChunk> | null>;
259
+ declare function tryPrepareResumeStream({ limits, abortSignal, lastMessage, meta: suppliedMeta, emitOutput, onOutcome, validatePending, sessionId, config, selectWorkflow, knownWorkflowIds, defaultWorkflowId, applyResumeSelection, frameworkAdapter, }: TryResumeArgs): Promise<AsyncIterable<StreamChunk> | null>;
140
260
 
141
261
  interface RuntimeConfig {
142
262
  session?: {
@@ -145,6 +265,7 @@ interface RuntimeConfig {
145
265
  [key: string]: unknown;
146
266
  }
147
267
  interface StreamChatArgs<Options> {
268
+ abortSignal?: AbortSignal | undefined;
148
269
  messages: ChatMessage[];
149
270
  options?: Options | undefined;
150
271
  sessionId?: string;
@@ -157,7 +278,7 @@ interface StreamChatArgs<Options> {
157
278
  getProvider: GetProviderFn;
158
279
  applyResumeSelection?: ApplyResumeSelection;
159
280
  }
160
- declare function streamChat<Options = unknown>({ messages, options, sessionId, defaultWorkflowId, loadRuntimeConfig, selectWorkflow, workflowRegistry, knownWorkflowIds, frameworkAdapter, getProvider, applyResumeSelection, }: StreamChatArgs<Options>): Promise<AsyncIterable<StreamChunk>>;
281
+ declare function streamChat<Options = unknown>({ messages, abortSignal, options, sessionId, defaultWorkflowId, loadRuntimeConfig, selectWorkflow, workflowRegistry, knownWorkflowIds, frameworkAdapter, getProvider, applyResumeSelection, }: StreamChatArgs<Options>): Promise<AsyncIterable<StreamChunk>>;
161
282
 
162
283
  interface TransformOptions {
163
284
  debug?: boolean;
@@ -173,4 +294,4 @@ declare function transformGraphStreamForUI(stream: AsyncIterable<StreamEvent>, o
173
294
 
174
295
  declare function extractLatestUserMessage(messages: ChatMessage[]): string;
175
296
 
176
- export { type Agent, type AgentProcessOptions, type AgentProjectTopologyOptions, type ApplyResumeSelection, ChatMessage, type ChatRequestBody, type CheckpointRequestBody, type CompiledGraphLike, type CreateAgentArgs, type OrchestrateArgs, type ResumeMeta, type SaveMemoryFn, type SelectWorkflowFn, type StreamChatArgs, createAgent, createChatRouteHandler, createCheckpointRouteHandler, extractLatestUserMessage, handleChatRequestBody, handleCheckpointRequestBody, orchestrateGraphStream, parseChatRequestBody, parseCheckpointRequestBody, parseResumeMeta, projectWorkflowTopology, streamChat, transformGraphStreamForUI, tryPrepareResumeStream };
297
+ export { type Agent, type AgentProcessOptions, type AgentProjectTopologyOptions, type ApplyResumeSelection, ChatMessage, type ChatRequestBody, type CheckpointRequestBody, type CompiledGraphLike, type CreateAgentArgs, type ExecutableWorkflow, type ExecuteOptions, type ExecutionInfo, type ExecutionInterrupt, ExecutionRequestError, type ExecutionResult, type OrchestrateArgs, type ResumeHandle, type ResumeMeta, type ResumeOptions, type ResumeResponse, type SaveMemoryFn, type SelectWorkflowFn, type StreamChatArgs, createAgent, createChatRouteHandler, createCheckpointRouteHandler, extractLatestUserMessage, handleChatRequestBody, handleCheckpointRequestBody, orchestrateGraphStream, parseChatRequestBody, parseCheckpointRequestBody, parseResumeMeta, projectWorkflowTopology, streamChat, transformGraphStreamForUI, tryPrepareResumeStream };