@ekairos/events 1.22.35-beta.development.0 → 1.22.35

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.
Files changed (73) hide show
  1. package/README.md +5 -3
  2. package/dist/codex.d.ts +11 -2
  3. package/dist/codex.js +16 -8
  4. package/dist/context.action-calls.d.ts +48 -0
  5. package/dist/context.action-calls.js +123 -0
  6. package/dist/context.action.d.ts +55 -0
  7. package/dist/context.action.js +25 -0
  8. package/dist/context.builder.d.ts +71 -43
  9. package/dist/context.builder.js +123 -28
  10. package/dist/context.config.d.ts +2 -1
  11. package/dist/context.config.js +8 -3
  12. package/dist/context.contract.d.ts +2 -4
  13. package/dist/context.contract.js +3 -9
  14. package/dist/context.d.ts +3 -2
  15. package/dist/context.engine.d.ts +60 -52
  16. package/dist/context.engine.js +506 -297
  17. package/dist/context.events.js +28 -87
  18. package/dist/context.js +1 -0
  19. package/dist/context.part-identity.d.ts +40 -0
  20. package/dist/context.part-identity.js +270 -0
  21. package/dist/context.parts.d.ts +389 -164
  22. package/dist/context.parts.js +343 -218
  23. package/dist/context.registry.d.ts +1 -1
  24. package/dist/context.runtime.d.ts +14 -4
  25. package/dist/context.runtime.js +21 -3
  26. package/dist/context.step-stream.d.ts +16 -2
  27. package/dist/context.step-stream.js +58 -16
  28. package/dist/context.store.d.ts +55 -10
  29. package/dist/context.stream.d.ts +14 -4
  30. package/dist/context.stream.js +31 -3
  31. package/dist/domain.d.ts +1 -0
  32. package/dist/domain.js +1 -0
  33. package/dist/index.d.ts +13 -10
  34. package/dist/index.js +7 -6
  35. package/dist/react.context-event-parts.d.ts +18 -0
  36. package/dist/react.context-event-parts.js +509 -0
  37. package/dist/react.d.ts +7 -42
  38. package/dist/react.js +4 -87
  39. package/dist/react.step-stream.d.ts +39 -0
  40. package/dist/react.step-stream.js +625 -0
  41. package/dist/react.types.d.ts +121 -0
  42. package/dist/react.types.js +2 -0
  43. package/dist/react.use-context.d.ts +7 -0
  44. package/dist/react.use-context.js +867 -0
  45. package/dist/reactors/ai-sdk.chunk-map.d.ts +1 -0
  46. package/dist/reactors/ai-sdk.chunk-map.js +56 -5
  47. package/dist/reactors/ai-sdk.reactor.d.ts +8 -9
  48. package/dist/reactors/ai-sdk.reactor.js +6 -9
  49. package/dist/reactors/ai-sdk.step.d.ts +4 -5
  50. package/dist/reactors/ai-sdk.step.js +24 -17
  51. package/dist/reactors/scripted.reactor.d.ts +7 -4
  52. package/dist/reactors/types.d.ts +19 -10
  53. package/dist/runtime.d.ts +6 -0
  54. package/dist/runtime.js +9 -0
  55. package/dist/runtime.step.js +1 -1
  56. package/dist/schema.d.ts +268 -2
  57. package/dist/schema.js +4 -9
  58. package/dist/steps/do-context-stream-step.js +4 -4
  59. package/dist/steps/durable.steps.d.ts +28 -0
  60. package/dist/steps/durable.steps.js +34 -0
  61. package/dist/steps/store.steps.d.ts +64 -22
  62. package/dist/steps/store.steps.js +192 -35
  63. package/dist/steps/stream.steps.d.ts +32 -0
  64. package/dist/steps/stream.steps.js +124 -6
  65. package/dist/steps/trace.steps.d.ts +4 -4
  66. package/dist/steps/trace.steps.js +21 -6
  67. package/dist/stores/instant.store.d.ts +11 -11
  68. package/dist/stores/instant.store.js +136 -6
  69. package/dist/tools-to-model-tools.d.ts +4 -2
  70. package/dist/tools-to-model-tools.js +30 -11
  71. package/package.json +18 -7
  72. package/dist/context.toolcalls.d.ts +0 -60
  73. package/dist/context.toolcalls.js +0 -117
package/dist/schema.d.ts CHANGED
@@ -1,2 +1,268 @@
1
- import { type DomainSchemaResult } from "@ekairos/domain";
2
- export declare const eventsDomain: DomainSchemaResult;
1
+ export declare const eventsDomain: import("@ekairos/domain").DomainSchemaResult<{
2
+ event_contexts: import("@instantdb/core").EntityDef<{
3
+ createdAt: import("@instantdb/core").DataAttrDef<Date, true, false, false>;
4
+ updatedAt: import("@instantdb/core").DataAttrDef<Date, false, false, false>;
5
+ key: import("@instantdb/core").DataAttrDef<string, false, true, true>;
6
+ name: import("@instantdb/core").DataAttrDef<string, false, false, false>;
7
+ status: import("@instantdb/core").DataAttrDef<string, false, true, false>;
8
+ content: import("@instantdb/core").DataAttrDef<any, false, false, false>;
9
+ description: import("@instantdb/core").DataAttrDef<string, false, false, false>;
10
+ goal: import("@instantdb/core").DataAttrDef<string, false, false, false>;
11
+ resources: import("@instantdb/core").DataAttrDef<any, false, false, false>;
12
+ reactor: import("@instantdb/core").DataAttrDef<any, false, false, false>;
13
+ }, {}, unknown>;
14
+ event_items: import("@instantdb/core").EntityDef<{
15
+ channel: import("@instantdb/core").DataAttrDef<string, true, true, false>;
16
+ createdAt: import("@instantdb/core").DataAttrDef<Date, true, true, false>;
17
+ type: import("@instantdb/core").DataAttrDef<string, false, true, false>;
18
+ content: import("@instantdb/core").DataAttrDef<any, false, false, false>;
19
+ status: import("@instantdb/core").DataAttrDef<string, false, true, false>;
20
+ }, {}, unknown>;
21
+ event_executions: import("@instantdb/core").EntityDef<{
22
+ createdAt: import("@instantdb/core").DataAttrDef<Date, true, false, false>;
23
+ updatedAt: import("@instantdb/core").DataAttrDef<Date, false, false, false>;
24
+ status: import("@instantdb/core").DataAttrDef<string, false, true, false>;
25
+ workflowRunId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
26
+ activeStreamId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
27
+ activeStreamClientId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
28
+ lastStreamId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
29
+ lastStreamClientId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
30
+ }, {}, unknown>;
31
+ event_steps: import("@instantdb/core").EntityDef<{
32
+ createdAt: import("@instantdb/core").DataAttrDef<Date, true, true, false>;
33
+ updatedAt: import("@instantdb/core").DataAttrDef<Date, false, false, false>;
34
+ status: import("@instantdb/core").DataAttrDef<string, false, true, false>;
35
+ iteration: import("@instantdb/core").DataAttrDef<number, true, true, false>;
36
+ errorText: import("@instantdb/core").DataAttrDef<string, false, false, false>;
37
+ streamId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
38
+ streamClientId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
39
+ streamStartedAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
40
+ streamFinishedAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
41
+ streamAbortReason: import("@instantdb/core").DataAttrDef<string, false, false, false>;
42
+ }, {}, unknown>;
43
+ event_parts: import("@instantdb/core").EntityDef<{
44
+ key: import("@instantdb/core").DataAttrDef<string, true, true, true>;
45
+ stepId: import("@instantdb/core").DataAttrDef<string, true, true, false>;
46
+ idx: import("@instantdb/core").DataAttrDef<number, true, true, false>;
47
+ type: import("@instantdb/core").DataAttrDef<string, false, true, false>;
48
+ part: import("@instantdb/core").DataAttrDef<any, false, false, false>;
49
+ metadata: import("@instantdb/core").DataAttrDef<any, false, false, false>;
50
+ updatedAt: import("@instantdb/core").DataAttrDef<Date, false, false, false>;
51
+ }, {}, unknown>;
52
+ event_trace_events: import("@instantdb/core").EntityDef<{
53
+ key: import("@instantdb/core").DataAttrDef<string, true, true, true>;
54
+ workflowRunId: import("@instantdb/core").DataAttrDef<string, true, true, false>;
55
+ seq: import("@instantdb/core").DataAttrDef<number, true, true, false>;
56
+ eventId: import("@instantdb/core").DataAttrDef<string, true, true, false>;
57
+ eventKind: import("@instantdb/core").DataAttrDef<string, true, true, false>;
58
+ eventAt: import("@instantdb/core").DataAttrDef<Date, false, false, false>;
59
+ ingestedAt: import("@instantdb/core").DataAttrDef<Date, false, false, false>;
60
+ orgId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
61
+ projectId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
62
+ contextKey: import("@instantdb/core").DataAttrDef<string, false, true, false>;
63
+ contextId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
64
+ executionId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
65
+ stepId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
66
+ contextEventId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
67
+ toolCallId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
68
+ partKey: import("@instantdb/core").DataAttrDef<string, false, true, false>;
69
+ partIdx: import("@instantdb/core").DataAttrDef<number, false, true, false>;
70
+ spanId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
71
+ parentSpanId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
72
+ isDeleted: import("@instantdb/core").DataAttrDef<boolean, false, false, false>;
73
+ aiProvider: import("@instantdb/core").DataAttrDef<string, false, true, false>;
74
+ aiModel: import("@instantdb/core").DataAttrDef<string, false, true, false>;
75
+ promptTokens: import("@instantdb/core").DataAttrDef<number, false, false, false>;
76
+ promptTokensCached: import("@instantdb/core").DataAttrDef<number, false, false, false>;
77
+ promptTokensUncached: import("@instantdb/core").DataAttrDef<number, false, false, false>;
78
+ completionTokens: import("@instantdb/core").DataAttrDef<number, false, false, false>;
79
+ totalTokens: import("@instantdb/core").DataAttrDef<number, false, false, false>;
80
+ latencyMs: import("@instantdb/core").DataAttrDef<number, false, false, false>;
81
+ cacheCostUsd: import("@instantdb/core").DataAttrDef<number, false, false, false>;
82
+ computeCostUsd: import("@instantdb/core").DataAttrDef<number, false, false, false>;
83
+ costUsd: import("@instantdb/core").DataAttrDef<number, false, false, false>;
84
+ payload: import("@instantdb/core").DataAttrDef<any, false, false, false>;
85
+ }, {}, unknown>;
86
+ event_trace_runs: import("@instantdb/core").EntityDef<{
87
+ workflowRunId: import("@instantdb/core").DataAttrDef<string, true, true, true>;
88
+ orgId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
89
+ projectId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
90
+ firstEventAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
91
+ lastEventAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
92
+ lastIngestedAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
93
+ eventsCount: import("@instantdb/core").DataAttrDef<number, false, false, false>;
94
+ status: import("@instantdb/core").DataAttrDef<string, false, true, false>;
95
+ payload: import("@instantdb/core").DataAttrDef<any, false, false, false>;
96
+ }, {}, unknown>;
97
+ event_trace_spans: import("@instantdb/core").EntityDef<{
98
+ spanId: import("@instantdb/core").DataAttrDef<string, true, true, true>;
99
+ parentSpanId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
100
+ workflowRunId: import("@instantdb/core").DataAttrDef<string, true, true, false>;
101
+ executionId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
102
+ stepId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
103
+ kind: import("@instantdb/core").DataAttrDef<string, false, true, false>;
104
+ name: import("@instantdb/core").DataAttrDef<string, false, true, false>;
105
+ status: import("@instantdb/core").DataAttrDef<string, false, true, false>;
106
+ startedAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
107
+ endedAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
108
+ durationMs: import("@instantdb/core").DataAttrDef<number, false, false, false>;
109
+ payload: import("@instantdb/core").DataAttrDef<any, false, false, false>;
110
+ }, {}, unknown>;
111
+ document_documents: import("@instantdb/core").EntityDef<{
112
+ name: import("@instantdb/core").DataAttrDef<string, false, true, false>;
113
+ mimeType: import("@instantdb/core").DataAttrDef<string, false, false, false>;
114
+ size: import("@instantdb/core").DataAttrDef<number, false, false, false>;
115
+ ownerId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
116
+ orgId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
117
+ createdAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
118
+ processedAt: import("@instantdb/core").DataAttrDef<Date, false, true, false>;
119
+ updatedAt: import("@instantdb/core").DataAttrDef<Date, false, false, false>;
120
+ lastJobId: import("@instantdb/core").DataAttrDef<string, false, false, false>;
121
+ content: import("@instantdb/core").DataAttrDef<any, false, false, false>;
122
+ }, {}, unknown>;
123
+ }, {
124
+ contextItemsContext: {
125
+ readonly forward: {
126
+ readonly on: "event_items";
127
+ readonly has: "one";
128
+ readonly label: "context";
129
+ };
130
+ readonly reverse: {
131
+ readonly on: "event_contexts";
132
+ readonly has: "many";
133
+ readonly label: "items";
134
+ };
135
+ };
136
+ contextExecutionsContext: {
137
+ readonly forward: {
138
+ readonly on: "event_executions";
139
+ readonly has: "one";
140
+ readonly label: "context";
141
+ };
142
+ readonly reverse: {
143
+ readonly on: "event_contexts";
144
+ readonly has: "many";
145
+ readonly label: "executions";
146
+ };
147
+ };
148
+ contextCurrentExecution: {
149
+ readonly forward: {
150
+ readonly on: "event_contexts";
151
+ readonly has: "one";
152
+ readonly label: "currentExecution";
153
+ };
154
+ readonly reverse: {
155
+ readonly on: "event_executions";
156
+ readonly has: "one";
157
+ readonly label: "currentOf";
158
+ };
159
+ };
160
+ contextExecutionsTrigger: {
161
+ readonly forward: {
162
+ readonly on: "event_executions";
163
+ readonly has: "one";
164
+ readonly label: "trigger";
165
+ };
166
+ readonly reverse: {
167
+ readonly on: "event_items";
168
+ readonly has: "many";
169
+ readonly label: "executionsAsTrigger";
170
+ };
171
+ };
172
+ contextExecutionsReaction: {
173
+ readonly forward: {
174
+ readonly on: "event_executions";
175
+ readonly has: "one";
176
+ readonly label: "reaction";
177
+ };
178
+ readonly reverse: {
179
+ readonly on: "event_items";
180
+ readonly has: "many";
181
+ readonly label: "executionsAsReaction";
182
+ };
183
+ };
184
+ contextStepsExecution: {
185
+ readonly forward: {
186
+ readonly on: "event_steps";
187
+ readonly has: "one";
188
+ readonly label: "execution";
189
+ };
190
+ readonly reverse: {
191
+ readonly on: "event_executions";
192
+ readonly has: "many";
193
+ readonly label: "steps";
194
+ };
195
+ };
196
+ contextExecutionItems: {
197
+ readonly forward: {
198
+ readonly on: "event_items";
199
+ readonly has: "one";
200
+ readonly label: "execution";
201
+ };
202
+ readonly reverse: {
203
+ readonly on: "event_executions";
204
+ readonly has: "many";
205
+ readonly label: "items";
206
+ };
207
+ };
208
+ contextPartsStep: {
209
+ readonly forward: {
210
+ readonly on: "event_parts";
211
+ readonly has: "one";
212
+ readonly label: "step";
213
+ };
214
+ readonly reverse: {
215
+ readonly on: "event_steps";
216
+ readonly has: "many";
217
+ readonly label: "parts";
218
+ };
219
+ };
220
+ contextStepStream: {
221
+ readonly forward: {
222
+ readonly on: "event_steps";
223
+ readonly has: "one";
224
+ readonly label: "stream";
225
+ };
226
+ readonly reverse: {
227
+ readonly on: "$streams";
228
+ readonly has: "many";
229
+ readonly label: "step";
230
+ };
231
+ };
232
+ contextExecutionActiveStream: {
233
+ readonly forward: {
234
+ readonly on: "event_executions";
235
+ readonly has: "one";
236
+ readonly label: "activeStream";
237
+ };
238
+ readonly reverse: {
239
+ readonly on: "$streams";
240
+ readonly has: "many";
241
+ readonly label: "activeOf";
242
+ };
243
+ };
244
+ contextExecutionLastStream: {
245
+ readonly forward: {
246
+ readonly on: "event_executions";
247
+ readonly has: "one";
248
+ readonly label: "lastStream";
249
+ };
250
+ readonly reverse: {
251
+ readonly on: "$streams";
252
+ readonly has: "many";
253
+ readonly label: "lastOf";
254
+ };
255
+ };
256
+ documentFile: {
257
+ readonly forward: {
258
+ readonly on: "document_documents";
259
+ readonly has: "one";
260
+ readonly label: "file";
261
+ };
262
+ readonly reverse: {
263
+ readonly on: "$files";
264
+ readonly has: "one";
265
+ readonly label: "document";
266
+ };
267
+ };
268
+ }, import("@instantdb/core").RoomsDef, {}, "events", "events">;
package/dist/schema.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i } from "@instantdb/core";
2
2
  import { domain } from "@ekairos/domain";
3
3
  export const eventsDomain = domain("events")
4
- .schema({
4
+ .withSchema({
5
5
  entities: {
6
6
  event_contexts: i.entity({
7
7
  createdAt: i.date(),
@@ -10,6 +10,9 @@ export const eventsDomain = domain("events")
10
10
  name: i.string().optional(),
11
11
  status: i.string().optional().indexed(), // open_idle | open_streaming | closed
12
12
  content: i.any().optional(),
13
+ description: i.string().optional(),
14
+ goal: i.string().optional(),
15
+ resources: i.any().optional(),
13
16
  reactor: i.json().optional(),
14
17
  }),
15
18
  event_items: i.entity({
@@ -34,14 +37,6 @@ export const eventsDomain = domain("events")
34
37
  updatedAt: i.date().optional(),
35
38
  status: i.string().optional().indexed(), // running | completed | failed
36
39
  iteration: i.number().indexed(),
37
- kind: i.string().optional().indexed(), // message | action_execute | action_result
38
- actionName: i.string().optional().indexed(),
39
- actionInput: i.any().optional(),
40
- actionOutput: i.any().optional(),
41
- actionError: i.string().optional(),
42
- actionRequests: i.any().optional(),
43
- actionResults: i.any().optional(),
44
- continueLoop: i.boolean().optional(),
45
40
  errorText: i.string().optional(),
46
41
  streamId: i.string().optional().indexed(),
47
42
  streamClientId: i.string().optional().indexed(),
@@ -12,7 +12,7 @@ export async function doContextStreamStep(params) {
12
12
  const { getWritable } = await import("workflow");
13
13
  const writable = getWritable();
14
14
  const { jsonSchema, gateway, smoothStream, stepCountIs, streamText } = await import("ai");
15
- const { extractToolCallsFromParts } = await import("../context.toolcalls.js");
15
+ const { extractActionCallsFromParts } = await import("../context.action-calls.js");
16
16
  // Match DurableAgent's model init behavior:
17
17
  // - string => AI Gateway model id, resolved via `gateway(...)` in the step runtime
18
18
  // - function => model factory (should be a `"use step"` function for workflow serialization)
@@ -82,9 +82,9 @@ export async function doContextStreamStep(params) {
82
82
  }));
83
83
  await uiStream.pipeTo(writable, { preventClose: true });
84
84
  const assistantEvent = await finishPromise;
85
- const actionRequests = extractToolCallsFromParts(assistantEvent?.content?.parts).map((entry) => ({
86
- actionRef: String(entry.toolCallId),
87
- actionName: String(entry.toolName),
85
+ const actionRequests = extractActionCallsFromParts(assistantEvent?.content?.parts).map((entry) => ({
86
+ actionRef: String(entry.actionCallId),
87
+ actionName: String(entry.actionName),
88
88
  input: entry.args,
89
89
  }));
90
90
  return {
@@ -0,0 +1,28 @@
1
+ import type { ContextDurableWorkflowPayload, ContextReactFinalResult } from "../context.engine.js";
2
+ export type ContextDurableWorkflowStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
3
+ export type ContextReturnValueHookPayload<Context = any> = {
4
+ ok: true;
5
+ result: ContextReactFinalResult<Context>;
6
+ } | {
7
+ ok: false;
8
+ error: {
9
+ name?: string;
10
+ message: string;
11
+ stack?: string;
12
+ };
13
+ };
14
+ export declare function startContextDurableWorkflow(params: {
15
+ payload: ContextDurableWorkflowPayload<any, any, any>;
16
+ }): Promise<{
17
+ runId: string;
18
+ }>;
19
+ export declare function readContextDurableWorkflowStatus(params: {
20
+ runId: string;
21
+ }): Promise<ContextDurableWorkflowStatus>;
22
+ export declare function readContextDurableWorkflowReturnValue(params: {
23
+ runId: string;
24
+ }): Promise<ContextReactFinalResult<any>>;
25
+ export declare function resumeContextReturnValueHook(params: {
26
+ token: string;
27
+ payload: ContextReturnValueHookPayload;
28
+ }): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { getContextDurableWorkflow } from "../context.durable.js";
2
+ export async function startContextDurableWorkflow(params) {
3
+ "use step";
4
+ const workflow = getContextDurableWorkflow();
5
+ if (typeof workflow !== "function") {
6
+ const contextKey = String(params.payload.contextKey || "(missing)");
7
+ throw new Error([
8
+ "ContextEngine.react(..., { durable: true }) needs a registered durable context workflow.",
9
+ "Call configureContextDurableWorkflow(contextDurableWorkflow) during server/workflow bootstrap.",
10
+ "If you want inline execution inside the current workflow step, pass durable: false.",
11
+ `Context key: ${contextKey}.`,
12
+ ].join(" "));
13
+ }
14
+ const { start } = await import("workflow/api");
15
+ const run = await start(workflow, [params.payload]);
16
+ return { runId: String(run.runId) };
17
+ }
18
+ export async function readContextDurableWorkflowStatus(params) {
19
+ "use step";
20
+ const { getRun } = await import("workflow/api");
21
+ const run = getRun(params.runId);
22
+ return (await run.status);
23
+ }
24
+ export async function readContextDurableWorkflowReturnValue(params) {
25
+ "use step";
26
+ const { getRun } = await import("workflow/api");
27
+ const run = getRun(params.runId);
28
+ return (await run.returnValue);
29
+ }
30
+ export async function resumeContextReturnValueHook(params) {
31
+ "use step";
32
+ const { resumeHook } = await import("workflow/api");
33
+ await resumeHook(params.token, params.payload);
34
+ }
@@ -1,7 +1,8 @@
1
- import type { UIMessageChunk } from "ai";
2
1
  import type { ContextEnvironment } from "../context.config.js";
3
2
  import type { ContextRuntime } from "../context.runtime.js";
4
- import type { ContextExecution, ContextItem, ContextIdentifier, StoredContext, ContextStatus } from "../context.store.js";
3
+ import type { ContextExecution, ContextItem, ContextIdentifier, ContextResource, StoredContextResource, StoredContext, ContextStatus } from "../context.store.js";
4
+ import type { ContextStreamEvent } from "../context.stream.js";
5
+ import { type ContextActionResultForStream, type PersistedContextStepStreamSession } from "./stream.steps.js";
5
6
  type RuntimeParams<Env extends ContextEnvironment = ContextEnvironment> = {
6
7
  runtime: ContextRuntime<Env>;
7
8
  };
@@ -9,6 +10,10 @@ export type ContextReviewRequest = {
9
10
  toolCallId: string;
10
11
  toolName?: string;
11
12
  };
13
+ type ContextStepPatch = {
14
+ status?: "running" | "completed" | "failed";
15
+ errorText?: string;
16
+ };
12
17
  /**
13
18
  * Initializes/ensures the story context exists.
14
19
  *
@@ -16,10 +21,6 @@ export type ContextReviewRequest = {
16
21
  */
17
22
  export declare function initializeContext<C>(params: RuntimeParams & {
18
23
  contextIdentifier: ContextIdentifier | null;
19
- opts?: {
20
- silent?: boolean;
21
- writable?: WritableStream<UIMessageChunk>;
22
- };
23
24
  }): Promise<{
24
25
  context: StoredContext<C>;
25
26
  isNew: boolean;
@@ -28,6 +29,17 @@ export declare function updateContextContent<C>(params: RuntimeParams & {
28
29
  contextIdentifier: ContextIdentifier;
29
30
  content: C;
30
31
  }): Promise<StoredContext<C>>;
32
+ export declare function updateContextDefinition<C>(params: RuntimeParams & {
33
+ contextIdentifier: ContextIdentifier;
34
+ definition: {
35
+ description?: string | null;
36
+ goal?: string | null;
37
+ };
38
+ }): Promise<StoredContext<C>>;
39
+ export declare function upsertContextResources(params: RuntimeParams & {
40
+ contextIdentifier: ContextIdentifier;
41
+ resources: ContextResource[];
42
+ }): Promise<StoredContextResource[]>;
31
43
  export declare function updateContextReactor<C>(params: RuntimeParams & {
32
44
  contextIdentifier: ContextIdentifier;
33
45
  reactor: {
@@ -43,7 +55,7 @@ export declare function saveTriggerItem(params: RuntimeParams & {
43
55
  contextIdentifier: ContextIdentifier;
44
56
  event: ContextItem;
45
57
  }): Promise<ContextItem>;
46
- export declare function saveTriggerAndCreateExecution(params: {
58
+ export declare function openExecution(params: {
47
59
  runtime: ContextRuntime<ContextEnvironment>;
48
60
  contextIdentifier: ContextIdentifier;
49
61
  triggerEvent: ContextItem;
@@ -61,6 +73,9 @@ export declare function saveReactionItem(params: RuntimeParams & {
61
73
  reviewRequests?: ContextReviewRequest[];
62
74
  };
63
75
  }): Promise<ContextItem>;
76
+ export declare function getContextItems(params: RuntimeParams & {
77
+ contextIdentifier: ContextIdentifier;
78
+ }): Promise<ContextItem[]>;
64
79
  export declare function updateItem(params: RuntimeParams & {
65
80
  eventId: string;
66
81
  event: ContextItem;
@@ -88,12 +103,29 @@ export declare function completeExecution(params: RuntimeParams & {
88
103
  contextIdentifier: ContextIdentifier;
89
104
  executionId: string;
90
105
  status: "completed" | "failed";
91
- }): Promise<void>;
106
+ contextId?: string;
107
+ reactionEventId?: string;
108
+ reactionEvent?: ContextItem;
109
+ }): Promise<{
110
+ reactionEvent?: ContextItem;
111
+ }>;
92
112
  export declare function updateExecutionWorkflowRun(params: {
93
113
  runtime: ContextRuntime<ContextEnvironment>;
94
114
  executionId: string;
95
115
  workflowRunId: string;
96
116
  }): Promise<void>;
117
+ export declare function openExecutionStep<C>(params: {
118
+ runtime: ContextRuntime<ContextEnvironment>;
119
+ contextIdentifier: ContextIdentifier;
120
+ content: C;
121
+ executionId: string;
122
+ iteration: number;
123
+ }): Promise<{
124
+ stepId: string;
125
+ stream: PersistedContextStepStreamSession;
126
+ context: StoredContext<C>;
127
+ events: ContextItem[];
128
+ }>;
97
129
  export declare function createContextStep(params: {
98
130
  runtime: ContextRuntime<ContextEnvironment>;
99
131
  executionId: string;
@@ -107,30 +139,40 @@ export declare function updateContextStep(params: {
107
139
  executionId?: string;
108
140
  contextId?: string;
109
141
  iteration?: number;
110
- patch: {
111
- status?: "running" | "completed" | "failed";
112
- kind?: "message" | "action_execute" | "action_result";
113
- actionName?: string;
114
- actionInput?: unknown;
115
- actionOutput?: unknown;
116
- actionError?: string;
117
- actionRequests?: any;
118
- actionResults?: any;
119
- continueLoop?: boolean;
120
- errorText?: string;
121
- };
142
+ patch: ContextStepPatch;
122
143
  }): Promise<void>;
144
+ export declare function completeExecutionStep(params: {
145
+ runtime: ContextRuntime<ContextEnvironment>;
146
+ session?: PersistedContextStepStreamSession | null;
147
+ stepId: string;
148
+ executionId?: string;
149
+ contextId?: string;
150
+ iteration?: number;
151
+ parts?: any[];
152
+ actionResults?: ContextActionResultForStream[];
153
+ stepStatus?: ContextStepPatch["status"];
154
+ errorText?: string;
155
+ reactionEventId?: string;
156
+ reactionEvent?: ContextItem;
157
+ }): Promise<{
158
+ reactionEvent?: ContextItem;
159
+ actionResultChunkEvents: ContextStreamEvent[];
160
+ }>;
123
161
  export declare function linkItemToExecutionStep(params: {
124
162
  runtime: ContextRuntime<ContextEnvironment>;
125
163
  itemId: string;
126
164
  executionId: string;
127
165
  }): Promise<void>;
128
- export declare function saveContextPartsStep(params: {
166
+ export declare function saveExecutionStepOutput(params: {
129
167
  runtime: ContextRuntime<ContextEnvironment>;
130
168
  stepId: string;
131
169
  executionId?: string;
132
170
  contextId?: string;
133
171
  iteration?: number;
134
172
  parts: any[];
135
- }): Promise<void>;
173
+ reactionEventId: string;
174
+ reactionEvent: ContextItem;
175
+ }): Promise<{
176
+ reactionEvent: ContextItem;
177
+ }>;
136
178
  export {};