@oomol-lab/open-flow 0.1.0-beta.54 → 0.1.0-beta.55
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/browser/{createResourceDialog-BsaBMf7_.js → createResourceDialog-4H5_lZ6s.js} +3 -3
- package/dist/browser/{main-BPABKzwN.js → dist-BFmpkX4P.js} +9 -1
- package/dist/browser/flow-authoring-node.d.ts +5 -0
- package/dist/browser/flow-authoring.d.ts +1 -1
- package/dist/browser/flow-authoring.js +9434 -9187
- package/dist/browser/flow-change.d.ts +6 -1
- package/dist/browser/flow-change.js +3108 -141
- package/dist/browser/{flowChanges-CcscgZsW.js → flowChanges-ZzG-f9cg.js} +1978 -5437
- package/dist/browser/{flowWorkspace-CoT_ewLX.js → flowWorkspace-ChpRaTMX.js} +3197 -310
- package/dist/browser/{icons-0s-Q_3lp.js → icons-CdAB9wyS.js} +4294 -54
- package/dist/browser/{markdownContent-D3FFc-u_.js → markdownContent-frwDfQQU.js} +1 -2
- package/dist/browser/preview.css +375 -322
- package/dist/browser/preview.js +5458 -1888
- package/dist/browser/theme.css +1 -0
- package/dist/browser/ui.css +30 -0
- package/dist/browser/ui.js +4 -3
- package/dist/browser/workbench.css +375 -322
- package/dist/browser/workbench.js +8 -8
- package/dist/browser/{workbenchSelect-BqUPacsr.js → workbenchSelect-BRZN4ish.js} +1 -1
- package/dist/common/authoringExamples.d.ts +3 -2
- package/dist/common/control-api-conformance.js +3410 -3285
- package/dist/common/control-api.js +3680 -3531
- package/dist/common/control-requests.js +2132 -1860
- package/dist/common/decision.d.ts +47 -0
- package/dist/common/decision.js +10153 -0
- package/dist/common/flow-encoding.js +3105 -124
- package/dist/common/flow-semantics.js +276 -2
- package/dist/common/integration-trigger.js +202 -1
- package/dist/common/mcp.js +3748 -3623
- package/dist/common/openapi.js +202 -1
- package/dist/common/poll-trigger.js +226 -1
- package/dist/common/run-events.js +1 -0
- package/dist/common/runtime-contract.d.ts +8 -0
- package/dist/common/scheduler.d.ts +1 -1
- package/dist/common/scheduler.js +2137 -1936
- package/dist/common/webhook-trigger.js +202 -1
- package/package.json +5 -1
- package/dist/browser/dist-BDBTOgS5.js +0 -9
package/dist/common/openapi.js
CHANGED
|
@@ -5911,6 +5911,70 @@ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
|
5911
5911
|
});
|
|
5912
5912
|
};
|
|
5913
5913
|
});
|
|
5914
|
+
function discriminatorMap(def) {
|
|
5915
|
+
const map = /* @__PURE__ */ new Map();
|
|
5916
|
+
for (const option of def.options) {
|
|
5917
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
5918
|
+
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
5919
|
+
for (const value of values) if (map.has(value)) {
|
|
5920
|
+
if (value !== void 0) throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
5921
|
+
map.set(value, null);
|
|
5922
|
+
} else map.set(value, option);
|
|
5923
|
+
}
|
|
5924
|
+
return map;
|
|
5925
|
+
}
|
|
5926
|
+
var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
5927
|
+
def.inclusive = false;
|
|
5928
|
+
$ZodUnion.init(inst, def);
|
|
5929
|
+
const _super = inst._zod.parse;
|
|
5930
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
5931
|
+
const propValues = {};
|
|
5932
|
+
let undefinedCount = 0;
|
|
5933
|
+
for (const option of zod.def.options) {
|
|
5934
|
+
const pv = option._zod.propValues;
|
|
5935
|
+
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
5936
|
+
if (pv[zod.def.discriminator]?.has(void 0)) undefinedCount++;
|
|
5937
|
+
for (const [k, v] of Object.entries(pv)) {
|
|
5938
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
|
|
5939
|
+
for (const val of v) propValues[k].add(val);
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(void 0);
|
|
5943
|
+
return propValues;
|
|
5944
|
+
});
|
|
5945
|
+
def.options.forEach((option, i) => {
|
|
5946
|
+
const propShape = rawShape(option._zod.def);
|
|
5947
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
5948
|
+
});
|
|
5949
|
+
const disc = cached(() => discriminatorMap(def));
|
|
5950
|
+
inst._zod.parse = (payload, ctx) => {
|
|
5951
|
+
const input = payload.value;
|
|
5952
|
+
if (!isObject(input)) {
|
|
5953
|
+
payload.issues.push({
|
|
5954
|
+
code: "invalid_type",
|
|
5955
|
+
expected: "object",
|
|
5956
|
+
input,
|
|
5957
|
+
inst
|
|
5958
|
+
});
|
|
5959
|
+
return payload;
|
|
5960
|
+
}
|
|
5961
|
+
const value = input?.[def.discriminator];
|
|
5962
|
+
const opt = disc.value.get(value);
|
|
5963
|
+
if (opt && (value !== void 0 || ctx.direction !== "backward")) return opt._zod.run(payload, ctx);
|
|
5964
|
+
if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
|
|
5965
|
+
payload.issues.push({
|
|
5966
|
+
code: "invalid_union",
|
|
5967
|
+
errors: [],
|
|
5968
|
+
note: "No matching discriminator",
|
|
5969
|
+
discriminator: def.discriminator,
|
|
5970
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
5971
|
+
input,
|
|
5972
|
+
path: [def.discriminator],
|
|
5973
|
+
inst
|
|
5974
|
+
});
|
|
5975
|
+
return payload;
|
|
5976
|
+
};
|
|
5977
|
+
});
|
|
5914
5978
|
var $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
|
|
5915
5979
|
$ZodType.init(inst, def);
|
|
5916
5980
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -8959,6 +9023,18 @@ function union(options, params) {
|
|
|
8959
9023
|
...normalizeParams(params)
|
|
8960
9024
|
});
|
|
8961
9025
|
}
|
|
9026
|
+
var ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
9027
|
+
ZodUnion.init(inst, def);
|
|
9028
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
9029
|
+
});
|
|
9030
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
9031
|
+
return new ZodDiscriminatedUnion({
|
|
9032
|
+
type: "union",
|
|
9033
|
+
options,
|
|
9034
|
+
discriminator,
|
|
9035
|
+
...normalizeParams(params)
|
|
9036
|
+
});
|
|
9037
|
+
}
|
|
8962
9038
|
var ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
8963
9039
|
$ZodIntersection.init(inst, def);
|
|
8964
9040
|
ZodType.init(inst, def);
|
|
@@ -9237,6 +9313,96 @@ function json$1(params) {
|
|
|
9237
9313
|
return jsonSchema;
|
|
9238
9314
|
}
|
|
9239
9315
|
//#endregion
|
|
9316
|
+
//#region src/decision/common/decision.ts
|
|
9317
|
+
var decisionLimits = {
|
|
9318
|
+
choice: 255,
|
|
9319
|
+
score: 10
|
|
9320
|
+
};
|
|
9321
|
+
/** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
|
|
9322
|
+
function limitDecisionQuestion(question) {
|
|
9323
|
+
if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
|
|
9324
|
+
if (question.type === "choice") return {
|
|
9325
|
+
...question,
|
|
9326
|
+
criteria: question.criteria.slice(0, decisionLimits.choice)
|
|
9327
|
+
};
|
|
9328
|
+
return {
|
|
9329
|
+
...question,
|
|
9330
|
+
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
9331
|
+
};
|
|
9332
|
+
}
|
|
9333
|
+
function limitDecisionQuestions(questions) {
|
|
9334
|
+
const limited = questions.map(limitDecisionQuestion);
|
|
9335
|
+
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
9336
|
+
}
|
|
9337
|
+
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
9338
|
+
function limitDecisionTask(task) {
|
|
9339
|
+
if (task.executor.kind !== "decision") return task;
|
|
9340
|
+
const original = task.executor.questions;
|
|
9341
|
+
const questions = limitDecisionQuestions(original);
|
|
9342
|
+
if (questions === original) return task;
|
|
9343
|
+
const outputs = task.outputs.map((port) => {
|
|
9344
|
+
if (!("handle" in port)) return port;
|
|
9345
|
+
const index = original.findIndex((question) => question.name === port.handle);
|
|
9346
|
+
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
9347
|
+
return {
|
|
9348
|
+
...port,
|
|
9349
|
+
jsonSchema: decisionAnswerSchema(questions[index])
|
|
9350
|
+
};
|
|
9351
|
+
});
|
|
9352
|
+
return {
|
|
9353
|
+
...task,
|
|
9354
|
+
executor: {
|
|
9355
|
+
...task.executor,
|
|
9356
|
+
questions
|
|
9357
|
+
},
|
|
9358
|
+
outputs
|
|
9359
|
+
};
|
|
9360
|
+
}
|
|
9361
|
+
var probability = {
|
|
9362
|
+
type: "number",
|
|
9363
|
+
minimum: 0,
|
|
9364
|
+
maximum: 1
|
|
9365
|
+
};
|
|
9366
|
+
function decisionAnswerSchema(question) {
|
|
9367
|
+
return answerSchema(limitDecisionQuestion(question));
|
|
9368
|
+
}
|
|
9369
|
+
function answerSchema(question) {
|
|
9370
|
+
const properties = { type: { const: question.type } };
|
|
9371
|
+
if (question.type === "noul") properties.noul = probability;
|
|
9372
|
+
else {
|
|
9373
|
+
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
9374
|
+
properties.confidence = probability;
|
|
9375
|
+
properties.probabilities = {
|
|
9376
|
+
type: "object",
|
|
9377
|
+
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
9378
|
+
required: keys,
|
|
9379
|
+
additionalProperties: false
|
|
9380
|
+
};
|
|
9381
|
+
if (question.type === "choice") properties.choice = {
|
|
9382
|
+
type: "string",
|
|
9383
|
+
...keys.length ? { enum: keys } : {}
|
|
9384
|
+
};
|
|
9385
|
+
else {
|
|
9386
|
+
properties.score = {
|
|
9387
|
+
type: "number",
|
|
9388
|
+
minimum: 0,
|
|
9389
|
+
maximum: Math.max(0, keys.length - 1)
|
|
9390
|
+
};
|
|
9391
|
+
properties.legend = {
|
|
9392
|
+
type: "object",
|
|
9393
|
+
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
9394
|
+
required: keys,
|
|
9395
|
+
additionalProperties: false
|
|
9396
|
+
};
|
|
9397
|
+
}
|
|
9398
|
+
}
|
|
9399
|
+
return {
|
|
9400
|
+
type: "object",
|
|
9401
|
+
properties,
|
|
9402
|
+
required: Object.keys(properties)
|
|
9403
|
+
};
|
|
9404
|
+
}
|
|
9405
|
+
//#endregion
|
|
9240
9406
|
//#region src/flow/common/triggerScheduleSchema.ts
|
|
9241
9407
|
var triggerScheduleSchema = array(union([object$1({
|
|
9242
9408
|
type: literal("cron"),
|
|
@@ -9353,6 +9519,32 @@ var agentValue = union([object$1({
|
|
|
9353
9519
|
input: text
|
|
9354
9520
|
})]);
|
|
9355
9521
|
var agentInput = union([agentValue, object$1({ kind: literal("model") })]);
|
|
9522
|
+
var decisionQuestion = discriminatedUnion("type", [
|
|
9523
|
+
strictObject({
|
|
9524
|
+
name: text,
|
|
9525
|
+
instructions: text,
|
|
9526
|
+
type: literal("noul"),
|
|
9527
|
+
criteria: strictObject({
|
|
9528
|
+
true: text.optional(),
|
|
9529
|
+
false: text.optional()
|
|
9530
|
+
}).optional()
|
|
9531
|
+
}),
|
|
9532
|
+
strictObject({
|
|
9533
|
+
name: text,
|
|
9534
|
+
instructions: text,
|
|
9535
|
+
type: literal("choice"),
|
|
9536
|
+
criteria: array(strictObject({
|
|
9537
|
+
name: text,
|
|
9538
|
+
description: text
|
|
9539
|
+
}))
|
|
9540
|
+
}),
|
|
9541
|
+
strictObject({
|
|
9542
|
+
name: text,
|
|
9543
|
+
instructions: text,
|
|
9544
|
+
type: literal("score"),
|
|
9545
|
+
criteria: strings
|
|
9546
|
+
})
|
|
9547
|
+
]);
|
|
9356
9548
|
var managed = object$1({
|
|
9357
9549
|
...ports,
|
|
9358
9550
|
name: text,
|
|
@@ -9380,6 +9572,10 @@ var managed = object$1({
|
|
|
9380
9572
|
in: _enum(["header", "query"]).optional()
|
|
9381
9573
|
}))
|
|
9382
9574
|
}),
|
|
9575
|
+
strictObject({
|
|
9576
|
+
kind: literal("decision"),
|
|
9577
|
+
questions: array(decisionQuestion)
|
|
9578
|
+
}),
|
|
9383
9579
|
object$1({
|
|
9384
9580
|
kind: literal("llm"),
|
|
9385
9581
|
mode: _enum(["chat", "json"])
|
|
@@ -9406,7 +9602,7 @@ var managed = object$1({
|
|
|
9406
9602
|
}).optional()
|
|
9407
9603
|
})
|
|
9408
9604
|
])
|
|
9409
|
-
});
|
|
9605
|
+
}).transform(limitDecisionTask);
|
|
9410
9606
|
var operand = union([object$1({
|
|
9411
9607
|
kind: literal("value"),
|
|
9412
9608
|
value: json.optional(),
|
|
@@ -9800,6 +9996,11 @@ var shapes = {
|
|
|
9800
9996
|
before: text.optional(),
|
|
9801
9997
|
value: text.optional()
|
|
9802
9998
|
},
|
|
9999
|
+
"task.decision.set": {
|
|
10000
|
+
taskId: text,
|
|
10001
|
+
before: managed,
|
|
10002
|
+
value: managed
|
|
10003
|
+
},
|
|
9803
10004
|
"task.openapi.set": {
|
|
9804
10005
|
taskId: text,
|
|
9805
10006
|
before: managed,
|
|
@@ -3641,6 +3641,30 @@ function createSchemaComparer() {
|
|
|
3641
3641
|
}
|
|
3642
3642
|
createSchemaComparer();
|
|
3643
3643
|
//#endregion
|
|
3644
|
+
//#region ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
3645
|
+
var has = Object.prototype.hasOwnProperty;
|
|
3646
|
+
function dequal(foo, bar) {
|
|
3647
|
+
var ctor, len;
|
|
3648
|
+
if (foo === bar) return true;
|
|
3649
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
3650
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
3651
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
3652
|
+
if (ctor === Array) {
|
|
3653
|
+
if ((len = foo.length) === bar.length) while (len-- && dequal(foo[len], bar[len]));
|
|
3654
|
+
return len === -1;
|
|
3655
|
+
}
|
|
3656
|
+
if (!ctor || typeof foo === "object") {
|
|
3657
|
+
len = 0;
|
|
3658
|
+
for (ctor in foo) {
|
|
3659
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
3660
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
3661
|
+
}
|
|
3662
|
+
return Object.keys(bar).length === len;
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
return foo !== foo && bar !== bar;
|
|
3666
|
+
}
|
|
3667
|
+
//#endregion
|
|
3644
3668
|
//#region ../../node_modules/.bun/zod@4.6.5/node_modules/zod/v4/core/util.js
|
|
3645
3669
|
function getEnumValues(entries) {
|
|
3646
3670
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
@@ -5894,6 +5918,70 @@ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
|
5894
5918
|
});
|
|
5895
5919
|
};
|
|
5896
5920
|
});
|
|
5921
|
+
function discriminatorMap(def) {
|
|
5922
|
+
const map = /* @__PURE__ */ new Map();
|
|
5923
|
+
for (const option of def.options) {
|
|
5924
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
5925
|
+
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
5926
|
+
for (const value of values) if (map.has(value)) {
|
|
5927
|
+
if (value !== void 0) throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
5928
|
+
map.set(value, null);
|
|
5929
|
+
} else map.set(value, option);
|
|
5930
|
+
}
|
|
5931
|
+
return map;
|
|
5932
|
+
}
|
|
5933
|
+
var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
5934
|
+
def.inclusive = false;
|
|
5935
|
+
$ZodUnion.init(inst, def);
|
|
5936
|
+
const _super = inst._zod.parse;
|
|
5937
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
5938
|
+
const propValues = {};
|
|
5939
|
+
let undefinedCount = 0;
|
|
5940
|
+
for (const option of zod.def.options) {
|
|
5941
|
+
const pv = option._zod.propValues;
|
|
5942
|
+
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
5943
|
+
if (pv[zod.def.discriminator]?.has(void 0)) undefinedCount++;
|
|
5944
|
+
for (const [k, v] of Object.entries(pv)) {
|
|
5945
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
|
|
5946
|
+
for (const val of v) propValues[k].add(val);
|
|
5947
|
+
}
|
|
5948
|
+
}
|
|
5949
|
+
if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(void 0);
|
|
5950
|
+
return propValues;
|
|
5951
|
+
});
|
|
5952
|
+
def.options.forEach((option, i) => {
|
|
5953
|
+
const propShape = rawShape(option._zod.def);
|
|
5954
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
5955
|
+
});
|
|
5956
|
+
const disc = cached(() => discriminatorMap(def));
|
|
5957
|
+
inst._zod.parse = (payload, ctx) => {
|
|
5958
|
+
const input = payload.value;
|
|
5959
|
+
if (!isObject(input)) {
|
|
5960
|
+
payload.issues.push({
|
|
5961
|
+
code: "invalid_type",
|
|
5962
|
+
expected: "object",
|
|
5963
|
+
input,
|
|
5964
|
+
inst
|
|
5965
|
+
});
|
|
5966
|
+
return payload;
|
|
5967
|
+
}
|
|
5968
|
+
const value = input?.[def.discriminator];
|
|
5969
|
+
const opt = disc.value.get(value);
|
|
5970
|
+
if (opt && (value !== void 0 || ctx.direction !== "backward")) return opt._zod.run(payload, ctx);
|
|
5971
|
+
if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
|
|
5972
|
+
payload.issues.push({
|
|
5973
|
+
code: "invalid_union",
|
|
5974
|
+
errors: [],
|
|
5975
|
+
note: "No matching discriminator",
|
|
5976
|
+
discriminator: def.discriminator,
|
|
5977
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
5978
|
+
input,
|
|
5979
|
+
path: [def.discriminator],
|
|
5980
|
+
inst
|
|
5981
|
+
});
|
|
5982
|
+
return payload;
|
|
5983
|
+
};
|
|
5984
|
+
});
|
|
5897
5985
|
var $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
|
|
5898
5986
|
$ZodType.init(inst, def);
|
|
5899
5987
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -8942,6 +9030,18 @@ function union(options, params) {
|
|
|
8942
9030
|
...normalizeParams(params)
|
|
8943
9031
|
});
|
|
8944
9032
|
}
|
|
9033
|
+
var ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
9034
|
+
ZodUnion.init(inst, def);
|
|
9035
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
9036
|
+
});
|
|
9037
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
9038
|
+
return new ZodDiscriminatedUnion({
|
|
9039
|
+
type: "union",
|
|
9040
|
+
options,
|
|
9041
|
+
discriminator,
|
|
9042
|
+
...normalizeParams(params)
|
|
9043
|
+
});
|
|
9044
|
+
}
|
|
8945
9045
|
var ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
8946
9046
|
$ZodIntersection.init(inst, def);
|
|
8947
9047
|
ZodType.init(inst, def);
|
|
@@ -9220,6 +9320,96 @@ function json$1(params) {
|
|
|
9220
9320
|
return jsonSchema;
|
|
9221
9321
|
}
|
|
9222
9322
|
//#endregion
|
|
9323
|
+
//#region src/decision/common/decision.ts
|
|
9324
|
+
var decisionLimits = {
|
|
9325
|
+
choice: 255,
|
|
9326
|
+
score: 10
|
|
9327
|
+
};
|
|
9328
|
+
/** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
|
|
9329
|
+
function limitDecisionQuestion(question) {
|
|
9330
|
+
if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
|
|
9331
|
+
if (question.type === "choice") return {
|
|
9332
|
+
...question,
|
|
9333
|
+
criteria: question.criteria.slice(0, decisionLimits.choice)
|
|
9334
|
+
};
|
|
9335
|
+
return {
|
|
9336
|
+
...question,
|
|
9337
|
+
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
9338
|
+
};
|
|
9339
|
+
}
|
|
9340
|
+
function limitDecisionQuestions(questions) {
|
|
9341
|
+
const limited = questions.map(limitDecisionQuestion);
|
|
9342
|
+
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
9343
|
+
}
|
|
9344
|
+
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
9345
|
+
function limitDecisionTask(task) {
|
|
9346
|
+
if (task.executor.kind !== "decision") return task;
|
|
9347
|
+
const original = task.executor.questions;
|
|
9348
|
+
const questions = limitDecisionQuestions(original);
|
|
9349
|
+
if (questions === original) return task;
|
|
9350
|
+
const outputs = task.outputs.map((port) => {
|
|
9351
|
+
if (!("handle" in port)) return port;
|
|
9352
|
+
const index = original.findIndex((question) => question.name === port.handle);
|
|
9353
|
+
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
9354
|
+
return {
|
|
9355
|
+
...port,
|
|
9356
|
+
jsonSchema: decisionAnswerSchema(questions[index])
|
|
9357
|
+
};
|
|
9358
|
+
});
|
|
9359
|
+
return {
|
|
9360
|
+
...task,
|
|
9361
|
+
executor: {
|
|
9362
|
+
...task.executor,
|
|
9363
|
+
questions
|
|
9364
|
+
},
|
|
9365
|
+
outputs
|
|
9366
|
+
};
|
|
9367
|
+
}
|
|
9368
|
+
var probability = {
|
|
9369
|
+
type: "number",
|
|
9370
|
+
minimum: 0,
|
|
9371
|
+
maximum: 1
|
|
9372
|
+
};
|
|
9373
|
+
function decisionAnswerSchema(question) {
|
|
9374
|
+
return answerSchema(limitDecisionQuestion(question));
|
|
9375
|
+
}
|
|
9376
|
+
function answerSchema(question) {
|
|
9377
|
+
const properties = { type: { const: question.type } };
|
|
9378
|
+
if (question.type === "noul") properties.noul = probability;
|
|
9379
|
+
else {
|
|
9380
|
+
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
9381
|
+
properties.confidence = probability;
|
|
9382
|
+
properties.probabilities = {
|
|
9383
|
+
type: "object",
|
|
9384
|
+
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
9385
|
+
required: keys,
|
|
9386
|
+
additionalProperties: false
|
|
9387
|
+
};
|
|
9388
|
+
if (question.type === "choice") properties.choice = {
|
|
9389
|
+
type: "string",
|
|
9390
|
+
...keys.length ? { enum: keys } : {}
|
|
9391
|
+
};
|
|
9392
|
+
else {
|
|
9393
|
+
properties.score = {
|
|
9394
|
+
type: "number",
|
|
9395
|
+
minimum: 0,
|
|
9396
|
+
maximum: Math.max(0, keys.length - 1)
|
|
9397
|
+
};
|
|
9398
|
+
properties.legend = {
|
|
9399
|
+
type: "object",
|
|
9400
|
+
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
9401
|
+
required: keys,
|
|
9402
|
+
additionalProperties: false
|
|
9403
|
+
};
|
|
9404
|
+
}
|
|
9405
|
+
}
|
|
9406
|
+
return {
|
|
9407
|
+
type: "object",
|
|
9408
|
+
properties,
|
|
9409
|
+
required: Object.keys(properties)
|
|
9410
|
+
};
|
|
9411
|
+
}
|
|
9412
|
+
//#endregion
|
|
9223
9413
|
//#region src/flow/common/triggerScheduleSchema.ts
|
|
9224
9414
|
var triggerScheduleSchema = array(union([object({
|
|
9225
9415
|
type: literal("cron"),
|
|
@@ -9336,6 +9526,32 @@ var agentValue = union([object({
|
|
|
9336
9526
|
input: text
|
|
9337
9527
|
})]);
|
|
9338
9528
|
var agentInput = union([agentValue, object({ kind: literal("model") })]);
|
|
9529
|
+
var decisionQuestion = discriminatedUnion("type", [
|
|
9530
|
+
strictObject({
|
|
9531
|
+
name: text,
|
|
9532
|
+
instructions: text,
|
|
9533
|
+
type: literal("noul"),
|
|
9534
|
+
criteria: strictObject({
|
|
9535
|
+
true: text.optional(),
|
|
9536
|
+
false: text.optional()
|
|
9537
|
+
}).optional()
|
|
9538
|
+
}),
|
|
9539
|
+
strictObject({
|
|
9540
|
+
name: text,
|
|
9541
|
+
instructions: text,
|
|
9542
|
+
type: literal("choice"),
|
|
9543
|
+
criteria: array(strictObject({
|
|
9544
|
+
name: text,
|
|
9545
|
+
description: text
|
|
9546
|
+
}))
|
|
9547
|
+
}),
|
|
9548
|
+
strictObject({
|
|
9549
|
+
name: text,
|
|
9550
|
+
instructions: text,
|
|
9551
|
+
type: literal("score"),
|
|
9552
|
+
criteria: strings
|
|
9553
|
+
})
|
|
9554
|
+
]);
|
|
9339
9555
|
var managed = object({
|
|
9340
9556
|
...ports,
|
|
9341
9557
|
name: text,
|
|
@@ -9363,6 +9579,10 @@ var managed = object({
|
|
|
9363
9579
|
in: _enum(["header", "query"]).optional()
|
|
9364
9580
|
}))
|
|
9365
9581
|
}),
|
|
9582
|
+
strictObject({
|
|
9583
|
+
kind: literal("decision"),
|
|
9584
|
+
questions: array(decisionQuestion)
|
|
9585
|
+
}),
|
|
9366
9586
|
object({
|
|
9367
9587
|
kind: literal("llm"),
|
|
9368
9588
|
mode: _enum(["chat", "json"])
|
|
@@ -9389,7 +9609,7 @@ var managed = object({
|
|
|
9389
9609
|
}).optional()
|
|
9390
9610
|
})
|
|
9391
9611
|
])
|
|
9392
|
-
});
|
|
9612
|
+
}).transform(limitDecisionTask);
|
|
9393
9613
|
var operand = union([object({
|
|
9394
9614
|
kind: literal("value"),
|
|
9395
9615
|
value: json.optional(),
|
|
@@ -9783,6 +10003,11 @@ var shapes = {
|
|
|
9783
10003
|
before: text.optional(),
|
|
9784
10004
|
value: text.optional()
|
|
9785
10005
|
},
|
|
10006
|
+
"task.decision.set": {
|
|
10007
|
+
taskId: text,
|
|
10008
|
+
before: managed,
|
|
10009
|
+
value: managed
|
|
10010
|
+
},
|
|
9786
10011
|
"task.openapi.set": {
|
|
9787
10012
|
taskId: text,
|
|
9788
10013
|
before: managed,
|
|
@@ -86,3 +86,11 @@ export declare function resolveAction(declarations: readonly ConnectorCapability
|
|
|
86
86
|
readonly connectionId?: string;
|
|
87
87
|
readonly input: Readonly<Record<string, JsonValue>>;
|
|
88
88
|
};
|
|
89
|
+
export interface DecisionTaskInvocation {
|
|
90
|
+
readonly questions: readonly import('./decision.js').DecisionQuestion[];
|
|
91
|
+
readonly state: JsonValue;
|
|
92
|
+
readonly invocationId: string;
|
|
93
|
+
readonly signal: AbortSignal;
|
|
94
|
+
readonly version: 1;
|
|
95
|
+
}
|
|
96
|
+
export type InvokeDecisionTask = (invocation: DecisionTaskInvocation) => Promise<LlmTaskResult>;
|
|
@@ -25,7 +25,7 @@ export type SchedulerEvent = {
|
|
|
25
25
|
readonly inputs: Readonly<Record<string, JsonValue>>;
|
|
26
26
|
readonly jobId: string;
|
|
27
27
|
readonly nodeId: string;
|
|
28
|
-
readonly nodeKind: 'agent' | 'approval' | 'condition' | 'connector' | 'javascript' | 'openapi' | 'llm' | 'subflow' | 'value' | 'wait';
|
|
28
|
+
readonly nodeKind: 'agent' | 'approval' | 'condition' | 'connector' | 'decision' | 'javascript' | 'openapi' | 'llm' | 'subflow' | 'value' | 'wait';
|
|
29
29
|
readonly nodeTitle?: string;
|
|
30
30
|
readonly runId: string;
|
|
31
31
|
readonly type: 'node.started';
|