@ekairos/story 1.21.40-beta.0 → 1.21.43-beta.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/dist/ekairos.config.js +1 -16
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/next.d.ts +2 -1
- package/dist/next.js +40 -27
- package/dist/runtime.d.ts +1 -2
- package/dist/runtime.js +1 -2
- package/dist/steps/reaction.steps.d.ts +25 -0
- package/dist/steps/reaction.steps.js +135 -0
- package/dist/steps/store.steps.d.ts +13 -28
- package/dist/steps/store.steps.js +20 -56
- package/dist/steps/stream.steps.d.ts +7 -0
- package/dist/steps/stream.steps.js +15 -0
- package/dist/stores/instant.document-parser.d.ts +1 -1
- package/dist/stores/instant.document-parser.js +175 -39
- package/dist/stores/instant.documents.js +82 -6
- package/dist/stores/instant.store.d.ts +2 -0
- package/dist/stores/instant.store.js +13 -0
- package/dist/story.builder.d.ts +4 -4
- package/dist/story.builder.js +2 -2
- package/dist/story.config.d.ts +0 -2
- package/dist/story.config.js +46 -39
- package/dist/story.d.ts +2 -2
- package/dist/story.engine.d.ts +2 -2
- package/dist/story.engine.js +19 -17
- package/dist/story.js +2 -2
- package/package.json +2 -2
package/dist/story.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Story, type StoryOptions, type StoryStreamOptions, type ShouldContinue, type StoryShouldContinueArgs, } from "./story.engine";
|
|
2
|
-
export { story, createStory, type StoryConfig, type StoryInstance, type RegistrableStoryBuilder, } from "./story.builder";
|
|
1
|
+
export { Story, type StoryOptions, type StoryStreamOptions, type ShouldContinue, type StoryShouldContinueArgs, } from "./story.engine.js";
|
|
2
|
+
export { story, createStory, type StoryConfig, type StoryInstance, type RegistrableStoryBuilder, } from "./story.builder.js";
|
package/dist/story.engine.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Tool } from "ai";
|
|
2
|
-
import type { StoryEnvironment } from "./story.config";
|
|
3
|
-
import type { ContextEvent, ContextIdentifier, StoredContext } from "./story.store";
|
|
2
|
+
import type { StoryEnvironment } from "./story.config.js";
|
|
3
|
+
import type { ContextEvent, ContextIdentifier, StoredContext } from "./story.store.js";
|
|
4
4
|
export interface StoryOptions<Context = any, Env extends StoryEnvironment = StoryEnvironment> {
|
|
5
5
|
onContextCreated?: (args: {
|
|
6
6
|
env: Env;
|
package/dist/story.engine.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { applyToolExecutionResultToParts } from "./story.toolcalls";
|
|
2
|
-
import {
|
|
3
|
-
import { toolsToModelTools } from "./tools-to-model-tools";
|
|
4
|
-
import { closeStoryStream, writeContextSubstate, writeToolOutputs } from "./steps/stream.steps";
|
|
5
|
-
import { completeExecution,
|
|
1
|
+
import { applyToolExecutionResultToParts } from "./story.toolcalls.js";
|
|
2
|
+
import { executeReaction } from "./steps/reaction.steps.js";
|
|
3
|
+
import { toolsToModelTools } from "./tools-to-model-tools.js";
|
|
4
|
+
import { closeStoryStream, writeContextSubstate, writeStoryPing, writeToolOutputs } from "./steps/stream.steps.js";
|
|
5
|
+
import { completeExecution, createReactionEvent, initializeContext, saveReactionEvent, saveTriggerEvent, updateContextContent, updateContextStatus, updateEvent, } from "./steps/store.steps.js";
|
|
6
6
|
export class Story {
|
|
7
7
|
constructor(opts = {}) {
|
|
8
8
|
this.opts = opts;
|
|
@@ -59,7 +59,7 @@ export class Story {
|
|
|
59
59
|
const preventClose = params.options?.preventClose ?? false;
|
|
60
60
|
const sendFinish = params.options?.sendFinish ?? true;
|
|
61
61
|
// 1) Ensure context exists (step)
|
|
62
|
-
const ctxResult = await
|
|
62
|
+
const ctxResult = await initializeContext(params.env, params.contextIdentifier);
|
|
63
63
|
const currentContext = ctxResult.context;
|
|
64
64
|
const contextSelector = params.contextIdentifier?.id
|
|
65
65
|
? { id: String(params.contextIdentifier.id) }
|
|
@@ -70,12 +70,16 @@ export class Story {
|
|
|
70
70
|
await this.opts.onContextCreated?.({ env: params.env, context: currentContext });
|
|
71
71
|
}
|
|
72
72
|
// 2) Persist trigger event + create execution shell (steps)
|
|
73
|
-
const persistedTriggerEvent = await
|
|
73
|
+
const persistedTriggerEvent = await saveTriggerEvent(params.env, contextSelector, triggerEvent);
|
|
74
74
|
const triggerEventId = persistedTriggerEvent.id;
|
|
75
|
-
const reactionEventId = await
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const { reactionEventId, executionId } = await createReactionEvent({
|
|
76
|
+
env: params.env,
|
|
77
|
+
contextIdentifier: contextSelector,
|
|
78
|
+
triggerEventId,
|
|
79
|
+
});
|
|
80
|
+
// Emit a simple ping chunk early so clients can validate that streaming works end-to-end.
|
|
81
|
+
// This should be ignored safely by clients that don't care about it.
|
|
82
|
+
await writeStoryPing({ label: "story-start" });
|
|
79
83
|
let reactionEvent = null;
|
|
80
84
|
// Latest persisted context state for this run (we keep it in memory; store is updated via steps).
|
|
81
85
|
let updatedContext = currentContext;
|
|
@@ -95,7 +99,6 @@ export class Story {
|
|
|
95
99
|
};
|
|
96
100
|
try {
|
|
97
101
|
for (let iter = 0; iter < maxIterations; iter++) {
|
|
98
|
-
const events = await getEvents(params.env, contextSelector);
|
|
99
102
|
// Normalize/initialize context (workflow-level; may call steps if needed)
|
|
100
103
|
const nextContent = await this.initialize(updatedContext, params.env);
|
|
101
104
|
updatedContext = await updateContextContent(params.env, contextSelector, nextContent);
|
|
@@ -105,12 +108,11 @@ export class Story {
|
|
|
105
108
|
// IMPORTANT: step args must be serializable.
|
|
106
109
|
// Match DurableAgent behavior: convert tool input schemas to plain JSON Schema in workflow context.
|
|
107
110
|
const toolsForModel = toolsToModelTools(toolsAll);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
const { assistantEvent, toolCalls, messagesForModel } = await executeReaction({
|
|
112
|
+
env: params.env,
|
|
113
|
+
contextIdentifier: contextSelector,
|
|
111
114
|
model: this.getModel(updatedContext, params.env),
|
|
112
115
|
system: systemPrompt,
|
|
113
|
-
messages: messagesForModel,
|
|
114
116
|
tools: toolsForModel,
|
|
115
117
|
eventId: reactionEventId,
|
|
116
118
|
maxSteps: maxModelSteps,
|
|
@@ -119,7 +121,7 @@ export class Story {
|
|
|
119
121
|
});
|
|
120
122
|
// Persist/append the assistant event for this iteration
|
|
121
123
|
if (!reactionEvent) {
|
|
122
|
-
reactionEvent = await
|
|
124
|
+
reactionEvent = await saveReactionEvent(params.env, contextSelector, {
|
|
123
125
|
...assistantEvent,
|
|
124
126
|
status: "pending",
|
|
125
127
|
});
|
package/dist/story.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekairos/story",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.43-beta.0",
|
|
4
4
|
"description": "Pulzar Story - Workflow-based AI Stories",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ai-sdk/openai": "^2.0.52",
|
|
51
|
-
"@ekairos/domain": "^1.21.
|
|
51
|
+
"@ekairos/domain": "^1.21.43-beta.0",
|
|
52
52
|
"@instantdb/admin": "^0.22.13",
|
|
53
53
|
"@instantdb/core": "^0.22.13",
|
|
54
54
|
"@vercel/sandbox": "^0.0.23",
|