@skaile/workspaces 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/README.md +32 -13
- package/dist/app-sdk/index.js +1 -1
- package/dist/{asset-feeds-DKNYRLED.js → asset-feeds-4AWAT5PW.js} +6 -6
- package/dist/{asset-feeds-DKNYRLED.js.map → asset-feeds-4AWAT5PW.js.map} +1 -1
- package/dist/asset-manager/catalog-deployer.js +1 -1
- package/dist/asset-manager/index.js +5 -5
- package/dist/asset-manager/installer.js +2 -2
- package/dist/bridge/drivers/claude-sdk.js +108 -5
- package/dist/bridge/drivers/claude-sdk.js.map +1 -1
- package/dist/bridge/drivers/codex.js +1 -1
- package/dist/bridge/drivers/continue.js +2 -2
- package/dist/bridge/drivers/echo.js +1 -1
- package/dist/bridge/drivers/gemini.js +3 -3
- package/dist/bridge/drivers/goose.js +2 -2
- package/dist/bridge/drivers/omp.js +1 -1
- package/dist/bridge/drivers/opencode.js +2 -2
- package/dist/bridge/drivers/qwen.js +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/bridge/src/drivers/claude-sdk.d.ts +33 -0
- package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
- package/dist/{chunk-CERGXDGG.js → chunk-2OCYS5EP.js} +3 -3
- package/dist/{chunk-CERGXDGG.js.map → chunk-2OCYS5EP.js.map} +1 -1
- package/dist/{chunk-W3Q37HEF.js → chunk-3HVASHBF.js} +3 -3
- package/dist/{chunk-W3Q37HEF.js.map → chunk-3HVASHBF.js.map} +1 -1
- package/dist/{chunk-UQ3RJKDD.js → chunk-4O2RAXKJ.js} +179 -52
- package/dist/chunk-4O2RAXKJ.js.map +1 -0
- package/dist/{chunk-DZM33LQO.js → chunk-4QROZZ5Z.js} +15 -3
- package/dist/chunk-4QROZZ5Z.js.map +1 -0
- package/dist/{chunk-G2ILW47R.js → chunk-57RFYEVM.js} +3 -3
- package/dist/{chunk-G2ILW47R.js.map → chunk-57RFYEVM.js.map} +1 -1
- package/dist/{chunk-BLWNI5KW.js → chunk-AKVAZ5CB.js} +2 -2
- package/dist/{chunk-BLWNI5KW.js.map → chunk-AKVAZ5CB.js.map} +1 -1
- package/dist/{chunk-BFIK6NPZ.js → chunk-AM5LFRXJ.js} +3 -3
- package/dist/{chunk-BFIK6NPZ.js.map → chunk-AM5LFRXJ.js.map} +1 -1
- package/dist/{chunk-RDE43ORT.js → chunk-D4VHBAJC.js} +4 -4
- package/dist/{chunk-RDE43ORT.js.map → chunk-D4VHBAJC.js.map} +1 -1
- package/dist/{chunk-PTS3QN5P.js → chunk-EEHOMCRU.js} +1021 -115
- package/dist/chunk-EEHOMCRU.js.map +1 -0
- package/dist/{chunk-CXX3UGJP.js → chunk-ENBTXMPL.js} +7 -7
- package/dist/{chunk-CXX3UGJP.js.map → chunk-ENBTXMPL.js.map} +1 -1
- package/dist/{chunk-LD6YGIKZ.js → chunk-EUWN4EK4.js} +60 -21
- package/dist/chunk-EUWN4EK4.js.map +1 -0
- package/dist/{chunk-FB4GPWYC.js → chunk-FKBQRV4J.js} +57 -16
- package/dist/chunk-FKBQRV4J.js.map +1 -0
- package/dist/{chunk-WG3L5VHF.js → chunk-HY3MBSNC.js} +2 -2
- package/dist/{chunk-WG3L5VHF.js.map → chunk-HY3MBSNC.js.map} +1 -1
- package/dist/{chunk-7IRH7MGV.js → chunk-IHX2SN35.js} +9 -9
- package/dist/{chunk-7IRH7MGV.js.map → chunk-IHX2SN35.js.map} +1 -1
- package/dist/{chunk-3F54MH2T.js → chunk-JAFEMG7W.js} +4 -4
- package/dist/{chunk-3F54MH2T.js.map → chunk-JAFEMG7W.js.map} +1 -1
- package/dist/{chunk-X6BPVUV2.js → chunk-L3TS7ZO4.js} +3 -3
- package/dist/{chunk-X6BPVUV2.js.map → chunk-L3TS7ZO4.js.map} +1 -1
- package/dist/{chunk-RIEXN7WA.js → chunk-MADO7PH5.js} +2 -2
- package/dist/{chunk-RIEXN7WA.js.map → chunk-MADO7PH5.js.map} +1 -1
- package/dist/{chunk-BCTU4TN7.js → chunk-MWFYXUFK.js} +3 -3
- package/dist/{chunk-BCTU4TN7.js.map → chunk-MWFYXUFK.js.map} +1 -1
- package/dist/{chunk-TK66CMXV.js → chunk-NU4E7C5I.js} +7 -3
- package/dist/chunk-NU4E7C5I.js.map +1 -0
- package/dist/{chunk-ZE2KEPE2.js → chunk-OEGHKO5N.js} +258 -24
- package/dist/chunk-OEGHKO5N.js.map +1 -0
- package/dist/{chunk-63ZPKREA.js → chunk-P43HBWKK.js} +11 -4
- package/dist/chunk-P43HBWKK.js.map +1 -0
- package/dist/{chunk-7UZGKVSK.js → chunk-PJ6INYDD.js} +3 -3
- package/dist/{chunk-7UZGKVSK.js.map → chunk-PJ6INYDD.js.map} +1 -1
- package/dist/{chunk-CA5CWLGN.js → chunk-PKEAYYEJ.js} +7 -4
- package/dist/chunk-PKEAYYEJ.js.map +1 -0
- package/dist/{chunk-ETFETLLB.js → chunk-UZYTSIX6.js} +6 -6
- package/dist/{chunk-ETFETLLB.js.map → chunk-UZYTSIX6.js.map} +1 -1
- package/dist/{chunk-SIF5F5SN.js → chunk-V4ZLZJFN.js} +3 -3
- package/dist/{chunk-SIF5F5SN.js.map → chunk-V4ZLZJFN.js.map} +1 -1
- package/dist/{chunk-ZR5Q4KZK.js → chunk-VNIKF66R.js} +3 -3
- package/dist/{chunk-ZR5Q4KZK.js.map → chunk-VNIKF66R.js.map} +1 -1
- package/dist/{chunk-CILACPUC.js → chunk-WSARNOPP.js} +5 -5
- package/dist/{chunk-CILACPUC.js.map → chunk-WSARNOPP.js.map} +1 -1
- package/dist/{chunk-TAJBFYCT.js → chunk-YWPEDILM.js} +83 -36
- package/dist/chunk-YWPEDILM.js.map +1 -0
- package/dist/{chunk-UNP4M5ZZ.js → chunk-ZR2X4SIG.js} +4 -4
- package/dist/{chunk-UNP4M5ZZ.js.map → chunk-ZR2X4SIG.js.map} +1 -1
- package/dist/cli/index.js +50 -50
- package/dist/connectors/config.js +1 -1
- package/dist/connectors/index.js +6 -6
- package/dist/core/index.js +1 -1
- package/dist/core/src/subprocess.d.ts +5 -1
- package/dist/core/src/subprocess.d.ts.map +1 -1
- package/dist/deploy/index.js +1 -1
- package/dist/discovery/index.js +1 -1
- package/dist/{ensure-sources-R6KW7K3M.js → ensure-sources-QF72HVUM.js} +8 -8
- package/dist/{ensure-sources-R6KW7K3M.js.map → ensure-sources-QF72HVUM.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +6 -6
- package/dist/factory-assets/connectors/deploy.js +6 -6
- package/dist/factory-assets/connectors/devserver.js +6 -6
- package/dist/factory-assets/connectors/flow/CONNECTOR.md +61 -14
- package/dist/factory-assets/connectors/flow/adapter.d.ts +78 -34
- package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/adapter.js +6 -6
- package/dist/factory-assets/connectors/flow/contract/expression.d.ts +55 -0
- package/dist/factory-assets/connectors/flow/contract/expression.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/contract/flow.v2.schema.json +61 -134
- package/dist/factory-assets/connectors/flow/contract/index.d.ts +1 -1
- package/dist/factory-assets/connectors/flow/contract/index.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/contract/normalize.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/contract/schema.d.ts +14 -2
- package/dist/factory-assets/connectors/flow/contract/schema.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/contract.js +2 -2
- package/dist/factory-assets/connectors/flow/engine/bindings.d.ts +9 -0
- package/dist/factory-assets/connectors/flow/engine/bindings.d.ts.map +1 -0
- package/dist/factory-assets/connectors/flow/engine/engine.d.ts +11 -6
- package/dist/factory-assets/connectors/flow/engine/engine.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine/flow-kind-provider.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine/index.d.ts +2 -0
- package/dist/factory-assets/connectors/flow/engine/index.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts +22 -0
- package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine/output-schema.d.ts +18 -0
- package/dist/factory-assets/connectors/flow/engine/output-schema.d.ts.map +1 -0
- package/dist/factory-assets/connectors/flow/engine/types.d.ts +21 -15
- package/dist/factory-assets/connectors/flow/engine/types.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine.js +4 -4
- package/dist/factory-assets/connectors/flow/index.d.ts +3 -0
- package/dist/factory-assets/connectors/flow/index.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/inline-sub-flow-host.d.ts +48 -0
- package/dist/factory-assets/connectors/flow/inline-sub-flow-host.d.ts.map +1 -0
- package/dist/factory-assets/connectors/flow/node-executor.d.ts +45 -0
- package/dist/factory-assets/connectors/flow/node-executor.d.ts.map +1 -0
- package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts +3 -2
- package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/prompt-fragments.js +2 -2
- package/dist/factory-assets/connectors/flow/run-flow.d.ts +10 -9
- package/dist/factory-assets/connectors/flow/run-flow.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/run-flow.js +7 -7
- package/dist/factory-assets/connectors/flow/sub-flow-runner.d.ts +73 -0
- package/dist/factory-assets/connectors/flow/sub-flow-runner.d.ts.map +1 -0
- package/dist/factory-assets/connectors/flow.js +6 -6
- package/dist/factory-assets/connectors/git.js +6 -6
- package/dist/factory-assets/connectors/gmail.js +6 -6
- package/dist/factory-assets/connectors/googledrive.js +6 -6
- package/dist/factory-assets/connectors/local.js +6 -6
- package/dist/factory-assets/connectors/mattermost.js +6 -6
- package/dist/factory-assets/connectors/memory.js +6 -6
- package/dist/factory-assets/connectors/minio.js +6 -6
- package/dist/factory-assets/connectors/postgres.js +6 -6
- package/dist/factory-assets/connectors/s3.js +6 -6
- package/dist/factory-assets/connectors/sharepoint.js +6 -6
- package/dist/factory-assets/connectors/sqlite.js +6 -6
- package/dist/factory-assets/connectors/static-server.js +6 -6
- package/dist/factory-assets/connectors/tunnel.js +6 -6
- package/dist/factory-assets/connectors/webdav.js +6 -6
- package/dist/factory-assets/connectors/xstate-store.js +6 -6
- package/dist/factory-assets/connectors/xstate.js +6 -6
- package/dist/{flows-F3CJNMK6.js → flows-YIW4HL3L.js} +4 -4
- package/dist/{flows-F3CJNMK6.js.map → flows-YIW4HL3L.js.map} +1 -1
- package/dist/{helpers-KPOLCGKX.js → helpers-LURCZHA4.js} +8 -8
- package/dist/{helpers-KPOLCGKX.js.map → helpers-LURCZHA4.js.map} +1 -1
- package/dist/library/index.js +3 -3
- package/dist/library/install.js +1 -1
- package/dist/{library-publish-ZAPZS64O.js → library-publish-2GMJM3NZ.js} +14 -14
- package/dist/{library-publish-ZAPZS64O.js.map → library-publish-2GMJM3NZ.js.map} +1 -1
- package/dist/{open-library-I4F2UNOY.js → open-library-POFOXZWH.js} +12 -12
- package/dist/{open-library-I4F2UNOY.js.map → open-library-POFOXZWH.js.map} +1 -1
- package/dist/{paths-KBACHM5B.js → paths-ZLX4ITAQ.js} +6 -6
- package/dist/{paths-KBACHM5B.js.map → paths-ZLX4ITAQ.js.map} +1 -1
- package/dist/{plugin-store-CYSNVZIX.js → plugin-store-YIMNH2FH.js} +3 -3
- package/dist/{plugin-store-CYSNVZIX.js.map → plugin-store-YIMNH2FH.js.map} +1 -1
- package/dist/{project-SIHZBTGB.js → project-GVOPZEJZ.js} +9 -9
- package/dist/{project-SIHZBTGB.js.map → project-GVOPZEJZ.js.map} +1 -1
- package/dist/resolver/index.js +1 -1
- package/dist/runner/index.js +15 -12
- package/dist/runner/src/serve.d.ts +3 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +5 -5
- package/dist/sdk/bridge.js +2 -2
- package/dist/sdk/core.js +1 -1
- package/dist/sdk/flow.js +4 -4
- package/dist/sdk/index.js +15 -12
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/resolver.js +1 -1
- package/dist/sdk/runner.js +15 -12
- package/dist/sdk/session.js +2 -2
- package/dist/sdk/types.js +1 -1
- package/dist/session/index.js +2 -2
- package/dist/session/src/dispatcher.d.ts.map +1 -1
- package/dist/{setup-KMBXMV25.js → setup-RHWARBBB.js} +5 -5
- package/dist/{setup-KMBXMV25.js.map → setup-RHWARBBB.js.map} +1 -1
- package/dist/{skills-LHS4TOKK.js → skills-HGVH6UTA.js} +5 -5
- package/dist/{skills-LHS4TOKK.js.map → skills-HGVH6UTA.js.map} +1 -1
- package/dist/{source-X226ZJPR.js → source-FB3T4IHP.js} +13 -13
- package/dist/{source-X226ZJPR.js.map → source-FB3T4IHP.js.map} +1 -1
- package/dist/{source-manifest-publish-N2QVUR5U.js → source-manifest-publish-XTRDVPSC.js} +15 -15
- package/dist/{source-manifest-publish-N2QVUR5U.js.map → source-manifest-publish-XTRDVPSC.js.map} +1 -1
- package/dist/tui/index.js +15 -12
- package/dist/tui/index.js.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/src/events.d.ts +20 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/flow.d.ts +26 -0
- package/dist/types/src/flow.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/protocol.d.ts +1 -0
- package/dist/types/src/protocol.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +12 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/workspace-plugin/adapters/mcp.js +4 -4
- package/dist/workspace-plugin/adapters/omp.js +7 -7
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-63ZPKREA.js.map +0 -1
- package/dist/chunk-CA5CWLGN.js.map +0 -1
- package/dist/chunk-DZM33LQO.js.map +0 -1
- package/dist/chunk-FB4GPWYC.js.map +0 -1
- package/dist/chunk-LD6YGIKZ.js.map +0 -1
- package/dist/chunk-PTS3QN5P.js.map +0 -1
- package/dist/chunk-TAJBFYCT.js.map +0 -1
- package/dist/chunk-TK66CMXV.js.map +0 -1
- package/dist/chunk-UQ3RJKDD.js.map +0 -1
- package/dist/chunk-ZE2KEPE2.js.map +0 -1
|
@@ -1,15 +1,69 @@
|
|
|
1
|
-
import { parseFlowDefinition } from './chunk-
|
|
2
|
-
import { nodeIsOptional, nodeSkillId, nodeLabel,
|
|
1
|
+
import { resolveFlowBindings, stableFlowJson, parseFlowDefinition, evaluateFlowExpression, inspectFlowExpression, collectFlowBindingExpressions } from './chunk-OEGHKO5N.js';
|
|
2
|
+
import { isAgentNode, nodeBindings, nodeIsOptional, nodeSkillId, nodeLabel, isActiveRuntimeNode } from './chunk-4QROZZ5Z.js';
|
|
3
3
|
import { assetSearchDirs } from './chunk-ZAP2BDHG.js';
|
|
4
|
+
import * as z2 from 'zod';
|
|
4
5
|
import * as path from 'path';
|
|
5
6
|
import path__default from 'path';
|
|
6
|
-
import * as z from 'zod';
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import { parse } from 'yaml';
|
|
9
9
|
|
|
10
|
+
// factory-assets/connectors/flow/engine/bindings.ts
|
|
11
|
+
function buildFlowExpressionContext(flow, snapshots) {
|
|
12
|
+
const nodes = {};
|
|
13
|
+
for (const node of flow.nodes) {
|
|
14
|
+
const snapshot = snapshots.get(node.id);
|
|
15
|
+
const output = snapshot?.status === "complete" && snapshot.output?.fields ? { fields: snapshot.output.fields } : void 0;
|
|
16
|
+
nodes[node.id] = { status: snapshot?.status ?? "not_started", output };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
flow: { input: flow.defaults?.run_input ?? {} },
|
|
20
|
+
defaults: flow.defaults,
|
|
21
|
+
nodes
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function resolveNodeBindings(flow, node, snapshots, flowInputOrigins = {}) {
|
|
25
|
+
const origins = Object.fromEntries(
|
|
26
|
+
flow.nodes.map((producer) => [producer.id, isAgentNode(producer) ? "agent" : "runtime"])
|
|
27
|
+
);
|
|
28
|
+
return resolveFlowBindings(
|
|
29
|
+
nodeBindings(node),
|
|
30
|
+
buildFlowExpressionContext(flow, snapshots),
|
|
31
|
+
origins,
|
|
32
|
+
flowInputOrigins
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function interpolateNodeInstruction(instruction, values) {
|
|
36
|
+
return instruction.replace(/\$\{([A-Za-z_][A-Za-z0-9_-]*)\}/g, (_placeholder, name) => {
|
|
37
|
+
if (!Object.hasOwn(values, name)) {
|
|
38
|
+
throw new Error(`Node instruction binding ${name} is missing`);
|
|
39
|
+
}
|
|
40
|
+
const value = values[name];
|
|
41
|
+
return typeof value === "string" ? value : stableFlowJson(value);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
10
45
|
// factory-assets/connectors/flow/engine/engine.ts
|
|
11
|
-
function
|
|
12
|
-
return flow.nodes.filter(
|
|
46
|
+
function activeRuntimeNodes(flow) {
|
|
47
|
+
return flow.nodes.filter(isActiveRuntimeNode);
|
|
48
|
+
}
|
|
49
|
+
function failedPreconditions(node, context) {
|
|
50
|
+
const failures = [];
|
|
51
|
+
for (const requirement of node.contract?.requires ?? []) {
|
|
52
|
+
const message = requirement.message ?? `Precondition failed: ${requirement.expr}`;
|
|
53
|
+
try {
|
|
54
|
+
if (!evaluateFlowExpression(requirement.expr, context)) {
|
|
55
|
+
failures.push({ expression: requirement.expr, message, reason: "false" });
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
failures.push({
|
|
59
|
+
expression: requirement.expr,
|
|
60
|
+
message,
|
|
61
|
+
reason: "error",
|
|
62
|
+
detail: error instanceof Error ? error.message : "Flow expression evaluation failed"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return failures;
|
|
13
67
|
}
|
|
14
68
|
function buildIncoming(edges) {
|
|
15
69
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -28,8 +82,14 @@ function buildOutgoing(edges) {
|
|
|
28
82
|
return map;
|
|
29
83
|
}
|
|
30
84
|
function computeFlowState(flow, completedIds, runningIds = /* @__PURE__ */ new Set(), skippedIds = /* @__PURE__ */ new Set()) {
|
|
31
|
-
const nodes =
|
|
85
|
+
const nodes = activeRuntimeNodes(flow);
|
|
32
86
|
const incoming = buildIncoming(flow.edges);
|
|
87
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const node of nodes) {
|
|
89
|
+
const status = completedIds.has(node.id) ? "complete" : runningIds.has(node.id) ? "running" : skippedIds.has(node.id) ? "skipped" : "not_started";
|
|
90
|
+
snapshots.set(node.id, { status });
|
|
91
|
+
}
|
|
92
|
+
const context = buildFlowExpressionContext(flow, snapshots);
|
|
33
93
|
const nodeStates = nodes.map((node) => {
|
|
34
94
|
const optional = nodeIsOptional(node);
|
|
35
95
|
const skillId = nodeSkillId(node);
|
|
@@ -42,7 +102,8 @@ function computeFlowState(flow, completedIds, runningIds = /* @__PURE__ */ new S
|
|
|
42
102
|
status: "complete",
|
|
43
103
|
optional,
|
|
44
104
|
canRun: false,
|
|
45
|
-
blockers: []
|
|
105
|
+
blockers: [],
|
|
106
|
+
failedPreconditions: []
|
|
46
107
|
};
|
|
47
108
|
}
|
|
48
109
|
if (runningIds.has(node.id)) {
|
|
@@ -53,7 +114,8 @@ function computeFlowState(flow, completedIds, runningIds = /* @__PURE__ */ new S
|
|
|
53
114
|
status: "running",
|
|
54
115
|
optional,
|
|
55
116
|
canRun: false,
|
|
56
|
-
blockers: []
|
|
117
|
+
blockers: [],
|
|
118
|
+
failedPreconditions: []
|
|
57
119
|
};
|
|
58
120
|
}
|
|
59
121
|
if (skippedIds.has(node.id)) {
|
|
@@ -64,19 +126,30 @@ function computeFlowState(flow, completedIds, runningIds = /* @__PURE__ */ new S
|
|
|
64
126
|
status: "skipped",
|
|
65
127
|
optional,
|
|
66
128
|
canRun: false,
|
|
67
|
-
blockers: []
|
|
129
|
+
blockers: [],
|
|
130
|
+
failedPreconditions: []
|
|
68
131
|
};
|
|
69
132
|
}
|
|
70
133
|
const edges = incoming.get(node.id) ?? [];
|
|
71
134
|
const hardBlockers = edges.filter((e) => e.type === "flow").filter((e) => !completedIds.has(e.source) && !skippedIds.has(e.source)).map((e) => e.source);
|
|
72
|
-
const
|
|
135
|
+
const preconditionFailures = failedPreconditions(node, context);
|
|
136
|
+
const canRun = hardBlockers.length === 0 && preconditionFailures.length === 0;
|
|
73
137
|
let status;
|
|
74
138
|
if (!canRun) {
|
|
75
139
|
status = "not_started";
|
|
76
140
|
} else {
|
|
77
141
|
status = "available";
|
|
78
142
|
}
|
|
79
|
-
return {
|
|
143
|
+
return {
|
|
144
|
+
nodeId: node.id,
|
|
145
|
+
skillId,
|
|
146
|
+
label,
|
|
147
|
+
status,
|
|
148
|
+
optional,
|
|
149
|
+
canRun,
|
|
150
|
+
blockers: hardBlockers,
|
|
151
|
+
failedPreconditions: preconditionFailures
|
|
152
|
+
};
|
|
80
153
|
});
|
|
81
154
|
new Map(nodeStates.map((s) => [s.nodeId, s]));
|
|
82
155
|
const available = nodeStates.filter((s) => s.status === "available").map((s) => s.nodeId);
|
|
@@ -89,8 +162,9 @@ function computeFlowState(flow, completedIds, runningIds = /* @__PURE__ */ new S
|
|
|
89
162
|
return { flowId: flow.id, nodes: nodeStates, available, completed, focus, done };
|
|
90
163
|
}
|
|
91
164
|
function computeFlowStateFromSnapshots(flow, snapshots) {
|
|
92
|
-
const nodes =
|
|
165
|
+
const nodes = activeRuntimeNodes(flow);
|
|
93
166
|
const incoming = buildIncoming(flow.edges);
|
|
167
|
+
const context = buildFlowExpressionContext(flow, snapshots);
|
|
94
168
|
const statusFor = (nodeId) => snapshots.get(nodeId)?.status ?? "not_started";
|
|
95
169
|
const passed = (nodeId) => {
|
|
96
170
|
const s = statusFor(nodeId);
|
|
@@ -105,9 +179,11 @@ function computeFlowStateFromSnapshots(flow, snapshots) {
|
|
|
105
179
|
const edges = incoming.get(node.id) ?? [];
|
|
106
180
|
const flowPreds = edges.filter((e) => e.type === "flow");
|
|
107
181
|
const hardBlockers = flowPreds.filter((e) => !passed(e.source)).map((e) => e.source);
|
|
182
|
+
const isAdmissionState = status === "not_started" || status === "available";
|
|
183
|
+
const preconditionFailures = isAdmissionState ? failedPreconditions(node, context) : [];
|
|
108
184
|
let effectiveStatus = status;
|
|
109
|
-
if (
|
|
110
|
-
effectiveStatus = "available";
|
|
185
|
+
if (isAdmissionState) {
|
|
186
|
+
effectiveStatus = hardBlockers.length === 0 && preconditionFailures.length === 0 ? "available" : "not_started";
|
|
111
187
|
}
|
|
112
188
|
return {
|
|
113
189
|
nodeId: node.id,
|
|
@@ -115,8 +191,9 @@ function computeFlowStateFromSnapshots(flow, snapshots) {
|
|
|
115
191
|
label,
|
|
116
192
|
status: effectiveStatus,
|
|
117
193
|
optional,
|
|
118
|
-
canRun: hardBlockers.length === 0 && effectiveStatus === "available",
|
|
194
|
+
canRun: hardBlockers.length === 0 && preconditionFailures.length === 0 && effectiveStatus === "available",
|
|
119
195
|
blockers: hardBlockers,
|
|
196
|
+
failedPreconditions: preconditionFailures,
|
|
120
197
|
approval: snapshot?.approval,
|
|
121
198
|
input: snapshot?.input,
|
|
122
199
|
output: snapshot?.output,
|
|
@@ -154,7 +231,7 @@ function resolveNextNodes(flow, justCompleted, completedIds, skippedIds = /* @__
|
|
|
154
231
|
return result;
|
|
155
232
|
}
|
|
156
233
|
function computeSkippable(flow, completedIds) {
|
|
157
|
-
const nodes =
|
|
234
|
+
const nodes = activeRuntimeNodes(flow);
|
|
158
235
|
const outgoing = buildOutgoing(flow.edges);
|
|
159
236
|
return nodes.filter((n) => !completedIds.has(n.id)).filter(nodeIsOptional).filter((n) => {
|
|
160
237
|
const deps = (outgoing.get(n.id) ?? []).filter((e) => e.type === "flow");
|
|
@@ -164,47 +241,93 @@ function computeSkippable(flow, completedIds) {
|
|
|
164
241
|
});
|
|
165
242
|
}).map((n) => n.id);
|
|
166
243
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
244
|
+
function consumerExpressions(node) {
|
|
245
|
+
const expressions = (node.contract?.requires ?? []).map(({ expr }) => expr);
|
|
246
|
+
expressions.push(...collectFlowBindingExpressions(node.contract?.input));
|
|
247
|
+
if (node.run?.kind === "router") {
|
|
248
|
+
expressions.push(...node.run.routes.map(({ when }) => when));
|
|
249
|
+
}
|
|
250
|
+
return expressions;
|
|
251
|
+
}
|
|
252
|
+
function readsProducerOutput(node, producerId) {
|
|
253
|
+
return consumerExpressions(node).some(
|
|
254
|
+
(expression) => inspectFlowExpression(expression, false).some(
|
|
255
|
+
({ path: path3 }) => path3.startsWith(`nodes.${producerId}.output.fields.`)
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
function getConsumedOutputSchema(flow, producerId) {
|
|
260
|
+
const producer = flow.nodes.find(({ id }) => id === producerId);
|
|
261
|
+
const schema = producer?.contract?.output?.fields;
|
|
262
|
+
if (!schema) return void 0;
|
|
263
|
+
return flow.nodes.some(
|
|
264
|
+
(consumer) => consumer.id !== producerId && readsProducerOutput(consumer, producerId)
|
|
265
|
+
) ? schema : void 0;
|
|
266
|
+
}
|
|
267
|
+
function validateConsumedNodeOutput(flow, producerId, fields) {
|
|
268
|
+
const schema = getConsumedOutputSchema(flow, producerId);
|
|
269
|
+
if (!schema) return { valid: true, issues: [] };
|
|
270
|
+
try {
|
|
271
|
+
const validator = z2.fromJSONSchema(schema);
|
|
272
|
+
const parsed = validator.safeParse(fields ?? {});
|
|
273
|
+
if (parsed.success) return { valid: true, issues: [] };
|
|
274
|
+
return {
|
|
275
|
+
valid: false,
|
|
276
|
+
issues: parsed.error.issues.map((issue) => {
|
|
277
|
+
const suffix = issue.path.map(String).join(".");
|
|
278
|
+
return `fields${suffix ? `.${suffix}` : ""}: ${issue.message}`;
|
|
279
|
+
}).sort()
|
|
280
|
+
};
|
|
281
|
+
} catch (error) {
|
|
282
|
+
return {
|
|
283
|
+
valid: false,
|
|
284
|
+
issues: [
|
|
285
|
+
`fields: invalid authored JSON Schema: ${error instanceof Error ? error.message : String(error)}`
|
|
286
|
+
]
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
var FlowNodeSchema = z2.looseObject({
|
|
291
|
+
id: z2.string().min(1),
|
|
292
|
+
skill: z2.string().optional(),
|
|
293
|
+
type: z2.string().optional(),
|
|
294
|
+
label: z2.string().optional(),
|
|
295
|
+
description: z2.string().optional(),
|
|
296
|
+
data: z2.looseObject({
|
|
297
|
+
optional: z2.boolean().optional(),
|
|
175
298
|
// Mandatory approval gate — autonomous mode cannot skip it.
|
|
176
|
-
approval:
|
|
299
|
+
approval: z2.looseObject({ mandatory: z2.boolean().optional() }).optional()
|
|
177
300
|
}).refine((d) => !(d.optional === true && d.approval?.mandatory === true), {
|
|
178
301
|
// A mandatory gate can never be skipped, so optional+mandatory is a
|
|
179
302
|
// contradiction — reject it rather than silently letting mandatory win.
|
|
180
303
|
message: "a node cannot be both optional and a mandatory approval gate"
|
|
181
304
|
}).optional()
|
|
182
305
|
});
|
|
183
|
-
var FlowEdgeSchema =
|
|
184
|
-
id:
|
|
185
|
-
source:
|
|
186
|
-
target:
|
|
187
|
-
condition:
|
|
306
|
+
var FlowEdgeSchema = z2.looseObject({
|
|
307
|
+
id: z2.string().optional(),
|
|
308
|
+
source: z2.string().min(1),
|
|
309
|
+
target: z2.string().min(1),
|
|
310
|
+
condition: z2.string().optional()
|
|
188
311
|
});
|
|
189
|
-
var FlowManifestSchema =
|
|
190
|
-
id:
|
|
191
|
-
version:
|
|
192
|
-
name:
|
|
193
|
-
description:
|
|
194
|
-
metadata:
|
|
195
|
-
tags:
|
|
196
|
-
stage:
|
|
197
|
-
icon:
|
|
198
|
-
category:
|
|
199
|
-
onboarding:
|
|
312
|
+
var FlowManifestSchema = z2.looseObject({
|
|
313
|
+
id: z2.string().min(1),
|
|
314
|
+
version: z2.string().optional(),
|
|
315
|
+
name: z2.string().min(1),
|
|
316
|
+
description: z2.string().optional(),
|
|
317
|
+
metadata: z2.looseObject({
|
|
318
|
+
tags: z2.array(z2.string()).optional(),
|
|
319
|
+
stage: z2.string().optional(),
|
|
320
|
+
icon: z2.string().optional(),
|
|
321
|
+
category: z2.string().optional(),
|
|
322
|
+
onboarding: z2.record(z2.string(), z2.unknown()).optional()
|
|
200
323
|
}).optional(),
|
|
201
|
-
globals:
|
|
202
|
-
modes:
|
|
203
|
-
tier_presets:
|
|
204
|
-
artifact_handoff:
|
|
205
|
-
entry:
|
|
206
|
-
nodes:
|
|
207
|
-
edges:
|
|
324
|
+
globals: z2.record(z2.string(), z2.unknown()).optional(),
|
|
325
|
+
modes: z2.record(z2.string(), z2.unknown()).optional(),
|
|
326
|
+
tier_presets: z2.record(z2.string(), z2.record(z2.string(), z2.unknown())).optional(),
|
|
327
|
+
artifact_handoff: z2.unknown().optional(),
|
|
328
|
+
entry: z2.string().optional(),
|
|
329
|
+
nodes: z2.array(FlowNodeSchema).optional(),
|
|
330
|
+
edges: z2.array(FlowEdgeSchema).optional()
|
|
208
331
|
});
|
|
209
332
|
function validateFlow(data) {
|
|
210
333
|
const result = FlowManifestSchema.safeParse(data);
|
|
@@ -258,13 +381,17 @@ var flowKindProvider = {
|
|
|
258
381
|
if (typeof asset === "string") add(asset, "nodes[].run.assets");
|
|
259
382
|
}
|
|
260
383
|
}
|
|
384
|
+
if (run.kind === "sub-flow" && typeof run.flow === "string") {
|
|
385
|
+
const flowRef = run.flow.startsWith("flow:") ? run.flow : `flow:${run.flow}`;
|
|
386
|
+
add(flowRef, "nodes[].run.flow");
|
|
387
|
+
}
|
|
261
388
|
const skill = typeof data.skill === "string" ? data.skill : n.skill;
|
|
262
389
|
if (typeof skill === "string") {
|
|
263
390
|
add(skill, "nodes[].data.skill");
|
|
264
391
|
}
|
|
265
392
|
const subFlow = typeof data.flow === "string" ? data.flow : n.flow;
|
|
266
393
|
if (typeof subFlow === "string") {
|
|
267
|
-
add(subFlow
|
|
394
|
+
add(subFlow.startsWith("flow:") ? subFlow : `flow:${subFlow}`, "nodes[].data.flow");
|
|
268
395
|
}
|
|
269
396
|
}
|
|
270
397
|
}
|
|
@@ -314,6 +441,6 @@ function loadAllFlows(aiResourcesRoot) {
|
|
|
314
441
|
return [...byId.values()];
|
|
315
442
|
}
|
|
316
443
|
|
|
317
|
-
export { FlowManifestSchema, computeFlowState, computeFlowStateFromSnapshots, computeSkippable, flowKindProvider, isBlocking, loadAllFlows, loadFlow, loadFlowsFromDir, resolveNextNodes, validateFlow };
|
|
318
|
-
//# sourceMappingURL=chunk-
|
|
319
|
-
//# sourceMappingURL=chunk-
|
|
444
|
+
export { FlowManifestSchema, buildFlowExpressionContext, computeFlowState, computeFlowStateFromSnapshots, computeSkippable, flowKindProvider, getConsumedOutputSchema, interpolateNodeInstruction, isBlocking, loadAllFlows, loadFlow, loadFlowsFromDir, resolveNextNodes, resolveNodeBindings, validateConsumedNodeOutput, validateFlow };
|
|
445
|
+
//# sourceMappingURL=chunk-4O2RAXKJ.js.map
|
|
446
|
+
//# sourceMappingURL=chunk-4O2RAXKJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../factory-assets/connectors/flow/engine/bindings.ts","../factory-assets/connectors/flow/engine/engine.ts","../factory-assets/connectors/flow/engine/output-schema.ts","../factory-assets/connectors/flow/engine/flow-manifest.ts","../factory-assets/connectors/flow/engine/flow-kind-provider.ts","../factory-assets/connectors/flow/engine/loader.ts"],"names":["path","z","parseYaml"],"mappings":";;;;;;;;;;AAWO,SAAS,0BAAA,CACd,MACA,SAAA,EACuB;AACvB,EAAA,MAAM,QAAwC,EAAC;AAC/C,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,KAAA,EAAO;AAC7B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;AAC1B","file":"chunk-4O2RAXKJ.js","sourcesContent":["import {\n resolveFlowBindings,\n stableFlowJson,\n type BindingOrigin,\n type FlowExpressionContext,\n type ResolvedNodeBindings,\n} from \"../contract/expression.js\";\nimport { isAgentNode, nodeBindings } from \"./node-shape.js\";\nimport type { FlowDefinition, FlowNode, NodeExecutionSnapshot } from \"./types.js\";\n\n/** Build the bounded expression context from immutable definition and snapshot state. */\nexport function buildFlowExpressionContext(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): FlowExpressionContext {\n const nodes: FlowExpressionContext[\"nodes\"] = {};\n for (const node of flow.nodes) {\n const snapshot = snapshots.get(node.id);\n const output =\n snapshot?.status === \"complete\" && snapshot.output?.fields\n ? { fields: snapshot.output.fields }\n : undefined;\n nodes[node.id] = { status: snapshot?.status ?? \"not_started\", output };\n }\n return {\n flow: { input: flow.defaults?.run_input ?? {} },\n defaults: flow.defaults,\n nodes,\n };\n}\n\n/** Resolve one node's named inputs and derive their runtime/agent origins. */\nexport function resolveNodeBindings(\n flow: FlowDefinition,\n node: FlowNode,\n snapshots: Map<string, NodeExecutionSnapshot>,\n flowInputOrigins: Record<string, BindingOrigin[]> = {},\n): ResolvedNodeBindings {\n const origins = Object.fromEntries(\n flow.nodes.map((producer) => [producer.id, isAgentNode(producer) ? \"agent\" : \"runtime\"]),\n ) as Record<string, \"agent\" | \"runtime\">;\n return resolveFlowBindings(\n nodeBindings(node),\n buildFlowExpressionContext(flow, snapshots),\n origins,\n flowInputOrigins,\n );\n}\n\n/** Interpolate named, already-resolved binding values into an agent instruction. */\nexport function interpolateNodeInstruction(\n instruction: string,\n values: Record<string, unknown>,\n): string {\n return instruction.replace(/\\$\\{([A-Za-z_][A-Za-z0-9_-]*)\\}/g, (_placeholder, name: string) => {\n if (!Object.hasOwn(values, name)) {\n throw new Error(`Node instruction binding ${name} is missing`);\n }\n const value = values[name];\n return typeof value === \"string\" ? value : stableFlowJson(value);\n });\n}\n","import type {\n FlowDefinition,\n FlowEdge,\n FlowNode,\n FlowState,\n NodeExecutionSnapshot,\n NodePreconditionFailure,\n NodeState,\n NodeStatus,\n} from \"./types.js\";\nimport { evaluateFlowExpression, type FlowExpressionContext } from \"../contract/expression.js\";\nimport { buildFlowExpressionContext } from \"./bindings.js\";\nimport { isActiveRuntimeNode, nodeIsOptional, nodeLabel, nodeSkillId } from \"./node-shape.js\";\n\n// ---------------------------------------------------------------------------\n// Core engine — stateless, pure functions\n// ---------------------------------------------------------------------------\n\n/** Return nodes with state owned by the current runtime. */\nfunction activeRuntimeNodes(flow: FlowDefinition): FlowNode[] {\n return flow.nodes.filter(isActiveRuntimeNode);\n}\n\n/** Evaluate every authored admission condition without mutating runtime state. */\nfunction failedPreconditions(\n node: FlowNode,\n context: FlowExpressionContext,\n): NodePreconditionFailure[] {\n const failures: NodePreconditionFailure[] = [];\n for (const requirement of node.contract?.requires ?? []) {\n const message = requirement.message ?? `Precondition failed: ${requirement.expr}`;\n try {\n if (!evaluateFlowExpression(requirement.expr, context)) {\n failures.push({ expression: requirement.expr, message, reason: \"false\" });\n }\n } catch (error) {\n failures.push({\n expression: requirement.expr,\n message,\n reason: \"error\",\n detail: error instanceof Error ? error.message : \"Flow expression evaluation failed\",\n });\n }\n }\n return failures;\n}\n\n/** Build adjacency: target → sources[] (incoming edges per node) */\nfunction buildIncoming(edges: FlowEdge[]): Map<string, FlowEdge[]> {\n const map = new Map<string, FlowEdge[]>();\n for (const edge of edges) {\n if (!map.has(edge.target)) map.set(edge.target, []);\n map.get(edge.target)!.push(edge);\n }\n return map;\n}\n\n/** Build adjacency: source → targets[] (outgoing edges per node) */\nfunction buildOutgoing(edges: FlowEdge[]): Map<string, FlowEdge[]> {\n const map = new Map<string, FlowEdge[]>();\n for (const edge of edges) {\n if (!map.has(edge.source)) map.set(edge.source, []);\n map.get(edge.source)!.push(edge);\n }\n return map;\n}\n\n/**\n * Compute the full {@link FlowState} from a flow definition and caller-supplied node ID sets.\n *\n * This is the primary engine function. It is stateless and side-effect-free — calling it\n * twice with the same arguments always returns an equivalent result.\n *\n * Edge semantics applied during computation:\n * - `'flow'` — hard dependency: target cannot start until source is `complete` or `skipped`.\n * - `'parallel'` — soft dependency: target may run while source is still running.\n * - `'optional'` — advisory: target can start regardless of source state.\n *\n * A node is `available` when every incoming `'flow'`-type edge has a complete or skipped source\n * and every authored precondition evaluates true.\n * A node is `not_started` when at least one hard predecessor is still pending.\n * The flow is `done` when every non-optional node is `complete` or `skipped`.\n *\n * This set-based overload has statuses but no completed output fields. Use\n * {@link computeFlowStateFromSnapshots} when a precondition reads node output.\n *\n * Prefer {@link computeFlowStateFromSnapshots} for callers that track full `NodeExecution`\n * state (interaction statuses such as `awaiting_approval`, `awaiting_input`, `failed`).\n *\n * @param flow - The parsed flow definition.\n * @param completedIds - Set of node IDs that have finished successfully.\n * @param runningIds - Set of node IDs currently executing. Defaults to an empty set.\n * @param skippedIds - Set of node IDs that were explicitly skipped. Skipped nodes count\n * as satisfied for downstream dependency checks. Defaults to an empty set.\n * @returns A {@link FlowState} describing every active runtime node.\n * @docLink packages/flow-engine/concepts#compute-flow-state\n */\nexport function computeFlowState(\n flow: FlowDefinition,\n completedIds: Set<string>,\n runningIds: Set<string> = new Set(),\n skippedIds: Set<string> = new Set(),\n): FlowState {\n const nodes = activeRuntimeNodes(flow);\n const incoming = buildIncoming(flow.edges);\n const snapshots = new Map<string, NodeExecutionSnapshot>();\n for (const node of nodes) {\n const status: NodeStatus = completedIds.has(node.id)\n ? \"complete\"\n : runningIds.has(node.id)\n ? \"running\"\n : skippedIds.has(node.id)\n ? \"skipped\"\n : \"not_started\";\n snapshots.set(node.id, { status });\n }\n const context = buildFlowExpressionContext(flow, snapshots);\n\n const nodeStates: NodeState[] = nodes.map((node) => {\n const optional = nodeIsOptional(node);\n const skillId = nodeSkillId(node);\n const label = nodeLabel(node);\n\n if (completedIds.has(node.id)) {\n return {\n nodeId: node.id,\n skillId,\n label,\n status: \"complete\",\n optional,\n canRun: false,\n blockers: [],\n failedPreconditions: [],\n };\n }\n if (runningIds.has(node.id)) {\n return {\n nodeId: node.id,\n skillId,\n label,\n status: \"running\",\n optional,\n canRun: false,\n blockers: [],\n failedPreconditions: [],\n };\n }\n if (skippedIds.has(node.id)) {\n return {\n nodeId: node.id,\n skillId,\n label,\n status: \"skipped\",\n optional,\n canRun: false,\n blockers: [],\n failedPreconditions: [],\n };\n }\n\n const edges = incoming.get(node.id) ?? [];\n\n // Hard blockers: flow-type edges whose source is neither complete nor skipped\n const hardBlockers = edges\n .filter((e) => e.type === \"flow\")\n .filter((e) => !completedIds.has(e.source) && !skippedIds.has(e.source))\n .map((e) => e.source);\n\n const preconditionFailures = failedPreconditions(node, context);\n const canRun = hardBlockers.length === 0 && preconditionFailures.length === 0;\n\n let status: NodeStatus;\n if (!canRun) {\n status = \"not_started\";\n } else {\n status = \"available\";\n }\n\n return {\n nodeId: node.id,\n skillId,\n label,\n status,\n optional,\n canRun,\n blockers: hardBlockers,\n failedPreconditions: preconditionFailures,\n };\n });\n\n const _stateMap = new Map(nodeStates.map((s) => [s.nodeId, s]));\n\n const available = nodeStates.filter((s) => s.status === \"available\").map((s) => s.nodeId);\n const completed = nodeStates.filter((s) => s.status === \"complete\").map((s) => s.nodeId);\n const focus = nodeStates\n .filter(\n (s) =>\n s.status === \"running\" || s.status === \"awaiting_approval\" || s.status === \"awaiting_input\",\n )\n .map((s) => s.nodeId);\n\n // Flow is done when all required nodes are complete or skipped\n const requiredNodes = nodes.filter((n) => !nodeIsOptional(n));\n const done = requiredNodes.every((n) => completedIds.has(n.id) || skippedIds.has(n.id));\n\n return { flowId: flow.id, nodes: nodeStates, available, completed, focus, done };\n}\n\n/**\n * Snapshot-based variant of {@link computeFlowState}.\n *\n * Accepts a map of `NodeExecutionSnapshot` values carrying the current status and\n * interaction metadata for every node the caller knows about. Nodes absent from the\n * map are treated as `not_started`.\n *\n * This is the preferred API for the turn-based runner, which has a full `FlowExecution`\n * and needs to convey richer statuses (`awaiting_approval`, `awaiting_input`, `failed`)\n * back to the engine so downstream availability is computed correctly.\n *\n * Engine semantics:\n * - A node is `available` when all its incoming `'flow'`-type predecessors are `complete`\n * or `skipped`. Any other upstream status — including `awaiting_approval`,\n * `awaiting_input`, and `failed` — is treated as blocking. Every authored precondition\n * must also evaluate true against the snapshot expression context.\n * - A `failed` optional node does **not** block its dependents.\n * - The flow is `done` when every non-optional node is `complete` or `skipped`. A single\n * required node stuck in `failed` keeps `done` false.\n *\n * @param flow - The parsed flow definition.\n * @param snapshots - Map from node ID to its current {@link NodeExecutionSnapshot}.\n * Missing entries default to `not_started` with no interaction metadata.\n * @returns A {@link FlowState} describing every active runtime node,\n * including interaction fields (`approval`, `input`, `output`, `error`) copied\n * from the matching snapshot.\n * @docLink packages/flow-engine/concepts#compute-flow-state-from-snapshots\n */\nexport function computeFlowStateFromSnapshots(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): FlowState {\n const nodes = activeRuntimeNodes(flow);\n const incoming = buildIncoming(flow.edges);\n const context = buildFlowExpressionContext(flow, snapshots);\n\n /** Resolve the effective status for a node — defaulting to `not_started`. */\n const statusFor = (nodeId: string): NodeStatus => snapshots.get(nodeId)?.status ?? \"not_started\";\n\n /** A predecessor \"passes\" when it is complete or skipped. */\n const passed = (nodeId: string): boolean => {\n const s = statusFor(nodeId);\n return s === \"complete\" || s === \"skipped\";\n };\n\n const nodeStates: NodeState[] = nodes.map((node) => {\n const snapshot = snapshots.get(node.id);\n const optional = nodeIsOptional(node);\n const skillId = nodeSkillId(node);\n const label = nodeLabel(node);\n const status = snapshot?.status ?? \"not_started\";\n\n const edges = incoming.get(node.id) ?? [];\n const flowPreds = edges.filter((e) => e.type === \"flow\");\n const hardBlockers = flowPreds.filter((e) => !passed(e.source)).map((e) => e.source);\n\n const isAdmissionState = status === \"not_started\" || status === \"available\";\n const preconditionFailures = isAdmissionState ? failedPreconditions(node, context) : [];\n\n // Recompute admission in both directions after fresh start or hydrate.\n let effectiveStatus: NodeStatus = status;\n if (isAdmissionState) {\n effectiveStatus =\n hardBlockers.length === 0 && preconditionFailures.length === 0\n ? \"available\"\n : \"not_started\";\n }\n\n return {\n nodeId: node.id,\n skillId,\n label,\n status: effectiveStatus,\n optional,\n canRun:\n hardBlockers.length === 0 &&\n preconditionFailures.length === 0 &&\n effectiveStatus === \"available\",\n blockers: hardBlockers,\n failedPreconditions: preconditionFailures,\n approval: snapshot?.approval,\n input: snapshot?.input,\n output: snapshot?.output,\n error: snapshot?.error,\n };\n });\n\n const available = nodeStates.filter((s) => s.status === \"available\").map((s) => s.nodeId);\n const completed = nodeStates.filter((s) => s.status === \"complete\").map((s) => s.nodeId);\n const focus = nodeStates\n .filter(\n (s) =>\n s.status === \"running\" || s.status === \"awaiting_approval\" || s.status === \"awaiting_input\",\n )\n .map((s) => s.nodeId);\n\n const requiredNodes = nodes.filter((n) => !nodeIsOptional(n));\n const done = requiredNodes.every((n) => {\n const s = statusFor(n.id);\n return s === \"complete\" || s === \"skipped\";\n });\n\n return { flowId: flow.id, nodes: nodeStates, available, completed, focus, done };\n}\n\n/**\n * Returns `true` when the given status prevents downstream nodes from starting.\n *\n * Only `'complete'` and `'skipped'` satisfy a hard (`'flow'`-type) edge dependency.\n * All other statuses — including `'awaiting_approval'`, `'awaiting_input'`, and\n * `'failed'` — are considered blocking.\n *\n * Use this helper in the FlowAdapter and the turn-based orchestrator instead of\n * hard-coding the two-value whitelist inline.\n *\n * @param status - The {@link NodeStatus} to evaluate.\n * @returns `true` if the status prevents dependents from becoming `available`.\n * @docLink packages/flow-engine/concepts#is-blocking\n */\nexport function isBlocking(status: NodeStatus): boolean {\n return status !== \"complete\" && status !== \"skipped\";\n}\n\n/**\n * Returns the IDs of nodes that become newly `available` after a specific node completes.\n *\n * More efficient than recomputing the full {@link FlowState} when only the downstream\n * impact of a single completion is needed. Only the direct successors of `justCompleted`\n * are evaluated — the rest of the graph is untouched.\n *\n * @param flow - The parsed flow definition.\n * @param justCompleted - ID of the node that just finished (will be added to the\n * effective completed set before evaluating successors).\n * @param completedIds - Set of node IDs already known to be complete before this call.\n * @param skippedIds - Set of node IDs that were explicitly skipped. Defaults to an empty set.\n * @returns Array of node IDs whose hard dependencies are now fully satisfied and that\n * were not already available before `justCompleted` finished. Unlike executable-node-filtered\n * helpers, this walks raw edge targets and does not filter by node type — if a `group`,\n * `sub-flow`, or `router` node is a direct successor, its ID can appear here. Callers that\n * dispatch these IDs are responsible for filtering inert nodes.\n * @docLink packages/flow-engine/concepts#resolve-next-nodes\n */\nexport function resolveNextNodes(\n flow: FlowDefinition,\n justCompleted: string,\n completedIds: Set<string>,\n skippedIds: Set<string> = new Set(),\n): string[] {\n const outgoing = buildOutgoing(flow.edges);\n const incoming = buildIncoming(flow.edges);\n const candidates = (outgoing.get(justCompleted) ?? []).map((e) => e.target);\n\n const nextCompleted = new Set([...completedIds, justCompleted]);\n const result: string[] = [];\n\n for (const candidateId of candidates) {\n const edges = incoming.get(candidateId) ?? [];\n const hardBlockers = edges\n .filter((e) => e.type === \"flow\")\n .filter((e) => !nextCompleted.has(e.source) && !skippedIds.has(e.source));\n if (hardBlockers.length === 0) {\n result.push(candidateId);\n }\n }\n\n return result;\n}\n\n/**\n * Returns the IDs of optional nodes that have not yet started and can be safely skipped.\n *\n * A node is skippable when it is:\n * 1. Not yet complete (absent from `completedIds`).\n * 2. Marked `optional` (`FlowNode.data.optional === true`).\n * 3. Not connected via a `'flow'`-type edge to any non-optional downstream node\n * (i.e. skipping it cannot starve a required node of a hard dependency).\n *\n * The runner may call this to present the user with a list of nodes they can bypass\n * without breaking the flow's required path.\n *\n * @param flow - The parsed flow definition.\n * @param completedIds - Set of node IDs that have already completed (excluded from results).\n * @returns Array of node IDs that are safe to skip at this point in the execution.\n * @docLink packages/flow-engine/concepts#compute-skippable\n */\nexport function computeSkippable(flow: FlowDefinition, completedIds: Set<string>): string[] {\n const nodes = activeRuntimeNodes(flow);\n const outgoing = buildOutgoing(flow.edges);\n\n return nodes\n .filter((n) => !completedIds.has(n.id))\n .filter(nodeIsOptional)\n .filter((n) => {\n // A node is skippable if none of its outgoing flow-type edges go to a required node\n const deps = (outgoing.get(n.id) ?? []).filter((e) => e.type === \"flow\");\n return deps.every((e) => {\n const target = flow.nodes.find((t) => t.id === e.target);\n return target ? nodeIsOptional(target) : false;\n });\n })\n .map((n) => n.id);\n}\n","import * as z from \"zod\";\nimport { collectFlowBindingExpressions, inspectFlowExpression } from \"../contract/expression.js\";\nimport type { FlowDefinition, FlowNode } from \"./types.js\";\n\n/** Result of validating fields at a producer's consumed-output boundary. */\nexport interface NodeOutputValidationResult {\n /** Whether the fields may be exposed to downstream consumers. */\n valid: boolean;\n /** Stable, path-bearing failures. Empty when validation is not required. */\n issues: string[];\n}\n\nfunction consumerExpressions(node: FlowNode): string[] {\n const expressions = (node.contract?.requires ?? []).map(({ expr }) => expr);\n expressions.push(...collectFlowBindingExpressions(node.contract?.input));\n if (node.run?.kind === \"router\") {\n expressions.push(...node.run.routes.map(({ when }) => when));\n }\n return expressions;\n}\n\nfunction readsProducerOutput(node: FlowNode, producerId: string): boolean {\n return consumerExpressions(node).some((expression) =>\n inspectFlowExpression(expression, false).some(({ path }) =>\n path.startsWith(`nodes.${producerId}.output.fields.`),\n ),\n );\n}\n\n/**\n * Return a producer's declared fields schema only when another node reads it.\n *\n * Consumption is deliberately limited to preconditions, named bindings, and\n * router conditions. Status reads and unreferenced declarations remain prose-only.\n */\nexport function getConsumedOutputSchema(\n flow: FlowDefinition,\n producerId: string,\n): Record<string, unknown> | undefined {\n const producer = flow.nodes.find(({ id }) => id === producerId);\n const schema = producer?.contract?.output?.fields;\n if (!schema) return undefined;\n return flow.nodes.some(\n (consumer) => consumer.id !== producerId && readsProducerOutput(consumer, producerId),\n )\n ? schema\n : undefined;\n}\n\n/** Validate proposed fields only when a downstream deterministic consumer requires them. */\nexport function validateConsumedNodeOutput(\n flow: FlowDefinition,\n producerId: string,\n fields: Record<string, unknown> | undefined,\n): NodeOutputValidationResult {\n const schema = getConsumedOutputSchema(flow, producerId);\n if (!schema) return { valid: true, issues: [] };\n\n try {\n const validator = z.fromJSONSchema(schema as Parameters<typeof z.fromJSONSchema>[0]);\n const parsed = validator.safeParse(fields ?? {});\n if (parsed.success) return { valid: true, issues: [] };\n return {\n valid: false,\n issues: parsed.error.issues\n .map((issue) => {\n const suffix = issue.path.map(String).join(\".\");\n return `fields${suffix ? `.${suffix}` : \"\"}: ${issue.message}`;\n })\n .sort(),\n };\n } catch (error) {\n return {\n valid: false,\n issues: [\n `fields: invalid authored JSON Schema: ${\n error instanceof Error ? error.message : String(error)\n }`,\n ],\n };\n }\n}\n","/**\n * Flow manifest schema and validation.\n *\n * Moved from @skaile/workspaces/types/manifests/flow.ts in Phase 1.7.3.\n * This is now the canonical location for flow manifest validation.\n */\n\nimport * as z from \"zod\";\n\n// ---------------------------------------------------------------------------\n// Validation result (inline — avoids importing from types/manifests/_shared)\n// ---------------------------------------------------------------------------\n\nexport interface ManifestValidationSuccess<T> {\n ok: true;\n data: T;\n}\n\nexport interface ManifestValidationFailure {\n ok: false;\n errors: Array<{ path: string; message: string }>;\n}\n\nexport type ManifestValidationResult<T> = ManifestValidationSuccess<T> | ManifestValidationFailure;\n\n// ---------------------------------------------------------------------------\n// Schema\n// ---------------------------------------------------------------------------\n\nconst FlowNodeSchema = z.looseObject({\n id: z.string().min(1),\n skill: z.string().optional(),\n type: z.string().optional(),\n label: z.string().optional(),\n description: z.string().optional(),\n data: z\n .looseObject({\n optional: z.boolean().optional(),\n // Mandatory approval gate — autonomous mode cannot skip it.\n approval: z.looseObject({ mandatory: z.boolean().optional() }).optional(),\n })\n .refine((d) => !(d.optional === true && d.approval?.mandatory === true), {\n // A mandatory gate can never be skipped, so optional+mandatory is a\n // contradiction — reject it rather than silently letting mandatory win.\n message: \"a node cannot be both optional and a mandatory approval gate\",\n })\n .optional(),\n});\n\nconst FlowEdgeSchema = z.looseObject({\n id: z.string().optional(),\n source: z.string().min(1),\n target: z.string().min(1),\n condition: z.string().optional(),\n});\n\nexport const FlowManifestSchema = z.looseObject({\n id: z.string().min(1),\n version: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n metadata: z\n .looseObject({\n tags: z.array(z.string()).optional(),\n stage: z.string().optional(),\n icon: z.string().optional(),\n category: z.string().optional(),\n onboarding: z.record(z.string(), z.unknown()).optional(),\n })\n .optional(),\n globals: z.record(z.string(), z.unknown()).optional(),\n modes: z.record(z.string(), z.unknown()).optional(),\n tier_presets: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),\n artifact_handoff: z.unknown().optional(),\n entry: z.string().optional(),\n nodes: z.array(FlowNodeSchema).optional(),\n edges: z.array(FlowEdgeSchema).optional(),\n});\n\nexport type FlowManifest = z.infer<typeof FlowManifestSchema>;\n\n// ---------------------------------------------------------------------------\n// Validation\n// ---------------------------------------------------------------------------\n\nexport function validateFlow(data: unknown): ManifestValidationResult<FlowManifest> {\n const result = FlowManifestSchema.safeParse(data);\n if (result.success) {\n return { ok: true, data: result.data };\n }\n return {\n ok: false,\n errors: result.error.issues.map((issue) => ({\n path: issue.path.join(\".\"),\n message: issue.message,\n })),\n };\n}\n","/**\n * Flow asset kind provider.\n *\n * Exported from @skaile/workspaces/factory-assets/connectors/flow/engine for explicit registration\n * by the CLI at bootstrap. Discovery does NOT auto-include this provider\n * (discovery must stay a leaf — no flow-engine imports).\n *\n * Implements IAssetKindProvider with flow-specific:\n * - Discovery patterns: *.flow.yaml, *.flow.json\n * - Manifest validation via FlowManifestSchema\n * - Requires extraction: nodes[].run.assets plus legacy skill/sub-flow references\n * - File filter: just the manifest file (flows are single-file)\n */\n\nimport * as path from \"node:path\";\nimport type {\n AssetKindFileFilter,\n AssetKindRequiresEdge,\n IAssetKindProvider,\n} from \"@skaile/workspaces/plugins\";\nimport { validateFlow } from \"./flow-manifest.js\";\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport const flowKindProvider: IAssetKindProvider = {\n kind: \"flow\",\n displayName: \"Flow\",\n providerVersion: \"1.1.0\",\n discoveryPatterns: [\"**/*.flow.yaml\", \"**/*.flow.json\"],\n\n matchesPath(relativePath: string): boolean {\n return relativePath.endsWith(\".flow.yaml\") || relativePath.endsWith(\".flow.json\");\n },\n\n validateManifest(data: unknown) {\n return validateFlow(data);\n },\n\n defaultFileFilter(manifestPath: string): AssetKindFileFilter {\n return {\n assetRoot: path.dirname(manifestPath),\n files: [path.basename(manifestPath)],\n };\n },\n\n extractRequires(assetRef: string, manifest: Record<string, unknown>): AssetKindRequiresEdge[] {\n const edges: AssetKindRequiresEdge[] = [];\n const seen = new Set<string>();\n const add = (to: string, field: string): void => {\n if (seen.has(to)) return;\n seen.add(to);\n edges.push({ from: assetRef, to, field });\n };\n\n const nodes = manifest.nodes;\n if (Array.isArray(nodes)) {\n for (const node of nodes) {\n if (typeof node !== \"object\" || node === null) continue;\n const n = node as Record<string, unknown>;\n const data = (\n typeof n.data === \"object\" && n.data !== null ? (n.data as Record<string, unknown>) : {}\n ) as Record<string, unknown>;\n const run =\n typeof n.run === \"object\" && n.run !== null ? (n.run as Record<string, unknown>) : {};\n\n if (Array.isArray(run.assets)) {\n for (const asset of run.assets) {\n if (typeof asset === \"string\") add(asset, \"nodes[].run.assets\");\n }\n }\n\n if (run.kind === \"sub-flow\" && typeof run.flow === \"string\") {\n const flowRef = run.flow.startsWith(\"flow:\") ? run.flow : `flow:${run.flow}`;\n add(flowRef, \"nodes[].run.flow\");\n }\n\n const skill = typeof data.skill === \"string\" ? data.skill : n.skill;\n if (typeof skill === \"string\") {\n add(skill, \"nodes[].data.skill\");\n }\n\n const subFlow = typeof data.flow === \"string\" ? data.flow : n.flow;\n if (typeof subFlow === \"string\") {\n add(subFlow.startsWith(\"flow:\") ? subFlow : `flow:${subFlow}`, \"nodes[].data.flow\");\n }\n }\n }\n\n return edges;\n },\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { assetSearchDirs } from \"@skaile/workspaces/core\";\nimport { parse as parseYaml } from \"yaml\";\nimport { parseFlowDefinition } from \"../contract/normalize.js\";\nimport type { FlowDefinition } from \"./types.js\";\n\n/**\n * Load a single {@link FlowDefinition} from a YAML or JSON file on disk.\n *\n * Format detection is based on file extension:\n * - `.yaml` / `.yml` — parsed with the `yaml` library.\n * - Everything else — parsed as JSON.\n *\n * @param filePath - Absolute path to the flow file.\n * @returns The parsed {@link FlowDefinition}.\n * @throws {Error} If the file does not exist, cannot be read, or fails to parse.\n * @docLink packages/flow-engine/concepts#flow-loading\n */\nexport function loadFlow(filePath: string): FlowDefinition {\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const ext = path.extname(filePath).toLowerCase();\n const authored = ext === \".yaml\" || ext === \".yml\" ? parseYaml(raw) : JSON.parse(raw);\n const parsed = parseFlowDefinition(authored);\n if (!parsed.ok) {\n const details = parsed.errors\n .map((issue) => ` ${issue.path || \"<root>\"}: ${issue.message}`)\n .join(\"\\n\");\n throw new Error(`Invalid flow definition:\\n${details}`);\n }\n return parsed.data;\n}\n\n/**\n * Load all `*.flow.yaml` and legacy `*.flow.json` / `*.json` flow files from a directory.\n *\n * Files that fail to parse are skipped with a warning written to `stderr` — they do not\n * cause the function to throw. Files whose name starts with `_` are skipped entirely\n * (treated as drafts or disabled flows). Files missing the required `id`, `nodes`, or\n * `edges` fields are also discarded silently.\n *\n * @param dirPath - Absolute path to the directory to scan.\n * @returns Array of successfully parsed {@link FlowDefinition} objects. Empty if the\n * directory does not exist or contains no valid flow files.\n * @docLink packages/flow-engine/concepts#flow-loading\n */\nexport function loadFlowsFromDir(dirPath: string): FlowDefinition[] {\n if (!fs.existsSync(dirPath)) return [];\n\n const files = fs.readdirSync(dirPath).filter((f) => {\n if (f.startsWith(\"_\")) return false;\n return f.endsWith(\".flow.yaml\") || f.endsWith(\".flow.json\") || f.endsWith(\".json\");\n });\n\n const flows: FlowDefinition[] = [];\n\n for (const file of files) {\n try {\n const def = loadFlow(path.join(dirPath, file));\n if (def.id && def.nodes && def.edges) {\n flows.push(def);\n }\n } catch (err) {\n process.stderr.write(`[agent-flow-engine] skipping ${file}: ${(err as Error).message}\\n`);\n }\n }\n\n return flows;\n}\n\n/**\n * Discover and load all flow definitions from every domain under an `ai-assets` root.\n *\n * Walks the top-level subdirectories of `aiResourcesRoot`, looks for a `flows/`\n * subdirectory inside each domain, and delegates to {@link loadFlowsFromDir} for\n * each one found. Files prefixed with `_` are skipped (draft/disabled).\n *\n * @param aiResourcesRoot - Absolute path to the `ai-assets/` directory (or equivalent\n * resource root). Typically the `ai-assets/` folder at the monorepo root.\n * @returns Flat array of all successfully parsed {@link FlowDefinition} objects across\n * all domains. Empty if the root directory does not exist.\n * @docLink packages/flow-engine/concepts#flow-loading\n */\nexport function loadAllFlows(aiResourcesRoot: string): FlowDefinition[] {\n if (!fs.existsSync(aiResourcesRoot)) return [];\n\n // `assetSearchDirs` covers both the flat (`<root>/flows/`) and domain-nested\n // (`<root>/<domain>/flows/`) layouts via the one shared layout primitive.\n // De-dupe by id (first dir wins) so a root that happens to define a flow in\n // both layouts surfaces it once.\n const byId = new Map<string, FlowDefinition>();\n for (const { dir } of assetSearchDirs(aiResourcesRoot, \"flows\")) {\n for (const flow of loadFlowsFromDir(dir)) {\n if (!byId.has(flow.id)) byId.set(flow.id, flow);\n }\n }\n return [...byId.values()];\n}\n"]}
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
function isAgentNode(node) {
|
|
3
3
|
return node.type === "skill" || node.run?.kind === "agent";
|
|
4
4
|
}
|
|
5
|
+
function isFunctionNode(node) {
|
|
6
|
+
return node.run?.kind === "function";
|
|
7
|
+
}
|
|
8
|
+
function isGateNode(node) {
|
|
9
|
+
return node.run?.kind === "gate";
|
|
10
|
+
}
|
|
11
|
+
function isSubFlowNode(node) {
|
|
12
|
+
return node.run?.kind === "sub-flow";
|
|
13
|
+
}
|
|
14
|
+
function isActiveRuntimeNode(node) {
|
|
15
|
+
return isAgentNode(node) || isFunctionNode(node) || isGateNode(node) || isSubFlowNode(node);
|
|
16
|
+
}
|
|
5
17
|
function nodeIsOptional(node) {
|
|
6
18
|
return node.control?.optional ?? node.data?.optional ?? false;
|
|
7
19
|
}
|
|
@@ -33,6 +45,6 @@ function flowDefaults(flow) {
|
|
|
33
45
|
return flow.defaults ?? flow.globals ?? {};
|
|
34
46
|
}
|
|
35
47
|
|
|
36
|
-
export { flowDefaults, isAgentNode, nodeAssets, nodeBindings, nodeInstruction, nodeIsOptional, nodeLabel, nodeRequiresApproval, nodeSkillId };
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
export { flowDefaults, isActiveRuntimeNode, isAgentNode, isFunctionNode, isGateNode, isSubFlowNode, nodeAssets, nodeBindings, nodeInstruction, nodeIsOptional, nodeLabel, nodeRequiresApproval, nodeSkillId };
|
|
49
|
+
//# sourceMappingURL=chunk-4QROZZ5Z.js.map
|
|
50
|
+
//# sourceMappingURL=chunk-4QROZZ5Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../factory-assets/connectors/flow/engine/node-shape.ts"],"names":[],"mappings":";AAGO,SAAS,YAAY,IAAA,EAAyB;AACnD,EAAA,OAAO,IAAA,CAAK,IAAA,KAAS,OAAA,IAAW,IAAA,CAAK,KAAK,IAAA,KAAS,OAAA;AACrD;AAGO,SAAS,eACd,IAAA,EACyF;AACzF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,UAAA;AAC5B;AAGO,SAAS,WACd,IAAA,EACqF;AACrF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,MAAA;AAC5B;AAGO,SAAS,cACd,IAAA,EACyF;AACzF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,UAAA;AAC5B;AAGO,SAAS,oBAAoB,IAAA,EAAyB;AAC3D,EAAA,OAAO,WAAA,CAAY,IAAI,CAAA,IAAK,cAAA,CAAe,IAAI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OAAA,IAAW,IAAA,CAAK,IAAA,EAAM,KAAA,GAAQ,CAAA,MAAA,EAAS,IAAA,CAAK,IAAA,CAAK,KAAK,CAAA,CAAA,GAAK,MAAA;AACvF,EAAA,OAAO,KAAA,GAAQ,CAAC,KAAA,EAAO,GAAG,YAAY,CAAA,GAAI,YAAA;AAC5C;AAGO,SAAS,aAAa,IAAA,EAAyC;AACpE,EAAA,IAAI,IAAA,CAAK,QAAA,EAAU,KAAA,EAAO,OAAO,KAAK,QAAA,CAAS,KAAA;AAC/C,EAAA,OAAO,IAAA,CAAK,IAAA,EAAM,UAAA,IAAc,EAAC;AACnC;AAGO,SAAS,gBAAgB,IAAA,EAAoC;AAClE,EAAA,OAAO,KAAK,GAAA,EAAK,IAAA,KAAS,OAAA,GAAU,IAAA,CAAK,IAAI,WAAA,GAAc,MAAA;AAC7D;AAGO,SAAS,aAAa,IAAA,EAA+C;AAC1E,EAAA,OAAO,IAAA,CAAK,QAAA,IAAY,IAAA,CAAK,OAAA,IAAW,EAAC;AAC3C","file":"chunk-4QROZZ5Z.js","sourcesContent":["import type { FlowDefinition, FlowNode } from \"./types.js\";\n\n/** Returns whether a node is executable by the currently active agent-turn runtime. */\nexport function isAgentNode(node: FlowNode): boolean {\n return node.type === \"skill\" || node.run?.kind === \"agent\";\n}\n\n/** Returns whether a node executes deterministically through NodeExecutor. */\nexport function isFunctionNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"function\" }> } {\n return node.run?.kind === \"function\";\n}\n\n/** Returns whether a node is a runtime-owned human decision point. */\nexport function isGateNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"gate\" }> } {\n return node.run?.kind === \"gate\";\n}\n\n/** Returns whether a node delegates once to an inline child flow. */\nexport function isSubFlowNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"sub-flow\" }> } {\n return node.run?.kind === \"sub-flow\";\n}\n\n/** Returns whether the current runtime owns the node's execution state. */\nexport function isActiveRuntimeNode(node: FlowNode): boolean {\n return isAgentNode(node) || isFunctionNode(node) || isGateNode(node) || isSubFlowNode(node);\n}\n\n/** @deprecated Use {@link isActiveRuntimeNode}; gates are active but nobody executes them. */\nexport const isExecutableNode = isActiveRuntimeNode;\n\n/** Returns the node's optional policy across strict v2 and legacy definitions. */\nexport function nodeIsOptional(node: FlowNode): boolean {\n return node.control?.optional ?? node.data?.optional ?? false;\n}\n\n/** Returns the node's mandatory approval policy across strict v2 and legacy definitions. */\nexport function nodeRequiresApproval(node: FlowNode): boolean {\n return node.gate?.approval === \"mandatory\" || node.data?.approval?.mandatory === true;\n}\n\n/** Returns the first declared skill requirement without making it the node identity. */\nexport function nodeSkillId(node: FlowNode): string {\n if (node.type === \"skill\") return node.data?.skill ?? node.id;\n const skillAsset = node.run?.assets?.find((asset) => asset.startsWith(\"skill:\"));\n return skillAsset?.slice(\"skill:\".length).replace(/#.*$/, \"\") ?? node.id;\n}\n\n/** Returns the user-facing node label across strict v2 and legacy definitions. */\nexport function nodeLabel(node: FlowNode): string {\n return node.label ?? node.data?.label ?? nodeSkillId(node);\n}\n\n/** Returns strict v2 run assets or the equivalent legacy declarations. */\nexport function nodeAssets(node: FlowNode): string[] {\n if (node.run?.assets) return node.run.assets;\n const legacyAssets = Array.isArray(node.data?.assets)\n ? node.data.assets.filter((asset): asset is string => typeof asset === \"string\")\n : [];\n const skill = node.type === \"skill\" && node.data?.skill ? `skill:${node.data.skill}` : undefined;\n return skill ? [skill, ...legacyAssets] : legacyAssets;\n}\n\n/** Returns the binding values already supplied at the node boundary. */\nexport function nodeBindings(node: FlowNode): Record<string, unknown> {\n if (node.contract?.input) return node.contract.input;\n return node.data?.parameters ?? {};\n}\n\n/** Returns the first-class instruction for a strict v2 agent node. */\nexport function nodeInstruction(node: FlowNode): string | undefined {\n return node.run?.kind === \"agent\" ? node.run.instruction : undefined;\n}\n\n/** Returns run-scoped defaults across strict v2 and legacy definitions. */\nexport function flowDefaults(flow: FlowDefinition): Record<string, unknown> {\n return flow.defaults ?? flow.globals ?? {};\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveLibraryDir } from './chunk-
|
|
1
|
+
import { resolveLibraryDir } from './chunk-3HVASHBF.js';
|
|
2
2
|
import { factoryAssetRoots } from './chunk-UFY2HFLO.js';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import os from 'os';
|
|
@@ -25,5 +25,5 @@ function aiResourceRoots() {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export { AI_RESOURCES, MONOREPO_ROOT, aiResourceRoots };
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-57RFYEVM.js.map
|
|
29
|
+
//# sourceMappingURL=chunk-57RFYEVM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/paths.ts"],"names":[],"mappings":";;;;;;;AAOA,IAAM,WAAW,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAW5D,SAAS,iBAAiB,IAAA,EAA6B;AACrD,EAAA,IAAI,GAAA,GAAM,IAAA;AACV,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,CAAA,EAAA,EAAK;AAC1B,IAAA,IAAI,EAAA,CAAG,WAAW,IAAA,CAAK,IAAA,CAAK,KAAK,YAAY,CAAC,GAAG,OAAO,GAAA;AACxD,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAA;AAC/B,IAAA,IAAI,WAAW,GAAA,EAAK;AACpB,IAAA,GAAA,GAAM,MAAA;AAAA,EACR;AACA,EAAA,OAAO,IAAA;AACT;AAYO,IAAM,aAAA,GAA+B,iBAAiB,QAA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,GAA4B;AAC1C,EAAA,MAAM,KAAA,GAAkB,CAAC,GAAG,iBAAA,EAAmB,CAAA;AAG/C,EAAA,KAAA,CAAM,IAAA,CAAK,mBAAmB,CAAA;AAC9B,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,KAAK,CAAC,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAM,EAAA,CAAG,UAAA,CAAW,CAAC,CAAC,CAAA;AAC3D","file":"chunk-57RFYEVM.js","sourcesContent":["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { factoryAssetRoots } from \"@skaile/workspaces/core\";\nimport { resolveLibraryDir } from \"@skaile/workspaces/library\";\n\nconst __ownDir = path.dirname(fileURLToPath(import.meta.url));\n\n/**\n * Walk up from `from` looking for the monorepo marker (`biome.json`, the\n * repo-root shared tooling config). Returns the matching directory or `null`\n * when none is found within eight levels — the latter is the typical case when\n * `@skaile/workspaces` has been installed via `npm i` without a skaile-dev\n * workspace context. Used only to gate dev-only commands (e.g.\n * `serve --compile-test`); first-party content is located via\n * {@link aiResourceRoots}, not this.\n */\nfunction findMonorepoRoot(from: string): string | null {\n let dir = from;\n for (let i = 0; i < 8; i++) {\n if (fs.existsSync(path.join(dir, \"biome.json\"))) return dir;\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Absolute path to the monorepo root, or `null` when the CLI is running\n * outside the skaile-dev workspace (typical for `npm i -g` installs).\n *\n * Consumers that only make sense inside the workspace (e.g.\n * `skaile serve --compile-test`) MUST check for `null` and report a\n * \"monorepo-only feature\" error before proceeding.\n *\n * @docLink cli/dev-guide#paths\n */\nexport const MONOREPO_ROOT: string | null = findMonorepoRoot(__ownDir);\n\n/**\n * Default content root used by path display and the `validate` command.\n *\n * The primary first-party `factory-assets/` root resolved through the shared\n * `factoryAssetRoots()` helper — the `SKAILE_FACTORY_ASSETS_DIR` override when\n * set, else the in-repo source during dev / bundled `dist/factory-assets/` after\n * `npm i`. Falls back to `~/.skaile/libraries/` — the user-library directory\n * managed by `skaile library add` — when the package cannot be located.\n * Consumers `fs.existsSync` first and degrade to \"no skills / flows discovered\".\n *\n * @docLink cli/dev-guide#paths\n */\nexport const AI_RESOURCES: string =\n factoryAssetRoots()[0] ?? path.join(os.homedir(), \".skaile\", \"libraries\");\n\n/**\n * All content roots that skill / flow discovery should walk, in priority order,\n * filtered to those that exist on disk and de-duplicated.\n *\n * - The first-party `factory-assets/` roots from the shared `factoryAssetRoots()`\n * helper — the `SKAILE_FACTORY_ASSETS_DIR` override layer (when set) ahead of\n * the bundled tree (in-repo source in dev, `dist/factory-assets/` after\n * install). No monorepo special-case.\n * - The user-library dir `~/.skaile/libraries/`.\n *\n * Order is significant: `findSkills` / flow discovery dedupe first-root-wins, so\n * the env override shadows the bundled tree on a name clash.\n *\n * This is the discovery surface used by `findSkills`, flow discovery, and the\n * completion resolvers.\n *\n * @docLink cli/dev-guide#paths\n */\nexport function aiResourceRoots(): string[] {\n const roots: string[] = [...factoryAssetRoots()];\n // resolveLibraryDir honors SKAILE_LIBRARIES_DIR (the authoring side does too),\n // so a custom-dir library is visible to discovery instead of being missed.\n roots.push(resolveLibraryDir());\n return [...new Set(roots)].filter((r) => fs.existsSync(r));\n}\n"]}
|
|
@@ -303,5 +303,5 @@ function resolveProjectDir(additionalEnvVars) {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
export { PluginStore, WorkspacePlugin, buildClaudePluginFiles, resolveProjectDir };
|
|
306
|
-
//# sourceMappingURL=chunk-
|
|
307
|
-
//# sourceMappingURL=chunk-
|
|
306
|
+
//# sourceMappingURL=chunk-AKVAZ5CB.js.map
|
|
307
|
+
//# sourceMappingURL=chunk-AKVAZ5CB.js.map
|