@ekairos/dataset 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.
- package/README.md +347 -0
- package/dist/agents.d.ts +8 -0
- package/dist/agents.js +8 -0
- package/dist/builder/agentMaterializers.d.ts +9 -0
- package/dist/builder/agentMaterializers.js +10 -0
- package/dist/builder/context.d.ts +15 -0
- package/dist/builder/context.js +251 -0
- package/dist/builder/instructions.d.ts +5 -0
- package/dist/builder/instructions.js +40 -0
- package/dist/builder/materialize.d.ts +83 -0
- package/dist/builder/materialize.js +548 -0
- package/dist/builder/materializeQuery.d.ts +12 -0
- package/dist/builder/materializeQuery.js +31 -0
- package/dist/builder/persistence.d.ts +22 -0
- package/dist/builder/persistence.js +153 -0
- package/dist/builder/rows.d.ts +7 -0
- package/dist/builder/rows.js +56 -0
- package/dist/builder/schemaInference.d.ts +3 -0
- package/dist/builder/schemaInference.js +61 -0
- package/dist/builder/types.d.ts +140 -0
- package/dist/builder/types.js +1 -0
- package/dist/clearDataset.tool.d.ts +2 -3
- package/dist/clearDataset.tool.js +13 -17
- package/dist/completeDataset.steps.d.ts +117 -0
- package/dist/completeDataset.steps.js +487 -0
- package/dist/completeDataset.tool.d.ts +132 -7
- package/dist/completeDataset.tool.js +46 -192
- package/dist/contextResources.d.ts +31 -0
- package/dist/contextResources.js +151 -0
- package/dist/contextWorkspace.d.ts +79 -0
- package/dist/contextWorkspace.js +234 -0
- package/dist/dataset/steps.d.ts +39 -15
- package/dist/dataset/steps.js +96 -39
- package/dist/dataset.d.ts +3 -67
- package/dist/dataset.js +129 -521
- package/dist/datasetFiles.d.ts +5 -1
- package/dist/datasetFiles.js +29 -27
- package/dist/domain.d.ts +1 -2
- package/dist/domain.js +1 -6
- package/dist/executeCommand.tool.d.ts +2 -30
- package/dist/executeCommand.tool.js +165 -39
- package/dist/file/file-dataset.agent.d.ts +19 -56
- package/dist/file/file-dataset.agent.js +176 -134
- package/dist/file/file-dataset.steps.d.ts +27 -0
- package/dist/file/file-dataset.steps.js +47 -0
- package/dist/file/file-dataset.types.d.ts +64 -0
- package/dist/file/file-dataset.types.js +1 -0
- package/dist/file/filepreview.d.ts +5 -35
- package/dist/file/filepreview.js +60 -107
- package/dist/file/filepreview.types.d.ts +31 -0
- package/dist/file/filepreview.types.js +1 -0
- package/dist/file/generateSchema.tool.d.ts +2 -3
- package/dist/file/generateSchema.tool.js +11 -15
- package/dist/file/index.d.ts +1 -2
- package/dist/file/index.js +1 -18
- package/dist/file/prompts.d.ts +2 -3
- package/dist/file/prompts.js +134 -27
- package/dist/file/scripts.generated.d.ts +1 -0
- package/dist/file/scripts.generated.js +11 -0
- package/dist/file/steps.d.ts +1 -2
- package/dist/file/steps.js +9 -7
- package/dist/id.d.ts +1 -0
- package/dist/id.js +10 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +8 -23
- package/dist/materializeDataset.tool.d.ts +52 -32
- package/dist/materializeDataset.tool.js +81 -65
- package/dist/query/index.d.ts +1 -2
- package/dist/query/index.js +1 -18
- package/dist/query/queryDomain.d.ts +3 -4
- package/dist/query/queryDomain.js +3 -40
- package/dist/query/queryDomain.step.d.ts +1 -1
- package/dist/query/queryDomain.step.js +13 -13
- package/dist/sandbox/steps.d.ts +23 -15
- package/dist/sandbox/steps.js +73 -76
- package/dist/sandbox.steps.d.ts +1 -2
- package/dist/sandbox.steps.js +1 -18
- package/dist/schema.d.ts +13 -13
- package/dist/schema.js +25 -37
- package/dist/service.d.ts +8 -5
- package/dist/service.js +70 -15
- package/dist/skill.d.ts +0 -1
- package/dist/skill.js +12 -17
- package/dist/transform/filepreview.d.ts +2 -3
- package/dist/transform/filepreview.js +9 -26
- package/dist/transform/index.d.ts +2 -3
- package/dist/transform/index.js +2 -8
- package/dist/transform/prompts.d.ts +1 -34
- package/dist/transform/prompts.js +58 -43
- package/dist/transform/transform-dataset.agent.d.ts +20 -45
- package/dist/transform/transform-dataset.agent.js +146 -91
- package/dist/transform/transform-dataset.steps.d.ts +30 -0
- package/dist/transform/transform-dataset.steps.js +61 -0
- package/dist/transform/transform-dataset.types.d.ts +95 -0
- package/dist/transform/transform-dataset.types.js +1 -0
- package/dist/transform/transformDataset.d.ts +3 -3
- package/dist/transform/transformDataset.js +15 -18
- package/dist/writeDatasetRows.tool.d.ts +188 -0
- package/dist/writeDatasetRows.tool.js +258 -0
- package/package.json +35 -10
- package/dist/clearDataset.tool.d.ts.map +0 -1
- package/dist/clearDataset.tool.js.map +0 -1
- package/dist/completeDataset.tool.d.ts.map +0 -1
- package/dist/completeDataset.tool.js.map +0 -1
- package/dist/dataset/steps.d.ts.map +0 -1
- package/dist/dataset/steps.js.map +0 -1
- package/dist/dataset.d.ts.map +0 -1
- package/dist/dataset.js.map +0 -1
- package/dist/datasetFiles.d.ts.map +0 -1
- package/dist/datasetFiles.js.map +0 -1
- package/dist/domain.d.ts.map +0 -1
- package/dist/domain.js.map +0 -1
- package/dist/eventsReactRuntime.d.ts +0 -22
- package/dist/eventsReactRuntime.d.ts.map +0 -1
- package/dist/eventsReactRuntime.js +0 -29
- package/dist/eventsReactRuntime.js.map +0 -1
- package/dist/executeCommand.tool.d.ts.map +0 -1
- package/dist/executeCommand.tool.js.map +0 -1
- package/dist/file/file-dataset.agent.d.ts.map +0 -1
- package/dist/file/file-dataset.agent.js.map +0 -1
- package/dist/file/filepreview.d.ts.map +0 -1
- package/dist/file/filepreview.js.map +0 -1
- package/dist/file/generateSchema.tool.d.ts.map +0 -1
- package/dist/file/generateSchema.tool.js.map +0 -1
- package/dist/file/index.d.ts.map +0 -1
- package/dist/file/index.js.map +0 -1
- package/dist/file/prompts.d.ts.map +0 -1
- package/dist/file/prompts.js.map +0 -1
- package/dist/file/steps.d.ts.map +0 -1
- package/dist/file/steps.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/materializeDataset.tool.d.ts.map +0 -1
- package/dist/materializeDataset.tool.js.map +0 -1
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js.map +0 -1
- package/dist/query/queryDomain.d.ts.map +0 -1
- package/dist/query/queryDomain.js.map +0 -1
- package/dist/query/queryDomain.step.d.ts.map +0 -1
- package/dist/query/queryDomain.step.js.map +0 -1
- package/dist/sandbox/steps.d.ts.map +0 -1
- package/dist/sandbox/steps.js.map +0 -1
- package/dist/sandbox.steps.d.ts.map +0 -1
- package/dist/sandbox.steps.js.map +0 -1
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js.map +0 -1
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js.map +0 -1
- package/dist/skill.d.ts.map +0 -1
- package/dist/skill.js.map +0 -1
- package/dist/transform/filepreview.d.ts.map +0 -1
- package/dist/transform/filepreview.js.map +0 -1
- package/dist/transform/index.d.ts.map +0 -1
- package/dist/transform/index.js.map +0 -1
- package/dist/transform/prompts.d.ts.map +0 -1
- package/dist/transform/prompts.js.map +0 -1
- package/dist/transform/transform-dataset.agent.d.ts.map +0 -1
- package/dist/transform/transform-dataset.agent.js.map +0 -1
- package/dist/transform/transformDataset.d.ts.map +0 -1
- package/dist/transform/transformDataset.js.map +0 -1
package/dist/sandbox/steps.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
+
import { type SandboxConfig } from "@ekairos/sandbox";
|
|
1
2
|
export type DatasetSandboxId = string;
|
|
2
|
-
export type CreateDatasetSandboxParams = {
|
|
3
|
-
|
|
4
|
-
timeoutMs?: number;
|
|
5
|
-
ports?: number[];
|
|
6
|
-
resources?: {
|
|
7
|
-
vcpus?: number;
|
|
8
|
-
};
|
|
9
|
-
purpose?: string;
|
|
10
|
-
params?: Record<string, any>;
|
|
3
|
+
export type CreateDatasetSandboxParams = Pick<SandboxConfig, "provider" | "timeoutMs" | "ports" | "resources" | "purpose" | "params" | "env" | "domain" | "dataset" | "vercel"> & {
|
|
4
|
+
sandboxRuntime?: string;
|
|
11
5
|
};
|
|
12
6
|
export type DatasetSandboxRunCommandResult = {
|
|
13
7
|
exitCode: number;
|
|
@@ -15,33 +9,47 @@ export type DatasetSandboxRunCommandResult = {
|
|
|
15
9
|
stderr: string;
|
|
16
10
|
};
|
|
17
11
|
export declare function createDatasetSandboxStep(params: {
|
|
18
|
-
|
|
12
|
+
runtime: any;
|
|
19
13
|
} & CreateDatasetSandboxParams): Promise<{
|
|
20
14
|
sandboxId: DatasetSandboxId;
|
|
21
15
|
}>;
|
|
22
16
|
export declare function runDatasetSandboxCommandStep(params: {
|
|
23
|
-
|
|
17
|
+
runtime: any;
|
|
24
18
|
sandboxId: DatasetSandboxId;
|
|
25
19
|
cmd: string;
|
|
26
20
|
args?: string[];
|
|
27
21
|
}): Promise<DatasetSandboxRunCommandResult>;
|
|
28
22
|
export declare function writeDatasetSandboxFilesStep(params: {
|
|
29
|
-
|
|
23
|
+
runtime: any;
|
|
30
24
|
sandboxId: DatasetSandboxId;
|
|
31
25
|
files: Array<{
|
|
32
26
|
path: string;
|
|
33
27
|
contentBase64: string;
|
|
34
28
|
}>;
|
|
35
29
|
}): Promise<void>;
|
|
30
|
+
export declare function writeDatasetSandboxTextFilesStep(params: {
|
|
31
|
+
runtime: any;
|
|
32
|
+
sandboxId: DatasetSandboxId;
|
|
33
|
+
files: Array<{
|
|
34
|
+
path: string;
|
|
35
|
+
content: string;
|
|
36
|
+
}>;
|
|
37
|
+
}): Promise<void>;
|
|
36
38
|
export declare function readDatasetSandboxFileStep(params: {
|
|
37
|
-
|
|
39
|
+
runtime: any;
|
|
38
40
|
sandboxId: DatasetSandboxId;
|
|
39
41
|
path: string;
|
|
40
42
|
}): Promise<{
|
|
41
43
|
contentBase64: string;
|
|
42
44
|
}>;
|
|
45
|
+
export declare function readDatasetSandboxTextFileStep(params: {
|
|
46
|
+
runtime: any;
|
|
47
|
+
sandboxId: DatasetSandboxId;
|
|
48
|
+
path: string;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
content: string;
|
|
51
|
+
}>;
|
|
43
52
|
export declare function stopDatasetSandboxStep(params: {
|
|
44
|
-
|
|
53
|
+
runtime: any;
|
|
45
54
|
sandboxId: DatasetSandboxId;
|
|
46
55
|
}): Promise<void>;
|
|
47
|
-
//# sourceMappingURL=steps.d.ts.map
|
package/dist/sandbox/steps.js
CHANGED
|
@@ -1,63 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.createDatasetSandboxStep = createDatasetSandboxStep;
|
|
40
|
-
exports.runDatasetSandboxCommandStep = runDatasetSandboxCommandStep;
|
|
41
|
-
exports.writeDatasetSandboxFilesStep = writeDatasetSandboxFilesStep;
|
|
42
|
-
exports.readDatasetSandboxFileStep = readDatasetSandboxFileStep;
|
|
43
|
-
exports.stopDatasetSandboxStep = stopDatasetSandboxStep;
|
|
44
|
-
const node_child_process_1 = require("node:child_process");
|
|
45
|
-
const node_fs_1 = require("node:fs");
|
|
46
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
47
|
-
const node_util_1 = require("node:util");
|
|
48
|
-
const runtime_1 = require("@ekairos/events/runtime");
|
|
49
|
-
const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { SandboxService } from "@ekairos/sandbox";
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
50
7
|
const localSandboxRoots = new Map();
|
|
51
8
|
function isLocalDatasetSandboxMode() {
|
|
52
9
|
return String(process.env.DATASET_TEST_LOCAL_SANDBOX ?? "").trim() === "1";
|
|
53
10
|
}
|
|
11
|
+
async function getRuntimeDb(runtime) {
|
|
12
|
+
if (!runtime) {
|
|
13
|
+
throw new Error("Dataset sandbox step requires runtime.");
|
|
14
|
+
}
|
|
15
|
+
const db = runtime.db;
|
|
16
|
+
return typeof db === "function" ? await db.call(runtime) : db;
|
|
17
|
+
}
|
|
54
18
|
function getLocalSandboxRoot(sandboxId) {
|
|
55
19
|
return (localSandboxRoots.get(sandboxId) ||
|
|
56
|
-
|
|
20
|
+
path.resolve(process.cwd(), "test-results", "dataset-sandboxes", sandboxId));
|
|
57
21
|
}
|
|
58
22
|
async function ensureLocalSandboxRoot(sandboxId) {
|
|
59
23
|
const root = getLocalSandboxRoot(sandboxId);
|
|
60
|
-
await
|
|
24
|
+
await fs.mkdir(root, { recursive: true });
|
|
61
25
|
localSandboxRoots.set(sandboxId, root);
|
|
62
26
|
return root;
|
|
63
27
|
}
|
|
@@ -66,18 +30,20 @@ async function runLocalSandboxCommand(params) {
|
|
|
66
30
|
const cmd = String(params.cmd ?? "").trim();
|
|
67
31
|
const args = params.args ?? [];
|
|
68
32
|
if (cmd === "mkdir") {
|
|
69
|
-
const
|
|
70
|
-
|
|
33
|
+
const targets = args.filter((arg) => !String(arg).startsWith("-"));
|
|
34
|
+
for (const target of targets) {
|
|
35
|
+
await fs.mkdir(String(target ?? ""), { recursive: true });
|
|
36
|
+
}
|
|
71
37
|
return { exitCode: 0, stdout: "", stderr: "" };
|
|
72
38
|
}
|
|
73
39
|
if (cmd === "rm") {
|
|
74
40
|
const target = args[args.length - 1];
|
|
75
|
-
await
|
|
41
|
+
await fs.rm(String(target ?? ""), { force: true, recursive: false });
|
|
76
42
|
return { exitCode: 0, stdout: "", stderr: "" };
|
|
77
43
|
}
|
|
78
44
|
if (cmd === "test" && args[0] === "-f") {
|
|
79
45
|
try {
|
|
80
|
-
await
|
|
46
|
+
await fs.access(String(args[1] ?? ""));
|
|
81
47
|
return { exitCode: 0, stdout: "", stderr: "" };
|
|
82
48
|
}
|
|
83
49
|
catch {
|
|
@@ -99,22 +65,26 @@ async function runLocalSandboxCommand(params) {
|
|
|
99
65
|
stderr: String(result.stderr ?? ""),
|
|
100
66
|
};
|
|
101
67
|
}
|
|
102
|
-
async function createDatasetSandboxStep(params) {
|
|
68
|
+
export async function createDatasetSandboxStep(params) {
|
|
103
69
|
"use step";
|
|
104
70
|
if (isLocalDatasetSandboxMode()) {
|
|
105
71
|
const sandboxId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
106
72
|
await ensureLocalSandboxRoot(sandboxId);
|
|
107
73
|
return { sandboxId };
|
|
108
74
|
}
|
|
109
|
-
const db =
|
|
110
|
-
const { SandboxService } = (await Promise.resolve().then(() => __importStar(require("@ekairos/sandbox"))));
|
|
75
|
+
const db = await getRuntimeDb(params.runtime);
|
|
111
76
|
const service = new SandboxService(db);
|
|
112
|
-
const
|
|
77
|
+
const sandboxParams = {
|
|
78
|
+
...params,
|
|
79
|
+
...(params.sandboxRuntime ? { runtime: params.sandboxRuntime } : {}),
|
|
80
|
+
};
|
|
81
|
+
delete sandboxParams.sandboxRuntime;
|
|
82
|
+
const created = await service.createSandbox(sandboxParams);
|
|
113
83
|
if (!created.ok)
|
|
114
84
|
throw new Error(created.error);
|
|
115
85
|
return { sandboxId: created.data.sandboxId };
|
|
116
86
|
}
|
|
117
|
-
async function runDatasetSandboxCommandStep(params) {
|
|
87
|
+
export async function runDatasetSandboxCommandStep(params) {
|
|
118
88
|
"use step";
|
|
119
89
|
if (isLocalDatasetSandboxMode()) {
|
|
120
90
|
return await runLocalSandboxCommand({
|
|
@@ -123,8 +93,7 @@ async function runDatasetSandboxCommandStep(params) {
|
|
|
123
93
|
args: params.args,
|
|
124
94
|
});
|
|
125
95
|
}
|
|
126
|
-
const db =
|
|
127
|
-
const { SandboxService } = (await Promise.resolve().then(() => __importStar(require("@ekairos/sandbox"))));
|
|
96
|
+
const db = await getRuntimeDb(params.runtime);
|
|
128
97
|
const service = new SandboxService(db);
|
|
129
98
|
const result = await service.runCommand(params.sandboxId, params.cmd, params.args ?? []);
|
|
130
99
|
if (!result.ok)
|
|
@@ -135,49 +104,77 @@ async function runDatasetSandboxCommandStep(params) {
|
|
|
135
104
|
stderr: result.data.error ?? "",
|
|
136
105
|
};
|
|
137
106
|
}
|
|
138
|
-
async function writeDatasetSandboxFilesStep(params) {
|
|
107
|
+
export async function writeDatasetSandboxFilesStep(params) {
|
|
139
108
|
"use step";
|
|
140
109
|
if (isLocalDatasetSandboxMode()) {
|
|
141
110
|
for (const file of params.files) {
|
|
142
|
-
await
|
|
143
|
-
await
|
|
111
|
+
await fs.mkdir(path.dirname(file.path), { recursive: true });
|
|
112
|
+
await fs.writeFile(file.path, Buffer.from(file.contentBase64, "base64"));
|
|
144
113
|
}
|
|
145
114
|
return;
|
|
146
115
|
}
|
|
147
|
-
const db =
|
|
148
|
-
const { SandboxService } = (await Promise.resolve().then(() => __importStar(require("@ekairos/sandbox"))));
|
|
116
|
+
const db = await getRuntimeDb(params.runtime);
|
|
149
117
|
const service = new SandboxService(db);
|
|
150
118
|
const result = await service.writeFiles(params.sandboxId, params.files);
|
|
151
119
|
if (!result.ok)
|
|
152
120
|
throw new Error(result.error);
|
|
153
121
|
}
|
|
154
|
-
async function
|
|
122
|
+
export async function writeDatasetSandboxTextFilesStep(params) {
|
|
155
123
|
"use step";
|
|
156
124
|
if (isLocalDatasetSandboxMode()) {
|
|
157
|
-
const
|
|
125
|
+
for (const file of params.files) {
|
|
126
|
+
await fs.mkdir(path.dirname(file.path), { recursive: true });
|
|
127
|
+
await fs.writeFile(file.path, file.content, "utf-8");
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const db = await getRuntimeDb(params.runtime);
|
|
132
|
+
const service = new SandboxService(db);
|
|
133
|
+
const files = params.files.map((file) => ({
|
|
134
|
+
path: file.path,
|
|
135
|
+
contentBase64: Buffer.from(file.content, "utf-8").toString("base64"),
|
|
136
|
+
}));
|
|
137
|
+
const result = await service.writeFiles(params.sandboxId, files);
|
|
138
|
+
if (!result.ok)
|
|
139
|
+
throw new Error(result.error);
|
|
140
|
+
}
|
|
141
|
+
export async function readDatasetSandboxFileStep(params) {
|
|
142
|
+
"use step";
|
|
143
|
+
if (isLocalDatasetSandboxMode()) {
|
|
144
|
+
const content = await fs.readFile(params.path);
|
|
158
145
|
return { contentBase64: Buffer.from(content).toString("base64") };
|
|
159
146
|
}
|
|
160
|
-
const db =
|
|
161
|
-
const { SandboxService } = (await Promise.resolve().then(() => __importStar(require("@ekairos/sandbox"))));
|
|
147
|
+
const db = await getRuntimeDb(params.runtime);
|
|
162
148
|
const service = new SandboxService(db);
|
|
163
149
|
const result = await service.readFile(params.sandboxId, params.path);
|
|
164
150
|
if (!result.ok)
|
|
165
151
|
throw new Error(result.error);
|
|
166
152
|
return result.data;
|
|
167
153
|
}
|
|
168
|
-
async function
|
|
154
|
+
export async function readDatasetSandboxTextFileStep(params) {
|
|
155
|
+
"use step";
|
|
156
|
+
if (isLocalDatasetSandboxMode()) {
|
|
157
|
+
const content = await fs.readFile(params.path, "utf-8");
|
|
158
|
+
return { content };
|
|
159
|
+
}
|
|
160
|
+
const db = await getRuntimeDb(params.runtime);
|
|
161
|
+
const service = new SandboxService(db);
|
|
162
|
+
const result = await service.readFile(params.sandboxId, params.path);
|
|
163
|
+
if (!result.ok)
|
|
164
|
+
throw new Error(result.error);
|
|
165
|
+
return { content: Buffer.from(result.data.contentBase64, "base64").toString("utf-8") };
|
|
166
|
+
}
|
|
167
|
+
export async function stopDatasetSandboxStep(params) {
|
|
169
168
|
"use step";
|
|
170
169
|
if (isLocalDatasetSandboxMode()) {
|
|
171
170
|
const root = getLocalSandboxRoot(params.sandboxId);
|
|
172
|
-
await
|
|
171
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
173
172
|
localSandboxRoots.delete(params.sandboxId);
|
|
174
173
|
return;
|
|
175
174
|
}
|
|
176
|
-
const db =
|
|
177
|
-
const { SandboxService } = (await Promise.resolve().then(() => __importStar(require("@ekairos/sandbox"))));
|
|
175
|
+
const db = await getRuntimeDb(params.runtime);
|
|
178
176
|
const service = new SandboxService(db);
|
|
179
177
|
const result = await service.stopSandbox(params.sandboxId);
|
|
180
178
|
if (!result.ok)
|
|
181
179
|
throw new Error(result.error);
|
|
182
180
|
}
|
|
183
|
-
//# sourceMappingURL=steps.js.map
|
package/dist/sandbox.steps.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./sandbox/steps";
|
|
2
|
-
//# sourceMappingURL=sandbox.steps.d.ts.map
|
|
1
|
+
export * from "./sandbox/steps.js";
|
package/dist/sandbox.steps.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./sandbox/steps"), exports);
|
|
18
|
-
//# sourceMappingURL=sandbox.steps.js.map
|
|
1
|
+
export * from "./sandbox/steps.js";
|
package/dist/schema.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ declare const entities: {
|
|
|
8
8
|
updatedAt: import("@instantdb/core").DataAttrDef<number, false, false, false>;
|
|
9
9
|
organizationId: import("@instantdb/core").DataAttrDef<string, false, true, false>;
|
|
10
10
|
title: import("@instantdb/core").DataAttrDef<string, false, false, false>;
|
|
11
|
-
sources: import("@instantdb/core").DataAttrDef<any, false, false, false>;
|
|
12
|
-
sourceKinds: import("@instantdb/core").DataAttrDef<any, false, false, false>;
|
|
13
11
|
instructions: import("@instantdb/core").DataAttrDef<string, false, false, false>;
|
|
14
12
|
analysis: import("@instantdb/core").DataAttrDef<any, false, false, false>;
|
|
15
13
|
schema: import("@instantdb/core").DataAttrDef<any, false, false, false>;
|
|
@@ -21,15 +19,6 @@ declare const entities: {
|
|
|
21
19
|
order: import("@instantdb/core").DataAttrDef<number, true, true, false>;
|
|
22
20
|
createdAt: import("@instantdb/core").DataAttrDef<number, true, false, false>;
|
|
23
21
|
}, {}, void>;
|
|
24
|
-
readonly $files: import("@instantdb/core").EntityDef<{
|
|
25
|
-
path: import("@instantdb/core").DataAttrDef<string, false, true, false>;
|
|
26
|
-
url: import("@instantdb/core").DataAttrDef<string, false, false, false>;
|
|
27
|
-
name: import("@instantdb/core").DataAttrDef<string, false, false, false>;
|
|
28
|
-
contentType: import("@instantdb/core").DataAttrDef<string, false, false, false>;
|
|
29
|
-
size: import("@instantdb/core").DataAttrDef<number, false, false, false>;
|
|
30
|
-
createdAt: import("@instantdb/core").DataAttrDef<number, false, true, false>;
|
|
31
|
-
updatedAt: import("@instantdb/core").DataAttrDef<number, false, true, false>;
|
|
32
|
-
}, {}, void>;
|
|
33
22
|
};
|
|
34
23
|
declare const links: {
|
|
35
24
|
readonly dataset_datasetsRecords: {
|
|
@@ -56,8 +45,19 @@ declare const links: {
|
|
|
56
45
|
readonly label: "datasets";
|
|
57
46
|
};
|
|
58
47
|
};
|
|
48
|
+
readonly dataset_datasetsContext: {
|
|
49
|
+
readonly forward: {
|
|
50
|
+
readonly on: "dataset_datasets";
|
|
51
|
+
readonly has: "one";
|
|
52
|
+
readonly label: "context";
|
|
53
|
+
};
|
|
54
|
+
readonly reverse: {
|
|
55
|
+
readonly on: "event_contexts";
|
|
56
|
+
readonly has: "many";
|
|
57
|
+
readonly label: "datasets";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
59
60
|
};
|
|
60
61
|
declare const rooms: {};
|
|
61
|
-
export declare const datasetDomain: DomainSchemaResult<typeof entities, typeof links, typeof rooms>;
|
|
62
|
+
export declare const datasetDomain: DomainSchemaResult<typeof entities, typeof links, typeof rooms, {}, "dataset", "dataset">;
|
|
62
63
|
export {};
|
|
63
|
-
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.js
CHANGED
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@instantdb/core");
|
|
5
|
-
const domain_1 = require("@ekairos/domain");
|
|
1
|
+
import { i } from "@instantdb/core";
|
|
2
|
+
import { domain } from "@ekairos/domain";
|
|
3
|
+
import { eventsDomain } from "@ekairos/events";
|
|
6
4
|
const entities = {
|
|
7
|
-
dataset_datasets:
|
|
8
|
-
datasetId:
|
|
9
|
-
sandboxId:
|
|
10
|
-
status:
|
|
11
|
-
createdAt:
|
|
12
|
-
updatedAt:
|
|
13
|
-
organizationId:
|
|
14
|
-
title:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
calculatedTotalRows: core_1.i.number().optional(),
|
|
21
|
-
actualGeneratedRowCount: core_1.i.number().optional(),
|
|
5
|
+
dataset_datasets: i.entity({
|
|
6
|
+
datasetId: i.string().unique().indexed(),
|
|
7
|
+
sandboxId: i.string().optional().indexed(),
|
|
8
|
+
status: i.string().optional().indexed(),
|
|
9
|
+
createdAt: i.number().optional().indexed(),
|
|
10
|
+
updatedAt: i.number().optional(),
|
|
11
|
+
organizationId: i.string().optional().indexed(),
|
|
12
|
+
title: i.string().optional(),
|
|
13
|
+
instructions: i.string().optional(),
|
|
14
|
+
analysis: i.json().optional(),
|
|
15
|
+
schema: i.json().optional(),
|
|
16
|
+
calculatedTotalRows: i.number().optional(),
|
|
17
|
+
actualGeneratedRowCount: i.number().optional(),
|
|
22
18
|
}),
|
|
23
|
-
dataset_records:
|
|
24
|
-
rowContent:
|
|
25
|
-
order:
|
|
26
|
-
createdAt:
|
|
27
|
-
}),
|
|
28
|
-
// Keep $files compatible with Instant's base file fields used by dataset agents/tools.
|
|
29
|
-
// (path/url are required by file download + dataset output linking)
|
|
30
|
-
$files: core_1.i.entity({
|
|
31
|
-
path: core_1.i.string().optional().indexed(),
|
|
32
|
-
url: core_1.i.string().optional(),
|
|
33
|
-
name: core_1.i.string().optional(),
|
|
34
|
-
contentType: core_1.i.string().optional(),
|
|
35
|
-
size: core_1.i.number().optional(),
|
|
36
|
-
createdAt: core_1.i.number().optional().indexed(),
|
|
37
|
-
updatedAt: core_1.i.number().optional().indexed(),
|
|
19
|
+
dataset_records: i.entity({
|
|
20
|
+
rowContent: i.json(),
|
|
21
|
+
order: i.number().indexed(),
|
|
22
|
+
createdAt: i.number(),
|
|
38
23
|
}),
|
|
39
24
|
};
|
|
40
25
|
const links = {
|
|
@@ -46,11 +31,14 @@ const links = {
|
|
|
46
31
|
forward: { on: "dataset_datasets", has: "one", label: "dataFile" },
|
|
47
32
|
reverse: { on: "$files", has: "many", label: "datasets" },
|
|
48
33
|
},
|
|
34
|
+
dataset_datasetsContext: {
|
|
35
|
+
forward: { on: "dataset_datasets", has: "one", label: "context" },
|
|
36
|
+
reverse: { on: "event_contexts", has: "many", label: "datasets" },
|
|
37
|
+
},
|
|
49
38
|
};
|
|
50
39
|
const rooms = {};
|
|
51
|
-
|
|
40
|
+
export const datasetDomain = domain("dataset").includes(eventsDomain).withSchema({
|
|
52
41
|
entities,
|
|
53
42
|
links,
|
|
54
43
|
rooms,
|
|
55
44
|
});
|
|
56
|
-
//# sourceMappingURL=schema.js.map
|
package/dist/service.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InstantAdminDatabase } from "@instantdb/admin";
|
|
1
|
+
import type { InstantAdminDatabase } from "@instantdb/admin";
|
|
2
2
|
import { SchemaOf } from "@ekairos/domain";
|
|
3
|
-
import { datasetDomain } from "./schema";
|
|
3
|
+
import { datasetDomain } from "./schema.js";
|
|
4
4
|
export type ServiceResult<T = any> = {
|
|
5
5
|
ok: true;
|
|
6
6
|
data: T;
|
|
@@ -15,8 +15,7 @@ export declare class DatasetService {
|
|
|
15
15
|
private resolveDatasetEntityId;
|
|
16
16
|
createDataset(params: {
|
|
17
17
|
id?: string;
|
|
18
|
-
|
|
19
|
-
sourceKinds?: any;
|
|
18
|
+
contextId?: string;
|
|
20
19
|
instructions?: string;
|
|
21
20
|
status?: string;
|
|
22
21
|
organizationId?: string;
|
|
@@ -64,6 +63,7 @@ export declare class DatasetService {
|
|
|
64
63
|
uploadDatasetOutputFile(params: {
|
|
65
64
|
datasetId: string;
|
|
66
65
|
fileBuffer: Buffer;
|
|
66
|
+
storagePath?: string;
|
|
67
67
|
}): Promise<ServiceResult<{
|
|
68
68
|
fileId: string;
|
|
69
69
|
storagePath: string;
|
|
@@ -74,6 +74,10 @@ export declare class DatasetService {
|
|
|
74
74
|
storagePath: string;
|
|
75
75
|
}): Promise<ServiceResult<void>>;
|
|
76
76
|
readRecordsFromFile(datasetId: string): Promise<ServiceResult<AsyncGenerator<any, void, unknown>>>;
|
|
77
|
+
readLinkedRecords(datasetId: string): Promise<ServiceResult<Array<{
|
|
78
|
+
rowContent: any;
|
|
79
|
+
order: number;
|
|
80
|
+
}>>>;
|
|
77
81
|
previewRows(datasetId: string, limit?: number): Promise<ServiceResult<any[]>>;
|
|
78
82
|
readRows(params: {
|
|
79
83
|
datasetId: string;
|
|
@@ -87,4 +91,3 @@ export declare class DatasetService {
|
|
|
87
91
|
readOne(datasetId: string): Promise<ServiceResult<any | null>>;
|
|
88
92
|
}
|
|
89
93
|
export {};
|
|
90
|
-
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DatasetService = void 0;
|
|
4
|
-
const admin_1 = require("@instantdb/admin");
|
|
5
|
-
class DatasetService {
|
|
1
|
+
import { createDatasetId } from "./id.js";
|
|
2
|
+
export class DatasetService {
|
|
6
3
|
constructor(db) {
|
|
7
4
|
this.db = db;
|
|
8
5
|
}
|
|
@@ -30,19 +27,22 @@ class DatasetService {
|
|
|
30
27
|
}
|
|
31
28
|
async createDataset(params) {
|
|
32
29
|
try {
|
|
33
|
-
const datasetId = params.id ?? (
|
|
30
|
+
const datasetId = params.id ?? createDatasetId();
|
|
31
|
+
const { id: _id, contextId, ...attrs } = params;
|
|
34
32
|
const existing = await this.resolveDatasetEntityId(datasetId);
|
|
35
|
-
const entityId = existing.ok ? existing.data : (
|
|
33
|
+
const entityId = existing.ok ? existing.data : createDatasetId();
|
|
36
34
|
const mutations = [];
|
|
37
35
|
mutations.push(this.db.tx.dataset_datasets[entityId].update({
|
|
38
36
|
datasetId,
|
|
39
|
-
sources: params.sources ?? "",
|
|
40
37
|
instructions: params.instructions ?? "",
|
|
41
38
|
status: params.status ?? "created",
|
|
42
39
|
createdAt: Date.now(),
|
|
43
40
|
updatedAt: Date.now(),
|
|
44
|
-
...
|
|
41
|
+
...attrs,
|
|
45
42
|
}));
|
|
43
|
+
if (contextId) {
|
|
44
|
+
mutations.push(this.db.tx.dataset_datasets[entityId].link({ context: contextId }));
|
|
45
|
+
}
|
|
46
46
|
await this.db.transact(mutations);
|
|
47
47
|
return { ok: true, data: { datasetId } };
|
|
48
48
|
}
|
|
@@ -76,7 +76,7 @@ class DatasetService {
|
|
|
76
76
|
return resolved;
|
|
77
77
|
const mutations = [];
|
|
78
78
|
for (const record of params.records) {
|
|
79
|
-
const recordId = (
|
|
79
|
+
const recordId = createDatasetId();
|
|
80
80
|
mutations.push(this.db.tx.dataset_records[recordId].update({
|
|
81
81
|
rowContent: record.rowContent,
|
|
82
82
|
order: record.order,
|
|
@@ -311,7 +311,7 @@ class DatasetService {
|
|
|
311
311
|
}
|
|
312
312
|
async uploadDatasetOutputFile(params) {
|
|
313
313
|
try {
|
|
314
|
-
const storagePath = `/dataset/${params.datasetId}/output.jsonl`;
|
|
314
|
+
const storagePath = params.storagePath ?? `/dataset/${params.datasetId}/output.jsonl`;
|
|
315
315
|
const uploadResult = await this.db.storage.uploadFile(storagePath, params.fileBuffer, {
|
|
316
316
|
contentType: "application/x-ndjson",
|
|
317
317
|
contentDisposition: "output.jsonl",
|
|
@@ -432,8 +432,51 @@ class DatasetService {
|
|
|
432
432
|
return { ok: false, error: message };
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
+
async readLinkedRecords(datasetId) {
|
|
436
|
+
try {
|
|
437
|
+
const query = await this.db.query({
|
|
438
|
+
dataset_datasets: {
|
|
439
|
+
$: {
|
|
440
|
+
where: { datasetId },
|
|
441
|
+
limit: 1,
|
|
442
|
+
},
|
|
443
|
+
records: {},
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
const datasetRecord = query.dataset_datasets?.[0];
|
|
447
|
+
if (!datasetRecord) {
|
|
448
|
+
return { ok: false, error: `Dataset not found with id: ${datasetId}` };
|
|
449
|
+
}
|
|
450
|
+
const linkedRecords = Array.isArray(datasetRecord?.records)
|
|
451
|
+
? datasetRecord.records
|
|
452
|
+
: [];
|
|
453
|
+
return {
|
|
454
|
+
ok: true,
|
|
455
|
+
data: linkedRecords
|
|
456
|
+
.slice()
|
|
457
|
+
.sort((a, b) => Number(a?.order ?? 0) - Number(b?.order ?? 0))
|
|
458
|
+
.map((record) => ({
|
|
459
|
+
rowContent: record?.rowContent,
|
|
460
|
+
order: Number(record?.order ?? 0),
|
|
461
|
+
})),
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
466
|
+
return { ok: false, error: message };
|
|
467
|
+
}
|
|
468
|
+
}
|
|
435
469
|
async previewRows(datasetId, limit = 20) {
|
|
436
470
|
try {
|
|
471
|
+
const linkedRecords = await this.readLinkedRecords(datasetId);
|
|
472
|
+
if (linkedRecords.ok && linkedRecords.data.length > 0) {
|
|
473
|
+
return {
|
|
474
|
+
ok: true,
|
|
475
|
+
data: linkedRecords.data
|
|
476
|
+
.slice(0, Math.max(0, Number(limit ?? 20)))
|
|
477
|
+
.map((record) => record.rowContent),
|
|
478
|
+
};
|
|
479
|
+
}
|
|
437
480
|
const readResult = await this.readRecordsFromFile(datasetId);
|
|
438
481
|
if (!readResult.ok) {
|
|
439
482
|
return readResult;
|
|
@@ -454,12 +497,26 @@ class DatasetService {
|
|
|
454
497
|
}
|
|
455
498
|
async readRows(params) {
|
|
456
499
|
try {
|
|
500
|
+
const start = Math.max(0, Number(params.cursor ?? 0));
|
|
501
|
+
const limit = Math.max(1, Number(params.limit ?? 200));
|
|
502
|
+
const linkedRecords = await this.readLinkedRecords(params.datasetId);
|
|
503
|
+
if (linkedRecords.ok && linkedRecords.data.length > 0) {
|
|
504
|
+
const rows = linkedRecords.data
|
|
505
|
+
.slice(start, start + limit)
|
|
506
|
+
.map((record) => record.rowContent);
|
|
507
|
+
return {
|
|
508
|
+
ok: true,
|
|
509
|
+
data: {
|
|
510
|
+
rows,
|
|
511
|
+
cursor: start + rows.length,
|
|
512
|
+
done: start + rows.length >= linkedRecords.data.length,
|
|
513
|
+
},
|
|
514
|
+
};
|
|
515
|
+
}
|
|
457
516
|
const readResult = await this.readRecordsFromFile(params.datasetId);
|
|
458
517
|
if (!readResult.ok) {
|
|
459
518
|
return readResult;
|
|
460
519
|
}
|
|
461
|
-
const start = Math.max(0, Number(params.cursor ?? 0));
|
|
462
|
-
const limit = Math.max(1, Number(params.limit ?? 200));
|
|
463
520
|
const rows = [];
|
|
464
521
|
let index = 0;
|
|
465
522
|
let hasMore = false;
|
|
@@ -507,5 +564,3 @@ class DatasetService {
|
|
|
507
564
|
}
|
|
508
565
|
}
|
|
509
566
|
}
|
|
510
|
-
exports.DatasetService = DatasetService;
|
|
511
|
-
//# sourceMappingURL=service.js.map
|
package/dist/skill.d.ts
CHANGED