@kaelen-ai/cli 0.1.17 → 0.1.18
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/index.js +73 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -837,6 +837,7 @@ var BINDING_SCOPES = /* @__PURE__ */ new Set(["project", "principal"]);
|
|
|
837
837
|
var CREDENTIAL_SOURCES = /* @__PURE__ */ new Set(["none", "platform", "secret_bundle"]);
|
|
838
838
|
var TARGET_EXECUTION_KEYS = /* @__PURE__ */ new Set([
|
|
839
839
|
"applications",
|
|
840
|
+
"application_bindings",
|
|
840
841
|
"endpoints",
|
|
841
842
|
"secret_names",
|
|
842
843
|
"timeout_ms",
|
|
@@ -1129,6 +1130,13 @@ function validateTargetExecution(target, declaredApps, declaredEndpoints, errors
|
|
|
1129
1130
|
errors.push(`${owner} references undeclared application "${ref}"`);
|
|
1130
1131
|
}
|
|
1131
1132
|
}
|
|
1133
|
+
validateApplicationBindings(
|
|
1134
|
+
owner,
|
|
1135
|
+
executionRecord.application_bindings,
|
|
1136
|
+
applicationRefs,
|
|
1137
|
+
declaredApps,
|
|
1138
|
+
errors
|
|
1139
|
+
);
|
|
1132
1140
|
const endpointRefs = validateScopeList(
|
|
1133
1141
|
owner,
|
|
1134
1142
|
"execution.endpoints",
|
|
@@ -1161,6 +1169,60 @@ function validateTargetExecution(target, declaredApps, declaredEndpoints, errors
|
|
|
1161
1169
|
errors.push(`${owner} endpoints is no longer supported; use execution.endpoints`);
|
|
1162
1170
|
}
|
|
1163
1171
|
}
|
|
1172
|
+
function validateApplicationBindings(owner, value, applicationRefs, declaredApps, errors) {
|
|
1173
|
+
if (value === void 0) {
|
|
1174
|
+
if (applicationRefs.length > 0) {
|
|
1175
|
+
errors.push(`${owner} execution.application_bindings is required when execution.applications is set`);
|
|
1176
|
+
}
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
if (!Array.isArray(value)) {
|
|
1180
|
+
errors.push(`${owner} execution.application_bindings must be an array`);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
const applicationRefSet = new Set(applicationRefs);
|
|
1184
|
+
const boundApplicationNames = /* @__PURE__ */ new Set();
|
|
1185
|
+
const seenAliases = /* @__PURE__ */ new Set();
|
|
1186
|
+
for (const entry of value) {
|
|
1187
|
+
if (!isRecord2(entry)) {
|
|
1188
|
+
errors.push(`${owner} execution.application_bindings entry must be an object`);
|
|
1189
|
+
continue;
|
|
1190
|
+
}
|
|
1191
|
+
for (const key of Object.keys(entry)) {
|
|
1192
|
+
if (key !== "application_name" && key !== "application_alias") {
|
|
1193
|
+
errors.push(
|
|
1194
|
+
`${owner} execution.application_bindings entry contains unsupported key "${key}"`
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
const applicationName = stringField2(entry, "application_name");
|
|
1199
|
+
const applicationAlias = stringField2(entry, "application_alias");
|
|
1200
|
+
if (!applicationName) {
|
|
1201
|
+
errors.push(`${owner} execution.application_bindings entry application_name is required`);
|
|
1202
|
+
continue;
|
|
1203
|
+
}
|
|
1204
|
+
if (!applicationAlias) {
|
|
1205
|
+
errors.push(`${owner} execution.application_bindings entry application_alias is required`);
|
|
1206
|
+
continue;
|
|
1207
|
+
}
|
|
1208
|
+
if (!declaredApps.has(applicationName)) {
|
|
1209
|
+
errors.push(`${owner} execution.application_bindings references undeclared application "${applicationName}"`);
|
|
1210
|
+
}
|
|
1211
|
+
if (!applicationRefSet.has(applicationName)) {
|
|
1212
|
+
errors.push(`${owner} execution.application_bindings references application "${applicationName}" not present in execution.applications`);
|
|
1213
|
+
}
|
|
1214
|
+
if (seenAliases.has(applicationAlias)) {
|
|
1215
|
+
errors.push(`${owner} execution.application_bindings duplicates application_alias "${applicationAlias}"`);
|
|
1216
|
+
}
|
|
1217
|
+
seenAliases.add(applicationAlias);
|
|
1218
|
+
boundApplicationNames.add(applicationName);
|
|
1219
|
+
}
|
|
1220
|
+
for (const ref of applicationRefs) {
|
|
1221
|
+
if (!boundApplicationNames.has(ref)) {
|
|
1222
|
+
errors.push(`${owner} execution.application_bindings is missing application "${ref}"`);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1164
1226
|
function validateRateBudget(owner, value, errors) {
|
|
1165
1227
|
if (value === void 0) return;
|
|
1166
1228
|
if (!isRecord2(value)) {
|
|
@@ -2471,18 +2533,11 @@ ${stdout || "(empty)"}`
|
|
|
2471
2533
|
|
|
2472
2534
|
// src/build/manifest.ts
|
|
2473
2535
|
async function generateManifest(input) {
|
|
2474
|
-
const entrypoints = {};
|
|
2475
|
-
for (const b of input.behaviorBundles) {
|
|
2476
|
-
entrypoints[b.name] = `behaviors/${b.name}.js`;
|
|
2477
|
-
}
|
|
2478
|
-
for (const c of input.conversationBundles) {
|
|
2479
|
-
entrypoints[c.name] = `conversations/${c.name}.js`;
|
|
2480
|
-
}
|
|
2481
2536
|
const m = await evaluateAndEmitManifest({
|
|
2482
2537
|
cwd: input.cwd,
|
|
2483
2538
|
outDir: input.outDir,
|
|
2484
2539
|
userFiles: input.userFiles,
|
|
2485
|
-
entrypoints
|
|
2540
|
+
entrypoints: input.entrypoints
|
|
2486
2541
|
});
|
|
2487
2542
|
await writeFile(
|
|
2488
2543
|
join(input.outDir, "manifest.json"),
|
|
@@ -2946,7 +3001,6 @@ var INTERNAL_RUN = "__io_cli_compiled_run";
|
|
|
2946
3001
|
var INTERNAL_ON_START = "__io_cli_compiled_on_start";
|
|
2947
3002
|
var INTERNAL_ON_MESSAGE = "__io_cli_compiled_on_message";
|
|
2948
3003
|
var INTERNAL_ON_END = "__io_cli_compiled_on_end";
|
|
2949
|
-
var INTERNAL_APPLICATIONS = "__io_cli_compiled_applications";
|
|
2950
3004
|
function conversationChannel(name) {
|
|
2951
3005
|
return `session:${name}`;
|
|
2952
3006
|
}
|
|
@@ -3048,13 +3102,6 @@ function functionSourceFromProperty(source, prop, label) {
|
|
|
3048
3102
|
}
|
|
3049
3103
|
return source.slice(value.start, value.end);
|
|
3050
3104
|
}
|
|
3051
|
-
function expressionSourceFromProperty(source, prop, label) {
|
|
3052
|
-
const value = prop.value;
|
|
3053
|
-
if (!value) {
|
|
3054
|
-
throw new BuildError(`compiled target is missing ${label} value`);
|
|
3055
|
-
}
|
|
3056
|
-
return source.slice(value.start, value.end);
|
|
3057
|
-
}
|
|
3058
3105
|
function replaceRange(source, start, end, text) {
|
|
3059
3106
|
return `${source.slice(0, start)}${text}${source.slice(end)}`;
|
|
3060
3107
|
}
|
|
@@ -3392,8 +3439,6 @@ function buildBehaviorReplacement(source, spec, behavior) {
|
|
|
3392
3439
|
}
|
|
3393
3440
|
const execution = compactExecution(behavior.execution);
|
|
3394
3441
|
const runSource = functionSourceFromProperty(source, run, "run");
|
|
3395
|
-
const applications = findProperty(spec, "applications");
|
|
3396
|
-
const applicationsSource = applications ? expressionSourceFromProperty(source, applications, "applications") : void 0;
|
|
3397
3442
|
const configEntries = [
|
|
3398
3443
|
`kind: "behavior"`,
|
|
3399
3444
|
`name: ${JSON.stringify(behavior.name)}`,
|
|
@@ -3402,13 +3447,9 @@ function buildBehaviorReplacement(source, spec, behavior) {
|
|
|
3402
3447
|
if (execution) {
|
|
3403
3448
|
configEntries.push(`execution: ${JSON.stringify(execution)}`);
|
|
3404
3449
|
}
|
|
3405
|
-
if (applicationsSource) {
|
|
3406
|
-
configEntries.push(`applications: ${INTERNAL_APPLICATIONS}`);
|
|
3407
|
-
}
|
|
3408
3450
|
const configSource = `Object.freeze({ ${configEntries.join(", ")} })`;
|
|
3409
3451
|
return {
|
|
3410
3452
|
replacement: [
|
|
3411
|
-
...applicationsSource ? [`const ${INTERNAL_APPLICATIONS} = ${applicationsSource};`] : [],
|
|
3412
3453
|
`const ${INTERNAL_CONFIG} = ${configSource};`,
|
|
3413
3454
|
`const ${INTERNAL_RUN} = ${runSource};`,
|
|
3414
3455
|
`export { ${INTERNAL_CONFIG} as config, ${INTERNAL_RUN} as run };`
|
|
@@ -3416,9 +3457,7 @@ function buildBehaviorReplacement(source, spec, behavior) {
|
|
|
3416
3457
|
refs: /* @__PURE__ */ new Set([
|
|
3417
3458
|
INTERNAL_CONFIG,
|
|
3418
3459
|
INTERNAL_RUN,
|
|
3419
|
-
...
|
|
3420
|
-
...refsFromExpressionSource(runSource),
|
|
3421
|
-
...applicationsSource ? refsFromExpressionSource(applicationsSource) : []
|
|
3460
|
+
...refsFromExpressionSource(runSource)
|
|
3422
3461
|
])
|
|
3423
3462
|
};
|
|
3424
3463
|
}
|
|
@@ -3433,11 +3472,9 @@ function buildConversationReplacement(source, spec, conversation) {
|
|
|
3433
3472
|
const execution = compactExecution(conversation.execution);
|
|
3434
3473
|
const onStart = findProperty(spec, "onStart");
|
|
3435
3474
|
const onEnd = findProperty(spec, "onEnd");
|
|
3436
|
-
const applications = findProperty(spec, "applications");
|
|
3437
3475
|
const onMessageSource = functionSourceFromProperty(source, onMessage, "onMessage");
|
|
3438
3476
|
const onStartSource = onStart ? functionSourceFromProperty(source, onStart, "onStart") : void 0;
|
|
3439
3477
|
const onEndSource = onEnd ? functionSourceFromProperty(source, onEnd, "onEnd") : void 0;
|
|
3440
|
-
const applicationsSource = applications ? expressionSourceFromProperty(source, applications, "applications") : void 0;
|
|
3441
3478
|
const configEntries = [
|
|
3442
3479
|
`kind: "conversation"`,
|
|
3443
3480
|
`name: ${JSON.stringify(conversation.name)}`,
|
|
@@ -3447,24 +3484,18 @@ function buildConversationReplacement(source, spec, conversation) {
|
|
|
3447
3484
|
if (execution) {
|
|
3448
3485
|
configEntries.push(`execution: ${JSON.stringify(execution)}`);
|
|
3449
3486
|
}
|
|
3450
|
-
if (applicationsSource) {
|
|
3451
|
-
configEntries.push(`applications: ${INTERNAL_APPLICATIONS}`);
|
|
3452
|
-
}
|
|
3453
3487
|
const configSource = `Object.freeze({ ${configEntries.join(", ")} })`;
|
|
3454
3488
|
const refs = /* @__PURE__ */ new Set([
|
|
3455
3489
|
INTERNAL_CONFIG,
|
|
3456
3490
|
INTERNAL_ON_START,
|
|
3457
3491
|
INTERNAL_ON_MESSAGE,
|
|
3458
3492
|
INTERNAL_ON_END,
|
|
3459
|
-
...applicationsSource ? [INTERNAL_APPLICATIONS] : [],
|
|
3460
3493
|
...refsFromExpressionSource(onMessageSource),
|
|
3461
3494
|
...onStartSource ? refsFromExpressionSource(onStartSource) : [],
|
|
3462
|
-
...onEndSource ? refsFromExpressionSource(onEndSource) : []
|
|
3463
|
-
...applicationsSource ? refsFromExpressionSource(applicationsSource) : []
|
|
3495
|
+
...onEndSource ? refsFromExpressionSource(onEndSource) : []
|
|
3464
3496
|
]);
|
|
3465
3497
|
return {
|
|
3466
3498
|
replacement: [
|
|
3467
|
-
...applicationsSource ? [`const ${INTERNAL_APPLICATIONS} = ${applicationsSource};`] : [],
|
|
3468
3499
|
`const ${INTERNAL_CONFIG} = ${configSource};`,
|
|
3469
3500
|
`const ${INTERNAL_ON_START} = ${onStartSource ?? "undefined"};`,
|
|
3470
3501
|
`const ${INTERNAL_ON_MESSAGE} = ${onMessageSource};`,
|
|
@@ -3549,12 +3580,17 @@ async function buildPipeline(config, cwd = process.cwd(), minify = false, buildD
|
|
|
3549
3580
|
bundleAll(allBehaviorSources, outDir, "behaviors", minify),
|
|
3550
3581
|
bundleAll(allConversationSources, outDir, "conversations", minify)
|
|
3551
3582
|
]);
|
|
3583
|
+
const entrypoints = Object.fromEntries(
|
|
3584
|
+
[...behaviorBundles, ...conversationBundles].map((bundle) => [
|
|
3585
|
+
bundle.name,
|
|
3586
|
+
relative(outDir, bundle.outFile).split("\\").join("/")
|
|
3587
|
+
])
|
|
3588
|
+
);
|
|
3552
3589
|
const manifest = await generateManifest({
|
|
3553
3590
|
cwd,
|
|
3554
3591
|
userFiles: files,
|
|
3555
3592
|
outDir,
|
|
3556
|
-
|
|
3557
|
-
conversationBundles
|
|
3593
|
+
entrypoints
|
|
3558
3594
|
});
|
|
3559
3595
|
validateManifest(manifest);
|
|
3560
3596
|
const { catalog: catalog2, warnings } = generateCatalog(manifest);
|
|
@@ -6681,7 +6717,7 @@ async function catalogShowCommand(options) {
|
|
|
6681
6717
|
|
|
6682
6718
|
// src/index.ts
|
|
6683
6719
|
var program = new Command();
|
|
6684
|
-
program.name("io").description("IO CLI \u2014 build and deploy behaviors").version("0.1.
|
|
6720
|
+
program.name("io").description("IO CLI \u2014 build and deploy behaviors").version("0.1.18");
|
|
6685
6721
|
program.command("init").description("Initialize io.config.json for the current project").option("--yes", "Overwrite existing config without prompting").action(initCommand);
|
|
6686
6722
|
program.command("build").description("Build behaviors from the io/ directory").option("--dir <path>", "Source directory", "io").option("--minify", "Minify bundles", false).action(buildCommand);
|
|
6687
6723
|
program.command("deploy").description("Build and package for deployment").option("--dir <path>", "Source directory", "io").option("--no-minify", "Skip minification").option("--yes", "Skip confirmation prompt").option("--watch", "Tail deployment status until it reaches a terminal state").action(deployCommand);
|