yaml-flow 2.2.0 → 2.3.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/README.md +40 -0
- package/dist/{constants-Bwvkbr5s.d.cts → constants-BftTHiuV.d.cts} +51 -1
- package/dist/{constants-Ewufm5cK.d.ts → constants-DMbnp--H.d.ts} +51 -1
- package/dist/event-graph/index.cjs +208 -0
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.d.cts +2 -2
- package/dist/event-graph/index.d.ts +2 -2
- package/dist/event-graph/index.js +208 -1
- package/dist/event-graph/index.js.map +1 -1
- package/dist/index.cjs +208 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +208 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TaskConfig, i as ExecutionState, d as ConflictStrategy, G as GraphConfig } from '../constants-
|
|
2
|
-
export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, j as ExecutionStatus, k as ExportOptions, l as GraphEvent, m as GraphSettings, I as InjectTokensEvent, M as MermaidOptions,
|
|
1
|
+
import { T as TaskConfig, i as ExecutionState, d as ConflictStrategy, G as GraphConfig } from '../constants-BftTHiuV.cjs';
|
|
2
|
+
export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, j as ExecutionStatus, k as ExportOptions, l as GraphEvent, m as GraphIssue, n as GraphSettings, o as GraphValidationResult, I as InjectTokensEvent, p as IssueSeverity, M as MermaidOptions, a6 as RepeatableConfig, S as SchedulerResult, q as StuckDetection, r as TASK_STATUS, a7 as TaskCircuitBreakerConfig, s as TaskCompletedEvent, t as TaskCreationEvent, u as TaskFailedEvent, a8 as TaskMessage, a9 as TaskProgressEvent, aa as TaskRetryConfig, v as TaskStartedEvent, w as TaskState, x as TaskStatus, y as addDynamicTask, ab as addKeyToProvides, ac as addKeyToRequires, z as apply, B as applyAll, F as computeAvailableOutputs, H as createDefaultTaskState, J as createInitialExecutionState, K as detectStuckState, L as exportGraphConfig, N as exportGraphConfigToFile, O as flowToMermaid, P as getAllTasks, Q as getCandidateTasks, R as getProvides, ad as getRepeatableMax, U as getRequires, V as getTask, W as graphToMermaid, ae as groupTasksByProvides, af as hasOutputConflict, X as hasTask, Y as isExecutionComplete, Z as isNonActiveTask, _ as isRepeatableTask, $ as isTaskCompleted, a0 as isTaskRunning, a1 as loadGraphConfig, a2 as next, a3 as planExecution, ag as removeKeyFromProvides, ah as removeKeyFromRequires, a4 as validateGraph, a5 as validateGraphConfig } from '../constants-BftTHiuV.cjs';
|
|
3
3
|
import '../types-FZ_eyErS.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TaskConfig, i as ExecutionState, d as ConflictStrategy, G as GraphConfig } from '../constants-
|
|
2
|
-
export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, j as ExecutionStatus, k as ExportOptions, l as GraphEvent, m as GraphSettings, I as InjectTokensEvent, M as MermaidOptions,
|
|
1
|
+
import { T as TaskConfig, i as ExecutionState, d as ConflictStrategy, G as GraphConfig } from '../constants-DMbnp--H.js';
|
|
2
|
+
export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, j as ExecutionStatus, k as ExportOptions, l as GraphEvent, m as GraphIssue, n as GraphSettings, o as GraphValidationResult, I as InjectTokensEvent, p as IssueSeverity, M as MermaidOptions, a6 as RepeatableConfig, S as SchedulerResult, q as StuckDetection, r as TASK_STATUS, a7 as TaskCircuitBreakerConfig, s as TaskCompletedEvent, t as TaskCreationEvent, u as TaskFailedEvent, a8 as TaskMessage, a9 as TaskProgressEvent, aa as TaskRetryConfig, v as TaskStartedEvent, w as TaskState, x as TaskStatus, y as addDynamicTask, ab as addKeyToProvides, ac as addKeyToRequires, z as apply, B as applyAll, F as computeAvailableOutputs, H as createDefaultTaskState, J as createInitialExecutionState, K as detectStuckState, L as exportGraphConfig, N as exportGraphConfigToFile, O as flowToMermaid, P as getAllTasks, Q as getCandidateTasks, R as getProvides, ad as getRepeatableMax, U as getRequires, V as getTask, W as graphToMermaid, ae as groupTasksByProvides, af as hasOutputConflict, X as hasTask, Y as isExecutionComplete, Z as isNonActiveTask, _ as isRepeatableTask, $ as isTaskCompleted, a0 as isTaskRunning, a1 as loadGraphConfig, a2 as next, a3 as planExecution, ag as removeKeyFromProvides, ah as removeKeyFromRequires, a4 as validateGraph, a5 as validateGraphConfig } from '../constants-DMbnp--H.js';
|
|
3
3
|
import '../types-FZ_eyErS.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1252,6 +1252,213 @@ ${serialized}`;
|
|
|
1252
1252
|
return String(obj);
|
|
1253
1253
|
}
|
|
1254
1254
|
|
|
1255
|
-
|
|
1255
|
+
// src/event-graph/validate.ts
|
|
1256
|
+
function buildProducerMap2(tasks) {
|
|
1257
|
+
const map = {};
|
|
1258
|
+
for (const [name, config] of Object.entries(tasks)) {
|
|
1259
|
+
for (const token of getProvides(config)) {
|
|
1260
|
+
if (!map[token]) map[token] = [];
|
|
1261
|
+
map[token].push(name);
|
|
1262
|
+
}
|
|
1263
|
+
if (config.on) {
|
|
1264
|
+
for (const tokens of Object.values(config.on)) {
|
|
1265
|
+
for (const token of tokens) {
|
|
1266
|
+
if (!map[token]) map[token] = [];
|
|
1267
|
+
if (!map[token].includes(name)) map[token].push(name);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
if (config.on_failure) {
|
|
1272
|
+
for (const token of config.on_failure) {
|
|
1273
|
+
if (!map[token]) map[token] = [];
|
|
1274
|
+
if (!map[token].includes(name)) map[token].push(name);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
return map;
|
|
1279
|
+
}
|
|
1280
|
+
function buildTaskDeps(tasks, producerMap) {
|
|
1281
|
+
const deps = {};
|
|
1282
|
+
for (const [name, config] of Object.entries(tasks)) {
|
|
1283
|
+
deps[name] = /* @__PURE__ */ new Set();
|
|
1284
|
+
for (const token of getRequires(config)) {
|
|
1285
|
+
for (const producer of producerMap[token] || []) {
|
|
1286
|
+
if (producer !== name) deps[name].add(producer);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
return deps;
|
|
1291
|
+
}
|
|
1292
|
+
function detectCycles(taskNames, deps) {
|
|
1293
|
+
const WHITE = 0, GRAY = 1, BLACK = 2;
|
|
1294
|
+
const color = {};
|
|
1295
|
+
const parent = {};
|
|
1296
|
+
const cycles = [];
|
|
1297
|
+
for (const name of taskNames) {
|
|
1298
|
+
color[name] = WHITE;
|
|
1299
|
+
parent[name] = null;
|
|
1300
|
+
}
|
|
1301
|
+
function dfs(node) {
|
|
1302
|
+
color[node] = GRAY;
|
|
1303
|
+
for (const dep of deps[node] || []) {
|
|
1304
|
+
if (color[dep] === GRAY) {
|
|
1305
|
+
const cycle = [dep];
|
|
1306
|
+
let cur = node;
|
|
1307
|
+
while (cur !== dep) {
|
|
1308
|
+
cycle.push(cur);
|
|
1309
|
+
cur = parent[cur];
|
|
1310
|
+
}
|
|
1311
|
+
cycle.push(dep);
|
|
1312
|
+
cycle.reverse();
|
|
1313
|
+
cycles.push(cycle);
|
|
1314
|
+
} else if (color[dep] === WHITE) {
|
|
1315
|
+
parent[dep] = node;
|
|
1316
|
+
dfs(dep);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
color[node] = BLACK;
|
|
1320
|
+
}
|
|
1321
|
+
for (const name of taskNames) {
|
|
1322
|
+
if (color[name] === WHITE) {
|
|
1323
|
+
dfs(name);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
return cycles;
|
|
1327
|
+
}
|
|
1328
|
+
function validateGraph(graph) {
|
|
1329
|
+
const issues = [];
|
|
1330
|
+
const tasks = getAllTasks(graph);
|
|
1331
|
+
const taskNames = Object.keys(tasks);
|
|
1332
|
+
if (taskNames.length === 0) {
|
|
1333
|
+
issues.push({
|
|
1334
|
+
severity: "error",
|
|
1335
|
+
code: "EMPTY_GRAPH",
|
|
1336
|
+
message: "Graph has no tasks"
|
|
1337
|
+
});
|
|
1338
|
+
return buildResult(issues);
|
|
1339
|
+
}
|
|
1340
|
+
const producerMap = buildProducerMap2(tasks);
|
|
1341
|
+
const deps = buildTaskDeps(tasks, producerMap);
|
|
1342
|
+
for (const [name, config] of Object.entries(tasks)) {
|
|
1343
|
+
for (const token of getRequires(config)) {
|
|
1344
|
+
if (!producerMap[token]) {
|
|
1345
|
+
issues.push({
|
|
1346
|
+
severity: "error",
|
|
1347
|
+
code: "DANGLING_REQUIRES",
|
|
1348
|
+
message: `Task "${name}" requires token "${token}" but no task produces it`,
|
|
1349
|
+
tasks: [name],
|
|
1350
|
+
tokens: [token]
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
const cycles = detectCycles(taskNames, deps);
|
|
1356
|
+
for (const cycle of cycles) {
|
|
1357
|
+
issues.push({
|
|
1358
|
+
severity: "error",
|
|
1359
|
+
code: "CIRCULAR_DEPENDENCY",
|
|
1360
|
+
message: `Circular dependency: ${cycle.join(" \u2192 ")}`,
|
|
1361
|
+
tasks: cycle.filter((_t, i) => i < cycle.length - 1)
|
|
1362
|
+
// dedupe last = first
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
for (const [name, config] of Object.entries(tasks)) {
|
|
1366
|
+
const req = getRequires(config);
|
|
1367
|
+
const prov = getProvides(config);
|
|
1368
|
+
const self = req.filter((token) => prov.includes(token));
|
|
1369
|
+
if (self.length > 0) {
|
|
1370
|
+
issues.push({
|
|
1371
|
+
severity: "error",
|
|
1372
|
+
code: "SELF_DEPENDENCY",
|
|
1373
|
+
message: `Task "${name}" requires tokens it provides itself: [${self.join(", ")}]`,
|
|
1374
|
+
tasks: [name],
|
|
1375
|
+
tokens: self
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
for (const [token, producers] of Object.entries(producerMap)) {
|
|
1380
|
+
if (producers.length > 1) {
|
|
1381
|
+
issues.push({
|
|
1382
|
+
severity: "warning",
|
|
1383
|
+
code: "PROVIDE_CONFLICT",
|
|
1384
|
+
message: `Token "${token}" is produced by multiple tasks: [${producers.join(", ")}]. This requires a conflict strategy.`,
|
|
1385
|
+
tasks: producers,
|
|
1386
|
+
tokens: [token]
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
if (graph.settings.completion === "goal-reached" && graph.settings.goal) {
|
|
1391
|
+
for (const goalToken of graph.settings.goal) {
|
|
1392
|
+
if (!producerMap[goalToken]) {
|
|
1393
|
+
issues.push({
|
|
1394
|
+
severity: "error",
|
|
1395
|
+
code: "UNREACHABLE_GOAL",
|
|
1396
|
+
message: `Goal token "${goalToken}" cannot be produced by any task`,
|
|
1397
|
+
tokens: [goalToken]
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
if (taskNames.length > 1) {
|
|
1403
|
+
for (const [name, config] of Object.entries(tasks)) {
|
|
1404
|
+
const prov = getProvides(config);
|
|
1405
|
+
const onProv = config.on ? Object.values(config.on).flat() : [];
|
|
1406
|
+
const failProv = config.on_failure || [];
|
|
1407
|
+
if (prov.length === 0 && onProv.length === 0 && failProv.length === 0) {
|
|
1408
|
+
issues.push({
|
|
1409
|
+
severity: "warning",
|
|
1410
|
+
code: "DEAD_END_TASK",
|
|
1411
|
+
message: `Task "${name}" has no provides \u2014 it cannot unblock any downstream task`,
|
|
1412
|
+
tasks: [name]
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
const allRequired = /* @__PURE__ */ new Set();
|
|
1418
|
+
for (const config of Object.values(tasks)) {
|
|
1419
|
+
for (const token of getRequires(config)) {
|
|
1420
|
+
allRequired.add(token);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
for (const [name, config] of Object.entries(tasks)) {
|
|
1424
|
+
const req = getRequires(config);
|
|
1425
|
+
const prov = getProvides(config);
|
|
1426
|
+
const onProv = config.on ? Object.values(config.on).flat() : [];
|
|
1427
|
+
const allProv = [...prov, ...onProv];
|
|
1428
|
+
const isEntryPoint = req.length === 0;
|
|
1429
|
+
const hasDownstream = allProv.some((token) => allRequired.has(token));
|
|
1430
|
+
if (isEntryPoint && !hasDownstream && taskNames.length > 1) {
|
|
1431
|
+
const isGoalRelevant = graph.settings.completion === "goal-reached" && graph.settings.goal?.some((g) => allProv.includes(g));
|
|
1432
|
+
if (!isGoalRelevant) {
|
|
1433
|
+
issues.push({
|
|
1434
|
+
severity: "info",
|
|
1435
|
+
code: "ISOLATED_TASK",
|
|
1436
|
+
message: `Task "${name}" is disconnected \u2014 it has no requires and nothing depends on its provides`,
|
|
1437
|
+
tasks: [name]
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
if (graph.settings.completion === "goal-reached" && !graph.settings.goal) {
|
|
1443
|
+
issues.push({
|
|
1444
|
+
severity: "error",
|
|
1445
|
+
code: "MISSING_GOAL",
|
|
1446
|
+
message: 'Completion strategy is "goal-reached" but no goal tokens are defined'
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
return buildResult(issues);
|
|
1450
|
+
}
|
|
1451
|
+
function buildResult(issues) {
|
|
1452
|
+
const errors = issues.filter((i) => i.severity === "error");
|
|
1453
|
+
const warnings = issues.filter((i) => i.severity === "warning");
|
|
1454
|
+
return {
|
|
1455
|
+
valid: errors.length === 0,
|
|
1456
|
+
issues,
|
|
1457
|
+
errors,
|
|
1458
|
+
warnings
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
export { COMPLETION_STRATEGIES, CONFLICT_STRATEGIES, DEFAULTS, EXECUTION_MODES, EXECUTION_STATUS, TASK_STATUS, addDynamicTask, addKeyToProvides, addKeyToRequires, apply, applyAll, applyTaskCompletion, applyTaskFailure, applyTaskProgress, applyTaskStart, computeAvailableOutputs, createDefaultTaskState, createInitialExecutionState, detectStuckState, exportGraphConfig, exportGraphConfigToFile, flowToMermaid, getAllTasks, getCandidateTasks, getNonConflictingTasks, getProvides, getRepeatableMax, getRequires, getTask, graphToMermaid, groupTasksByProvides, hasOutputConflict, hasTask, isExecutionComplete, isNonActiveTask, isRepeatableTask, isTaskCompleted, isTaskRunning, loadGraphConfig, next, planExecution, removeKeyFromProvides, removeKeyFromRequires, selectBestAlternative, selectRandomTasks, validateGraph, validateGraphConfig };
|
|
1256
1463
|
//# sourceMappingURL=index.js.map
|
|
1257
1464
|
//# sourceMappingURL=index.js.map
|