@oomol-lab/open-flow 0.1.0-beta.55 → 0.1.0-beta.57
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/README.md +1 -1
- package/dist/browser/{createResourceDialog-4H5_lZ6s.js → createResourceDialog-C23SBjYd.js} +2 -2
- package/dist/browser/flow-authoring-edge.d.ts +3 -3
- package/dist/browser/flow-authoring-node.d.ts +30 -46
- package/dist/browser/flow-authoring.js +9215 -21030
- package/dist/browser/flow-change-schema.d.ts +267 -1
- package/dist/browser/flow-change.d.ts +19 -104
- package/dist/browser/flow-change.js +154 -298
- package/dist/browser/{flowChanges-ZzG-f9cg.js → flowChanges-fBiAeTzR.js} +2347 -2216
- package/dist/browser/{flowWorkspace-ChpRaTMX.js → flowWorkspace-MqcEfg7T.js} +118 -293
- package/dist/browser/{icons-CdAB9wyS.js → icons-6oQ8Q9Wm.js} +4309 -4454
- package/dist/browser/lib-DrKav3HG.js +11403 -0
- package/dist/browser/preview.css +1 -1
- package/dist/browser/preview.js +9609 -9548
- package/dist/browser/ui-idTooltip.d.ts +11 -0
- package/dist/browser/ui.d.ts +5 -0
- package/dist/browser/ui.js +83 -1
- package/dist/browser/workbench.css +1 -1
- package/dist/browser/workbench.js +227 -417
- package/dist/browser/{workbenchSelect-BRZN4ish.js → workbenchSelect-DpLbIr29.js} +1 -1
- package/dist/common/authoring.d.ts +207 -0
- package/dist/common/authoringSchema.d.ts +1293 -0
- package/dist/common/control-api-conformance.js +1060 -623
- package/dist/common/control-api-errors.d.ts +2 -1
- package/dist/common/control-api.d.ts +87 -6
- package/dist/common/control-api.js +1058 -705
- package/dist/common/control-requests.d.ts +128 -0
- package/dist/common/control-requests.js +2913 -1145
- package/dist/common/decision.js +6337 -6371
- package/dist/common/flow-agent.d.ts +1 -1
- package/dist/common/flow-connectionUsage.d.ts +1 -2
- package/dist/common/flow-encoding.d.ts +2 -4
- package/dist/common/flow-encoding.js +131 -182
- package/dist/common/flow-graph.d.ts +10 -10
- package/dist/common/flow-semantics.d.ts +13 -9
- package/dist/common/flow-semantics.js +9051 -9232
- package/dist/common/flowInspection.d.ts +3 -21
- package/dist/common/integration-trigger.js +8653 -8687
- package/dist/common/lib-DrKav3HG.js +11403 -0
- package/dist/common/mcp.d.ts +120 -12
- package/dist/common/mcp.js +537 -188
- package/dist/common/openapi.js +6337 -6371
- package/dist/common/poll-trigger.js +8653 -8687
- package/dist/common/run-events.js +0 -1
- package/dist/common/scheduler.d.ts +3 -9
- package/dist/common/scheduler.js +128 -209
- package/dist/common/webhook-trigger.js +6337 -6371
- package/package.json +7 -1
- package/skills/open-flow/SKILL.md +32 -0
- package/skills/open-flow/references/flow-authoring.md +356 -0
- package/skills/open-flow/references/flow-n8n-conversion.md +196 -0
|
@@ -265,7 +265,7 @@ function safeExtend(schema, shape) {
|
|
|
265
265
|
if (!isPlainObject$1(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
266
266
|
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
267
267
|
}
|
|
268
|
-
function merge(a, b) {
|
|
268
|
+
function merge$1(a, b) {
|
|
269
269
|
if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
270
270
|
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
271
271
|
const newShape = {};
|
|
@@ -2780,6 +2780,9 @@ function handlePipeResult(left, next, ctx) {
|
|
|
2780
2780
|
issues: left.issues
|
|
2781
2781
|
}, ctx);
|
|
2782
2782
|
}
|
|
2783
|
+
var $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (inst, def) => {
|
|
2784
|
+
$ZodPipe.init(inst, def);
|
|
2785
|
+
});
|
|
2783
2786
|
var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
2784
2787
|
$ZodType.init(inst, def);
|
|
2785
2788
|
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
@@ -5503,7 +5506,7 @@ var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
|
5503
5506
|
return safeExtend(this, incoming);
|
|
5504
5507
|
},
|
|
5505
5508
|
merge(other) {
|
|
5506
|
-
return merge(this, other);
|
|
5509
|
+
return merge$1(this, other);
|
|
5507
5510
|
},
|
|
5508
5511
|
pick(mask) {
|
|
5509
5512
|
return pick$1(this, mask);
|
|
@@ -5581,7 +5584,7 @@ var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
|
5581
5584
|
inst.keyType = def.keyType;
|
|
5582
5585
|
inst.valueType = def.valueType;
|
|
5583
5586
|
});
|
|
5584
|
-
function record(keyType, valueType, params) {
|
|
5587
|
+
function record$3(keyType, valueType, params) {
|
|
5585
5588
|
if (!valueType || !valueType._zod) return new ZodRecord({
|
|
5586
5589
|
type: "record",
|
|
5587
5590
|
keyType: string(),
|
|
@@ -5790,6 +5793,10 @@ function pipe(in_, out) {
|
|
|
5790
5793
|
out
|
|
5791
5794
|
});
|
|
5792
5795
|
}
|
|
5796
|
+
var ZodPreprocess = /*@__PURE__*/ $constructor("ZodPreprocess", (inst, def) => {
|
|
5797
|
+
ZodPipe.init(inst, def);
|
|
5798
|
+
$ZodPreprocess.init(inst, def);
|
|
5799
|
+
});
|
|
5793
5800
|
var ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
5794
5801
|
$ZodReadonly.init(inst, def);
|
|
5795
5802
|
ZodType.init(inst, def);
|
|
@@ -5825,7 +5832,7 @@ function refine(fn, _params = {}) {
|
|
|
5825
5832
|
function superRefine(fn, params) {
|
|
5826
5833
|
return /* @__PURE__ */ _superRefine(fn, params);
|
|
5827
5834
|
}
|
|
5828
|
-
function json$
|
|
5835
|
+
function json$5(params) {
|
|
5829
5836
|
const jsonSchema = lazy(() => {
|
|
5830
5837
|
return union([
|
|
5831
5838
|
string(params),
|
|
@@ -5833,23 +5840,17 @@ function json$3(params) {
|
|
|
5833
5840
|
boolean(),
|
|
5834
5841
|
_null(),
|
|
5835
5842
|
array(jsonSchema),
|
|
5836
|
-
record(string(), jsonSchema)
|
|
5843
|
+
record$3(string(), jsonSchema)
|
|
5837
5844
|
]);
|
|
5838
5845
|
});
|
|
5839
5846
|
return jsonSchema;
|
|
5840
5847
|
}
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
/** Converts explicit user values at authoring boundaries, never persisted legacy data. */
|
|
5848
|
-
function inputValues(values) {
|
|
5849
|
-
return Object.fromEntries(Object.entries(values).map(([name, value]) => [name, {
|
|
5850
|
-
kind: "value",
|
|
5851
|
-
value
|
|
5852
|
-
}]));
|
|
5848
|
+
function preprocess(fn, schema) {
|
|
5849
|
+
return new ZodPreprocess({
|
|
5850
|
+
type: "pipe",
|
|
5851
|
+
in: transform(fn),
|
|
5852
|
+
out: schema
|
|
5853
|
+
});
|
|
5853
5854
|
}
|
|
5854
5855
|
//#endregion
|
|
5855
5856
|
//#region ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
@@ -5900,9 +5901,9 @@ function deepCompareStrict(a, b) {
|
|
|
5900
5901
|
//#endregion
|
|
5901
5902
|
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/pointer.js
|
|
5902
5903
|
function encodePointer(p) {
|
|
5903
|
-
return encodeURI(escapePointer(p));
|
|
5904
|
+
return encodeURI(escapePointer$1(p));
|
|
5904
5905
|
}
|
|
5905
|
-
function escapePointer(p) {
|
|
5906
|
+
function escapePointer$1(p) {
|
|
5906
5907
|
return p.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
5907
5908
|
}
|
|
5908
5909
|
//#endregion
|
|
@@ -6756,6 +6757,660 @@ var Validator = class {
|
|
|
6756
6757
|
}
|
|
6757
6758
|
};
|
|
6758
6759
|
//#endregion
|
|
6760
|
+
//#region src/openapi/common/authBindings.ts
|
|
6761
|
+
/** Never allow credentials to enter a Revision as literal node inputs. */
|
|
6762
|
+
function assertOpenApiAuthBindings(document) {
|
|
6763
|
+
for (const node of Object.values(document.graph.nodes)) {
|
|
6764
|
+
if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
|
|
6765
|
+
for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
|
|
6766
|
+
}
|
|
6767
|
+
}
|
|
6768
|
+
//#endregion
|
|
6769
|
+
//#region src/flow/common/inputValue.ts
|
|
6770
|
+
/** Converts explicit user values at authoring boundaries, never persisted legacy data. */
|
|
6771
|
+
function inputValues(values) {
|
|
6772
|
+
return Object.fromEntries(Object.entries(values).map(([name, value]) => [name, {
|
|
6773
|
+
kind: "value",
|
|
6774
|
+
value
|
|
6775
|
+
}]));
|
|
6776
|
+
}
|
|
6777
|
+
//#endregion
|
|
6778
|
+
//#region src/flow/common/condition.ts
|
|
6779
|
+
var unaryOperator = (operator) => operator.startsWith("is");
|
|
6780
|
+
var operandHandle = (caseIndex, groupIndex, expressionIndex, side) => `${caseIndex}/${groupIndex}/${expressionIndex}/${side}`;
|
|
6781
|
+
/** Derived addresses let operand bindings use the ordinary input analysis and editor. Never persisted as node inputs. */
|
|
6782
|
+
function conditionOperands(node) {
|
|
6783
|
+
return node.cases.flatMap((item, c) => item.groups.flatMap((group, g) => group.expressions.flatMap((expression, e) => [{
|
|
6784
|
+
handle: operandHandle(c, g, e, "left"),
|
|
6785
|
+
operand: expression.left,
|
|
6786
|
+
expression,
|
|
6787
|
+
side: "left"
|
|
6788
|
+
}, ...!unaryOperator(expression.operator) ? [{
|
|
6789
|
+
handle: operandHandle(c, g, e, "right"),
|
|
6790
|
+
operand: expression.right ?? { kind: "value" },
|
|
6791
|
+
expression,
|
|
6792
|
+
side: "right"
|
|
6793
|
+
}] : []])));
|
|
6794
|
+
}
|
|
6795
|
+
function nodeInputMappings(node) {
|
|
6796
|
+
if (node.kind != "condition") return "inputs" in node ? node.inputs : {};
|
|
6797
|
+
return Object.fromEntries(conditionOperands(node).flatMap(({ handle, operand }) => operand.kind == "source" ? [[handle, {
|
|
6798
|
+
kind: "sources",
|
|
6799
|
+
sources: [operand.source]
|
|
6800
|
+
}]] : operand.value === void 0 ? [] : [[handle, {
|
|
6801
|
+
kind: "value",
|
|
6802
|
+
value: operand.value
|
|
6803
|
+
}]]));
|
|
6804
|
+
}
|
|
6805
|
+
function conditionInputPorts(node) {
|
|
6806
|
+
return Object.fromEntries(conditionOperands(node).map(({ handle, operand }) => [handle, {
|
|
6807
|
+
jsonSchema: operand.kind === "value" ? operand.jsonSchema ?? {} : {},
|
|
6808
|
+
nullable: operand.kind === "value" ? operand.value === null : true
|
|
6809
|
+
}]));
|
|
6810
|
+
}
|
|
6811
|
+
function setConditionInput(node, handle, mapping) {
|
|
6812
|
+
const entry = conditionOperands(node).find((item) => item.handle == handle);
|
|
6813
|
+
if (entry == null) throw new Error("Condition operand does not exist.");
|
|
6814
|
+
if (mapping?.kind == "sources" && mapping.sources.length != 1) throw new Error("A Condition operand requires one Source.");
|
|
6815
|
+
const value = mapping?.kind == "sources" ? {
|
|
6816
|
+
kind: "source",
|
|
6817
|
+
source: mapping.sources[0]
|
|
6818
|
+
} : {
|
|
6819
|
+
kind: "value",
|
|
6820
|
+
...entry.operand.kind === "value" && entry.operand.jsonSchema != null ? { jsonSchema: entry.operand.jsonSchema } : {},
|
|
6821
|
+
...mapping?.kind == "value" ? { value: mapping.value } : {}
|
|
6822
|
+
};
|
|
6823
|
+
const [c, g, e] = handle.split("/").map(Number);
|
|
6824
|
+
return {
|
|
6825
|
+
...node,
|
|
6826
|
+
cases: node.cases.map((item, ci) => ci != c ? item : {
|
|
6827
|
+
...item,
|
|
6828
|
+
groups: item.groups.map((group, gi) => gi != g ? group : {
|
|
6829
|
+
...group,
|
|
6830
|
+
expressions: group.expressions.map((expression, ei) => ei != e ? expression : {
|
|
6831
|
+
...expression,
|
|
6832
|
+
[entry.side]: value
|
|
6833
|
+
})
|
|
6834
|
+
})
|
|
6835
|
+
})
|
|
6836
|
+
};
|
|
6837
|
+
}
|
|
6838
|
+
function resourceNameIssue(value) {
|
|
6839
|
+
const name = value.trim();
|
|
6840
|
+
if (name.length == 0) return "empty";
|
|
6841
|
+
if (name.length > 80) return "tooLong";
|
|
6842
|
+
for (const character of name) {
|
|
6843
|
+
const code = character.charCodeAt(0);
|
|
6844
|
+
if (code <= 31 || code >= 127 && code <= 159) return "controlCharacter";
|
|
6845
|
+
}
|
|
6846
|
+
if (!/^[\p{L}\p{N}](?:[\p{L}\p{N} _-]*[\p{L}\p{N}])?$/u.test(name)) return "specialCharacter";
|
|
6847
|
+
}
|
|
6848
|
+
function portsByHandle(ports) {
|
|
6849
|
+
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
|
|
6850
|
+
}
|
|
6851
|
+
function decodeConnectorCapabilities(value) {
|
|
6852
|
+
if (!Array.isArray(value)) throw new TypeError("Connector capabilities must be an array.");
|
|
6853
|
+
if (value.length == 0) return [];
|
|
6854
|
+
if (value.some((item) => item != null && typeof item == "object" && !Array.isArray(item) && Object.hasOwn(item, "mode"))) {
|
|
6855
|
+
if (value.length != 1) throw new TypeError("Connector capability is declared more than once.");
|
|
6856
|
+
const source = value[0];
|
|
6857
|
+
if (source.mode == "shared") {
|
|
6858
|
+
if (source.kind != "connector" || Object.keys(source).some((key) => !["kind", "mode"].includes(key))) throw new TypeError("Invalid shared Connector permission capability.");
|
|
6859
|
+
return [{
|
|
6860
|
+
kind: "connector",
|
|
6861
|
+
mode: "shared"
|
|
6862
|
+
}];
|
|
6863
|
+
}
|
|
6864
|
+
if (Object.keys(source).some((key) => ![
|
|
6865
|
+
"kind",
|
|
6866
|
+
"mode",
|
|
6867
|
+
"actions"
|
|
6868
|
+
].includes(key)) || source.kind != "connector" || source.mode != "independent" || !Array.isArray(source.actions)) throw new TypeError("Invalid Connector permission capability.");
|
|
6869
|
+
const actions = source.actions.map((entry) => {
|
|
6870
|
+
if (entry == null || typeof entry != "object" || Array.isArray(entry)) throw new TypeError("Invalid Connector Action.");
|
|
6871
|
+
const action = entry;
|
|
6872
|
+
if (Object.keys(action).some((key) => !["action", "connectionId"].includes(key)) || typeof action.action != "string" || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_.-]+$/.test(action.action) || Object.hasOwn(action, "connectionId") && (typeof action.connectionId != "string" || action.connectionId.length == 0)) throw new TypeError("Invalid Connector Action permission.");
|
|
6873
|
+
return action.connectionId == null ? { action: action.action } : {
|
|
6874
|
+
action: action.action,
|
|
6875
|
+
connectionId: action.connectionId
|
|
6876
|
+
};
|
|
6877
|
+
});
|
|
6878
|
+
if (new Set(actions.map((action) => action.action)).size != actions.length) throw new TypeError("Duplicate Connector Action permission.");
|
|
6879
|
+
return [{
|
|
6880
|
+
kind: "connector",
|
|
6881
|
+
mode: "independent",
|
|
6882
|
+
actions
|
|
6883
|
+
}];
|
|
6884
|
+
}
|
|
6885
|
+
if (value.some((item) => item != null && typeof item == "object" && !Array.isArray(item) && !Object.hasOwn(item, "action"))) {
|
|
6886
|
+
if (value.length != 1) throw new TypeError("Connector capability is declared more than once.");
|
|
6887
|
+
const item = value[0];
|
|
6888
|
+
if (item == null || typeof item != "object" || Array.isArray(item)) throw new TypeError("Invalid Connector capability.");
|
|
6889
|
+
const source = item;
|
|
6890
|
+
if (Object.keys(source).some((key) => ![
|
|
6891
|
+
"kind",
|
|
6892
|
+
"actionHints",
|
|
6893
|
+
"connectionHints"
|
|
6894
|
+
].includes(key)) || source.kind != "connector" || Object.hasOwn(source, "actionHints") && !Array.isArray(source.actionHints) || Object.hasOwn(source, "connectionHints") && !Array.isArray(source.connectionHints)) throw new TypeError("Invalid Connector capability.");
|
|
6895
|
+
const actionHints = (source.actionHints ?? []).map((action) => {
|
|
6896
|
+
if (typeof action != "string" || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_.-]+$/.test(action)) throw new TypeError("Invalid Connector Action hint.");
|
|
6897
|
+
return action;
|
|
6898
|
+
});
|
|
6899
|
+
if (new Set(actionHints).size != actionHints.length) throw new TypeError("Duplicate Connector Action hint.");
|
|
6900
|
+
const keys = /* @__PURE__ */ new Set();
|
|
6901
|
+
const connectionHints = (source.connectionHints ?? []).map((entry) => {
|
|
6902
|
+
if (entry == null || typeof entry != "object" || Array.isArray(entry)) throw new TypeError("Invalid Connector Connection hint.");
|
|
6903
|
+
const hint = entry;
|
|
6904
|
+
if (Object.keys(hint).some((key) => ![
|
|
6905
|
+
"action",
|
|
6906
|
+
"connectionId",
|
|
6907
|
+
"alias"
|
|
6908
|
+
].includes(key)) || typeof hint.action != "string" || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_.-]+$/.test(hint.action) || typeof hint.connectionId != "string" || hint.connectionId.length == 0 || Object.hasOwn(hint, "alias") && (typeof hint.alias != "string" || hint.alias.length == 0)) throw new TypeError("Invalid Connector Connection hint.");
|
|
6909
|
+
const key = `${hint.action}\0${hint.alias ?? ""}`;
|
|
6910
|
+
if (keys.has(key)) throw new TypeError("Duplicate Connector Connection hint.");
|
|
6911
|
+
keys.add(key);
|
|
6912
|
+
return hint.alias == null ? {
|
|
6913
|
+
action: hint.action,
|
|
6914
|
+
connectionId: hint.connectionId
|
|
6915
|
+
} : {
|
|
6916
|
+
action: hint.action,
|
|
6917
|
+
connectionId: hint.connectionId,
|
|
6918
|
+
alias: hint.alias
|
|
6919
|
+
};
|
|
6920
|
+
});
|
|
6921
|
+
return [{
|
|
6922
|
+
kind: "connector",
|
|
6923
|
+
...actionHints.length == 0 ? {} : { actionHints },
|
|
6924
|
+
...connectionHints.length == 0 ? {} : { connectionHints }
|
|
6925
|
+
}];
|
|
6926
|
+
}
|
|
6927
|
+
const actions = /* @__PURE__ */ new Set();
|
|
6928
|
+
return value.map((item) => {
|
|
6929
|
+
if (item == null || typeof item != "object" || Array.isArray(item)) throw new TypeError("Invalid Connector capability.");
|
|
6930
|
+
const source = item;
|
|
6931
|
+
if (Object.keys(source).some((key) => ![
|
|
6932
|
+
"kind",
|
|
6933
|
+
"action",
|
|
6934
|
+
"connections",
|
|
6935
|
+
"connectionId"
|
|
6936
|
+
].includes(key)) || source.kind != "connector" || typeof source.action != "string" || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_.-]+$/.test(source.action) || !Array.isArray(source.connections)) throw new TypeError("Invalid Connector capability.");
|
|
6937
|
+
if (actions.has(source.action)) throw new TypeError("Connector Action is declared more than once.");
|
|
6938
|
+
actions.add(source.action);
|
|
6939
|
+
const ids = /* @__PURE__ */ new Set();
|
|
6940
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
6941
|
+
const connections = source.connections.map((entry) => {
|
|
6942
|
+
if (entry == null || typeof entry != "object" || Array.isArray(entry)) throw new TypeError("Invalid Connector Connection.");
|
|
6943
|
+
const connection = entry;
|
|
6944
|
+
if (Object.keys(connection).some((key) => !["connectionId", "alias"].includes(key)) || typeof connection.connectionId != "string" || connection.connectionId.length == 0 || ids.has(connection.connectionId)) throw new TypeError("Invalid or duplicate Connector Connection ID.");
|
|
6945
|
+
ids.add(connection.connectionId);
|
|
6946
|
+
if (Object.hasOwn(connection, "alias")) {
|
|
6947
|
+
if (typeof connection.alias != "string" || connection.alias.length == 0 || aliases.has(connection.alias)) throw new TypeError("Invalid or duplicate Connector alias.");
|
|
6948
|
+
aliases.add(connection.alias);
|
|
6949
|
+
}
|
|
6950
|
+
return {
|
|
6951
|
+
connectionId: connection.connectionId,
|
|
6952
|
+
...connection.alias == null ? {} : { alias: connection.alias }
|
|
6953
|
+
};
|
|
6954
|
+
});
|
|
6955
|
+
if (Object.hasOwn(source, "connectionId") && (typeof source.connectionId != "string" || !ids.has(source.connectionId))) throw new TypeError("The default Connector Connection must be declared.");
|
|
6956
|
+
return {
|
|
6957
|
+
kind: "connector",
|
|
6958
|
+
action: source.action,
|
|
6959
|
+
connections,
|
|
6960
|
+
...source.connectionId == null ? {} : { connectionId: source.connectionId }
|
|
6961
|
+
};
|
|
6962
|
+
});
|
|
6963
|
+
}
|
|
6964
|
+
function normalizeNodeName(value) {
|
|
6965
|
+
return value.trim().normalize("NFC");
|
|
6966
|
+
}
|
|
6967
|
+
function nodeNameIssue(graph, nodeId, value) {
|
|
6968
|
+
const name = normalizeNodeName(value);
|
|
6969
|
+
if (name.length == 0) return "empty";
|
|
6970
|
+
return Object.entries(graph.nodes).some(([candidateId, node]) => candidateId != nodeId && node.name != null && normalizeNodeName(node.name) == name) ? "duplicate" : void 0;
|
|
6971
|
+
}
|
|
6972
|
+
var FlowChangeError = class extends Error {
|
|
6973
|
+
constructor(message) {
|
|
6974
|
+
super(message);
|
|
6975
|
+
this.name = "FlowChangeError";
|
|
6976
|
+
}
|
|
6977
|
+
};
|
|
6978
|
+
function invalid(message) {
|
|
6979
|
+
throw new FlowChangeError(message);
|
|
6980
|
+
}
|
|
6981
|
+
function applyFlowChanges(content, operations) {
|
|
6982
|
+
const document = { ...content.document };
|
|
6983
|
+
const modules = { ...content.modules };
|
|
6984
|
+
for (const operation of operations) switch (operation.kind) {
|
|
6985
|
+
case "graph.trigger.sources.set": {
|
|
6986
|
+
const graph = document.graph;
|
|
6987
|
+
const node = graph.nodes[operation.nodeId];
|
|
6988
|
+
if (node?.kind != "error") invalid("The Flow Error node does not exist.");
|
|
6989
|
+
if (!dequal(node.sourceFlowIds, operation.before)) invalid("The Flow Error node’s sources changed before this operation was applied.");
|
|
6990
|
+
const { sourceFlowIds: _, ...base } = node;
|
|
6991
|
+
const updated = operation.value == null ? base : {
|
|
6992
|
+
...base,
|
|
6993
|
+
sourceFlowIds: operation.value
|
|
6994
|
+
};
|
|
6995
|
+
document.graph = {
|
|
6996
|
+
...graph,
|
|
6997
|
+
nodes: {
|
|
6998
|
+
...graph.nodes,
|
|
6999
|
+
[operation.nodeId]: updated
|
|
7000
|
+
}
|
|
7001
|
+
};
|
|
7002
|
+
break;
|
|
7003
|
+
}
|
|
7004
|
+
case "binding.create":
|
|
7005
|
+
if (document.bindings[operation.bindingId] != null) invalid("A Binding with this ID already exists.");
|
|
7006
|
+
document.bindings = {
|
|
7007
|
+
...document.bindings,
|
|
7008
|
+
[operation.bindingId]: operation.binding
|
|
7009
|
+
};
|
|
7010
|
+
break;
|
|
7011
|
+
case "binding.delete": {
|
|
7012
|
+
if (document.bindings[operation.bindingId] == null) invalid("The Binding does not exist.");
|
|
7013
|
+
const bindings = { ...document.bindings };
|
|
7014
|
+
delete bindings[operation.bindingId];
|
|
7015
|
+
document.bindings = bindings;
|
|
7016
|
+
break;
|
|
7017
|
+
}
|
|
7018
|
+
case "binding.target.set": {
|
|
7019
|
+
const binding = document.bindings[operation.bindingId];
|
|
7020
|
+
if (binding == null) invalid("The Binding does not exist.");
|
|
7021
|
+
if (binding.target != operation.before) invalid("The Binding target changed before this operation was applied.");
|
|
7022
|
+
document.bindings = {
|
|
7023
|
+
...document.bindings,
|
|
7024
|
+
[operation.bindingId]: {
|
|
7025
|
+
...binding,
|
|
7026
|
+
target: operation.value
|
|
7027
|
+
}
|
|
7028
|
+
};
|
|
7029
|
+
break;
|
|
7030
|
+
}
|
|
7031
|
+
case "graph.edge.connect": {
|
|
7032
|
+
const graph = document.graph;
|
|
7033
|
+
if (graph.nodes[operation.edge.source] == null) invalid("The source Node does not exist.");
|
|
7034
|
+
const node = graph.nodes[operation.edge.target];
|
|
7035
|
+
if (node == null || !("inputs" in node)) invalid("The target Node does not accept execution dependencies.");
|
|
7036
|
+
if (graph.edges.some((edge) => dequal(edge, operation.edge))) invalid("The Nodes are already connected.");
|
|
7037
|
+
Object.assign(document, { graph: {
|
|
7038
|
+
...graph,
|
|
7039
|
+
edges: [...graph.edges, operation.edge]
|
|
7040
|
+
} });
|
|
7041
|
+
break;
|
|
7042
|
+
}
|
|
7043
|
+
case "graph.edge.disconnect": {
|
|
7044
|
+
const graph = document.graph;
|
|
7045
|
+
const edges = graph.edges.filter((edge) => !dequal(edge, operation.edge));
|
|
7046
|
+
if (edges.length == graph.edges.length) invalid("The Nodes are not connected.");
|
|
7047
|
+
Object.assign(document, { graph: {
|
|
7048
|
+
...graph,
|
|
7049
|
+
edges
|
|
7050
|
+
} });
|
|
7051
|
+
break;
|
|
7052
|
+
}
|
|
7053
|
+
case "graph.node.additional-inputs.set": {
|
|
7054
|
+
const graph = document.graph;
|
|
7055
|
+
const node = graph.nodes[operation.nodeId];
|
|
7056
|
+
if (node?.kind != "task") invalid("The Task Node does not exist.");
|
|
7057
|
+
if (!dequal(node.additionalInputs, operation.before)) invalid("The Task Node inputs changed before this operation was applied.");
|
|
7058
|
+
const { additionalInputs: _, ...rest } = node;
|
|
7059
|
+
const updated = operation.value == null ? rest : {
|
|
7060
|
+
...rest,
|
|
7061
|
+
additionalInputs: operation.value
|
|
7062
|
+
};
|
|
7063
|
+
Object.assign(document, { graph: {
|
|
7064
|
+
...graph,
|
|
7065
|
+
nodes: {
|
|
7066
|
+
...graph.nodes,
|
|
7067
|
+
[operation.nodeId]: updated
|
|
7068
|
+
}
|
|
7069
|
+
} });
|
|
7070
|
+
break;
|
|
7071
|
+
}
|
|
7072
|
+
case "graph.node.condition.set": {
|
|
7073
|
+
const graph = document.graph;
|
|
7074
|
+
const node = graph.nodes[operation.nodeId];
|
|
7075
|
+
if (node?.kind != "condition") invalid("The Condition Node does not exist.");
|
|
7076
|
+
if (!dequal(node.cases, operation.before.cases) || node.matchMode != operation.before.matchMode) invalid("The Condition Node changed before this operation was applied.");
|
|
7077
|
+
const updated = {
|
|
7078
|
+
...node,
|
|
7079
|
+
...operation.value
|
|
7080
|
+
};
|
|
7081
|
+
Object.assign(document, { graph: {
|
|
7082
|
+
...graph,
|
|
7083
|
+
nodes: {
|
|
7084
|
+
...graph.nodes,
|
|
7085
|
+
[operation.nodeId]: updated
|
|
7086
|
+
}
|
|
7087
|
+
} });
|
|
7088
|
+
break;
|
|
7089
|
+
}
|
|
7090
|
+
case "graph.node.replace": {
|
|
7091
|
+
const graph = document.graph;
|
|
7092
|
+
if (!dequal(graph.nodes[operation.nodeId], operation.before)) invalid("The Node changed before this operation was applied.");
|
|
7093
|
+
if (operation.node.kind != operation.before.kind) invalid("Replacing a Node cannot change its kind.");
|
|
7094
|
+
if (operation.node.kind == "task" && "moduleId" in operation.node.task && operation.node.task.capabilities !== void 0) decodeConnectorCapabilities(operation.node.task.capabilities);
|
|
7095
|
+
const name = normalizeNodeName(operation.node.name ?? "");
|
|
7096
|
+
const issue = nodeNameIssue(graph, operation.nodeId, name);
|
|
7097
|
+
if (issue != null) invalid(`Node name is ${issue}.`);
|
|
7098
|
+
const node = name == operation.node.name ? operation.node : {
|
|
7099
|
+
...operation.node,
|
|
7100
|
+
name
|
|
7101
|
+
};
|
|
7102
|
+
Object.assign(document, { graph: {
|
|
7103
|
+
...graph,
|
|
7104
|
+
nodes: {
|
|
7105
|
+
...graph.nodes,
|
|
7106
|
+
[operation.nodeId]: node
|
|
7107
|
+
}
|
|
7108
|
+
} });
|
|
7109
|
+
break;
|
|
7110
|
+
}
|
|
7111
|
+
case "graph.node.create": {
|
|
7112
|
+
const graph = document.graph;
|
|
7113
|
+
if (graph.nodes[operation.nodeId] != null) invalid("A Node with this ID already exists in the target graph.");
|
|
7114
|
+
if (operation.node.kind == "error" && Object.values(graph.nodes).some((node) => node.kind == "error")) invalid("A graph can contain only one Flow Error node.");
|
|
7115
|
+
if (operation.node.kind == "manual" && Object.values(graph.nodes).some((node) => node.kind == "manual")) invalid("A graph can contain only one manual Trigger.");
|
|
7116
|
+
if (operation.node.kind == "task" && "moduleId" in operation.node.task && operation.node.task.capabilities !== void 0) decodeConnectorCapabilities(operation.node.task.capabilities);
|
|
7117
|
+
if (operation.node.name == null) invalid("A Node name cannot be empty.");
|
|
7118
|
+
const name = normalizeNodeName(operation.node.name);
|
|
7119
|
+
const issue = nodeNameIssue(graph, operation.nodeId, name);
|
|
7120
|
+
if (issue == "empty") invalid("A Node name cannot be empty.");
|
|
7121
|
+
if (issue == "duplicate") invalid("A Node with this name already exists in the target graph.");
|
|
7122
|
+
const node = name == operation.node.name ? operation.node : {
|
|
7123
|
+
...operation.node,
|
|
7124
|
+
name
|
|
7125
|
+
};
|
|
7126
|
+
Object.assign(document, { graph: {
|
|
7127
|
+
...graph,
|
|
7128
|
+
nodes: {
|
|
7129
|
+
...graph.nodes,
|
|
7130
|
+
[operation.nodeId]: node
|
|
7131
|
+
}
|
|
7132
|
+
} });
|
|
7133
|
+
break;
|
|
7134
|
+
}
|
|
7135
|
+
case "graph.node.delete": {
|
|
7136
|
+
const graph = document.graph;
|
|
7137
|
+
if (graph.nodes[operation.nodeId] == null) invalid("The Node does not exist in the target graph.");
|
|
7138
|
+
const removed = /* @__PURE__ */ new Set([operation.nodeId]);
|
|
7139
|
+
const nodes = Object.fromEntries(Object.entries(graph.nodes).filter(([nodeId]) => !removed.has(nodeId)));
|
|
7140
|
+
Object.assign(document, { graph: {
|
|
7141
|
+
...graph,
|
|
7142
|
+
edges: graph.edges.filter((edge) => !removed.has(edge.source) && !removed.has(edge.target)),
|
|
7143
|
+
nodes
|
|
7144
|
+
} });
|
|
7145
|
+
break;
|
|
7146
|
+
}
|
|
7147
|
+
case "graph.node.field.set": {
|
|
7148
|
+
const graph = document.graph;
|
|
7149
|
+
const node = graph.nodes[operation.nodeId];
|
|
7150
|
+
if (node == null) invalid("The Node does not exist in the target graph.");
|
|
7151
|
+
if (operation.field == "connectionId" && node.kind != "poll" && node.kind != "integration") invalid("Only provider Triggers select a node Connection.");
|
|
7152
|
+
if (!dequal(Reflect.get(node, operation.field), operation.before)) invalid("The Node field changed before this operation was applied.");
|
|
7153
|
+
const updated = { ...node };
|
|
7154
|
+
if (operation.field == "name") {
|
|
7155
|
+
if (typeof operation.value != "string") invalid("A Node name cannot be empty.");
|
|
7156
|
+
const name = normalizeNodeName(operation.value);
|
|
7157
|
+
const issue = nodeNameIssue(graph, operation.nodeId, name);
|
|
7158
|
+
if (issue == "empty") invalid("A Node name cannot be empty.");
|
|
7159
|
+
if (issue == "duplicate") invalid("A Node with this name already exists in the target graph.");
|
|
7160
|
+
Object.assign(updated, { name });
|
|
7161
|
+
} else if (operation.value == null) Reflect.deleteProperty(updated, operation.field);
|
|
7162
|
+
else Object.assign(updated, { [operation.field]: operation.value });
|
|
7163
|
+
Object.assign(document, { graph: {
|
|
7164
|
+
...graph,
|
|
7165
|
+
nodes: {
|
|
7166
|
+
...graph.nodes,
|
|
7167
|
+
[operation.nodeId]: updated
|
|
7168
|
+
}
|
|
7169
|
+
} });
|
|
7170
|
+
break;
|
|
7171
|
+
}
|
|
7172
|
+
case "graph.node.input.set": {
|
|
7173
|
+
const graph = document.graph;
|
|
7174
|
+
const node = graph.nodes[operation.nodeId];
|
|
7175
|
+
if (node == null || !("inputs" in node)) invalid("The Node does not accept inputs.");
|
|
7176
|
+
if (!dequal(nodeInputMappings(node)[operation.handle], operation.before)) invalid("The Node input changed before this operation was applied.");
|
|
7177
|
+
const inputs = { ...node.inputs };
|
|
7178
|
+
if (operation.value == null) delete inputs[operation.handle];
|
|
7179
|
+
else inputs[operation.handle] = operation.value;
|
|
7180
|
+
Object.assign(document, { graph: {
|
|
7181
|
+
...graph,
|
|
7182
|
+
nodes: {
|
|
7183
|
+
...graph.nodes,
|
|
7184
|
+
[operation.nodeId]: node.kind == "condition" ? setConditionInput(node, operation.handle, operation.value) : {
|
|
7185
|
+
...node,
|
|
7186
|
+
inputs
|
|
7187
|
+
}
|
|
7188
|
+
}
|
|
7189
|
+
} });
|
|
7190
|
+
break;
|
|
7191
|
+
}
|
|
7192
|
+
case "graph.node.task.capabilities.set": {
|
|
7193
|
+
const graph = document.graph;
|
|
7194
|
+
const node = graph.nodes[operation.nodeId];
|
|
7195
|
+
if (node?.kind != "task" || !("moduleId" in node.task)) invalid("The inline Task Node does not exist.");
|
|
7196
|
+
if (!dequal(node.task.capabilities, operation.before)) invalid("The inline Task capabilities changed before this operation was applied.");
|
|
7197
|
+
const task = { ...node.task };
|
|
7198
|
+
if (operation.value === void 0) delete task.capabilities;
|
|
7199
|
+
else task.capabilities = decodeConnectorCapabilities(operation.value);
|
|
7200
|
+
Object.assign(document, { graph: {
|
|
7201
|
+
...graph,
|
|
7202
|
+
nodes: {
|
|
7203
|
+
...graph.nodes,
|
|
7204
|
+
[operation.nodeId]: {
|
|
7205
|
+
...node,
|
|
7206
|
+
task
|
|
7207
|
+
}
|
|
7208
|
+
}
|
|
7209
|
+
} });
|
|
7210
|
+
break;
|
|
7211
|
+
}
|
|
7212
|
+
case "graph.node.task.name.set": {
|
|
7213
|
+
const graph = document.graph;
|
|
7214
|
+
const node = graph.nodes[operation.nodeId];
|
|
7215
|
+
if (node?.kind != "task" || !("moduleId" in node.task)) invalid("The inline Task Node does not exist.");
|
|
7216
|
+
if (node.task.name != operation.before) invalid("The inline Task name changed before this operation was applied.");
|
|
7217
|
+
const updated = {
|
|
7218
|
+
...node,
|
|
7219
|
+
task: {
|
|
7220
|
+
...node.task,
|
|
7221
|
+
name: operation.value
|
|
7222
|
+
}
|
|
7223
|
+
};
|
|
7224
|
+
Object.assign(document, { graph: {
|
|
7225
|
+
...graph,
|
|
7226
|
+
nodes: {
|
|
7227
|
+
...graph.nodes,
|
|
7228
|
+
[operation.nodeId]: updated
|
|
7229
|
+
}
|
|
7230
|
+
} });
|
|
7231
|
+
break;
|
|
7232
|
+
}
|
|
7233
|
+
case "graph.node.task.ports.set": {
|
|
7234
|
+
const graph = document.graph;
|
|
7235
|
+
const node = graph.nodes[operation.nodeId];
|
|
7236
|
+
if (node?.kind != "task" || !("moduleId" in node.task)) invalid("The inline Task Node does not exist.");
|
|
7237
|
+
if (!dequal({
|
|
7238
|
+
inputs: node.task.inputs,
|
|
7239
|
+
outputs: node.task.outputs
|
|
7240
|
+
}, operation.before)) invalid("The inline Task ports changed before this operation was applied.");
|
|
7241
|
+
const updated = {
|
|
7242
|
+
...node,
|
|
7243
|
+
task: {
|
|
7244
|
+
...node.task,
|
|
7245
|
+
inputs: operation.value.inputs,
|
|
7246
|
+
outputs: operation.value.outputs
|
|
7247
|
+
}
|
|
7248
|
+
};
|
|
7249
|
+
Object.assign(document, { graph: {
|
|
7250
|
+
...graph,
|
|
7251
|
+
nodes: {
|
|
7252
|
+
...graph.nodes,
|
|
7253
|
+
[operation.nodeId]: updated
|
|
7254
|
+
}
|
|
7255
|
+
} });
|
|
7256
|
+
break;
|
|
7257
|
+
}
|
|
7258
|
+
case "graph.node.values.set": {
|
|
7259
|
+
const graph = document.graph;
|
|
7260
|
+
const node = graph.nodes[operation.nodeId];
|
|
7261
|
+
if (node?.kind != "value") invalid("The Value Node does not exist.");
|
|
7262
|
+
if (!dequal(node.values, operation.before)) invalid("The Value Node changed before this operation was applied.");
|
|
7263
|
+
Object.assign(document, { graph: {
|
|
7264
|
+
...graph,
|
|
7265
|
+
nodes: {
|
|
7266
|
+
...graph.nodes,
|
|
7267
|
+
[operation.nodeId]: {
|
|
7268
|
+
...node,
|
|
7269
|
+
values: operation.value
|
|
7270
|
+
}
|
|
7271
|
+
}
|
|
7272
|
+
} });
|
|
7273
|
+
break;
|
|
7274
|
+
}
|
|
7275
|
+
case "graph.node.resolution.set": {
|
|
7276
|
+
const graph = document.graph;
|
|
7277
|
+
const node = graph.nodes[operation.nodeId];
|
|
7278
|
+
if (node?.kind != "wait" && node?.kind != "approval" || !dequal({
|
|
7279
|
+
inputDefinitions: node.inputDefinitions,
|
|
7280
|
+
prompt: node.prompt
|
|
7281
|
+
}, operation.before)) invalid("The resolution node changed before this operation was applied.");
|
|
7282
|
+
const updated = {
|
|
7283
|
+
...node,
|
|
7284
|
+
...operation.value
|
|
7285
|
+
};
|
|
7286
|
+
document.graph = {
|
|
7287
|
+
...graph,
|
|
7288
|
+
nodes: {
|
|
7289
|
+
...graph.nodes,
|
|
7290
|
+
[operation.nodeId]: updated
|
|
7291
|
+
}
|
|
7292
|
+
};
|
|
7293
|
+
break;
|
|
7294
|
+
}
|
|
7295
|
+
case "graph.node.webhook.set": {
|
|
7296
|
+
const graph = document.graph;
|
|
7297
|
+
const node = graph.nodes[operation.nodeId];
|
|
7298
|
+
if (node?.kind != "webhook") invalid("The Webhook Node does not exist.");
|
|
7299
|
+
if (node.method != operation.before.method || !dequal(node.bodyFields, operation.before.bodyFields) || !dequal(node.options, operation.before.options)) invalid("The Webhook Node changed before this operation was applied.");
|
|
7300
|
+
const { options: _, ...rest } = node;
|
|
7301
|
+
const updated = operation.value.options == null ? {
|
|
7302
|
+
...rest,
|
|
7303
|
+
bodyFields: operation.value.bodyFields,
|
|
7304
|
+
method: operation.value.method
|
|
7305
|
+
} : {
|
|
7306
|
+
...node,
|
|
7307
|
+
...operation.value
|
|
7308
|
+
};
|
|
7309
|
+
Object.assign(document, { graph: {
|
|
7310
|
+
...graph,
|
|
7311
|
+
nodes: {
|
|
7312
|
+
...graph.nodes,
|
|
7313
|
+
[operation.nodeId]: updated
|
|
7314
|
+
}
|
|
7315
|
+
} });
|
|
7316
|
+
break;
|
|
7317
|
+
}
|
|
7318
|
+
case "graph.trigger.config.set": {
|
|
7319
|
+
const graph = document.graph;
|
|
7320
|
+
const node = graph.nodes[operation.nodeId];
|
|
7321
|
+
if (node == null || node.kind != "integration" && node.kind != "poll") invalid("The configurable Trigger Node does not exist.");
|
|
7322
|
+
if (!dequal(node.config[operation.name], operation.before)) invalid("The Trigger configuration changed before this operation was applied.");
|
|
7323
|
+
const config = { ...node.config };
|
|
7324
|
+
if (operation.value === void 0) delete config[operation.name];
|
|
7325
|
+
else config[operation.name] = operation.value;
|
|
7326
|
+
document.graph = {
|
|
7327
|
+
...graph,
|
|
7328
|
+
nodes: {
|
|
7329
|
+
...graph.nodes,
|
|
7330
|
+
[operation.nodeId]: {
|
|
7331
|
+
...node,
|
|
7332
|
+
config
|
|
7333
|
+
}
|
|
7334
|
+
}
|
|
7335
|
+
};
|
|
7336
|
+
break;
|
|
7337
|
+
}
|
|
7338
|
+
case "graph.trigger.schedule.set": {
|
|
7339
|
+
const graph = document.graph;
|
|
7340
|
+
const node = graph.nodes[operation.nodeId];
|
|
7341
|
+
if (node == null || node.kind != "cron" && node.kind != "poll") invalid("The scheduled Trigger Node does not exist.");
|
|
7342
|
+
if (!dequal(node.kind == "cron" ? node.cronTimes : node.pollTimes, operation.before)) invalid("The Trigger schedule changed before this operation was applied.");
|
|
7343
|
+
const updated = node.kind == "cron" ? {
|
|
7344
|
+
...node,
|
|
7345
|
+
cronTimes: operation.value
|
|
7346
|
+
} : {
|
|
7347
|
+
...node,
|
|
7348
|
+
pollTimes: operation.value
|
|
7349
|
+
};
|
|
7350
|
+
document.graph = {
|
|
7351
|
+
...graph,
|
|
7352
|
+
nodes: {
|
|
7353
|
+
...graph.nodes,
|
|
7354
|
+
[operation.nodeId]: updated
|
|
7355
|
+
}
|
|
7356
|
+
};
|
|
7357
|
+
break;
|
|
7358
|
+
}
|
|
7359
|
+
case "module.create":
|
|
7360
|
+
if (modules[operation.moduleId] != null) invalid("A CodeModule with this ID already exists.");
|
|
7361
|
+
modules[operation.moduleId] = operation.module;
|
|
7362
|
+
break;
|
|
7363
|
+
case "module.delete":
|
|
7364
|
+
if (modules[operation.moduleId] == null) invalid("The CodeModule does not exist.");
|
|
7365
|
+
delete modules[operation.moduleId];
|
|
7366
|
+
break;
|
|
7367
|
+
case "module.rename": {
|
|
7368
|
+
const module = modules[operation.moduleId];
|
|
7369
|
+
if (module == null) invalid("The CodeModule does not exist.");
|
|
7370
|
+
if (module.name != operation.before) invalid("The CodeModule name changed before this operation was applied.");
|
|
7371
|
+
modules[operation.moduleId] = {
|
|
7372
|
+
...module,
|
|
7373
|
+
name: operation.name
|
|
7374
|
+
};
|
|
7375
|
+
break;
|
|
7376
|
+
}
|
|
7377
|
+
case "module.source.replace": {
|
|
7378
|
+
const module = modules[operation.moduleId];
|
|
7379
|
+
if (module == null) invalid("The CodeModule does not exist.");
|
|
7380
|
+
if (module.source != operation.beforeSource || !dequal(module.imports, operation.beforeImports)) invalid("The CodeModule source changed before this operation was applied.");
|
|
7381
|
+
modules[operation.moduleId] = {
|
|
7382
|
+
...module,
|
|
7383
|
+
imports: operation.imports,
|
|
7384
|
+
source: operation.source
|
|
7385
|
+
};
|
|
7386
|
+
break;
|
|
7387
|
+
}
|
|
7388
|
+
case "graph.node.task.set": {
|
|
7389
|
+
const graph = document.graph;
|
|
7390
|
+
const node = graph.nodes[operation.nodeId];
|
|
7391
|
+
if (node?.kind != "task") invalid("The Task Node does not exist.");
|
|
7392
|
+
if (!dequal(node.task, operation.before)) invalid("The Task configuration changed before this operation was applied.");
|
|
7393
|
+
document.graph = {
|
|
7394
|
+
...graph,
|
|
7395
|
+
nodes: {
|
|
7396
|
+
...graph.nodes,
|
|
7397
|
+
[operation.nodeId]: {
|
|
7398
|
+
...node,
|
|
7399
|
+
task: operation.value
|
|
7400
|
+
}
|
|
7401
|
+
}
|
|
7402
|
+
};
|
|
7403
|
+
break;
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7406
|
+
assertOpenApiAuthBindings(document);
|
|
7407
|
+
return {
|
|
7408
|
+
document,
|
|
7409
|
+
modelVersion: 6,
|
|
7410
|
+
modules
|
|
7411
|
+
};
|
|
7412
|
+
}
|
|
7413
|
+
//#endregion
|
|
6759
7414
|
//#region src/json-schema-subset/utils.ts
|
|
6760
7415
|
var nextId = 0;
|
|
6761
7416
|
function createId() {
|
|
@@ -7175,7 +7830,7 @@ var ExpressionKind = Object.freeze({
|
|
|
7175
7830
|
});
|
|
7176
7831
|
//#endregion
|
|
7177
7832
|
//#region src/json-schema-subset/expression/expression.ts
|
|
7178
|
-
var expression = (delegate) => (e1, e2) => {
|
|
7833
|
+
var expression$1 = (delegate) => (e1, e2) => {
|
|
7179
7834
|
const rootNode = {
|
|
7180
7835
|
parent: null,
|
|
7181
7836
|
swapped: false,
|
|
@@ -9163,7 +9818,7 @@ function checkWithResult(extendsContext, schema1, schema2) {
|
|
|
9163
9818
|
const describe = describer();
|
|
9164
9819
|
const equals = schemaEqualsChecker(extendsContext);
|
|
9165
9820
|
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
9166
|
-
context.calculate = expression({
|
|
9821
|
+
context.calculate = expression$1({
|
|
9167
9822
|
describe,
|
|
9168
9823
|
equals,
|
|
9169
9824
|
calculate,
|
|
@@ -9402,7 +10057,7 @@ var isObject = (x) => x !== null && typeof x === "object";
|
|
|
9402
10057
|
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
9403
10058
|
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
9404
10059
|
//#endregion
|
|
9405
|
-
//#region src/
|
|
10060
|
+
//#region src/flow/common/schemaComparer.ts
|
|
9406
10061
|
function isStringLikeSchema(value) {
|
|
9407
10062
|
return toPlainObject(value)?.type === "string";
|
|
9408
10063
|
}
|
|
@@ -9691,47 +10346,41 @@ var webhookMethods = [
|
|
|
9691
10346
|
"PATCH",
|
|
9692
10347
|
"DELETE"
|
|
9693
10348
|
];
|
|
10349
|
+
function webhookSupportsBody(method) {
|
|
10350
|
+
return method !== "GET";
|
|
10351
|
+
}
|
|
9694
10352
|
var text$1 = string();
|
|
9695
|
-
var json$
|
|
10353
|
+
var json$4 = json$5();
|
|
9696
10354
|
var strings = array(text$1);
|
|
9697
10355
|
var port = object$1({
|
|
9698
10356
|
description: text$1.optional(),
|
|
9699
|
-
jsonSchema: json$
|
|
10357
|
+
jsonSchema: json$4,
|
|
9700
10358
|
nullable: boolean(),
|
|
9701
10359
|
handle: text$1
|
|
9702
10360
|
});
|
|
9703
|
-
var input = port.extend({ value: json$
|
|
10361
|
+
var input = port.extend({ value: json$4.optional() });
|
|
9704
10362
|
var group = object$1({
|
|
9705
10363
|
collapsed: boolean().optional(),
|
|
9706
10364
|
group: text$1
|
|
9707
10365
|
});
|
|
9708
|
-
var
|
|
10366
|
+
var source = union([object$1({
|
|
9709
10367
|
kind: literal("node"),
|
|
9710
10368
|
nodeId: text$1,
|
|
9711
10369
|
output: text$1,
|
|
9712
10370
|
field: text$1.optional()
|
|
9713
|
-
})
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
});
|
|
9718
|
-
var source = union([
|
|
9719
|
-
nodeSource,
|
|
9720
|
-
flowSource,
|
|
9721
|
-
object$1({
|
|
9722
|
-
kind: literal("binding"),
|
|
9723
|
-
bindingId: text$1
|
|
9724
|
-
})
|
|
9725
|
-
]);
|
|
10371
|
+
}), object$1({
|
|
10372
|
+
kind: literal("binding"),
|
|
10373
|
+
bindingId: text$1
|
|
10374
|
+
})]);
|
|
9726
10375
|
var fixedInput = union([object$1({ kind: literal("unset") }), object$1({
|
|
9727
10376
|
kind: literal("value"),
|
|
9728
|
-
value: json$
|
|
10377
|
+
value: json$4
|
|
9729
10378
|
})]);
|
|
9730
10379
|
var mapping = union([fixedInput, object$1({
|
|
9731
10380
|
kind: literal("sources"),
|
|
9732
10381
|
sources: array(source)
|
|
9733
10382
|
})]);
|
|
9734
|
-
var inputs$1 = record(text$1, mapping);
|
|
10383
|
+
var inputs$1 = record$3(text$1, mapping);
|
|
9735
10384
|
var ports = {
|
|
9736
10385
|
inputs: array(union([input, group])),
|
|
9737
10386
|
outputs: array(union([port, group]))
|
|
@@ -9776,7 +10425,7 @@ var inline = object$1({
|
|
|
9776
10425
|
});
|
|
9777
10426
|
var agentValue = union([object$1({
|
|
9778
10427
|
kind: literal("value"),
|
|
9779
|
-
value: json$
|
|
10428
|
+
value: json$4
|
|
9780
10429
|
}), object$1({
|
|
9781
10430
|
kind: literal("input"),
|
|
9782
10431
|
input: text$1
|
|
@@ -9808,7 +10457,7 @@ var decisionQuestion = discriminatedUnion("type", [
|
|
|
9808
10457
|
criteria: strings
|
|
9809
10458
|
})
|
|
9810
10459
|
]);
|
|
9811
|
-
var
|
|
10460
|
+
var managedFields = object$1({
|
|
9812
10461
|
...ports,
|
|
9813
10462
|
name: text$1,
|
|
9814
10463
|
executor: union([
|
|
@@ -9823,7 +10472,7 @@ var managed = object$1({
|
|
|
9823
10472
|
method: text$1,
|
|
9824
10473
|
path: text$1,
|
|
9825
10474
|
serverUrl: text$1,
|
|
9826
|
-
document: json$
|
|
10475
|
+
document: json$4,
|
|
9827
10476
|
auth: array(object$1({
|
|
9828
10477
|
id: text$1,
|
|
9829
10478
|
type: _enum([
|
|
@@ -9859,17 +10508,20 @@ var managed = object$1({
|
|
|
9859
10508
|
inputs: array(input.extend({ source: agentInput }))
|
|
9860
10509
|
})),
|
|
9861
10510
|
notification: object$1({
|
|
9862
|
-
|
|
10511
|
+
action: text$1,
|
|
10512
|
+
connectionId: text$1.optional(),
|
|
10513
|
+
inputDefinitions: array(input),
|
|
9863
10514
|
messageHandle: text$1,
|
|
9864
|
-
inputs: record(text$1, agentValue)
|
|
10515
|
+
inputs: record$3(text$1, agentValue)
|
|
9865
10516
|
}).optional()
|
|
9866
10517
|
})
|
|
9867
10518
|
])
|
|
9868
|
-
})
|
|
9869
|
-
var
|
|
10519
|
+
});
|
|
10520
|
+
var managed = managedFields.transform(limitDecisionTask);
|
|
10521
|
+
var operand$1 = union([object$1({
|
|
9870
10522
|
kind: literal("value"),
|
|
9871
|
-
value: json$
|
|
9872
|
-
jsonSchema: json$
|
|
10523
|
+
value: json$4.optional(),
|
|
10524
|
+
jsonSchema: json$4.optional()
|
|
9873
10525
|
}), object$1({
|
|
9874
10526
|
kind: literal("source"),
|
|
9875
10527
|
source
|
|
@@ -9880,7 +10532,7 @@ var condition = {
|
|
|
9880
10532
|
description: text$1.optional(),
|
|
9881
10533
|
output: text$1,
|
|
9882
10534
|
groups: array(object$1({ expressions: array(object$1({
|
|
9883
|
-
left: operand,
|
|
10535
|
+
left: operand$1,
|
|
9884
10536
|
operator: _enum([
|
|
9885
10537
|
"!=",
|
|
9886
10538
|
"<",
|
|
@@ -9903,7 +10555,7 @@ var condition = {
|
|
|
9903
10555
|
"notHasValue",
|
|
9904
10556
|
"startsWith"
|
|
9905
10557
|
]),
|
|
9906
|
-
right: operand.optional()
|
|
10558
|
+
right: operand$1.optional()
|
|
9907
10559
|
})) }))
|
|
9908
10560
|
}))
|
|
9909
10561
|
};
|
|
@@ -9916,7 +10568,7 @@ var webhookOptions = object$1({
|
|
|
9916
10568
|
allowedOrigins: strings.optional(),
|
|
9917
10569
|
noResponseBody: never().optional(),
|
|
9918
10570
|
responseData: text$1.optional(),
|
|
9919
|
-
responseHeaders: record(text$1, text$1).optional(),
|
|
10571
|
+
responseHeaders: record$3(text$1, text$1).optional(),
|
|
9920
10572
|
responseStatusCode: number().int().min(200).max(599).optional()
|
|
9921
10573
|
});
|
|
9922
10574
|
var webhook = {
|
|
@@ -9972,7 +10624,7 @@ var base = {
|
|
|
9972
10624
|
var node = union([
|
|
9973
10625
|
object$1({
|
|
9974
10626
|
...base,
|
|
9975
|
-
inputs: record(text$1, never()),
|
|
10627
|
+
inputs: record$3(text$1, never()),
|
|
9976
10628
|
kind: literal("condition"),
|
|
9977
10629
|
...condition
|
|
9978
10630
|
}),
|
|
@@ -9982,21 +10634,10 @@ var node = union([
|
|
|
9982
10634
|
kind: literal("value"),
|
|
9983
10635
|
values: array(input)
|
|
9984
10636
|
}),
|
|
9985
|
-
object$1({
|
|
9986
|
-
...base,
|
|
9987
|
-
kind: literal("subflow"),
|
|
9988
|
-
subflowId: text$1
|
|
9989
|
-
}),
|
|
9990
|
-
object$1({
|
|
9991
|
-
...base,
|
|
9992
|
-
kind: literal("task"),
|
|
9993
|
-
task: inline,
|
|
9994
|
-
additionalInputs: array(input).optional()
|
|
9995
|
-
}),
|
|
9996
10637
|
object$1({
|
|
9997
10638
|
...base,
|
|
9998
10639
|
kind: literal("task"),
|
|
9999
|
-
|
|
10640
|
+
task: union([inline, managed]),
|
|
10000
10641
|
additionalInputs: array(input).optional()
|
|
10001
10642
|
}),
|
|
10002
10643
|
strictObject({
|
|
@@ -10032,7 +10673,7 @@ var node = union([
|
|
|
10032
10673
|
...trigger$1,
|
|
10033
10674
|
kind: literal("poll"),
|
|
10034
10675
|
connectionId: text$1.min(1).optional(),
|
|
10035
|
-
config: record(text$1, fixedInput),
|
|
10676
|
+
config: record$3(text$1, fixedInput),
|
|
10036
10677
|
definition: object$1({
|
|
10037
10678
|
...definition,
|
|
10038
10679
|
type: literal("poll")
|
|
@@ -10043,7 +10684,7 @@ var node = union([
|
|
|
10043
10684
|
...trigger$1,
|
|
10044
10685
|
kind: literal("integration"),
|
|
10045
10686
|
connectionId: text$1.min(1).optional(),
|
|
10046
|
-
config: record(text$1, fixedInput),
|
|
10687
|
+
config: record$3(text$1, fixedInput),
|
|
10047
10688
|
definition: object$1({
|
|
10048
10689
|
...definition,
|
|
10049
10690
|
type: literal("integration"),
|
|
@@ -10051,10 +10692,25 @@ var node = union([
|
|
|
10051
10692
|
})
|
|
10052
10693
|
})
|
|
10053
10694
|
]);
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10695
|
+
/** Configuration schemas shared by the node authoring boundary. */
|
|
10696
|
+
var authoringDefinitionSchemas = {
|
|
10697
|
+
input,
|
|
10698
|
+
port,
|
|
10699
|
+
ports,
|
|
10700
|
+
condition: strictObject(condition),
|
|
10701
|
+
wait: strictObject(wait),
|
|
10702
|
+
webhook: strictObject(webhook),
|
|
10703
|
+
schedule: triggerScheduleSchema,
|
|
10704
|
+
capabilities: array(capability),
|
|
10705
|
+
connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
|
|
10706
|
+
openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
|
|
10707
|
+
decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
|
|
10708
|
+
llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
|
|
10709
|
+
agent: managedFields.shape.executor.options[4].omit({
|
|
10710
|
+
kind: true,
|
|
10711
|
+
notification: true
|
|
10712
|
+
}).strict()
|
|
10713
|
+
};
|
|
10058
10714
|
var edge = object$1({
|
|
10059
10715
|
source: text$1,
|
|
10060
10716
|
target: text$1,
|
|
@@ -10062,15 +10718,10 @@ var edge = object$1({
|
|
|
10062
10718
|
});
|
|
10063
10719
|
var at = {
|
|
10064
10720
|
nodeId: text$1,
|
|
10065
|
-
target:
|
|
10721
|
+
target: never().optional()
|
|
10066
10722
|
};
|
|
10067
|
-
var subflow = object$1({
|
|
10068
|
-
name: text$1,
|
|
10069
|
-
inputs: array(input),
|
|
10070
|
-
outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
|
|
10071
|
-
});
|
|
10072
10723
|
var graph = object$1({
|
|
10073
|
-
nodes: record(text$1, node),
|
|
10724
|
+
nodes: record$3(text$1, node),
|
|
10074
10725
|
edges: array(edge).default([])
|
|
10075
10726
|
});
|
|
10076
10727
|
var binding = object$1({
|
|
@@ -10082,24 +10733,35 @@ var module = object$1({
|
|
|
10082
10733
|
imports: strings,
|
|
10083
10734
|
source: text$1
|
|
10084
10735
|
});
|
|
10085
|
-
var document = object$1({
|
|
10086
|
-
bindings: record(text$1, binding),
|
|
10087
|
-
graph
|
|
10088
|
-
|
|
10089
|
-
tasks: record(text$1, managed)
|
|
10090
|
-
});
|
|
10736
|
+
var document = preprocess(rejectRetiredDefinitions, object$1({
|
|
10737
|
+
bindings: record$3(text$1, binding),
|
|
10738
|
+
graph
|
|
10739
|
+
}));
|
|
10091
10740
|
object$1({
|
|
10092
10741
|
modelVersion: union([
|
|
10093
10742
|
literal(2),
|
|
10094
10743
|
literal(4),
|
|
10095
|
-
literal(5)
|
|
10744
|
+
literal(5),
|
|
10745
|
+
literal(6)
|
|
10096
10746
|
]),
|
|
10097
10747
|
document,
|
|
10098
|
-
modules: record(text$1, module)
|
|
10748
|
+
modules: record$3(text$1, module)
|
|
10099
10749
|
}).extend({
|
|
10100
10750
|
kind: literal("open-flow-flow-revision"),
|
|
10101
10751
|
version: literal(1)
|
|
10102
10752
|
});
|
|
10753
|
+
function rejectRetiredDefinitions(value) {
|
|
10754
|
+
const candidate = record$2(value);
|
|
10755
|
+
if (candidate.tasks !== void 0 && (candidate.tasks === null || typeof candidate.tasks !== "object" || Array.isArray(candidate.tasks) || Object.keys(candidate.tasks).length > 0)) throw new TypeError("Independent Task definitions are no longer supported.");
|
|
10756
|
+
if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$2(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
|
|
10757
|
+
const subflows = candidate.subflows;
|
|
10758
|
+
if (subflows !== void 0 && (subflows === null || typeof subflows !== "object" || Array.isArray(subflows) || Object.keys(subflows).length > 0)) throw new TypeError("Subflows are no longer supported.");
|
|
10759
|
+
if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => record$2(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
|
|
10760
|
+
return value;
|
|
10761
|
+
}
|
|
10762
|
+
function record$2(value) {
|
|
10763
|
+
return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
10764
|
+
}
|
|
10103
10765
|
var shapes = {
|
|
10104
10766
|
"graph.trigger.sources.set": {
|
|
10105
10767
|
nodeId: text$1,
|
|
@@ -10117,17 +10779,22 @@ var shapes = {
|
|
|
10117
10779
|
value: text$1
|
|
10118
10780
|
},
|
|
10119
10781
|
"graph.edge.connect": {
|
|
10120
|
-
|
|
10121
|
-
|
|
10782
|
+
edge,
|
|
10783
|
+
target: never().optional()
|
|
10122
10784
|
},
|
|
10123
10785
|
"graph.edge.disconnect": {
|
|
10124
|
-
|
|
10125
|
-
|
|
10786
|
+
edge,
|
|
10787
|
+
target: never().optional()
|
|
10126
10788
|
},
|
|
10127
10789
|
"graph.node.create": {
|
|
10128
10790
|
...at,
|
|
10129
10791
|
node
|
|
10130
10792
|
},
|
|
10793
|
+
"graph.node.replace": {
|
|
10794
|
+
...at,
|
|
10795
|
+
before: node,
|
|
10796
|
+
node
|
|
10797
|
+
},
|
|
10131
10798
|
"graph.node.delete": at,
|
|
10132
10799
|
"graph.node.field.set": union([
|
|
10133
10800
|
object$1({
|
|
@@ -10186,13 +10853,11 @@ var shapes = {
|
|
|
10186
10853
|
},
|
|
10187
10854
|
"graph.node.resolution.set": {
|
|
10188
10855
|
...at,
|
|
10189
|
-
target: object$1({ kind: literal("flow") }),
|
|
10190
10856
|
before: object$1(wait),
|
|
10191
10857
|
value: object$1(wait)
|
|
10192
10858
|
},
|
|
10193
10859
|
"graph.node.webhook.set": {
|
|
10194
10860
|
...at,
|
|
10195
|
-
target: object$1({ kind: literal("flow") }),
|
|
10196
10861
|
before: object$1(webhook),
|
|
10197
10862
|
value: object$1(webhook)
|
|
10198
10863
|
},
|
|
@@ -10239,50 +10904,10 @@ var shapes = {
|
|
|
10239
10904
|
imports: strings,
|
|
10240
10905
|
source: text$1
|
|
10241
10906
|
},
|
|
10242
|
-
"
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
"subflow.definition.set": {
|
|
10247
|
-
subflowId: text$1,
|
|
10248
|
-
before: subflow,
|
|
10249
|
-
definition: subflow
|
|
10250
|
-
},
|
|
10251
|
-
"subflow.delete": { subflowId: text$1 },
|
|
10252
|
-
"task.create": {
|
|
10253
|
-
taskId: text$1,
|
|
10254
|
-
task: managed
|
|
10255
|
-
},
|
|
10256
|
-
"task.delete": { taskId: text$1 },
|
|
10257
|
-
"task.connector.connection.set": {
|
|
10258
|
-
taskId: text$1,
|
|
10259
|
-
before: text$1.optional(),
|
|
10260
|
-
value: text$1.optional()
|
|
10261
|
-
},
|
|
10262
|
-
"task.decision.set": {
|
|
10263
|
-
taskId: text$1,
|
|
10264
|
-
before: managed,
|
|
10265
|
-
value: managed
|
|
10266
|
-
},
|
|
10267
|
-
"task.openapi.set": {
|
|
10268
|
-
taskId: text$1,
|
|
10269
|
-
before: managed,
|
|
10270
|
-
value: managed
|
|
10271
|
-
},
|
|
10272
|
-
"task.agent.set": {
|
|
10273
|
-
taskId: text$1,
|
|
10274
|
-
before: managed,
|
|
10275
|
-
value: managed
|
|
10276
|
-
},
|
|
10277
|
-
"task.llm.mode.set": {
|
|
10278
|
-
taskId: text$1,
|
|
10279
|
-
before: _enum(["chat", "json"]),
|
|
10280
|
-
value: _enum(["chat", "json"])
|
|
10281
|
-
},
|
|
10282
|
-
"task.name.set": {
|
|
10283
|
-
taskId: text$1,
|
|
10284
|
-
before: text$1,
|
|
10285
|
-
value: text$1
|
|
10907
|
+
"graph.node.task.set": {
|
|
10908
|
+
...at,
|
|
10909
|
+
before: union([inline, managed]),
|
|
10910
|
+
value: union([inline, managed])
|
|
10286
10911
|
}
|
|
10287
10912
|
};
|
|
10288
10913
|
var variants = new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object$1({
|
|
@@ -10304,20 +10929,89 @@ function decodeChangeOperation(candidate, index) {
|
|
|
10304
10929
|
if (schema == null) throw new TypeError(`operations[${index}]: Unknown operation ${JSON.stringify(kind)}.`);
|
|
10305
10930
|
return parseOperation(candidate, index, schema.parse);
|
|
10306
10931
|
}
|
|
10932
|
+
function decodeChangeOperations(value) {
|
|
10933
|
+
checkJsonDepth(value);
|
|
10934
|
+
return array(unknown()).min(1).parse(value).map(decodeChangeOperation);
|
|
10935
|
+
}
|
|
10307
10936
|
function changeOperationsSchema(kind) {
|
|
10308
10937
|
const schema = kind == null ? operations : variants.get(kind);
|
|
10309
10938
|
if (schema == null) throw new TypeError(`Unknown operation ${JSON.stringify(kind)}.`);
|
|
10310
10939
|
return toJSONSchema(schema, { io: "input" });
|
|
10311
10940
|
}
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10941
|
+
//#endregion
|
|
10942
|
+
//#region src/control/common/authoringLlm.ts
|
|
10943
|
+
var authoringLlmConfiguration = strictObject({
|
|
10944
|
+
mode: _enum(["chat", "json"]),
|
|
10945
|
+
resultSchema: json$5(),
|
|
10946
|
+
model: json$5().optional().describe("Default model settings: {model, temperature?, top_p?, max_tokens?}. A bound model input takes precedence."),
|
|
10947
|
+
template: json$5().optional().describe("Default message templates: [{role: \"system\" | \"user\" | \"assistant\", content: \"Text with {{namedInput}}\"}]."),
|
|
10948
|
+
messages: json$5().optional().describe("Default conversation history, prepended without template interpolation; an array of {role, content} or null.")
|
|
10949
|
+
});
|
|
10950
|
+
var defaults = {
|
|
10951
|
+
model: "model",
|
|
10952
|
+
template: "template",
|
|
10953
|
+
messages: "messages"
|
|
10954
|
+
};
|
|
10955
|
+
/** Read defaults only. Node bindings remain independently visible and editable. */
|
|
10956
|
+
function llmConfigurationView(task) {
|
|
10957
|
+
if (task.executor.kind != "llm") throw new TypeError("Expected an LLM task.");
|
|
10958
|
+
const config = {
|
|
10959
|
+
mode: task.executor.mode,
|
|
10960
|
+
resultSchema: task.outputs.find((port) => "handle" in port)?.jsonSchema ?? {}
|
|
10961
|
+
};
|
|
10962
|
+
for (const [name, handle] of Object.entries(defaults)) {
|
|
10963
|
+
const port = task.inputs.find((candidate) => "handle" in candidate && candidate.handle == handle);
|
|
10964
|
+
if (port != null && Object.hasOwn(port, "value")) config[name] = port.value;
|
|
10319
10965
|
}
|
|
10320
|
-
|
|
10966
|
+
return config;
|
|
10967
|
+
}
|
|
10968
|
+
/** Update default values without altering port contracts, groups, or node bindings. */
|
|
10969
|
+
function prepareLlmConfiguration(config, previous, name) {
|
|
10970
|
+
if (previous.executor.kind != "llm") throw new TypeError("Expected an LLM task.");
|
|
10971
|
+
const old = llmConfigurationView(previous);
|
|
10972
|
+
const changed = Object.keys(defaults).filter((key) => Object.hasOwn(old, key) != Object.hasOwn(config, key) || !dequal(old[key], config[key]));
|
|
10973
|
+
const inputs = previous.inputs.map((port) => {
|
|
10974
|
+
if (!("handle" in port)) return port;
|
|
10975
|
+
const key = changed.find((candidate) => defaults[candidate] == port.handle);
|
|
10976
|
+
if (key == null) return port;
|
|
10977
|
+
const { value: _value, ...withoutDefault } = port;
|
|
10978
|
+
return Object.hasOwn(config, key) ? {
|
|
10979
|
+
...withoutDefault,
|
|
10980
|
+
value: config[key]
|
|
10981
|
+
} : withoutDefault;
|
|
10982
|
+
});
|
|
10983
|
+
return {
|
|
10984
|
+
...previous,
|
|
10985
|
+
name,
|
|
10986
|
+
executor: {
|
|
10987
|
+
...previous.executor,
|
|
10988
|
+
mode: config.mode
|
|
10989
|
+
},
|
|
10990
|
+
inputs,
|
|
10991
|
+
outputs: dequal(old.resultSchema, config.resultSchema) ? previous.outputs : previous.outputs.map((port) => "handle" in port ? {
|
|
10992
|
+
...port,
|
|
10993
|
+
jsonSchema: config.resultSchema
|
|
10994
|
+
} : port)
|
|
10995
|
+
};
|
|
10996
|
+
}
|
|
10997
|
+
/** Keep the production LLM factory's contracts while removing sample business data. */
|
|
10998
|
+
function initialAuthoringLlmTask(task) {
|
|
10999
|
+
if (task.executor.kind != "llm") throw new TypeError("Expected an LLM task.");
|
|
11000
|
+
return {
|
|
11001
|
+
...task,
|
|
11002
|
+
inputs: task.inputs.flatMap((port) => {
|
|
11003
|
+
if (!("handle" in port)) return [port];
|
|
11004
|
+
if (port.handle == "input") return [];
|
|
11005
|
+
if (port.handle == "template") return [{
|
|
11006
|
+
...port,
|
|
11007
|
+
value: [{
|
|
11008
|
+
role: "user",
|
|
11009
|
+
content: ""
|
|
11010
|
+
}]
|
|
11011
|
+
}];
|
|
11012
|
+
return [port];
|
|
11013
|
+
})
|
|
11014
|
+
};
|
|
10321
11015
|
}
|
|
10322
11016
|
//#endregion
|
|
10323
11017
|
//#region src/openapi/common/openapi.ts
|
|
@@ -10485,7 +11179,7 @@ function snapshot(documentValue, path, method) {
|
|
|
10485
11179
|
for (const entry of security) for (const name of Object.keys(object(entry))) copy(`#/components/securitySchemes/${name.replace(/~/g, "~0").replace(/\//g, "~1")}`);
|
|
10486
11180
|
return structuredClone(result);
|
|
10487
11181
|
}
|
|
10488
|
-
function schema
|
|
11182
|
+
function schema(doc, schemaValue) {
|
|
10489
11183
|
const defs = {};
|
|
10490
11184
|
const ids = /* @__PURE__ */ new Map();
|
|
10491
11185
|
function convert(value) {
|
|
@@ -10590,7 +11284,7 @@ function jsonContent(doc, value) {
|
|
|
10590
11284
|
const json = mediaType == null ? void 0 : media[mediaType];
|
|
10591
11285
|
if (json == null) throw new Error("Only JSON request and response bodies are supported.");
|
|
10592
11286
|
return {
|
|
10593
|
-
schema: schema
|
|
11287
|
+
schema: schema(doc, object(json).schema ?? {}),
|
|
10594
11288
|
required: content.required === true,
|
|
10595
11289
|
mediaType
|
|
10596
11290
|
};
|
|
@@ -10609,7 +11303,7 @@ function openApiTask(config, name = "OpenAPI") {
|
|
|
10609
11303
|
const { op } = operation(doc, config.path, config.method);
|
|
10610
11304
|
const params = parameters(config);
|
|
10611
11305
|
const inputs = params.map((p) => {
|
|
10612
|
-
const jsonSchema = schema
|
|
11306
|
+
const jsonSchema = schema(doc, p.schema ?? {});
|
|
10613
11307
|
const defaultValue = typeof jsonSchema == "boolean" ? void 0 : object(jsonSchema).default;
|
|
10614
11308
|
return {
|
|
10615
11309
|
handle: `${p.in}.${p.name}`,
|
|
@@ -10647,7 +11341,7 @@ function openApiTask(config, name = "OpenAPI") {
|
|
|
10647
11341
|
if (r.content == null) schemas.push({ type: "null" });
|
|
10648
11342
|
else {
|
|
10649
11343
|
jsonContent(doc, r);
|
|
10650
|
-
for (const [mediaType, media] of Object.entries(object(r.content))) if (/^application\/(json|.+\+json)$/.test(mediaType)) schemas.push(schema
|
|
11344
|
+
for (const [mediaType, media] of Object.entries(object(r.content))) if (/^application\/(json|.+\+json)$/.test(mediaType)) schemas.push(schema(doc, object(media).schema ?? {}));
|
|
10651
11345
|
}
|
|
10652
11346
|
}
|
|
10653
11347
|
if (!schemas.length) throw new Error("A successful JSON response definition is required.");
|
|
@@ -10702,943 +11396,845 @@ function selectOperation(value, sourceUrl, path, method) {
|
|
|
10702
11396
|
openApiTask(config);
|
|
10703
11397
|
return config;
|
|
10704
11398
|
}
|
|
10705
|
-
`${JSON.stringify("open-flow-engine/v5")}`, new Set([
|
|
10706
|
-
"assert",
|
|
10707
|
-
"assert/strict",
|
|
10708
|
-
"buffer",
|
|
10709
|
-
"console",
|
|
10710
|
-
"constants",
|
|
10711
|
-
"crypto",
|
|
10712
|
-
"events",
|
|
10713
|
-
"fs",
|
|
10714
|
-
"fs/promises",
|
|
10715
|
-
"os",
|
|
10716
|
-
"path",
|
|
10717
|
-
"path/posix",
|
|
10718
|
-
"process",
|
|
10719
|
-
"punycode",
|
|
10720
|
-
"querystring",
|
|
10721
|
-
"stream",
|
|
10722
|
-
"stream/promises",
|
|
10723
|
-
"stream/web",
|
|
10724
|
-
"string_decoder",
|
|
10725
|
-
"timers",
|
|
10726
|
-
"timers/promises",
|
|
10727
|
-
"url",
|
|
10728
|
-
"util",
|
|
10729
|
-
"zlib"
|
|
10730
|
-
].flatMap((name) => [name, `node:${name}`])), `${JSON.stringify("open-flow-engine/v5/nodejs-compat-v1")}`;
|
|
10731
|
-
//#endregion
|
|
10732
|
-
//#region src/flow/common/agent.ts
|
|
10733
|
-
var schema = lazy(() => union([boolean(), strictObject({
|
|
10734
|
-
type: union([_enum([
|
|
10735
|
-
"array",
|
|
10736
|
-
"boolean",
|
|
10737
|
-
"integer",
|
|
10738
|
-
"null",
|
|
10739
|
-
"number",
|
|
10740
|
-
"object",
|
|
10741
|
-
"string"
|
|
10742
|
-
]), array(_enum([
|
|
10743
|
-
"array",
|
|
10744
|
-
"boolean",
|
|
10745
|
-
"integer",
|
|
10746
|
-
"null",
|
|
10747
|
-
"number",
|
|
10748
|
-
"object",
|
|
10749
|
-
"string"
|
|
10750
|
-
])).min(1)]).optional(),
|
|
10751
|
-
const: json$3().optional(),
|
|
10752
|
-
allOf: array(schema).min(1).optional(),
|
|
10753
|
-
anyOf: array(schema).min(1).optional(),
|
|
10754
|
-
oneOf: array(schema).min(1).optional(),
|
|
10755
|
-
not: schema.optional(),
|
|
10756
|
-
if: schema.optional(),
|
|
10757
|
-
then: schema.optional(),
|
|
10758
|
-
else: schema.optional(),
|
|
10759
|
-
$ref: string().optional(),
|
|
10760
|
-
$schema: _enum([
|
|
10761
|
-
"http://json-schema.org/draft-07/schema#",
|
|
10762
|
-
"https://json-schema.org/draft-07/schema",
|
|
10763
|
-
"https://json-schema.org/draft/2019-09/schema",
|
|
10764
|
-
"https://json-schema.org/draft/2020-12/schema"
|
|
10765
|
-
]).optional(),
|
|
10766
|
-
$defs: record(string(), schema).optional(),
|
|
10767
|
-
definitions: record(string(), schema).optional(),
|
|
10768
|
-
pattern: string().refine((value) => {
|
|
10769
|
-
try {
|
|
10770
|
-
return new RegExp(value, "u").source.length > 0;
|
|
10771
|
-
} catch {
|
|
10772
|
-
return false;
|
|
10773
|
-
}
|
|
10774
|
-
}, "Invalid regular expression.").optional(),
|
|
10775
|
-
format: string().refine((value) => Object.hasOwn(format, value), "Unsupported string format.").optional(),
|
|
10776
|
-
multipleOf: number().positive().optional(),
|
|
10777
|
-
uniqueItems: boolean().optional(),
|
|
10778
|
-
contains: schema.optional(),
|
|
10779
|
-
minContains: number().int().nonnegative().optional(),
|
|
10780
|
-
maxContains: number().int().nonnegative().optional(),
|
|
10781
|
-
minProperties: number().int().nonnegative().optional(),
|
|
10782
|
-
maxProperties: number().int().nonnegative().optional(),
|
|
10783
|
-
propertyNames: schema.optional(),
|
|
10784
|
-
patternProperties: record(string().refine((value) => {
|
|
10785
|
-
try {
|
|
10786
|
-
return new RegExp(value, "u").source.length > 0;
|
|
10787
|
-
} catch {
|
|
10788
|
-
return false;
|
|
10789
|
-
}
|
|
10790
|
-
}, "Invalid regular expression."), schema).optional(),
|
|
10791
|
-
dependentRequired: record(string(), array(string())).optional(),
|
|
10792
|
-
dependentSchemas: record(string(), schema).optional(),
|
|
10793
|
-
dependencies: record(string(), union([schema, array(string())])).optional(),
|
|
10794
|
-
prefixItems: array(schema).optional(),
|
|
10795
|
-
additionalItems: schema.optional(),
|
|
10796
|
-
unevaluatedItems: schema.optional(),
|
|
10797
|
-
unevaluatedProperties: schema.optional(),
|
|
10798
|
-
description: string().optional(),
|
|
10799
|
-
title: string().optional(),
|
|
10800
|
-
default: json$3().optional(),
|
|
10801
|
-
examples: array(json$3()).optional(),
|
|
10802
|
-
readOnly: boolean().optional(),
|
|
10803
|
-
writeOnly: boolean().optional(),
|
|
10804
|
-
deprecated: boolean().optional(),
|
|
10805
|
-
$comment: string().optional(),
|
|
10806
|
-
enum: array(json$3()).min(1).optional(),
|
|
10807
|
-
properties: record(string(), schema).optional(),
|
|
10808
|
-
required: array(string()).optional(),
|
|
10809
|
-
additionalProperties: schema.optional(),
|
|
10810
|
-
items: union([schema, array(schema)]).optional(),
|
|
10811
|
-
minItems: number().int().nonnegative().optional(),
|
|
10812
|
-
maxItems: number().int().nonnegative().optional(),
|
|
10813
|
-
minLength: number().int().nonnegative().optional(),
|
|
10814
|
-
maxLength: number().int().nonnegative().optional(),
|
|
10815
|
-
minimum: number().optional(),
|
|
10816
|
-
maximum: number().optional(),
|
|
10817
|
-
exclusiveMinimum: number().optional(),
|
|
10818
|
-
exclusiveMaximum: number().optional()
|
|
10819
|
-
}).transform(({ title: _title, default: _default, examples: _examples, readOnly: _readOnly, writeOnly: _writeOnly, deprecated: _deprecated, $comment: _comment, ...value }) => value)]));
|
|
10820
|
-
new TextEncoder();
|
|
10821
11399
|
//#endregion
|
|
10822
|
-
//#region
|
|
10823
|
-
var
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
}
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
},
|
|
10849
|
-
ImportOutsideModule: {
|
|
10850
|
-
message: `'import' and 'export' may appear only with 'sourceType: "module"'`,
|
|
10851
|
-
code
|
|
10852
|
-
}
|
|
10853
|
-
};
|
|
10854
|
-
var NodeDescriptions = {
|
|
10855
|
-
ArrayPattern: "array destructuring pattern",
|
|
10856
|
-
AssignmentExpression: "assignment expression",
|
|
10857
|
-
AssignmentPattern: "assignment expression",
|
|
10858
|
-
ArrowFunctionExpression: "arrow function expression",
|
|
10859
|
-
ConditionalExpression: "conditional expression",
|
|
10860
|
-
CatchClause: "catch clause",
|
|
10861
|
-
ForOfStatement: "for-of statement",
|
|
10862
|
-
ForInStatement: "for-in statement",
|
|
10863
|
-
ForStatement: "for-loop",
|
|
10864
|
-
FormalParameters: "function parameter list",
|
|
10865
|
-
Identifier: "identifier",
|
|
10866
|
-
ImportSpecifier: "import specifier",
|
|
10867
|
-
ImportDefaultSpecifier: "import default specifier",
|
|
10868
|
-
ImportNamespaceSpecifier: "import namespace specifier",
|
|
10869
|
-
ObjectPattern: "object destructuring pattern",
|
|
10870
|
-
ParenthesizedExpression: "parenthesized expression",
|
|
10871
|
-
RestElement: "rest element",
|
|
10872
|
-
UpdateExpression: {
|
|
10873
|
-
true: "prefix operation",
|
|
10874
|
-
false: "postfix operation"
|
|
10875
|
-
},
|
|
10876
|
-
VariableDeclarator: "variable declaration",
|
|
10877
|
-
YieldExpression: "yield expression"
|
|
10878
|
-
};
|
|
10879
|
-
var toNodeDescription = (node) => node.type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[`${node.prefix}`] : NodeDescriptions[node.type];
|
|
10880
|
-
var StandardErrors = {
|
|
10881
|
-
AccessorIsGenerator: ({ kind }) => `A ${kind}ter cannot be a generator.`,
|
|
10882
|
-
ArgumentsInClass: "'arguments' is only allowed in functions and class methods.",
|
|
10883
|
-
AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.",
|
|
10884
|
-
AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.",
|
|
10885
|
-
AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.",
|
|
10886
|
-
AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.",
|
|
10887
|
-
AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.",
|
|
10888
|
-
AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.",
|
|
10889
|
-
BadGetterArity: "A 'get' accessor must not have any formal parameters.",
|
|
10890
|
-
BadSetterArity: "A 'set' accessor must have exactly one formal parameter.",
|
|
10891
|
-
BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.",
|
|
10892
|
-
ConstructorClassField: "Classes may not have a field named 'constructor'.",
|
|
10893
|
-
ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.",
|
|
10894
|
-
ConstructorIsAccessor: "Class constructor may not be an accessor.",
|
|
10895
|
-
ConstructorIsAsync: "Constructor can't be an async function.",
|
|
10896
|
-
ConstructorIsGenerator: "Constructor can't be a generator.",
|
|
10897
|
-
DeclarationMissingInitializer: ({ kind }) => `Missing initializer in ${kind} declaration.`,
|
|
10898
|
-
DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",
|
|
10899
|
-
DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",
|
|
10900
|
-
DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
|
|
10901
|
-
DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
|
|
10902
|
-
DecoratorStaticBlock: "Decorators can't be used with a static block.",
|
|
10903
|
-
DeferImportRequiresNamespace: "Only `import defer * as x from \"./module\"` is valid.",
|
|
10904
|
-
DeletePrivateField: "Deleting a private field is not allowed.",
|
|
10905
|
-
DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
|
|
10906
|
-
DuplicateConstructor: "Duplicate constructor in the same class.",
|
|
10907
|
-
DuplicateDefaultExport: "Only one default export allowed per module.",
|
|
10908
|
-
DuplicateExport: ({ exportName }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`,
|
|
10909
|
-
DuplicateProto: "Redefinition of __proto__ property.",
|
|
10910
|
-
DuplicateRegExpFlags: "Duplicate regular expression flag.",
|
|
10911
|
-
ElementAfterRest: "Rest element must be last element.",
|
|
10912
|
-
EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
|
|
10913
|
-
ExportBindingIsString: ({ localName, exportName }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
|
|
10914
|
-
ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
|
|
10915
|
-
ForInOfLoopInitializer: ({ type }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
|
|
10916
|
-
ForInUsing: "For-in loop may not start with 'using' declaration.",
|
|
10917
|
-
ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.",
|
|
10918
|
-
ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.",
|
|
10919
|
-
GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.",
|
|
10920
|
-
IllegalBreakContinue: ({ type }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`,
|
|
10921
|
-
IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.",
|
|
10922
|
-
IllegalReturn: "'return' outside of function.",
|
|
10923
|
-
ImportBindingIsString: ({ importName }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
|
|
10924
|
-
ImportCallArity: ({ phase }) => `\`import${phase ? `.${phase}` : ""}()\` requires exactly one or two arguments.`,
|
|
10925
|
-
ImportCallNotNewExpression: ({ phase }) => `Cannot use new with import${phase ? `.${phase}` : ""}().`,
|
|
10926
|
-
ImportCallSpreadArgument: ({ phase }) => `\`...\` is not allowed in \`import${phase ? `.${phase}` : ""}()\`.`,
|
|
10927
|
-
IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
|
|
10928
|
-
InvalidBigIntLiteral: "Invalid BigIntLiteral.",
|
|
10929
|
-
InvalidCodePoint: "Code point out of bounds.",
|
|
10930
|
-
InvalidCoverDiscardElement: "'void' must be followed by an expression when not used in a binding position.",
|
|
10931
|
-
InvalidCoverInitializedName: "Invalid shorthand property initializer.",
|
|
10932
|
-
InvalidDigit: ({ radix }) => `Expected number in radix ${radix}.`,
|
|
10933
|
-
InvalidEscapeSequence: "Bad character escape sequence.",
|
|
10934
|
-
InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.",
|
|
10935
|
-
InvalidEscapedReservedWord: ({ reservedWord }) => `Escape sequence in keyword ${reservedWord}.`,
|
|
10936
|
-
InvalidIdentifier: ({ identifierName }) => `Invalid identifier ${identifierName}.`,
|
|
10937
|
-
InvalidLhs: ({ ancestor }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`,
|
|
10938
|
-
InvalidLhsBinding: ({ ancestor }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`,
|
|
10939
|
-
InvalidLhsOptionalChaining: ({ ancestor }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
|
|
10940
|
-
InvalidNumber: "Invalid number.",
|
|
10941
|
-
InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
|
|
10942
|
-
InvalidOrUnexpectedToken: ({ unexpected }) => `Unexpected character '${unexpected}'.`,
|
|
10943
|
-
InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.",
|
|
10944
|
-
InvalidPrivateFieldResolution: ({ identifierName }) => `Private name #${identifierName} is not defined.`,
|
|
10945
|
-
InvalidPropertyBindingPattern: "Binding member expression.",
|
|
10946
|
-
InvalidRestAssignmentPattern: "Invalid rest operator's argument.",
|
|
10947
|
-
LabelRedeclaration: ({ labelName }) => `Label '${labelName}' is already declared.`,
|
|
10948
|
-
LetInLexicalBinding: "'let' is disallowed as a lexically bound name.",
|
|
10949
|
-
LineTerminatorBeforeArrow: "No line break is allowed before '=>'.",
|
|
10950
|
-
MalformedRegExpFlags: "Invalid regular expression flag.",
|
|
10951
|
-
MissingClassName: "A class name is required.",
|
|
10952
|
-
MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
|
|
10953
|
-
MissingSemicolon: "Missing semicolon.",
|
|
10954
|
-
MissingPlugin: ({ missingPlugin }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map((name) => JSON.stringify(name)).join(", ")}.`,
|
|
10955
|
-
MissingOneOfPlugins: ({ missingPlugin }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map((name) => JSON.stringify(name)).join(", ")}.`,
|
|
10956
|
-
MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.",
|
|
10957
|
-
MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.",
|
|
10958
|
-
ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.",
|
|
10959
|
-
ModuleAttributesWithDuplicateKeys: ({ key }) => `Duplicate key "${key}" is not allowed in module attributes.`,
|
|
10960
|
-
ModuleExportNameHasLoneSurrogate: ({ surrogateCharCode }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`,
|
|
10961
|
-
ModuleExportUndefined: ({ localName }) => `Export '${localName}' is not defined.`,
|
|
10962
|
-
MultipleDefaultsInSwitch: "Multiple default clauses.",
|
|
10963
|
-
NewlineAfterThrow: "Illegal newline after throw.",
|
|
10964
|
-
NoCatchOrFinally: "Missing catch or finally clause.",
|
|
10965
|
-
NumberIdentifier: "Identifier directly after number.",
|
|
10966
|
-
NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",
|
|
10967
|
-
ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.",
|
|
10968
|
-
OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.",
|
|
10969
|
-
OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.",
|
|
10970
|
-
OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.",
|
|
10971
|
-
ParamDupe: "Argument name clash.",
|
|
10972
|
-
PatternHasAccessor: "Object pattern can't contain getter or setter.",
|
|
10973
|
-
PatternHasMethod: "Object pattern can't contain methods.",
|
|
10974
|
-
PrivateInExpectedIn: ({ identifierName }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`,
|
|
10975
|
-
PrivateNameRedeclaration: ({ identifierName }) => `Duplicate private name #${identifierName}.`,
|
|
10976
|
-
RestTrailingComma: "Unexpected trailing comma after rest element.",
|
|
10977
|
-
SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.",
|
|
10978
|
-
SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",
|
|
10979
|
-
SourcePhaseImportRequiresDefault: "Only `import source x from \"./module\"` is valid.",
|
|
10980
|
-
StaticPrototype: "Classes may not have static property named prototype.",
|
|
10981
|
-
SuperCallNotNewExpression: "Cannot use new with super(...).",
|
|
10982
|
-
SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
|
|
10983
|
-
SuperPrivateField: "Private fields can't be accessed on super.",
|
|
10984
|
-
TrailingDecorator: "Decorators must be attached to a class element.",
|
|
10985
|
-
UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.",
|
|
10986
|
-
UnexpectedDigitAfterHash: "Unexpected digit after hash token.",
|
|
10987
|
-
UnexpectedImportExport: "'import' and 'export' may only appear at the top level.",
|
|
10988
|
-
UnexpectedKeyword: ({ keyword }) => `Unexpected keyword '${keyword}'.`,
|
|
10989
|
-
UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.",
|
|
10990
|
-
UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.",
|
|
10991
|
-
UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.",
|
|
10992
|
-
UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.",
|
|
10993
|
-
UnexpectedPrivateField: "Unexpected private name.",
|
|
10994
|
-
UnexpectedReservedWord: ({ reservedWord }) => `Unexpected reserved word '${reservedWord}'.`,
|
|
10995
|
-
UnexpectedSuper: "'super' is only allowed in object methods and classes.",
|
|
10996
|
-
UnexpectedToken: ({ expected, unexpected }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`,
|
|
10997
|
-
UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
|
|
10998
|
-
UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",
|
|
10999
|
-
UnexpectedVoidPattern: "Unexpected void binding.",
|
|
11000
|
-
UnsupportedDecoratorExport: "A decorated export must export a class declaration.",
|
|
11001
|
-
UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
|
|
11002
|
-
UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.",
|
|
11003
|
-
UnsupportedMetaProperty: ({ target, onlyValidPropertyName }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`,
|
|
11004
|
-
UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.",
|
|
11005
|
-
UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.",
|
|
11006
|
-
UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",
|
|
11007
|
-
UnterminatedComment: "Unterminated comment.",
|
|
11008
|
-
UnterminatedRegExp: "Unterminated regular expression.",
|
|
11009
|
-
UnterminatedString: "Unterminated string constant.",
|
|
11010
|
-
UnterminatedTemplate: "Unterminated template.",
|
|
11011
|
-
UsingDeclarationExport: "Using declaration cannot be exported.",
|
|
11012
|
-
UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.",
|
|
11013
|
-
VarRedeclaration: ({ identifierName }) => `Identifier '${identifierName}' has already been declared.`,
|
|
11014
|
-
VoidPatternCatchClauseParam: "A void binding can not be the catch clause parameter. Use `try { ... } catch { ... }` if you want to discard the caught error.",
|
|
11015
|
-
VoidPatternInitializer: "A void binding may not have an initializer.",
|
|
11016
|
-
YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.",
|
|
11017
|
-
YieldInParameter: "Yield expression is not allowed in formal parameters.",
|
|
11018
|
-
YieldNotInGeneratorFunction: "'yield' is only allowed within generator functions.",
|
|
11019
|
-
ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0."
|
|
11020
|
-
};
|
|
11021
|
-
var StrictModeErrors = {
|
|
11022
|
-
StrictDelete: "Deleting local variable in strict mode.",
|
|
11023
|
-
StrictEvalArguments: ({ referenceName }) => `Assigning to '${referenceName}' in strict mode.`,
|
|
11024
|
-
StrictEvalArgumentsBinding: ({ bindingName }) => `Binding '${bindingName}' in strict mode.`,
|
|
11025
|
-
StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.",
|
|
11026
|
-
StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.",
|
|
11027
|
-
StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.",
|
|
11028
|
-
StrictWith: "'with' in strict mode."
|
|
11029
|
-
};
|
|
11030
|
-
var ParseExpressionErrors = {
|
|
11031
|
-
ParseExpressionEmptyInput: "Unexpected parseExpression() input: The input is empty or contains only comments.",
|
|
11032
|
-
ParseExpressionExpectsEOF: ({ unexpected }) => `Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`${String.fromCodePoint(unexpected)}\`.`
|
|
11033
|
-
};
|
|
11034
|
-
var PipelineOperatorErrors = {
|
|
11035
|
-
PipeTopicRequiresHackPipes: "Topic references are only supported when using the `\"proposal\": \"hack\"` version of the pipeline proposal.",
|
|
11036
|
-
PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
|
|
11037
|
-
PipeTopicUnconfiguredToken: ({ token }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`,
|
|
11038
|
-
PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",
|
|
11039
|
-
PipeUnparenthesizedBody: ({ type }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({ type })}; please wrap it in parentheses.`,
|
|
11040
|
-
PipelineUnparenthesized: "Cannot mix binary operator with solo-await F#-style pipeline. Please wrap the pipeline in parentheses."
|
|
11041
|
-
};
|
|
11042
|
-
var FunctionBindErrors = {
|
|
11043
|
-
UnsupportedBind: "Binding should be performed on object property.",
|
|
11044
|
-
UnsupportedBindRHS: "The right-hand side of binding can not be super or import."
|
|
11045
|
-
};
|
|
11046
|
-
function defineHidden(obj, key, value) {
|
|
11047
|
-
Object.defineProperty(obj, key, {
|
|
11048
|
-
enumerable: false,
|
|
11049
|
-
configurable: true,
|
|
11050
|
-
value
|
|
11051
|
-
});
|
|
11400
|
+
//#region src/control/common/authoringOpenApi.ts
|
|
11401
|
+
var authenticationSchema = union([
|
|
11402
|
+
strictObject({ schemes: array(string().min(1)).describe("One complete security alternative advertised by this operation; [] selects no authentication.") }),
|
|
11403
|
+
strictObject({ type: _enum(["bearer", "basic"]) }),
|
|
11404
|
+
strictObject({
|
|
11405
|
+
type: literal("apiKey"),
|
|
11406
|
+
name: string().min(1),
|
|
11407
|
+
in: _enum(["header", "query"])
|
|
11408
|
+
})
|
|
11409
|
+
]);
|
|
11410
|
+
var authoringOpenApiSchema = strictObject({
|
|
11411
|
+
sourceUrl: string().min(1),
|
|
11412
|
+
path: string().min(1),
|
|
11413
|
+
method: string().min(1),
|
|
11414
|
+
serverUrl: string().optional(),
|
|
11415
|
+
authentication: authenticationSchema.optional().describe("Omit to use the operation default. Bind credentials through the advertised node inputs.")
|
|
11416
|
+
});
|
|
11417
|
+
function openApiAuthenticationChoices(config) {
|
|
11418
|
+
try {
|
|
11419
|
+
return securityOptions(config.document, config.path, config.method).map(({ label, auth, error }) => Object.assign({ label }, auth == null ? { error } : { authentication: { schemes: auth.map((item) => item.id) } }));
|
|
11420
|
+
} catch (error) {
|
|
11421
|
+
return [{
|
|
11422
|
+
label: "Saved operation",
|
|
11423
|
+
error: error.message
|
|
11424
|
+
}];
|
|
11425
|
+
}
|
|
11052
11426
|
}
|
|
11053
|
-
function
|
|
11054
|
-
const
|
|
11055
|
-
|
|
11056
|
-
const
|
|
11057
|
-
|
|
11058
|
-
error.reasonCode = reasonCode;
|
|
11059
|
-
error.loc = loc;
|
|
11060
|
-
error.pos = pos;
|
|
11061
|
-
error.syntaxPlugin = syntaxPlugin;
|
|
11062
|
-
if (hasMissingPlugin) error.missingPlugin = details.missingPlugin;
|
|
11063
|
-
defineHidden(error, "clone", function clone(overrides = {}) {
|
|
11064
|
-
const { line, column, index = pos } = overrides.loc ?? loc;
|
|
11065
|
-
return constructor(new Position(line, column), index, {
|
|
11066
|
-
...details,
|
|
11067
|
-
...overrides.details
|
|
11068
|
-
});
|
|
11069
|
-
});
|
|
11070
|
-
defineHidden(error, "details", details);
|
|
11071
|
-
Object.defineProperty(error, "message", {
|
|
11072
|
-
configurable: true,
|
|
11073
|
-
get() {
|
|
11074
|
-
const message = `${toMessage(details)} (${loc.line}:${loc.column})`;
|
|
11075
|
-
this.message = message;
|
|
11076
|
-
return message;
|
|
11077
|
-
},
|
|
11078
|
-
set(value) {
|
|
11079
|
-
Object.defineProperty(this, "message", {
|
|
11080
|
-
value,
|
|
11081
|
-
writable: true
|
|
11082
|
-
});
|
|
11083
|
-
}
|
|
11084
|
-
});
|
|
11085
|
-
return error;
|
|
11086
|
-
};
|
|
11087
|
-
}
|
|
11088
|
-
function ParseErrorEnum(argument, syntaxPlugin) {
|
|
11089
|
-
if (Array.isArray(argument)) return (parseErrorTemplates) => ParseErrorEnum(parseErrorTemplates, argument[0]);
|
|
11090
|
-
const ParseErrorConstructors = {};
|
|
11091
|
-
for (const reasonCode of Object.keys(argument)) {
|
|
11092
|
-
const template = argument[reasonCode];
|
|
11093
|
-
const { message, ...rest } = typeof template === "string" ? { message: () => template } : typeof template === "function" ? { message: template } : template;
|
|
11094
|
-
ParseErrorConstructors[reasonCode] = toParseErrorConstructor({
|
|
11095
|
-
code: "BABEL_PARSER_SYNTAX_ERROR",
|
|
11096
|
-
reasonCode,
|
|
11097
|
-
toMessage: typeof message === "string" ? () => message : message,
|
|
11098
|
-
...syntaxPlugin ? { syntaxPlugin } : {},
|
|
11099
|
-
...rest
|
|
11100
|
-
});
|
|
11427
|
+
function authenticationView(config) {
|
|
11428
|
+
const schemes = config.auth.map((item) => item.id);
|
|
11429
|
+
if (!openApiAuthenticationChoices(config).some((option) => "authentication" in option && dequal(option.authentication?.schemes, schemes)) && config.auth.length == 1) {
|
|
11430
|
+
const { id: _id, ...manual } = config.auth[0];
|
|
11431
|
+
return manual;
|
|
11101
11432
|
}
|
|
11102
|
-
return
|
|
11103
|
-
}
|
|
11104
|
-
({
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
}
|
|
11112
|
-
|
|
11113
|
-
var
|
|
11114
|
-
|
|
11115
|
-
|
|
11116
|
-
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
}
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
beforeExpr,
|
|
11217
|
-
startsExpr
|
|
11218
|
-
}),
|
|
11219
|
-
templateTail: createToken("...`", { startsExpr }),
|
|
11220
|
-
templateNonTail: createToken("...${", {
|
|
11221
|
-
beforeExpr,
|
|
11222
|
-
startsExpr
|
|
11223
|
-
}),
|
|
11224
|
-
at: createToken("@"),
|
|
11225
|
-
hash: createToken("#", { startsExpr }),
|
|
11226
|
-
interpreterDirective: createToken("#!..."),
|
|
11227
|
-
eq: createToken("=", {
|
|
11228
|
-
beforeExpr,
|
|
11229
|
-
isAssign
|
|
11230
|
-
}),
|
|
11231
|
-
assign: createToken("_=", {
|
|
11232
|
-
beforeExpr,
|
|
11233
|
-
isAssign
|
|
11234
|
-
}),
|
|
11235
|
-
slashAssign: createToken("_=", {
|
|
11236
|
-
beforeExpr,
|
|
11237
|
-
isAssign
|
|
11238
|
-
}),
|
|
11239
|
-
xorAssign: createToken("_=", {
|
|
11240
|
-
beforeExpr,
|
|
11241
|
-
isAssign
|
|
11433
|
+
return { schemes };
|
|
11434
|
+
}
|
|
11435
|
+
function openApiConfigView(config) {
|
|
11436
|
+
return {
|
|
11437
|
+
sourceUrl: config.sourceUrl,
|
|
11438
|
+
path: config.path,
|
|
11439
|
+
method: config.method,
|
|
11440
|
+
serverUrl: config.serverUrl,
|
|
11441
|
+
authentication: authenticationView(config)
|
|
11442
|
+
};
|
|
11443
|
+
}
|
|
11444
|
+
var AuthoringOpenApiAuthenticationError = class extends Error {
|
|
11445
|
+
constructor(config) {
|
|
11446
|
+
super("Choose one complete authentication alternative advertised by this operation, or configure manual authentication.");
|
|
11447
|
+
this.code = "openapi.authentication-invalid";
|
|
11448
|
+
this.name = "AuthoringOpenApiAuthenticationError";
|
|
11449
|
+
this.details = {
|
|
11450
|
+
field: "config.authentication",
|
|
11451
|
+
choices: openApiAuthenticationChoices(config)
|
|
11452
|
+
};
|
|
11453
|
+
}
|
|
11454
|
+
};
|
|
11455
|
+
function prepareAuthentication(config, choice) {
|
|
11456
|
+
if (!("schemes" in choice)) return [{
|
|
11457
|
+
id: "manual",
|
|
11458
|
+
...choice
|
|
11459
|
+
}];
|
|
11460
|
+
const names = new Set(choice.schemes);
|
|
11461
|
+
const matched = securityOptions(config.document, config.path, config.method).find((option) => option.auth != null && names.size == choice.schemes.length && option.auth.length == names.size && option.auth.every((auth) => names.has(auth.id)));
|
|
11462
|
+
if (matched?.auth == null) throw new AuthoringOpenApiAuthenticationError(config);
|
|
11463
|
+
return matched.auth;
|
|
11464
|
+
}
|
|
11465
|
+
/** Operation snapshots and credential handles remain stable until their business selection changes. */
|
|
11466
|
+
async function prepareOpenApiTask(config, previous, fetch, name, explicit = {}) {
|
|
11467
|
+
const current = previous?.executor.kind == "openapi" ? previous.executor : void 0;
|
|
11468
|
+
const changed = current == null || config.sourceUrl != current.sourceUrl || config.path != current.path || config.method != current.method;
|
|
11469
|
+
const authentication = changed && current != null && !explicit.authentication ? void 0 : config.authentication;
|
|
11470
|
+
let selected;
|
|
11471
|
+
if (!changed) selected = current;
|
|
11472
|
+
else {
|
|
11473
|
+
const document = await fetch(config.sourceUrl);
|
|
11474
|
+
if (authentication != null && !("schemes" in authentication)) {
|
|
11475
|
+
const saved = snapshot(document, config.path, config.method);
|
|
11476
|
+
selected = {
|
|
11477
|
+
kind: "openapi",
|
|
11478
|
+
sourceUrl: httpUrl(config.sourceUrl),
|
|
11479
|
+
path: config.path,
|
|
11480
|
+
method: config.method,
|
|
11481
|
+
serverUrl: serverAddress(servers(saved, config.path, config.method)[0], config.sourceUrl),
|
|
11482
|
+
document: saved,
|
|
11483
|
+
auth: []
|
|
11484
|
+
};
|
|
11485
|
+
} else selected = selectOperation(document, config.sourceUrl, config.path, config.method);
|
|
11486
|
+
}
|
|
11487
|
+
const defaultAuth = () => {
|
|
11488
|
+
const defaultSelection = securityOptions(current.document, current.path, current.method).find((option) => option.auth != null)?.auth;
|
|
11489
|
+
if (defaultSelection == null) throw new AuthoringOpenApiAuthenticationError(current);
|
|
11490
|
+
return defaultSelection;
|
|
11491
|
+
};
|
|
11492
|
+
const auth = authentication == null ? !changed && explicit.authentication ? defaultAuth() : selected.auth : !changed && dequal(authentication, authenticationView(current)) ? current.auth : prepareAuthentication(selected, authentication);
|
|
11493
|
+
const serverUrl = !changed && explicit.serverUrl && config.serverUrl == null ? serverAddress(servers(current.document, current.path, current.method)[0], current.sourceUrl) : changed && current != null && !explicit.serverUrl ? selected.serverUrl : config.serverUrl ?? selected.serverUrl;
|
|
11494
|
+
const executor = {
|
|
11495
|
+
...selected,
|
|
11496
|
+
auth,
|
|
11497
|
+
serverUrl
|
|
11498
|
+
};
|
|
11499
|
+
if (previous != null && !changed && dequal(auth, current.auth)) return {
|
|
11500
|
+
...previous,
|
|
11501
|
+
name,
|
|
11502
|
+
executor
|
|
11503
|
+
};
|
|
11504
|
+
return openApiTask(executor, name);
|
|
11505
|
+
}
|
|
11506
|
+
//#endregion
|
|
11507
|
+
//#region src/control/common/authoringSchema.ts
|
|
11508
|
+
var id$2 = string().min(1);
|
|
11509
|
+
var json$3 = json$5();
|
|
11510
|
+
var patch = record$3(id$2, json$3);
|
|
11511
|
+
var authoringTypes = [
|
|
11512
|
+
"manual",
|
|
11513
|
+
"webhook",
|
|
11514
|
+
"cron",
|
|
11515
|
+
"error",
|
|
11516
|
+
"poll",
|
|
11517
|
+
"integration",
|
|
11518
|
+
"code",
|
|
11519
|
+
"connector",
|
|
11520
|
+
"agent",
|
|
11521
|
+
"llm",
|
|
11522
|
+
"decision",
|
|
11523
|
+
"openapi",
|
|
11524
|
+
"condition",
|
|
11525
|
+
"value",
|
|
11526
|
+
"wait",
|
|
11527
|
+
"approval"
|
|
11528
|
+
];
|
|
11529
|
+
var type = _enum(authoringTypes);
|
|
11530
|
+
var referenceSchema = id$2.describe("An existing node reference returned by read/search, or $alias for a preceding node.add in this edit batch. For node.add.as \"step\", reference \"$step\", never bare \"step\". Aliases are local to one batch.");
|
|
11531
|
+
var output = strictObject({
|
|
11532
|
+
kind: literal("output"),
|
|
11533
|
+
node: referenceSchema,
|
|
11534
|
+
port: id$2.optional().describe("Omit for a node with one output. For multiple outputs, choose a name from node details."),
|
|
11535
|
+
field: string().optional()
|
|
11536
|
+
});
|
|
11537
|
+
var variable = strictObject({
|
|
11538
|
+
kind: literal("variable"),
|
|
11539
|
+
name: id$2
|
|
11540
|
+
});
|
|
11541
|
+
var authoringSourceSchema = union([
|
|
11542
|
+
output,
|
|
11543
|
+
variable,
|
|
11544
|
+
strictObject({
|
|
11545
|
+
kind: literal("value"),
|
|
11546
|
+
value: json$3
|
|
11242
11547
|
}),
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11548
|
+
strictObject({ kind: literal("unset") }),
|
|
11549
|
+
strictObject({ kind: literal("default") }),
|
|
11550
|
+
strictObject({
|
|
11551
|
+
kind: literal("sources"),
|
|
11552
|
+
sources: array(union([output, variable])).min(1)
|
|
11553
|
+
})
|
|
11554
|
+
]);
|
|
11555
|
+
var operand = union([
|
|
11556
|
+
strictObject({
|
|
11557
|
+
kind: literal("value"),
|
|
11558
|
+
value: json$3.optional(),
|
|
11559
|
+
schema: json$3.optional()
|
|
11246
11560
|
}),
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11561
|
+
output,
|
|
11562
|
+
variable
|
|
11563
|
+
]);
|
|
11564
|
+
var agentTool = authoringDefinitionSchemas.agent.shape.tools.element.omit({
|
|
11565
|
+
id: true,
|
|
11566
|
+
inputs: true
|
|
11567
|
+
}).extend({ inputs: record$3(id$2, authoringDefinitionSchemas.agent.shape.tools.element.shape.inputs.element.shape.source).optional().describe("Action input sources by name. The tool resolves types from the Action. New inputs default to model-provided; existing sources are preserved when omitted.") }).strict();
|
|
11568
|
+
var notification = strictObject({
|
|
11569
|
+
...authoringDefinitionSchemas.connector.shape,
|
|
11570
|
+
messageHandle: id$2,
|
|
11571
|
+
inputs: record$3(id$2, union([strictObject({
|
|
11572
|
+
kind: literal("value"),
|
|
11573
|
+
value: json$3
|
|
11574
|
+
}), strictObject({
|
|
11575
|
+
kind: literal("input"),
|
|
11576
|
+
input: id$2
|
|
11577
|
+
})]))
|
|
11578
|
+
});
|
|
11579
|
+
var field = strictObject({
|
|
11580
|
+
schema: json$3.optional(),
|
|
11581
|
+
nullable: boolean().optional(),
|
|
11582
|
+
description: string().optional()
|
|
11583
|
+
});
|
|
11584
|
+
var inputFields = record$3(id$2, field.extend({ default: json$3.optional() })).describe("Optional business input constraints by name. A binding to a new Code, Agent, LLM, Wait or Approval input automatically declares an input accepting any JSON. Existing constraints are preserved. Omitted schema accepts any JSON; omitted nullable is true. Use default for inherited values; input.set supplies data.");
|
|
11585
|
+
var outputFields = record$3(id$2, field).describe("Code return fields by name. Omitted schema accepts any JSON; omitted nullable is true.");
|
|
11586
|
+
var expression = strictObject({
|
|
11587
|
+
left: operand,
|
|
11588
|
+
operator: authoringDefinitionSchemas.condition.shape.cases.element.shape.groups.element.shape.expressions.element.shape.operator,
|
|
11589
|
+
right: operand.optional()
|
|
11590
|
+
});
|
|
11591
|
+
var all = strictObject({ all: array(expression) });
|
|
11592
|
+
var when = union([
|
|
11593
|
+
expression,
|
|
11594
|
+
all,
|
|
11595
|
+
strictObject({ any: array(union([expression, all])) })
|
|
11596
|
+
]);
|
|
11597
|
+
var authoringConfigurations = {
|
|
11598
|
+
manual: strictObject({}),
|
|
11599
|
+
error: strictObject({ sourceFlowIds: array(id$2).optional() }),
|
|
11600
|
+
webhook: authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(),
|
|
11601
|
+
cron: strictObject({ schedule: authoringDefinitionSchemas.schedule }),
|
|
11602
|
+
poll: strictObject({
|
|
11603
|
+
key: id$2,
|
|
11604
|
+
connectionId: id$2.optional(),
|
|
11605
|
+
schedule: authoringDefinitionSchemas.schedule
|
|
11251
11606
|
}),
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
startsExpr
|
|
11607
|
+
integration: strictObject({
|
|
11608
|
+
key: id$2,
|
|
11609
|
+
connectionId: id$2.optional()
|
|
11256
11610
|
}),
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11611
|
+
code: strictObject({
|
|
11612
|
+
inputs: inputFields,
|
|
11613
|
+
outputs: outputFields,
|
|
11614
|
+
capabilities: authoringDefinitionSchemas.capabilities.optional()
|
|
11261
11615
|
}),
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
startsExpr
|
|
11616
|
+
connector: authoringDefinitionSchemas.connector.strict(),
|
|
11617
|
+
openapi: authoringOpenApiSchema,
|
|
11618
|
+
agent: authoringDefinitionSchemas.agent.omit({
|
|
11619
|
+
prompt: true,
|
|
11620
|
+
tools: true
|
|
11621
|
+
}).extend({
|
|
11622
|
+
inputs: inputFields,
|
|
11623
|
+
resultSchema: json$3.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
|
|
11624
|
+
tools: array(agentTool),
|
|
11625
|
+
notification: notification.optional()
|
|
11626
|
+
}).strict(),
|
|
11627
|
+
llm: authoringLlmConfiguration.extend({ inputs: inputFields }),
|
|
11628
|
+
decision: authoringDefinitionSchemas.decision,
|
|
11629
|
+
condition: strictObject({
|
|
11630
|
+
match: _enum(["first", "all"]),
|
|
11631
|
+
branches: array(strictObject({
|
|
11632
|
+
name: id$2,
|
|
11633
|
+
description: string().optional(),
|
|
11634
|
+
when
|
|
11635
|
+
}))
|
|
11283
11636
|
}),
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11637
|
+
value: strictObject({
|
|
11638
|
+
values: patch,
|
|
11639
|
+
outputs: outputFields
|
|
11287
11640
|
}),
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11641
|
+
wait: strictObject({ inputs: inputFields }),
|
|
11642
|
+
approval: strictObject({ inputs: inputFields })
|
|
11643
|
+
};
|
|
11644
|
+
var updates = strictObject({
|
|
11645
|
+
name: id$2.optional(),
|
|
11646
|
+
description: string().optional(),
|
|
11647
|
+
icon: string().optional(),
|
|
11648
|
+
maxExecutions: int().positive().optional(),
|
|
11649
|
+
timeoutMs: number().nonnegative().optional(),
|
|
11650
|
+
config: patch.optional().describe("Recursively merge configuration; omitted fields remain unchanged and arrays replace as a whole. This includes schema objects: {} does not clear an existing schema. Use clear paths to remove fields, e.g. [\"config\",\"inputs\",\"amount\",\"schema\",\"type\"].")
|
|
11651
|
+
});
|
|
11652
|
+
var authoringEditSchema = discriminatedUnion("op", [
|
|
11653
|
+
strictObject({
|
|
11654
|
+
op: literal("node.add"),
|
|
11655
|
+
as: id$2.regex(/^[A-Za-z][\w-]*$/).describe("Unique batch-local alias without the $ prefix. Later edits must reference this new node as $alias; the bare alias is not its node ID."),
|
|
11656
|
+
type,
|
|
11657
|
+
name: id$2,
|
|
11658
|
+
config: patch.optional(),
|
|
11659
|
+
inputs: record$3(id$2, authoringSourceSchema).optional().describe("Input data sources, applied after creation, as input.set operations. Execution edges are separate."),
|
|
11660
|
+
code: string().optional(),
|
|
11661
|
+
prompt: string().optional()
|
|
11294
11662
|
}),
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11663
|
+
strictObject({
|
|
11664
|
+
op: literal("node.update"),
|
|
11665
|
+
node: referenceSchema,
|
|
11666
|
+
set: updates.optional(),
|
|
11667
|
+
clear: array(array(id$2).min(1)).optional()
|
|
11298
11668
|
}),
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11669
|
+
strictObject({
|
|
11670
|
+
op: literal("node.remove"),
|
|
11671
|
+
node: referenceSchema
|
|
11302
11672
|
}),
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
_default: createKeyword("default", { beforeExpr }),
|
|
11309
|
-
_else: createKeyword("else", { beforeExpr }),
|
|
11310
|
-
_finally: createKeyword("finally"),
|
|
11311
|
-
_function: createKeyword("function", { startsExpr }),
|
|
11312
|
-
_if: createKeyword("if"),
|
|
11313
|
-
_return: createKeyword("return", { beforeExpr }),
|
|
11314
|
-
_switch: createKeyword("switch"),
|
|
11315
|
-
_throw: createKeyword("throw", {
|
|
11316
|
-
beforeExpr,
|
|
11317
|
-
prefix,
|
|
11318
|
-
startsExpr
|
|
11673
|
+
strictObject({
|
|
11674
|
+
op: literal("input.set"),
|
|
11675
|
+
node: referenceSchema,
|
|
11676
|
+
input: id$2,
|
|
11677
|
+
source: authoringSourceSchema
|
|
11319
11678
|
}),
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
beforeExpr,
|
|
11326
|
-
startsExpr
|
|
11679
|
+
strictObject({
|
|
11680
|
+
op: _enum(["edge.connect", "edge.disconnect"]),
|
|
11681
|
+
source: referenceSchema,
|
|
11682
|
+
target: referenceSchema,
|
|
11683
|
+
branch: id$2.optional()
|
|
11327
11684
|
}),
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
_null: createKeyword("null", { startsExpr }),
|
|
11335
|
-
_true: createKeyword("true", { startsExpr }),
|
|
11336
|
-
_false: createKeyword("false", { startsExpr }),
|
|
11337
|
-
_typeof: createKeyword("typeof", {
|
|
11338
|
-
beforeExpr,
|
|
11339
|
-
prefix,
|
|
11340
|
-
startsExpr
|
|
11685
|
+
strictObject({
|
|
11686
|
+
op: literal("text.edit"),
|
|
11687
|
+
node: referenceSchema,
|
|
11688
|
+
field: _enum(["code", "prompt"]),
|
|
11689
|
+
oldText: id$2,
|
|
11690
|
+
newText: string()
|
|
11341
11691
|
}),
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11692
|
+
strictObject({
|
|
11693
|
+
op: literal("text.set"),
|
|
11694
|
+
node: referenceSchema,
|
|
11695
|
+
field: _enum(["code", "prompt"]),
|
|
11696
|
+
text: string()
|
|
11697
|
+
})
|
|
11698
|
+
]);
|
|
11699
|
+
var authoringRequestSchema = strictObject({
|
|
11700
|
+
baseRevision: id$2,
|
|
11701
|
+
requestId: id$2.max(256),
|
|
11702
|
+
edits: array(authoringEditSchema).min(1).max(1e3)
|
|
11703
|
+
});
|
|
11704
|
+
var authoringReadSchema = strictObject({
|
|
11705
|
+
revision: id$2.optional().describe("Fixed revision from a previous read; omit to read the current draft."),
|
|
11706
|
+
nodes: array(id$2).min(1).max(100).optional().describe("Node references to read in one batch. Mutually exclusive with text. Long texts return metadata."),
|
|
11707
|
+
text: strictObject({
|
|
11708
|
+
node: id$2,
|
|
11709
|
+
field: _enum(["code", "prompt"]),
|
|
11710
|
+
start: int().positive().default(1),
|
|
11711
|
+
lines: int().min(1).max(200).default(80)
|
|
11712
|
+
}).optional().describe("Read code or prompt by line (1-based). Mutually exclusive with nodes. Follow nextStart at the same revision until truncated is false.")
|
|
11713
|
+
}).refine((v) => v.nodes == null || v.text == null, "Choose nodes or text.").meta({
|
|
11714
|
+
not: { required: ["nodes", "text"] },
|
|
11715
|
+
description: "Omit nodes and text for an outline; provide nodes for details, or text for an excerpt."
|
|
11716
|
+
});
|
|
11717
|
+
var authoringCheckSchema = strictObject({ revisionId: id$2 });
|
|
11718
|
+
var authoringSearchSchema = strictObject({
|
|
11719
|
+
revision: id$2.optional(),
|
|
11720
|
+
query: id$2.max(1e3),
|
|
11721
|
+
type: type.optional(),
|
|
11722
|
+
offset: int().nonnegative().default(0),
|
|
11723
|
+
limit: int().min(1).max(100).default(20)
|
|
11724
|
+
});
|
|
11725
|
+
var authoringSchemaQuery = strictObject({
|
|
11726
|
+
type: type.optional(),
|
|
11727
|
+
action: id$2.optional()
|
|
11728
|
+
}).refine((v) => v.type == null || v.action == null, "Choose type or action.");
|
|
11729
|
+
var requestContracts = {
|
|
11730
|
+
read: {
|
|
11731
|
+
schema: authoringReadSchema,
|
|
11732
|
+
guidance: "Choose one mode: outline (omit nodes and text), node details (nodes), or text excerpt (text). nodes and text are mutually exclusive. Text defaults to 80 lines, at most 200 lines and 24000 characters. For the complete text, repeat at nextStart with the same revision until truncated is false.",
|
|
11733
|
+
examples: [
|
|
11734
|
+
{},
|
|
11735
|
+
{
|
|
11736
|
+
revision: "REVISION",
|
|
11737
|
+
nodes: ["NODE"]
|
|
11738
|
+
},
|
|
11739
|
+
{
|
|
11740
|
+
revision: "REVISION",
|
|
11741
|
+
text: {
|
|
11742
|
+
node: "NODE",
|
|
11743
|
+
field: "prompt",
|
|
11744
|
+
start: 1,
|
|
11745
|
+
lines: 80
|
|
11746
|
+
}
|
|
11747
|
+
}
|
|
11748
|
+
]
|
|
11749
|
+
},
|
|
11750
|
+
search: {
|
|
11751
|
+
schema: authoringSearchSchema,
|
|
11752
|
+
guidance: "Search names, configurations and text. Keep the returned revision when following nextOffset or reading a match.",
|
|
11753
|
+
examples: [{
|
|
11754
|
+
query: "Customer summary",
|
|
11755
|
+
type: "agent"
|
|
11756
|
+
}]
|
|
11757
|
+
},
|
|
11758
|
+
edit: {
|
|
11759
|
+
schema: authoringRequestSchema,
|
|
11760
|
+
guidance: "Use the observed revision as baseRevision and a stable requestId. Edits are ordered and atomic. node.add.as declares a batch-local alias without $. Every later reference to that new node must use $alias, including node, edge source/target and output source node fields; a bare alias is not the node ID. Use returned node references in later batches. Updates recursively merge objects (including schemas); {} preserves existing fields. Arrays replace as a whole. Remove fields with clear paths. Text replacement requires exactly one match. Read the target text first. A saved draft can have validation diagnostics.",
|
|
11761
|
+
examples: [{
|
|
11762
|
+
baseRevision: "REVISION",
|
|
11763
|
+
requestId: "CREATE_REQUEST",
|
|
11764
|
+
edits: [
|
|
11765
|
+
{
|
|
11766
|
+
op: "node.add",
|
|
11767
|
+
as: "start",
|
|
11768
|
+
type: "manual",
|
|
11769
|
+
name: "Start"
|
|
11770
|
+
},
|
|
11771
|
+
{
|
|
11772
|
+
op: "node.add",
|
|
11773
|
+
as: "step",
|
|
11774
|
+
type: "code",
|
|
11775
|
+
name: "Process",
|
|
11776
|
+
code: "export default ({value}) => ({result:value})"
|
|
11777
|
+
},
|
|
11778
|
+
{
|
|
11779
|
+
op: "edge.connect",
|
|
11780
|
+
source: "$start",
|
|
11781
|
+
target: "$step"
|
|
11782
|
+
},
|
|
11783
|
+
{
|
|
11784
|
+
op: "node.update",
|
|
11785
|
+
node: "$step",
|
|
11786
|
+
set: { description: "Created and connected in one atomic edit." }
|
|
11787
|
+
}
|
|
11788
|
+
]
|
|
11789
|
+
}, {
|
|
11790
|
+
baseRevision: "REVISION",
|
|
11791
|
+
requestId: "REQUEST",
|
|
11792
|
+
edits: [{
|
|
11793
|
+
op: "text.edit",
|
|
11794
|
+
node: "NODE",
|
|
11795
|
+
field: "prompt",
|
|
11796
|
+
oldText: "Original rule.",
|
|
11797
|
+
newText: "Updated rule."
|
|
11798
|
+
}]
|
|
11799
|
+
}]
|
|
11800
|
+
},
|
|
11801
|
+
check: {
|
|
11802
|
+
schema: authoringCheckSchema,
|
|
11803
|
+
guidance: "Check a fixed revision. In the CLI, pass this identity with --revision REVISION.",
|
|
11804
|
+
examples: [{ revisionId: "REVISION" }]
|
|
11805
|
+
}
|
|
11806
|
+
};
|
|
11807
|
+
/** Transport-independent discovery of the same requests the service validates. */
|
|
11808
|
+
function authoringRequestContract(name) {
|
|
11809
|
+
if (!Object.hasOwn(requestContracts, name)) return void 0;
|
|
11810
|
+
const contract = requestContracts[name];
|
|
11811
|
+
return {
|
|
11812
|
+
request: toJSONSchema(contract.schema, { io: "input" }),
|
|
11813
|
+
guidance: contract.guidance,
|
|
11814
|
+
examples: contract.examples
|
|
11815
|
+
};
|
|
11816
|
+
}
|
|
11817
|
+
function authoringSchema(kind) {
|
|
11818
|
+
return kind == null ? {
|
|
11819
|
+
types: authoringTypes,
|
|
11820
|
+
request: toJSONSchema(authoringRequestSchema),
|
|
11821
|
+
guidance: "Read a node type schema before creating or configuring it. Use $alias to reference a preceding node.add in the same batch. Read returns stable node references. Long code and prompt fields use text reads and edits. Changes use the observed baseRevision and a stable requestId."
|
|
11822
|
+
} : {
|
|
11823
|
+
type: kind,
|
|
11824
|
+
inputSources: ["poll", "integration"].includes(kind) ? [
|
|
11825
|
+
"value",
|
|
11826
|
+
"unset",
|
|
11827
|
+
"default"
|
|
11828
|
+
] : [
|
|
11829
|
+
"manual",
|
|
11830
|
+
"error",
|
|
11831
|
+
"cron",
|
|
11832
|
+
"webhook",
|
|
11833
|
+
"value",
|
|
11834
|
+
"condition"
|
|
11835
|
+
].includes(kind) ? [] : [
|
|
11836
|
+
"value",
|
|
11837
|
+
"unset",
|
|
11838
|
+
"default",
|
|
11839
|
+
"output",
|
|
11840
|
+
"variable",
|
|
11841
|
+
"sources"
|
|
11842
|
+
],
|
|
11843
|
+
extensibleInputs: [
|
|
11844
|
+
"code",
|
|
11845
|
+
"agent",
|
|
11846
|
+
"llm",
|
|
11847
|
+
"wait",
|
|
11848
|
+
"approval"
|
|
11849
|
+
].includes(kind),
|
|
11850
|
+
guidance: kind == "condition" ? "Edit branch operands through config.branches. A branch can test one expression, all expressions, or any alternatives. Unmatched execution uses branch otherwise." : ["poll", "integration"].includes(kind) ? "Configure static parameters with node.add.inputs or input.set. Definitions come from the selected Trigger key; execution output and variable sources are unavailable." : kind == "llm" ? "Configure model settings, message templates and history as defaults. Input bindings with the same names override these defaults; named business inputs can be bound directly. Template strings interpolate {{name}}." : kind == "openapi" ? "Select an operation; the tool resolves its ports and authentication. Read authenticationChoices from node details. authentication is replaced as a complete choice. Bind advertised credentials through inputs." : "Supply business configuration and input data. Fixed definitions are assembled by the tool. Existing constraints and defaults are preserved on partial updates.",
|
|
11851
|
+
example: {
|
|
11852
|
+
op: "node.add",
|
|
11853
|
+
as: "step",
|
|
11854
|
+
type: kind,
|
|
11855
|
+
name: "Step",
|
|
11856
|
+
...{
|
|
11857
|
+
connector: { config: {
|
|
11858
|
+
action: "<Action ID>",
|
|
11859
|
+
connectionId: "<Connection ID>"
|
|
11860
|
+
} },
|
|
11861
|
+
poll: { config: {
|
|
11862
|
+
key: "<Trigger key>",
|
|
11863
|
+
schedule: [{
|
|
11864
|
+
type: "every",
|
|
11865
|
+
unit: "minute",
|
|
11866
|
+
value: 5
|
|
11867
|
+
}]
|
|
11868
|
+
} },
|
|
11869
|
+
integration: { config: { key: "<Trigger key>" } },
|
|
11870
|
+
openapi: { config: {
|
|
11871
|
+
sourceUrl: "https://example.com/openapi.json",
|
|
11872
|
+
path: "/items",
|
|
11873
|
+
method: "get"
|
|
11874
|
+
} },
|
|
11875
|
+
code: {
|
|
11876
|
+
code: "export default ({value}) => ({result:value})",
|
|
11877
|
+
inputs: { value: {
|
|
11878
|
+
kind: "value",
|
|
11879
|
+
value: "Hello"
|
|
11880
|
+
} }
|
|
11881
|
+
},
|
|
11882
|
+
condition: { config: {
|
|
11883
|
+
match: "first",
|
|
11884
|
+
branches: [{
|
|
11885
|
+
name: "yes",
|
|
11886
|
+
when: {
|
|
11887
|
+
left: {
|
|
11888
|
+
kind: "value",
|
|
11889
|
+
value: 120
|
|
11890
|
+
},
|
|
11891
|
+
operator: ">",
|
|
11892
|
+
right: {
|
|
11893
|
+
kind: "value",
|
|
11894
|
+
value: 100
|
|
11895
|
+
}
|
|
11896
|
+
}
|
|
11897
|
+
}]
|
|
11898
|
+
} },
|
|
11899
|
+
value: { config: { values: {
|
|
11900
|
+
threshold: 100,
|
|
11901
|
+
region: "EU"
|
|
11902
|
+
} } },
|
|
11903
|
+
webhook: { config: {
|
|
11904
|
+
method: "POST",
|
|
11905
|
+
body: { orderId: {
|
|
11906
|
+
schema: { type: "string" },
|
|
11907
|
+
nullable: false
|
|
11908
|
+
} }
|
|
11909
|
+
} },
|
|
11910
|
+
wait: {
|
|
11911
|
+
prompt: "Continue processing this order?",
|
|
11912
|
+
inputs: { order: {
|
|
11913
|
+
kind: "value",
|
|
11914
|
+
value: { orderId: "A-1" }
|
|
11915
|
+
} }
|
|
11916
|
+
},
|
|
11917
|
+
approval: {
|
|
11918
|
+
prompt: "Approve this order?",
|
|
11919
|
+
inputs: { order: {
|
|
11920
|
+
kind: "value",
|
|
11921
|
+
value: { orderId: "A-1" }
|
|
11922
|
+
} }
|
|
11923
|
+
},
|
|
11924
|
+
llm: {
|
|
11925
|
+
config: {
|
|
11926
|
+
model: { model: "deepseek-v4-flash" },
|
|
11927
|
+
template: [{
|
|
11928
|
+
role: "user",
|
|
11929
|
+
content: "Summarize {{order}}."
|
|
11930
|
+
}]
|
|
11931
|
+
},
|
|
11932
|
+
inputs: { order: {
|
|
11933
|
+
kind: "value",
|
|
11934
|
+
value: {
|
|
11935
|
+
orderId: "A-1",
|
|
11936
|
+
total: 42
|
|
11937
|
+
}
|
|
11938
|
+
} }
|
|
11939
|
+
},
|
|
11940
|
+
agent: {
|
|
11941
|
+
config: { model: "deepseek-v4-flash" },
|
|
11942
|
+
inputs: { orders: {
|
|
11943
|
+
kind: "value",
|
|
11944
|
+
value: [{
|
|
11945
|
+
orderId: "A-1",
|
|
11946
|
+
total: 42
|
|
11947
|
+
}]
|
|
11948
|
+
} },
|
|
11949
|
+
prompt: "Summarize {{orders}}."
|
|
11950
|
+
}
|
|
11951
|
+
}[kind]
|
|
11952
|
+
},
|
|
11953
|
+
configuration: toJSONSchema(authoringConfigurations[kind].partial()),
|
|
11954
|
+
texts: kind == "code" ? ["code"] : [
|
|
11955
|
+
"agent",
|
|
11956
|
+
"wait",
|
|
11957
|
+
"approval"
|
|
11958
|
+
].includes(kind) ? ["prompt"] : []
|
|
11959
|
+
};
|
|
11960
|
+
}
|
|
11961
|
+
var authoringDiagnosticSchema = object$1({
|
|
11962
|
+
code: id$2,
|
|
11963
|
+
message: string(),
|
|
11964
|
+
nodes: array(id$2),
|
|
11965
|
+
field: string().optional(),
|
|
11966
|
+
line: number().optional(),
|
|
11967
|
+
column: number().optional()
|
|
11968
|
+
});
|
|
11969
|
+
var authoringCheckResponse = object$1({
|
|
11970
|
+
flowId: id$2,
|
|
11971
|
+
revisionId: id$2,
|
|
11972
|
+
valid: boolean(),
|
|
11973
|
+
diagnostics: array(authoringDiagnosticSchema),
|
|
11974
|
+
version: literal(1)
|
|
11975
|
+
});
|
|
11976
|
+
var authoringEditResponse = object$1({
|
|
11977
|
+
flowId: id$2,
|
|
11978
|
+
saved: literal(true),
|
|
11979
|
+
revision: id$2,
|
|
11980
|
+
nodes: record$3(id$2, id$2),
|
|
11981
|
+
changes: array(object$1({
|
|
11982
|
+
index: int(),
|
|
11983
|
+
op: id$2,
|
|
11984
|
+
node: id$2.optional()
|
|
11985
|
+
})),
|
|
11986
|
+
validation: object$1({
|
|
11987
|
+
status: _enum([
|
|
11988
|
+
"valid",
|
|
11989
|
+
"invalid",
|
|
11990
|
+
"unavailable"
|
|
11991
|
+
]),
|
|
11992
|
+
diagnostics: array(authoringDiagnosticSchema).optional()
|
|
11346
11993
|
}),
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11994
|
+
version: literal(1)
|
|
11995
|
+
});
|
|
11996
|
+
var authoringReadResponse = object$1({
|
|
11997
|
+
flowId: id$2,
|
|
11998
|
+
revision: id$2,
|
|
11999
|
+
data: object$1({
|
|
12000
|
+
nodes: array(record$3(string(), json$3)).optional(),
|
|
12001
|
+
edges: array(json$3).optional(),
|
|
12002
|
+
text: record$3(string(), json$3).optional()
|
|
11351
12003
|
}),
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
12004
|
+
version: literal(1)
|
|
12005
|
+
});
|
|
12006
|
+
var authoringSearchResponse = object$1({
|
|
12007
|
+
flowId: id$2,
|
|
12008
|
+
revision: id$2,
|
|
12009
|
+
data: object$1({
|
|
12010
|
+
matches: array(object$1({
|
|
12011
|
+
node: id$2,
|
|
12012
|
+
field: id$2,
|
|
12013
|
+
line: int().optional(),
|
|
12014
|
+
excerpt: string()
|
|
12015
|
+
})),
|
|
12016
|
+
total: int(),
|
|
12017
|
+
nextOffset: int().optional()
|
|
11355
12018
|
}),
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
}
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
}
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
"
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
"
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
"
|
|
11451
|
-
"
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
"
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
"
|
|
11466
|
-
"
|
|
11467
|
-
"
|
|
11468
|
-
"
|
|
11469
|
-
"
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
})
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
}
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
EmptyTypeParameters: "Type parameter list cannot be empty.",
|
|
11569
|
-
ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
|
|
11570
|
-
ExportAssignmentInTSNamespace: "An export assignment cannot be used in a namespace.",
|
|
11571
|
-
ExportInTSNamespace: "Export declarations are not permitted in a namespace.",
|
|
11572
|
-
ImportAliasHasImportType: "An import alias can not use 'import type'.",
|
|
11573
|
-
ImportInTSNamespace: "Import declarations in a namespace cannot reference a module.",
|
|
11574
|
-
IncompatibleModifiers: ({ modifiers }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`,
|
|
11575
|
-
IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.",
|
|
11576
|
-
IndexSignatureHasAccessibility: ({ modifier }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`,
|
|
11577
|
-
IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.",
|
|
11578
|
-
IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.",
|
|
11579
|
-
IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.",
|
|
11580
|
-
InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.",
|
|
11581
|
-
InlineModuleDeclarationMustUseString: "`module ... {}` declarations must have a string name. Use `namespace ... {}` instead.",
|
|
11582
|
-
InvalidHeritageClauseType: ({ token }) => `'${token}' list can only include identifiers or qualified-names with optional type arguments.`,
|
|
11583
|
-
InvalidModifierOnAwaitUsingDeclaration: (modifier) => `'${modifier}' modifier cannot appear on an await using declaration.`,
|
|
11584
|
-
InvalidModifierOnTypeMember: ({ modifier }) => `'${modifier}' modifier cannot appear on a type member.`,
|
|
11585
|
-
InvalidModifierOnTypeParameter: ({ modifier }) => `'${modifier}' modifier cannot appear on a type parameter.`,
|
|
11586
|
-
InvalidModifierOnTypeParameterPositions: ({ modifier }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`,
|
|
11587
|
-
InvalidModifierOnUsingDeclaration: (modifier) => `'${modifier}' modifier cannot appear on a using declaration.`,
|
|
11588
|
-
InvalidModifiersOrder: ({ orderedModifiers }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`,
|
|
11589
|
-
InvalidNamespaceName: (value) => `Namespace name cannot be '${value}'.`,
|
|
11590
|
-
InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",
|
|
11591
|
-
InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
|
|
11592
|
-
MissingInterfaceName: "'interface' declarations must be followed by an identifier.",
|
|
11593
|
-
NamespaceExportInTSNamespace: "Global module exports may only appear at top level.",
|
|
11594
|
-
NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
|
|
11595
|
-
NonClassMethodPropertyHasAbstractModifier: "'abstract' modifier can only appear on a class, method, or property declaration.",
|
|
11596
|
-
OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
|
|
11597
|
-
OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.",
|
|
11598
|
-
PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
|
|
11599
|
-
PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
|
|
11600
|
-
PrivateElementHasAccessibility: ({ modifier }) => `Private elements cannot have an accessibility modifier ('${modifier}').`,
|
|
11601
|
-
ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
|
|
11602
|
-
ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",
|
|
11603
|
-
ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",
|
|
11604
|
-
SetAccessorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.",
|
|
11605
|
-
SetAccessorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.",
|
|
11606
|
-
SetAccessorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.",
|
|
11607
|
-
SingleTypeParameterWithoutTrailingComma: ({ typeParameterName }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`,
|
|
11608
|
-
StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.",
|
|
11609
|
-
TupleOptionalAfterType: "A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",
|
|
11610
|
-
TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",
|
|
11611
|
-
TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.",
|
|
11612
|
-
TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",
|
|
11613
|
-
TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",
|
|
11614
|
-
UnexpectedParameterInitializer: "A parameter initializer is only allowed in a function or constructor implementation.",
|
|
11615
|
-
UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
|
|
11616
|
-
UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
|
|
11617
|
-
UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
|
|
11618
|
-
UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
|
|
11619
|
-
UnexpectedTypeDeclaration: (type) => `'${type}' declarations can only be declared inside a block.`,
|
|
11620
|
-
UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.",
|
|
11621
|
-
UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
|
|
11622
|
-
UnsupportedSignatureParameterKind: ({ type }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.`,
|
|
11623
|
-
UsingDeclarationInAmbientContext: (kind) => `'${kind}' declarations are not allowed in ambient contexts.`
|
|
11624
|
-
});
|
|
11625
|
-
ParseErrorEnum`placeholders`({
|
|
11626
|
-
ClassNameIsRequired: "A class name is required.",
|
|
11627
|
-
UnexpectedSpace: "Unexpected space in placeholder."
|
|
11628
|
-
});
|
|
11629
|
-
function generateExportedTokenTypes(internalTokenTypes) {
|
|
11630
|
-
const tokenTypes = {};
|
|
11631
|
-
for (const typeName of Object.keys(internalTokenTypes)) tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]);
|
|
11632
|
-
return tokenTypes;
|
|
11633
|
-
}
|
|
11634
|
-
generateExportedTokenTypes(tt);
|
|
12019
|
+
version: literal(1)
|
|
12020
|
+
});
|
|
12021
|
+
//#endregion
|
|
12022
|
+
//#region src/trigger/common/contract.ts
|
|
12023
|
+
var errorOutputs = [
|
|
12024
|
+
{
|
|
12025
|
+
handle: "workflow",
|
|
12026
|
+
nullable: false,
|
|
12027
|
+
jsonSchema: {
|
|
12028
|
+
type: "object",
|
|
12029
|
+
additionalProperties: false,
|
|
12030
|
+
required: [
|
|
12031
|
+
"flowId",
|
|
12032
|
+
"name",
|
|
12033
|
+
"revisionId",
|
|
12034
|
+
"publicationId"
|
|
12035
|
+
],
|
|
12036
|
+
properties: {
|
|
12037
|
+
flowId: { type: "string" },
|
|
12038
|
+
name: { type: "string" },
|
|
12039
|
+
revisionId: { type: "string" },
|
|
12040
|
+
publicationId: { type: ["string", "null"] }
|
|
12041
|
+
}
|
|
12042
|
+
}
|
|
12043
|
+
},
|
|
12044
|
+
{
|
|
12045
|
+
handle: "execution",
|
|
12046
|
+
nullable: false,
|
|
12047
|
+
jsonSchema: {
|
|
12048
|
+
type: "object",
|
|
12049
|
+
additionalProperties: false,
|
|
12050
|
+
required: [
|
|
12051
|
+
"runId",
|
|
12052
|
+
"status",
|
|
12053
|
+
"startedAt",
|
|
12054
|
+
"finishedAt"
|
|
12055
|
+
],
|
|
12056
|
+
properties: {
|
|
12057
|
+
runId: { type: "string" },
|
|
12058
|
+
status: { enum: ["failed", "indeterminate"] },
|
|
12059
|
+
startedAt: { type: ["string", "null"] },
|
|
12060
|
+
finishedAt: { type: "string" }
|
|
12061
|
+
}
|
|
12062
|
+
}
|
|
12063
|
+
},
|
|
12064
|
+
{
|
|
12065
|
+
handle: "error",
|
|
12066
|
+
nullable: false,
|
|
12067
|
+
jsonSchema: {
|
|
12068
|
+
type: "object",
|
|
12069
|
+
additionalProperties: false,
|
|
12070
|
+
required: ["code", "message"],
|
|
12071
|
+
properties: {
|
|
12072
|
+
code: { type: "string" },
|
|
12073
|
+
message: { type: "string" },
|
|
12074
|
+
nodeId: { type: "string" },
|
|
12075
|
+
jobId: { type: "string" },
|
|
12076
|
+
path: {
|
|
12077
|
+
type: "array",
|
|
12078
|
+
items: { type: "string" }
|
|
12079
|
+
}
|
|
12080
|
+
}
|
|
12081
|
+
}
|
|
12082
|
+
}
|
|
12083
|
+
];
|
|
12084
|
+
var webhookOutputs = [
|
|
12085
|
+
{
|
|
12086
|
+
handle: "headers",
|
|
12087
|
+
jsonSchema: {
|
|
12088
|
+
type: "object",
|
|
12089
|
+
additionalProperties: { type: "string" }
|
|
12090
|
+
},
|
|
12091
|
+
nullable: false
|
|
12092
|
+
},
|
|
12093
|
+
{
|
|
12094
|
+
handle: "query",
|
|
12095
|
+
jsonSchema: {
|
|
12096
|
+
type: "object",
|
|
12097
|
+
additionalProperties: {
|
|
12098
|
+
type: ["string", "array"],
|
|
12099
|
+
items: { type: "string" }
|
|
12100
|
+
}
|
|
12101
|
+
},
|
|
12102
|
+
nullable: false
|
|
12103
|
+
},
|
|
12104
|
+
{
|
|
12105
|
+
handle: "body",
|
|
12106
|
+
jsonSchema: {
|
|
12107
|
+
type: "object",
|
|
12108
|
+
additionalProperties: true
|
|
12109
|
+
},
|
|
12110
|
+
nullable: false
|
|
12111
|
+
},
|
|
12112
|
+
{
|
|
12113
|
+
handle: "webhookUrl",
|
|
12114
|
+
jsonSchema: { type: "string" },
|
|
12115
|
+
nullable: false
|
|
12116
|
+
}
|
|
12117
|
+
];
|
|
12118
|
+
var cronOutputs = [{
|
|
12119
|
+
handle: "scheduledAt",
|
|
12120
|
+
jsonSchema: {
|
|
12121
|
+
type: "string",
|
|
12122
|
+
format: "date-time"
|
|
12123
|
+
},
|
|
12124
|
+
nullable: false
|
|
12125
|
+
}];
|
|
12126
|
+
function triggerOutputDefinitions(trigger) {
|
|
12127
|
+
switch (trigger.kind) {
|
|
12128
|
+
case "error": return errorOutputs;
|
|
12129
|
+
case "manual": return [];
|
|
12130
|
+
case "cron": return cronOutputs;
|
|
12131
|
+
case "poll":
|
|
12132
|
+
case "integration": return trigger.definition.outputs;
|
|
12133
|
+
case "webhook": return webhookOutputs.filter((port) => port.handle !== "body" || webhookSupportsBody(trigger.method)).map((port) => port.handle === "body" ? Object.assign({}, port, { jsonSchema: {
|
|
12134
|
+
type: "object",
|
|
12135
|
+
additionalProperties: false,
|
|
12136
|
+
properties: Object.fromEntries(trigger.bodyFields.map((field) => [field.handle, field.jsonSchema])),
|
|
12137
|
+
required: trigger.bodyFields.filter((field) => !field.nullable && !Object.hasOwn(field, "value")).map((field) => field.handle)
|
|
12138
|
+
} }) : port);
|
|
12139
|
+
}
|
|
12140
|
+
}
|
|
12141
|
+
function triggerOutputPorts(trigger) {
|
|
12142
|
+
return Object.fromEntries(triggerOutputDefinitions(trigger).map(({ handle, ...port }) => [handle, port]));
|
|
12143
|
+
}
|
|
12144
|
+
//#endregion
|
|
12145
|
+
//#region src/flow/common/graph.ts
|
|
12146
|
+
function nodeInputPorts(node) {
|
|
12147
|
+
switch (node.kind) {
|
|
12148
|
+
case "condition": return conditionInputPorts(node);
|
|
12149
|
+
case "value": return {};
|
|
12150
|
+
case "task": return portsByHandle([...node.task.inputs, ...node.additionalInputs ?? []]);
|
|
12151
|
+
case "approval":
|
|
12152
|
+
case "wait": return portsByHandle(node.inputDefinitions);
|
|
12153
|
+
case "cron":
|
|
12154
|
+
case "integration":
|
|
12155
|
+
case "poll":
|
|
12156
|
+
case "error":
|
|
12157
|
+
case "manual":
|
|
12158
|
+
case "webhook": return {};
|
|
12159
|
+
}
|
|
12160
|
+
}
|
|
12161
|
+
function resolutionActions(node) {
|
|
12162
|
+
return node.kind == "wait" ? ["continue"] : ["approve", "reject"];
|
|
12163
|
+
}
|
|
12164
|
+
var objectPort = (properties) => ({
|
|
12165
|
+
nullable: false,
|
|
12166
|
+
jsonSchema: {
|
|
12167
|
+
type: "object",
|
|
12168
|
+
properties,
|
|
12169
|
+
required: Object.keys(properties),
|
|
12170
|
+
additionalProperties: false
|
|
12171
|
+
}
|
|
12172
|
+
});
|
|
12173
|
+
function resolutionOutputPorts(node) {
|
|
12174
|
+
const actions = resolutionActions(node);
|
|
12175
|
+
const inputs = {
|
|
12176
|
+
type: "object",
|
|
12177
|
+
properties: Object.fromEntries(node.inputDefinitions.map((port) => [port.handle, {}])),
|
|
12178
|
+
required: node.inputDefinitions.map((port) => port.handle),
|
|
12179
|
+
additionalProperties: false
|
|
12180
|
+
};
|
|
12181
|
+
return {
|
|
12182
|
+
pending: objectPort({
|
|
12183
|
+
inputs,
|
|
12184
|
+
prompt: { type: "string" },
|
|
12185
|
+
...Object.fromEntries(actions.map((action) => [`${action}Url`, { type: "string" }])),
|
|
12186
|
+
expiresAt: { type: "string" }
|
|
12187
|
+
}),
|
|
12188
|
+
...Object.fromEntries(actions.map((action) => [action, objectPort({
|
|
12189
|
+
inputs,
|
|
12190
|
+
action: { const: action },
|
|
12191
|
+
resolvedAt: { type: "string" },
|
|
12192
|
+
comment: { type: ["string", "null"] }
|
|
12193
|
+
})]))
|
|
12194
|
+
};
|
|
12195
|
+
}
|
|
12196
|
+
function nodeOutputPorts(node) {
|
|
12197
|
+
switch (node.kind) {
|
|
12198
|
+
case "condition": return {};
|
|
12199
|
+
case "value": return portsByHandle(node.values);
|
|
12200
|
+
case "task": return portsByHandle(node.task.outputs);
|
|
12201
|
+
case "approval":
|
|
12202
|
+
case "wait": return resolutionOutputPorts(node);
|
|
12203
|
+
case "cron":
|
|
12204
|
+
case "integration":
|
|
12205
|
+
case "poll":
|
|
12206
|
+
case "error":
|
|
12207
|
+
case "manual":
|
|
12208
|
+
case "webhook": return triggerOutputPorts(node);
|
|
12209
|
+
}
|
|
12210
|
+
}
|
|
12211
|
+
//#endregion
|
|
12212
|
+
//#region src/flow/common/moduleChanges.ts
|
|
12213
|
+
async function imports(source) {
|
|
12214
|
+
try {
|
|
12215
|
+
const { parse } = await import("./lib-DrKav3HG.js");
|
|
12216
|
+
const program = parse(source, {
|
|
12217
|
+
errorRecovery: true,
|
|
12218
|
+
sourceType: "module"
|
|
12219
|
+
}).program;
|
|
12220
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
12221
|
+
for (const statement of program.body) {
|
|
12222
|
+
if (statement.type != "ImportDeclaration") continue;
|
|
12223
|
+
const match = /^\.\/(.+)\.mjs$/.exec(statement.source.value);
|
|
12224
|
+
if (match?.[1] != null) dependencies.add(match[1]);
|
|
12225
|
+
}
|
|
12226
|
+
return [...dependencies].toSorted();
|
|
12227
|
+
} catch {
|
|
12228
|
+
return [];
|
|
12229
|
+
}
|
|
12230
|
+
}
|
|
11635
12231
|
//#endregion
|
|
11636
12232
|
//#region src/flow/common/nodeChanges.ts
|
|
11637
12233
|
var codeTaskTemplate = `export default async function (inputs, context) {
|
|
11638
12234
|
return { result: inputs.value }
|
|
11639
12235
|
}
|
|
11640
12236
|
`;
|
|
11641
|
-
|
|
12237
|
+
var defaultCodeTaskPorts = {
|
|
11642
12238
|
inputs: [{
|
|
11643
12239
|
handle: "value",
|
|
11644
12240
|
jsonSchema: { type: "string" },
|
|
@@ -11650,7 +12246,8 @@ function createCodeTask(target, identity, name, module = void 0, ports = {
|
|
|
11650
12246
|
jsonSchema: {},
|
|
11651
12247
|
nullable: true
|
|
11652
12248
|
}]
|
|
11653
|
-
}
|
|
12249
|
+
};
|
|
12250
|
+
function createCodeTask(identity, name, module = void 0, ports = defaultCodeTaskPorts) {
|
|
11654
12251
|
return [{
|
|
11655
12252
|
kind: "module.create",
|
|
11656
12253
|
module: {
|
|
@@ -11679,30 +12276,48 @@ function createCodeTask(target, identity, name, module = void 0, ports = {
|
|
|
11679
12276
|
outputs: ports.outputs
|
|
11680
12277
|
}
|
|
11681
12278
|
},
|
|
11682
|
-
nodeId: identity.nodeId
|
|
11683
|
-
target
|
|
12279
|
+
nodeId: identity.nodeId
|
|
11684
12280
|
}];
|
|
11685
12281
|
}
|
|
11686
|
-
function createManagedTask(
|
|
12282
|
+
function createManagedTask(identity, task) {
|
|
11687
12283
|
return [{
|
|
11688
|
-
kind: "task.create",
|
|
11689
|
-
task,
|
|
11690
|
-
taskId: identity.taskId
|
|
11691
|
-
}, {
|
|
11692
12284
|
kind: "graph.node.create",
|
|
11693
12285
|
node: {
|
|
11694
12286
|
inputs: defaultInputs(task.inputs),
|
|
11695
12287
|
kind: "task",
|
|
11696
12288
|
name: task.name,
|
|
11697
|
-
|
|
12289
|
+
task
|
|
11698
12290
|
},
|
|
11699
|
-
nodeId: identity.nodeId
|
|
11700
|
-
target
|
|
12291
|
+
nodeId: identity.nodeId
|
|
11701
12292
|
}];
|
|
11702
12293
|
}
|
|
11703
|
-
function
|
|
12294
|
+
function createAgentTask(identity, name, defaults = {}) {
|
|
12295
|
+
return createManagedTask(identity, {
|
|
12296
|
+
name,
|
|
12297
|
+
inputs: defaults.inputs ?? [{
|
|
12298
|
+
handle: "input",
|
|
12299
|
+
jsonSchema: { type: "string" },
|
|
12300
|
+
nullable: false,
|
|
12301
|
+
value: ""
|
|
12302
|
+
}],
|
|
12303
|
+
outputs: [{
|
|
12304
|
+
handle: "output",
|
|
12305
|
+
jsonSchema: { type: "string" },
|
|
12306
|
+
nullable: false,
|
|
12307
|
+
description: defaults.outputDescription ?? "The final result produced by the Agent."
|
|
12308
|
+
}],
|
|
12309
|
+
executor: {
|
|
12310
|
+
kind: "agent",
|
|
12311
|
+
model: "deepseek-v4-flash",
|
|
12312
|
+
prompt: defaults.prompt ?? "Summarize the following content, highlighting key points and next steps.\n\n{{input}}",
|
|
12313
|
+
maxRounds: 10,
|
|
12314
|
+
tools: []
|
|
12315
|
+
}
|
|
12316
|
+
});
|
|
12317
|
+
}
|
|
12318
|
+
function createLlmTask(identity, name, mode, outputDescription, options = {}) {
|
|
11704
12319
|
const values = options.inputs ?? {};
|
|
11705
|
-
return createManagedTask(
|
|
12320
|
+
return createManagedTask(identity, {
|
|
11706
12321
|
executor: {
|
|
11707
12322
|
kind: "llm",
|
|
11708
12323
|
mode
|
|
@@ -11753,7 +12368,7 @@ function createLlmTask(target, identity, name, mode, outputDescription, options
|
|
|
11753
12368
|
}]
|
|
11754
12369
|
});
|
|
11755
12370
|
}
|
|
11756
|
-
function createCondition(
|
|
12371
|
+
function createCondition(nodeId, name) {
|
|
11757
12372
|
return [{
|
|
11758
12373
|
kind: "graph.node.create",
|
|
11759
12374
|
node: {
|
|
@@ -11770,29 +12385,27 @@ function createCondition(target, nodeId, name) {
|
|
|
11770
12385
|
kind: "condition",
|
|
11771
12386
|
name
|
|
11772
12387
|
},
|
|
11773
|
-
nodeId
|
|
11774
|
-
target
|
|
12388
|
+
nodeId
|
|
11775
12389
|
}];
|
|
11776
12390
|
}
|
|
11777
|
-
function createValue(
|
|
12391
|
+
function createValue(nodeId, name, values = [{
|
|
12392
|
+
handle: "value",
|
|
12393
|
+
jsonSchema: {},
|
|
12394
|
+
nullable: true,
|
|
12395
|
+
value: null
|
|
12396
|
+
}]) {
|
|
11778
12397
|
return [{
|
|
11779
12398
|
kind: "graph.node.create",
|
|
11780
12399
|
node: {
|
|
11781
12400
|
inputs: {},
|
|
11782
12401
|
kind: "value",
|
|
11783
12402
|
name,
|
|
11784
|
-
values
|
|
11785
|
-
handle: "value",
|
|
11786
|
-
jsonSchema: {},
|
|
11787
|
-
nullable: true,
|
|
11788
|
-
value: null
|
|
11789
|
-
}]
|
|
12403
|
+
values
|
|
11790
12404
|
},
|
|
11791
|
-
nodeId
|
|
11792
|
-
target
|
|
12405
|
+
nodeId
|
|
11793
12406
|
}];
|
|
11794
12407
|
}
|
|
11795
|
-
function createWait(
|
|
12408
|
+
function createWait(nodeId, name) {
|
|
11796
12409
|
return [{
|
|
11797
12410
|
kind: "graph.node.create",
|
|
11798
12411
|
node: {
|
|
@@ -11802,11 +12415,10 @@ function createWait(target, nodeId, name) {
|
|
|
11802
12415
|
name,
|
|
11803
12416
|
prompt: name
|
|
11804
12417
|
},
|
|
11805
|
-
nodeId
|
|
11806
|
-
target
|
|
12418
|
+
nodeId
|
|
11807
12419
|
}];
|
|
11808
12420
|
}
|
|
11809
|
-
function createApproval(
|
|
12421
|
+
function createApproval(nodeId, name) {
|
|
11810
12422
|
return [{
|
|
11811
12423
|
kind: "graph.node.create",
|
|
11812
12424
|
node: {
|
|
@@ -11816,19 +12428,17 @@ function createApproval(target, nodeId, name) {
|
|
|
11816
12428
|
name,
|
|
11817
12429
|
prompt: name
|
|
11818
12430
|
},
|
|
11819
|
-
nodeId
|
|
11820
|
-
target
|
|
12431
|
+
nodeId
|
|
11821
12432
|
}];
|
|
11822
12433
|
}
|
|
11823
|
-
function createBuiltinTrigger(
|
|
12434
|
+
function createBuiltinTrigger(nodeId, node) {
|
|
11824
12435
|
return [{
|
|
11825
12436
|
kind: "graph.node.create",
|
|
11826
12437
|
node,
|
|
11827
|
-
nodeId
|
|
11828
|
-
target
|
|
12438
|
+
nodeId
|
|
11829
12439
|
}];
|
|
11830
12440
|
}
|
|
11831
|
-
function createProviderTrigger(
|
|
12441
|
+
function createProviderTrigger(nodeId, definition, options) {
|
|
11832
12442
|
const name = options.name ?? definition.displayName;
|
|
11833
12443
|
return [{
|
|
11834
12444
|
kind: "graph.node.create",
|
|
@@ -11850,10 +12460,33 @@ function createProviderTrigger(target, nodeId, definition, options) {
|
|
|
11850
12460
|
kind: "integration",
|
|
11851
12461
|
name
|
|
11852
12462
|
},
|
|
11853
|
-
nodeId
|
|
11854
|
-
target
|
|
12463
|
+
nodeId
|
|
11855
12464
|
}];
|
|
11856
12465
|
}
|
|
12466
|
+
function cleanVariableBindings(content, operations) {
|
|
12467
|
+
const before = bindingReferences(content.document);
|
|
12468
|
+
const changed = applyFlowChanges(content, operations);
|
|
12469
|
+
const after = bindingReferences(changed.document);
|
|
12470
|
+
return [...operations, ...[...before.keys()].flatMap((bindingId) => after.has(bindingId) || changed.document.bindings[bindingId]?.kind != "variable" ? [] : [{
|
|
12471
|
+
bindingId,
|
|
12472
|
+
kind: "binding.delete"
|
|
12473
|
+
}])];
|
|
12474
|
+
}
|
|
12475
|
+
function bindingReferences(document) {
|
|
12476
|
+
const references = /* @__PURE__ */ new Map();
|
|
12477
|
+
const add = (bindingId) => {
|
|
12478
|
+
references.set(bindingId, (references.get(bindingId) ?? 0) + 1);
|
|
12479
|
+
};
|
|
12480
|
+
for (const node of Object.values(document.graph.nodes)) {
|
|
12481
|
+
if (!("inputs" in node)) continue;
|
|
12482
|
+
const inputs = Object.values(nodeInputMappings(node));
|
|
12483
|
+
for (const mapping of inputs) {
|
|
12484
|
+
if (mapping.kind != "sources") continue;
|
|
12485
|
+
for (const source of mapping.sources) if (source.kind == "binding") add(source.bindingId);
|
|
12486
|
+
}
|
|
12487
|
+
}
|
|
12488
|
+
return references;
|
|
12489
|
+
}
|
|
11857
12490
|
function defaultInputs(ports) {
|
|
11858
12491
|
return Object.fromEntries(ports.flatMap((port) => "handle" in port && Object.hasOwn(port, "value") ? [[port.handle, {
|
|
11859
12492
|
kind: "value",
|
|
@@ -11863,20 +12496,1167 @@ function defaultInputs(ports) {
|
|
|
11863
12496
|
function llmInputValue(values, handle, fallback) {
|
|
11864
12497
|
return values != null && Object.hasOwn(values, handle) ? values[handle] : fallback;
|
|
11865
12498
|
}
|
|
11866
|
-
function createDecisionTask(
|
|
11867
|
-
return createManagedTask(
|
|
12499
|
+
function createDecisionTask(identity, name = "AI Decision", questions) {
|
|
12500
|
+
return createManagedTask(identity, decisionTask(questions, name));
|
|
11868
12501
|
}
|
|
11869
12502
|
//#endregion
|
|
12503
|
+
//#region src/control/common/authoringCondition.ts
|
|
12504
|
+
/** Preserve empty groups in invalid drafts; do not turn them into unconditional branches. */
|
|
12505
|
+
function conditionConfigurationView(node, source) {
|
|
12506
|
+
const operand = (value) => value.kind == "source" ? source(value.source) : {
|
|
12507
|
+
kind: "value",
|
|
12508
|
+
...value.value === void 0 ? {} : { value: value.value },
|
|
12509
|
+
...value.jsonSchema === void 0 ? {} : { schema: value.jsonSchema }
|
|
12510
|
+
};
|
|
12511
|
+
const expression = (value) => ({
|
|
12512
|
+
left: operand(value.left),
|
|
12513
|
+
operator: value.operator,
|
|
12514
|
+
...value.right === void 0 ? {} : { right: operand(value.right) }
|
|
12515
|
+
});
|
|
12516
|
+
return {
|
|
12517
|
+
match: node.matchMode,
|
|
12518
|
+
branches: node.cases.map((branch) => {
|
|
12519
|
+
const groups = branch.groups.map((group) => group.expressions.length == 1 ? expression(group.expressions[0]) : { all: group.expressions.map(expression) });
|
|
12520
|
+
return {
|
|
12521
|
+
name: branch.output,
|
|
12522
|
+
...branch.description === void 0 ? {} : { description: branch.description },
|
|
12523
|
+
when: groups.length == 1 ? groups[0] : { any: groups }
|
|
12524
|
+
};
|
|
12525
|
+
})
|
|
12526
|
+
};
|
|
12527
|
+
}
|
|
12528
|
+
function prepareConditionConfiguration(config, source) {
|
|
12529
|
+
const operand = (value) => value.kind == "value" ? {
|
|
12530
|
+
kind: "value",
|
|
12531
|
+
...value.value === void 0 ? {} : { value: value.value },
|
|
12532
|
+
...value.schema === void 0 ? {} : { jsonSchema: value.schema }
|
|
12533
|
+
} : {
|
|
12534
|
+
kind: "source",
|
|
12535
|
+
source: source(value)
|
|
12536
|
+
};
|
|
12537
|
+
const expression = (value) => ({
|
|
12538
|
+
left: operand(value.left),
|
|
12539
|
+
operator: value.operator,
|
|
12540
|
+
...value.right === void 0 ? {} : { right: operand(value.right) }
|
|
12541
|
+
});
|
|
12542
|
+
return {
|
|
12543
|
+
matchMode: config.match,
|
|
12544
|
+
cases: config.branches.map((branch) => {
|
|
12545
|
+
const groups = "any" in branch.when ? branch.when.any : [branch.when];
|
|
12546
|
+
return {
|
|
12547
|
+
output: branch.name,
|
|
12548
|
+
...branch.description === void 0 ? {} : { description: branch.description },
|
|
12549
|
+
groups: groups.map((group) => ({ expressions: ("all" in group ? group.all : [group]).map(expression) }))
|
|
12550
|
+
};
|
|
12551
|
+
})
|
|
12552
|
+
};
|
|
12553
|
+
}
|
|
12554
|
+
/** Map a path relative to a persisted Condition configuration into its normalized public config. */
|
|
12555
|
+
function conditionConfigurationFieldPath(node, path) {
|
|
12556
|
+
if (path[0] == "matchMode") return ["match", ...path.slice(1)];
|
|
12557
|
+
if (path[0] != "cases") return path;
|
|
12558
|
+
if (path.length == 1) return ["branches"];
|
|
12559
|
+
const branchIndex = Number(path[1]), branch = node.cases[branchIndex], base = ["branches", path[1]];
|
|
12560
|
+
if (path[2] == "output") return [
|
|
12561
|
+
...base,
|
|
12562
|
+
"name",
|
|
12563
|
+
...path.slice(3)
|
|
12564
|
+
];
|
|
12565
|
+
if (path[2] != "groups") return [...base, ...path.slice(2)];
|
|
12566
|
+
base.push("when");
|
|
12567
|
+
if (branch == null || path.length == 3) return base;
|
|
12568
|
+
const groupIndex = Number(path[3]), group = branch.groups[groupIndex];
|
|
12569
|
+
if (branch.groups.length != 1) base.push("any", path[3]);
|
|
12570
|
+
if (path[4] != "expressions") return [...base, ...path.slice(4)];
|
|
12571
|
+
if (group == null || path.length == 5) return group?.expressions.length == 1 ? base : [...base, "all"];
|
|
12572
|
+
if (group.expressions.length != 1) base.push("all", path[5]);
|
|
12573
|
+
const remaining = path.slice(6).filter((part, index) => !(index == 1 && part == "source"));
|
|
12574
|
+
if (remaining[0] == "left" || remaining[0] == "right") switch (remaining[1]) {
|
|
12575
|
+
case "jsonSchema":
|
|
12576
|
+
remaining[1] = "schema";
|
|
12577
|
+
break;
|
|
12578
|
+
case "nodeId":
|
|
12579
|
+
remaining[1] = "node";
|
|
12580
|
+
break;
|
|
12581
|
+
case "output":
|
|
12582
|
+
remaining[1] = "port";
|
|
12583
|
+
break;
|
|
12584
|
+
case "bindingId": remaining[1] = "name";
|
|
12585
|
+
}
|
|
12586
|
+
return [...base, ...remaining];
|
|
12587
|
+
}
|
|
12588
|
+
//#endregion
|
|
12589
|
+
//#region src/control/common/authoringDiagnosticFields.ts
|
|
12590
|
+
var metadata = /* @__PURE__ */ new Set([
|
|
12591
|
+
"name",
|
|
12592
|
+
"description",
|
|
12593
|
+
"icon",
|
|
12594
|
+
"timeoutMs",
|
|
12595
|
+
"maxExecutions"
|
|
12596
|
+
]);
|
|
12597
|
+
function portField(ports, path, parent) {
|
|
12598
|
+
const port = ports[Number(path[0])];
|
|
12599
|
+
if (port == null || !("handle" in port)) return parent;
|
|
12600
|
+
const field = `${parent}.${port.handle}`;
|
|
12601
|
+
switch (path[1]) {
|
|
12602
|
+
case "jsonSchema": return [
|
|
12603
|
+
field,
|
|
12604
|
+
"schema",
|
|
12605
|
+
...path.slice(2)
|
|
12606
|
+
].join(".");
|
|
12607
|
+
case "value": return [
|
|
12608
|
+
field,
|
|
12609
|
+
"default",
|
|
12610
|
+
...path.slice(2)
|
|
12611
|
+
].join(".");
|
|
12612
|
+
case "nullable":
|
|
12613
|
+
case "description": return [field, ...path.slice(1)].join(".");
|
|
12614
|
+
default: return field;
|
|
12615
|
+
}
|
|
12616
|
+
}
|
|
12617
|
+
/** Accept a decoded JSON Pointer, including or omitting its initial empty component. */
|
|
12618
|
+
function authoringDiagnosticField(_content, node, parts) {
|
|
12619
|
+
const path = parts[0] == "" ? parts.slice(1) : parts;
|
|
12620
|
+
if (path[0] == "modules") return "code";
|
|
12621
|
+
let location = path[0] == "document" && path[1] == "graph" && path[2] == "nodes" ? path.slice(4) : path;
|
|
12622
|
+
const inlineDefinition = node.kind == "task" && location[0] == "task";
|
|
12623
|
+
if (inlineDefinition) location = location.slice(1);
|
|
12624
|
+
if (location.length == 0) return "config";
|
|
12625
|
+
const head = location[0];
|
|
12626
|
+
if (!inlineDefinition && metadata.has(head)) return location.join(".");
|
|
12627
|
+
if (head == "prompt") return "prompt";
|
|
12628
|
+
if (head == "inputs" && !inlineDefinition) {
|
|
12629
|
+
if (node.kind == "condition" && location[1] != null) {
|
|
12630
|
+
const [branch, group, expression, side] = location[1].split("/");
|
|
12631
|
+
if (branch != null && group != null && expression != null && (side == "left" || side == "right")) return ["config", ...conditionConfigurationFieldPath(node, [
|
|
12632
|
+
"cases",
|
|
12633
|
+
branch,
|
|
12634
|
+
"groups",
|
|
12635
|
+
group,
|
|
12636
|
+
"expressions",
|
|
12637
|
+
expression,
|
|
12638
|
+
side
|
|
12639
|
+
])].join(".");
|
|
12640
|
+
return "config.branches";
|
|
12641
|
+
}
|
|
12642
|
+
return location[1] == null ? "inputs" : `inputs.${location[1]}`;
|
|
12643
|
+
}
|
|
12644
|
+
if (node.kind == "task") {
|
|
12645
|
+
const task = node.task;
|
|
12646
|
+
if (task == null) return "config";
|
|
12647
|
+
const executor = "executor" in task ? task.executor : void 0;
|
|
12648
|
+
if (head == "additionalInputs") return portField(node.additionalInputs ?? [], location.slice(1), "config.inputs");
|
|
12649
|
+
if (head == "inputs" || head == "outputs") {
|
|
12650
|
+
const ports = task[head];
|
|
12651
|
+
const port = ports[Number(location[1])];
|
|
12652
|
+
if (head == "outputs" && (executor?.kind == "agent" || executor?.kind == "llm")) return location[2] == "jsonSchema" ? [
|
|
12653
|
+
"config",
|
|
12654
|
+
"resultSchema",
|
|
12655
|
+
...location.slice(3)
|
|
12656
|
+
].join(".") : "config.resultSchema";
|
|
12657
|
+
if (head == "inputs" && executor?.kind == "llm" && port != null && "handle" in port && [
|
|
12658
|
+
"model",
|
|
12659
|
+
"template",
|
|
12660
|
+
"messages"
|
|
12661
|
+
].includes(port.handle)) return [
|
|
12662
|
+
"config",
|
|
12663
|
+
port.handle,
|
|
12664
|
+
...location[2] == "value" ? location.slice(3) : []
|
|
12665
|
+
].join(".");
|
|
12666
|
+
const custom = executor == null || executor.kind == "agent" || executor.kind == "llm";
|
|
12667
|
+
return portField(ports, location.slice(1), custom ? `config.${head}` : head == "inputs" ? "inputPorts" : "outputPorts");
|
|
12668
|
+
}
|
|
12669
|
+
if (head == "executor") {
|
|
12670
|
+
const field = location[1];
|
|
12671
|
+
if (field == null || field == "kind") return "config";
|
|
12672
|
+
if (field == "prompt") return "prompt";
|
|
12673
|
+
if (executor?.kind == "openapi") {
|
|
12674
|
+
if (field == "document") return "config";
|
|
12675
|
+
if (field == "auth") return "config.authentication";
|
|
12676
|
+
}
|
|
12677
|
+
if (executor?.kind == "agent") {
|
|
12678
|
+
if (field == "tools") {
|
|
12679
|
+
const tool = executor.tools[Number(location[2])];
|
|
12680
|
+
if (tool == null) return "config.tools";
|
|
12681
|
+
const base = `config.tools.${location[2]}`;
|
|
12682
|
+
if (location[3] == "id") return base;
|
|
12683
|
+
if (location[3] == "inputs") {
|
|
12684
|
+
const input = tool.inputs[Number(location[4])];
|
|
12685
|
+
if (input == null) return `${base}.inputs`;
|
|
12686
|
+
return location[5] == "source" ? [
|
|
12687
|
+
base,
|
|
12688
|
+
"inputs",
|
|
12689
|
+
input.handle,
|
|
12690
|
+
...location.slice(6)
|
|
12691
|
+
].join(".") : `${base}.inputs.${input.handle}`;
|
|
12692
|
+
}
|
|
12693
|
+
}
|
|
12694
|
+
if (field == "notification" && location[2] == "inputDefinitions") return "config.notification.inputs";
|
|
12695
|
+
}
|
|
12696
|
+
return ["config", ...location.slice(1)].join(".");
|
|
12697
|
+
}
|
|
12698
|
+
if (head == "capabilities") return ["config", ...location].join(".");
|
|
12699
|
+
if (head == "name") return "name";
|
|
12700
|
+
return "config";
|
|
12701
|
+
}
|
|
12702
|
+
switch (node.kind) {
|
|
12703
|
+
case "condition": return head == "cases" || head == "matchMode" ? ["config", ...conditionConfigurationFieldPath(node, location)].join(".") : "config";
|
|
12704
|
+
case "wait":
|
|
12705
|
+
case "approval": return head == "inputDefinitions" ? portField(node.inputDefinitions, location.slice(1), "config.inputs") : "config";
|
|
12706
|
+
case "webhook":
|
|
12707
|
+
if (head == "bodyFields") return portField(node.bodyFields, location.slice(1), "config.body");
|
|
12708
|
+
return head == "method" || head == "options" ? ["config", ...location].join(".") : "config";
|
|
12709
|
+
case "value": {
|
|
12710
|
+
if (head != "values") return "config";
|
|
12711
|
+
const port = node.values[Number(location[1])];
|
|
12712
|
+
if (port == null) return "config.values";
|
|
12713
|
+
if (location[2] == "value") return [
|
|
12714
|
+
"config",
|
|
12715
|
+
"values",
|
|
12716
|
+
port.handle,
|
|
12717
|
+
...location.slice(3)
|
|
12718
|
+
].join(".");
|
|
12719
|
+
return portField(node.values, location.slice(1), "config.outputs");
|
|
12720
|
+
}
|
|
12721
|
+
case "cron": return head == "cronTimes" ? [
|
|
12722
|
+
"config",
|
|
12723
|
+
"schedule",
|
|
12724
|
+
...location.slice(1)
|
|
12725
|
+
].join(".") : "config";
|
|
12726
|
+
case "poll":
|
|
12727
|
+
case "integration":
|
|
12728
|
+
if (head == "config") return location[1] == null ? "inputs" : `inputs.${location[1]}`;
|
|
12729
|
+
if (head == "definition") return location[1] == "configInputs" ? portField(node.definition.configInputs, location.slice(2), "inputPorts") : "config.key";
|
|
12730
|
+
if (head == "pollTimes") return [
|
|
12731
|
+
"config",
|
|
12732
|
+
"schedule",
|
|
12733
|
+
...location.slice(1)
|
|
12734
|
+
].join(".");
|
|
12735
|
+
return head == "connectionId" ? "config.connectionId" : "config";
|
|
12736
|
+
case "error": return head == "sourceFlowIds" ? ["config", ...location].join(".") : "config";
|
|
12737
|
+
default: return "config";
|
|
12738
|
+
}
|
|
12739
|
+
}
|
|
12740
|
+
//#endregion
|
|
12741
|
+
//#region src/control/common/authoringFields.ts
|
|
12742
|
+
var record$1 = (value) => value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
12743
|
+
/** Business field contracts, independent of storage handles and presentation groups. */
|
|
12744
|
+
function fieldsView(ports) {
|
|
12745
|
+
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, {
|
|
12746
|
+
schema: port.jsonSchema,
|
|
12747
|
+
nullable: port.nullable,
|
|
12748
|
+
...port.description == null ? {} : { description: port.description },
|
|
12749
|
+
...Object.hasOwn(port, "value") ? { default: port.value } : {}
|
|
12750
|
+
}]] : []));
|
|
12751
|
+
}
|
|
12752
|
+
function fieldsToPorts(fields, previous) {
|
|
12753
|
+
const remaining = new Map(Object.entries(record$1(fields)));
|
|
12754
|
+
function port(handle, value) {
|
|
12755
|
+
const field = record$1(value);
|
|
12756
|
+
return {
|
|
12757
|
+
handle,
|
|
12758
|
+
jsonSchema: Object.hasOwn(field, "schema") ? field.schema : {},
|
|
12759
|
+
nullable: field.nullable ?? true,
|
|
12760
|
+
...field.description == null ? {} : { description: String(field.description) },
|
|
12761
|
+
...Object.hasOwn(field, "default") ? { value: field.default } : {}
|
|
12762
|
+
};
|
|
12763
|
+
}
|
|
12764
|
+
return [...previous.flatMap((old) => {
|
|
12765
|
+
if (!("handle" in old)) return [old];
|
|
12766
|
+
if (!remaining.has(old.handle)) return [];
|
|
12767
|
+
const value = remaining.get(old.handle);
|
|
12768
|
+
remaining.delete(old.handle);
|
|
12769
|
+
return [dequal(fieldsView([old])[old.handle], value) ? old : port(old.handle, value)];
|
|
12770
|
+
}), ...Array.from(remaining, ([handle, value]) => port(handle, value))];
|
|
12771
|
+
}
|
|
12772
|
+
//#endregion
|
|
12773
|
+
//#region src/control/common/authoringTools.ts
|
|
12774
|
+
var AuthoringToolInputError = class extends Error {
|
|
12775
|
+
constructor(details) {
|
|
12776
|
+
super(`Unknown input ${JSON.stringify(details.input)} for tool ${JSON.stringify(details.tool)}. Choose from: ${details.choices.join(", ") || "(none)"}.`);
|
|
12777
|
+
this.code = "tool.input-not-found";
|
|
12778
|
+
this.name = "AuthoringToolInputError";
|
|
12779
|
+
this.details = details;
|
|
12780
|
+
}
|
|
12781
|
+
};
|
|
12782
|
+
function outwardAgentTools(tools) {
|
|
12783
|
+
return tools.map(({ id: _id, inputs, ...tool }) => ({
|
|
12784
|
+
...tool,
|
|
12785
|
+
inputs: Object.fromEntries(inputs.map((input) => [input.handle, input.source]))
|
|
12786
|
+
}));
|
|
12787
|
+
}
|
|
12788
|
+
/** Keep persisted Action contracts until the caller selects a different Action. */
|
|
12789
|
+
async function prepareAgentTools(tools, previous, action, id) {
|
|
12790
|
+
const prepared = [];
|
|
12791
|
+
for (const tool of tools) {
|
|
12792
|
+
const old = previous.find((item) => item.name == tool.name);
|
|
12793
|
+
const retained = old?.action == tool.action ? old : void 0;
|
|
12794
|
+
const definition = retained == null ? await action(tool.action) : void 0;
|
|
12795
|
+
const ports = retained?.inputs ?? Object.entries(definition.inputs).map(([handle, port]) => Object.assign({}, port, {
|
|
12796
|
+
handle,
|
|
12797
|
+
source: { kind: "model" }
|
|
12798
|
+
}));
|
|
12799
|
+
const choices = ports.map((port) => port.handle);
|
|
12800
|
+
for (const input of Object.keys(tool.inputs ?? {})) if (!choices.includes(input)) throw new AuthoringToolInputError({
|
|
12801
|
+
tool: tool.name,
|
|
12802
|
+
action: tool.action,
|
|
12803
|
+
input,
|
|
12804
|
+
choices
|
|
12805
|
+
});
|
|
12806
|
+
const { inputs: sources, ...settings } = tool;
|
|
12807
|
+
prepared.push({
|
|
12808
|
+
...settings,
|
|
12809
|
+
id: old?.id ?? id(),
|
|
12810
|
+
action: definition?.actionId ?? tool.action,
|
|
12811
|
+
inputs: ports.map((port) => sources != null && Object.hasOwn(sources, port.handle) ? Object.assign({}, port, { source: sources[port.handle] }) : port)
|
|
12812
|
+
});
|
|
12813
|
+
}
|
|
12814
|
+
return prepared;
|
|
12815
|
+
}
|
|
12816
|
+
//#endregion
|
|
12817
|
+
//#region src/control/common/authoring.ts
|
|
12818
|
+
var record = (value) => value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
12819
|
+
var json$2 = (value) => JSON.parse(JSON.stringify(value));
|
|
12820
|
+
var AuthoringError = class extends Error {
|
|
12821
|
+
constructor(code, message, details = {}) {
|
|
12822
|
+
super(message);
|
|
12823
|
+
this.code = code;
|
|
12824
|
+
this.details = details;
|
|
12825
|
+
this.name = "AuthoringError";
|
|
12826
|
+
}
|
|
12827
|
+
};
|
|
12828
|
+
function fail(code, message, details = {}) {
|
|
12829
|
+
throw new AuthoringError(code, message, details);
|
|
12830
|
+
}
|
|
12831
|
+
function nodeAt(content, ref) {
|
|
12832
|
+
return (Object.hasOwn(content.document.graph.nodes, ref) ? content.document.graph.nodes[ref] : void 0) ?? fail("node.not-found", `Node ${JSON.stringify(ref)} does not exist.`, { node: ref });
|
|
12833
|
+
}
|
|
12834
|
+
function taskAt(node) {
|
|
12835
|
+
return node.kind == "task" ? node.task : void 0;
|
|
12836
|
+
}
|
|
12837
|
+
var llmReservedInputs = [
|
|
12838
|
+
"model",
|
|
12839
|
+
"template",
|
|
12840
|
+
"messages"
|
|
12841
|
+
];
|
|
12842
|
+
function inputDefinitions(node) {
|
|
12843
|
+
if (node.kind == "condition") return {};
|
|
12844
|
+
if (node.kind == "poll" || node.kind == "integration") return Object.fromEntries(node.definition.configInputs.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
|
|
12845
|
+
return nodeInputPorts(node);
|
|
12846
|
+
}
|
|
12847
|
+
function inputMappings(node) {
|
|
12848
|
+
return node.kind == "condition" ? {} : node.kind == "poll" || node.kind == "integration" ? node.config : nodeInputMappings(node);
|
|
12849
|
+
}
|
|
12850
|
+
function typeOf(node) {
|
|
12851
|
+
const task = taskAt(node);
|
|
12852
|
+
return node.kind != "task" ? node.kind : task != null && "executor" in task ? task.executor.kind : "code";
|
|
12853
|
+
}
|
|
12854
|
+
function outwardSource(content, value) {
|
|
12855
|
+
if (Array.isArray(value)) return value.map((v) => outwardSource(content, v));
|
|
12856
|
+
if (value == null || typeof value != "object") return value;
|
|
12857
|
+
const v = record(value);
|
|
12858
|
+
if (v.kind == "node" && typeof v.nodeId == "string" && typeof v.output == "string") return {
|
|
12859
|
+
kind: "output",
|
|
12860
|
+
node: v.nodeId,
|
|
12861
|
+
port: v.output,
|
|
12862
|
+
...v.field == null ? {} : { field: v.field }
|
|
12863
|
+
};
|
|
12864
|
+
if (v.kind == "binding" && typeof v.bindingId == "string") return {
|
|
12865
|
+
kind: "variable",
|
|
12866
|
+
name: content.document.bindings[v.bindingId]?.target ?? "[missing variable]"
|
|
12867
|
+
};
|
|
12868
|
+
if (v.kind == "value") return value;
|
|
12869
|
+
return Object.fromEntries(Object.entries(v).map(([k, item]) => [k, outwardSource(content, item)]));
|
|
12870
|
+
}
|
|
12871
|
+
function authoringEdges(edges) {
|
|
12872
|
+
return edges.map((edge) => edge.sourceHandle == null ? {
|
|
12873
|
+
source: edge.source,
|
|
12874
|
+
target: edge.target
|
|
12875
|
+
} : {
|
|
12876
|
+
source: edge.source,
|
|
12877
|
+
target: edge.target,
|
|
12878
|
+
branch: edge.sourceHandle
|
|
12879
|
+
});
|
|
12880
|
+
}
|
|
12881
|
+
function authoringNode(content, ref) {
|
|
12882
|
+
const node = nodeAt(content, ref), type = typeOf(node), task = taskAt(node);
|
|
12883
|
+
let config = {};
|
|
12884
|
+
const texts = {};
|
|
12885
|
+
if (task != null && "executor" in task) {
|
|
12886
|
+
const { kind: _, ...executor } = task.executor;
|
|
12887
|
+
config = { ...executor };
|
|
12888
|
+
if (task.executor.kind == "agent") {
|
|
12889
|
+
const { prompt, tools, notification, ...rest } = task.executor;
|
|
12890
|
+
const { kind: _agentKind, ...settings } = rest;
|
|
12891
|
+
config = {
|
|
12892
|
+
...settings,
|
|
12893
|
+
inputs: fieldsView([...task.inputs, ...node.kind == "task" ? node.additionalInputs ?? [] : []]),
|
|
12894
|
+
resultSchema: task.outputs.find((port) => "handle" in port)?.jsonSchema ?? { type: "string" },
|
|
12895
|
+
tools: outwardAgentTools(tools)
|
|
12896
|
+
};
|
|
12897
|
+
texts.prompt = prompt;
|
|
12898
|
+
if (notification != null) {
|
|
12899
|
+
const { inputDefinitions: _definitions, ...noticeSettings } = notification;
|
|
12900
|
+
config.notification = noticeSettings;
|
|
12901
|
+
}
|
|
12902
|
+
} else if (task.executor.kind == "llm") config = {
|
|
12903
|
+
...llmConfigurationView(task),
|
|
12904
|
+
inputs: fieldsView([...task.inputs, ...node.kind == "task" ? node.additionalInputs ?? [] : []].filter((port) => !("handle" in port) || !llmReservedInputs.includes(port.handle)))
|
|
12905
|
+
};
|
|
12906
|
+
else if (task.executor.kind == "openapi") config = { ...openApiConfigView(task.executor) };
|
|
12907
|
+
} else if (node.kind == "task" && "moduleId" in node.task) {
|
|
12908
|
+
config = {
|
|
12909
|
+
inputs: fieldsView([...node.task.inputs, ...node.additionalInputs ?? []]),
|
|
12910
|
+
outputs: fieldsView(node.task.outputs),
|
|
12911
|
+
...node.task.capabilities == null ? {} : { capabilities: node.task.capabilities }
|
|
12912
|
+
};
|
|
12913
|
+
texts.code = content.modules[node.task.moduleId]?.source ?? "";
|
|
12914
|
+
} else switch (node.kind) {
|
|
12915
|
+
case "condition":
|
|
12916
|
+
config = { ...conditionConfigurationView(node, (value) => outwardSource(content, value)) };
|
|
12917
|
+
break;
|
|
12918
|
+
case "value":
|
|
12919
|
+
config = {
|
|
12920
|
+
values: Object.fromEntries(node.values.filter((port) => Object.hasOwn(port, "value")).map((port) => [port.handle, port.value])),
|
|
12921
|
+
outputs: fieldsView(node.values.map(({ value: _value, ...port }) => port))
|
|
12922
|
+
};
|
|
12923
|
+
break;
|
|
12924
|
+
case "wait":
|
|
12925
|
+
case "approval":
|
|
12926
|
+
config = { inputs: fieldsView(node.inputDefinitions) };
|
|
12927
|
+
texts.prompt = node.prompt;
|
|
12928
|
+
break;
|
|
12929
|
+
case "webhook":
|
|
12930
|
+
config = {
|
|
12931
|
+
body: fieldsView(node.bodyFields),
|
|
12932
|
+
method: node.method,
|
|
12933
|
+
...node.options == null ? {} : { options: node.options }
|
|
12934
|
+
};
|
|
12935
|
+
break;
|
|
12936
|
+
case "cron":
|
|
12937
|
+
config = { schedule: node.cronTimes };
|
|
12938
|
+
break;
|
|
12939
|
+
case "error":
|
|
12940
|
+
config = node.sourceFlowIds == null ? {} : { sourceFlowIds: node.sourceFlowIds };
|
|
12941
|
+
break;
|
|
12942
|
+
case "poll":
|
|
12943
|
+
case "integration": config = {
|
|
12944
|
+
key: node.definition.key,
|
|
12945
|
+
...node.connectionId == null ? {} : { connectionId: node.connectionId },
|
|
12946
|
+
...node.kind == "poll" ? { schedule: node.pollTimes } : {}
|
|
12947
|
+
};
|
|
12948
|
+
}
|
|
12949
|
+
const edges = authoringEdges(content.document.graph.edges);
|
|
12950
|
+
return {
|
|
12951
|
+
ref,
|
|
12952
|
+
type,
|
|
12953
|
+
name: node.name ?? ref,
|
|
12954
|
+
readOnly: false,
|
|
12955
|
+
...node.description == null ? {} : { description: node.description },
|
|
12956
|
+
...node.icon == null ? {} : { icon: node.icon },
|
|
12957
|
+
..."timeoutMs" in node && node.timeoutMs != null ? { timeoutMs: node.timeoutMs } : {},
|
|
12958
|
+
..."maxExecutions" in node && node.maxExecutions != null ? { maxExecutions: node.maxExecutions } : {},
|
|
12959
|
+
config: json$2(config),
|
|
12960
|
+
texts: Object.fromEntries(Object.entries(texts).map(([field, text]) => [field, {
|
|
12961
|
+
lines: text.split("\n").length,
|
|
12962
|
+
characters: text.length
|
|
12963
|
+
}])),
|
|
12964
|
+
inputs: outwardSource(content, inputMappings(node)),
|
|
12965
|
+
inputPorts: fieldsView(Object.entries(inputDefinitions(node)).map(([handle, port]) => Object.assign({}, port, { handle }))),
|
|
12966
|
+
outputPorts: fieldsView(Object.entries(nodeOutputPorts(node)).map(([handle, port]) => Object.assign({}, port, { handle }))),
|
|
12967
|
+
...task != null && "executor" in task && task.executor.kind == "openapi" ? { authenticationChoices: openApiAuthenticationChoices(task.executor) } : {},
|
|
12968
|
+
incoming: edges.filter((e) => e.target == ref),
|
|
12969
|
+
outgoing: edges.filter((e) => e.source == ref)
|
|
12970
|
+
};
|
|
12971
|
+
}
|
|
12972
|
+
function textAt(content, node, field) {
|
|
12973
|
+
if (field == "code" && node.kind == "task" && "moduleId" in node.task) return content.modules[node.task.moduleId]?.source ?? fail("text.missing", "Node source is missing.");
|
|
12974
|
+
const task = taskAt(node);
|
|
12975
|
+
if (field == "prompt" && task != null && "executor" in task && task.executor.kind == "agent") return task.executor.prompt;
|
|
12976
|
+
if (field == "prompt" && (node.kind == "wait" || node.kind == "approval")) return node.prompt;
|
|
12977
|
+
return fail("text.unsupported", `This node has no ${field} field.`);
|
|
12978
|
+
}
|
|
12979
|
+
function readAuthoring(content, query = {}) {
|
|
12980
|
+
const q = authoringReadSchema.parse(query);
|
|
12981
|
+
if (q.text != null) {
|
|
12982
|
+
const lines = textAt(content, nodeAt(content, q.text.node), q.text.field).split("\n");
|
|
12983
|
+
const selected = lines.slice(q.text.start - 1, q.text.start - 1 + q.text.lines);
|
|
12984
|
+
let count = 0, characters = 0;
|
|
12985
|
+
for (const line of selected) {
|
|
12986
|
+
if (characters + line.length + 1 > 24e3) break;
|
|
12987
|
+
characters += line.length + 1;
|
|
12988
|
+
count++;
|
|
12989
|
+
}
|
|
12990
|
+
if (count == 0 && selected.length > 0) fail("text.line-too-large", "Selected line exceeds 24000 characters; use search to locate a smaller edit.", {
|
|
12991
|
+
node: q.text.node,
|
|
12992
|
+
field: q.text.field
|
|
12993
|
+
});
|
|
12994
|
+
const end = q.text.start - 1 + count;
|
|
12995
|
+
return { text: {
|
|
12996
|
+
...q.text,
|
|
12997
|
+
content: selected.slice(0, count).join("\n"),
|
|
12998
|
+
totalLines: lines.length,
|
|
12999
|
+
...end < lines.length ? { nextStart: end + 1 } : {},
|
|
13000
|
+
truncated: end < lines.length
|
|
13001
|
+
} };
|
|
13002
|
+
}
|
|
13003
|
+
if (q.nodes != null) return { nodes: q.nodes.map((ref) => authoringNode(content, ref)) };
|
|
13004
|
+
return {
|
|
13005
|
+
nodes: Object.keys(content.document.graph.nodes).map((ref) => {
|
|
13006
|
+
const node = authoringNode(content, ref);
|
|
13007
|
+
return {
|
|
13008
|
+
ref,
|
|
13009
|
+
type: node.type,
|
|
13010
|
+
name: node.name,
|
|
13011
|
+
readOnly: node.readOnly,
|
|
13012
|
+
inputHandles: Object.keys(node.inputPorts),
|
|
13013
|
+
outputHandles: Object.keys(node.outputPorts),
|
|
13014
|
+
inputs: compactValue(node.inputs),
|
|
13015
|
+
texts: node.texts
|
|
13016
|
+
};
|
|
13017
|
+
}),
|
|
13018
|
+
edges: authoringEdges(content.document.graph.edges)
|
|
13019
|
+
};
|
|
13020
|
+
}
|
|
13021
|
+
function compactValue(value, depth = 0) {
|
|
13022
|
+
if (depth >= 4 && value != null && typeof value == "object") return { truncated: true };
|
|
13023
|
+
if (typeof value == "string") return value.length > 160 ? {
|
|
13024
|
+
preview: value.slice(0, 160),
|
|
13025
|
+
truncated: true
|
|
13026
|
+
} : value;
|
|
13027
|
+
if (Array.isArray(value)) return value.length > 8 ? {
|
|
13028
|
+
preview: value.slice(0, 8).map((v) => compactValue(v, depth + 1)),
|
|
13029
|
+
truncated: true
|
|
13030
|
+
} : value.map((v) => compactValue(v, depth + 1));
|
|
13031
|
+
if (value != null && typeof value == "object") return Object.fromEntries([...Object.entries(value).slice(0, 8).map(([key, v]) => [key, compactValue(v, depth + 1)]), ...Object.keys(value).length > 8 ? [["truncated", true]] : []]);
|
|
13032
|
+
return value;
|
|
13033
|
+
}
|
|
13034
|
+
function searchAuthoring(content, query) {
|
|
13035
|
+
const q = authoringSearchSchema.parse(query), needle = q.query.toLowerCase();
|
|
13036
|
+
const matches = [];
|
|
13037
|
+
for (const [ref, node] of Object.entries(content.document.graph.nodes)) {
|
|
13038
|
+
const view = authoringNode(content, ref);
|
|
13039
|
+
if (q.type != null && q.type != view.type) continue;
|
|
13040
|
+
const fields = {
|
|
13041
|
+
name: view.name,
|
|
13042
|
+
description: view.description ?? "",
|
|
13043
|
+
inputs: JSON.stringify(view.inputs),
|
|
13044
|
+
config: JSON.stringify(view.config),
|
|
13045
|
+
...Object.fromEntries(Object.keys(view.texts).map((field) => [field, textAt(content, node, field)]))
|
|
13046
|
+
};
|
|
13047
|
+
for (const [field, value] of Object.entries(fields)) for (const [index, line] of value.split("\n").entries()) {
|
|
13048
|
+
const at = line.toLowerCase().indexOf(needle);
|
|
13049
|
+
if (at >= 0) matches.push({
|
|
13050
|
+
node: ref,
|
|
13051
|
+
field,
|
|
13052
|
+
line: index + 1,
|
|
13053
|
+
excerpt: line.slice(Math.max(0, at - 100), at + Math.max(needle.length, 100))
|
|
13054
|
+
});
|
|
13055
|
+
}
|
|
13056
|
+
}
|
|
13057
|
+
const end = q.offset + q.limit;
|
|
13058
|
+
return {
|
|
13059
|
+
matches: matches.slice(q.offset, end),
|
|
13060
|
+
total: matches.length,
|
|
13061
|
+
...end < matches.length ? { nextOffset: end } : {}
|
|
13062
|
+
};
|
|
13063
|
+
}
|
|
13064
|
+
function merge(base, patch) {
|
|
13065
|
+
if (patch == null || typeof patch != "object" || Array.isArray(patch)) return patch;
|
|
13066
|
+
const result = { ...record(base) };
|
|
13067
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
13068
|
+
if ([
|
|
13069
|
+
"__proto__",
|
|
13070
|
+
"constructor",
|
|
13071
|
+
"prototype"
|
|
13072
|
+
].includes(key)) fail("edit.invalid-field", `Invalid field ${key}.`);
|
|
13073
|
+
Object.defineProperty(result, key, {
|
|
13074
|
+
value: merge(result[key], value),
|
|
13075
|
+
enumerable: true,
|
|
13076
|
+
writable: true,
|
|
13077
|
+
configurable: true
|
|
13078
|
+
});
|
|
13079
|
+
}
|
|
13080
|
+
return result;
|
|
13081
|
+
}
|
|
13082
|
+
function clearPath(value, path) {
|
|
13083
|
+
let current = value;
|
|
13084
|
+
for (const part of path.slice(0, -1)) {
|
|
13085
|
+
if (!Object.hasOwn(current, part) || Array.isArray(current[part]) || current[part] == null || typeof current[part] != "object") fail("edit.invalid-field", `Cannot clear ${path.join(".")}.`);
|
|
13086
|
+
current = record(current[part]);
|
|
13087
|
+
}
|
|
13088
|
+
const last = path.at(-1);
|
|
13089
|
+
if (!Object.hasOwn(current, last)) fail("edit.invalid-field", `Cannot clear absent field ${path.join(".")}.`);
|
|
13090
|
+
delete current[last];
|
|
13091
|
+
}
|
|
13092
|
+
async function compileAuthoring(base, request, host) {
|
|
13093
|
+
const parsed = authoringRequestSchema.parse(request);
|
|
13094
|
+
let content = base, index = 0, sequence = 0;
|
|
13095
|
+
const operations = [], aliases = {};
|
|
13096
|
+
const touchedModules = /* @__PURE__ */ new Set();
|
|
13097
|
+
function fresh(label) {
|
|
13098
|
+
return host.id(`${index}:${label}:${sequence++}`);
|
|
13099
|
+
}
|
|
13100
|
+
function apply(changes) {
|
|
13101
|
+
const checked = decodeChangeOperations(changes);
|
|
13102
|
+
content = applyFlowChanges(content, checked);
|
|
13103
|
+
operations.push(...checked);
|
|
13104
|
+
}
|
|
13105
|
+
function resolve(ref) {
|
|
13106
|
+
return ref.startsWith("$") ? (Object.hasOwn(aliases, ref.slice(1)) ? aliases[ref.slice(1)] : void 0) ?? fail("node.alias-missing", `Unknown alias ${ref}.`) : ref;
|
|
13107
|
+
}
|
|
13108
|
+
function source(value) {
|
|
13109
|
+
if (value.kind == "output") {
|
|
13110
|
+
const ref = resolve(value.node);
|
|
13111
|
+
const choices = Object.keys(nodeOutputPorts(nodeAt(content, ref)));
|
|
13112
|
+
const port = value.port ?? (choices.length == 1 ? choices[0] : void 0);
|
|
13113
|
+
if (port == null) fail("source.port-required", "Choose an output name; this node does not have exactly one output.", {
|
|
13114
|
+
node: ref,
|
|
13115
|
+
choices
|
|
13116
|
+
});
|
|
13117
|
+
return {
|
|
13118
|
+
kind: "node",
|
|
13119
|
+
nodeId: ref,
|
|
13120
|
+
output: port,
|
|
13121
|
+
...value.field == null ? {} : { field: value.field }
|
|
13122
|
+
};
|
|
13123
|
+
}
|
|
13124
|
+
const existing = Object.entries(content.document.bindings).find(([, binding]) => binding.target == value.name);
|
|
13125
|
+
const bindingId = existing?.[0] ?? fresh("binding");
|
|
13126
|
+
if (existing == null) apply([{
|
|
13127
|
+
kind: "binding.create",
|
|
13128
|
+
bindingId,
|
|
13129
|
+
binding: {
|
|
13130
|
+
kind: "variable",
|
|
13131
|
+
target: value.name
|
|
13132
|
+
}
|
|
13133
|
+
}]);
|
|
13134
|
+
return {
|
|
13135
|
+
kind: "binding",
|
|
13136
|
+
bindingId
|
|
13137
|
+
};
|
|
13138
|
+
}
|
|
13139
|
+
function replace(ref, node) {
|
|
13140
|
+
const before = nodeAt(content, ref);
|
|
13141
|
+
if (!dequal(before, node)) apply([{
|
|
13142
|
+
kind: "graph.node.replace",
|
|
13143
|
+
nodeId: ref,
|
|
13144
|
+
before,
|
|
13145
|
+
node
|
|
13146
|
+
}]);
|
|
13147
|
+
}
|
|
13148
|
+
function taskNode(ref, task) {
|
|
13149
|
+
const node = nodeAt(content, ref);
|
|
13150
|
+
if (node.kind != "task" || !("executor" in node.task)) fail("node.invalid-type", "Expected a managed node.");
|
|
13151
|
+
replace(ref, {
|
|
13152
|
+
...node,
|
|
13153
|
+
task
|
|
13154
|
+
});
|
|
13155
|
+
}
|
|
13156
|
+
async function connectorTask(config, name) {
|
|
13157
|
+
const action = await host.action(String(config.action));
|
|
13158
|
+
return {
|
|
13159
|
+
name,
|
|
13160
|
+
executor: {
|
|
13161
|
+
kind: "connector",
|
|
13162
|
+
action: action.actionId,
|
|
13163
|
+
...config.connectionId == null ? {} : { connectionId: String(config.connectionId) }
|
|
13164
|
+
},
|
|
13165
|
+
inputs: Object.entries(action.inputs).map(([handle, port]) => Object.assign({ handle }, port)),
|
|
13166
|
+
outputs: Object.entries(action.outputs).map(([handle, port]) => Object.assign({ handle }, port))
|
|
13167
|
+
};
|
|
13168
|
+
}
|
|
13169
|
+
async function configure(ref, patch = {}, clear = []) {
|
|
13170
|
+
const node = nodeAt(content, ref), view = authoringNode(content, ref), type = view.type;
|
|
13171
|
+
const update = record(merge({
|
|
13172
|
+
name: view.name,
|
|
13173
|
+
...view.description == null ? {} : { description: view.description },
|
|
13174
|
+
...view.icon == null ? {} : { icon: view.icon },
|
|
13175
|
+
...view.timeoutMs == null ? {} : { timeoutMs: view.timeoutMs },
|
|
13176
|
+
...view.maxExecutions == null ? {} : { maxExecutions: view.maxExecutions },
|
|
13177
|
+
config: view.config
|
|
13178
|
+
}, patch));
|
|
13179
|
+
const explicit = (key) => Object.hasOwn(record(patch.config), key) || clear.some((path) => path[0] == "config" && path[1] == key);
|
|
13180
|
+
if (type == "openapi" && Object.hasOwn(record(patch.config), "authentication")) record(update.config).authentication = record(patch.config).authentication;
|
|
13181
|
+
for (const path of clear) clearPath(update, path);
|
|
13182
|
+
if (typeof update.name != "string") fail("node.name-required", "Node name cannot be cleared.");
|
|
13183
|
+
const config = authoringConfigurations[type].parse(update.config);
|
|
13184
|
+
const { config: _, ...metadata } = update;
|
|
13185
|
+
const { name: _name, description: _description, icon: _icon, ...rest } = node;
|
|
13186
|
+
let next = {
|
|
13187
|
+
...rest,
|
|
13188
|
+
...metadata
|
|
13189
|
+
};
|
|
13190
|
+
if ("inputs" in node) {
|
|
13191
|
+
const clean = { ...next };
|
|
13192
|
+
if (!Object.hasOwn(update, "timeoutMs")) delete clean.timeoutMs;
|
|
13193
|
+
if (!Object.hasOwn(update, "maxExecutions")) delete clean.maxExecutions;
|
|
13194
|
+
next = clean;
|
|
13195
|
+
} else if (update.timeoutMs != null || update.maxExecutions != null) fail("node.invalid-field", "Trigger nodes do not have execution limits.");
|
|
13196
|
+
function taskInputs(task, reserved = []) {
|
|
13197
|
+
if (node.kind != "task") throw new Error("Expected a task.");
|
|
13198
|
+
const fields = record(config.inputs);
|
|
13199
|
+
for (const key of reserved) if (Object.hasOwn(fields, key)) fail("input.reserved", `Configure ${key} through config.${key} or input.set.`, {
|
|
13200
|
+
node: ref,
|
|
13201
|
+
input: key
|
|
13202
|
+
});
|
|
13203
|
+
const extraNames = new Set(node.additionalInputs?.map((port) => port.handle) ?? []);
|
|
13204
|
+
const main = Object.fromEntries(Object.entries(fields).filter(([key]) => !extraNames.has(key)));
|
|
13205
|
+
for (const port of task.inputs) if ("handle" in port && (reserved.includes(port.handle) || extraNames.has(port.handle) && Object.hasOwn(fields, port.handle))) main[port.handle] = fieldsView([port])[port.handle];
|
|
13206
|
+
if (node.additionalInputs != null) {
|
|
13207
|
+
const extra = Object.fromEntries(Object.entries(fields).filter(([key]) => extraNames.has(key)));
|
|
13208
|
+
for (const port of node.additionalInputs) if (reserved.includes(port.handle)) extra[port.handle] = fieldsView([port])[port.handle];
|
|
13209
|
+
next = {
|
|
13210
|
+
...next,
|
|
13211
|
+
additionalInputs: fieldsToPorts(extra, node.additionalInputs)
|
|
13212
|
+
};
|
|
13213
|
+
}
|
|
13214
|
+
return fieldsToPorts(main, task.inputs);
|
|
13215
|
+
}
|
|
13216
|
+
if (node.kind == "task" && "moduleId" in node.task) {
|
|
13217
|
+
const inputs = taskInputs(node.task);
|
|
13218
|
+
next = {
|
|
13219
|
+
...next,
|
|
13220
|
+
task: {
|
|
13221
|
+
moduleId: node.task.moduleId,
|
|
13222
|
+
name: String(update.name),
|
|
13223
|
+
...config,
|
|
13224
|
+
inputs,
|
|
13225
|
+
outputs: fieldsToPorts(config.outputs, node.task.outputs)
|
|
13226
|
+
}
|
|
13227
|
+
};
|
|
13228
|
+
} else if (node.kind == "task" && "executor" in node.task) {
|
|
13229
|
+
const before = node.task;
|
|
13230
|
+
let task;
|
|
13231
|
+
if (type == "connector") task = config.action == (before.executor.kind == "connector" ? before.executor.action : "") ? {
|
|
13232
|
+
...before,
|
|
13233
|
+
name: String(update.name),
|
|
13234
|
+
executor: {
|
|
13235
|
+
kind: "connector",
|
|
13236
|
+
...config
|
|
13237
|
+
}
|
|
13238
|
+
} : await connectorTask(config, String(update.name));
|
|
13239
|
+
else if (type == "decision") task = decisionTask(config.questions, String(update.name));
|
|
13240
|
+
else if (type == "openapi") task = await prepareOpenApiTask(config, before, (url) => host.openapi(url), String(update.name), {
|
|
13241
|
+
authentication: explicit("authentication"),
|
|
13242
|
+
serverUrl: explicit("serverUrl")
|
|
13243
|
+
});
|
|
13244
|
+
else if (type == "llm") {
|
|
13245
|
+
task = prepareLlmConfiguration(config, before, String(update.name));
|
|
13246
|
+
task = {
|
|
13247
|
+
...task,
|
|
13248
|
+
inputs: taskInputs(task, llmReservedInputs)
|
|
13249
|
+
};
|
|
13250
|
+
} else {
|
|
13251
|
+
const { inputs: _inputs, resultSchema, notification, tools, ...executor } = config;
|
|
13252
|
+
const prepared = {
|
|
13253
|
+
...executor,
|
|
13254
|
+
kind: type,
|
|
13255
|
+
...before.executor.kind == "agent" ? { prompt: before.executor.prompt } : {}
|
|
13256
|
+
};
|
|
13257
|
+
if (type == "agent") {
|
|
13258
|
+
const previous = before.executor.kind == "agent" ? before.executor : void 0;
|
|
13259
|
+
Object.assign(prepared, { tools: await prepareAgentTools(tools, previous?.tools ?? [], (id) => host.action(id), () => fresh("tool")) });
|
|
13260
|
+
Reflect.deleteProperty(prepared, "notification");
|
|
13261
|
+
if (notification != null) {
|
|
13262
|
+
if (dequal(record(view.config).notification, notification) && previous?.notification != null) Object.assign(prepared, { notification: previous.notification });
|
|
13263
|
+
else {
|
|
13264
|
+
const settings = record(notification);
|
|
13265
|
+
const definition = await connectorTask(settings, `${update.name} notification`);
|
|
13266
|
+
Object.assign(prepared, { notification: {
|
|
13267
|
+
action: settings.action,
|
|
13268
|
+
...settings.connectionId == null ? {} : { connectionId: settings.connectionId },
|
|
13269
|
+
inputDefinitions: definition.inputs,
|
|
13270
|
+
messageHandle: settings.messageHandle,
|
|
13271
|
+
inputs: settings.inputs
|
|
13272
|
+
} });
|
|
13273
|
+
}
|
|
13274
|
+
}
|
|
13275
|
+
}
|
|
13276
|
+
const outputs = dequal(record(view.config).resultSchema, resultSchema) ? before.outputs : before.outputs.map((port) => "handle" in port ? {
|
|
13277
|
+
...port,
|
|
13278
|
+
jsonSchema: resultSchema
|
|
13279
|
+
} : port);
|
|
13280
|
+
task = {
|
|
13281
|
+
name: String(update.name),
|
|
13282
|
+
inputs: type == "agent" ? taskInputs(before) : before.inputs,
|
|
13283
|
+
outputs,
|
|
13284
|
+
executor: prepared
|
|
13285
|
+
};
|
|
13286
|
+
}
|
|
13287
|
+
next = {
|
|
13288
|
+
...next,
|
|
13289
|
+
task
|
|
13290
|
+
};
|
|
13291
|
+
} else switch (node.kind) {
|
|
13292
|
+
case "condition":
|
|
13293
|
+
next = {
|
|
13294
|
+
...next,
|
|
13295
|
+
...prepareConditionConfiguration(config, source)
|
|
13296
|
+
};
|
|
13297
|
+
break;
|
|
13298
|
+
case "value": {
|
|
13299
|
+
const fields = { ...record(config.outputs) };
|
|
13300
|
+
for (const key of Object.keys(record(config.values))) if (!Object.hasOwn(fields, key)) fields[key] = {};
|
|
13301
|
+
const values = fieldsToPorts(fields, node.values.map(({ value: _value, ...port }) => port)).filter((port) => "handle" in port).map((port) => Object.assign({}, port, Object.hasOwn(record(config.values), port.handle) ? { value: record(config.values)[port.handle] } : {}));
|
|
13302
|
+
next = {
|
|
13303
|
+
...next,
|
|
13304
|
+
values
|
|
13305
|
+
};
|
|
13306
|
+
break;
|
|
13307
|
+
}
|
|
13308
|
+
case "wait":
|
|
13309
|
+
case "approval":
|
|
13310
|
+
next = {
|
|
13311
|
+
...next,
|
|
13312
|
+
inputDefinitions: fieldsToPorts(config.inputs, node.inputDefinitions)
|
|
13313
|
+
};
|
|
13314
|
+
break;
|
|
13315
|
+
case "webhook": {
|
|
13316
|
+
const { body, ...settings } = config;
|
|
13317
|
+
const { options: _options, ...withoutOptions } = next;
|
|
13318
|
+
next = {
|
|
13319
|
+
...withoutOptions,
|
|
13320
|
+
...settings,
|
|
13321
|
+
bodyFields: fieldsToPorts(body, node.bodyFields)
|
|
13322
|
+
};
|
|
13323
|
+
break;
|
|
13324
|
+
}
|
|
13325
|
+
case "cron":
|
|
13326
|
+
next = {
|
|
13327
|
+
...next,
|
|
13328
|
+
cronTimes: config.schedule
|
|
13329
|
+
};
|
|
13330
|
+
break;
|
|
13331
|
+
case "poll":
|
|
13332
|
+
case "integration": {
|
|
13333
|
+
if (config.key != node.definition.key) fail("trigger.key-immutable", "Create a new node to change its Trigger type.");
|
|
13334
|
+
const { connectionId: _connection, ...withoutConnection } = next;
|
|
13335
|
+
next = {
|
|
13336
|
+
...withoutConnection,
|
|
13337
|
+
...config.connectionId == null ? {} : { connectionId: config.connectionId },
|
|
13338
|
+
...node.kind == "poll" ? { pollTimes: config.schedule } : {}
|
|
13339
|
+
};
|
|
13340
|
+
break;
|
|
13341
|
+
}
|
|
13342
|
+
default: {
|
|
13343
|
+
const fields = { ...next };
|
|
13344
|
+
for (const key of Object.keys(record(view.config))) delete fields[key];
|
|
13345
|
+
next = {
|
|
13346
|
+
...fields,
|
|
13347
|
+
...config
|
|
13348
|
+
};
|
|
13349
|
+
}
|
|
13350
|
+
}
|
|
13351
|
+
replace(ref, next);
|
|
13352
|
+
}
|
|
13353
|
+
async function setText(ref, field, text) {
|
|
13354
|
+
const node = nodeAt(content, ref), before = textAt(content, node, field);
|
|
13355
|
+
if (before == text) return;
|
|
13356
|
+
if (field == "code" && node.kind == "task" && "moduleId" in node.task) {
|
|
13357
|
+
const moduleId = node.task.moduleId, module = content.modules[moduleId];
|
|
13358
|
+
const shared = Object.values(content.document.graph.nodes).some((n) => n.kind == "task" && "moduleId" in n.task && n.task.moduleId == moduleId && n !== node) || Object.values(content.modules).some((m) => m.imports.includes(moduleId));
|
|
13359
|
+
const imports$1 = await imports(text);
|
|
13360
|
+
if (shared) {
|
|
13361
|
+
const id = fresh("module");
|
|
13362
|
+
apply([{
|
|
13363
|
+
kind: "module.create",
|
|
13364
|
+
moduleId: id,
|
|
13365
|
+
module: {
|
|
13366
|
+
...module,
|
|
13367
|
+
source: text,
|
|
13368
|
+
imports: imports$1
|
|
13369
|
+
}
|
|
13370
|
+
}]);
|
|
13371
|
+
replace(ref, {
|
|
13372
|
+
...node,
|
|
13373
|
+
task: {
|
|
13374
|
+
...node.task,
|
|
13375
|
+
moduleId: id
|
|
13376
|
+
}
|
|
13377
|
+
});
|
|
13378
|
+
} else apply([{
|
|
13379
|
+
kind: "module.source.replace",
|
|
13380
|
+
moduleId,
|
|
13381
|
+
beforeSource: before,
|
|
13382
|
+
beforeImports: module.imports,
|
|
13383
|
+
source: text,
|
|
13384
|
+
imports: imports$1
|
|
13385
|
+
}]);
|
|
13386
|
+
} else if (node.kind == "task" && "executor" in node.task) {
|
|
13387
|
+
const task = node.task;
|
|
13388
|
+
taskNode(ref, {
|
|
13389
|
+
...task,
|
|
13390
|
+
executor: {
|
|
13391
|
+
...task.executor,
|
|
13392
|
+
prompt: text
|
|
13393
|
+
}
|
|
13394
|
+
});
|
|
13395
|
+
} else if (node.kind == "wait" || node.kind == "approval") replace(ref, {
|
|
13396
|
+
...node,
|
|
13397
|
+
prompt: text
|
|
13398
|
+
});
|
|
13399
|
+
}
|
|
13400
|
+
async function setInput(ref, input, value) {
|
|
13401
|
+
const node = nodeAt(content, ref);
|
|
13402
|
+
if (node.kind == "condition") fail("input.unsupported", "Edit the branch condition operands through config.branches.", {
|
|
13403
|
+
node: ref,
|
|
13404
|
+
field: "config.branches"
|
|
13405
|
+
});
|
|
13406
|
+
if (node.kind == "poll" || node.kind == "integration") {
|
|
13407
|
+
if (!Object.hasOwn(inputDefinitions(node), input)) fail("input.not-found", `Unknown input ${input}.`, {
|
|
13408
|
+
node: ref,
|
|
13409
|
+
input,
|
|
13410
|
+
choices: Object.keys(inputDefinitions(node))
|
|
13411
|
+
});
|
|
13412
|
+
if (value.kind != "value" && value.kind != "unset" && value.kind != "default") fail("input.source-unsupported", "Trigger parameters accept only value, unset or default; they cannot depend on execution outputs or variables.", {
|
|
13413
|
+
node: ref,
|
|
13414
|
+
input,
|
|
13415
|
+
allowed: [
|
|
13416
|
+
"value",
|
|
13417
|
+
"unset",
|
|
13418
|
+
"default"
|
|
13419
|
+
]
|
|
13420
|
+
});
|
|
13421
|
+
const config = { ...node.config };
|
|
13422
|
+
if (value.kind == "default") delete config[input];
|
|
13423
|
+
else config[input] = value;
|
|
13424
|
+
replace(ref, {
|
|
13425
|
+
...node,
|
|
13426
|
+
config
|
|
13427
|
+
});
|
|
13428
|
+
return;
|
|
13429
|
+
}
|
|
13430
|
+
if (!Object.hasOwn(inputDefinitions(node), input)) {
|
|
13431
|
+
const type = typeOf(node);
|
|
13432
|
+
if (![
|
|
13433
|
+
"agent",
|
|
13434
|
+
"code",
|
|
13435
|
+
"llm",
|
|
13436
|
+
"wait",
|
|
13437
|
+
"approval"
|
|
13438
|
+
].includes(type)) fail("input.not-found", `Unknown input ${input}.`, {
|
|
13439
|
+
node: ref,
|
|
13440
|
+
input,
|
|
13441
|
+
choices: Object.keys(inputDefinitions(node))
|
|
13442
|
+
});
|
|
13443
|
+
if (type == "llm" && llmReservedInputs.includes(input)) fail("input.not-found", `Missing built-in LLM input ${input}.`, {
|
|
13444
|
+
node: ref,
|
|
13445
|
+
input,
|
|
13446
|
+
choices: Object.keys(inputDefinitions(node))
|
|
13447
|
+
});
|
|
13448
|
+
await configure(ref, { config: { inputs: { [input]: {} } } });
|
|
13449
|
+
}
|
|
13450
|
+
const mapping = value.kind == "default" ? void 0 : value.kind == "value" || value.kind == "unset" ? value : {
|
|
13451
|
+
kind: "sources",
|
|
13452
|
+
sources: (value.kind == "sources" ? value.sources : [value]).map(source)
|
|
13453
|
+
};
|
|
13454
|
+
const before = nodeInputMappings(nodeAt(content, ref))[input];
|
|
13455
|
+
if (!dequal(before, mapping)) apply([{
|
|
13456
|
+
kind: "graph.node.input.set",
|
|
13457
|
+
nodeId: ref,
|
|
13458
|
+
handle: input,
|
|
13459
|
+
before,
|
|
13460
|
+
...mapping == null ? {} : { value: mapping }
|
|
13461
|
+
}]);
|
|
13462
|
+
}
|
|
13463
|
+
for (const edit of parsed.edits) {
|
|
13464
|
+
try {
|
|
13465
|
+
switch (edit.op) {
|
|
13466
|
+
case "node.add": {
|
|
13467
|
+
if (Object.hasOwn(aliases, edit.as)) fail("node.alias-duplicate", `Duplicate alias ${edit.as}.`);
|
|
13468
|
+
const nodeId = host.id(`node:${edit.as}`), identity = {
|
|
13469
|
+
nodeId,
|
|
13470
|
+
moduleId: fresh("module")
|
|
13471
|
+
}, name = edit.name;
|
|
13472
|
+
aliases[edit.as] = nodeId;
|
|
13473
|
+
const config = edit.config ?? {};
|
|
13474
|
+
let changes;
|
|
13475
|
+
switch (edit.type) {
|
|
13476
|
+
case "code":
|
|
13477
|
+
changes = createCodeTask(identity, name, void 0, {
|
|
13478
|
+
inputs: [],
|
|
13479
|
+
outputs: config.outputs == null ? defaultCodeTaskPorts.outputs : []
|
|
13480
|
+
});
|
|
13481
|
+
break;
|
|
13482
|
+
case "agent":
|
|
13483
|
+
changes = createAgentTask(identity, name, {
|
|
13484
|
+
inputs: [],
|
|
13485
|
+
prompt: edit.prompt ?? ""
|
|
13486
|
+
});
|
|
13487
|
+
break;
|
|
13488
|
+
case "llm":
|
|
13489
|
+
changes = createLlmTask(identity, name, "chat", "Generated response.").map((change) => change.kind == "graph.node.create" && change.node.kind == "task" && "executor" in change.node.task ? Object.assign({}, change, { node: Object.assign({}, change.node, { task: initialAuthoringLlmTask(change.node.task) }) }) : change);
|
|
13490
|
+
break;
|
|
13491
|
+
case "decision":
|
|
13492
|
+
changes = createDecisionTask(identity, name);
|
|
13493
|
+
break;
|
|
13494
|
+
case "connector":
|
|
13495
|
+
changes = createManagedTask(identity, await connectorTask(config, name));
|
|
13496
|
+
break;
|
|
13497
|
+
case "openapi":
|
|
13498
|
+
changes = createManagedTask(identity, await prepareOpenApiTask(authoringConfigurations.openapi.parse(config), void 0, (url) => host.openapi(url), name));
|
|
13499
|
+
break;
|
|
13500
|
+
case "condition":
|
|
13501
|
+
changes = createCondition(nodeId, name);
|
|
13502
|
+
break;
|
|
13503
|
+
case "value":
|
|
13504
|
+
changes = createValue(nodeId, name, []);
|
|
13505
|
+
break;
|
|
13506
|
+
case "wait":
|
|
13507
|
+
changes = createWait(nodeId, name);
|
|
13508
|
+
break;
|
|
13509
|
+
case "approval":
|
|
13510
|
+
changes = createApproval(nodeId, name);
|
|
13511
|
+
break;
|
|
13512
|
+
case "poll":
|
|
13513
|
+
case "integration": {
|
|
13514
|
+
const definition = host.trigger(String(config.key));
|
|
13515
|
+
if (definition.type != edit.type) fail("trigger.type-mismatch", "Trigger key has a different type.");
|
|
13516
|
+
changes = createProviderTrigger(nodeId, definition, {
|
|
13517
|
+
name,
|
|
13518
|
+
config: {}
|
|
13519
|
+
});
|
|
13520
|
+
break;
|
|
13521
|
+
}
|
|
13522
|
+
default: changes = [{
|
|
13523
|
+
kind: "graph.node.create",
|
|
13524
|
+
nodeId,
|
|
13525
|
+
node: {
|
|
13526
|
+
kind: edit.type,
|
|
13527
|
+
name,
|
|
13528
|
+
...edit.type == "cron" ? { cronTimes: [{
|
|
13529
|
+
type: "every",
|
|
13530
|
+
unit: "hour",
|
|
13531
|
+
value: 1
|
|
13532
|
+
}] } : {},
|
|
13533
|
+
...edit.type == "webhook" ? {
|
|
13534
|
+
method: "POST",
|
|
13535
|
+
bodyFields: []
|
|
13536
|
+
} : {}
|
|
13537
|
+
}
|
|
13538
|
+
}];
|
|
13539
|
+
}
|
|
13540
|
+
apply(changes);
|
|
13541
|
+
await configure(nodeId, { config });
|
|
13542
|
+
const added = nodeAt(content, nodeId);
|
|
13543
|
+
if (added.kind == "task") replace(nodeId, {
|
|
13544
|
+
...added,
|
|
13545
|
+
inputs: {}
|
|
13546
|
+
});
|
|
13547
|
+
if (edit.code != null) await setText(nodeId, "code", edit.code);
|
|
13548
|
+
if (edit.prompt != null) await setText(nodeId, "prompt", edit.prompt);
|
|
13549
|
+
for (const [input, binding] of Object.entries(edit.inputs ?? {})) await setInput(nodeId, input, binding);
|
|
13550
|
+
break;
|
|
13551
|
+
}
|
|
13552
|
+
case "node.update":
|
|
13553
|
+
await configure(resolve(edit.node), edit.set, edit.clear);
|
|
13554
|
+
break;
|
|
13555
|
+
case "node.remove": {
|
|
13556
|
+
const ref = resolve(edit.node), node = nodeAt(content, ref);
|
|
13557
|
+
if (node.kind == "task" && "moduleId" in node.task) touchedModules.add(node.task.moduleId);
|
|
13558
|
+
apply([{
|
|
13559
|
+
kind: "graph.node.delete",
|
|
13560
|
+
nodeId: ref
|
|
13561
|
+
}]);
|
|
13562
|
+
break;
|
|
13563
|
+
}
|
|
13564
|
+
case "input.set":
|
|
13565
|
+
await setInput(resolve(edit.node), edit.input, edit.source);
|
|
13566
|
+
break;
|
|
13567
|
+
case "edge.connect":
|
|
13568
|
+
case "edge.disconnect": {
|
|
13569
|
+
const from = resolve(edit.source), to = resolve(edit.target);
|
|
13570
|
+
nodeAt(content, from);
|
|
13571
|
+
nodeAt(content, to);
|
|
13572
|
+
const edge = {
|
|
13573
|
+
source: from,
|
|
13574
|
+
target: to,
|
|
13575
|
+
...edit.branch == null ? {} : { sourceHandle: edit.branch }
|
|
13576
|
+
};
|
|
13577
|
+
const exists = content.document.graph.edges.some((e) => dequal(e, edge));
|
|
13578
|
+
if (edit.op == "edge.connect" != exists) apply([{
|
|
13579
|
+
kind: edit.op == "edge.connect" ? "graph.edge.connect" : "graph.edge.disconnect",
|
|
13580
|
+
edge
|
|
13581
|
+
}]);
|
|
13582
|
+
break;
|
|
13583
|
+
}
|
|
13584
|
+
case "text.set":
|
|
13585
|
+
await setText(resolve(edit.node), edit.field, edit.text);
|
|
13586
|
+
break;
|
|
13587
|
+
case "text.edit": {
|
|
13588
|
+
const ref = resolve(edit.node), value = textAt(content, nodeAt(content, ref), edit.field), count = value.split(edit.oldText).length - 1;
|
|
13589
|
+
if (count != 1) fail("text.match-count", `Expected one exact match, found ${count}. Read the field and include more context.`, {
|
|
13590
|
+
node: ref,
|
|
13591
|
+
field: edit.field,
|
|
13592
|
+
matches: count
|
|
13593
|
+
});
|
|
13594
|
+
await setText(ref, edit.field, value.replace(edit.oldText, () => edit.newText));
|
|
13595
|
+
break;
|
|
13596
|
+
}
|
|
13597
|
+
}
|
|
13598
|
+
} catch (error) {
|
|
13599
|
+
if (error instanceof AuthoringError || error instanceof AuthoringToolInputError || error instanceof AuthoringOpenApiAuthenticationError) throw new AuthoringError(error.code, error.message, {
|
|
13600
|
+
...error.details,
|
|
13601
|
+
editIndex: index
|
|
13602
|
+
});
|
|
13603
|
+
throw new AuthoringError("edit.invalid", error instanceof Error ? error.message : String(error), { editIndex: index });
|
|
13604
|
+
}
|
|
13605
|
+
index++;
|
|
13606
|
+
}
|
|
13607
|
+
for (const moduleId of touchedModules) if (!Object.values(content.document.graph.nodes).some((n) => n.kind == "task" && "moduleId" in n.task && n.task.moduleId == moduleId) && !Object.values(content.modules).some((m) => m.imports.includes(moduleId))) apply([{
|
|
13608
|
+
kind: "module.delete",
|
|
13609
|
+
moduleId
|
|
13610
|
+
}]);
|
|
13611
|
+
const cleaned = cleanVariableBindings(base, operations);
|
|
13612
|
+
return {
|
|
13613
|
+
operations: cleaned,
|
|
13614
|
+
content: cleaned.length == 0 ? base : applyFlowChanges(base, cleaned),
|
|
13615
|
+
nodes: aliases
|
|
13616
|
+
};
|
|
13617
|
+
}
|
|
13618
|
+
var escapePointer = (value) => value.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
13619
|
+
function authoringDiagnostics(content, diagnostics) {
|
|
13620
|
+
const nodes = Object.entries(content.document.graph.nodes);
|
|
13621
|
+
return diagnostics.map((diagnostic) => {
|
|
13622
|
+
const affected = nodes.filter(([id, node]) => {
|
|
13623
|
+
const roots = [`/document/graph/nodes/${escapePointer(id)}`];
|
|
13624
|
+
if (node.kind == "task" && "moduleId" in node.task) roots.push(`/modules/${escapePointer(node.task.moduleId)}`);
|
|
13625
|
+
return roots.some((root) => diagnostic.path == root || diagnostic.path.startsWith(`${root}/`));
|
|
13626
|
+
});
|
|
13627
|
+
const message = diagnostic.message.replace(/(CodeModule|Managed Task|Task|Binding) "([^"\n]+)"/g, (_, kind, id) => {
|
|
13628
|
+
if (kind == "Binding") return `Variable "${content.document.bindings[id]?.target ?? "unresolved"}"`;
|
|
13629
|
+
const owners = nodes.filter(([, n]) => n.kind == "task" && kind == "CodeModule" && "moduleId" in n.task && n.task.moduleId == id);
|
|
13630
|
+
return owners.length ? `${kind == "CodeModule" ? "Code for" : "Node"} ${owners.map(([ref, n]) => JSON.stringify(n.name ?? ref)).join(", ")}` : kind == "CodeModule" ? "Referenced code" : "Node configuration";
|
|
13631
|
+
}).replaceAll("CodeModule", "Code");
|
|
13632
|
+
const parts = diagnostic.path.split("/").map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
13633
|
+
return {
|
|
13634
|
+
code: diagnostic.code,
|
|
13635
|
+
message,
|
|
13636
|
+
nodes: affected.map(([id]) => id),
|
|
13637
|
+
field: affected[0] == null ? "config" : authoringDiagnosticField(content, affected[0][1], parts),
|
|
13638
|
+
...diagnostic.line ? {
|
|
13639
|
+
line: diagnostic.line,
|
|
13640
|
+
column: diagnostic.column
|
|
13641
|
+
} : {}
|
|
13642
|
+
};
|
|
13643
|
+
});
|
|
13644
|
+
}
|
|
13645
|
+
//#endregion
|
|
13646
|
+
//#region src/execution/common/wait.ts
|
|
13647
|
+
/** Shared by decision entry points, the editor, and durable decision storage. */
|
|
13648
|
+
var waitCommentSchema = string().trim().refine((value) => [...value].length <= 2e3, "Wait comment must contain at most 2,000 Unicode code points.").nullable().optional();
|
|
13649
|
+
//#endregion
|
|
11870
13650
|
//#region src/control/common/draftOperations.ts
|
|
11871
13651
|
var text = string().min(1);
|
|
11872
|
-
var json$1 = json$
|
|
13652
|
+
var json$1 = json$5();
|
|
11873
13653
|
var triggerCreate = strictObject({
|
|
11874
13654
|
kind: literal("graph.trigger.create"),
|
|
11875
13655
|
nodeId: text,
|
|
11876
13656
|
key: text,
|
|
11877
13657
|
connectionId: text.optional(),
|
|
11878
13658
|
name: text.optional(),
|
|
11879
|
-
config: record(text, json$1),
|
|
13659
|
+
config: record$3(text, json$1),
|
|
11880
13660
|
schedule: triggerScheduleSchema.readonly().optional()
|
|
11881
13661
|
});
|
|
11882
13662
|
function decodeDraftOperations(value) {
|
|
@@ -11901,7 +13681,7 @@ function resolveDraftOperations(operations, definition) {
|
|
|
11901
13681
|
if (operation.kind != "graph.trigger.create") return [operation];
|
|
11902
13682
|
const snapshot = definition(operation.key);
|
|
11903
13683
|
if (snapshot.type != "poll" && operation.schedule != null) throw new Error("Only Poll triggers accept a schedule.");
|
|
11904
|
-
return createProviderTrigger(
|
|
13684
|
+
return createProviderTrigger(operation.nodeId, snapshot, operation);
|
|
11905
13685
|
});
|
|
11906
13686
|
}
|
|
11907
13687
|
//#endregion
|
|
@@ -11935,7 +13715,6 @@ var eventSourceRevisionSchema = strictObject({
|
|
|
11935
13715
|
});
|
|
11936
13716
|
//#endregion
|
|
11937
13717
|
//#region src/control/common/authoringExamples.ts
|
|
11938
|
-
var target = { kind: "flow" };
|
|
11939
13718
|
var descriptions = {
|
|
11940
13719
|
"manual": "A Manual start node.",
|
|
11941
13720
|
"error": "A Flow Error node. Select upstream Flows, then publish and enable this Flow to listen for failures in their automatic runs.",
|
|
@@ -11964,26 +13743,20 @@ function authoringExample(name) {
|
|
|
11964
13743
|
let operations;
|
|
11965
13744
|
switch (name) {
|
|
11966
13745
|
case "error":
|
|
11967
|
-
operations = createBuiltinTrigger(
|
|
13746
|
+
operations = createBuiltinTrigger("error", {
|
|
11968
13747
|
kind: "error",
|
|
11969
13748
|
name: "Flow Error"
|
|
11970
13749
|
});
|
|
11971
13750
|
break;
|
|
11972
13751
|
case "decision":
|
|
11973
|
-
operations = createDecisionTask(
|
|
11974
|
-
nodeId: "decision",
|
|
11975
|
-
taskId: "decision-task"
|
|
11976
|
-
}, "AI Decision", [{
|
|
13752
|
+
operations = createDecisionTask({ nodeId: "decision" }, "AI Decision", [{
|
|
11977
13753
|
name: "needs_support",
|
|
11978
13754
|
type: "noul",
|
|
11979
13755
|
instructions: "Does the customer need support?"
|
|
11980
13756
|
}]);
|
|
11981
13757
|
break;
|
|
11982
13758
|
case "openapi":
|
|
11983
|
-
operations = createManagedTask(
|
|
11984
|
-
nodeId: "api",
|
|
11985
|
-
taskId: "api-task"
|
|
11986
|
-
}, openApiTask(selectOperation({
|
|
13759
|
+
operations = createManagedTask({ nodeId: "api" }, openApiTask(selectOperation({
|
|
11987
13760
|
openapi: "3.1.0",
|
|
11988
13761
|
paths: { "/items": { get: { responses: { "200": { content: { "application/json": { schema: {
|
|
11989
13762
|
type: "array",
|
|
@@ -11992,13 +13765,13 @@ function authoringExample(name) {
|
|
|
11992
13765
|
}, "https://api.example.com/openapi.json", "/items", "get")));
|
|
11993
13766
|
break;
|
|
11994
13767
|
case "manual":
|
|
11995
|
-
operations = createBuiltinTrigger(
|
|
13768
|
+
operations = createBuiltinTrigger("start", {
|
|
11996
13769
|
kind: "manual",
|
|
11997
13770
|
name: "Start"
|
|
11998
13771
|
});
|
|
11999
13772
|
break;
|
|
12000
13773
|
case "webhook":
|
|
12001
|
-
operations = createBuiltinTrigger(
|
|
13774
|
+
operations = createBuiltinTrigger("start", {
|
|
12002
13775
|
kind: "webhook",
|
|
12003
13776
|
method: "POST",
|
|
12004
13777
|
name: "Webhook",
|
|
@@ -12006,7 +13779,7 @@ function authoringExample(name) {
|
|
|
12006
13779
|
});
|
|
12007
13780
|
break;
|
|
12008
13781
|
case "cron":
|
|
12009
|
-
operations = createBuiltinTrigger(
|
|
13782
|
+
operations = createBuiltinTrigger("start", {
|
|
12010
13783
|
kind: "cron",
|
|
12011
13784
|
name: "Schedule",
|
|
12012
13785
|
cronTimes: [{
|
|
@@ -12040,10 +13813,7 @@ function authoringExample(name) {
|
|
|
12040
13813
|
}];
|
|
12041
13814
|
break;
|
|
12042
13815
|
case "agent":
|
|
12043
|
-
operations = createManagedTask(
|
|
12044
|
-
nodeId: "agent",
|
|
12045
|
-
taskId: "agent-task"
|
|
12046
|
-
}, {
|
|
13816
|
+
operations = createManagedTask({ nodeId: "agent" }, {
|
|
12047
13817
|
name: "Agent",
|
|
12048
13818
|
inputs: [{
|
|
12049
13819
|
handle: "input",
|
|
@@ -12067,10 +13837,7 @@ function authoringExample(name) {
|
|
|
12067
13837
|
});
|
|
12068
13838
|
break;
|
|
12069
13839
|
case "connector":
|
|
12070
|
-
operations = createManagedTask(
|
|
12071
|
-
nodeId: "notify",
|
|
12072
|
-
taskId: "notify-task"
|
|
12073
|
-
}, {
|
|
13840
|
+
operations = createManagedTask({ nodeId: "notify" }, {
|
|
12074
13841
|
name: "Notify",
|
|
12075
13842
|
executor: {
|
|
12076
13843
|
kind: "connector",
|
|
@@ -12087,7 +13854,7 @@ function authoringExample(name) {
|
|
|
12087
13854
|
});
|
|
12088
13855
|
break;
|
|
12089
13856
|
case "code":
|
|
12090
|
-
operations = createCodeTask(
|
|
13857
|
+
operations = createCodeTask({
|
|
12091
13858
|
nodeId: "format",
|
|
12092
13859
|
moduleId: "format-module"
|
|
12093
13860
|
}, "Format", {
|
|
@@ -12112,10 +13879,9 @@ function authoringExample(name) {
|
|
|
12112
13879
|
break;
|
|
12113
13880
|
case "condition":
|
|
12114
13881
|
operations = [
|
|
12115
|
-
...createCondition(
|
|
13882
|
+
...createCondition("condition", "Condition"),
|
|
12116
13883
|
{
|
|
12117
13884
|
kind: "graph.node.input.set",
|
|
12118
|
-
target,
|
|
12119
13885
|
nodeId: "condition",
|
|
12120
13886
|
handle: "0/0/0/left",
|
|
12121
13887
|
value: {
|
|
@@ -12125,7 +13891,6 @@ function authoringExample(name) {
|
|
|
12125
13891
|
},
|
|
12126
13892
|
{
|
|
12127
13893
|
kind: "graph.node.input.set",
|
|
12128
|
-
target,
|
|
12129
13894
|
nodeId: "condition",
|
|
12130
13895
|
handle: "0/0/0/right",
|
|
12131
13896
|
value: {
|
|
@@ -12136,20 +13901,17 @@ function authoringExample(name) {
|
|
|
12136
13901
|
];
|
|
12137
13902
|
break;
|
|
12138
13903
|
case "value":
|
|
12139
|
-
operations = createValue(
|
|
13904
|
+
operations = createValue("value", "Value");
|
|
12140
13905
|
break;
|
|
12141
13906
|
case "approval":
|
|
12142
|
-
operations = createApproval(
|
|
13907
|
+
operations = createApproval("approval", "Approve?");
|
|
12143
13908
|
break;
|
|
12144
13909
|
case "wait":
|
|
12145
|
-
operations = createWait(
|
|
13910
|
+
operations = createWait("wait", "Continue?");
|
|
12146
13911
|
break;
|
|
12147
13912
|
case "llm-chat":
|
|
12148
13913
|
case "llm-json":
|
|
12149
|
-
operations = createLlmTask(
|
|
12150
|
-
nodeId: "llm",
|
|
12151
|
-
taskId: "llm-task"
|
|
12152
|
-
}, "LLM", name == "llm-chat" ? "chat" : "json", "Generated response.");
|
|
13914
|
+
operations = createLlmTask({ nodeId: "llm" }, "LLM", name == "llm-chat" ? "chat" : "json", "Generated response.");
|
|
12153
13915
|
break;
|
|
12154
13916
|
case "poll-notification":
|
|
12155
13917
|
operations = [
|
|
@@ -12158,7 +13920,6 @@ function authoringExample(name) {
|
|
|
12158
13920
|
...authoringExample("connector").operations,
|
|
12159
13921
|
{
|
|
12160
13922
|
kind: "graph.edge.connect",
|
|
12161
|
-
target,
|
|
12162
13923
|
edge: {
|
|
12163
13924
|
source: "mail",
|
|
12164
13925
|
target: "format"
|
|
@@ -12166,7 +13927,6 @@ function authoringExample(name) {
|
|
|
12166
13927
|
},
|
|
12167
13928
|
{
|
|
12168
13929
|
kind: "graph.edge.connect",
|
|
12169
|
-
target,
|
|
12170
13930
|
edge: {
|
|
12171
13931
|
source: "format",
|
|
12172
13932
|
target: "notify"
|
|
@@ -12174,7 +13934,6 @@ function authoringExample(name) {
|
|
|
12174
13934
|
},
|
|
12175
13935
|
{
|
|
12176
13936
|
kind: "graph.node.input.set",
|
|
12177
|
-
target,
|
|
12178
13937
|
nodeId: "format",
|
|
12179
13938
|
handle: "events",
|
|
12180
13939
|
before: {
|
|
@@ -12192,7 +13951,6 @@ function authoringExample(name) {
|
|
|
12192
13951
|
},
|
|
12193
13952
|
{
|
|
12194
13953
|
kind: "graph.node.input.set",
|
|
12195
|
-
target,
|
|
12196
13954
|
nodeId: "notify",
|
|
12197
13955
|
handle: "text",
|
|
12198
13956
|
before: {
|
|
@@ -12220,16 +13978,21 @@ function authoringExample(name) {
|
|
|
12220
13978
|
//#endregion
|
|
12221
13979
|
//#region src/control/common/requests.ts
|
|
12222
13980
|
var waitActionBodySchema = strictObject({ comment: waitCommentSchema });
|
|
12223
|
-
var json = json$
|
|
13981
|
+
var json = json$5();
|
|
12224
13982
|
var id = string().min(1);
|
|
12225
13983
|
var version = literal(1);
|
|
12226
13984
|
var flowName = id.refine((value) => value == value.trim() && resourceNameIssue(value) == null, "Flow name is invalid.");
|
|
12227
|
-
var inputs = record(string(), record(string(), json));
|
|
13985
|
+
var inputs = record$3(string(), record$3(string(), json));
|
|
12228
13986
|
var trigger = strictObject({
|
|
12229
13987
|
nodeId: id,
|
|
12230
|
-
outputs: record(string(), json)
|
|
13988
|
+
outputs: record$3(string(), json)
|
|
12231
13989
|
});
|
|
12232
13990
|
var schemas = {
|
|
13991
|
+
authoringCheck: authoringCheckSchema,
|
|
13992
|
+
authoringEdit: authoringRequestSchema,
|
|
13993
|
+
authoringRead: authoringReadSchema,
|
|
13994
|
+
authoringSearch: authoringSearchSchema,
|
|
13995
|
+
authoringSchema: authoringSchemaQuery,
|
|
12233
13996
|
loadOpenApiDocument: strictObject({
|
|
12234
13997
|
url: string().min(1).max(8192),
|
|
12235
13998
|
version
|
|
@@ -12262,7 +14025,7 @@ var schemas = {
|
|
|
12262
14025
|
}),
|
|
12263
14026
|
updatePresentation: strictObject({
|
|
12264
14027
|
expectedRevision: int().positive(),
|
|
12265
|
-
value: record(string(), json),
|
|
14028
|
+
value: record$3(string(), json),
|
|
12266
14029
|
version
|
|
12267
14030
|
}),
|
|
12268
14031
|
checkFlow: strictObject({
|
|
@@ -12330,6 +14093,11 @@ function decoder(schema) {
|
|
|
12330
14093
|
return (value) => schema.parse(value);
|
|
12331
14094
|
}
|
|
12332
14095
|
var controlRequests = {
|
|
14096
|
+
authoringCheck: decoder(schemas.authoringCheck),
|
|
14097
|
+
authoringEdit: decoder(schemas.authoringEdit),
|
|
14098
|
+
authoringRead: decoder(schemas.authoringRead),
|
|
14099
|
+
authoringSearch: decoder(schemas.authoringSearch),
|
|
14100
|
+
authoringSchema: decoder(schemas.authoringSchema),
|
|
12333
14101
|
loadOpenApiDocument: decoder(schemas.loadOpenApiDocument),
|
|
12334
14102
|
createEventSource: decoder(schemas.createEventSource),
|
|
12335
14103
|
updateEventSource: decoder(schemas.updateEventSource),
|
|
@@ -12361,7 +14129,7 @@ var controlRequests = {
|
|
|
12361
14129
|
versionOnly: decoder(schemas.versionOnly)
|
|
12362
14130
|
};
|
|
12363
14131
|
function controlRequestSchema(name) {
|
|
12364
|
-
const schema = toJSONSchema(schemas[name]);
|
|
14132
|
+
const schema = toJSONSchema(schemas[name], { io: "input" });
|
|
12365
14133
|
if (name == "changeDraft") return {
|
|
12366
14134
|
...schema,
|
|
12367
14135
|
properties: {
|
|
@@ -12372,4 +14140,4 @@ function controlRequestSchema(name) {
|
|
|
12372
14140
|
return schema;
|
|
12373
14141
|
}
|
|
12374
14142
|
//#endregion
|
|
12375
|
-
export { authoringExample, authoringExamples, controlRequestSchema, controlRequests, decodeDraftOperations, draftOperationsSchema, resolveDraftOperations, waitActionBodySchema };
|
|
14143
|
+
export { AuthoringError, authoringCheckResponse, authoringCheckSchema, authoringConfigurations, authoringDiagnosticSchema, authoringDiagnostics, authoringEditResponse, authoringEditSchema, authoringExample, authoringExamples, authoringNode, authoringReadResponse, authoringReadSchema, authoringRequestContract, authoringRequestSchema, authoringSchema, authoringSchemaQuery, authoringSearchResponse, authoringSearchSchema, authoringSourceSchema, authoringTypes, compileAuthoring, controlRequestSchema, controlRequests, decodeDraftOperations, draftOperationsSchema, readAuthoring, resolveDraftOperations, searchAuthoring, waitActionBodySchema };
|