@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
|
@@ -2,7 +2,7 @@ import type { AgentInput, AgentTool, JsonValue, ManagedTaskDefinition, ManagedTa
|
|
|
2
2
|
export type AgentConfig = Extract<ManagedTaskExecutor, {
|
|
3
3
|
readonly kind: 'agent';
|
|
4
4
|
}>;
|
|
5
|
-
export declare function agentConfigIssues(task: ManagedTaskDefinition
|
|
5
|
+
export declare function agentConfigIssues(task: ManagedTaskDefinition): readonly string[];
|
|
6
6
|
export declare function agentInput(source: Exclude<AgentInput, {
|
|
7
7
|
readonly kind: 'model';
|
|
8
8
|
}>, input: Readonly<Record<string, JsonValue>>): JsonValue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FlowDocument,
|
|
1
|
+
import type { FlowDocument, RevisionContent } from '../browser/flow-change.js';
|
|
2
2
|
export interface ConnectionUsage {
|
|
3
3
|
readonly providerId: string;
|
|
4
4
|
readonly connectionId?: string;
|
|
@@ -6,7 +6,6 @@ export interface ConnectionUsage {
|
|
|
6
6
|
readonly triggerId?: string;
|
|
7
7
|
readonly nodeId: string;
|
|
8
8
|
readonly name: string;
|
|
9
|
-
readonly target: GraphTarget;
|
|
10
9
|
readonly kind: 'connector' | 'agent' | 'trigger' | 'notification' | 'code';
|
|
11
10
|
}
|
|
12
11
|
export declare function connectionUsage(document: FlowDocument): readonly ConnectionUsage[];
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { CodeModule, FlowDocument, Graph, Group, InputPort, JsonValue,
|
|
1
|
+
import type { CodeModule, FlowDocument, Graph, Group, InputPort, JsonValue, ManagedTaskDefinition, Port, RevisionContent, TriggerNode } from '@oomol-lab/open-flow/flow-change';
|
|
2
2
|
export { maxJsonDepth } from './flow-json.js';
|
|
3
3
|
export { decodeFlowDocument, decodeRevisionContent } from '../browser/flow-change-schema.js';
|
|
4
4
|
export declare function canonicalJsonBytes(value: JsonValue): Uint8Array;
|
|
5
5
|
export declare function digestBytes(bytes: Uint8Array): Promise<string>;
|
|
6
6
|
export declare function canonicalPorts(value: readonly (InputPort | Port | Group)[]): JsonValue;
|
|
7
|
-
export declare function canonicalOutputs(value: readonly (OutputMapping & Port)[]): JsonValue;
|
|
8
7
|
export declare function canonicalGraph(value: Graph): JsonValue;
|
|
9
8
|
export declare function canonicalRevisionGraph(content: RevisionContent, graph: Graph): JsonValue;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function canonicalTask(task: FlowDocument['tasks'][string]): JsonValue;
|
|
9
|
+
export declare function canonicalTask(task: ManagedTaskDefinition): JsonValue;
|
|
12
10
|
export declare function triggerRuntimeJson(trigger: TriggerNode): string;
|
|
13
11
|
export declare function canonicalDocument(document: FlowDocument): JsonValue;
|
|
14
12
|
export declare function canonicalModule(module: CodeModule): JsonValue;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/openapi/common/authBindings.ts
|
|
2
2
|
/** Never allow credentials to enter a Revision as literal node inputs. */
|
|
3
3
|
function assertOpenApiAuthBindings(document) {
|
|
4
|
-
for (const
|
|
5
|
-
if (node.kind != "task" || node.
|
|
6
|
-
for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") &&
|
|
4
|
+
for (const node of Object.values(document.graph.nodes)) {
|
|
5
|
+
if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
|
|
6
|
+
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.");
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
@@ -2813,6 +2813,9 @@ function handlePipeResult(left, next, ctx) {
|
|
|
2813
2813
|
issues: left.issues
|
|
2814
2814
|
}, ctx);
|
|
2815
2815
|
}
|
|
2816
|
+
var $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (inst, def) => {
|
|
2817
|
+
$ZodPipe.init(inst, def);
|
|
2818
|
+
});
|
|
2816
2819
|
var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
2817
2820
|
$ZodType.init(inst, def);
|
|
2818
2821
|
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
@@ -5637,6 +5640,10 @@ function pipe(in_, out) {
|
|
|
5637
5640
|
out
|
|
5638
5641
|
});
|
|
5639
5642
|
}
|
|
5643
|
+
var ZodPreprocess = /*@__PURE__*/ $constructor("ZodPreprocess", (inst, def) => {
|
|
5644
|
+
ZodPipe.init(inst, def);
|
|
5645
|
+
$ZodPreprocess.init(inst, def);
|
|
5646
|
+
});
|
|
5640
5647
|
var ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
5641
5648
|
$ZodReadonly.init(inst, def);
|
|
5642
5649
|
ZodType.init(inst, def);
|
|
@@ -5685,6 +5692,13 @@ function json$1(params) {
|
|
|
5685
5692
|
});
|
|
5686
5693
|
return jsonSchema;
|
|
5687
5694
|
}
|
|
5695
|
+
function preprocess(fn, schema) {
|
|
5696
|
+
return new ZodPreprocess({
|
|
5697
|
+
type: "pipe",
|
|
5698
|
+
in: transform(fn),
|
|
5699
|
+
out: schema
|
|
5700
|
+
});
|
|
5701
|
+
}
|
|
5688
5702
|
//#endregion
|
|
5689
5703
|
//#region src/json-schema-subset/utils.ts
|
|
5690
5704
|
var nextId = 0;
|
|
@@ -8332,7 +8346,7 @@ var isObject = (x) => x !== null && typeof x === "object";
|
|
|
8332
8346
|
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
8333
8347
|
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
8334
8348
|
//#endregion
|
|
8335
|
-
//#region src/
|
|
8349
|
+
//#region src/flow/common/schemaComparer.ts
|
|
8336
8350
|
function isStringLikeSchema(value) {
|
|
8337
8351
|
return toPlainObject(value)?.type === "string";
|
|
8338
8352
|
}
|
|
@@ -8578,24 +8592,15 @@ var group = object({
|
|
|
8578
8592
|
collapsed: boolean().optional(),
|
|
8579
8593
|
group: text
|
|
8580
8594
|
});
|
|
8581
|
-
var
|
|
8595
|
+
var source = union([object({
|
|
8582
8596
|
kind: literal("node"),
|
|
8583
8597
|
nodeId: text,
|
|
8584
8598
|
output: text,
|
|
8585
8599
|
field: text.optional()
|
|
8586
|
-
})
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
});
|
|
8591
|
-
var source = union([
|
|
8592
|
-
nodeSource,
|
|
8593
|
-
flowSource,
|
|
8594
|
-
object({
|
|
8595
|
-
kind: literal("binding"),
|
|
8596
|
-
bindingId: text
|
|
8597
|
-
})
|
|
8598
|
-
]);
|
|
8600
|
+
}), object({
|
|
8601
|
+
kind: literal("binding"),
|
|
8602
|
+
bindingId: text
|
|
8603
|
+
})]);
|
|
8599
8604
|
var fixedInput = union([object({ kind: literal("unset") }), object({
|
|
8600
8605
|
kind: literal("value"),
|
|
8601
8606
|
value: json
|
|
@@ -8681,7 +8686,7 @@ var decisionQuestion = discriminatedUnion("type", [
|
|
|
8681
8686
|
criteria: strings
|
|
8682
8687
|
})
|
|
8683
8688
|
]);
|
|
8684
|
-
var
|
|
8689
|
+
var managedFields = object({
|
|
8685
8690
|
...ports,
|
|
8686
8691
|
name: text,
|
|
8687
8692
|
executor: union([
|
|
@@ -8732,13 +8737,16 @@ var managed = object({
|
|
|
8732
8737
|
inputs: array(input.extend({ source: agentInput }))
|
|
8733
8738
|
})),
|
|
8734
8739
|
notification: object({
|
|
8735
|
-
|
|
8740
|
+
action: text,
|
|
8741
|
+
connectionId: text.optional(),
|
|
8742
|
+
inputDefinitions: array(input),
|
|
8736
8743
|
messageHandle: text,
|
|
8737
8744
|
inputs: record$1(text, agentValue)
|
|
8738
8745
|
}).optional()
|
|
8739
8746
|
})
|
|
8740
8747
|
])
|
|
8741
|
-
})
|
|
8748
|
+
});
|
|
8749
|
+
var managed = managedFields.transform(limitDecisionTask);
|
|
8742
8750
|
var operand = union([object({
|
|
8743
8751
|
kind: literal("value"),
|
|
8744
8752
|
value: json.optional(),
|
|
@@ -8855,21 +8863,10 @@ var node = union([
|
|
|
8855
8863
|
kind: literal("value"),
|
|
8856
8864
|
values: array(input)
|
|
8857
8865
|
}),
|
|
8858
|
-
object({
|
|
8859
|
-
...base,
|
|
8860
|
-
kind: literal("subflow"),
|
|
8861
|
-
subflowId: text
|
|
8862
|
-
}),
|
|
8863
8866
|
object({
|
|
8864
8867
|
...base,
|
|
8865
8868
|
kind: literal("task"),
|
|
8866
|
-
task: inline,
|
|
8867
|
-
additionalInputs: array(input).optional()
|
|
8868
|
-
}),
|
|
8869
|
-
object({
|
|
8870
|
-
...base,
|
|
8871
|
-
kind: literal("task"),
|
|
8872
|
-
taskId: text,
|
|
8869
|
+
task: union([inline, managed]),
|
|
8873
8870
|
additionalInputs: array(input).optional()
|
|
8874
8871
|
}),
|
|
8875
8872
|
strictObject({
|
|
@@ -8924,10 +8921,10 @@ var node = union([
|
|
|
8924
8921
|
})
|
|
8925
8922
|
})
|
|
8926
8923
|
]);
|
|
8927
|
-
|
|
8928
|
-
kind:
|
|
8929
|
-
|
|
8930
|
-
})
|
|
8924
|
+
strictObject(condition), strictObject(wait), strictObject(webhook), managedFields.shape.executor.options[0].omit({ kind: true }).strict(), managedFields.shape.executor.options[1].omit({ kind: true }).strict(), managedFields.shape.executor.options[2].omit({ kind: true }).strict(), managedFields.shape.executor.options[3].omit({ kind: true }).strict(), managedFields.shape.executor.options[4].omit({
|
|
8925
|
+
kind: true,
|
|
8926
|
+
notification: true
|
|
8927
|
+
}).strict();
|
|
8931
8928
|
var edge = object({
|
|
8932
8929
|
source: text,
|
|
8933
8930
|
target: text,
|
|
@@ -8935,13 +8932,8 @@ var edge = object({
|
|
|
8935
8932
|
});
|
|
8936
8933
|
var at = {
|
|
8937
8934
|
nodeId: text,
|
|
8938
|
-
target
|
|
8935
|
+
target: never().optional()
|
|
8939
8936
|
};
|
|
8940
|
-
var subflow = object({
|
|
8941
|
-
name: text,
|
|
8942
|
-
inputs: array(input),
|
|
8943
|
-
outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
|
|
8944
|
-
});
|
|
8945
8937
|
var graph = object({
|
|
8946
8938
|
nodes: record$1(text, node),
|
|
8947
8939
|
edges: array(edge).default([])
|
|
@@ -8955,17 +8947,16 @@ var module = object({
|
|
|
8955
8947
|
imports: strings,
|
|
8956
8948
|
source: text
|
|
8957
8949
|
});
|
|
8958
|
-
var document = object({
|
|
8950
|
+
var document = preprocess(rejectRetiredDefinitions, object({
|
|
8959
8951
|
bindings: record$1(text, binding),
|
|
8960
|
-
graph
|
|
8961
|
-
|
|
8962
|
-
tasks: record$1(text, managed)
|
|
8963
|
-
});
|
|
8952
|
+
graph
|
|
8953
|
+
}));
|
|
8964
8954
|
var revision = object({
|
|
8965
8955
|
modelVersion: union([
|
|
8966
8956
|
literal(2),
|
|
8967
8957
|
literal(4),
|
|
8968
|
-
literal(5)
|
|
8958
|
+
literal(5),
|
|
8959
|
+
literal(6)
|
|
8969
8960
|
]),
|
|
8970
8961
|
document,
|
|
8971
8962
|
modules: record$1(text, module)
|
|
@@ -8974,6 +8965,15 @@ var envelope = revision.extend({
|
|
|
8974
8965
|
kind: literal("open-flow-flow-revision"),
|
|
8975
8966
|
version: literal(1)
|
|
8976
8967
|
});
|
|
8968
|
+
function rejectRetiredDefinitions(value) {
|
|
8969
|
+
const candidate = record(value);
|
|
8970
|
+
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.");
|
|
8971
|
+
if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
|
|
8972
|
+
const subflows = candidate.subflows;
|
|
8973
|
+
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.");
|
|
8974
|
+
if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => record(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
|
|
8975
|
+
return value;
|
|
8976
|
+
}
|
|
8977
8977
|
function record(value) {
|
|
8978
8978
|
return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
8979
8979
|
}
|
|
@@ -9042,26 +9042,9 @@ function upgradeLegacyGraph(value) {
|
|
|
9042
9042
|
function upgradeLegacyDocument(value) {
|
|
9043
9043
|
const candidate = record(value);
|
|
9044
9044
|
const root = upgradeLegacyGraph(candidate.graph);
|
|
9045
|
-
const subflows = Object.fromEntries(Object.entries(record(candidate.subflows)).map(([id, subflowCandidate]) => {
|
|
9046
|
-
const legacySubflow = record(subflowCandidate);
|
|
9047
|
-
const upgraded = upgradeLegacyGraph(legacySubflow.graph);
|
|
9048
|
-
const outputs = Array.isArray(legacySubflow.outputs) ? legacySubflow.outputs.map((outputCandidate) => {
|
|
9049
|
-
const output = record(outputCandidate);
|
|
9050
|
-
return {
|
|
9051
|
-
...output,
|
|
9052
|
-
sources: upgradeLegacySources(output.sources, upgraded.resolutionIds)
|
|
9053
|
-
};
|
|
9054
|
-
}) : legacySubflow.outputs;
|
|
9055
|
-
return [id, {
|
|
9056
|
-
...legacySubflow,
|
|
9057
|
-
graph: upgraded.graph,
|
|
9058
|
-
outputs
|
|
9059
|
-
}];
|
|
9060
|
-
}));
|
|
9061
9045
|
return {
|
|
9062
9046
|
...candidate,
|
|
9063
|
-
graph: root.graph
|
|
9064
|
-
subflows
|
|
9047
|
+
graph: root.graph
|
|
9065
9048
|
};
|
|
9066
9049
|
}
|
|
9067
9050
|
function repairedEntries(value, schema, repair) {
|
|
@@ -9121,30 +9104,66 @@ function repairGraph(value, bindings) {
|
|
|
9121
9104
|
edges: Array.isArray(candidate.edges) ? candidate.edges.flatMap((edgeCandidate) => edge.safeParse(edgeCandidate).data ?? []) : []
|
|
9122
9105
|
};
|
|
9123
9106
|
}
|
|
9107
|
+
function upgradeTaskNodes(candidateDocument) {
|
|
9108
|
+
const definitions = record(candidateDocument.tasks);
|
|
9109
|
+
const sourceGraph = record(candidateDocument.graph);
|
|
9110
|
+
const nodes = Object.fromEntries(Object.entries(record(sourceGraph.nodes)).map(([id, value]) => {
|
|
9111
|
+
const candidateNode = record(value);
|
|
9112
|
+
if (candidateNode.kind != "task" || !Object.hasOwn(candidateNode, "taskId")) return [id, value];
|
|
9113
|
+
if (typeof candidateNode.taskId != "string" || candidateNode.task !== void 0) throw new TypeError("Invalid legacy Task reference.");
|
|
9114
|
+
const task = record(definitions[candidateNode.taskId]);
|
|
9115
|
+
const executor = record(task.executor);
|
|
9116
|
+
let upgraded = task;
|
|
9117
|
+
if (executor.kind == "agent" && executor.notification != null) {
|
|
9118
|
+
const notice = record(executor.notification);
|
|
9119
|
+
const connector = record(definitions[String(notice.taskId)]);
|
|
9120
|
+
const config = record(connector.executor);
|
|
9121
|
+
if (config.kind != "connector") throw new TypeError("Invalid legacy Agent notification reference.");
|
|
9122
|
+
const { taskId: _, ...rest } = notice;
|
|
9123
|
+
upgraded = {
|
|
9124
|
+
...task,
|
|
9125
|
+
executor: {
|
|
9126
|
+
...executor,
|
|
9127
|
+
notification: {
|
|
9128
|
+
...rest,
|
|
9129
|
+
action: config.action,
|
|
9130
|
+
connectionId: config.connectionId,
|
|
9131
|
+
inputDefinitions: Array.isArray(connector.inputs) ? connector.inputs.filter((candidatePort) => Object.hasOwn(record(candidatePort), "handle")) : connector.inputs
|
|
9132
|
+
}
|
|
9133
|
+
}
|
|
9134
|
+
};
|
|
9135
|
+
}
|
|
9136
|
+
const { taskId: _, ...rest } = candidateNode;
|
|
9137
|
+
return [id, {
|
|
9138
|
+
...rest,
|
|
9139
|
+
task: managed.parse(upgraded)
|
|
9140
|
+
}];
|
|
9141
|
+
}));
|
|
9142
|
+
const { tasks: _, ...rest } = candidateDocument;
|
|
9143
|
+
return {
|
|
9144
|
+
...rest,
|
|
9145
|
+
graph: {
|
|
9146
|
+
...sourceGraph,
|
|
9147
|
+
nodes
|
|
9148
|
+
}
|
|
9149
|
+
};
|
|
9150
|
+
}
|
|
9124
9151
|
/** Best-effort recovery for a parseable Revision envelope. Invalid collection entries are discarded. */
|
|
9125
9152
|
function repairRevisionEnvelope(value) {
|
|
9126
9153
|
checkJsonDepth(value);
|
|
9127
9154
|
const envelopeSource = record(value);
|
|
9128
9155
|
if (envelopeSource.kind != "open-flow-flow-revision" || envelopeSource.version != 1) throw new TypeError("The value is not an Open Flow Revision envelope.");
|
|
9129
|
-
if (typeof envelopeSource.modelVersion == "number" && envelopeSource.modelVersion >
|
|
9130
|
-
|
|
9156
|
+
if (typeof envelopeSource.modelVersion == "number" && envelopeSource.modelVersion > 6) throw new TypeError("The Flow model is newer than this package.");
|
|
9157
|
+
let sourceDocument = record(envelopeSource.modelVersion == 1 || envelopeSource.modelVersion == 2 ? upgradeLegacyDocument(envelopeSource.document) : envelopeSource.document);
|
|
9158
|
+
if (typeof envelopeSource.modelVersion == "number" && envelopeSource.modelVersion < 6) sourceDocument = upgradeTaskNodes(sourceDocument);
|
|
9159
|
+
rejectRetiredDefinitions(sourceDocument);
|
|
9131
9160
|
const bindings = record(sourceDocument.bindings);
|
|
9132
9161
|
const sourceGraph = repairGraph(sourceDocument.graph, bindings);
|
|
9133
|
-
const subflows = Object.fromEntries(Object.entries(record(sourceDocument.subflows)).flatMap(([id, subflowCandidate]) => {
|
|
9134
|
-
const legacySubflow = record(subflowCandidate);
|
|
9135
|
-
const result = subflow.extend({ graph }).safeParse({
|
|
9136
|
-
...legacySubflow,
|
|
9137
|
-
graph: repairGraph(legacySubflow.graph, bindings)
|
|
9138
|
-
});
|
|
9139
|
-
return result.success ? [[id, result.data]] : [];
|
|
9140
|
-
}));
|
|
9141
9162
|
return decodeRevisionContent({
|
|
9142
|
-
modelVersion:
|
|
9163
|
+
modelVersion: 6,
|
|
9143
9164
|
document: {
|
|
9144
9165
|
bindings: repairedEntries(sourceDocument.bindings, binding),
|
|
9145
|
-
graph: sourceGraph
|
|
9146
|
-
subflows,
|
|
9147
|
-
tasks: repairedEntries(sourceDocument.tasks, managed)
|
|
9166
|
+
graph: sourceGraph
|
|
9148
9167
|
},
|
|
9149
9168
|
modules: repairedEntries(envelopeSource.modules, module)
|
|
9150
9169
|
});
|
|
@@ -9156,7 +9175,7 @@ function decodeFlowDocument(value) {
|
|
|
9156
9175
|
function decodeRevisionContent(value) {
|
|
9157
9176
|
checkJsonDepth(value);
|
|
9158
9177
|
const content = revision.parse(value);
|
|
9159
|
-
|
|
9178
|
+
checkModelVersion(content);
|
|
9160
9179
|
assertOpenApiAuthBindings(content.document);
|
|
9161
9180
|
return content;
|
|
9162
9181
|
}
|
|
@@ -9168,7 +9187,7 @@ function decodeRevisionEnvelope(value) {
|
|
|
9168
9187
|
document: upgradeLegacyDocument(revisionSource.document)
|
|
9169
9188
|
} : value;
|
|
9170
9189
|
const content = envelope.parse(candidate);
|
|
9171
|
-
|
|
9190
|
+
checkModelVersion(content);
|
|
9172
9191
|
assertOpenApiAuthBindings(content.document);
|
|
9173
9192
|
return {
|
|
9174
9193
|
modelVersion: content.modelVersion,
|
|
@@ -9193,17 +9212,22 @@ var shapes = {
|
|
|
9193
9212
|
value: text
|
|
9194
9213
|
},
|
|
9195
9214
|
"graph.edge.connect": {
|
|
9196
|
-
|
|
9197
|
-
|
|
9215
|
+
edge,
|
|
9216
|
+
target: never().optional()
|
|
9198
9217
|
},
|
|
9199
9218
|
"graph.edge.disconnect": {
|
|
9200
|
-
|
|
9201
|
-
|
|
9219
|
+
edge,
|
|
9220
|
+
target: never().optional()
|
|
9202
9221
|
},
|
|
9203
9222
|
"graph.node.create": {
|
|
9204
9223
|
...at,
|
|
9205
9224
|
node
|
|
9206
9225
|
},
|
|
9226
|
+
"graph.node.replace": {
|
|
9227
|
+
...at,
|
|
9228
|
+
before: node,
|
|
9229
|
+
node
|
|
9230
|
+
},
|
|
9207
9231
|
"graph.node.delete": at,
|
|
9208
9232
|
"graph.node.field.set": union([
|
|
9209
9233
|
object({
|
|
@@ -9262,13 +9286,11 @@ var shapes = {
|
|
|
9262
9286
|
},
|
|
9263
9287
|
"graph.node.resolution.set": {
|
|
9264
9288
|
...at,
|
|
9265
|
-
target: object({ kind: literal("flow") }),
|
|
9266
9289
|
before: object(wait),
|
|
9267
9290
|
value: object(wait)
|
|
9268
9291
|
},
|
|
9269
9292
|
"graph.node.webhook.set": {
|
|
9270
9293
|
...at,
|
|
9271
|
-
target: object({ kind: literal("flow") }),
|
|
9272
9294
|
before: object(webhook),
|
|
9273
9295
|
value: object(webhook)
|
|
9274
9296
|
},
|
|
@@ -9315,58 +9337,19 @@ var shapes = {
|
|
|
9315
9337
|
imports: strings,
|
|
9316
9338
|
source: text
|
|
9317
9339
|
},
|
|
9318
|
-
"
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
"subflow.definition.set": {
|
|
9323
|
-
subflowId: text,
|
|
9324
|
-
before: subflow,
|
|
9325
|
-
definition: subflow
|
|
9326
|
-
},
|
|
9327
|
-
"subflow.delete": { subflowId: text },
|
|
9328
|
-
"task.create": {
|
|
9329
|
-
taskId: text,
|
|
9330
|
-
task: managed
|
|
9331
|
-
},
|
|
9332
|
-
"task.delete": { taskId: text },
|
|
9333
|
-
"task.connector.connection.set": {
|
|
9334
|
-
taskId: text,
|
|
9335
|
-
before: text.optional(),
|
|
9336
|
-
value: text.optional()
|
|
9337
|
-
},
|
|
9338
|
-
"task.decision.set": {
|
|
9339
|
-
taskId: text,
|
|
9340
|
-
before: managed,
|
|
9341
|
-
value: managed
|
|
9342
|
-
},
|
|
9343
|
-
"task.openapi.set": {
|
|
9344
|
-
taskId: text,
|
|
9345
|
-
before: managed,
|
|
9346
|
-
value: managed
|
|
9347
|
-
},
|
|
9348
|
-
"task.agent.set": {
|
|
9349
|
-
taskId: text,
|
|
9350
|
-
before: managed,
|
|
9351
|
-
value: managed
|
|
9352
|
-
},
|
|
9353
|
-
"task.llm.mode.set": {
|
|
9354
|
-
taskId: text,
|
|
9355
|
-
before: _enum(["chat", "json"]),
|
|
9356
|
-
value: _enum(["chat", "json"])
|
|
9357
|
-
},
|
|
9358
|
-
"task.name.set": {
|
|
9359
|
-
taskId: text,
|
|
9360
|
-
before: text,
|
|
9361
|
-
value: text
|
|
9340
|
+
"graph.node.task.set": {
|
|
9341
|
+
...at,
|
|
9342
|
+
before: union([inline, managed]),
|
|
9343
|
+
value: union([inline, managed])
|
|
9362
9344
|
}
|
|
9363
9345
|
};
|
|
9364
9346
|
array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
|
|
9365
9347
|
kind: literal(kind),
|
|
9366
9348
|
...shape
|
|
9367
9349
|
})])).values()])).min(1);
|
|
9368
|
-
function
|
|
9369
|
-
if (content.modelVersion <
|
|
9350
|
+
function checkModelVersion(content) {
|
|
9351
|
+
if (content.modelVersion < 6 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == "task" && "executor" in candidateNode.task)) throw new TypeError("Node-owned managed Tasks require Flow model version 6.");
|
|
9352
|
+
if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == "error")) throw new TypeError("Error workflows require Flow model version 5.");
|
|
9370
9353
|
}
|
|
9371
9354
|
//#endregion
|
|
9372
9355
|
//#region src/flow/common/encoding.ts
|
|
@@ -9420,15 +9403,6 @@ function canonicalInputMapping(value) {
|
|
|
9420
9403
|
function canonicalInputs(value) {
|
|
9421
9404
|
return Object.fromEntries(entries(value).map(([handle, mapping]) => [handle, canonicalInputMapping(mapping)]));
|
|
9422
9405
|
}
|
|
9423
|
-
function canonicalOutputs(value) {
|
|
9424
|
-
return value.map((output) => ({
|
|
9425
|
-
...output.description == null ? {} : { description: output.description },
|
|
9426
|
-
handle: output.handle,
|
|
9427
|
-
jsonSchema: output.jsonSchema,
|
|
9428
|
-
nullable: output.nullable,
|
|
9429
|
-
sources: output.sources.map((source) => ({ ...source }))
|
|
9430
|
-
}));
|
|
9431
|
-
}
|
|
9432
9406
|
function canonicalOperand(operand) {
|
|
9433
9407
|
return operand.kind === "source" ? {
|
|
9434
9408
|
kind: "source",
|
|
@@ -9464,18 +9438,13 @@ function canonicalNode(value) {
|
|
|
9464
9438
|
matchMode: value.matchMode,
|
|
9465
9439
|
kind: value.kind
|
|
9466
9440
|
};
|
|
9467
|
-
case "subflow": return {
|
|
9468
|
-
...common,
|
|
9469
|
-
kind: value.kind,
|
|
9470
|
-
subflowId: value.subflowId
|
|
9471
|
-
};
|
|
9472
9441
|
case "task": {
|
|
9473
|
-
const node = value.task
|
|
9442
|
+
const node = "moduleId" in value.task ? Object.assign({}, common, {
|
|
9474
9443
|
kind: value.kind,
|
|
9475
9444
|
task: canonicalInlineTask(value.task)
|
|
9476
9445
|
}) : Object.assign({}, common, {
|
|
9477
9446
|
kind: value.kind,
|
|
9478
|
-
|
|
9447
|
+
task: canonicalTask(value.task)
|
|
9479
9448
|
});
|
|
9480
9449
|
if (value.additionalInputs != null) node.additionalInputs = canonicalPorts(value.additionalInputs);
|
|
9481
9450
|
return node;
|
|
@@ -9557,22 +9526,9 @@ function canonicalLegacyGraph(graph) {
|
|
|
9557
9526
|
}))
|
|
9558
9527
|
};
|
|
9559
9528
|
}
|
|
9560
|
-
function canonicalLegacyOutputs(value, graph) {
|
|
9561
|
-
const resolutionIds = resolutionNodeIds(graph);
|
|
9562
|
-
return value.map((output) => ({
|
|
9563
|
-
...output.description == null ? {} : { description: output.description },
|
|
9564
|
-
handle: output.handle,
|
|
9565
|
-
jsonSchema: output.jsonSchema,
|
|
9566
|
-
nullable: output.nullable,
|
|
9567
|
-
sources: output.sources.map((source) => canonicalLegacySource(source, resolutionIds))
|
|
9568
|
-
}));
|
|
9569
|
-
}
|
|
9570
9529
|
function canonicalRevisionGraph(content, graph) {
|
|
9571
9530
|
return content.modelVersion == 2 ? canonicalLegacyGraph(graph) : canonicalGraph(graph);
|
|
9572
9531
|
}
|
|
9573
|
-
function canonicalRevisionOutputs(content, value, graph) {
|
|
9574
|
-
return content.modelVersion == 2 ? canonicalLegacyOutputs(value, graph) : canonicalOutputs(value);
|
|
9575
|
-
}
|
|
9576
9532
|
function canonicalTask(task) {
|
|
9577
9533
|
return {
|
|
9578
9534
|
executor: task.executor,
|
|
@@ -9682,29 +9638,22 @@ function triggerRuntimeJson(trigger) {
|
|
|
9682
9638
|
function canonicalDocument(document) {
|
|
9683
9639
|
return {
|
|
9684
9640
|
bindings: Object.fromEntries(entries(document.bindings)),
|
|
9685
|
-
graph: canonicalGraph(document.graph)
|
|
9686
|
-
subflows: Object.fromEntries(entries(document.subflows).map(([id, subflow]) => [id, {
|
|
9687
|
-
graph: canonicalGraph(subflow.graph),
|
|
9688
|
-
inputs: canonicalPorts(subflow.inputs),
|
|
9689
|
-
name: subflow.name,
|
|
9690
|
-
outputs: canonicalOutputs(subflow.outputs)
|
|
9691
|
-
}])),
|
|
9692
|
-
tasks: Object.fromEntries(entries(document.tasks).map(([id, task]) => [id, canonicalTask(task)]))
|
|
9641
|
+
graph: canonicalGraph(document.graph)
|
|
9693
9642
|
};
|
|
9694
9643
|
}
|
|
9695
9644
|
function canonicalRevisionDocument(content) {
|
|
9696
|
-
if (content.modelVersion
|
|
9645
|
+
if (content.modelVersion >= 6) return canonicalDocument(content.document);
|
|
9646
|
+
if (content.modelVersion != 2) return {
|
|
9647
|
+
...canonicalDocument(content.document),
|
|
9648
|
+
subflows: {},
|
|
9649
|
+
tasks: {}
|
|
9650
|
+
};
|
|
9697
9651
|
const { document } = content;
|
|
9698
9652
|
return {
|
|
9699
9653
|
bindings: Object.fromEntries(entries(document.bindings)),
|
|
9700
9654
|
graph: canonicalLegacyGraph(document.graph),
|
|
9701
|
-
subflows:
|
|
9702
|
-
|
|
9703
|
-
inputs: canonicalPorts(subflow.inputs),
|
|
9704
|
-
name: subflow.name,
|
|
9705
|
-
outputs: canonicalLegacyOutputs(subflow.outputs, subflow.graph)
|
|
9706
|
-
}])),
|
|
9707
|
-
tasks: Object.fromEntries(entries(document.tasks).map(([id, task]) => [id, canonicalTask(task)]))
|
|
9655
|
+
subflows: {},
|
|
9656
|
+
tasks: {}
|
|
9708
9657
|
};
|
|
9709
9658
|
}
|
|
9710
9659
|
function canonicalModule(module) {
|
|
@@ -9745,10 +9694,10 @@ function revisionRepairKind(bytes) {
|
|
|
9745
9694
|
return;
|
|
9746
9695
|
}
|
|
9747
9696
|
const source = value;
|
|
9748
|
-
return typeof source.modelVersion == "number" && source.modelVersion <
|
|
9697
|
+
return typeof source.modelVersion == "number" && source.modelVersion < 6 ? "upgrade" : "repair";
|
|
9749
9698
|
}
|
|
9750
9699
|
function repairRevision(bytes) {
|
|
9751
9700
|
return repairRevisionEnvelope(revisionValue(bytes));
|
|
9752
9701
|
}
|
|
9753
9702
|
//#endregion
|
|
9754
|
-
export { canonicalDocument, canonicalGraph, canonicalJsonBytes, canonicalModule,
|
|
9703
|
+
export { canonicalDocument, canonicalGraph, canonicalJsonBytes, canonicalModule, canonicalPorts, canonicalRevisionGraph, canonicalTask, decodeFlowDocument, decodeRevision, decodeRevisionContent, digestBytes, encodeRevision, maxJsonDepth, repairRevision, revisionRepairKind, triggerRuntimeJson };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Diagnostic
|
|
1
|
+
import type { Graph, GraphNode, InputPortDefinition, NodeSource, PortDefinition, RevisionContent, SchemaMismatch } from '../browser/flow-change.js';
|
|
2
|
+
import type { Diagnostic } from './flow-semantics.js';
|
|
3
3
|
export declare function isResolutionNode(node: GraphNode | undefined): node is Extract<GraphNode, {
|
|
4
4
|
readonly kind: 'approval' | 'wait';
|
|
5
5
|
}>;
|
|
6
|
-
export declare function nodeInputPorts(
|
|
6
|
+
export declare function nodeInputPorts(node: GraphNode): Readonly<Record<string, InputPortDefinition>>;
|
|
7
7
|
export declare function resolutionActions(node: Extract<GraphNode, {
|
|
8
8
|
readonly kind: 'approval' | 'wait';
|
|
9
9
|
}>): readonly ['continue'] | readonly ['approve', 'reject'];
|
|
10
10
|
export declare function resolutionOutputPorts(node: Extract<GraphNode, {
|
|
11
11
|
readonly kind: 'approval' | 'wait';
|
|
12
12
|
}>): Readonly<Record<string, PortDefinition>>;
|
|
13
|
-
export declare function nodeOutputPorts(
|
|
14
|
-
export declare function nodeOutputDescription(
|
|
13
|
+
export declare function nodeOutputPorts(node: GraphNode): Readonly<Record<string, PortDefinition>>;
|
|
14
|
+
export declare function nodeOutputDescription(graph: Graph, nodeId: string, output: string): string | undefined;
|
|
15
15
|
export declare function graphOrder(graph: Graph): readonly string[];
|
|
16
16
|
export type InputSourceCheck = {
|
|
17
17
|
readonly kind: 'available';
|
|
@@ -50,10 +50,10 @@ export interface InputSourcesCheck {
|
|
|
50
50
|
readonly sources: readonly InputSourceCheck[];
|
|
51
51
|
}
|
|
52
52
|
/** Check one saved binding without enumerating candidate ports. */
|
|
53
|
-
export declare function checkInputSource(
|
|
54
|
-
export declare function checkInputSources(
|
|
53
|
+
export declare function checkInputSource(graph: Graph, target: string, handle: string, source: Pick<NodeSource, 'nodeId' | 'output' | 'field'>): InputSourceCheck;
|
|
54
|
+
export declare function checkInputSources(graph: Graph, target: string, handle: string, sources: readonly Pick<NodeSource, 'nodeId' | 'output' | 'field'>[]): InputSourcesCheck;
|
|
55
55
|
/** Enumerate structurally available outputs while retaining their compatibility with one input. */
|
|
56
|
-
export declare function inputSourceCandidates(
|
|
57
|
-
export declare function availableOutputs(
|
|
58
|
-
export declare function validateFlowGraph(revision: RevisionContent
|
|
56
|
+
export declare function inputSourceCandidates(graph: Graph, target: string, handle: string): Readonly<Record<string, readonly InputSourceCandidate[]>>;
|
|
57
|
+
export declare function availableOutputs(graph: Graph, target: string, handle?: string): Readonly<Record<string, readonly string[]>>;
|
|
58
|
+
export declare function validateFlowGraph(revision: RevisionContent): readonly Diagnostic[];
|
|
59
59
|
export {};
|