@nanobpm/nano-agent-graph-engine 0.17.1 → 0.18.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -2
- package/dist/cli.js +28 -10
- package/dist/guide.md +1 -1
- package/dist/index.js +7 -1
- package/dist/layout-thread.js +52 -1
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/declarative.d.ts +7 -8
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/layout.d.ts +13 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/forEach.d.ts +13 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/package.json +1 -1
- package/package.json +2 -2
- package/skills/agent-graph-authoring/SKILL.md +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nano-agent-graph-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Nano Agent Graph Engine: write durable flows in TypeScript (defineFlow), compile them to BPMN, and run them in a local engine that orchestrates scripts, headless agents, this session and you (user tasks).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
package/README.md
CHANGED
|
@@ -407,8 +407,9 @@ If no notifications appear on macOS, check System Settings → Notifications for
|
|
|
407
407
|
## Parallelism and fan-out
|
|
408
408
|
|
|
409
409
|
Flows fan out with `w.parallel([...])`, a fixed set of branches, and
|
|
410
|
-
`w.forEach("files", "file", body, { outputCollection, outputElement })`, one branch per
|
|
411
|
-
list item with the results collected in order.
|
|
410
|
+
`w.forEach("files", "file", body, { outputCollection, outputElement, name })`, one branch per
|
|
411
|
+
list item with the results collected in order. A multi-step body is a sub-process, drawn
|
|
412
|
+
expanded with its steps inline (`name` labels it, e.g. "Review & challenge each file"). Both are BPMN parallel gateways and
|
|
412
413
|
multi-instance activities, so the engine joins the branches and continues only when
|
|
413
414
|
all are done, or when `completionCondition` holds.
|
|
414
415
|
|
package/dist/cli.js
CHANGED
|
@@ -549,6 +549,12 @@ var init_forEach = __esm({
|
|
|
549
549
|
}
|
|
550
550
|
node2.completionCondition = compCond;
|
|
551
551
|
}
|
|
552
|
+
if (opts?.name !== void 0) {
|
|
553
|
+
if (typeof opts.name !== "string" || opts.name.trim() === "") {
|
|
554
|
+
throw new Error(`forEach("${itemVar}") name must be a non-empty string`);
|
|
555
|
+
}
|
|
556
|
+
node2.name = opts.name.trim();
|
|
557
|
+
}
|
|
552
558
|
if (node2.outputElement && !node2.outputCollection) {
|
|
553
559
|
throw new Error(`forEach("${itemVar}") outputElement needs an outputCollection to collect into`);
|
|
554
560
|
}
|
|
@@ -565,7 +571,7 @@ var init_forEach = __esm({
|
|
|
565
571
|
return [api2.newEdge(only.name)];
|
|
566
572
|
}
|
|
567
573
|
const subId = `Sub_${api2.nextGw()}`;
|
|
568
|
-
api2.addSubProcess(subId, mi);
|
|
574
|
+
api2.addSubProcess(subId, mi, node2.name);
|
|
569
575
|
api2.connect(incoming, subId);
|
|
570
576
|
api2.pushScope(subId);
|
|
571
577
|
const startId = `${subId}_start`;
|
|
@@ -1088,7 +1094,7 @@ var init_declarative = __esm({
|
|
|
1088
1094
|
addTimerCatchEvent: (node2) => this.addTimerCatchEvent(node2),
|
|
1089
1095
|
addGateway: (id, name2) => this.addGateway(id, name2),
|
|
1090
1096
|
addParallelGateway: (id) => this.addParallelGateway(id),
|
|
1091
|
-
addSubProcess: (id, mi) => this.addSubProcess(id, mi),
|
|
1097
|
+
addSubProcess: (id, mi, name2) => this.addSubProcess(id, mi, name2),
|
|
1092
1098
|
addPlainStart: (id) => this.addPlainStart(id),
|
|
1093
1099
|
addPlainEnd: (id) => this.addPlainEnd(id),
|
|
1094
1100
|
nextGw: () => this.gw++,
|
|
@@ -1220,11 +1226,11 @@ ${props.join("\n")}
|
|
|
1220
1226
|
}
|
|
1221
1227
|
/** An embedded sub-process whose body renders nested in its own scope, with the
|
|
1222
1228
|
* given multi-instance characteristics lifted onto it. */
|
|
1223
|
-
addSubProcess(id, mi) {
|
|
1229
|
+
addSubProcess(id, mi, name2) {
|
|
1224
1230
|
const node2 = {
|
|
1225
1231
|
id,
|
|
1226
1232
|
scope: this.currentScope(),
|
|
1227
|
-
render: (inc, outg) => ` <bpmn:subProcess id="${escapeXml(id)}">
|
|
1233
|
+
render: (inc, outg) => ` <bpmn:subProcess id="${escapeXml(id)}"${name2 ? ` name="${escapeXml(name2)}"` : ""}>
|
|
1228
1234
|
` + incomingOutgoing(inc, outg) + mi + this.renderScope(id) + `
|
|
1229
1235
|
</bpmn:subProcess>`
|
|
1230
1236
|
};
|
|
@@ -29136,6 +29142,7 @@ import fs2 from "node:fs";
|
|
|
29136
29142
|
import path2 from "node:path";
|
|
29137
29143
|
import crypto3 from "node:crypto";
|
|
29138
29144
|
import { Worker } from "node:worker_threads";
|
|
29145
|
+
import { createRequire } from "node:module";
|
|
29139
29146
|
function threadUrl() {
|
|
29140
29147
|
const js = new URL("./layout-thread.js", import.meta.url);
|
|
29141
29148
|
return fs2.existsSync(js) ? js : new URL("./layout-thread.ts", import.meta.url);
|
|
@@ -29161,7 +29168,8 @@ function layoutV2(xml3, file2) {
|
|
|
29161
29168
|
return p2;
|
|
29162
29169
|
}
|
|
29163
29170
|
async function layoutXml(xml3) {
|
|
29164
|
-
const file2 = path2.join(cacheDir(), `${crypto3.createHash("sha256").update(
|
|
29171
|
+
const file2 = path2.join(cacheDir(), `${crypto3.createHash("sha256").update(`${workflowVersion}
|
|
29172
|
+
${xml3}`).digest("hex").slice(0, 32)}.bpmn`);
|
|
29165
29173
|
try {
|
|
29166
29174
|
return fs2.readFileSync(file2, "utf8");
|
|
29167
29175
|
} catch {
|
|
@@ -29187,13 +29195,23 @@ async function layoutXml(xml3) {
|
|
|
29187
29195
|
function layoutFlow(flow) {
|
|
29188
29196
|
return layoutXml(declarativeToBpmn(flow));
|
|
29189
29197
|
}
|
|
29190
|
-
var budgetMs, cacheDir, pending;
|
|
29198
|
+
var workflowVersion, budgetMs, cacheDir, pending;
|
|
29191
29199
|
var init_layout = __esm({
|
|
29192
29200
|
"src/layout.ts"() {
|
|
29193
29201
|
"use strict";
|
|
29194
29202
|
init_dist();
|
|
29195
29203
|
init_dist7();
|
|
29196
29204
|
init_paths();
|
|
29205
|
+
workflowVersion = (() => {
|
|
29206
|
+
if ("0.19.0") return "0.19.0";
|
|
29207
|
+
try {
|
|
29208
|
+
let dir = path2.dirname(createRequire(import.meta.url).resolve("@nanobpm/workflow"));
|
|
29209
|
+
while (!fs2.existsSync(path2.join(dir, "package.json")) && path2.dirname(dir) !== dir) dir = path2.dirname(dir);
|
|
29210
|
+
return JSON.parse(fs2.readFileSync(path2.join(dir, "package.json"), "utf8")).version;
|
|
29211
|
+
} catch {
|
|
29212
|
+
return "unknown";
|
|
29213
|
+
}
|
|
29214
|
+
})();
|
|
29197
29215
|
budgetMs = () => Number(process.env.AGE_LAYOUT_MS ?? 5e3);
|
|
29198
29216
|
cacheDir = () => path2.join(engineDir(), "layout-cache");
|
|
29199
29217
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -31359,11 +31377,11 @@ var init_nanobpmn_engine = __esm({
|
|
|
31359
31377
|
|
|
31360
31378
|
// src/wasm.ts
|
|
31361
31379
|
import fs4 from "node:fs";
|
|
31362
|
-
import { createRequire } from "node:module";
|
|
31380
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
31363
31381
|
function wasmPath() {
|
|
31364
31382
|
const local = new URL("./nanobpmn_engine_bg.wasm", import.meta.url);
|
|
31365
31383
|
if (fs4.existsSync(local)) return local.pathname;
|
|
31366
|
-
const req =
|
|
31384
|
+
const req = createRequire2(import.meta.url);
|
|
31367
31385
|
const pkg = req.resolve("@nanobpm/engine-wasm/readmodel");
|
|
31368
31386
|
return pkg.replace(/nanobpmn_engine\.js$/, "nanobpmn_engine_bg.wasm");
|
|
31369
31387
|
}
|
|
@@ -31527,7 +31545,7 @@ var init_resolve_hook = __esm({
|
|
|
31527
31545
|
// src/typecheck.ts
|
|
31528
31546
|
import fs6 from "node:fs";
|
|
31529
31547
|
import path4 from "node:path";
|
|
31530
|
-
import { createRequire as
|
|
31548
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
31531
31549
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
31532
31550
|
function typecheckKit() {
|
|
31533
31551
|
const here = path4.dirname(fileURLToPath2(import.meta.url));
|
|
@@ -31536,7 +31554,7 @@ function typecheckKit() {
|
|
|
31536
31554
|
return void 0;
|
|
31537
31555
|
}
|
|
31538
31556
|
function loadTs(kit) {
|
|
31539
|
-
return tsCache ??=
|
|
31557
|
+
return tsCache ??= createRequire3(path4.join(kit, "ts.cjs"))("./ts.cjs");
|
|
31540
31558
|
}
|
|
31541
31559
|
function typecheckFlows(files) {
|
|
31542
31560
|
const kit = typecheckKit();
|
package/dist/guide.md
CHANGED
|
@@ -124,7 +124,7 @@ export const triage = defineFlow("triage", { Start: { in: Input }, fetch: { in:
|
|
|
124
124
|
- **First of**: `w.race({ timeout: { timer: { after: "PT1H" }, do: (b) => … }, reply: { signal: { correlationKey: "prKey" }, do: (b) => … } })` waits for whichever event comes first. A timer + signal race is a poll delay that a message can cut short.
|
|
125
125
|
- **SLA on a step**: `w.task(…).boundary({ timer: "PT50M", onTimeout: (b) => b.run("sla", …) })` cancels the step when the timer fires and runs `onTimeout`, which then continues with the rest of the flow.
|
|
126
126
|
- **Fixed branches**: `w.parallel([(b) => …, (b) => …])` runs every branch and joins them before continuing.
|
|
127
|
-
- **Fan-out**: `w.forEach("items", "item", (b) => …, { outputCollection: "results", outputElement: "notes" })` runs one branch per list item, with results collected in order. Options: `sequential`, `completionCondition
|
|
127
|
+
- **Fan-out**: `w.forEach("items", "item", (b) => …, { outputCollection: "results", outputElement: "notes" })` runs one branch per list item, with results collected in order. Options: `sequential`, `completionCondition`, and `name` to label a multi-step body (it's drawn as an expanded sub-process). Up to 4 headless agent branches run at once.
|
|
128
128
|
- **Waits**:
|
|
129
129
|
- `w.timer(name, { after: "PT1H" })` waits for a duration.
|
|
130
130
|
- `w.startOn({ cycle: "R/PT24H" })` starts the flow on a timer.
|
package/dist/index.js
CHANGED
|
@@ -464,6 +464,12 @@ registerNodeKind("forEach", {
|
|
|
464
464
|
}
|
|
465
465
|
node.completionCondition = compCond;
|
|
466
466
|
}
|
|
467
|
+
if (opts?.name !== void 0) {
|
|
468
|
+
if (typeof opts.name !== "string" || opts.name.trim() === "") {
|
|
469
|
+
throw new Error(`forEach("${itemVar}") name must be a non-empty string`);
|
|
470
|
+
}
|
|
471
|
+
node.name = opts.name.trim();
|
|
472
|
+
}
|
|
467
473
|
if (node.outputElement && !node.outputCollection) {
|
|
468
474
|
throw new Error(`forEach("${itemVar}") outputElement needs an outputCollection to collect into`);
|
|
469
475
|
}
|
|
@@ -480,7 +486,7 @@ registerNodeKind("forEach", {
|
|
|
480
486
|
return [api.newEdge(only.name)];
|
|
481
487
|
}
|
|
482
488
|
const subId = `Sub_${api.nextGw()}`;
|
|
483
|
-
api.addSubProcess(subId, mi);
|
|
489
|
+
api.addSubProcess(subId, mi, node.name);
|
|
484
490
|
api.connect(incoming, subId);
|
|
485
491
|
api.pushScope(subId);
|
|
486
492
|
const startId = `${subId}_start`;
|
package/dist/layout-thread.js
CHANGED
|
@@ -12797,9 +12797,60 @@ async function layoutBpmn(bpmnXml) {
|
|
|
12797
12797
|
}
|
|
12798
12798
|
throw new Error('layoutBpmn requires the optional peer dependency "bpmn-auto-layout". Install it to generate diagram layout: npm i bpmn-auto-layout', { cause });
|
|
12799
12799
|
}
|
|
12800
|
-
const result = await layoutProcess2(bpmnXml);
|
|
12800
|
+
const result = await layoutProcess2(seedExpandedSubProcesses(bpmnXml));
|
|
12801
12801
|
return typeof result === "string" ? result : result.xml;
|
|
12802
12802
|
}
|
|
12803
|
+
var DI_NS = {
|
|
12804
|
+
bpmndi: "http://www.omg.org/spec/BPMN/20100524/DI",
|
|
12805
|
+
dc: "http://www.omg.org/spec/DD/20100524/DC"
|
|
12806
|
+
};
|
|
12807
|
+
function xmlAttrs(tag, allowSpacedEquals = false) {
|
|
12808
|
+
const attrs = /* @__PURE__ */ new Map();
|
|
12809
|
+
const body = tag.replace(/^<[^\s/>]+/, "");
|
|
12810
|
+
for (const m of body.matchAll(/([^\s=/>]+)(\s*)=(\s*)(?:"([^"]*)"|'([^']*)')/g)) {
|
|
12811
|
+
if (!allowSpacedEquals && (m[2] !== "" || m[3] !== ""))
|
|
12812
|
+
continue;
|
|
12813
|
+
const name2 = m[1];
|
|
12814
|
+
const value = m[4] ?? m[5];
|
|
12815
|
+
if (name2 !== void 0 && value !== void 0 && !attrs.has(name2))
|
|
12816
|
+
attrs.set(name2, value);
|
|
12817
|
+
}
|
|
12818
|
+
return attrs;
|
|
12819
|
+
}
|
|
12820
|
+
function xmlId(tag) {
|
|
12821
|
+
const id = xmlAttrs(tag).get("id");
|
|
12822
|
+
return id === void 0 || id === "" ? void 0 : id;
|
|
12823
|
+
}
|
|
12824
|
+
function maskNonMarkup(xml3) {
|
|
12825
|
+
return xml3.replace(/<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<\?[\s\S]*?\?>/g, (m) => " ".repeat(m.length));
|
|
12826
|
+
}
|
|
12827
|
+
function seedExpandedSubProcesses(bpmnXml) {
|
|
12828
|
+
const scan = maskNonMarkup(bpmnXml);
|
|
12829
|
+
if (/<(?:\w+:)?BPMNDiagram\b/.test(scan))
|
|
12830
|
+
return bpmnXml;
|
|
12831
|
+
const planes = [];
|
|
12832
|
+
for (const proc of scan.matchAll(/<bpmn:process\b[^>]*>[\s\S]*?<\/bpmn:process>/g)) {
|
|
12833
|
+
const procId = xmlId(proc[0].slice(0, proc[0].indexOf(">") + 1));
|
|
12834
|
+
if (procId === void 0)
|
|
12835
|
+
continue;
|
|
12836
|
+
const subs = [...proc[0].matchAll(/<bpmn:subProcess\b[^>]*>/g)].filter((m) => xmlAttrs(m[0]).get("triggeredByEvent") !== "true").map((m) => xmlId(m[0])).filter((id) => id !== void 0);
|
|
12837
|
+
if (subs.length === 0)
|
|
12838
|
+
continue;
|
|
12839
|
+
const shapes = subs.map((id, i) => `<bpmndi:BPMNShape id="Seed_${i}_${id}_di" bpmnElement="${id}" isExpanded="true"><dc:Bounds x="0" y="0" width="100" height="80"/></bpmndi:BPMNShape>`);
|
|
12840
|
+
planes.push(`<bpmndi:BPMNDiagram id="Seed_${procId}_diagram"><bpmndi:BPMNPlane id="Seed_${procId}_plane" bpmnElement="${procId}">` + shapes.join("") + `</bpmndi:BPMNPlane></bpmndi:BPMNDiagram>`);
|
|
12841
|
+
}
|
|
12842
|
+
if (planes.length === 0)
|
|
12843
|
+
return bpmnXml;
|
|
12844
|
+
const end = /<\/bpmn:definitions>\s*$/.exec(scan);
|
|
12845
|
+
const defs = /<bpmn:definitions\b[^>]*>/.exec(scan);
|
|
12846
|
+
if (end === null || defs === null)
|
|
12847
|
+
return bpmnXml;
|
|
12848
|
+
const defsAttrs = xmlAttrs(defs[0], true);
|
|
12849
|
+
const missing = Object.entries(DI_NS).filter(([prefix2]) => !defsAttrs.has(`xmlns:${prefix2}`)).map(([prefix2, uri2]) => ` xmlns:${prefix2}="${uri2}"`).join("");
|
|
12850
|
+
const insertAt = defs.index + "<bpmn:definitions".length;
|
|
12851
|
+
const xml3 = bpmnXml.slice(0, insertAt) + missing + bpmnXml.slice(insertAt, end.index) + planes.join("") + bpmnXml.slice(end.index);
|
|
12852
|
+
return xml3;
|
|
12853
|
+
}
|
|
12803
12854
|
|
|
12804
12855
|
// src/layout-thread.ts
|
|
12805
12856
|
var xml2 = await layoutBpmn(workerData.xml);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeclarativeFlow, FlowContracts, FlowNode, JsonObject, NodeEnvelopes, StepHandler, TimerStart } from "./types.js";
|
|
2
2
|
import type { Envelope } from "./envelope.js";
|
|
3
3
|
import type { HumanIoMapping } from "./io-mapping.js";
|
|
4
|
+
import type { ForEachOpts } from "./nodes/forEach.js";
|
|
4
5
|
import "./nodes/index.js";
|
|
5
6
|
/** The TS payload type of a contract's input envelope (untyped fallback). */
|
|
6
7
|
export type InPayload<Ct> = Ct extends {
|
|
@@ -149,6 +150,8 @@ export interface FlowBuilder<C extends object = object> {
|
|
|
149
150
|
* item bound to the `itemVar` variable in the child's scope. A single-activity
|
|
150
151
|
* body attaches the multi-instance characteristics to that activity; a
|
|
151
152
|
* multi-step body is wrapped in an embedded multi-instance sub-process. Options:
|
|
153
|
+
* - `name` — label the multi-step body's sub-process on the diagram (e.g.
|
|
154
|
+
* "Review & challenge each file"); a single-step body keeps its step's name.
|
|
152
155
|
* - `sequential` — run children one at a time (a sequential MI) instead of all
|
|
153
156
|
* at once (the default: a parallel MI).
|
|
154
157
|
* - `outputCollection` / `outputElement` — collect each child's `outputElement`
|
|
@@ -158,12 +161,7 @@ export interface FlowBuilder<C extends object = object> {
|
|
|
158
161
|
* after a child completes, the remaining children are cancelled and the body
|
|
159
162
|
* completes early.
|
|
160
163
|
*/
|
|
161
|
-
forEach(collection: string, itemVar: string, body: Block<C>, opts?:
|
|
162
|
-
sequential?: boolean;
|
|
163
|
-
outputCollection?: string;
|
|
164
|
-
outputElement?: string;
|
|
165
|
-
completionCondition?: string;
|
|
166
|
-
}): FlowBuilder<C>;
|
|
164
|
+
forEach(collection: string, itemVar: string, body: Block<C>, opts?: ForEachOpts): FlowBuilder<C>;
|
|
167
165
|
/** Exit the enclosing loop (routes to whatever follows it). Only valid inside
|
|
168
166
|
* a `loop`. */
|
|
169
167
|
break(): FlowBuilder<C>;
|
|
@@ -334,8 +332,9 @@ export interface EmitApi {
|
|
|
334
332
|
addGateway(id: string, name?: string): RenderNode;
|
|
335
333
|
/** Place a `<bpmn:parallelGateway>`. */
|
|
336
334
|
addParallelGateway(id: string): RenderNode;
|
|
337
|
-
/** Place an embedded `<bpmn:subProcess>` whose body renders in its own scope
|
|
338
|
-
|
|
335
|
+
/** Place an embedded `<bpmn:subProcess>` whose body renders in its own scope,
|
|
336
|
+
* optionally labelled with `name`. */
|
|
337
|
+
addSubProcess(id: string, mi: string, name?: string): RenderNode;
|
|
339
338
|
/** Place a plain none `<bpmn:startEvent>` (for an embedded sub-process). */
|
|
340
339
|
addPlainStart(id: string): void;
|
|
341
340
|
/** Place a plain `<bpmn:endEvent>` (for an embedded sub-process). */
|
|
@@ -10,6 +10,19 @@ import type { DeclarativeFlow } from "./types.js";
|
|
|
10
10
|
* clear error is thrown if it is missing.
|
|
11
11
|
*/
|
|
12
12
|
export declare function layoutBpmn(bpmnXml: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* bpmn-auto-layout 2 draws a sub-process EXPANDED (its steps inline, on the
|
|
15
|
+
* main diagram) only when the input's own DI says `isExpanded="true"`; otherwise
|
|
16
|
+
* it collapses it onto a drill-down plane, which hides the steps — e.g. a
|
|
17
|
+
* multi-step `forEach` body — from anyone reading the diagram. A code-first
|
|
18
|
+
* model has no DI, so seed a minimal diagram that marks each embedded
|
|
19
|
+
* sub-process expanded (one plane per process). Input that already has a
|
|
20
|
+
* diagram is returned untouched: its expanded/collapsed choices are the author's.
|
|
21
|
+
* Only the `bpmn:` prefix our emitters write is recognised; other input passes
|
|
22
|
+
* through and lays out as before. Exported for tests only (not re-exported
|
|
23
|
+
* from the package index).
|
|
24
|
+
*/
|
|
25
|
+
export declare function seedExpandedSubProcesses(bpmnXml: string): string;
|
|
13
26
|
/**
|
|
14
27
|
* Derive an executable BPMN model from a declarative flow AND auto-generate its
|
|
15
28
|
* diagram (DI), so the model opens rendered in a modeller/viewer. Convenience
|
|
@@ -15,10 +15,23 @@ interface ForEachNode {
|
|
|
15
15
|
outputElement?: string;
|
|
16
16
|
/** FEEL boolean that, once true, completes the body early. */
|
|
17
17
|
completionCondition?: string;
|
|
18
|
+
/** Label for the multi-step body's sub-process (what the box does, on the diagram). */
|
|
19
|
+
name?: string;
|
|
18
20
|
}
|
|
19
21
|
declare module "../types.js" {
|
|
20
22
|
interface FlowNodeRegistry {
|
|
21
23
|
forEach: ForEachNode;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
26
|
+
/** `forEach` options — the single definition `FlowBuilder.forEach` uses too. */
|
|
27
|
+
export interface ForEachOpts {
|
|
28
|
+
/** Label the multi-step body's sub-process, e.g. "Review & challenge each file".
|
|
29
|
+
* A single-step body has no box of its own (the MI is lifted onto the step,
|
|
30
|
+
* which keeps its own name), so the label does not apply there. */
|
|
31
|
+
name?: string;
|
|
32
|
+
sequential?: boolean;
|
|
33
|
+
outputCollection?: string;
|
|
34
|
+
outputElement?: string;
|
|
35
|
+
completionCondition?: string;
|
|
36
|
+
}
|
|
24
37
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanobpm/workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Code-first durable orchestration for nanobpmn (ADR 0044/0045). Author a durable workflow as a declarative flow — `defineFlow(id, w => { w.run(...); w.signal(...); w.task(...) })` — and the SDK derives the executable BPMN model, the job types, and the message/correlation wiring, then hosts a generic worker. `w.run` is a local step, `w.signal` is a durable human-in-the-loop wait, `w.task` is a step serviced by an external worker. `defineFlow` is the single code-first surface; the imperative `defineWorkflow` replay function is experimental/internal, not a recommended API. No diagram, no task-type wiring, no correlation plumbing authored by hand — and you can optionally auto-generate a diagram (DI) for the derived model with `declarativeToLayoutedBpmn` via the optional `bpmn-auto-layout` peer dependency. Talks to a running nanobpmn gateway through @nanobpm/nano-sdk (the shared engine-transport spine — ADR 0055), which negotiates the Falcon protocol on a Nano server and REST elsewhere.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanobpm/nano-agent-graph-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Durable BPMN process engine for Claude Code: code-first flows (defineFlow) that orchestrate scripts, Claude Code agents and people.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@nanobpm/agentic": "^0.16.0",
|
|
64
64
|
"@nanobpm/engine-wasm": "^0.11.0",
|
|
65
65
|
"@nanobpm/nano-app-schema": "^0.11.0",
|
|
66
|
-
"@nanobpm/workflow": "^0.
|
|
66
|
+
"@nanobpm/workflow": "^0.19.0",
|
|
67
67
|
"@tailwindcss/cli": "^4.3.5",
|
|
68
68
|
"@tanstack/react-query": "^5.107.1",
|
|
69
69
|
"@types/node": "^26.6.6",
|
|
@@ -124,7 +124,7 @@ export const triage = defineFlow("triage", { Start: { in: Input }, fetch: { in:
|
|
|
124
124
|
- **First of**: `w.race({ timeout: { timer: { after: "PT1H" }, do: (b) => … }, reply: { signal: { correlationKey: "prKey" }, do: (b) => … } })` waits for whichever event comes first. A timer + signal race is a poll delay that a message can cut short.
|
|
125
125
|
- **SLA on a step**: `w.task(…).boundary({ timer: "PT50M", onTimeout: (b) => b.run("sla", …) })` cancels the step when the timer fires and runs `onTimeout`, which then continues with the rest of the flow.
|
|
126
126
|
- **Fixed branches**: `w.parallel([(b) => …, (b) => …])` runs every branch and joins them before continuing.
|
|
127
|
-
- **Fan-out**: `w.forEach("items", "item", (b) => …, { outputCollection: "results", outputElement: "notes" })` runs one branch per list item, with results collected in order. Options: `sequential`, `completionCondition
|
|
127
|
+
- **Fan-out**: `w.forEach("items", "item", (b) => …, { outputCollection: "results", outputElement: "notes" })` runs one branch per list item, with results collected in order. Options: `sequential`, `completionCondition`, and `name` to label a multi-step body (it's drawn as an expanded sub-process). Up to 4 headless agent branches run at once.
|
|
128
128
|
- **Waits**:
|
|
129
129
|
- `w.timer(name, { after: "PT1H" })` waits for a duration.
|
|
130
130
|
- `w.startOn({ cycle: "R/PT24H" })` starts the flow on a timer.
|