@ekairos/dataset 1.22.46-beta.development.0 → 1.22.47-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/builder/instructions.d.ts +1 -2
- package/dist/builder/instructions.js +4 -11
- package/dist/builder/materialize.d.ts +1 -2
- package/dist/builder/materialize.js +30 -36
- package/dist/builder/persistence.d.ts +1 -2
- package/dist/builder/persistence.js +17 -26
- package/dist/builder/schemaInference.d.ts +1 -2
- package/dist/builder/schemaInference.js +4 -12
- package/dist/builder/sourceRows.d.ts +0 -1
- package/dist/builder/sourceRows.js +3 -9
- package/dist/builder/types.d.ts +1 -2
- package/dist/builder/types.js +1 -3
- package/dist/clearDataset.tool.d.ts +0 -1
- package/dist/clearDataset.tool.js +12 -16
- package/dist/completeDataset.tool.d.ts +0 -1
- package/dist/completeDataset.tool.js +18 -25
- package/dist/dataset/steps.d.ts +5 -6
- package/dist/dataset/steps.js +25 -36
- package/dist/dataset.d.ts +2 -3
- package/dist/dataset.js +13 -17
- package/dist/datasetFiles.d.ts +0 -1
- package/dist/datasetFiles.js +5 -12
- package/dist/domain.d.ts +1 -2
- package/dist/domain.js +1 -6
- package/dist/eventsReactRuntime.d.ts +0 -1
- package/dist/eventsReactRuntime.js +9 -13
- package/dist/executeCommand.tool.d.ts +0 -1
- package/dist/executeCommand.tool.js +12 -16
- package/dist/file/file-dataset.agent.d.ts +1 -2
- package/dist/file/file-dataset.agent.js +34 -38
- package/dist/file/filepreview.d.ts +0 -1
- package/dist/file/filepreview.js +12 -16
- package/dist/file/generateSchema.tool.d.ts +0 -1
- package/dist/file/generateSchema.tool.js +10 -14
- package/dist/file/index.d.ts +1 -2
- package/dist/file/index.js +1 -18
- package/dist/file/prompts.d.ts +1 -2
- package/dist/file/prompts.js +13 -17
- package/dist/file/steps.d.ts +0 -1
- package/dist/file/steps.js +3 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +6 -23
- package/dist/materializeDataset.tool.d.ts +1 -2
- package/dist/materializeDataset.tool.js +40 -45
- package/dist/query/index.d.ts +1 -2
- package/dist/query/index.js +1 -18
- package/dist/query/queryDomain.d.ts +1 -2
- package/dist/query/queryDomain.js +2 -39
- package/dist/query/queryDomain.step.d.ts +0 -1
- package/dist/query/queryDomain.step.js +8 -12
- package/dist/sandbox/steps.d.ts +0 -1
- package/dist/sandbox/steps.js +30 -74
- package/dist/sandbox.steps.d.ts +1 -2
- package/dist/sandbox.steps.js +1 -18
- package/dist/schema.d.ts +0 -1
- package/dist/schema.js +22 -26
- package/dist/service.d.ts +1 -2
- package/dist/service.js +5 -10
- package/dist/skill.d.ts +0 -1
- package/dist/skill.js +12 -17
- package/dist/transform/filepreview.d.ts +0 -1
- package/dist/transform/filepreview.js +6 -10
- package/dist/transform/index.d.ts +2 -3
- package/dist/transform/index.js +2 -8
- package/dist/transform/prompts.d.ts +0 -1
- package/dist/transform/prompts.js +12 -16
- package/dist/transform/transform-dataset.agent.d.ts +1 -2
- package/dist/transform/transform-dataset.agent.js +31 -35
- package/dist/transform/transformDataset.d.ts +0 -1
- package/dist/transform/transformDataset.js +7 -11
- package/package.json +12 -7
- package/dist/builder/instructions.d.ts.map +0 -1
- package/dist/builder/instructions.js.map +0 -1
- package/dist/builder/materialize.d.ts.map +0 -1
- package/dist/builder/materialize.js.map +0 -1
- package/dist/builder/persistence.d.ts.map +0 -1
- package/dist/builder/persistence.js.map +0 -1
- package/dist/builder/schemaInference.d.ts.map +0 -1
- package/dist/builder/schemaInference.js.map +0 -1
- package/dist/builder/sourceRows.d.ts.map +0 -1
- package/dist/builder/sourceRows.js.map +0 -1
- package/dist/builder/types.d.ts.map +0 -1
- package/dist/builder/types.js.map +0 -1
- 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.map +0 -1
- 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
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const steps_1 = require("../dataset/steps");
|
|
7
|
-
function createGenerateSchemaTool({ datasetId, isNested, fileId, env }) {
|
|
8
|
-
return (0, ai_1.tool)({
|
|
1
|
+
import { tool } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { datasetUpdateSchemaStep } from "../dataset/steps.js";
|
|
4
|
+
export function createGenerateSchemaTool({ datasetId, isNested, fileId, env }) {
|
|
5
|
+
return tool({
|
|
9
6
|
description: `Generate a formal JSON schema for a SINGLE RECORD (row) from the file. This schema describes the structure of ONE record, not the entire dataset or array of records. Requirements:
|
|
10
7
|
1. Schema describes ONE RECORD structure only (no array wrappers)
|
|
11
8
|
2. All property names MUST use lowercaseCamelCase convention (e.g., 'productName', 'unitPrice')
|
|
12
9
|
3. Each property MUST have a description field
|
|
13
10
|
4. The schema description must explain what one record represents and field mappings from original file`,
|
|
14
|
-
inputSchema:
|
|
15
|
-
schemaTitle:
|
|
16
|
-
schemaDescription:
|
|
17
|
-
schemaJson:
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
schemaTitle: z.string().describe("Title for the RECORD schema in PascalCase (e.g., 'ProductRecord', 'TransactionRecord')"),
|
|
13
|
+
schemaDescription: z.string().describe("Comprehensive description that includes: 1) what ONE record represents, 2) its purpose, 3) complete field mapping from original file fields to schema fields with explanations (e.g., 'ARTÍCULO' -> 'articleCode': normalized to camelCase)"),
|
|
14
|
+
schemaJson: z.string().describe("Complete JSON schema as string describing ONE RECORD. Must be type 'object' with properties. All properties must be in lowercaseCamelCase and have descriptions. Do NOT use type 'array' at root level."),
|
|
18
15
|
}),
|
|
19
16
|
execute: async ({ schemaTitle, schemaDescription, schemaJson, }) => {
|
|
20
17
|
console.log(`[Dataset ${datasetId}] ========================================`);
|
|
@@ -74,7 +71,7 @@ function createGenerateSchemaTool({ datasetId, isNested, fileId, env }) {
|
|
|
74
71
|
console.log(`[Dataset ${datasetId}] Description: ${schemaDescription}`);
|
|
75
72
|
console.log(`[Dataset ${datasetId}] Schema JSON:`);
|
|
76
73
|
console.log(JSON.stringify(parsedSchema, null, 2));
|
|
77
|
-
const updateResult = await
|
|
74
|
+
const updateResult = await datasetUpdateSchemaStep({
|
|
78
75
|
env,
|
|
79
76
|
datasetId,
|
|
80
77
|
schema: schemaData,
|
|
@@ -107,4 +104,3 @@ function createGenerateSchemaTool({ datasetId, isNested, fileId, env }) {
|
|
|
107
104
|
},
|
|
108
105
|
});
|
|
109
106
|
}
|
|
110
|
-
//# sourceMappingURL=generateSchema.tool.js.map
|
package/dist/file/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./file-dataset.agent";
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from "./file-dataset.agent.js";
|
package/dist/file/index.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("./file-dataset.agent"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./file-dataset.agent.js";
|
package/dist/file/prompts.d.ts
CHANGED
package/dist/file/prompts.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Plain build API using template literals and XML
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const xmlbuilder2_1 = require("xmlbuilder2");
|
|
6
|
-
const datasetFiles_1 = require("../datasetFiles");
|
|
2
|
+
import { create } from "xmlbuilder2";
|
|
3
|
+
import { getDatasetWorkstation, getDatasetOutputPath } from "../datasetFiles.js";
|
|
7
4
|
function buildRole() {
|
|
8
|
-
let xml =
|
|
5
|
+
let xml = create()
|
|
9
6
|
.ele("Role")
|
|
10
7
|
.txt("You are a dataset creator for a SINGLE file. Your goal is to convert the file content into a validated JSONL dataset where each line represents one record.")
|
|
11
8
|
.up();
|
|
12
9
|
return xml.end({ prettyPrint: true, headless: true });
|
|
13
10
|
}
|
|
14
11
|
function buildGoal() {
|
|
15
|
-
let xml =
|
|
12
|
+
let xml = create()
|
|
16
13
|
.ele("Goal")
|
|
17
14
|
.txt("Convert the source file into a validated JSONL dataset (output.jsonl) where each line is a JSON object conforming to a generated schema. The schema describes ONE data record structure. Extract ONLY data records; exclude any header sections, metadata, or summary information from the file.")
|
|
18
15
|
.up();
|
|
19
16
|
return xml.end({ prettyPrint: true, headless: true });
|
|
20
17
|
}
|
|
21
18
|
function buildSourceInfo(context) {
|
|
22
|
-
let xml =
|
|
19
|
+
let xml = create()
|
|
23
20
|
.ele("Source")
|
|
24
21
|
.ele("Type").txt("file").up()
|
|
25
22
|
.ele("FileId").txt(context.fileId).up()
|
|
@@ -29,7 +26,7 @@ function buildSourceInfo(context) {
|
|
|
29
26
|
return xml;
|
|
30
27
|
}
|
|
31
28
|
function buildFilePreviewSection(preview) {
|
|
32
|
-
let xml =
|
|
29
|
+
let xml = create()
|
|
33
30
|
.ele("FilePreview")
|
|
34
31
|
.ele("TotalRows").txt(String(preview.totalRows)).up();
|
|
35
32
|
if (preview.metadata) {
|
|
@@ -91,7 +88,7 @@ function buildErrorsSection(errors) {
|
|
|
91
88
|
if (errors.length === 0) {
|
|
92
89
|
return null;
|
|
93
90
|
}
|
|
94
|
-
let xml =
|
|
91
|
+
let xml = create()
|
|
95
92
|
.ele("PreviousErrors");
|
|
96
93
|
for (const error of errors) {
|
|
97
94
|
xml = xml.ele("Error").txt(error).up();
|
|
@@ -100,7 +97,7 @@ function buildErrorsSection(errors) {
|
|
|
100
97
|
return xml;
|
|
101
98
|
}
|
|
102
99
|
function buildContextSection(context) {
|
|
103
|
-
let xml =
|
|
100
|
+
let xml = create()
|
|
104
101
|
.ele("Context");
|
|
105
102
|
const sourceXml = buildSourceInfo(context);
|
|
106
103
|
xml = xml.import(sourceXml.first());
|
|
@@ -121,7 +118,7 @@ function buildSchemaSection(context) {
|
|
|
121
118
|
if (!context.schema) {
|
|
122
119
|
return "";
|
|
123
120
|
}
|
|
124
|
-
let xml =
|
|
121
|
+
let xml = create()
|
|
125
122
|
.com("Schema section: This defines the structure of ONE RECORD (row). Each line in the JSONL output must conform to this schema.")
|
|
126
123
|
.ele("Schema")
|
|
127
124
|
.ele("Title").txt(context.schema.title || "").up()
|
|
@@ -131,13 +128,13 @@ function buildSchemaSection(context) {
|
|
|
131
128
|
return xml.end({ prettyPrint: true, headless: true });
|
|
132
129
|
}
|
|
133
130
|
function buildInstructions(context) {
|
|
134
|
-
const datasetWorkstation =
|
|
135
|
-
const outputPath =
|
|
131
|
+
const datasetWorkstation = getDatasetWorkstation(context.datasetId);
|
|
132
|
+
const outputPath = getDatasetOutputPath(context.datasetId);
|
|
136
133
|
const hasProvidedSchema = Boolean(context.schema?.schema);
|
|
137
134
|
const currentTask = hasProvidedSchema
|
|
138
135
|
? "Review FilePreview section, use the provided schema as the output contract, then parse the file and generate the dataset"
|
|
139
136
|
: "Review FilePreview section to understand file structure, then generate JSON Schema for a SINGLE RECORD, then parse the file and generate the dataset";
|
|
140
|
-
let xml =
|
|
137
|
+
let xml = create()
|
|
141
138
|
.ele("Instructions")
|
|
142
139
|
.ele("Workflow")
|
|
143
140
|
.ele("Step", { number: "1", name: "Inspect File" })
|
|
@@ -197,7 +194,7 @@ function buildInstructions(context) {
|
|
|
197
194
|
.up();
|
|
198
195
|
return xml.end({ prettyPrint: true, headless: true });
|
|
199
196
|
}
|
|
200
|
-
function buildFileDatasetPrompt(context) {
|
|
197
|
+
export function buildFileDatasetPrompt(context) {
|
|
201
198
|
const sections = [];
|
|
202
199
|
sections.push(buildRole());
|
|
203
200
|
sections.push("");
|
|
@@ -208,4 +205,3 @@ function buildFileDatasetPrompt(context) {
|
|
|
208
205
|
sections.push(buildInstructions(context));
|
|
209
206
|
return sections.join("\n");
|
|
210
207
|
}
|
|
211
|
-
//# sourceMappingURL=prompts.js.map
|
package/dist/file/steps.d.ts
CHANGED
package/dist/file/steps.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.readInstantFileStep = readInstantFileStep;
|
|
4
|
-
const runtime_1 = require("@ekairos/events/runtime");
|
|
5
|
-
async function readInstantFileStep(params) {
|
|
1
|
+
import { getContextRuntime } from "@ekairos/events/runtime";
|
|
2
|
+
export async function readInstantFileStep(params) {
|
|
6
3
|
"use step";
|
|
7
|
-
const db = (await
|
|
4
|
+
const db = (await getContextRuntime(params.env)).db;
|
|
8
5
|
const fileQuery = await db.query({
|
|
9
6
|
$files: { $: { where: { id: params.fileId }, limit: 1 } },
|
|
10
7
|
});
|
|
@@ -20,4 +17,3 @@ async function readInstantFileStep(params) {
|
|
|
20
17
|
contentBase64: Buffer.from(fileBuffer).toString("base64"),
|
|
21
18
|
};
|
|
22
19
|
}
|
|
23
|
-
//# sourceMappingURL=steps.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from "./dataset";
|
|
2
|
-
export * from "./domain";
|
|
3
|
-
export * from "./materializeDataset.tool";
|
|
4
|
-
export * from "./schema";
|
|
5
|
-
export * from "./service";
|
|
6
|
-
export * from "./skill";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from "./dataset.js";
|
|
2
|
+
export * from "./domain.js";
|
|
3
|
+
export * from "./materializeDataset.tool.js";
|
|
4
|
+
export * from "./schema.js";
|
|
5
|
+
export * from "./service.js";
|
|
6
|
+
export * from "./skill.js";
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
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 __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("./dataset"), exports);
|
|
18
|
-
__exportStar(require("./domain"), exports);
|
|
19
|
-
__exportStar(require("./materializeDataset.tool"), exports);
|
|
20
|
-
__exportStar(require("./schema"), exports);
|
|
21
|
-
__exportStar(require("./service"), exports);
|
|
22
|
-
__exportStar(require("./skill"), exports);
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./dataset.js";
|
|
2
|
+
export * from "./domain.js";
|
|
3
|
+
export * from "./materializeDataset.tool.js";
|
|
4
|
+
export * from "./schema.js";
|
|
5
|
+
export * from "./service.js";
|
|
6
|
+
export * from "./skill.js";
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import type { DomainSchemaResult } from "@ekairos/domain";
|
|
3
3
|
import type { EkairosRuntime, RuntimeForDomain } from "@ekairos/domain/runtime";
|
|
4
4
|
import type { ContextReactor } from "@ekairos/events";
|
|
5
|
-
import { datasetDomain } from "./schema";
|
|
5
|
+
import { datasetDomain } from "./schema.js";
|
|
6
6
|
declare const materializeDatasetToolInputSchema: z.ZodObject<{
|
|
7
7
|
datasetId: z.ZodOptional<z.ZodString>;
|
|
8
8
|
sandboxId: z.ZodOptional<z.ZodString>;
|
|
@@ -88,4 +88,3 @@ export declare function createMaterializeDatasetTool<Runtime extends AnyMaterial
|
|
|
88
88
|
datasetId: string;
|
|
89
89
|
}>;
|
|
90
90
|
export { materializeDatasetToolInputSchema };
|
|
91
|
-
//# sourceMappingURL=materializeDataset.tool.d.ts.map
|
|
@@ -1,63 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const fileSourceSchema = zod_1.z.object({
|
|
9
|
-
kind: zod_1.z.literal("file"),
|
|
10
|
-
fileId: zod_1.z.string(),
|
|
11
|
-
description: zod_1.z.string().optional(),
|
|
1
|
+
import { tool } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { dataset } from "./dataset.js";
|
|
4
|
+
const fileSourceSchema = z.object({
|
|
5
|
+
kind: z.literal("file"),
|
|
6
|
+
fileId: z.string(),
|
|
7
|
+
description: z.string().optional(),
|
|
12
8
|
});
|
|
13
|
-
const textSourceSchema =
|
|
14
|
-
kind:
|
|
15
|
-
text:
|
|
16
|
-
mimeType:
|
|
17
|
-
name:
|
|
18
|
-
description:
|
|
9
|
+
const textSourceSchema = z.object({
|
|
10
|
+
kind: z.literal("text"),
|
|
11
|
+
text: z.string(),
|
|
12
|
+
mimeType: z.string().optional(),
|
|
13
|
+
name: z.string().optional(),
|
|
14
|
+
description: z.string().optional(),
|
|
19
15
|
});
|
|
20
|
-
const datasetSourceSchema =
|
|
21
|
-
kind:
|
|
22
|
-
datasetId:
|
|
23
|
-
description:
|
|
16
|
+
const datasetSourceSchema = z.object({
|
|
17
|
+
kind: z.literal("dataset"),
|
|
18
|
+
datasetId: z.string(),
|
|
19
|
+
description: z.string().optional(),
|
|
24
20
|
});
|
|
25
|
-
const querySourceSchema =
|
|
26
|
-
kind:
|
|
27
|
-
query:
|
|
28
|
-
title:
|
|
29
|
-
explanation:
|
|
21
|
+
const querySourceSchema = z.object({
|
|
22
|
+
kind: z.literal("query"),
|
|
23
|
+
query: z.record(z.string(), z.any()),
|
|
24
|
+
title: z.string().optional(),
|
|
25
|
+
explanation: z.string().optional(),
|
|
30
26
|
});
|
|
31
|
-
const datasetSchemaSchema =
|
|
32
|
-
title:
|
|
33
|
-
description:
|
|
34
|
-
schema:
|
|
27
|
+
const datasetSchemaSchema = z.object({
|
|
28
|
+
title: z.string().optional(),
|
|
29
|
+
description: z.string().optional(),
|
|
30
|
+
schema: z.any(),
|
|
35
31
|
});
|
|
36
|
-
const materializeDatasetToolInputSchema =
|
|
37
|
-
datasetId:
|
|
38
|
-
sandboxId:
|
|
39
|
-
title:
|
|
40
|
-
sources:
|
|
41
|
-
.array(
|
|
32
|
+
const materializeDatasetToolInputSchema = z.object({
|
|
33
|
+
datasetId: z.string().optional(),
|
|
34
|
+
sandboxId: z.string().optional(),
|
|
35
|
+
title: z.string().optional(),
|
|
36
|
+
sources: z
|
|
37
|
+
.array(z.discriminatedUnion("kind", [
|
|
42
38
|
fileSourceSchema,
|
|
43
39
|
textSourceSchema,
|
|
44
40
|
datasetSourceSchema,
|
|
45
41
|
querySourceSchema,
|
|
46
42
|
]))
|
|
47
43
|
.min(1),
|
|
48
|
-
instructions:
|
|
49
|
-
mode:
|
|
50
|
-
output:
|
|
44
|
+
instructions: z.string().optional(),
|
|
45
|
+
mode: z.enum(["auto", "schema"]).optional(),
|
|
46
|
+
output: z.enum(["rows", "object"]).optional(),
|
|
51
47
|
schema: datasetSchemaSchema.optional(),
|
|
52
|
-
first:
|
|
48
|
+
first: z.boolean().optional(),
|
|
53
49
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return (0, ai_1.tool)({
|
|
50
|
+
export function createMaterializeDatasetTool(params) {
|
|
51
|
+
return tool({
|
|
57
52
|
description: "Materialize a dataset from declarative sources. Returns only the target datasetId. Query sources use the preconfigured runtime domain.",
|
|
58
53
|
inputSchema: materializeDatasetToolInputSchema,
|
|
59
54
|
execute: async (input) => {
|
|
60
|
-
let builder =
|
|
55
|
+
let builder = dataset(params.runtime);
|
|
61
56
|
if (input.title?.trim()) {
|
|
62
57
|
builder = builder.title(input.title);
|
|
63
58
|
}
|
|
@@ -109,4 +104,4 @@ function createMaterializeDatasetTool(params) {
|
|
|
109
104
|
},
|
|
110
105
|
});
|
|
111
106
|
}
|
|
112
|
-
|
|
107
|
+
export { materializeDatasetToolInputSchema };
|
package/dist/query/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./queryDomain";
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from "./queryDomain.js";
|
package/dist/query/index.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("./queryDomain"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./queryDomain.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryDomainStepInput, QueryDomainStepResult } from "./queryDomain.step";
|
|
1
|
+
import type { QueryDomainStepInput, QueryDomainStepResult } from "./queryDomain.step.js";
|
|
2
2
|
export type QueryDomainInput = QueryDomainStepInput;
|
|
3
3
|
export type QueryDomainResult = QueryDomainStepResult;
|
|
4
4
|
/**
|
|
@@ -6,4 +6,3 @@ export type QueryDomainResult = QueryDomainStepResult;
|
|
|
6
6
|
* Always returns a dataset + preview rows.
|
|
7
7
|
*/
|
|
8
8
|
export declare function queryDomain(input: QueryDomainInput): Promise<QueryDomainResult>;
|
|
9
|
-
//# sourceMappingURL=queryDomain.d.ts.map
|
|
@@ -1,46 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
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 __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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.queryDomain = queryDomain;
|
|
37
1
|
/**
|
|
38
2
|
* Workflow-compatible domain query.
|
|
39
3
|
* Always returns a dataset + preview rows.
|
|
40
4
|
*/
|
|
41
|
-
async function queryDomain(input) {
|
|
5
|
+
export async function queryDomain(input) {
|
|
42
6
|
"use step";
|
|
43
|
-
const { queryDomainStep } = await
|
|
7
|
+
const { queryDomainStep } = await import("./queryDomain.step.js");
|
|
44
8
|
return await queryDomainStep(input);
|
|
45
9
|
}
|
|
46
|
-
//# sourceMappingURL=queryDomain.js.map
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const admin_1 = require("@instantdb/admin");
|
|
5
|
-
const runtime_1 = require("@ekairos/events/runtime");
|
|
6
|
-
const service_1 = require("../service");
|
|
1
|
+
import { id as newId } from "@instantdb/admin";
|
|
2
|
+
import { getContextRuntime, getContextEnv } from "@ekairos/events/runtime";
|
|
3
|
+
import { DatasetService } from "../service.js";
|
|
7
4
|
function normalizeRows(result) {
|
|
8
5
|
if (!result || typeof result !== "object")
|
|
9
6
|
return [];
|
|
@@ -49,13 +46,13 @@ function inferSchema(rows) {
|
|
|
49
46
|
}
|
|
50
47
|
return { schema };
|
|
51
48
|
}
|
|
52
|
-
async function queryDomainStep(params) {
|
|
49
|
+
export async function queryDomainStep(params) {
|
|
53
50
|
"use step";
|
|
54
|
-
const env = await
|
|
55
|
-
const runtime = await
|
|
51
|
+
const env = await getContextEnv();
|
|
52
|
+
const runtime = await getContextRuntime(env);
|
|
56
53
|
const db = runtime.db;
|
|
57
|
-
const service = new
|
|
58
|
-
const datasetId = params.datasetId ?? (
|
|
54
|
+
const service = new DatasetService(db);
|
|
55
|
+
const datasetId = params.datasetId ?? newId();
|
|
59
56
|
const queryResult = await db.query(params.query);
|
|
60
57
|
const rows = normalizeRows(queryResult);
|
|
61
58
|
const previewRows = rows.slice(0, 20);
|
|
@@ -101,4 +98,3 @@ async function queryDomainStep(params) {
|
|
|
101
98
|
explanation: params.explanation,
|
|
102
99
|
};
|
|
103
100
|
}
|
|
104
|
-
//# sourceMappingURL=queryDomain.step.js.map
|
package/dist/sandbox/steps.d.ts
CHANGED