struere 0.8.0 → 0.8.2
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/bin/struere.js +58 -49
- package/dist/cli/index.js +55 -46
- package/dist/cli/templates/index.d.ts.map +1 -1
- package/dist/cli/utils/extractor.d.ts.map +1 -1
- package/dist/cli/utils/loader.d.ts.map +1 -1
- package/dist/cli/utils/plugin.d.ts +1 -1
- package/dist/cli/utils/plugin.d.ts.map +1 -1
- package/dist/define/index.d.ts +3 -0
- package/dist/define/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bin/struere.js
CHANGED
|
@@ -15511,9 +15511,9 @@ var require_nodefs_handler = __commonJS((exports, module) => {
|
|
|
15511
15511
|
if (this.fsw.closed) {
|
|
15512
15512
|
return;
|
|
15513
15513
|
}
|
|
15514
|
-
const
|
|
15514
|
+
const dirname3 = sysPath.dirname(file);
|
|
15515
15515
|
const basename3 = sysPath.basename(file);
|
|
15516
|
-
const parent = this.fsw._getWatchedDir(
|
|
15516
|
+
const parent = this.fsw._getWatchedDir(dirname3);
|
|
15517
15517
|
let prevStats = stats;
|
|
15518
15518
|
if (parent.has(basename3))
|
|
15519
15519
|
return;
|
|
@@ -15538,7 +15538,7 @@ var require_nodefs_handler = __commonJS((exports, module) => {
|
|
|
15538
15538
|
prevStats = newStats2;
|
|
15539
15539
|
}
|
|
15540
15540
|
} catch (error) {
|
|
15541
|
-
this.fsw._remove(
|
|
15541
|
+
this.fsw._remove(dirname3, basename3);
|
|
15542
15542
|
}
|
|
15543
15543
|
} else if (parent.has(basename3)) {
|
|
15544
15544
|
const at = newStats.atimeMs;
|
|
@@ -19889,7 +19889,7 @@ slug: "basic-agent-tests"
|
|
|
19889
19889
|
agent: "${agentSlug}"
|
|
19890
19890
|
description: "Verify agent responds correctly and uses tools appropriately"
|
|
19891
19891
|
tags: ["smoke-test"]
|
|
19892
|
-
judgeModel: "
|
|
19892
|
+
judgeModel: "grok-4-1-fast"
|
|
19893
19893
|
judgePrompt: "Evaluate whether the agent responds correctly and uses appropriate tools. Be lenient on phrasing but strict on factual accuracy."
|
|
19894
19894
|
|
|
19895
19895
|
cases:
|
|
@@ -19946,7 +19946,7 @@ slug: "${slug}"
|
|
|
19946
19946
|
agent: "${agentSlug}"
|
|
19947
19947
|
description: "TODO: Describe what this eval suite tests"
|
|
19948
19948
|
tags: []
|
|
19949
|
-
judgeModel: "
|
|
19949
|
+
judgeModel: "grok-4-1-fast"
|
|
19950
19950
|
judgePrompt: "TODO: Custom instructions for the judge (e.g. strictness level, focus areas)"
|
|
19951
19951
|
|
|
19952
19952
|
cases:
|
|
@@ -19962,8 +19962,11 @@ cases:
|
|
|
19962
19962
|
`;
|
|
19963
19963
|
}
|
|
19964
19964
|
function getEnvExample() {
|
|
19965
|
-
return `#
|
|
19966
|
-
|
|
19965
|
+
return `# xAI API Key (default provider)
|
|
19966
|
+
XAI_API_KEY=your_api_key_here
|
|
19967
|
+
|
|
19968
|
+
# Optional: Anthropic API Key (if using Claude models)
|
|
19969
|
+
# ANTHROPIC_API_KEY=your_anthropic_api_key
|
|
19967
19970
|
|
|
19968
19971
|
# Optional: OpenAI API Key (if using OpenAI models)
|
|
19969
19972
|
# OPENAI_API_KEY=your_openai_api_key
|
|
@@ -20040,8 +20043,8 @@ export default defineAgent({
|
|
|
20040
20043
|
version: "0.1.0",
|
|
20041
20044
|
description: "${displayName} Agent",
|
|
20042
20045
|
model: {
|
|
20043
|
-
provider: "
|
|
20044
|
-
name: "
|
|
20046
|
+
provider: "xai",
|
|
20047
|
+
name: "grok-4-1-fast",
|
|
20045
20048
|
temperature: 0.7,
|
|
20046
20049
|
maxTokens: 4096,
|
|
20047
20050
|
},
|
|
@@ -20367,6 +20370,7 @@ function scaffoldFixture(cwd, name, slug) {
|
|
|
20367
20370
|
// src/cli/utils/plugin.ts
|
|
20368
20371
|
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
20369
20372
|
import { join as join4 } from "path";
|
|
20373
|
+
var registered = false;
|
|
20370
20374
|
var VIRTUAL_MODULE_SOURCE = `
|
|
20371
20375
|
function defineAgent(config) {
|
|
20372
20376
|
if (!config.name) throw new Error('Agent name is required')
|
|
@@ -20374,8 +20378,8 @@ function defineAgent(config) {
|
|
|
20374
20378
|
if (!config.systemPrompt) throw new Error('System prompt is required')
|
|
20375
20379
|
return {
|
|
20376
20380
|
model: {
|
|
20377
|
-
provider: '
|
|
20378
|
-
name: '
|
|
20381
|
+
provider: 'xai',
|
|
20382
|
+
name: 'grok-4-1-fast',
|
|
20379
20383
|
temperature: 0.7,
|
|
20380
20384
|
maxTokens: 4096,
|
|
20381
20385
|
},
|
|
@@ -20493,9 +20497,27 @@ function defineConfig(config) {
|
|
|
20493
20497
|
|
|
20494
20498
|
export { defineAgent, defineRole, defineEntityType, defineTrigger, defineTools, defineConfig }
|
|
20495
20499
|
`;
|
|
20500
|
+
function registerStruerePlugin() {
|
|
20501
|
+
if (registered)
|
|
20502
|
+
return;
|
|
20503
|
+
registered = true;
|
|
20504
|
+
Bun.plugin({
|
|
20505
|
+
name: "struere-virtual",
|
|
20506
|
+
setup(build) {
|
|
20507
|
+
build.onResolve({ filter: /^struere$/ }, () => ({
|
|
20508
|
+
path: "struere",
|
|
20509
|
+
namespace: "struere-virtual"
|
|
20510
|
+
}));
|
|
20511
|
+
build.onLoad({ filter: /.*/, namespace: "struere-virtual" }, () => ({
|
|
20512
|
+
contents: VIRTUAL_MODULE_SOURCE,
|
|
20513
|
+
loader: "js"
|
|
20514
|
+
}));
|
|
20515
|
+
}
|
|
20516
|
+
});
|
|
20517
|
+
}
|
|
20496
20518
|
var TYPE_DECLARATIONS = `declare module 'struere' {
|
|
20497
20519
|
export interface ModelConfig {
|
|
20498
|
-
provider: 'anthropic' | 'openai' | 'google' | 'custom'
|
|
20520
|
+
provider: 'anthropic' | 'openai' | 'google' | 'xai' | 'custom'
|
|
20499
20521
|
name: string
|
|
20500
20522
|
temperature?: number
|
|
20501
20523
|
maxTokens?: number
|
|
@@ -20667,47 +20689,32 @@ function generateTypeDeclarations(cwd) {
|
|
|
20667
20689
|
mkdirSync3(shimDir, { recursive: true });
|
|
20668
20690
|
writeFileSync3(join4(shimDir, "index.js"), VIRTUAL_MODULE_SOURCE);
|
|
20669
20691
|
writeFileSync3(join4(shimDir, "index.d.ts"), TYPE_DECLARATIONS);
|
|
20670
|
-
writeFileSync3(join4(shimDir, "package.json"), JSON.stringify({ name: "struere", version: "0.0.0", main: "index.js", types: "index.d.ts" }));
|
|
20692
|
+
writeFileSync3(join4(shimDir, "package.json"), JSON.stringify({ name: "struere", version: "0.0.0", type: "module", main: "index.js", types: "index.d.ts" }));
|
|
20671
20693
|
}
|
|
20672
20694
|
|
|
20673
20695
|
// src/cli/commands/docs.ts
|
|
20674
|
-
import { join as join6, dirname as
|
|
20675
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as
|
|
20696
|
+
import { join as join6, dirname as dirname2 } from "path";
|
|
20697
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
20676
20698
|
|
|
20677
20699
|
// src/cli/utils/loader.ts
|
|
20678
20700
|
var import_yaml = __toESM(require_dist(), 1);
|
|
20679
|
-
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync3
|
|
20680
|
-
import { join as join5,
|
|
20681
|
-
var
|
|
20701
|
+
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync3 } from "fs";
|
|
20702
|
+
import { join as join5, basename } from "path";
|
|
20703
|
+
var pluginRegistered = false;
|
|
20682
20704
|
var importCounter = 0;
|
|
20683
20705
|
async function importUserFile(filePath) {
|
|
20684
|
-
|
|
20685
|
-
|
|
20686
|
-
|
|
20687
|
-
try {
|
|
20688
|
-
return await import(`${filePath}?v=${uid}`);
|
|
20689
|
-
} catch (err) {
|
|
20690
|
-
const detail = err instanceof Error ? err.stack || err.message : String(err);
|
|
20691
|
-
throw new Error(`Import error in ${basename(filePath)}:
|
|
20692
|
-
${detail}`);
|
|
20693
|
-
}
|
|
20706
|
+
if (!pluginRegistered) {
|
|
20707
|
+
registerStruerePlugin();
|
|
20708
|
+
pluginRegistered = true;
|
|
20694
20709
|
}
|
|
20695
|
-
const
|
|
20696
|
-
const inlined = VIRTUAL_MODULE_SOURCE.trim() + `
|
|
20697
|
-
` + stripped;
|
|
20710
|
+
const uid = `${Date.now()}-${importCounter++}`;
|
|
20698
20711
|
const name = basename(filePath, ".ts");
|
|
20699
|
-
const tmpPath = join5(dirname2(filePath), `.struere-tmp-${name}-${uid}.ts`);
|
|
20700
|
-
writeFileSync4(tmpPath, inlined);
|
|
20701
20712
|
try {
|
|
20702
|
-
return await import(`${
|
|
20713
|
+
return await import(`${filePath}?v=${uid}`);
|
|
20703
20714
|
} catch (err) {
|
|
20704
20715
|
const detail = err instanceof Error ? err.stack || err.message : String(err);
|
|
20705
20716
|
throw new Error(`Import error in ${name}.ts:
|
|
20706
20717
|
${detail}`);
|
|
20707
|
-
} finally {
|
|
20708
|
-
try {
|
|
20709
|
-
unlinkSync2(tmpPath);
|
|
20710
|
-
} catch {}
|
|
20711
20718
|
}
|
|
20712
20719
|
}
|
|
20713
20720
|
async function loadAllResources(cwd) {
|
|
@@ -20921,7 +20928,7 @@ function buildDocument(projectContext) {
|
|
|
20921
20928
|
lines.push(`## Key Patterns`);
|
|
20922
20929
|
lines.push("");
|
|
20923
20930
|
lines.push("- **Imports**: `import { defineAgent, defineEntityType, defineRole, defineTrigger, defineTools } from 'struere'`");
|
|
20924
|
-
lines.push("- **Default model**: `
|
|
20931
|
+
lines.push("- **Default model**: `grok-4-1-fast` (provider: `xai`). Also supports `anthropic`, `openai` and `google`");
|
|
20925
20932
|
lines.push("- **Scope rule values**: `actor.userId`, `actor.entityId`, `actor.organizationId`, `actor.relatedIds:TYPE`, `literal:VALUE`");
|
|
20926
20933
|
lines.push("- **Policy actions**: `create`, `read`, `update`, `delete`, `list` (deny overrides allow)");
|
|
20927
20934
|
lines.push("- **Entity link/unlink params**: `fromId`, `toId`, `relationType`");
|
|
@@ -21060,11 +21067,11 @@ function buildDocument(projectContext) {
|
|
|
21060
21067
|
}
|
|
21061
21068
|
function writeTarget(cwd, target, content) {
|
|
21062
21069
|
const filePath = join6(cwd, TARGET_FILES[target]);
|
|
21063
|
-
const dir =
|
|
21070
|
+
const dir = dirname2(filePath);
|
|
21064
21071
|
if (!existsSync6(dir)) {
|
|
21065
21072
|
mkdirSync4(dir, { recursive: true });
|
|
21066
21073
|
}
|
|
21067
|
-
|
|
21074
|
+
writeFileSync4(filePath, content);
|
|
21068
21075
|
}
|
|
21069
21076
|
async function generateDocs(cwd, targets) {
|
|
21070
21077
|
const generated = [];
|
|
@@ -21303,6 +21310,8 @@ function inferProvider(modelName) {
|
|
|
21303
21310
|
return "openai";
|
|
21304
21311
|
if (modelName.startsWith("gemini"))
|
|
21305
21312
|
return "google";
|
|
21313
|
+
if (modelName.startsWith("grok"))
|
|
21314
|
+
return "xai";
|
|
21306
21315
|
return "anthropic";
|
|
21307
21316
|
}
|
|
21308
21317
|
var BUILTIN_TOOLS = [
|
|
@@ -21459,8 +21468,8 @@ function extractAgentPayload(agent, customToolsMap) {
|
|
|
21459
21468
|
description: agent.description,
|
|
21460
21469
|
systemPrompt,
|
|
21461
21470
|
model: {
|
|
21462
|
-
provider: agent.model?.provider || "
|
|
21463
|
-
name: agent.model?.name || "
|
|
21471
|
+
provider: agent.model?.provider || "xai",
|
|
21472
|
+
name: agent.model?.name || "grok-4-1-fast",
|
|
21464
21473
|
temperature: agent.model?.temperature,
|
|
21465
21474
|
maxTokens: agent.model?.maxTokens
|
|
21466
21475
|
},
|
|
@@ -22606,7 +22615,7 @@ var statusCommand = new Command("status").description("Compare local vs remote s
|
|
|
22606
22615
|
});
|
|
22607
22616
|
|
|
22608
22617
|
// src/cli/commands/pull.ts
|
|
22609
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync5, writeFileSync as
|
|
22618
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
22610
22619
|
import { join as join8 } from "path";
|
|
22611
22620
|
|
|
22612
22621
|
// src/cli/utils/generator.ts
|
|
@@ -22962,7 +22971,7 @@ var pullCommand = new Command("pull").description("Pull remote resources to loca
|
|
|
22962
22971
|
return true;
|
|
22963
22972
|
}
|
|
22964
22973
|
ensureDir2(join8(cwd, relativePath.split("/").slice(0, -1).join("/")));
|
|
22965
|
-
|
|
22974
|
+
writeFileSync5(fullPath, content);
|
|
22966
22975
|
created.push(relativePath);
|
|
22967
22976
|
return true;
|
|
22968
22977
|
};
|
|
@@ -23535,7 +23544,7 @@ entitiesCommand.command("search <type> <query>").description("Search entities").
|
|
|
23535
23544
|
|
|
23536
23545
|
// src/cli/commands/eval.ts
|
|
23537
23546
|
import { join as join9 } from "path";
|
|
23538
|
-
import { mkdirSync as mkdirSync6, writeFileSync as
|
|
23547
|
+
import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
23539
23548
|
|
|
23540
23549
|
// src/cli/utils/evals.ts
|
|
23541
23550
|
var CONVEX_URL3 = process.env.STRUERE_CONVEX_URL || "https://rapid-wildebeest-172.convex.cloud";
|
|
@@ -23963,12 +23972,12 @@ var runCommand = new Command("run").description("Run an eval suite").argument("<
|
|
|
23963
23972
|
const outDir = join9(cwd, "evals", "runs", folderName);
|
|
23964
23973
|
mkdirSync6(outDir, { recursive: true });
|
|
23965
23974
|
const summaryMd = generateSummaryMd(suite.name, suite.slug, agentSlug, run, results);
|
|
23966
|
-
|
|
23975
|
+
writeFileSync6(join9(outDir, "_summary.md"), summaryMd);
|
|
23967
23976
|
for (const r of results) {
|
|
23968
23977
|
const label = statusLabel(r);
|
|
23969
23978
|
const fileName = `${label}_${slugify3(r.caseName)}.md`;
|
|
23970
23979
|
const caseMd = generateCaseMd(r);
|
|
23971
|
-
|
|
23980
|
+
writeFileSync6(join9(outDir, fileName), caseMd);
|
|
23972
23981
|
}
|
|
23973
23982
|
const relativePath = `evals/runs/${folderName}/`;
|
|
23974
23983
|
console.log();
|
|
@@ -24305,7 +24314,7 @@ templatesCommand.command("status <name>").description("Check template approval s
|
|
|
24305
24314
|
// package.json
|
|
24306
24315
|
var package_default = {
|
|
24307
24316
|
name: "struere",
|
|
24308
|
-
version: "0.8.
|
|
24317
|
+
version: "0.8.2",
|
|
24309
24318
|
description: "Build, test, and deploy AI agents",
|
|
24310
24319
|
keywords: [
|
|
24311
24320
|
"ai",
|
package/dist/cli/index.js
CHANGED
|
@@ -552,7 +552,7 @@ slug: "basic-agent-tests"
|
|
|
552
552
|
agent: "${agentSlug}"
|
|
553
553
|
description: "Verify agent responds correctly and uses tools appropriately"
|
|
554
554
|
tags: ["smoke-test"]
|
|
555
|
-
judgeModel: "
|
|
555
|
+
judgeModel: "grok-4-1-fast"
|
|
556
556
|
judgePrompt: "Evaluate whether the agent responds correctly and uses appropriate tools. Be lenient on phrasing but strict on factual accuracy."
|
|
557
557
|
|
|
558
558
|
cases:
|
|
@@ -609,7 +609,7 @@ slug: "${slug}"
|
|
|
609
609
|
agent: "${agentSlug}"
|
|
610
610
|
description: "TODO: Describe what this eval suite tests"
|
|
611
611
|
tags: []
|
|
612
|
-
judgeModel: "
|
|
612
|
+
judgeModel: "grok-4-1-fast"
|
|
613
613
|
judgePrompt: "TODO: Custom instructions for the judge (e.g. strictness level, focus areas)"
|
|
614
614
|
|
|
615
615
|
cases:
|
|
@@ -625,8 +625,11 @@ cases:
|
|
|
625
625
|
`;
|
|
626
626
|
}
|
|
627
627
|
function getEnvExample() {
|
|
628
|
-
return `#
|
|
629
|
-
|
|
628
|
+
return `# xAI API Key (default provider)
|
|
629
|
+
XAI_API_KEY=your_api_key_here
|
|
630
|
+
|
|
631
|
+
# Optional: Anthropic API Key (if using Claude models)
|
|
632
|
+
# ANTHROPIC_API_KEY=your_anthropic_api_key
|
|
630
633
|
|
|
631
634
|
# Optional: OpenAI API Key (if using OpenAI models)
|
|
632
635
|
# OPENAI_API_KEY=your_openai_api_key
|
|
@@ -703,8 +706,8 @@ export default defineAgent({
|
|
|
703
706
|
version: "0.1.0",
|
|
704
707
|
description: "${displayName} Agent",
|
|
705
708
|
model: {
|
|
706
|
-
provider: "
|
|
707
|
-
name: "
|
|
709
|
+
provider: "xai",
|
|
710
|
+
name: "grok-4-1-fast",
|
|
708
711
|
temperature: 0.7,
|
|
709
712
|
maxTokens: 4096,
|
|
710
713
|
},
|
|
@@ -1030,6 +1033,7 @@ function scaffoldFixture(cwd, name, slug) {
|
|
|
1030
1033
|
// src/cli/utils/plugin.ts
|
|
1031
1034
|
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
1032
1035
|
import { join as join4 } from "path";
|
|
1036
|
+
var registered = false;
|
|
1033
1037
|
var VIRTUAL_MODULE_SOURCE = `
|
|
1034
1038
|
function defineAgent(config) {
|
|
1035
1039
|
if (!config.name) throw new Error('Agent name is required')
|
|
@@ -1037,8 +1041,8 @@ function defineAgent(config) {
|
|
|
1037
1041
|
if (!config.systemPrompt) throw new Error('System prompt is required')
|
|
1038
1042
|
return {
|
|
1039
1043
|
model: {
|
|
1040
|
-
provider: '
|
|
1041
|
-
name: '
|
|
1044
|
+
provider: 'xai',
|
|
1045
|
+
name: 'grok-4-1-fast',
|
|
1042
1046
|
temperature: 0.7,
|
|
1043
1047
|
maxTokens: 4096,
|
|
1044
1048
|
},
|
|
@@ -1156,9 +1160,27 @@ function defineConfig(config) {
|
|
|
1156
1160
|
|
|
1157
1161
|
export { defineAgent, defineRole, defineEntityType, defineTrigger, defineTools, defineConfig }
|
|
1158
1162
|
`;
|
|
1163
|
+
function registerStruerePlugin() {
|
|
1164
|
+
if (registered)
|
|
1165
|
+
return;
|
|
1166
|
+
registered = true;
|
|
1167
|
+
Bun.plugin({
|
|
1168
|
+
name: "struere-virtual",
|
|
1169
|
+
setup(build) {
|
|
1170
|
+
build.onResolve({ filter: /^struere$/ }, () => ({
|
|
1171
|
+
path: "struere",
|
|
1172
|
+
namespace: "struere-virtual"
|
|
1173
|
+
}));
|
|
1174
|
+
build.onLoad({ filter: /.*/, namespace: "struere-virtual" }, () => ({
|
|
1175
|
+
contents: VIRTUAL_MODULE_SOURCE,
|
|
1176
|
+
loader: "js"
|
|
1177
|
+
}));
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1159
1181
|
var TYPE_DECLARATIONS = `declare module 'struere' {
|
|
1160
1182
|
export interface ModelConfig {
|
|
1161
|
-
provider: 'anthropic' | 'openai' | 'google' | 'custom'
|
|
1183
|
+
provider: 'anthropic' | 'openai' | 'google' | 'xai' | 'custom'
|
|
1162
1184
|
name: string
|
|
1163
1185
|
temperature?: number
|
|
1164
1186
|
maxTokens?: number
|
|
@@ -1330,50 +1352,35 @@ function generateTypeDeclarations(cwd) {
|
|
|
1330
1352
|
mkdirSync3(shimDir, { recursive: true });
|
|
1331
1353
|
writeFileSync3(join4(shimDir, "index.js"), VIRTUAL_MODULE_SOURCE);
|
|
1332
1354
|
writeFileSync3(join4(shimDir, "index.d.ts"), TYPE_DECLARATIONS);
|
|
1333
|
-
writeFileSync3(join4(shimDir, "package.json"), JSON.stringify({ name: "struere", version: "0.0.0", main: "index.js", types: "index.d.ts" }));
|
|
1355
|
+
writeFileSync3(join4(shimDir, "package.json"), JSON.stringify({ name: "struere", version: "0.0.0", type: "module", main: "index.js", types: "index.d.ts" }));
|
|
1334
1356
|
}
|
|
1335
1357
|
|
|
1336
1358
|
// src/cli/commands/docs.ts
|
|
1337
1359
|
import { Command as Command2 } from "commander";
|
|
1338
1360
|
import chalk2 from "chalk";
|
|
1339
1361
|
import ora2 from "ora";
|
|
1340
|
-
import { join as join6, dirname as
|
|
1341
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as
|
|
1362
|
+
import { join as join6, dirname as dirname2 } from "path";
|
|
1363
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
1342
1364
|
|
|
1343
1365
|
// src/cli/utils/loader.ts
|
|
1344
|
-
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync3
|
|
1345
|
-
import { join as join5,
|
|
1366
|
+
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync3 } from "fs";
|
|
1367
|
+
import { join as join5, basename } from "path";
|
|
1346
1368
|
import YAML from "yaml";
|
|
1347
|
-
var
|
|
1369
|
+
var pluginRegistered = false;
|
|
1348
1370
|
var importCounter = 0;
|
|
1349
1371
|
async function importUserFile(filePath) {
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
try {
|
|
1354
|
-
return await import(`${filePath}?v=${uid}`);
|
|
1355
|
-
} catch (err) {
|
|
1356
|
-
const detail = err instanceof Error ? err.stack || err.message : String(err);
|
|
1357
|
-
throw new Error(`Import error in ${basename(filePath)}:
|
|
1358
|
-
${detail}`);
|
|
1359
|
-
}
|
|
1372
|
+
if (!pluginRegistered) {
|
|
1373
|
+
registerStruerePlugin();
|
|
1374
|
+
pluginRegistered = true;
|
|
1360
1375
|
}
|
|
1361
|
-
const
|
|
1362
|
-
const inlined = VIRTUAL_MODULE_SOURCE.trim() + `
|
|
1363
|
-
` + stripped;
|
|
1376
|
+
const uid = `${Date.now()}-${importCounter++}`;
|
|
1364
1377
|
const name = basename(filePath, ".ts");
|
|
1365
|
-
const tmpPath = join5(dirname2(filePath), `.struere-tmp-${name}-${uid}.ts`);
|
|
1366
|
-
writeFileSync4(tmpPath, inlined);
|
|
1367
1378
|
try {
|
|
1368
|
-
return await import(`${
|
|
1379
|
+
return await import(`${filePath}?v=${uid}`);
|
|
1369
1380
|
} catch (err) {
|
|
1370
1381
|
const detail = err instanceof Error ? err.stack || err.message : String(err);
|
|
1371
1382
|
throw new Error(`Import error in ${name}.ts:
|
|
1372
1383
|
${detail}`);
|
|
1373
|
-
} finally {
|
|
1374
|
-
try {
|
|
1375
|
-
unlinkSync2(tmpPath);
|
|
1376
|
-
} catch {}
|
|
1377
1384
|
}
|
|
1378
1385
|
}
|
|
1379
1386
|
async function loadAllResources(cwd) {
|
|
@@ -1587,7 +1594,7 @@ function buildDocument(projectContext) {
|
|
|
1587
1594
|
lines.push(`## Key Patterns`);
|
|
1588
1595
|
lines.push("");
|
|
1589
1596
|
lines.push("- **Imports**: `import { defineAgent, defineEntityType, defineRole, defineTrigger, defineTools } from 'struere'`");
|
|
1590
|
-
lines.push("- **Default model**: `
|
|
1597
|
+
lines.push("- **Default model**: `grok-4-1-fast` (provider: `xai`). Also supports `anthropic`, `openai` and `google`");
|
|
1591
1598
|
lines.push("- **Scope rule values**: `actor.userId`, `actor.entityId`, `actor.organizationId`, `actor.relatedIds:TYPE`, `literal:VALUE`");
|
|
1592
1599
|
lines.push("- **Policy actions**: `create`, `read`, `update`, `delete`, `list` (deny overrides allow)");
|
|
1593
1600
|
lines.push("- **Entity link/unlink params**: `fromId`, `toId`, `relationType`");
|
|
@@ -1726,11 +1733,11 @@ function buildDocument(projectContext) {
|
|
|
1726
1733
|
}
|
|
1727
1734
|
function writeTarget(cwd, target, content) {
|
|
1728
1735
|
const filePath = join6(cwd, TARGET_FILES[target]);
|
|
1729
|
-
const dir =
|
|
1736
|
+
const dir = dirname2(filePath);
|
|
1730
1737
|
if (!existsSync6(dir)) {
|
|
1731
1738
|
mkdirSync4(dir, { recursive: true });
|
|
1732
1739
|
}
|
|
1733
|
-
|
|
1740
|
+
writeFileSync4(filePath, content);
|
|
1734
1741
|
}
|
|
1735
1742
|
async function generateDocs(cwd, targets) {
|
|
1736
1743
|
const generated = [];
|
|
@@ -1973,6 +1980,8 @@ function inferProvider(modelName) {
|
|
|
1973
1980
|
return "openai";
|
|
1974
1981
|
if (modelName.startsWith("gemini"))
|
|
1975
1982
|
return "google";
|
|
1983
|
+
if (modelName.startsWith("grok"))
|
|
1984
|
+
return "xai";
|
|
1976
1985
|
return "anthropic";
|
|
1977
1986
|
}
|
|
1978
1987
|
var BUILTIN_TOOLS = [
|
|
@@ -2129,8 +2138,8 @@ function extractAgentPayload(agent, customToolsMap) {
|
|
|
2129
2138
|
description: agent.description,
|
|
2130
2139
|
systemPrompt,
|
|
2131
2140
|
model: {
|
|
2132
|
-
provider: agent.model?.provider || "
|
|
2133
|
-
name: agent.model?.name || "
|
|
2141
|
+
provider: agent.model?.provider || "xai",
|
|
2142
|
+
name: agent.model?.name || "grok-4-1-fast",
|
|
2134
2143
|
temperature: agent.model?.temperature,
|
|
2135
2144
|
maxTokens: agent.model?.maxTokens
|
|
2136
2145
|
},
|
|
@@ -3293,7 +3302,7 @@ var statusCommand = new Command9("status").description("Compare local vs remote
|
|
|
3293
3302
|
import { Command as Command10 } from "commander";
|
|
3294
3303
|
import chalk10 from "chalk";
|
|
3295
3304
|
import ora8 from "ora";
|
|
3296
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync5, writeFileSync as
|
|
3305
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
3297
3306
|
import { join as join8 } from "path";
|
|
3298
3307
|
|
|
3299
3308
|
// src/cli/utils/generator.ts
|
|
@@ -3649,7 +3658,7 @@ var pullCommand = new Command10("pull").description("Pull remote resources to lo
|
|
|
3649
3658
|
return true;
|
|
3650
3659
|
}
|
|
3651
3660
|
ensureDir2(join8(cwd, relativePath.split("/").slice(0, -1).join("/")));
|
|
3652
|
-
|
|
3661
|
+
writeFileSync5(fullPath, content);
|
|
3653
3662
|
created.push(relativePath);
|
|
3654
3663
|
return true;
|
|
3655
3664
|
};
|
|
@@ -4232,7 +4241,7 @@ import { Command as Command12 } from "commander";
|
|
|
4232
4241
|
import chalk13 from "chalk";
|
|
4233
4242
|
import ora10 from "ora";
|
|
4234
4243
|
import { join as join9 } from "path";
|
|
4235
|
-
import { mkdirSync as mkdirSync6, writeFileSync as
|
|
4244
|
+
import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
4236
4245
|
|
|
4237
4246
|
// src/cli/utils/evals.ts
|
|
4238
4247
|
var CONVEX_URL3 = process.env.STRUERE_CONVEX_URL || "https://rapid-wildebeest-172.convex.cloud";
|
|
@@ -4660,12 +4669,12 @@ var runCommand = new Command12("run").description("Run an eval suite").argument(
|
|
|
4660
4669
|
const outDir = join9(cwd, "evals", "runs", folderName);
|
|
4661
4670
|
mkdirSync6(outDir, { recursive: true });
|
|
4662
4671
|
const summaryMd = generateSummaryMd(suite.name, suite.slug, agentSlug, run, results);
|
|
4663
|
-
|
|
4672
|
+
writeFileSync6(join9(outDir, "_summary.md"), summaryMd);
|
|
4664
4673
|
for (const r of results) {
|
|
4665
4674
|
const label = statusLabel(r);
|
|
4666
4675
|
const fileName = `${label}_${slugify3(r.caseName)}.md`;
|
|
4667
4676
|
const caseMd = generateCaseMd(r);
|
|
4668
|
-
|
|
4677
|
+
writeFileSync6(join9(outDir, fileName), caseMd);
|
|
4669
4678
|
}
|
|
4670
4679
|
const relativePath = `evals/runs/${folderName}/`;
|
|
4671
4680
|
console.log();
|
|
@@ -5006,7 +5015,7 @@ templatesCommand.command("status <name>").description("Check template approval s
|
|
|
5006
5015
|
// package.json
|
|
5007
5016
|
var package_default = {
|
|
5008
5017
|
name: "struere",
|
|
5009
|
-
version: "0.8.
|
|
5018
|
+
version: "0.8.2",
|
|
5010
5019
|
description: "Build, test, and deploy AI agents",
|
|
5011
5020
|
keywords: [
|
|
5012
5021
|
"ai",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,IAAI,MAAM,CAyBpC;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAwD5D;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAoB9F;AAED,wBAAgB,aAAa,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,IAAI,MAAM,CAyBpC;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAwD5D;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAoB9F;AAED,wBAAgB,aAAa,IAAI,MAAM,CAgBtC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAiBrC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BlE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAa9C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAgC7D;AAED,wBAAgB,eAAe,IAAI,MAAM,CAsExC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAatF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBnD;AAGD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBzE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAsB/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAmC/C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,YAAY,EAAE,MAAM,CAAA;QACpB,KAAK,EAAE;YACL,QAAQ,EAAE,MAAM,CAAA;YAChB,IAAI,EAAE,MAAM,CAAA;YACZ,WAAW,CAAC,EAAE,MAAM,CAAA;YACpB,SAAS,CAAC,EAAE,MAAM,CAAA;SACnB,CAAA;QACD,KAAK,EAAE,KAAK,CAAC;YACX,IAAI,EAAE,MAAM,CAAA;YACZ,WAAW,EAAE,MAAM,CAAA;YACnB,UAAU,EAAE,OAAO,CAAA;YACnB,WAAW,CAAC,EAAE,MAAM,CAAA;YACpB,SAAS,EAAE,OAAO,CAAA;SACnB,CAAC,CAAA;KACH,CAAC,CAAA;IACF,WAAW,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,OAAO,CAAA;QACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;QACvB,aAAa,CAAC,EAAE,OAAO,CAAA;QACvB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAC,CAAA;IACF,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,QAAQ,EAAE,KAAK,CAAC;YAC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MAAM,CAAA;QACZ,QAAQ,EAAE,KAAK,CAAC;YACd,GAAG,EAAE,MAAM,CAAA;YACX,IAAI,EAAE,MAAM,CAAA;YACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;SAChB,CAAC,CAAA;QACF,SAAS,CAAC,EAAE,KAAK,CAAC;YAChB,IAAI,EAAE,MAAM,CAAA;YACZ,EAAE,EAAE,MAAM,CAAA;YACV,IAAI,EAAE,MAAM,CAAA;YACZ,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SACnC,CAAC,CAAA;KACH,CAAC,CAAA;CACH;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,eAAe,GAAG,WAAW,CAuG1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAsBlJ,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,WAAW,EAAE,aAAa,EAAE,CAAA;IAC5B,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,QAAQ,EAAE,iBAAiB,EAAE,CAAA;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAgB5E;AAuGD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG;IACnD,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAUA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const VIRTUAL_MODULE_SOURCE = "\nfunction defineAgent(config) {\n if (!config.name) throw new Error('Agent name is required')\n if (!config.version) throw new Error('Agent version is required')\n if (!config.systemPrompt) throw new Error('System prompt is required')\n return {\n model: {\n provider: '
|
|
1
|
+
export declare const VIRTUAL_MODULE_SOURCE = "\nfunction defineAgent(config) {\n if (!config.name) throw new Error('Agent name is required')\n if (!config.version) throw new Error('Agent version is required')\n if (!config.systemPrompt) throw new Error('System prompt is required')\n return {\n model: {\n provider: 'xai',\n name: 'grok-4-1-fast',\n temperature: 0.7,\n maxTokens: 4096,\n },\n ...config,\n }\n}\n\nfunction defineRole(config) {\n if (!config.name) throw new Error('Role name is required')\n if (!config.policies || config.policies.length === 0) throw new Error('Role must have at least one policy')\n for (const policy of config.policies) {\n if (!policy.resource) throw new Error('Policy resource is required')\n if (!policy.actions || policy.actions.length === 0) throw new Error('Policy must have at least one action')\n if (!policy.effect) throw new Error('Policy effect is required')\n }\n return {\n ...config,\n scopeRules: config.scopeRules || [],\n fieldMasks: config.fieldMasks || [],\n }\n}\n\nfunction validateObjectProperties(schema, path) {\n if (schema.type === 'object' && !schema.properties) {\n throw new Error('Schema field \"' + path + '\" has type \"object\" but is missing \"properties\". All object fields must declare their properties.')\n }\n if (schema.properties) {\n for (const [key, value] of Object.entries(schema.properties)) {\n validateObjectProperties(value, path ? path + '.' + key : key)\n }\n }\n if (schema.items) {\n validateObjectProperties(schema.items, path + '[]')\n }\n}\n\nfunction defineEntityType(config) {\n if (!config.name) throw new Error('Entity type name is required')\n if (!config.slug) throw new Error('Entity type slug is required')\n if (!config.schema) throw new Error('Entity type schema is required')\n if (config.schema.type !== 'object') throw new Error('Entity type schema must be an object type')\n if (config.schema.properties) {\n for (const [key, value] of Object.entries(config.schema.properties)) {\n validateObjectProperties(value, key)\n }\n }\n if (config.boundToRole !== undefined && config.boundToRole === '') throw new Error('boundToRole cannot be an empty string')\n if (config.userIdField !== undefined && !config.boundToRole) throw new Error('userIdField requires boundToRole to be set')\n const userIdField = config.boundToRole && !config.userIdField ? 'userId' : config.userIdField\n return {\n ...config,\n searchFields: config.searchFields || [],\n userIdField,\n }\n}\n\nfunction defineTrigger(config) {\n const VALID_ACTIONS = ['created', 'updated', 'deleted']\n if (!config.name) throw new Error('Trigger name is required')\n if (!config.slug) throw new Error('Trigger slug is required')\n if (!config.on) throw new Error('Trigger \"on\" configuration is required')\n if (!config.on.entityType) throw new Error('Trigger entityType is required')\n if (!config.on.action || !VALID_ACTIONS.includes(config.on.action)) throw new Error('Trigger action must be one of: ' + VALID_ACTIONS.join(', '))\n if (!config.actions || config.actions.length === 0) throw new Error('Trigger must have at least one action')\n for (const action of config.actions) {\n if (!action.tool) throw new Error('Trigger action tool is required')\n if (!action.args || typeof action.args !== 'object') throw new Error('Trigger action args must be an object')\n }\n return config\n}\n\nfunction wrapHandler(name, handler) {\n return async (params, context) => {\n try {\n return await handler(params, context)\n } catch (error) {\n console.error('Tool \"' + name + '\" execution error:', error)\n throw error\n }\n }\n}\n\nfunction defineTools(tools) {\n return tools.map((tool) => {\n if (!tool.name) throw new Error('Tool name is required')\n if (!tool.description) throw new Error('Tool \"' + tool.name + '\" requires a description')\n if (!tool.parameters) throw new Error('Tool \"' + tool.name + '\" requires parameters definition')\n if (typeof tool.handler !== 'function') throw new Error('Tool \"' + tool.name + '\" requires a handler function')\n return {\n name: tool.name,\n description: tool.description,\n parameters: tool.parameters,\n handler: wrapHandler(tool.name, tool.handler),\n _originalHandler: tool.handler,\n }\n })\n}\n\nfunction defineConfig(config) {\n const defaultConfig = {\n port: 3000,\n host: 'localhost',\n cors: { origins: ['http://localhost:3000'], credentials: true },\n logging: { level: 'info', format: 'pretty' },\n auth: { type: 'none' },\n }\n return {\n ...defaultConfig,\n ...config,\n cors: config.cors ? { ...defaultConfig.cors, ...config.cors } : defaultConfig.cors,\n logging: config.logging ? { ...defaultConfig.logging, ...config.logging } : defaultConfig.logging,\n auth: config.auth ? { ...defaultConfig.auth, ...config.auth } : defaultConfig.auth,\n }\n}\n\nexport { defineAgent, defineRole, defineEntityType, defineTrigger, defineTools, defineConfig }\n";
|
|
2
2
|
export declare function registerStruerePlugin(): void;
|
|
3
3
|
export declare function generateTypeDeclarations(cwd: string): void;
|
|
4
4
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/plugin.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/plugin.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,88JA6HjC,CAAA;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAkB5C;AAqKD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAc1D"}
|
package/dist/define/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { defineAgent } from './agent';
|
|
2
|
+
export { defineRole } from './role';
|
|
3
|
+
export { defineEntityType } from './entityType';
|
|
4
|
+
export { defineTrigger } from './trigger';
|
|
2
5
|
export { defineTools } from './tools';
|
|
3
6
|
export { defineConfig } from './config';
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAA;IAC9D,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,M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