monomind 1.11.13 → 1.11.14
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/.claude/commands/mastermind/idea.md +1 -1
- package/.claude/commands/mastermind/master.md +1 -1
- package/.claude/scheduled_tasks.lock +1 -1
- package/.claude/skills/mastermind/_protocol.md +4 -4
- package/.claude/skills/mastermind/architect.md +4 -7
- package/.claude/skills/mastermind/autodev.md +2 -4
- package/.claude/skills/mastermind/build.md +3 -3
- package/.claude/skills/mastermind/content.md +3 -3
- package/.claude/skills/mastermind/createorg.md +2 -2
- package/.claude/skills/mastermind/finance.md +3 -3
- package/.claude/skills/mastermind/idea.md +0 -8
- package/.claude/skills/mastermind/marketing.md +3 -3
- package/.claude/skills/mastermind/monitor.md +2 -2
- package/.claude/skills/mastermind/ops.md +3 -3
- package/.claude/skills/mastermind/release.md +3 -3
- package/.claude/skills/mastermind/research.md +3 -3
- package/.claude/skills/mastermind/review.md +3 -3
- package/.claude/skills/mastermind/sales.md +3 -3
- package/README.md +286 -129
- package/package.json +2 -2
- package/packages/@monomind/cli/README.md +286 -129
- package/packages/@monomind/cli/bundled-graph/dist/src/build.js +73 -0
- package/packages/@monomind/cli/bundled-graph/dist/src/cluster.js +120 -0
- package/packages/@monomind/cli/bundled-graph/package.json +57 -0
- package/packages/@monomind/cli/dist/src/agents/halt-signal.d.ts +25 -0
- package/packages/@monomind/cli/dist/src/agents/halt-signal.js +76 -0
- package/packages/@monomind/cli/dist/src/agents/index.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/agents/index.js +13 -0
- package/packages/@monomind/cli/dist/src/agents/managed-agent.d.ts +41 -0
- package/packages/@monomind/cli/dist/src/agents/managed-agent.js +69 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-experiment.d.ts +23 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-experiment.js +49 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.d.ts +22 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.js +80 -0
- package/packages/@monomind/cli/dist/src/agents/registry-query.d.ts +71 -0
- package/packages/@monomind/cli/dist/src/agents/registry-query.js +125 -0
- package/packages/@monomind/cli/dist/src/agents/score-decay.d.ts +19 -0
- package/packages/@monomind/cli/dist/src/agents/score-decay.js +22 -0
- package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.js +40 -0
- package/packages/@monomind/cli/dist/src/agents/specialization-scorer.d.ts +54 -0
- package/packages/@monomind/cli/dist/src/agents/specialization-scorer.js +212 -0
- package/packages/@monomind/cli/dist/src/agents/termination-watcher.d.ts +30 -0
- package/packages/@monomind/cli/dist/src/agents/termination-watcher.js +84 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-index.d.ts +20 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-index.js +38 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-scanner.d.ts +64 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-scanner.js +308 -0
- package/packages/@monomind/cli/dist/src/agents/version-diff.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/agents/version-diff.js +64 -0
- package/packages/@monomind/cli/dist/src/agents/version-store.d.ts +60 -0
- package/packages/@monomind/cli/dist/src/agents/version-store.js +235 -0
- package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +45 -0
- package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.js +404 -0
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +333 -0
- package/packages/@monomind/cli/dist/src/commands/doctor.js +55 -1
- package/packages/@monomind/cli/dist/src/commands/ui.js +68 -0
- package/packages/@monomind/cli/dist/src/consensus/index.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/consensus/index.js +6 -0
- package/packages/@monomind/cli/dist/src/context/context-provider.d.ts +44 -0
- package/packages/@monomind/cli/dist/src/context/context-provider.js +25 -0
- package/packages/@monomind/cli/dist/src/context/git-state-provider.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/context/git-state-provider.js +34 -0
- package/packages/@monomind/cli/dist/src/context/index.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/context/index.js +12 -0
- package/packages/@monomind/cli/dist/src/context/project-conventions-provider.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/context/project-conventions-provider.js +19 -0
- package/packages/@monomind/cli/dist/src/context/prompt-assembler.d.ts +26 -0
- package/packages/@monomind/cli/dist/src/context/prompt-assembler.js +93 -0
- package/packages/@monomind/cli/dist/src/context/task-history-provider.d.ts +24 -0
- package/packages/@monomind/cli/dist/src/context/task-history-provider.js +32 -0
- package/packages/@monomind/cli/dist/src/context/user-preferences-provider.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/context/user-preferences-provider.js +27 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-reader.d.ts +31 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-reader.js +81 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-writer.d.ts +24 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-writer.js +65 -0
- package/packages/@monomind/cli/dist/src/dlq/index.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/dlq/index.js +7 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-manager.d.ts +33 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-manager.js +107 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-runner.d.ts +23 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-runner.js +59 -0
- package/packages/@monomind/cli/dist/src/eval/index.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/eval/index.js +7 -0
- package/packages/@monomind/cli/dist/src/eval/trace-collector.d.ts +40 -0
- package/packages/@monomind/cli/dist/src/eval/trace-collector.js +102 -0
- package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.js +264 -0
- package/packages/@monomind/cli/dist/src/init/statusline-generator.js +3 -3
- package/packages/@monomind/cli/dist/src/interactive/interrupt.d.ts +22 -0
- package/packages/@monomind/cli/dist/src/interactive/interrupt.js +71 -0
- package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.d.ts +25 -0
- package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.js +48 -0
- package/packages/@monomind/cli/dist/src/mcp/tool-registry.d.ts +61 -0
- package/packages/@monomind/cli/dist/src/mcp/tool-registry.js +246 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +230 -0
- package/packages/@monomind/cli/dist/src/model/complexity-scorer.d.ts +21 -0
- package/packages/@monomind/cli/dist/src/model/complexity-scorer.js +106 -0
- package/packages/@monomind/cli/dist/src/model/index.d.ts +4 -0
- package/packages/@monomind/cli/dist/src/model/index.js +4 -0
- package/packages/@monomind/cli/dist/src/model/model-settings.d.ts +22 -0
- package/packages/@monomind/cli/dist/src/model/model-settings.js +33 -0
- package/packages/@monomind/cli/dist/src/model/model-tier-resolver.d.ts +24 -0
- package/packages/@monomind/cli/dist/src/model/model-tier-resolver.js +65 -0
- package/packages/@monomind/cli/dist/src/monovector/capabilities.d.ts +34 -0
- package/packages/@monomind/cli/dist/src/monovector/capabilities.js +37 -0
- package/packages/@monomind/cli/dist/src/observability/replay-reader.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/orchestration/index.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/orchestration/index.js +6 -0
- package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.js +31 -0
- package/packages/@monomind/cli/dist/src/orchestration/routing-modes.d.ts +68 -0
- package/packages/@monomind/cli/dist/src/orchestration/routing-modes.js +180 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.js +126 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.js +188 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.js +206 -0
- package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +60 -0
- package/packages/@monomind/cli/dist/src/runtime/headless.js +284 -0
- package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.js +95 -0
- package/packages/@monomind/cli/dist/src/services/container-worker-pool.d.ts +197 -0
- package/packages/@monomind/cli/dist/src/services/container-worker-pool.js +623 -0
- package/packages/@monomind/cli/dist/src/services/index.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/services/index.js +11 -0
- package/packages/@monomind/cli/dist/src/services/worker-queue.d.ts +201 -0
- package/packages/@monomind/cli/dist/src/services/worker-queue.js +594 -0
- package/packages/@monomind/cli/dist/src/swarm/communication-graph.d.ts +25 -0
- package/packages/@monomind/cli/dist/src/swarm/communication-graph.js +77 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.d.ts +31 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.js +61 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.d.ts +19 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.js +68 -0
- package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.js +205 -0
- package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.js +190 -0
- package/packages/@monomind/cli/dist/src/transfer/test-seraphine.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/transfer/test-seraphine.js +105 -0
- package/packages/@monomind/cli/dist/src/transfer/tests/test-store.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/transfer/tests/test-store.js +214 -0
- package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.js +82 -0
- package/packages/@monomind/cli/dist/src/workflow/context-resolver.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/workflow/context-resolver.js +23 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-builder.d.ts +17 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-builder.js +129 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-executor.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-executor.js +116 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-types.d.ts +41 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-types.js +8 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-parser.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-parser.js +20 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-schema.d.ts +165 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-schema.js +82 -0
- package/packages/@monomind/cli/dist/src/workflow/index.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/workflow/index.js +11 -0
- package/packages/@monomind/cli/dist/src/workflow/template-engine.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/workflow/template-engine.js +40 -0
- package/packages/@monomind/cli/dist/src/workflow/workflow-executor.d.ts +29 -0
- package/packages/@monomind/cli/dist/src/workflow/workflow-executor.js +227 -0
- package/packages/@monomind/cli/package.json +9 -9
- package/packages/@monomind/guidance/dist/adversarial.d.ts +284 -0
- package/packages/@monomind/guidance/dist/adversarial.js +572 -0
- package/packages/@monomind/guidance/dist/analyzer.d.ts +530 -0
- package/packages/@monomind/guidance/dist/analyzer.js +2518 -0
- package/packages/@monomind/guidance/dist/artifacts.d.ts +283 -0
- package/packages/@monomind/guidance/dist/artifacts.js +356 -0
- package/packages/@monomind/guidance/dist/authority.d.ts +290 -0
- package/packages/@monomind/guidance/dist/authority.js +558 -0
- package/packages/@monomind/guidance/dist/capabilities.d.ts +209 -0
- package/packages/@monomind/guidance/dist/capabilities.js +485 -0
- package/packages/@monomind/guidance/dist/coherence.d.ts +233 -0
- package/packages/@monomind/guidance/dist/coherence.js +372 -0
- package/packages/@monomind/guidance/dist/compiler.d.ts +87 -0
- package/packages/@monomind/guidance/dist/compiler.js +419 -0
- package/packages/@monomind/guidance/dist/conformance-kit.d.ts +225 -0
- package/packages/@monomind/guidance/dist/conformance-kit.js +629 -0
- package/packages/@monomind/guidance/dist/continue-gate.d.ts +214 -0
- package/packages/@monomind/guidance/dist/continue-gate.js +353 -0
- package/packages/@monomind/guidance/dist/crypto-utils.d.ts +17 -0
- package/packages/@monomind/guidance/dist/crypto-utils.js +24 -0
- package/packages/@monomind/guidance/dist/evolution.d.ts +282 -0
- package/packages/@monomind/guidance/dist/evolution.js +500 -0
- package/packages/@monomind/guidance/dist/gates.d.ts +79 -0
- package/packages/@monomind/guidance/dist/gates.js +302 -0
- package/packages/@monomind/guidance/dist/gateway.d.ts +206 -0
- package/packages/@monomind/guidance/dist/gateway.js +452 -0
- package/packages/@monomind/guidance/dist/generators.d.ts +153 -0
- package/packages/@monomind/guidance/dist/generators.js +682 -0
- package/packages/@monomind/guidance/dist/headless.d.ts +177 -0
- package/packages/@monomind/guidance/dist/headless.js +342 -0
- package/packages/@monomind/guidance/dist/hooks.d.ts +109 -0
- package/packages/@monomind/guidance/dist/hooks.js +347 -0
- package/packages/@monomind/guidance/dist/index.d.ts +205 -0
- package/packages/@monomind/guidance/dist/index.js +321 -0
- package/packages/@monomind/guidance/dist/ledger.d.ts +162 -0
- package/packages/@monomind/guidance/dist/ledger.js +375 -0
- package/packages/@monomind/guidance/dist/manifest-validator.d.ts +289 -0
- package/packages/@monomind/guidance/dist/manifest-validator.js +838 -0
- package/packages/@monomind/guidance/dist/memory-gate.d.ts +222 -0
- package/packages/@monomind/guidance/dist/memory-gate.js +382 -0
- package/packages/@monomind/guidance/dist/meta-governance.d.ts +265 -0
- package/packages/@monomind/guidance/dist/meta-governance.js +348 -0
- package/packages/@monomind/guidance/dist/optimizer.d.ts +104 -0
- package/packages/@monomind/guidance/dist/optimizer.js +329 -0
- package/packages/@monomind/guidance/dist/persistence.d.ts +189 -0
- package/packages/@monomind/guidance/dist/persistence.js +464 -0
- package/packages/@monomind/guidance/dist/proof.d.ts +185 -0
- package/packages/@monomind/guidance/dist/proof.js +238 -0
- package/packages/@monomind/guidance/dist/retriever.d.ts +116 -0
- package/packages/@monomind/guidance/dist/retriever.js +394 -0
- package/packages/@monomind/guidance/dist/ruvbot-integration.d.ts +370 -0
- package/packages/@monomind/guidance/dist/ruvbot-integration.js +738 -0
- package/packages/@monomind/guidance/dist/temporal.d.ts +426 -0
- package/packages/@monomind/guidance/dist/temporal.js +658 -0
- package/packages/@monomind/guidance/dist/trust.d.ts +283 -0
- package/packages/@monomind/guidance/dist/trust.js +473 -0
- package/packages/@monomind/guidance/dist/truth-anchors.d.ts +276 -0
- package/packages/@monomind/guidance/dist/truth-anchors.js +488 -0
- package/packages/@monomind/guidance/dist/types.d.ts +378 -0
- package/packages/@monomind/guidance/dist/types.js +10 -0
- package/packages/@monomind/guidance/dist/uncertainty.d.ts +372 -0
- package/packages/@monomind/guidance/dist/uncertainty.js +619 -0
- package/packages/@monomind/guidance/dist/wasm-kernel.d.ts +48 -0
- package/packages/@monomind/guidance/dist/wasm-kernel.js +158 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { buildDAG, detectCycles, topologicalSort } from './dag-builder.js';
|
|
2
|
+
import { resolveContext } from './context-resolver.js';
|
|
3
|
+
import { getMonitor } from '../production/monitoring.js';
|
|
4
|
+
function classifyError(err) {
|
|
5
|
+
const msg = err.message.toLowerCase();
|
|
6
|
+
if (msg.includes('rate limit') || msg.includes('429') || msg.includes('too many requests'))
|
|
7
|
+
return 'RATE_LIMIT';
|
|
8
|
+
if (msg.includes('timed out') || msg.includes('timeout'))
|
|
9
|
+
return 'TIMEOUT';
|
|
10
|
+
if (msg.includes('validation') || msg.includes('invalid') || msg.includes('schema'))
|
|
11
|
+
return 'VALIDATION';
|
|
12
|
+
return 'UNKNOWN';
|
|
13
|
+
}
|
|
14
|
+
export class DAGExecutor {
|
|
15
|
+
runner;
|
|
16
|
+
constructor(runner) {
|
|
17
|
+
this.runner = runner;
|
|
18
|
+
}
|
|
19
|
+
async execute(tasks) {
|
|
20
|
+
const dag = buildDAG(tasks);
|
|
21
|
+
const cycles = detectCycles(dag);
|
|
22
|
+
if (cycles.length > 0) {
|
|
23
|
+
throw new Error(`Cycle detected in task DAG: ${cycles[0].join(' → ')}`);
|
|
24
|
+
}
|
|
25
|
+
const levels = topologicalSort(dag);
|
|
26
|
+
const results = new Map();
|
|
27
|
+
for (const level of levels) {
|
|
28
|
+
const levelResults = await Promise.all(level.map(async (task) => {
|
|
29
|
+
const context = resolveContext(task, results);
|
|
30
|
+
const timeoutMs = task.timeoutMs ?? 300_000;
|
|
31
|
+
let timeoutHandle;
|
|
32
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
33
|
+
timeoutHandle = setTimeout(() => reject(new Error(`Task "${task.id}" timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
34
|
+
});
|
|
35
|
+
const result = await Promise.race([
|
|
36
|
+
this.runWithRetry(task, context),
|
|
37
|
+
timeoutPromise,
|
|
38
|
+
]).finally(() => {
|
|
39
|
+
if (timeoutHandle)
|
|
40
|
+
clearTimeout(timeoutHandle);
|
|
41
|
+
}).catch((err) => {
|
|
42
|
+
const isTimeout = String(err).includes('timed out');
|
|
43
|
+
if (isTimeout) {
|
|
44
|
+
// Visible in monomind control — leaked task still running in background
|
|
45
|
+
getMonitor().counter('dag.task.timeout_leak', 1, {
|
|
46
|
+
taskId: task.id,
|
|
47
|
+
agentSlug: task.agentSlug,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
taskId: task.id,
|
|
52
|
+
agentSlug: task.agentSlug,
|
|
53
|
+
output: null,
|
|
54
|
+
outputRaw: '',
|
|
55
|
+
latencyMs: 0,
|
|
56
|
+
retryCount: 0,
|
|
57
|
+
completedAt: Date.now(),
|
|
58
|
+
status: isTimeout ? 'timeout' : 'error',
|
|
59
|
+
error: String(err),
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
}));
|
|
64
|
+
for (const result of levelResults) {
|
|
65
|
+
results.set(result.taskId, result);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return results;
|
|
69
|
+
}
|
|
70
|
+
async runWithRetry(task, context) {
|
|
71
|
+
const policy = task.retryPolicy ?? {
|
|
72
|
+
maxAttempts: 1,
|
|
73
|
+
initialDelayMs: 0,
|
|
74
|
+
backoffMultiplier: 1,
|
|
75
|
+
jitterMs: 0,
|
|
76
|
+
retryOn: [],
|
|
77
|
+
};
|
|
78
|
+
let lastError;
|
|
79
|
+
let actualAttempts = 0;
|
|
80
|
+
for (let attempt = 0; attempt < policy.maxAttempts; attempt++) {
|
|
81
|
+
actualAttempts = attempt + 1;
|
|
82
|
+
try {
|
|
83
|
+
return await this.runner(task, context);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
lastError = err;
|
|
87
|
+
// If retryOn is non-empty, check whether this error category matches.
|
|
88
|
+
// Unmatched errors consume the attempt but do not get retried further.
|
|
89
|
+
if (policy.retryOn.length > 0) {
|
|
90
|
+
const category = classifyError(lastError);
|
|
91
|
+
if (!policy.retryOn.includes(category)) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (attempt < policy.maxAttempts - 1) {
|
|
96
|
+
const delay = policy.initialDelayMs *
|
|
97
|
+
Math.pow(policy.backoffMultiplier, attempt) +
|
|
98
|
+
Math.random() * policy.jitterMs;
|
|
99
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
taskId: task.id,
|
|
105
|
+
agentSlug: task.agentSlug,
|
|
106
|
+
output: null,
|
|
107
|
+
outputRaw: '',
|
|
108
|
+
latencyMs: 0,
|
|
109
|
+
retryCount: actualAttempts,
|
|
110
|
+
completedAt: Date.now(),
|
|
111
|
+
status: 'error',
|
|
112
|
+
error: lastError?.message ?? 'Unknown error',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=dag-executor.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface RetryPolicy {
|
|
2
|
+
maxAttempts: number;
|
|
3
|
+
initialDelayMs: number;
|
|
4
|
+
backoffMultiplier: number;
|
|
5
|
+
jitterMs: number;
|
|
6
|
+
retryOn: Array<'RATE_LIMIT' | 'TIMEOUT' | 'VALIDATION' | 'UNKNOWN'>;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_RETRY_POLICY: RetryPolicy;
|
|
9
|
+
export interface DAGTask {
|
|
10
|
+
id: string;
|
|
11
|
+
description: string;
|
|
12
|
+
agentSlug: string;
|
|
13
|
+
contextDeps?: string[];
|
|
14
|
+
outputSchema?: string;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
retryPolicy?: RetryPolicy;
|
|
17
|
+
priority?: 'low' | 'normal' | 'high' | 'critical';
|
|
18
|
+
config?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface TaskResult {
|
|
21
|
+
taskId: string;
|
|
22
|
+
agentSlug: string;
|
|
23
|
+
output: unknown;
|
|
24
|
+
outputRaw: string;
|
|
25
|
+
tokenUsage?: {
|
|
26
|
+
input: number;
|
|
27
|
+
output: number;
|
|
28
|
+
};
|
|
29
|
+
latencyMs: number;
|
|
30
|
+
retryCount: number;
|
|
31
|
+
completedAt: number;
|
|
32
|
+
status: 'success' | 'error' | 'timeout';
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
export type DAGLevel = DAGTask[];
|
|
36
|
+
export interface DAG {
|
|
37
|
+
tasks: Map<string, DAGTask>;
|
|
38
|
+
edges: Map<string, Set<string>>;
|
|
39
|
+
reverseEdges: Map<string, Set<string>>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=dag-types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type WorkflowDefinition } from './dsl-schema.js';
|
|
2
|
+
export declare class DSLParser {
|
|
3
|
+
/**
|
|
4
|
+
* Load and validate a workflow definition from a YAML or JSON file.
|
|
5
|
+
*/
|
|
6
|
+
static loadFromFile(filePath: string): WorkflowDefinition;
|
|
7
|
+
/**
|
|
8
|
+
* Validate an unknown object against the workflow definition schema.
|
|
9
|
+
*/
|
|
10
|
+
static loadFromObject(raw: unknown): WorkflowDefinition;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=dsl-parser.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import YAML from 'yaml';
|
|
3
|
+
import { workflowDefinitionSchema, } from './dsl-schema.js';
|
|
4
|
+
export class DSLParser {
|
|
5
|
+
/**
|
|
6
|
+
* Load and validate a workflow definition from a YAML or JSON file.
|
|
7
|
+
*/
|
|
8
|
+
static loadFromFile(filePath) {
|
|
9
|
+
const raw = readFileSync(filePath, 'utf-8');
|
|
10
|
+
const parsed = filePath.endsWith('.json') ? JSON.parse(raw) : YAML.parse(raw);
|
|
11
|
+
return DSLParser.loadFromObject(parsed);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validate an unknown object against the workflow definition schema.
|
|
15
|
+
*/
|
|
16
|
+
static loadFromObject(raw) {
|
|
17
|
+
return workflowDefinitionSchema.parse(raw);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=dsl-parser.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const agentStepSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
type: z.ZodLiteral<"agent">;
|
|
5
|
+
agent: z.ZodString;
|
|
6
|
+
task: z.ZodString;
|
|
7
|
+
context_deps: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
|
+
output_key: z.ZodOptional<z.ZodString>;
|
|
9
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
retry_policy: z.ZodOptional<z.ZodObject<{
|
|
11
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
initialDelayMs: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
backoffMultiplier: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
jitterMs: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
retryOn: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
16
|
+
UNKNOWN: "UNKNOWN";
|
|
17
|
+
RATE_LIMIT: "RATE_LIMIT";
|
|
18
|
+
TIMEOUT: "TIMEOUT";
|
|
19
|
+
VALIDATION: "VALIDATION";
|
|
20
|
+
}>>>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const parallelStepSchema: z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
type: z.ZodLiteral<"parallel">;
|
|
26
|
+
steps: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export declare const sequenceStepSchema: z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
type: z.ZodLiteral<"sequence">;
|
|
31
|
+
steps: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export declare const conditionalStepSchema: z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
type: z.ZodLiteral<"conditional">;
|
|
36
|
+
condition: z.ZodString;
|
|
37
|
+
if_true: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
38
|
+
if_false: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const mapReduceStepSchema: z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
type: z.ZodLiteral<"map_reduce">;
|
|
43
|
+
items: z.ZodString;
|
|
44
|
+
map_agent: z.ZodString;
|
|
45
|
+
map_task: z.ZodString;
|
|
46
|
+
reduce_agent: z.ZodString;
|
|
47
|
+
reduce_task: z.ZodString;
|
|
48
|
+
concurrent: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare const loopStepSchema: z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
type: z.ZodLiteral<"loop">;
|
|
53
|
+
condition: z.ZodString;
|
|
54
|
+
max_iterations: z.ZodNumber;
|
|
55
|
+
body: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export declare const workflowStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
type: z.ZodLiteral<"agent">;
|
|
60
|
+
agent: z.ZodString;
|
|
61
|
+
task: z.ZodString;
|
|
62
|
+
context_deps: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
output_key: z.ZodOptional<z.ZodString>;
|
|
64
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
retry_policy: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
initialDelayMs: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
backoffMultiplier: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
jitterMs: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
retryOn: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
71
|
+
UNKNOWN: "UNKNOWN";
|
|
72
|
+
RATE_LIMIT: "RATE_LIMIT";
|
|
73
|
+
TIMEOUT: "TIMEOUT";
|
|
74
|
+
VALIDATION: "VALIDATION";
|
|
75
|
+
}>>>;
|
|
76
|
+
}, z.core.$strip>>;
|
|
77
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
78
|
+
id: z.ZodString;
|
|
79
|
+
type: z.ZodLiteral<"parallel">;
|
|
80
|
+
steps: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
type: z.ZodLiteral<"sequence">;
|
|
84
|
+
steps: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
85
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
type: z.ZodLiteral<"conditional">;
|
|
88
|
+
condition: z.ZodString;
|
|
89
|
+
if_true: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
90
|
+
if_false: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
91
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
92
|
+
id: z.ZodString;
|
|
93
|
+
type: z.ZodLiteral<"map_reduce">;
|
|
94
|
+
items: z.ZodString;
|
|
95
|
+
map_agent: z.ZodString;
|
|
96
|
+
map_task: z.ZodString;
|
|
97
|
+
reduce_agent: z.ZodString;
|
|
98
|
+
reduce_task: z.ZodString;
|
|
99
|
+
concurrent: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
101
|
+
id: z.ZodString;
|
|
102
|
+
type: z.ZodLiteral<"loop">;
|
|
103
|
+
condition: z.ZodString;
|
|
104
|
+
max_iterations: z.ZodNumber;
|
|
105
|
+
body: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
106
|
+
}, z.core.$strip>], "type">;
|
|
107
|
+
export type WorkflowStep = z.infer<typeof workflowStepSchema>;
|
|
108
|
+
export declare const workflowDefinitionSchema: z.ZodObject<{
|
|
109
|
+
name: z.ZodString;
|
|
110
|
+
version: z.ZodString;
|
|
111
|
+
description: z.ZodOptional<z.ZodString>;
|
|
112
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
113
|
+
steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
type: z.ZodLiteral<"agent">;
|
|
116
|
+
agent: z.ZodString;
|
|
117
|
+
task: z.ZodString;
|
|
118
|
+
context_deps: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
119
|
+
output_key: z.ZodOptional<z.ZodString>;
|
|
120
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
retry_policy: z.ZodOptional<z.ZodObject<{
|
|
122
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
initialDelayMs: z.ZodOptional<z.ZodNumber>;
|
|
124
|
+
backoffMultiplier: z.ZodOptional<z.ZodNumber>;
|
|
125
|
+
jitterMs: z.ZodOptional<z.ZodNumber>;
|
|
126
|
+
retryOn: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
127
|
+
UNKNOWN: "UNKNOWN";
|
|
128
|
+
RATE_LIMIT: "RATE_LIMIT";
|
|
129
|
+
TIMEOUT: "TIMEOUT";
|
|
130
|
+
VALIDATION: "VALIDATION";
|
|
131
|
+
}>>>;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
type: z.ZodLiteral<"parallel">;
|
|
136
|
+
steps: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
137
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
138
|
+
id: z.ZodString;
|
|
139
|
+
type: z.ZodLiteral<"sequence">;
|
|
140
|
+
steps: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
141
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
142
|
+
id: z.ZodString;
|
|
143
|
+
type: z.ZodLiteral<"conditional">;
|
|
144
|
+
condition: z.ZodString;
|
|
145
|
+
if_true: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
146
|
+
if_false: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
147
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
148
|
+
id: z.ZodString;
|
|
149
|
+
type: z.ZodLiteral<"map_reduce">;
|
|
150
|
+
items: z.ZodString;
|
|
151
|
+
map_agent: z.ZodString;
|
|
152
|
+
map_task: z.ZodString;
|
|
153
|
+
reduce_agent: z.ZodString;
|
|
154
|
+
reduce_task: z.ZodString;
|
|
155
|
+
concurrent: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
157
|
+
id: z.ZodString;
|
|
158
|
+
type: z.ZodLiteral<"loop">;
|
|
159
|
+
condition: z.ZodString;
|
|
160
|
+
max_iterations: z.ZodNumber;
|
|
161
|
+
body: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
162
|
+
}, z.core.$strip>], "type">>;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
export type WorkflowDefinition = z.infer<typeof workflowDefinitionSchema>;
|
|
165
|
+
//# sourceMappingURL=dsl-schema.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// ---------- Retry policy (reuse shape from dag-types) ----------
|
|
3
|
+
const retryPolicySchema = z.object({
|
|
4
|
+
maxAttempts: z.number().int().min(1).max(10).optional(),
|
|
5
|
+
initialDelayMs: z.number().int().min(0).optional(),
|
|
6
|
+
backoffMultiplier: z.number().min(1).optional(),
|
|
7
|
+
jitterMs: z.number().int().min(0).optional(),
|
|
8
|
+
retryOn: z
|
|
9
|
+
.array(z.enum(['RATE_LIMIT', 'TIMEOUT', 'VALIDATION', 'UNKNOWN']))
|
|
10
|
+
.optional(),
|
|
11
|
+
});
|
|
12
|
+
// ---------- Lazy wrapper for recursive step references ----------
|
|
13
|
+
// Use ZodTypeAny to avoid circular type reference (WorkflowStep is defined below)
|
|
14
|
+
const lazyStep = z.lazy(() => workflowStepSchema);
|
|
15
|
+
// ---------- 6 step-type schemas ----------
|
|
16
|
+
export const agentStepSchema = z.object({
|
|
17
|
+
id: z.string().min(1),
|
|
18
|
+
type: z.literal('agent'),
|
|
19
|
+
agent: z.string().min(1),
|
|
20
|
+
task: z.string().min(1),
|
|
21
|
+
context_deps: z.array(z.string()).optional(),
|
|
22
|
+
output_key: z.string().optional(),
|
|
23
|
+
timeout_ms: z.number().int().positive().optional(),
|
|
24
|
+
retry_policy: retryPolicySchema.optional(),
|
|
25
|
+
});
|
|
26
|
+
export const parallelStepSchema = z.object({
|
|
27
|
+
id: z.string().min(1),
|
|
28
|
+
type: z.literal('parallel'),
|
|
29
|
+
steps: z.array(lazyStep).min(2).max(50),
|
|
30
|
+
});
|
|
31
|
+
export const sequenceStepSchema = z.object({
|
|
32
|
+
id: z.string().min(1),
|
|
33
|
+
type: z.literal('sequence'),
|
|
34
|
+
steps: z.array(lazyStep).min(1),
|
|
35
|
+
});
|
|
36
|
+
export const conditionalStepSchema = z.object({
|
|
37
|
+
id: z.string().min(1),
|
|
38
|
+
type: z.literal('conditional'),
|
|
39
|
+
condition: z.string().min(1),
|
|
40
|
+
if_true: lazyStep,
|
|
41
|
+
if_false: lazyStep.optional(),
|
|
42
|
+
});
|
|
43
|
+
export const mapReduceStepSchema = z.object({
|
|
44
|
+
id: z.string().min(1),
|
|
45
|
+
type: z.literal('map_reduce'),
|
|
46
|
+
items: z.string().min(1),
|
|
47
|
+
map_agent: z.string().min(1),
|
|
48
|
+
map_task: z.string().min(1),
|
|
49
|
+
reduce_agent: z.string().min(1),
|
|
50
|
+
reduce_task: z.string().min(1),
|
|
51
|
+
concurrent: z.number().int().min(1).max(500).optional(),
|
|
52
|
+
});
|
|
53
|
+
export const loopStepSchema = z.object({
|
|
54
|
+
id: z.string().min(1),
|
|
55
|
+
type: z.literal('loop'),
|
|
56
|
+
condition: z.string().min(1),
|
|
57
|
+
max_iterations: z.number().int().min(1).max(100),
|
|
58
|
+
body: z.array(lazyStep).min(1),
|
|
59
|
+
});
|
|
60
|
+
// ---------- Discriminated union of all step types ----------
|
|
61
|
+
export const workflowStepSchema = z.discriminatedUnion('type', [
|
|
62
|
+
agentStepSchema,
|
|
63
|
+
parallelStepSchema,
|
|
64
|
+
sequenceStepSchema,
|
|
65
|
+
conditionalStepSchema,
|
|
66
|
+
mapReduceStepSchema,
|
|
67
|
+
loopStepSchema,
|
|
68
|
+
]);
|
|
69
|
+
// ---------- Semver regex ----------
|
|
70
|
+
const semverRegex = /^\d+\.\d+\.\d+(-[\w.]+)?$/;
|
|
71
|
+
// ---------- Top-level workflow definition ----------
|
|
72
|
+
export const workflowDefinitionSchema = z.object({
|
|
73
|
+
name: z.string().min(1),
|
|
74
|
+
version: z.string().regex(semverRegex, 'version must be valid semver (e.g. 1.0.0)'),
|
|
75
|
+
description: z.string().optional(),
|
|
76
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
77
|
+
steps: z.array(workflowStepSchema).min(1),
|
|
78
|
+
}).refine((def) => {
|
|
79
|
+
const ids = def.steps.map((s) => s.id);
|
|
80
|
+
return ids.length === new Set(ids).size;
|
|
81
|
+
}, { message: 'Workflow step IDs must be unique', path: ['steps'] });
|
|
82
|
+
//# sourceMappingURL=dsl-schema.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { buildDAG, detectCycles, topologicalSort } from './dag-builder.js';
|
|
2
|
+
export { DAGExecutor, type TaskRunner } from './dag-executor.js';
|
|
3
|
+
export { resolveContext, ContextResolutionError } from './context-resolver.js';
|
|
4
|
+
export type { DAGTask, TaskResult, DAGLevel, DAG, RetryPolicy, } from './dag-types.js';
|
|
5
|
+
export { DEFAULT_RETRY_POLICY } from './dag-types.js';
|
|
6
|
+
export { workflowStepSchema, workflowDefinitionSchema, agentStepSchema, parallelStepSchema, sequenceStepSchema, conditionalStepSchema, mapReduceStepSchema, loopStepSchema, } from './dsl-schema.js';
|
|
7
|
+
export type { WorkflowStep, WorkflowDefinition } from './dsl-schema.js';
|
|
8
|
+
export { DSLParser } from './dsl-parser.js';
|
|
9
|
+
export { substitute } from './template-engine.js';
|
|
10
|
+
export { evaluateCondition } from './condition-evaluator.js';
|
|
11
|
+
export { WorkflowExecutor } from './workflow-executor.js';
|
|
12
|
+
export type { AgentDispatcher, StepResult, WorkflowResult, } from './workflow-executor.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { buildDAG, detectCycles, topologicalSort } from './dag-builder.js';
|
|
2
|
+
export { DAGExecutor } from './dag-executor.js';
|
|
3
|
+
export { resolveContext, ContextResolutionError } from './context-resolver.js';
|
|
4
|
+
export { DEFAULT_RETRY_POLICY } from './dag-types.js';
|
|
5
|
+
// DSL workflow modules
|
|
6
|
+
export { workflowStepSchema, workflowDefinitionSchema, agentStepSchema, parallelStepSchema, sequenceStepSchema, conditionalStepSchema, mapReduceStepSchema, loopStepSchema, } from './dsl-schema.js';
|
|
7
|
+
export { DSLParser } from './dsl-parser.js';
|
|
8
|
+
export { substitute } from './template-engine.js';
|
|
9
|
+
export { evaluateCondition } from './condition-evaluator.js';
|
|
10
|
+
export { WorkflowExecutor } from './workflow-executor.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Substitute {{variable}} and {{step-id.field}} placeholders in a template
|
|
3
|
+
* string using values from a context object.
|
|
4
|
+
*
|
|
5
|
+
* - `{{variable}}` resolves to `context[variable]`
|
|
6
|
+
* - `{{a.b.c}}` resolves to nested path `context.a.b.c`
|
|
7
|
+
*
|
|
8
|
+
* Safe regex-based — no eval.
|
|
9
|
+
*/
|
|
10
|
+
export declare function substitute(template: string, context: Record<string, unknown>): string;
|
|
11
|
+
//# sourceMappingURL=template-engine.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Substitute {{variable}} and {{step-id.field}} placeholders in a template
|
|
3
|
+
* string using values from a context object.
|
|
4
|
+
*
|
|
5
|
+
* - `{{variable}}` resolves to `context[variable]`
|
|
6
|
+
* - `{{a.b.c}}` resolves to nested path `context.a.b.c`
|
|
7
|
+
*
|
|
8
|
+
* Safe regex-based — no eval.
|
|
9
|
+
*/
|
|
10
|
+
export function substitute(template, context) {
|
|
11
|
+
return template.replace(/\{\{([\w./-]+)\}\}/g, (_match, path) => {
|
|
12
|
+
const value = resolvePath(context, path);
|
|
13
|
+
if (value === undefined) {
|
|
14
|
+
return `{{${path}}}`;
|
|
15
|
+
}
|
|
16
|
+
return String(value);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const BLOCKED_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
20
|
+
function resolvePath(obj, path) {
|
|
21
|
+
const segments = path.split('.');
|
|
22
|
+
let current = obj;
|
|
23
|
+
for (const segment of segments) {
|
|
24
|
+
if (current === null || current === undefined) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (typeof current !== 'object') {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
if (BLOCKED_KEYS.has(segment)) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
if (!Object.prototype.hasOwnProperty.call(current, segment)) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
current = current[segment];
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=template-engine.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { WorkflowDefinition } from './dsl-schema.js';
|
|
2
|
+
export interface AgentDispatcher {
|
|
3
|
+
dispatch(agent: string, task: string, context: Record<string, unknown>): Promise<unknown>;
|
|
4
|
+
}
|
|
5
|
+
export interface StepResult {
|
|
6
|
+
stepId: string;
|
|
7
|
+
output: unknown;
|
|
8
|
+
status: 'success' | 'error';
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface WorkflowResult {
|
|
12
|
+
workflowName: string;
|
|
13
|
+
status: 'success' | 'error';
|
|
14
|
+
stepResults: StepResult[];
|
|
15
|
+
context: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export declare class WorkflowExecutor {
|
|
18
|
+
private readonly dispatcher;
|
|
19
|
+
constructor(dispatcher: AgentDispatcher);
|
|
20
|
+
execute(workflow: WorkflowDefinition): Promise<WorkflowResult>;
|
|
21
|
+
private executeStep;
|
|
22
|
+
private executeAgent;
|
|
23
|
+
private executeParallel;
|
|
24
|
+
private executeSequence;
|
|
25
|
+
private executeConditional;
|
|
26
|
+
private executeMapReduce;
|
|
27
|
+
private executeLoop;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=workflow-executor.d.ts.map
|