@ekairos/structure 1.21.83-beta.0 → 1.21.88-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/dataset/steps.js +24 -24
- package/dist/file/steps.js +2 -2
- package/dist/rowsOutputPaging.js +4 -4
- package/dist/rowsOutputSplit.js +3 -3
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +4 -4
- package/dist/sandbox/steps.js +10 -10
- package/dist/schema.js +4 -4
- package/dist/service.d.ts +1 -1
- package/dist/service.js +11 -11
- package/dist/steps/commitFromEvents.step.js +4 -4
- package/dist/steps/persistObjectFromStory.step.js +2 -2
- package/dist/structure.js +3 -3
- package/package.json +10 -10
package/dist/dataset/steps.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function structureGetOrCreateContextStep(params) {
|
|
2
2
|
"use step";
|
|
3
3
|
try {
|
|
4
|
-
const {
|
|
5
|
-
const runtime = await
|
|
4
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
5
|
+
const runtime = await getThreadRuntime(params.env);
|
|
6
6
|
const ctx = await runtime.store.getOrCreateContext({ key: params.contextKey });
|
|
7
7
|
return { ok: true, data: ctx };
|
|
8
8
|
}
|
|
@@ -14,8 +14,8 @@ export async function structureGetOrCreateContextStep(params) {
|
|
|
14
14
|
export async function structureGetContextStep(params) {
|
|
15
15
|
"use step";
|
|
16
16
|
try {
|
|
17
|
-
const {
|
|
18
|
-
const runtime = await
|
|
17
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
18
|
+
const runtime = await getThreadRuntime(params.env);
|
|
19
19
|
const ctx = await runtime.store.getContext({ key: params.contextKey });
|
|
20
20
|
if (!ctx)
|
|
21
21
|
return { ok: false, error: "Context not found" };
|
|
@@ -29,8 +29,8 @@ export async function structureGetContextStep(params) {
|
|
|
29
29
|
export async function structureUpdateContextContentStep(params) {
|
|
30
30
|
"use step";
|
|
31
31
|
try {
|
|
32
|
-
const {
|
|
33
|
-
const runtime = await
|
|
32
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
33
|
+
const runtime = await getThreadRuntime(params.env);
|
|
34
34
|
const updated = await runtime.store.updateContextContent({ key: params.contextKey }, params.content);
|
|
35
35
|
return { ok: true, data: updated };
|
|
36
36
|
}
|
|
@@ -42,8 +42,8 @@ export async function structureUpdateContextContentStep(params) {
|
|
|
42
42
|
export async function structurePatchContextContentStep(params) {
|
|
43
43
|
"use step";
|
|
44
44
|
try {
|
|
45
|
-
const {
|
|
46
|
-
const runtime = await
|
|
45
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
46
|
+
const runtime = await getThreadRuntime(params.env);
|
|
47
47
|
const existing = await runtime.store.getOrCreateContext({ key: params.contextKey });
|
|
48
48
|
const existingContent = (existing?.content ?? {});
|
|
49
49
|
const existingStructure = (existingContent?.structure ?? {});
|
|
@@ -65,8 +65,8 @@ export async function structureUploadRowsOutputJsonlStep(params) {
|
|
|
65
65
|
"use step";
|
|
66
66
|
const startedAt = Date.now();
|
|
67
67
|
try {
|
|
68
|
-
const {
|
|
69
|
-
const runtime = await
|
|
68
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
69
|
+
const runtime = await getThreadRuntime(params.env);
|
|
70
70
|
const db = runtime.db;
|
|
71
71
|
const storagePath = `/structure/${params.structureId}/output.jsonl`;
|
|
72
72
|
const fileBuffer = Buffer.from(params.contentBase64 ?? "", "base64");
|
|
@@ -89,15 +89,15 @@ export async function structureLinkRowsOutputFileToContextStep(params) {
|
|
|
89
89
|
"use step";
|
|
90
90
|
const startedAt = Date.now();
|
|
91
91
|
try {
|
|
92
|
-
const {
|
|
93
|
-
const runtime = await
|
|
92
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
93
|
+
const runtime = await getThreadRuntime(params.env);
|
|
94
94
|
const store = runtime.store;
|
|
95
95
|
const db = runtime.db;
|
|
96
96
|
const ctx = await store.getOrCreateContext({ key: params.contextKey });
|
|
97
97
|
const ctxId = ctx?.id;
|
|
98
98
|
if (!ctxId)
|
|
99
99
|
return { ok: false, error: "Context not found" };
|
|
100
|
-
await db.transact([db.tx.
|
|
100
|
+
await db.transact([db.tx.thread_contexts[ctxId].link({ structure_output_file: params.fileId })]);
|
|
101
101
|
console.log(`[structure:link-jsonl] contextKey=${params.contextKey} fileId=${params.fileId} elapsedMs=${Date.now() - startedAt}`);
|
|
102
102
|
return { ok: true };
|
|
103
103
|
}
|
|
@@ -109,15 +109,15 @@ export async function structureLinkRowsOutputFileToContextStep(params) {
|
|
|
109
109
|
export async function structureUnlinkRowsOutputFileFromContextStep(params) {
|
|
110
110
|
"use step";
|
|
111
111
|
try {
|
|
112
|
-
const {
|
|
113
|
-
const runtime = await
|
|
112
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
113
|
+
const runtime = await getThreadRuntime(params.env);
|
|
114
114
|
const store = runtime.store;
|
|
115
115
|
const db = runtime.db;
|
|
116
116
|
const ctx = await store.getOrCreateContext({ key: params.contextKey });
|
|
117
117
|
const ctxId = ctx?.id;
|
|
118
118
|
if (!ctxId)
|
|
119
119
|
return { ok: false, error: "Context not found" };
|
|
120
|
-
await db.transact([db.tx.
|
|
120
|
+
await db.transact([db.tx.thread_contexts[ctxId].unlink({ structure_output_file: params.fileId })]);
|
|
121
121
|
return { ok: true };
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
@@ -128,16 +128,16 @@ export async function structureUnlinkRowsOutputFileFromContextStep(params) {
|
|
|
128
128
|
export async function structureGetContextWithRowsOutputFileStep(params) {
|
|
129
129
|
"use step";
|
|
130
130
|
try {
|
|
131
|
-
const {
|
|
132
|
-
const runtime = await
|
|
131
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
132
|
+
const runtime = await getThreadRuntime(params.env);
|
|
133
133
|
const db = runtime.db;
|
|
134
134
|
const query = (await db.query({
|
|
135
|
-
|
|
135
|
+
thread_contexts: {
|
|
136
136
|
$: { where: { key: params.contextKey }, limit: 1 },
|
|
137
137
|
structure_output_file: {},
|
|
138
138
|
},
|
|
139
139
|
}));
|
|
140
|
-
const row = query.
|
|
140
|
+
const row = query.thread_contexts?.[0];
|
|
141
141
|
if (!row)
|
|
142
142
|
return { ok: false, error: "Context not found" };
|
|
143
143
|
return { ok: true, data: row };
|
|
@@ -152,16 +152,16 @@ export async function structureReadRowsOutputJsonlStep(params) {
|
|
|
152
152
|
const startedAt = Date.now();
|
|
153
153
|
try {
|
|
154
154
|
const contextKey = `structure:${params.structureId}`;
|
|
155
|
-
const {
|
|
156
|
-
const runtime = await
|
|
155
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
156
|
+
const runtime = await getThreadRuntime(params.env);
|
|
157
157
|
const db = runtime.db;
|
|
158
158
|
const query = (await db.query({
|
|
159
|
-
|
|
159
|
+
thread_contexts: {
|
|
160
160
|
$: { where: { key: contextKey }, limit: 1 },
|
|
161
161
|
structure_output_file: {},
|
|
162
162
|
},
|
|
163
163
|
}));
|
|
164
|
-
const ctx = query.
|
|
164
|
+
const ctx = query.thread_contexts?.[0];
|
|
165
165
|
if (!ctx)
|
|
166
166
|
return { ok: false, error: "Context not found" };
|
|
167
167
|
const linked = Array.isArray(ctx?.structure_output_file) ? ctx.structure_output_file[0] : ctx.structure_output_file;
|
package/dist/file/steps.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function readInstantFileStep(params) {
|
|
2
2
|
"use step";
|
|
3
|
-
const {
|
|
4
|
-
const runtime = (await
|
|
3
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
4
|
+
const runtime = (await getThreadRuntime(params.env));
|
|
5
5
|
const db = runtime.db;
|
|
6
6
|
const { DatasetService } = await import("../service.js");
|
|
7
7
|
const service = new DatasetService(db);
|
package/dist/rowsOutputPaging.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDatasetOutputPath, getDatasetWorkstation } from "./datasetFiles.js";
|
|
2
2
|
import { createDatasetSandboxStep, runDatasetSandboxCommandStep } from "./sandbox/steps.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getThreadRuntime } from "./runtime.js";
|
|
4
4
|
/**
|
|
5
5
|
* Step 1/2:
|
|
6
6
|
* Download the rows output.jsonl from Instant storage into a sandbox file.
|
|
@@ -37,16 +37,16 @@ export async function structureDownloadRowsOutputToSandboxStep(params) {
|
|
|
37
37
|
if (exists.exitCode === 0) {
|
|
38
38
|
return { sandboxId, localPath };
|
|
39
39
|
}
|
|
40
|
-
const storyRuntime = await
|
|
40
|
+
const storyRuntime = await getThreadRuntime(params.env);
|
|
41
41
|
const db = storyRuntime.db;
|
|
42
42
|
const contextKey = `structure:${params.structureId}`;
|
|
43
43
|
const query = (await db.query({
|
|
44
|
-
|
|
44
|
+
thread_contexts: {
|
|
45
45
|
$: { where: { key: contextKey }, limit: 1 },
|
|
46
46
|
structure_output_file: {},
|
|
47
47
|
},
|
|
48
48
|
}));
|
|
49
|
-
const ctx = query.
|
|
49
|
+
const ctx = query.thread_contexts?.[0];
|
|
50
50
|
const linked = Array.isArray(ctx?.structure_output_file) ? ctx.structure_output_file[0] : ctx.structure_output_file;
|
|
51
51
|
const url = linked?.url;
|
|
52
52
|
if (!url) {
|
package/dist/rowsOutputSplit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDatasetOutputPath, getDatasetWorkstation } from "./datasetFiles.js";
|
|
2
2
|
import { readDatasetSandboxFileStep, runDatasetSandboxCommandStep } from "./sandbox/steps.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getThreadRuntime } from "./runtime.js";
|
|
4
4
|
/**
|
|
5
5
|
* Step:
|
|
6
6
|
* Split a sandbox-local `output.jsonl` into a child dataset (also `output.jsonl`) of up to `limit` ROW entries.
|
|
@@ -84,7 +84,7 @@ export async function structureSplitRowsOutputToDatasetStep(params) {
|
|
|
84
84
|
sandboxId: params.sandboxId,
|
|
85
85
|
path: outPath,
|
|
86
86
|
});
|
|
87
|
-
const storyRuntime = await
|
|
87
|
+
const storyRuntime = await getThreadRuntime(params.env);
|
|
88
88
|
const db = storyRuntime.db;
|
|
89
89
|
const store = storyRuntime.store;
|
|
90
90
|
const storagePath = `/structure/${params.childDatasetId}/output.jsonl`;
|
|
@@ -102,7 +102,7 @@ export async function structureSplitRowsOutputToDatasetStep(params) {
|
|
|
102
102
|
if (!ctxId)
|
|
103
103
|
throw new Error("Failed to create child dataset context");
|
|
104
104
|
// Link the output file to the context (used by DatasetService.readRecordsFromFile).
|
|
105
|
-
await db.transact([db.tx.
|
|
105
|
+
await db.transact([db.tx.thread_contexts[ctxId].link({ structure_output_file: fileId })]);
|
|
106
106
|
// Patch metadata under `structure` namespace (never clobber Story runtime keys).
|
|
107
107
|
const existingContent = (ctx?.content ?? {});
|
|
108
108
|
const existingStructure = (existingContent?.structure ?? {});
|
package/dist/runtime.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Why dynamic import?
|
|
5
5
|
* - Some bundlers (notably Turbopack step bundles) can drop/hoist static imports in "use-step" modules,
|
|
6
|
-
* causing `ReferenceError:
|
|
6
|
+
* causing `ReferenceError: getThreadRuntime is not defined`.
|
|
7
7
|
* - Using a dynamic import keeps the symbol resolution local to the step runtime.
|
|
8
8
|
*/
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function getThreadRuntime(env: any): Promise<import("@ekairos/thread/runtime").ThreadRuntime>;
|
package/dist/runtime.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Why dynamic import?
|
|
5
5
|
* - Some bundlers (notably Turbopack step bundles) can drop/hoist static imports in "use-step" modules,
|
|
6
|
-
* causing `ReferenceError:
|
|
6
|
+
* causing `ReferenceError: getThreadRuntime is not defined`.
|
|
7
7
|
* - Using a dynamic import keeps the symbol resolution local to the step runtime.
|
|
8
8
|
*/
|
|
9
|
-
export async function
|
|
10
|
-
const {
|
|
11
|
-
return await
|
|
9
|
+
export async function getThreadRuntime(env) {
|
|
10
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
11
|
+
return await getThreadRuntime(env);
|
|
12
12
|
}
|
package/dist/sandbox/steps.js
CHANGED
|
@@ -104,8 +104,8 @@ export async function createDatasetSandboxStep(params) {
|
|
|
104
104
|
"use step";
|
|
105
105
|
const startedAt = Date.now();
|
|
106
106
|
const { env, ...configInput } = params;
|
|
107
|
-
const {
|
|
108
|
-
const db = (await
|
|
107
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
108
|
+
const db = (await getThreadRuntime(env)).db;
|
|
109
109
|
const { SandboxService } = (await import("@ekairos/sandbox"));
|
|
110
110
|
const service = new SandboxService(db);
|
|
111
111
|
const daytonaDefaults = getStructureDaytonaDefaults();
|
|
@@ -181,8 +181,8 @@ export async function createDatasetSandboxStep(params) {
|
|
|
181
181
|
export async function runDatasetSandboxCommandStep(params) {
|
|
182
182
|
"use step";
|
|
183
183
|
const startedAt = Date.now();
|
|
184
|
-
const {
|
|
185
|
-
const db = (await
|
|
184
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
185
|
+
const db = (await getThreadRuntime(params.env)).db;
|
|
186
186
|
const { SandboxService } = (await import("@ekairos/sandbox"));
|
|
187
187
|
const service = new SandboxService(db);
|
|
188
188
|
const result = await service.runCommand(params.sandboxId, params.cmd, params.args ?? []);
|
|
@@ -202,8 +202,8 @@ export async function runDatasetSandboxCommandStep(params) {
|
|
|
202
202
|
export async function writeDatasetSandboxFilesStep(params) {
|
|
203
203
|
"use step";
|
|
204
204
|
const startedAt = Date.now();
|
|
205
|
-
const {
|
|
206
|
-
const db = (await
|
|
205
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
206
|
+
const db = (await getThreadRuntime(params.env)).db;
|
|
207
207
|
const { SandboxService } = (await import("@ekairos/sandbox"));
|
|
208
208
|
const service = new SandboxService(db);
|
|
209
209
|
const result = await service.writeFiles(params.sandboxId, params.files);
|
|
@@ -233,8 +233,8 @@ export async function writeDatasetSandboxTextFileStep(params) {
|
|
|
233
233
|
export async function readDatasetSandboxFileStep(params) {
|
|
234
234
|
"use step";
|
|
235
235
|
const startedAt = Date.now();
|
|
236
|
-
const {
|
|
237
|
-
const db = (await
|
|
236
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
237
|
+
const db = (await getThreadRuntime(params.env)).db;
|
|
238
238
|
const { SandboxService } = (await import("@ekairos/sandbox"));
|
|
239
239
|
const service = new SandboxService(db);
|
|
240
240
|
const result = await service.readFile(params.sandboxId, params.path);
|
|
@@ -262,8 +262,8 @@ export async function readDatasetSandboxTextFileStep(params) {
|
|
|
262
262
|
export async function stopDatasetSandboxStep(params) {
|
|
263
263
|
"use step";
|
|
264
264
|
const startedAt = Date.now();
|
|
265
|
-
const {
|
|
266
|
-
const db = (await
|
|
265
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
266
|
+
const db = (await getThreadRuntime(params.env)).db;
|
|
267
267
|
const { SandboxService } = (await import("@ekairos/sandbox"));
|
|
268
268
|
const service = new SandboxService(db);
|
|
269
269
|
const result = await service.stopSandbox(params.sandboxId);
|
package/dist/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i } from "@instantdb/core";
|
|
2
2
|
import { domain } from "@ekairos/domain";
|
|
3
|
-
import {
|
|
3
|
+
import { threadDomain } from "@ekairos/thread/schema";
|
|
4
4
|
import { sandboxDomain } from "@ekairos/sandbox/schema";
|
|
5
5
|
const entities = {
|
|
6
6
|
// Keep $files compatible with Instant's base file fields used by structure flows.
|
|
@@ -19,16 +19,16 @@ const links = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Structure output link (rows):
|
|
21
21
|
*
|
|
22
|
-
* - `
|
|
22
|
+
* - `thread_contexts.structure_output_file` points to the `$files` record for `output.jsonl`.
|
|
23
23
|
* - Reverse label is prefixed to avoid collisions across domains.
|
|
24
24
|
*/
|
|
25
25
|
structureContextOutputFile: {
|
|
26
|
-
forward: { on: "
|
|
26
|
+
forward: { on: "thread_contexts", has: "one", label: "structure_output_file" },
|
|
27
27
|
reverse: { on: "$files", has: "many", label: "structure_contexts" },
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
const rooms = {};
|
|
31
31
|
export const structureDomain = domain("structure")
|
|
32
|
-
.includes(
|
|
32
|
+
.includes(threadDomain)
|
|
33
33
|
.includes(sandboxDomain)
|
|
34
34
|
.schema({ entities, links, rooms });
|
package/dist/service.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type ServiceResult<T = any> = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Back-compat helper for reading structure outputs outside the workflow runtime.
|
|
10
10
|
*
|
|
11
|
-
* IMPORTANT: The source of truth is `
|
|
11
|
+
* IMPORTANT: The source of truth is `thread_contexts` (Story context) keyed by `structure:<id>`.
|
|
12
12
|
*/
|
|
13
13
|
export declare class DatasetService {
|
|
14
14
|
private readonly db;
|
package/dist/service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Back-compat helper for reading structure outputs outside the workflow runtime.
|
|
3
3
|
*
|
|
4
|
-
* IMPORTANT: The source of truth is `
|
|
4
|
+
* IMPORTANT: The source of truth is `thread_contexts` (Story context) keyed by `structure:<id>`.
|
|
5
5
|
*/
|
|
6
6
|
export class DatasetService {
|
|
7
7
|
constructor(db) {
|
|
@@ -14,12 +14,12 @@ export class DatasetService {
|
|
|
14
14
|
try {
|
|
15
15
|
const key = this.contextKey(datasetId);
|
|
16
16
|
const res = await this.db.query({
|
|
17
|
-
|
|
17
|
+
thread_contexts: {
|
|
18
18
|
$: { where: { key }, limit: 1 },
|
|
19
19
|
structure_output_file: {},
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
|
-
const ctx = res.
|
|
22
|
+
const ctx = res.thread_contexts?.[0];
|
|
23
23
|
if (!ctx)
|
|
24
24
|
return { ok: false, error: "Context not found" };
|
|
25
25
|
return { ok: true, data: ctx };
|
|
@@ -44,12 +44,12 @@ export class DatasetService {
|
|
|
44
44
|
try {
|
|
45
45
|
const key = this.contextKey(datasetId);
|
|
46
46
|
const res = await this.db.query({
|
|
47
|
-
|
|
47
|
+
thread_contexts: {
|
|
48
48
|
$: { where: { key }, limit: 1 },
|
|
49
49
|
structure_output_file: {},
|
|
50
50
|
},
|
|
51
51
|
});
|
|
52
|
-
const ctx = res.
|
|
52
|
+
const ctx = res.thread_contexts?.[0];
|
|
53
53
|
const linked = Array.isArray(ctx?.structure_output_file) ? ctx.structure_output_file[0] : ctx?.structure_output_file;
|
|
54
54
|
const url = linked?.url;
|
|
55
55
|
if (!url)
|
|
@@ -90,13 +90,13 @@ export class DatasetService {
|
|
|
90
90
|
const datasetId = params.id ?? createUuidV4();
|
|
91
91
|
const key = this.contextKey(datasetId);
|
|
92
92
|
const existing = await this.db.query({
|
|
93
|
-
|
|
93
|
+
thread_contexts: { $: { where: { key }, limit: 1 } },
|
|
94
94
|
});
|
|
95
|
-
const ctx = existing.
|
|
95
|
+
const ctx = existing.thread_contexts?.[0];
|
|
96
96
|
if (ctx)
|
|
97
97
|
return { ok: true, data: { datasetId } };
|
|
98
98
|
await this.db.transact([
|
|
99
|
-
this.db.tx.
|
|
99
|
+
this.db.tx.thread_contexts[createUuidV4()].create({
|
|
100
100
|
createdAt: new Date(),
|
|
101
101
|
content: {},
|
|
102
102
|
key,
|
|
@@ -134,13 +134,13 @@ export class DatasetService {
|
|
|
134
134
|
try {
|
|
135
135
|
const key = this.contextKey(params.datasetId);
|
|
136
136
|
const res = await this.db.query({
|
|
137
|
-
|
|
137
|
+
thread_contexts: { $: { where: { key }, limit: 1 } },
|
|
138
138
|
});
|
|
139
|
-
const ctx = res?.
|
|
139
|
+
const ctx = res?.thread_contexts?.[0];
|
|
140
140
|
const ctxId = ctx?.id;
|
|
141
141
|
if (!ctxId)
|
|
142
142
|
return { ok: false, error: "Context not found" };
|
|
143
|
-
await this.db.transact([this.db.tx.
|
|
143
|
+
await this.db.transact([this.db.tx.thread_contexts[ctxId].link({ structure_output_file: params.fileId })]);
|
|
144
144
|
return { ok: true, data: undefined };
|
|
145
145
|
}
|
|
146
146
|
catch (error) {
|
|
@@ -22,11 +22,11 @@ export async function structureCommitFromEventsStep(params) {
|
|
|
22
22
|
"use step";
|
|
23
23
|
const contextKey = `structure:${params.structureId}`;
|
|
24
24
|
try {
|
|
25
|
-
const {
|
|
26
|
-
const runtime = (await
|
|
25
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
26
|
+
const runtime = (await getThreadRuntime(params.env));
|
|
27
27
|
const store = runtime.store;
|
|
28
28
|
const db = runtime.db;
|
|
29
|
-
const events = await store.
|
|
29
|
+
const events = await store.getItems({ key: contextKey });
|
|
30
30
|
const output = findLatestCompleteToolOutput(events ?? []);
|
|
31
31
|
const out = output;
|
|
32
32
|
if (!out || out.success !== true)
|
|
@@ -69,7 +69,7 @@ export async function structureCommitFromEventsStep(params) {
|
|
|
69
69
|
const ctxId = ctx?.id;
|
|
70
70
|
if (!ctxId)
|
|
71
71
|
return { ok: false, error: "Context not found" };
|
|
72
|
-
await db.transact(db.tx.
|
|
72
|
+
await db.transact(db.tx.thread_contexts[ctxId].link({ structure_output_file: out.fileId }));
|
|
73
73
|
}
|
|
74
74
|
await store.updateContextContent({ key: contextKey }, { ...prevContent, structure: nextStructure });
|
|
75
75
|
return { ok: true, data: { committed: true } };
|
|
@@ -36,8 +36,8 @@ function extractJsonObject(text) {
|
|
|
36
36
|
}
|
|
37
37
|
export async function persistObjectResultFromStoryStep(params) {
|
|
38
38
|
"use step";
|
|
39
|
-
const {
|
|
40
|
-
const runtime = (await
|
|
39
|
+
const { getThreadRuntime } = await import("@ekairos/thread/runtime");
|
|
40
|
+
const runtime = (await getThreadRuntime(params.env));
|
|
41
41
|
const store = runtime.store;
|
|
42
42
|
const contextKey = `structure:${params.datasetId}`;
|
|
43
43
|
const events = await store.getEvents({ key: contextKey });
|
package/dist/structure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createThread, didToolExecute, INPUT_TEXT_ITEM_TYPE, WEB_CHANNEL } from "@ekairos/thread";
|
|
2
2
|
import { getDatasetOutputPath, getDatasetOutputSchemaPath, getDatasetWorkstation, getDaytonaVolumeMountPath, getDaytonaVolumeName, } from "./datasetFiles.js";
|
|
3
3
|
import { structureDownloadRowsOutputToSandboxStep, structureReadRowsOutputPageFromSandboxStep, } from "./rowsOutputPaging.js";
|
|
4
4
|
import { structureSplitRowsOutputToDatasetStep } from "./rowsOutputSplit.js";
|
|
@@ -266,7 +266,7 @@ function createStructureStoryDefinition(config) {
|
|
|
266
266
|
const model = config.model ?? "openai/gpt-5.2";
|
|
267
267
|
const defaultSandboxConfig = getDefaultSandboxConfig(datasetId);
|
|
268
268
|
const resolvedSandboxConfig = mergeSandboxConfig(defaultSandboxConfig, config.sandboxConfig);
|
|
269
|
-
const story =
|
|
269
|
+
const story = createThread("ekairos.structure")
|
|
270
270
|
.context(async (stored, env) => {
|
|
271
271
|
const prev = stored?.content ?? {};
|
|
272
272
|
const sandboxState = prev.sandboxState ?? { initialized: false, sources: [] };
|
|
@@ -449,7 +449,7 @@ export function structure(env, opts) {
|
|
|
449
449
|
function makeUserMessageEvent(text) {
|
|
450
450
|
return {
|
|
451
451
|
id: createUuidV4(),
|
|
452
|
-
type:
|
|
452
|
+
type: INPUT_TEXT_ITEM_TYPE,
|
|
453
453
|
channel: WEB_CHANNEL,
|
|
454
454
|
createdAt: new Date().toISOString(),
|
|
455
455
|
content: { parts: [{ type: "text", text }] },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekairos/structure",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.88-beta.0",
|
|
4
4
|
"description": "Ekairos Structure - Unified structured extraction (rows or object) from file/text/dataset inputs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,25 +36,25 @@
|
|
|
36
36
|
"typecheck": "tsc --noEmit"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ekairos/domain": "^1.21.
|
|
40
|
-
"@ekairos/sandbox": "^1.21.
|
|
41
|
-
"@instantdb/admin": "
|
|
42
|
-
"@instantdb/core": "
|
|
39
|
+
"@ekairos/domain": "^1.21.88-beta.0",
|
|
40
|
+
"@ekairos/sandbox": "^1.21.85-beta.0",
|
|
41
|
+
"@instantdb/admin": "0.22.126",
|
|
42
|
+
"@instantdb/core": "0.22.126",
|
|
43
43
|
"ai": "^5.0.95",
|
|
44
44
|
"ajv": "^8.17.1",
|
|
45
45
|
"workflow": "4.0.1-beta.41",
|
|
46
46
|
"zod": "^4.1.8"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@ekairos/
|
|
49
|
+
"@ekairos/thread": "workspace:*"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@ekairos/tsconfig": "workspace:*",
|
|
53
|
-
"@ekairos/story": "workspace:*",
|
|
54
52
|
"@ekairos/sandbox": "workspace:*",
|
|
53
|
+
"@ekairos/thread": "workspace:*",
|
|
54
|
+
"@ekairos/tsconfig": "workspace:*",
|
|
55
55
|
"@types/node": "^24.5.0",
|
|
56
|
+
"dotenv": "^17.2.2",
|
|
56
57
|
"typescript": "^5.9.2",
|
|
57
|
-
"vitest": "^3.2.4"
|
|
58
|
-
"dotenv": "^17.2.2"
|
|
58
|
+
"vitest": "^3.2.4"
|
|
59
59
|
}
|
|
60
60
|
}
|