@codemation/core 0.5.0 → 0.6.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/CHANGELOG.md +33 -0
- package/dist/{EngineRuntimeRegistration.types-BtTZolK0.d.ts → EngineRuntimeRegistration.types-Dm129RJ6.d.ts} +2 -2
- package/dist/{EngineWorkflowRunnerService-Ddl0fekp.d.cts → EngineWorkflowRunnerService-Bf88QtwB.d.cts} +2 -2
- package/dist/{InMemoryRunDataFactory-i-u2yngD.d.cts → InMemoryRunDataFactory-Dyl4p2s8.d.cts} +12 -3
- package/dist/{RunIntentService-Cjx-glgz.d.cts → RunIntentService-B1Y3v1H6.d.cts} +25 -10
- package/dist/{RunIntentService-Dkr4YwN8.d.ts → RunIntentService-BDiodxhf.d.ts} +25 -10
- package/dist/bootstrap/index.cjs +2 -2
- package/dist/bootstrap/index.d.cts +5 -5
- package/dist/bootstrap/index.d.ts +3 -3
- package/dist/bootstrap/index.js +2 -2
- package/dist/{bootstrap-DHH2uo-W.cjs → bootstrap-DVL2ue5v.cjs} +4 -3
- package/dist/bootstrap-DVL2ue5v.cjs.map +1 -0
- package/dist/{bootstrap-DbUlOl11.js → bootstrap-DdeiJ8cd.js} +4 -3
- package/dist/bootstrap-DdeiJ8cd.js.map +1 -0
- package/dist/{index-B2v4wtys.d.ts → index-C2af8ssM.d.ts} +85 -7
- package/dist/index.cjs +79 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +75 -2
- package/dist/index.js.map +1 -1
- package/dist/{runtime-BdH94eBR.js → runtime-7Xh9z3dw.js} +36 -34
- package/dist/runtime-7Xh9z3dw.js.map +1 -0
- package/dist/{runtime-feFn8OmG.cjs → runtime-DVBwxFvX.cjs} +41 -33
- package/dist/runtime-DVBwxFvX.cjs.map +1 -0
- package/dist/testing.cjs +2 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/src/ai/AiHost.ts +20 -0
- package/src/ai/CallableToolConfig.ts +84 -0
- package/src/ai/CallableToolFactory.ts +13 -0
- package/src/ai/CallableToolKindToken.ts +5 -0
- package/src/authoring/callableTool.types.ts +12 -0
- package/src/authoring/defineNode.types.ts +3 -0
- package/src/authoring/index.ts +1 -0
- package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +9 -1
- package/src/contracts/credentialTypes.ts +20 -0
- package/src/contracts/runtimeTypes.ts +4 -2
- package/src/contracts/workflowTypes.ts +0 -7
- package/src/execution/NodeExecutor.ts +7 -25
- package/src/execution/NodeExecutorFactory.ts +7 -2
- package/src/execution/NodeOutputNormalizer.ts +22 -23
- package/src/execution/RunnableOutputBehaviorResolver.ts +23 -0
- package/src/execution/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/testing/SwitchHarnessNode.ts +0 -1
- package/dist/bootstrap-DHH2uo-W.cjs.map +0 -1
- package/dist/bootstrap-DbUlOl11.js.map +0 -1
- package/dist/runtime-BdH94eBR.js.map +0 -1
- package/dist/runtime-feFn8OmG.cjs.map +0 -1
|
@@ -978,49 +978,56 @@ function isUnbrandedPortsEmissionShape(value) {
|
|
|
978
978
|
//#region src/execution/NodeOutputNormalizer.ts
|
|
979
979
|
var NodeOutputNormalizer = class {
|
|
980
980
|
normalizeExecuteResult(args) {
|
|
981
|
-
const { baseItem, raw,
|
|
982
|
-
if (isPortsEmission(raw)) return this.emitPortsToOutputs(baseItem, raw,
|
|
981
|
+
const { baseItem, raw, behavior } = args;
|
|
982
|
+
if (isPortsEmission(raw)) return this.emitPortsToOutputs(baseItem, raw, behavior);
|
|
983
983
|
if (isUnbrandedPortsEmissionShape(raw)) throw new Error("execute() returned an unbranded `{ ports: ... }` object. Use emitPorts(...) for multi-port runnable outputs.");
|
|
984
|
-
if (Array.isArray(raw)) return this.arrayFanOutToMain(baseItem, raw,
|
|
985
|
-
if (this.isItemLike(raw)) return { main: [this.
|
|
986
|
-
return { main: [this.
|
|
984
|
+
if (Array.isArray(raw)) return this.arrayFanOutToMain(baseItem, raw, behavior);
|
|
985
|
+
if (this.isItemLike(raw)) return { main: [this.applyOutput(baseItem, raw, behavior)] };
|
|
986
|
+
return { main: [this.applyOutput(baseItem, { json: raw }, behavior)] };
|
|
987
987
|
}
|
|
988
|
-
arrayFanOutToMain(baseItem, raw,
|
|
988
|
+
arrayFanOutToMain(baseItem, raw, behavior) {
|
|
989
989
|
for (const el of raw) if (Array.isArray(el)) throw new Error("execute() fan-out arrays must contain only non-array JSON elements (nested arrays belong inside objects).");
|
|
990
|
-
return { main: raw.map((json) => this.
|
|
990
|
+
return { main: raw.map((json) => this.applyOutput(baseItem, { json }, behavior)) };
|
|
991
991
|
}
|
|
992
|
-
emitPortsToOutputs(baseItem, emission,
|
|
992
|
+
emitPortsToOutputs(baseItem, emission, behavior) {
|
|
993
993
|
const out = {};
|
|
994
994
|
for (const [port, payload] of Object.entries(emission.ports)) {
|
|
995
995
|
if (payload === void 0) continue;
|
|
996
|
-
out[port] = this.normalizePortPayload(baseItem, payload,
|
|
996
|
+
out[port] = this.normalizePortPayload(baseItem, payload, behavior);
|
|
997
997
|
}
|
|
998
998
|
return out;
|
|
999
999
|
}
|
|
1000
|
-
normalizePortPayload(baseItem, payload,
|
|
1000
|
+
normalizePortPayload(baseItem, payload, behavior) {
|
|
1001
1001
|
if (payload.length === 0) return [];
|
|
1002
1002
|
const el0 = payload[0];
|
|
1003
|
-
if (this.isItemLike(el0)) return payload.map((it) => this.
|
|
1004
|
-
return payload.map((json) => this.
|
|
1003
|
+
if (this.isItemLike(el0)) return payload.map((it) => this.applyOutput(baseItem, it, behavior));
|
|
1004
|
+
return payload.map((json) => this.applyOutput(baseItem, { json }, behavior));
|
|
1005
1005
|
}
|
|
1006
1006
|
isItemLike(value) {
|
|
1007
1007
|
return typeof value === "object" && value !== null && "json" in value;
|
|
1008
1008
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
...baseItem,
|
|
1012
|
-
...next,
|
|
1013
|
-
json: next.json
|
|
1014
|
-
};
|
|
1009
|
+
applyOutput(baseItem, next, behavior) {
|
|
1010
|
+
const explicitBinary = next.binary;
|
|
1015
1011
|
return {
|
|
1016
1012
|
json: next.json,
|
|
1017
|
-
...
|
|
1013
|
+
...explicitBinary !== void 0 ? { binary: explicitBinary } : behavior.keepBinaries && baseItem.binary ? { binary: baseItem.binary } : {},
|
|
1018
1014
|
...next.meta ? { meta: next.meta } : {},
|
|
1019
1015
|
...next.paired ? { paired: next.paired } : {}
|
|
1020
1016
|
};
|
|
1021
1017
|
}
|
|
1022
1018
|
};
|
|
1023
1019
|
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region src/execution/RunnableOutputBehaviorResolver.ts
|
|
1022
|
+
var RunnableOutputBehaviorResolver = class {
|
|
1023
|
+
resolve(config) {
|
|
1024
|
+
return { keepBinaries: this.isKeepBinariesEnabled(config) };
|
|
1025
|
+
}
|
|
1026
|
+
isKeepBinariesEnabled(config) {
|
|
1027
|
+
return config.keepBinaries === true;
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1024
1031
|
//#endregion
|
|
1025
1032
|
//#region src/execution/InProcessRetryRunnerFactory.ts
|
|
1026
1033
|
var InProcessRetryRunnerFactory = class {
|
|
@@ -1125,10 +1132,12 @@ var NodeExecutor = class {
|
|
|
1125
1132
|
fanInMerger = new FanInMergeByOriginMerger();
|
|
1126
1133
|
outputNormalizer = new NodeOutputNormalizer();
|
|
1127
1134
|
itemValueResolver;
|
|
1128
|
-
|
|
1135
|
+
outputBehaviorResolver;
|
|
1136
|
+
constructor(nodeInstanceFactory, retryRunner, itemValueResolver, outputBehaviorResolver) {
|
|
1129
1137
|
this.nodeInstanceFactory = nodeInstanceFactory;
|
|
1130
1138
|
this.retryRunner = retryRunner;
|
|
1131
1139
|
this.itemValueResolver = itemValueResolver ?? new ItemValueResolver();
|
|
1140
|
+
this.outputBehaviorResolver = outputBehaviorResolver ?? new RunnableOutputBehaviorResolver();
|
|
1132
1141
|
}
|
|
1133
1142
|
async execute(request) {
|
|
1134
1143
|
const policy = request.ctx.config.retryPolicy;
|
|
@@ -1191,7 +1200,7 @@ var NodeExecutor = class {
|
|
|
1191
1200
|
}
|
|
1192
1201
|
async executeRunnableActivation(request, node$1) {
|
|
1193
1202
|
const runnableConfig = request.ctx.config;
|
|
1194
|
-
const
|
|
1203
|
+
const behavior = this.outputBehaviorResolver.resolve(runnableConfig);
|
|
1195
1204
|
const inputSchema = this.resolveInputSchema(node$1, runnableConfig);
|
|
1196
1205
|
const inputBatch = request.input ?? [];
|
|
1197
1206
|
if (inputBatch.length === 0 && runnableConfig.emptyBatchExecution === "runOnce") {
|
|
@@ -1210,7 +1219,7 @@ var NodeExecutor = class {
|
|
|
1210
1219
|
return this.outputNormalizer.normalizeExecuteResult({
|
|
1211
1220
|
baseItem: syntheticItem,
|
|
1212
1221
|
raw,
|
|
1213
|
-
|
|
1222
|
+
behavior
|
|
1214
1223
|
});
|
|
1215
1224
|
}
|
|
1216
1225
|
const byPort = {};
|
|
@@ -1232,7 +1241,7 @@ var NodeExecutor = class {
|
|
|
1232
1241
|
const normalized = this.outputNormalizer.normalizeExecuteResult({
|
|
1233
1242
|
baseItem: item,
|
|
1234
1243
|
raw,
|
|
1235
|
-
|
|
1244
|
+
behavior
|
|
1236
1245
|
});
|
|
1237
1246
|
for (const [port, batch] of Object.entries(normalized)) {
|
|
1238
1247
|
if (!batch || batch.length === 0) continue;
|
|
@@ -1262,20 +1271,13 @@ var NodeExecutor = class {
|
|
|
1262
1271
|
if (isPortsEmission(value)) throw new Error(`Node ${nodeId}: ${methodName} must return NodeOutputs, not emitPorts(...).`);
|
|
1263
1272
|
if (isUnbrandedPortsEmissionShape(value)) throw new Error(`Node ${nodeId}: ${methodName} returned an unbranded \`{ ports: ... }\` object. Return NodeOutputs instead.`);
|
|
1264
1273
|
}
|
|
1265
|
-
resolveLineageCarry(node$1, config) {
|
|
1266
|
-
if (config.lineageCarry) return config.lineageCarry;
|
|
1267
|
-
const base = config;
|
|
1268
|
-
const declared = base.declaredOutputPorts;
|
|
1269
|
-
if ((declared && declared.length > 0 ? [...new Set([...declared, ...base.nodeErrorHandler ? ["error"] : []])] : base.nodeErrorHandler ? ["main", "error"] : ["main"]).length > 1) return "carryThrough";
|
|
1270
|
-
return "emitOnly";
|
|
1271
|
-
}
|
|
1272
1274
|
};
|
|
1273
1275
|
|
|
1274
1276
|
//#endregion
|
|
1275
1277
|
//#region src/execution/NodeExecutorFactory.ts
|
|
1276
1278
|
var NodeExecutorFactory = class {
|
|
1277
|
-
create(workflowNodeInstanceFactory, retryRunner) {
|
|
1278
|
-
return new NodeExecutor(workflowNodeInstanceFactory, retryRunner);
|
|
1279
|
+
create(workflowNodeInstanceFactory, retryRunner, outputBehaviorResolver) {
|
|
1280
|
+
return new NodeExecutor(workflowNodeInstanceFactory, retryRunner, void 0, outputBehaviorResolver);
|
|
1279
1281
|
}
|
|
1280
1282
|
};
|
|
1281
1283
|
|
|
@@ -5139,6 +5141,12 @@ Object.defineProperty(exports, 'RunTerminalPersistenceCoordinator', {
|
|
|
5139
5141
|
return RunTerminalPersistenceCoordinator;
|
|
5140
5142
|
}
|
|
5141
5143
|
});
|
|
5144
|
+
Object.defineProperty(exports, 'RunnableOutputBehaviorResolver', {
|
|
5145
|
+
enumerable: true,
|
|
5146
|
+
get: function () {
|
|
5147
|
+
return RunnableOutputBehaviorResolver;
|
|
5148
|
+
}
|
|
5149
|
+
});
|
|
5142
5150
|
Object.defineProperty(exports, 'StackTraceCallSitePathResolver', {
|
|
5143
5151
|
enumerable: true,
|
|
5144
5152
|
get: function () {
|
|
@@ -5271,4 +5279,4 @@ Object.defineProperty(exports, 'tool', {
|
|
|
5271
5279
|
return tool;
|
|
5272
5280
|
}
|
|
5273
5281
|
});
|
|
5274
|
-
//# sourceMappingURL=runtime-
|
|
5282
|
+
//# sourceMappingURL=runtime-DVBwxFvX.cjs.map
|