@ekairos/events 1.22.82-beta.development.0 → 1.22.84-beta.development.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/codex.js +3 -3
- package/dist/{context.toolcalls.d.ts → context.action-calls.d.ts} +10 -10
- package/dist/{context.toolcalls.js → context.action-calls.js} +23 -23
- package/dist/context.action.d.ts +12 -12
- package/dist/context.builder.d.ts +34 -16
- package/dist/context.builder.js +94 -4
- package/dist/context.d.ts +1 -1
- package/dist/context.engine.d.ts +16 -21
- package/dist/context.engine.js +80 -35
- package/dist/context.parts.js +114 -0
- package/dist/context.runtime.d.ts +4 -4
- package/dist/context.store.d.ts +53 -0
- package/dist/context.stream.d.ts +9 -1
- package/dist/context.stream.js +8 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/react.step-stream.js +82 -38
- package/dist/reactors/ai-sdk.reactor.d.ts +3 -3
- package/dist/reactors/ai-sdk.reactor.js +3 -4
- package/dist/reactors/ai-sdk.step.d.ts +1 -2
- package/dist/reactors/ai-sdk.step.js +3 -3
- package/dist/reactors/scripted.reactor.d.ts +4 -4
- package/dist/reactors/types.d.ts +5 -5
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +3 -0
- package/dist/steps/do-context-stream-step.js +4 -4
- package/dist/steps/store.steps.d.ts +12 -6
- package/dist/steps/store.steps.js +10 -0
- package/dist/stores/instant.store.d.ts +11 -3
- package/dist/stores/instant.store.js +88 -0
- package/package.json +2 -2
|
@@ -155,6 +155,9 @@ export class InstantStore {
|
|
|
155
155
|
? new Date(row.updatedAt)
|
|
156
156
|
: undefined,
|
|
157
157
|
content: row?.content ?? null,
|
|
158
|
+
description: typeof row?.description === "string" ? row.description : null,
|
|
159
|
+
goal: typeof row?.goal === "string" ? row.goal : null,
|
|
160
|
+
resources: this.normalizeContextResources(row?.resources),
|
|
158
161
|
reactor: row?.reactor && typeof row.reactor === "object"
|
|
159
162
|
? row.reactor
|
|
160
163
|
: null,
|
|
@@ -184,6 +187,9 @@ export class InstantStore {
|
|
|
184
187
|
key,
|
|
185
188
|
status: "open_idle",
|
|
186
189
|
content: {},
|
|
190
|
+
description: undefined,
|
|
191
|
+
goal: undefined,
|
|
192
|
+
resources: [],
|
|
187
193
|
reactor: undefined,
|
|
188
194
|
}),
|
|
189
195
|
]);
|
|
@@ -244,6 +250,28 @@ export class InstantStore {
|
|
|
244
250
|
throw new Error("InstantStore: context not found after update");
|
|
245
251
|
return updated;
|
|
246
252
|
}
|
|
253
|
+
async updateContextDefinition(contextIdentifier, definition) {
|
|
254
|
+
const context = await this.getContext(contextIdentifier);
|
|
255
|
+
if (!context?.id)
|
|
256
|
+
throw new Error("InstantStore: context not found");
|
|
257
|
+
const update = {
|
|
258
|
+
updatedAt: new Date(),
|
|
259
|
+
};
|
|
260
|
+
if (definition.description !== undefined) {
|
|
261
|
+
update.description =
|
|
262
|
+
typeof definition.description === "string" ? definition.description : undefined;
|
|
263
|
+
}
|
|
264
|
+
if (definition.goal !== undefined) {
|
|
265
|
+
update.goal = typeof definition.goal === "string" ? definition.goal : undefined;
|
|
266
|
+
}
|
|
267
|
+
await this.db.transact([
|
|
268
|
+
this.db.tx.event_contexts[context.id].update(update),
|
|
269
|
+
]);
|
|
270
|
+
const updated = await this.getContext({ id: context.id });
|
|
271
|
+
if (!updated)
|
|
272
|
+
throw new Error("InstantStore: context not found after definition update");
|
|
273
|
+
return updated;
|
|
274
|
+
}
|
|
247
275
|
async updateContextReactor(contextIdentifier, reactor) {
|
|
248
276
|
const context = await this.getContext(contextIdentifier);
|
|
249
277
|
if (!context?.id)
|
|
@@ -279,6 +307,66 @@ export class InstantStore {
|
|
|
279
307
|
throw new Error("InstantStore: context not found");
|
|
280
308
|
return context;
|
|
281
309
|
}
|
|
310
|
+
normalizeContextResource(resource) {
|
|
311
|
+
if (!resource || typeof resource !== "object")
|
|
312
|
+
return null;
|
|
313
|
+
const record = resource;
|
|
314
|
+
const key = typeof record.key === "string" ? record.key.trim() : "";
|
|
315
|
+
const type = typeof record.type === "string" ? record.type.trim() : "";
|
|
316
|
+
const name = typeof record.name === "string" ? record.name.trim() : "";
|
|
317
|
+
const description = typeof record.description === "string" ? record.description.trim() : "";
|
|
318
|
+
if (!key || !type || !name || !description)
|
|
319
|
+
return null;
|
|
320
|
+
return {
|
|
321
|
+
...record,
|
|
322
|
+
key,
|
|
323
|
+
type,
|
|
324
|
+
name,
|
|
325
|
+
description,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
normalizeContextResources(value) {
|
|
329
|
+
if (!Array.isArray(value))
|
|
330
|
+
return [];
|
|
331
|
+
return value.flatMap((resource) => {
|
|
332
|
+
const normalized = this.normalizeContextResource(resource);
|
|
333
|
+
return normalized ? [normalized] : [];
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
async getContextResources(contextIdentifier) {
|
|
337
|
+
const context = await this.resolveContext(contextIdentifier);
|
|
338
|
+
return context.resources ?? [];
|
|
339
|
+
}
|
|
340
|
+
async upsertContextResources(contextIdentifier, resources) {
|
|
341
|
+
const context = await this.resolveContext(contextIdentifier);
|
|
342
|
+
const now = new Date();
|
|
343
|
+
const storedResources = [];
|
|
344
|
+
for (const resource of resources) {
|
|
345
|
+
const resourceKey = typeof resource.key === "string" ? resource.key.trim() : "";
|
|
346
|
+
const type = typeof resource.type === "string" ? resource.type.trim() : "";
|
|
347
|
+
const name = typeof resource.name === "string" ? resource.name.trim() : "";
|
|
348
|
+
const description = typeof resource.description === "string" ? resource.description.trim() : "";
|
|
349
|
+
if (!resourceKey || !type || !name || !description) {
|
|
350
|
+
throw new Error("InstantStore: context resources require key, type, name, and description.");
|
|
351
|
+
}
|
|
352
|
+
const sanitizedResource = sanitizeInstantValue(resource);
|
|
353
|
+
const storedResource = {
|
|
354
|
+
...sanitizedResource,
|
|
355
|
+
key: resourceKey,
|
|
356
|
+
type,
|
|
357
|
+
name,
|
|
358
|
+
description,
|
|
359
|
+
};
|
|
360
|
+
storedResources.push(storedResource);
|
|
361
|
+
}
|
|
362
|
+
await this.db.transact([
|
|
363
|
+
this.db.tx.event_contexts[context.id].update({
|
|
364
|
+
resources: storedResources,
|
|
365
|
+
updatedAt: now,
|
|
366
|
+
}),
|
|
367
|
+
]);
|
|
368
|
+
return await this.getContextResources({ id: context.id });
|
|
369
|
+
}
|
|
282
370
|
async saveItem(contextIdentifier, event) {
|
|
283
371
|
const eventId = ensureValidEntityId(event?.id, "event.id");
|
|
284
372
|
const sanitizedEvent = sanitizeInstantValue(event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekairos/events",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.84-beta.development.0",
|
|
4
4
|
"description": "Ekairos Events - Context-first workflow runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
},
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@ai-sdk/openai": "^2.0.52",
|
|
130
|
-
"@ekairos/domain": "^1.22.
|
|
130
|
+
"@ekairos/domain": "^1.22.84-beta.development.0",
|
|
131
131
|
"@instantdb/admin": "0.22.158",
|
|
132
132
|
"@instantdb/core": "0.22.142",
|
|
133
133
|
"@vercel/mcp-adapter": "^1.0.0",
|