@nanobpm/nano-agent-graph-engine 0.0.0-stage → 0.17.1
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 +20 -0
- package/.claude-plugin/plugin.json +21 -0
- package/.mcp.json +8 -0
- package/README.md +525 -2
- package/dist/cli.js +55815 -0
- package/dist/explorer-app.html +196 -0
- package/dist/explorer.html +196 -0
- package/dist/guide.md +147 -0
- package/dist/index.js +1256 -0
- package/dist/layout-thread.js +12806 -0
- package/dist/nanobpmn_engine_bg.wasm +0 -0
- package/dist/step-thread.js +55 -0
- package/dist/typecheck/agent-graph-engine/agents.d.ts +120 -0
- package/dist/typecheck/agent-graph-engine/index.d.ts +124 -0
- package/dist/typecheck/agent-graph-engine/input.d.ts +57 -0
- package/dist/typecheck/agent-graph-engine/paths.d.ts +35 -0
- package/dist/typecheck/lib.decorators.d.ts +384 -0
- package/dist/typecheck/lib.decorators.legacy.d.ts +22 -0
- package/dist/typecheck/lib.es2015.collection.d.ts +147 -0
- package/dist/typecheck/lib.es2015.core.d.ts +597 -0
- package/dist/typecheck/lib.es2015.d.ts +28 -0
- package/dist/typecheck/lib.es2015.generator.d.ts +77 -0
- package/dist/typecheck/lib.es2015.iterable.d.ts +605 -0
- package/dist/typecheck/lib.es2015.promise.d.ts +81 -0
- package/dist/typecheck/lib.es2015.proxy.d.ts +128 -0
- package/dist/typecheck/lib.es2015.reflect.d.ts +144 -0
- package/dist/typecheck/lib.es2015.symbol.d.ts +46 -0
- package/dist/typecheck/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/dist/typecheck/lib.es2016.array.include.d.ts +116 -0
- package/dist/typecheck/lib.es2016.d.ts +21 -0
- package/dist/typecheck/lib.es2016.full.d.ts +23 -0
- package/dist/typecheck/lib.es2016.intl.d.ts +31 -0
- package/dist/typecheck/lib.es2017.arraybuffer.d.ts +21 -0
- package/dist/typecheck/lib.es2017.d.ts +26 -0
- package/dist/typecheck/lib.es2017.date.d.ts +31 -0
- package/dist/typecheck/lib.es2017.full.d.ts +23 -0
- package/dist/typecheck/lib.es2017.intl.d.ts +44 -0
- package/dist/typecheck/lib.es2017.object.d.ts +49 -0
- package/dist/typecheck/lib.es2017.sharedmemory.d.ts +135 -0
- package/dist/typecheck/lib.es2017.string.d.ts +45 -0
- package/dist/typecheck/lib.es2017.typedarrays.d.ts +53 -0
- package/dist/typecheck/lib.es2018.asyncgenerator.d.ts +77 -0
- package/dist/typecheck/lib.es2018.asynciterable.d.ts +53 -0
- package/dist/typecheck/lib.es2018.d.ts +24 -0
- package/dist/typecheck/lib.es2018.full.d.ts +24 -0
- package/dist/typecheck/lib.es2018.intl.d.ts +83 -0
- package/dist/typecheck/lib.es2018.promise.d.ts +30 -0
- package/dist/typecheck/lib.es2018.regexp.d.ts +37 -0
- package/dist/typecheck/lib.es2019.array.d.ts +79 -0
- package/dist/typecheck/lib.es2019.d.ts +24 -0
- package/dist/typecheck/lib.es2019.full.d.ts +24 -0
- package/dist/typecheck/lib.es2019.intl.d.ts +23 -0
- package/dist/typecheck/lib.es2019.object.d.ts +33 -0
- package/dist/typecheck/lib.es2019.string.d.ts +37 -0
- package/dist/typecheck/lib.es2019.symbol.d.ts +24 -0
- package/dist/typecheck/lib.es2020.bigint.d.ts +765 -0
- package/dist/typecheck/lib.es2020.d.ts +27 -0
- package/dist/typecheck/lib.es2020.date.d.ts +42 -0
- package/dist/typecheck/lib.es2020.full.d.ts +24 -0
- package/dist/typecheck/lib.es2020.intl.d.ts +474 -0
- package/dist/typecheck/lib.es2020.number.d.ts +28 -0
- package/dist/typecheck/lib.es2020.promise.d.ts +47 -0
- package/dist/typecheck/lib.es2020.sharedmemory.d.ts +99 -0
- package/dist/typecheck/lib.es2020.string.d.ts +44 -0
- package/dist/typecheck/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/dist/typecheck/lib.es2021.d.ts +23 -0
- package/dist/typecheck/lib.es2021.full.d.ts +24 -0
- package/dist/typecheck/lib.es2021.intl.d.ts +166 -0
- package/dist/typecheck/lib.es2021.promise.d.ts +48 -0
- package/dist/typecheck/lib.es2021.string.d.ts +33 -0
- package/dist/typecheck/lib.es2021.weakref.d.ts +78 -0
- package/dist/typecheck/lib.es2022.array.d.ts +121 -0
- package/dist/typecheck/lib.es2022.d.ts +25 -0
- package/dist/typecheck/lib.es2022.error.d.ts +75 -0
- package/dist/typecheck/lib.es2022.full.d.ts +24 -0
- package/dist/typecheck/lib.es2022.intl.d.ts +145 -0
- package/dist/typecheck/lib.es2022.object.d.ts +26 -0
- package/dist/typecheck/lib.es2022.regexp.d.ts +39 -0
- package/dist/typecheck/lib.es2022.string.d.ts +25 -0
- package/dist/typecheck/lib.es2023.array.d.ts +924 -0
- package/dist/typecheck/lib.es2023.collection.d.ts +21 -0
- package/dist/typecheck/lib.es2023.d.ts +22 -0
- package/dist/typecheck/lib.es2023.full.d.ts +24 -0
- package/dist/typecheck/lib.es2023.intl.d.ts +56 -0
- package/dist/typecheck/lib.es2024.arraybuffer.d.ts +65 -0
- package/dist/typecheck/lib.es2024.collection.d.ts +29 -0
- package/dist/typecheck/lib.es2024.d.ts +26 -0
- package/dist/typecheck/lib.es2024.full.d.ts +24 -0
- package/dist/typecheck/lib.es2024.object.d.ts +29 -0
- package/dist/typecheck/lib.es2024.promise.d.ts +35 -0
- package/dist/typecheck/lib.es2024.regexp.d.ts +25 -0
- package/dist/typecheck/lib.es2024.sharedmemory.d.ts +68 -0
- package/dist/typecheck/lib.es2024.string.d.ts +29 -0
- package/dist/typecheck/lib.es5.d.ts +4601 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/client.d.ts +169 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/declarative.d.ts +366 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/envelope.d.ts +77 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/imperative.d.ts +32 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/index.d.ts +14 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/io-mapping.d.ts +32 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/layout.d.ts +22 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/boundary.d.ts +63 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/branch.d.ts +11 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/break.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/continue.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/end.d.ts +40 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/forEach.d.ts +24 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/human.d.ts +44 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/index.d.ts +15 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/loop.d.ts +9 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/parallel.d.ts +9 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/race.d.ts +54 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/registry.d.ts +33 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/run.d.ts +12 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/signal.d.ts +11 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/switch.d.ts +11 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/task.d.ts +82 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/nodes/timer.d.ts +9 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/diff.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/index.d.ts +8 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/normalize.d.ts +19 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/parity.d.ts +28 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/test-support/xml.d.ts +17 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/types.d.ts +146 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/worker.d.ts +92 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/dist/xml.d.ts +14 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/package.json +65 -0
- package/dist/typecheck/node_modules/@nanobpm/workflow/src/bpmn-auto-layout.d.ts +10 -0
- package/dist/typecheck/node_modules/@types/node/assert/strict.d.ts +68 -0
- package/dist/typecheck/node_modules/@types/node/assert.d.ts +1077 -0
- package/dist/typecheck/node_modules/@types/node/async_hooks.d.ts +711 -0
- package/dist/typecheck/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/dist/typecheck/node_modules/@types/node/buffer.d.ts +1800 -0
- package/dist/typecheck/node_modules/@types/node/child_process.d.ts +1361 -0
- package/dist/typecheck/node_modules/@types/node/cluster.d.ts +432 -0
- package/dist/typecheck/node_modules/@types/node/console.d.ts +93 -0
- package/dist/typecheck/node_modules/@types/node/constants.d.ts +14 -0
- package/dist/typecheck/node_modules/@types/node/crypto.d.ts +3964 -0
- package/dist/typecheck/node_modules/@types/node/dgram.d.ts +652 -0
- package/dist/typecheck/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
- package/dist/typecheck/node_modules/@types/node/dns/promises.d.ts +497 -0
- package/dist/typecheck/node_modules/@types/node/dns.d.ts +876 -0
- package/dist/typecheck/node_modules/@types/node/domain.d.ts +150 -0
- package/dist/typecheck/node_modules/@types/node/events.d.ts +1008 -0
- package/dist/typecheck/node_modules/@types/node/ffi.d.ts +500 -0
- package/dist/typecheck/node_modules/@types/node/fs/promises.d.ts +1477 -0
- package/dist/typecheck/node_modules/@types/node/fs.d.ts +4803 -0
- package/dist/typecheck/node_modules/@types/node/globals.d.ts +150 -0
- package/dist/typecheck/node_modules/@types/node/globals.typedarray.d.ts +101 -0
- package/dist/typecheck/node_modules/@types/node/http.d.ts +2218 -0
- package/dist/typecheck/node_modules/@types/node/http2.d.ts +2498 -0
- package/dist/typecheck/node_modules/@types/node/https.d.ts +400 -0
- package/dist/typecheck/node_modules/@types/node/index.d.ts +116 -0
- package/dist/typecheck/node_modules/@types/node/inspector/promises.d.ts +35 -0
- package/dist/typecheck/node_modules/@types/node/inspector.d.ts +265 -0
- package/dist/typecheck/node_modules/@types/node/inspector.generated.d.ts +4406 -0
- package/dist/typecheck/node_modules/@types/node/module.d.ts +726 -0
- package/dist/typecheck/node_modules/@types/node/net.d.ts +1074 -0
- package/dist/typecheck/node_modules/@types/node/os.d.ts +498 -0
- package/dist/typecheck/node_modules/@types/node/package.json +140 -0
- package/dist/typecheck/node_modules/@types/node/path/posix.d.ts +8 -0
- package/dist/typecheck/node_modules/@types/node/path/win32.d.ts +8 -0
- package/dist/typecheck/node_modules/@types/node/path.d.ts +178 -0
- package/dist/typecheck/node_modules/@types/node/perf_hooks.d.ts +617 -0
- package/dist/typecheck/node_modules/@types/node/process.d.ts +2269 -0
- package/dist/typecheck/node_modules/@types/node/punycode.d.ts +89 -0
- package/dist/typecheck/node_modules/@types/node/querystring.d.ts +139 -0
- package/dist/typecheck/node_modules/@types/node/quic.d.ts +2191 -0
- package/dist/typecheck/node_modules/@types/node/readline/promises.d.ts +158 -0
- package/dist/typecheck/node_modules/@types/node/readline.d.ts +508 -0
- package/dist/typecheck/node_modules/@types/node/repl.d.ts +420 -0
- package/dist/typecheck/node_modules/@types/node/sea.d.ts +47 -0
- package/dist/typecheck/node_modules/@types/node/sqlite.d.ts +1140 -0
- package/dist/typecheck/node_modules/@types/node/stream/consumers.d.ts +114 -0
- package/dist/typecheck/node_modules/@types/node/stream/iter.d.ts +449 -0
- package/dist/typecheck/node_modules/@types/node/stream/promises.d.ts +211 -0
- package/dist/typecheck/node_modules/@types/node/stream/web.d.ts +320 -0
- package/dist/typecheck/node_modules/@types/node/stream.d.ts +1806 -0
- package/dist/typecheck/node_modules/@types/node/string_decoder.d.ts +27 -0
- package/dist/typecheck/node_modules/@types/node/test/reporters.d.ts +60 -0
- package/dist/typecheck/node_modules/@types/node/test.d.ts +2558 -0
- package/dist/typecheck/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/dist/typecheck/node_modules/@types/node/timers.d.ts +149 -0
- package/dist/typecheck/node_modules/@types/node/tls.d.ts +1232 -0
- package/dist/typecheck/node_modules/@types/node/trace_events.d.ts +103 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +467 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/dist/typecheck/node_modules/@types/node/ts5.6/index.d.ts +118 -0
- package/dist/typecheck/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/dist/typecheck/node_modules/@types/node/ts5.7/index.d.ts +118 -0
- package/dist/typecheck/node_modules/@types/node/tty.d.ts +226 -0
- package/dist/typecheck/node_modules/@types/node/url.d.ts +556 -0
- package/dist/typecheck/node_modules/@types/node/util/types.d.ts +558 -0
- package/dist/typecheck/node_modules/@types/node/util.d.ts +1680 -0
- package/dist/typecheck/node_modules/@types/node/v8.d.ts +1059 -0
- package/dist/typecheck/node_modules/@types/node/vfs.d.ts +211 -0
- package/dist/typecheck/node_modules/@types/node/vm.d.ts +1137 -0
- package/dist/typecheck/node_modules/@types/node/wasi.d.ts +131 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/events.d.ts +106 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/streams.d.ts +119 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/dist/typecheck/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/dist/typecheck/node_modules/@types/node/worker_threads.d.ts +672 -0
- package/dist/typecheck/node_modules/@types/node/zlib/iter.d.ts +131 -0
- package/dist/typecheck/node_modules/@types/node/zlib.d.ts +1364 -0
- package/dist/typecheck/node_modules/undici-types/agent.d.ts +30 -0
- package/dist/typecheck/node_modules/undici-types/api.d.ts +43 -0
- package/dist/typecheck/node_modules/undici-types/balanced-pool.d.ts +30 -0
- package/dist/typecheck/node_modules/undici-types/cache-interceptor.d.ts +179 -0
- package/dist/typecheck/node_modules/undici-types/cache.d.ts +36 -0
- package/dist/typecheck/node_modules/undici-types/client-stats.d.ts +15 -0
- package/dist/typecheck/node_modules/undici-types/client.d.ts +134 -0
- package/dist/typecheck/node_modules/undici-types/connector.d.ts +37 -0
- package/dist/typecheck/node_modules/undici-types/content-type.d.ts +21 -0
- package/dist/typecheck/node_modules/undici-types/cookies.d.ts +30 -0
- package/dist/typecheck/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/dist/typecheck/node_modules/undici-types/dispatcher.d.ts +253 -0
- package/dist/typecheck/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
- package/dist/typecheck/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/dist/typecheck/node_modules/undici-types/errors.d.ts +187 -0
- package/dist/typecheck/node_modules/undici-types/eventsource.d.ts +66 -0
- package/dist/typecheck/node_modules/undici-types/fetch.d.ts +235 -0
- package/dist/typecheck/node_modules/undici-types/formdata.d.ts +108 -0
- package/dist/typecheck/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/dist/typecheck/node_modules/undici-types/global-origin.d.ts +7 -0
- package/dist/typecheck/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/dist/typecheck/node_modules/undici-types/handlers.d.ts +16 -0
- package/dist/typecheck/node_modules/undici-types/header.d.ts +165 -0
- package/dist/typecheck/node_modules/undici-types/index.d.ts +93 -0
- package/dist/typecheck/node_modules/undici-types/interceptors.d.ts +80 -0
- package/dist/typecheck/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/dist/typecheck/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/dist/typecheck/node_modules/undici-types/mock-client.d.ts +27 -0
- package/dist/typecheck/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/dist/typecheck/node_modules/undici-types/mock-interceptor.d.ts +98 -0
- package/dist/typecheck/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/dist/typecheck/node_modules/undici-types/package.json +55 -0
- package/dist/typecheck/node_modules/undici-types/patch.d.ts +29 -0
- package/dist/typecheck/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/dist/typecheck/node_modules/undici-types/pool.d.ts +39 -0
- package/dist/typecheck/node_modules/undici-types/proxy-agent.d.ts +36 -0
- package/dist/typecheck/node_modules/undici-types/readable.d.ts +68 -0
- package/dist/typecheck/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/dist/typecheck/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/dist/typecheck/node_modules/undici-types/round-robin-pool.d.ts +39 -0
- package/dist/typecheck/node_modules/undici-types/snapshot-agent.d.ts +113 -0
- package/dist/typecheck/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
- package/dist/typecheck/node_modules/undici-types/util.d.ts +18 -0
- package/dist/typecheck/node_modules/undici-types/utility.d.ts +7 -0
- package/dist/typecheck/node_modules/undici-types/webidl.d.ts +346 -0
- package/dist/typecheck/node_modules/undici-types/websocket.d.ts +188 -0
- package/dist/typecheck/ts.cjs +446 -0
- package/hooks/hooks.json +30 -0
- package/hooks/mod.js +461 -0
- package/package.json +80 -4
- package/skills/agent-graph/SKILL.md +47 -0
- package/skills/agent-graph-authoring/SKILL.md +147 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1256 @@
|
|
|
1
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
|
|
8
|
+
// node_modules/@nanobpm/workflow/dist/xml.js
|
|
9
|
+
function escapeXml(s) {
|
|
10
|
+
return String(s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
11
|
+
}
|
|
12
|
+
var NCNAME = /^[A-Za-z_][A-Za-z0-9_.-]*$/;
|
|
13
|
+
function assertIdent(kind, value) {
|
|
14
|
+
if (!NCNAME.test(value)) {
|
|
15
|
+
throw new Error(`${kind} "${value}" is not a valid BPMN identifier (expected an NCName)`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var JOB_TYPE = /^[A-Za-z0-9_][A-Za-z0-9_.:+-]*$/;
|
|
19
|
+
function assertJobType(kind, value) {
|
|
20
|
+
if (typeof value !== "string" || !JOB_TYPE.test(value)) {
|
|
21
|
+
throw new Error(`${kind} "${value}" is not a valid job type (expected a non-empty token of letters, digits, and _ . : + -)`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
var ISO_DURATION = /^P(?:\d+W)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+S)?)?$/;
|
|
25
|
+
function isIsoDuration(v) {
|
|
26
|
+
if (!ISO_DURATION.test(v) || v === "P" || v === "PT" || v.endsWith("T"))
|
|
27
|
+
return false;
|
|
28
|
+
return /\d/.test(v);
|
|
29
|
+
}
|
|
30
|
+
function isIsoCycle(v) {
|
|
31
|
+
const slash = v.indexOf("/");
|
|
32
|
+
if (slash < 0)
|
|
33
|
+
return isIsoDuration(v);
|
|
34
|
+
const repeat = v.slice(0, slash);
|
|
35
|
+
const interval = v.slice(slash + 1);
|
|
36
|
+
return /^R\d*$/.test(repeat) && isIsoDuration(interval);
|
|
37
|
+
}
|
|
38
|
+
var ISO_DATE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
39
|
+
function isFeel(v) {
|
|
40
|
+
return v.startsWith("=") && v.length > 1;
|
|
41
|
+
}
|
|
42
|
+
function assertTimerDuration(kind, value) {
|
|
43
|
+
const v = typeof value === "string" ? value.trim() : "";
|
|
44
|
+
if (v === "" || !isFeel(v) && !isIsoDuration(v)) {
|
|
45
|
+
throw new Error(`${kind} "${value}" is not an ISO-8601 duration (e.g. PT1M30S, P1DT6H) or a FEEL expression (=...)`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function assertTimerCycle(kind, value) {
|
|
49
|
+
const v = typeof value === "string" ? value.trim() : "";
|
|
50
|
+
if (v === "" || !isFeel(v) && !isIsoCycle(v)) {
|
|
51
|
+
throw new Error(`${kind} "${value}" is not an ISO-8601 repeating interval (e.g. R/PT1H, R5/PT30M), a bare duration (e.g. PT1H), or a FEEL expression (=...)`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function assertTimerDate(kind, value) {
|
|
55
|
+
const v = typeof value === "string" ? value.trim() : "";
|
|
56
|
+
if (v === "" || !isFeel(v) && !ISO_DATE.test(v)) {
|
|
57
|
+
throw new Error(`${kind} "${value}" is not an ISO-8601 instant (e.g. 2026-01-01T09:00:00Z) or a FEEL expression (=...)`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// node_modules/@nanobpm/workflow/dist/nodes/registry.js
|
|
62
|
+
var kinds = /* @__PURE__ */ new Map();
|
|
63
|
+
function registerNodeKind(kind, handlers) {
|
|
64
|
+
if (kinds.has(kind)) {
|
|
65
|
+
throw new Error(`flow-node kind "${kind}" is already registered`);
|
|
66
|
+
}
|
|
67
|
+
const walk = handlers.walk;
|
|
68
|
+
const emit = handlers.emit;
|
|
69
|
+
kinds.set(kind, {
|
|
70
|
+
builderMethod: handlers.builderMethod,
|
|
71
|
+
build: handlers.build,
|
|
72
|
+
walk: walk ? (node, recurse) => walk(narrow(node, kind), recurse) : void 0,
|
|
73
|
+
emit: (node, incoming, loop, api) => emit(narrow(node, kind), incoming, loop, api)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function narrow(node, kind) {
|
|
77
|
+
if (isKind(node, kind))
|
|
78
|
+
return node;
|
|
79
|
+
throw new Error(`internal: node of kind "${node.kind}" dispatched to handler for "${kind}"`);
|
|
80
|
+
}
|
|
81
|
+
function isKind(node, kind) {
|
|
82
|
+
return node.kind === kind;
|
|
83
|
+
}
|
|
84
|
+
function requireNodeKind(kind) {
|
|
85
|
+
const h = kinds.get(kind);
|
|
86
|
+
if (!h) {
|
|
87
|
+
throw new Error(`no handler registered for flow-node kind "${kind}" \u2014 did its module under src/nodes/ import and call registerNodeKind()?`);
|
|
88
|
+
}
|
|
89
|
+
return h;
|
|
90
|
+
}
|
|
91
|
+
function eachNodeKind() {
|
|
92
|
+
return kinds.entries();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// node_modules/@nanobpm/workflow/dist/nodes/boundary.js
|
|
96
|
+
var BOUNDARY_HOST_KINDS = /* @__PURE__ */ new Set(["run", "task"]);
|
|
97
|
+
function isFeel2(value) {
|
|
98
|
+
return value.startsWith("=");
|
|
99
|
+
}
|
|
100
|
+
function renderBoundary(id, node, outg) {
|
|
101
|
+
const nameAttr = node.label ? ` name="${escapeXml(node.label)}"` : "";
|
|
102
|
+
const cancelAttr = node.interrupting ? "" : ` cancelActivity="false"`;
|
|
103
|
+
const durType = isFeel2(node.timer) ? ` xsi:type="bpmn:tFormalExpression"` : "";
|
|
104
|
+
return ` <bpmn:boundaryEvent id="${id}"${nameAttr} attachedToRef="${escapeXml(node.attachedTo)}"${cancelAttr}>
|
|
105
|
+
${outgoingOnly(outg)}
|
|
106
|
+
<bpmn:timerEventDefinition>
|
|
107
|
+
<bpmn:timeDuration${durType}>${escapeXml(node.timer)}</bpmn:timeDuration>
|
|
108
|
+
</bpmn:timerEventDefinition>
|
|
109
|
+
</bpmn:boundaryEvent>`;
|
|
110
|
+
}
|
|
111
|
+
registerNodeKind("boundary", {
|
|
112
|
+
build: (api) => (opts) => {
|
|
113
|
+
if (!opts || typeof opts !== "object") {
|
|
114
|
+
throw new Error(`boundary(...) needs { timer, onTimeout }`);
|
|
115
|
+
}
|
|
116
|
+
if (typeof opts.timer !== "string" || opts.timer.trim() === "") {
|
|
117
|
+
throw new Error(`boundary(...) needs a { timer } duration (an ISO-8601 duration or a FEEL =expression)`);
|
|
118
|
+
}
|
|
119
|
+
const duration = opts.timer.trim();
|
|
120
|
+
assertTimerDuration("boundary(...) timer", duration);
|
|
121
|
+
if (typeof opts.onTimeout !== "function") {
|
|
122
|
+
throw new Error(`boundary(...) needs an { onTimeout } escalation body (b) => {\u2026}`);
|
|
123
|
+
}
|
|
124
|
+
if (opts.interrupting !== void 0 && typeof opts.interrupting !== "boolean") {
|
|
125
|
+
throw new Error(`boundary(...) { interrupting } must be a boolean`);
|
|
126
|
+
}
|
|
127
|
+
if (opts.fireAndForget !== void 0 && typeof opts.fireAndForget !== "boolean") {
|
|
128
|
+
throw new Error(`boundary(...) { fireAndForget } must be a boolean`);
|
|
129
|
+
}
|
|
130
|
+
if (opts.name !== void 0 && typeof opts.name !== "string") {
|
|
131
|
+
throw new Error(`boundary(...) { name } must be a string`);
|
|
132
|
+
}
|
|
133
|
+
const host = api.out[api.out.length - 1];
|
|
134
|
+
if (!host) {
|
|
135
|
+
throw new Error(`boundary(...) must follow the activity it attaches to (e.g. w.run(...).boundary(...))`);
|
|
136
|
+
}
|
|
137
|
+
if (!BOUNDARY_HOST_KINDS.has(host.kind) || !("name" in host) || typeof host.name !== "string") {
|
|
138
|
+
throw new Error(`boundary(...) can only attach to a named activity (run/task), not a "${host.kind}"`);
|
|
139
|
+
}
|
|
140
|
+
const onTimeout = api.child(opts.onTimeout, false);
|
|
141
|
+
if (onTimeout.length === 0) {
|
|
142
|
+
throw new Error(`boundary(...) needs a non-empty { onTimeout } escalation body (its outgoing flow has nowhere to go)`);
|
|
143
|
+
}
|
|
144
|
+
api.out.push({
|
|
145
|
+
kind: "boundary",
|
|
146
|
+
attachedTo: host.name,
|
|
147
|
+
timer: duration,
|
|
148
|
+
interrupting: opts.interrupting ?? true,
|
|
149
|
+
fireAndForget: opts.fireAndForget ?? false,
|
|
150
|
+
onTimeout,
|
|
151
|
+
label: opts.name
|
|
152
|
+
});
|
|
153
|
+
return api.self();
|
|
154
|
+
},
|
|
155
|
+
walk: (node, recurse) => {
|
|
156
|
+
recurse(node.onTimeout);
|
|
157
|
+
},
|
|
158
|
+
emit: (node, incoming, loop, api) => {
|
|
159
|
+
const beId = `Be_${api.nextGw()}`;
|
|
160
|
+
api.addNode({
|
|
161
|
+
id: beId,
|
|
162
|
+
render: (_inc, outg) => renderBoundary(beId, node, outg)
|
|
163
|
+
});
|
|
164
|
+
const escalation = api.newEdge(beId);
|
|
165
|
+
const escOut = api.emitList(node.onTimeout, [escalation], loop);
|
|
166
|
+
if (node.fireAndForget) {
|
|
167
|
+
if (escOut.length > 0) {
|
|
168
|
+
const endId = `${beId}_End`;
|
|
169
|
+
api.addPlainEnd(endId);
|
|
170
|
+
api.connect(escOut, endId);
|
|
171
|
+
}
|
|
172
|
+
return [...incoming];
|
|
173
|
+
}
|
|
174
|
+
return [...incoming, ...escOut];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// node_modules/@nanobpm/workflow/dist/nodes/branch.js
|
|
179
|
+
registerNodeKind("branch", {
|
|
180
|
+
build: (api) => (condition, arms) => {
|
|
181
|
+
if (typeof condition !== "string" || condition.trim() === "") {
|
|
182
|
+
throw new Error(`branch() needs a non-empty FEEL condition`);
|
|
183
|
+
}
|
|
184
|
+
if (!arms || typeof arms.then !== "function")
|
|
185
|
+
throw new Error(`branch("${condition}") needs a then arm`);
|
|
186
|
+
if (arms.else !== void 0 && typeof arms.else !== "function") {
|
|
187
|
+
throw new Error(`branch("${condition}") else arm must be a block (b) => {\u2026}`);
|
|
188
|
+
}
|
|
189
|
+
api.out.push({
|
|
190
|
+
kind: "branch",
|
|
191
|
+
condition,
|
|
192
|
+
then: api.child(arms.then, false),
|
|
193
|
+
else: arms.else ? api.child(arms.else, false) : void 0
|
|
194
|
+
});
|
|
195
|
+
return api.self();
|
|
196
|
+
},
|
|
197
|
+
walk: (node, recurse) => {
|
|
198
|
+
recurse(node.then);
|
|
199
|
+
if (node.else)
|
|
200
|
+
recurse(node.else);
|
|
201
|
+
},
|
|
202
|
+
emit: (node, incoming, loop, api) => {
|
|
203
|
+
const id = `Gw_${api.nextGw()}`;
|
|
204
|
+
const gw = api.addGateway(id);
|
|
205
|
+
api.connect(incoming, id);
|
|
206
|
+
const te = api.newEdge(id, { condition: feel(node.condition), name: "then" });
|
|
207
|
+
const out = api.emitList(node.then, [te], loop);
|
|
208
|
+
const ee = api.newEdge(id, { name: "else" });
|
|
209
|
+
gw.defaultFlow = ee.id;
|
|
210
|
+
out.push(...api.emitList(node.else ?? [], [ee], loop));
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// node_modules/@nanobpm/workflow/dist/nodes/break.js
|
|
216
|
+
registerNodeKind("break", {
|
|
217
|
+
build: (api) => () => {
|
|
218
|
+
if (api.loopDepth === 0)
|
|
219
|
+
throw new Error(`break() is only valid inside a loop`);
|
|
220
|
+
api.out.push({ kind: "break" });
|
|
221
|
+
return api.self();
|
|
222
|
+
},
|
|
223
|
+
emit: (_node, incoming, loop, api) => {
|
|
224
|
+
if (!loop)
|
|
225
|
+
throw new Error(`break outside a loop in flow "${api.flowId}"`);
|
|
226
|
+
loop.breaks.push(...incoming);
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// node_modules/@nanobpm/workflow/dist/nodes/continue.js
|
|
232
|
+
registerNodeKind("continue", {
|
|
233
|
+
build: (api) => () => {
|
|
234
|
+
if (api.loopDepth === 0)
|
|
235
|
+
throw new Error(`continue() is only valid inside a loop`);
|
|
236
|
+
api.out.push({ kind: "continue" });
|
|
237
|
+
return api.self();
|
|
238
|
+
},
|
|
239
|
+
emit: (_node, incoming, loop, api) => {
|
|
240
|
+
if (!loop)
|
|
241
|
+
throw new Error(`continue outside a loop in flow "${api.flowId}"`);
|
|
242
|
+
api.connect(incoming, loop.headId);
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// node_modules/@nanobpm/workflow/dist/nodes/end.js
|
|
248
|
+
registerNodeKind("end", {
|
|
249
|
+
build: (api) => (name, opts) => {
|
|
250
|
+
if (name !== void 0 && typeof name === "object") {
|
|
251
|
+
opts = name;
|
|
252
|
+
name = void 0;
|
|
253
|
+
}
|
|
254
|
+
if (opts !== void 0 && (opts === null || typeof opts !== "object")) {
|
|
255
|
+
throw new Error(`end() options must be an object like { terminate: true }`);
|
|
256
|
+
}
|
|
257
|
+
const terminate = opts?.terminate === void 0 ? false : opts.terminate;
|
|
258
|
+
if (typeof terminate !== "boolean")
|
|
259
|
+
throw new Error(`end() { terminate } must be true or false`);
|
|
260
|
+
if (name !== void 0) {
|
|
261
|
+
if (typeof name !== "string")
|
|
262
|
+
throw new Error(`end() name must be a string`);
|
|
263
|
+
api.claim(name);
|
|
264
|
+
api.out.push({ kind: "end", name, terminate });
|
|
265
|
+
} else {
|
|
266
|
+
api.out.push({ kind: "end", terminate });
|
|
267
|
+
}
|
|
268
|
+
return api.self();
|
|
269
|
+
},
|
|
270
|
+
emit: (node, incoming, _loop, api) => {
|
|
271
|
+
let id = node.name ?? `End_${api.nextGw()}`;
|
|
272
|
+
while (node.name === void 0 && id === api.flowId)
|
|
273
|
+
id = `End_${api.nextGw()}`;
|
|
274
|
+
api.addNode({
|
|
275
|
+
id,
|
|
276
|
+
render: (inc) => node.terminate ? ` <bpmn:endEvent id="${escapeXml(id)}">
|
|
277
|
+
` + inc.map((f) => ` <bpmn:incoming>${escapeXml(f)}</bpmn:incoming>
|
|
278
|
+
`).join("") + ` <bpmn:terminateEventDefinition />
|
|
279
|
+
</bpmn:endEvent>` : ` <bpmn:endEvent id="${escapeXml(id)}">` + inc.map((f) => `<bpmn:incoming>${escapeXml(f)}</bpmn:incoming>`).join("") + `</bpmn:endEvent>`
|
|
280
|
+
});
|
|
281
|
+
api.connect(incoming, id);
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// node_modules/@nanobpm/workflow/dist/io-mapping.js
|
|
287
|
+
function isNonBlankString(v) {
|
|
288
|
+
return typeof v === "string" && v.trim() !== "";
|
|
289
|
+
}
|
|
290
|
+
function isEntry(e) {
|
|
291
|
+
if (e === null || typeof e !== "object")
|
|
292
|
+
return false;
|
|
293
|
+
if (!("source" in e) || !("target" in e))
|
|
294
|
+
return false;
|
|
295
|
+
const { source, target } = e;
|
|
296
|
+
return isNonBlankString(source) && isNonBlankString(target);
|
|
297
|
+
}
|
|
298
|
+
function validateEntries(label, dir, entries) {
|
|
299
|
+
if (entries === void 0)
|
|
300
|
+
return;
|
|
301
|
+
if (!Array.isArray(entries))
|
|
302
|
+
throw new Error(`${label} io.${dir} must be an array of { source, target }`);
|
|
303
|
+
for (const e of entries) {
|
|
304
|
+
if (!isEntry(e)) {
|
|
305
|
+
throw new Error(`${label} io.${dir} entries must be { source: non-empty string, target: non-empty string }`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function assertIoMapping(label, io) {
|
|
310
|
+
if (io === void 0)
|
|
311
|
+
return;
|
|
312
|
+
if (io === null || typeof io !== "object" || Array.isArray(io)) {
|
|
313
|
+
throw new Error(`${label} { io } must be an object { input?, output? }`);
|
|
314
|
+
}
|
|
315
|
+
validateEntries(label, "input", io.input);
|
|
316
|
+
validateEntries(label, "output", io.output);
|
|
317
|
+
}
|
|
318
|
+
function renderMappings(entries, tag) {
|
|
319
|
+
if (!entries || entries.length === 0)
|
|
320
|
+
return "";
|
|
321
|
+
return entries.map((e) => ` <zeebe:${tag} source="${escapeXml(e.source)}" target="${escapeXml(e.target)}" />
|
|
322
|
+
`).join("");
|
|
323
|
+
}
|
|
324
|
+
function renderIoMapping(io) {
|
|
325
|
+
if (!io || (io.input?.length ?? 0) === 0 && (io.output?.length ?? 0) === 0)
|
|
326
|
+
return "";
|
|
327
|
+
return ` <zeebe:ioMapping>
|
|
328
|
+
` + renderMappings(io.input, "input") + renderMappings(io.output, "output") + ` </zeebe:ioMapping>
|
|
329
|
+
`;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// node_modules/@nanobpm/workflow/dist/nodes/task.js
|
|
333
|
+
function resolvePrompt(name, prompt) {
|
|
334
|
+
if (typeof prompt !== "object" || prompt === null) {
|
|
335
|
+
throw new Error(`task("${name}") prompt must be an object with a non-empty resourceId`);
|
|
336
|
+
}
|
|
337
|
+
const resourceId = prompt.resourceId;
|
|
338
|
+
if (typeof resourceId !== "string" || resourceId.trim() === "") {
|
|
339
|
+
throw new Error(`task("${name}") prompt.resourceId must be a non-empty string`);
|
|
340
|
+
}
|
|
341
|
+
const bindingType = prompt.bindingType === void 0 ? "latest" : prompt.bindingType;
|
|
342
|
+
if (typeof bindingType !== "string" || bindingType.trim() === "") {
|
|
343
|
+
throw new Error(`task("${name}") prompt.bindingType must be a non-empty string`);
|
|
344
|
+
}
|
|
345
|
+
const resolved = { resourceId: resourceId.trim(), bindingType: bindingType.trim() };
|
|
346
|
+
if (prompt.append !== void 0) {
|
|
347
|
+
if (typeof prompt.append !== "string" || prompt.append.trim() === "") {
|
|
348
|
+
throw new Error(`task("${name}") prompt.append must be a non-empty string when provided`);
|
|
349
|
+
}
|
|
350
|
+
resolved.append = prompt.append.trim();
|
|
351
|
+
}
|
|
352
|
+
return resolved;
|
|
353
|
+
}
|
|
354
|
+
function taskExtensions(agent, prompt, io) {
|
|
355
|
+
const marker = agent === true ? ` <zeebe:agentDefinition agentType="external" />
|
|
356
|
+
` : "";
|
|
357
|
+
const linked = prompt !== void 0 ? ` <zeebe:linkedResources>
|
|
358
|
+
<zeebe:linkedResource resourceId="${escapeXml(prompt.resourceId)}" bindingType="${escapeXml(prompt.bindingType ?? "latest")}" resourceType="GenericScript" linkName="prompt" />
|
|
359
|
+
</zeebe:linkedResources>
|
|
360
|
+
` : "";
|
|
361
|
+
const inputs = [...io?.input ?? []];
|
|
362
|
+
if (prompt?.append !== void 0)
|
|
363
|
+
inputs.push({ source: prompt.append, target: "appendPrompt" });
|
|
364
|
+
const merged = { input: inputs, output: io?.output ?? [] };
|
|
365
|
+
return marker + linked + renderIoMapping(merged);
|
|
366
|
+
}
|
|
367
|
+
function hasTaskExtensions(node) {
|
|
368
|
+
return node.agent === true || node.prompt !== void 0 || node.io !== void 0;
|
|
369
|
+
}
|
|
370
|
+
registerNodeKind("task", {
|
|
371
|
+
build: (api) => (name, opts) => {
|
|
372
|
+
api.claim(name);
|
|
373
|
+
const override = opts?.jobType;
|
|
374
|
+
if (override !== void 0)
|
|
375
|
+
assertJobType("task jobType", override);
|
|
376
|
+
const prompt = opts?.prompt !== void 0 ? resolvePrompt(name, opts.prompt) : void 0;
|
|
377
|
+
assertIoMapping(`task("${name}")`, opts?.io);
|
|
378
|
+
if (opts?.agent !== void 0 && typeof opts.agent !== "boolean") {
|
|
379
|
+
throw new Error(`task("${name}") agent must be a boolean when provided`);
|
|
380
|
+
}
|
|
381
|
+
const agent = opts?.agent ?? prompt !== void 0;
|
|
382
|
+
api.out.push({
|
|
383
|
+
kind: "task",
|
|
384
|
+
name,
|
|
385
|
+
envelopes: api.contractEnvelopes(name),
|
|
386
|
+
jobType: override,
|
|
387
|
+
prompt,
|
|
388
|
+
agent,
|
|
389
|
+
io: opts?.io
|
|
390
|
+
});
|
|
391
|
+
return api.self();
|
|
392
|
+
},
|
|
393
|
+
emit: (node, incoming, _loop, api) => {
|
|
394
|
+
if (!hasTaskExtensions(node)) {
|
|
395
|
+
api.addServiceTask(node);
|
|
396
|
+
api.connect(incoming, node.name);
|
|
397
|
+
return [api.newEdge(node.name)];
|
|
398
|
+
}
|
|
399
|
+
api.addServiceTask(node, { extraExt: taskExtensions(node.agent, node.prompt, node.io) });
|
|
400
|
+
api.connect(incoming, node.name);
|
|
401
|
+
return [api.newEdge(node.name)];
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// node_modules/@nanobpm/workflow/dist/nodes/forEach.js
|
|
406
|
+
function miCharacteristics(node) {
|
|
407
|
+
const seq = node.sequential ? "true" : "false";
|
|
408
|
+
const attrs = [
|
|
409
|
+
`inputCollection="${escapeXml(`=${node.collection}`)}"`,
|
|
410
|
+
`inputElement="${escapeXml(node.itemVar)}"`
|
|
411
|
+
];
|
|
412
|
+
if (node.outputCollection)
|
|
413
|
+
attrs.push(`outputCollection="${escapeXml(node.outputCollection)}"`);
|
|
414
|
+
if (node.outputElement)
|
|
415
|
+
attrs.push(`outputElement="${escapeXml(`=${node.outputElement}`)}"`);
|
|
416
|
+
const completion = node.completionCondition ? ` <bpmn:completionCondition>${escapeXml(`=${node.completionCondition}`)}</bpmn:completionCondition>
|
|
417
|
+
` : "";
|
|
418
|
+
return ` <bpmn:multiInstanceLoopCharacteristics isSequential="${seq}">
|
|
419
|
+
<bpmn:extensionElements>
|
|
420
|
+
<zeebe:loopCharacteristics ${attrs.join(" ")} />
|
|
421
|
+
</bpmn:extensionElements>
|
|
422
|
+
` + completion + ` </bpmn:multiInstanceLoopCharacteristics>
|
|
423
|
+
`;
|
|
424
|
+
}
|
|
425
|
+
registerNodeKind("forEach", {
|
|
426
|
+
build: (api) => (collection, itemVar, body, opts) => {
|
|
427
|
+
if (typeof collection !== "string" || collection.trim() === "") {
|
|
428
|
+
throw new Error(`forEach() needs a non-empty FEEL collection expression`);
|
|
429
|
+
}
|
|
430
|
+
const collExpr = collection.trim().replace(/^=/, "").trim();
|
|
431
|
+
if (collExpr === "") {
|
|
432
|
+
throw new Error(`forEach() collection expression is empty after stripping the leading "="`);
|
|
433
|
+
}
|
|
434
|
+
assertIdent("forEach itemVar", itemVar);
|
|
435
|
+
if (typeof body !== "function")
|
|
436
|
+
throw new Error(`forEach("${itemVar}") needs a body function`);
|
|
437
|
+
const nodes = api.childScoped(body);
|
|
438
|
+
if (nodes.length === 0)
|
|
439
|
+
throw new Error(`forEach("${itemVar}") body declared no steps`);
|
|
440
|
+
const node = { kind: "forEach", collection: collExpr, itemVar, body: nodes };
|
|
441
|
+
if (opts?.sequential)
|
|
442
|
+
node.sequential = true;
|
|
443
|
+
if (opts?.outputCollection !== void 0) {
|
|
444
|
+
assertIdent("forEach outputCollection", opts.outputCollection);
|
|
445
|
+
node.outputCollection = opts.outputCollection;
|
|
446
|
+
}
|
|
447
|
+
if (opts?.outputElement !== void 0) {
|
|
448
|
+
if (typeof opts.outputElement !== "string" || opts.outputElement.trim() === "") {
|
|
449
|
+
throw new Error(`forEach("${itemVar}") outputElement must be a non-empty FEEL expression`);
|
|
450
|
+
}
|
|
451
|
+
const outEl = opts.outputElement.trim().replace(/^=/, "").trim();
|
|
452
|
+
if (outEl === "") {
|
|
453
|
+
throw new Error(`forEach("${itemVar}") outputElement is empty after stripping the leading "="`);
|
|
454
|
+
}
|
|
455
|
+
node.outputElement = outEl;
|
|
456
|
+
}
|
|
457
|
+
if (opts?.completionCondition !== void 0) {
|
|
458
|
+
if (typeof opts.completionCondition !== "string" || opts.completionCondition.trim() === "") {
|
|
459
|
+
throw new Error(`forEach("${itemVar}") completionCondition must be a non-empty FEEL expression`);
|
|
460
|
+
}
|
|
461
|
+
const compCond = opts.completionCondition.trim().replace(/^=/, "").trim();
|
|
462
|
+
if (compCond === "") {
|
|
463
|
+
throw new Error(`forEach("${itemVar}") completionCondition is empty after stripping the leading "="`);
|
|
464
|
+
}
|
|
465
|
+
node.completionCondition = compCond;
|
|
466
|
+
}
|
|
467
|
+
if (node.outputElement && !node.outputCollection) {
|
|
468
|
+
throw new Error(`forEach("${itemVar}") outputElement needs an outputCollection to collect into`);
|
|
469
|
+
}
|
|
470
|
+
api.out.push(node);
|
|
471
|
+
return api.self();
|
|
472
|
+
},
|
|
473
|
+
walk: (node, recurse) => recurse(node.body),
|
|
474
|
+
emit: (node, incoming, _loop, api) => {
|
|
475
|
+
const mi = miCharacteristics(node);
|
|
476
|
+
const only = node.body.length === 1 ? node.body[0] : void 0;
|
|
477
|
+
if (only && (only.kind === "run" || only.kind === "task" && !hasTaskExtensions(only))) {
|
|
478
|
+
api.addServiceTask(only, { mi });
|
|
479
|
+
api.connect(incoming, only.name);
|
|
480
|
+
return [api.newEdge(only.name)];
|
|
481
|
+
}
|
|
482
|
+
const subId = `Sub_${api.nextGw()}`;
|
|
483
|
+
api.addSubProcess(subId, mi);
|
|
484
|
+
api.connect(incoming, subId);
|
|
485
|
+
api.pushScope(subId);
|
|
486
|
+
const startId = `${subId}_start`;
|
|
487
|
+
api.addPlainStart(startId);
|
|
488
|
+
const innerOut = api.emitList(node.body, [api.newEdge(startId)], null);
|
|
489
|
+
if (innerOut.length > 0) {
|
|
490
|
+
const endId = `${subId}_end`;
|
|
491
|
+
api.addPlainEnd(endId);
|
|
492
|
+
api.connect(innerOut, endId);
|
|
493
|
+
}
|
|
494
|
+
api.popScope();
|
|
495
|
+
return [api.newEdge(subId)];
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
// node_modules/@nanobpm/workflow/dist/nodes/human.js
|
|
500
|
+
function renderAssignment(node) {
|
|
501
|
+
if (node.assignee === void 0 && node.candidateGroups === void 0)
|
|
502
|
+
return "";
|
|
503
|
+
const attrs = [
|
|
504
|
+
node.assignee !== void 0 ? ` assignee="${escapeXml(node.assignee)}"` : "",
|
|
505
|
+
node.candidateGroups !== void 0 ? ` candidateGroups="${escapeXml(node.candidateGroups)}"` : ""
|
|
506
|
+
].join("");
|
|
507
|
+
return ` <zeebe:assignmentDefinition${attrs} />
|
|
508
|
+
`;
|
|
509
|
+
}
|
|
510
|
+
function renderUserTask(node, inc, outg) {
|
|
511
|
+
const id = node.name;
|
|
512
|
+
const ext = ` <bpmn:extensionElements>
|
|
513
|
+
<zeebe:formDefinition formId="${escapeXml(node.form)}" />
|
|
514
|
+
<zeebe:userTask />
|
|
515
|
+
` + renderAssignment(node) + renderIoMapping(node.io) + ` </bpmn:extensionElements>`;
|
|
516
|
+
return ` <bpmn:userTask id="${escapeXml(id)}" name="${escapeXml(id)}">
|
|
517
|
+
` + ext + "\n" + incomingOutgoing(inc, outg) + ` </bpmn:userTask>`;
|
|
518
|
+
}
|
|
519
|
+
registerNodeKind("human", {
|
|
520
|
+
build: (api) => (name, opts) => {
|
|
521
|
+
api.claim(name);
|
|
522
|
+
if (opts === null || typeof opts !== "object") {
|
|
523
|
+
throw new Error(`human("${name}") needs an options object { form, \u2026 }`);
|
|
524
|
+
}
|
|
525
|
+
if (!isNonBlankString(opts.form)) {
|
|
526
|
+
throw new Error(`human("${name}") needs a non-empty { form } (the zeebe:formDefinition form id)`);
|
|
527
|
+
}
|
|
528
|
+
if (opts.assignee !== void 0 && !isNonBlankString(opts.assignee)) {
|
|
529
|
+
throw new Error(`human("${name}") { assignee } must be a non-empty string`);
|
|
530
|
+
}
|
|
531
|
+
if (opts.candidateGroups !== void 0 && !isNonBlankString(opts.candidateGroups)) {
|
|
532
|
+
throw new Error(`human("${name}") { candidateGroups } must be a non-empty string`);
|
|
533
|
+
}
|
|
534
|
+
assertIoMapping(`human("${name}")`, opts.io);
|
|
535
|
+
api.out.push({
|
|
536
|
+
kind: "human",
|
|
537
|
+
name,
|
|
538
|
+
form: opts.form,
|
|
539
|
+
assignee: opts.assignee,
|
|
540
|
+
candidateGroups: opts.candidateGroups,
|
|
541
|
+
io: opts.io
|
|
542
|
+
});
|
|
543
|
+
return api.self();
|
|
544
|
+
},
|
|
545
|
+
emit: (node, incoming, _loop, api) => {
|
|
546
|
+
api.addNode({ id: node.name, render: (inc, outg) => renderUserTask(node, inc, outg) });
|
|
547
|
+
api.connect(incoming, node.name);
|
|
548
|
+
return [api.newEdge(node.name)];
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
// node_modules/@nanobpm/workflow/dist/nodes/loop.js
|
|
553
|
+
registerNodeKind("loop", {
|
|
554
|
+
build: (api) => (body) => {
|
|
555
|
+
if (typeof body !== "function")
|
|
556
|
+
throw new Error(`loop() needs a body function`);
|
|
557
|
+
api.out.push({ kind: "loop", body: api.child(body, true) });
|
|
558
|
+
return api.self();
|
|
559
|
+
},
|
|
560
|
+
walk: (node, recurse) => recurse(node.body),
|
|
561
|
+
emit: (node, incoming, _loop, api) => {
|
|
562
|
+
const headId = `Loop_${api.nextGw()}`;
|
|
563
|
+
api.addGateway(headId);
|
|
564
|
+
api.connect(incoming, headId);
|
|
565
|
+
const ctx = { headId, breaks: [] };
|
|
566
|
+
const headOut = api.newEdge(headId);
|
|
567
|
+
const bodyOut = api.emitList(node.body, [headOut], ctx);
|
|
568
|
+
api.connect(bodyOut, headId);
|
|
569
|
+
return ctx.breaks;
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// node_modules/@nanobpm/workflow/dist/nodes/parallel.js
|
|
574
|
+
function hasPlainEnd(list) {
|
|
575
|
+
let found = false;
|
|
576
|
+
const visit = (nodes) => {
|
|
577
|
+
for (const n of nodes) {
|
|
578
|
+
if (found)
|
|
579
|
+
return;
|
|
580
|
+
if (n.kind === "end" && !n.terminate)
|
|
581
|
+
found = true;
|
|
582
|
+
else if (n.kind === "boundary" && !n.interrupting)
|
|
583
|
+
continue;
|
|
584
|
+
else if (n.kind !== "forEach")
|
|
585
|
+
requireNodeKind(n.kind).walk?.(n, visit);
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
visit(list);
|
|
589
|
+
return found;
|
|
590
|
+
}
|
|
591
|
+
registerNodeKind("parallel", {
|
|
592
|
+
build: (api) => (branches) => {
|
|
593
|
+
if (!Array.isArray(branches) || branches.length < 2) {
|
|
594
|
+
throw new Error(`parallel() needs at least two branch blocks`);
|
|
595
|
+
}
|
|
596
|
+
for (const fn of branches) {
|
|
597
|
+
if (typeof fn !== "function")
|
|
598
|
+
throw new Error(`parallel() branches must all be blocks (b) => {\u2026}`);
|
|
599
|
+
}
|
|
600
|
+
const bodies = branches.map((fn) => api.childScoped(fn));
|
|
601
|
+
if (bodies.some(hasPlainEnd)) {
|
|
602
|
+
throw new Error(`parallel(): a branch can't end() on its own \u2014 the join would wait for it forever. Use end({ terminate: true }) to end the whole instance, or let the branch reach the join`);
|
|
603
|
+
}
|
|
604
|
+
api.out.push({ kind: "parallel", branches: bodies });
|
|
605
|
+
return api.self();
|
|
606
|
+
},
|
|
607
|
+
walk: (node, recurse) => {
|
|
608
|
+
for (const branch of node.branches)
|
|
609
|
+
recurse(branch);
|
|
610
|
+
},
|
|
611
|
+
emit: (node, incoming, loop, api) => {
|
|
612
|
+
const splitId = `Gw_${api.nextGw()}`;
|
|
613
|
+
api.addParallelGateway(splitId);
|
|
614
|
+
api.connect(incoming, splitId);
|
|
615
|
+
const joinId = `Gw_${api.nextGw()}`;
|
|
616
|
+
api.addParallelGateway(joinId);
|
|
617
|
+
for (const branch of node.branches) {
|
|
618
|
+
const e = api.newEdge(splitId);
|
|
619
|
+
const branchOut = api.emitList(branch, [e], loop);
|
|
620
|
+
if (branchOut.length === 0) {
|
|
621
|
+
throw new Error(`parallel(): every path of a branch ends, so it never reaches the join \u2014 the steps after parallel() could run before it terminates. Make the end conditional, or move it after parallel()`);
|
|
622
|
+
}
|
|
623
|
+
api.connect(branchOut, joinId);
|
|
624
|
+
}
|
|
625
|
+
return [api.newEdge(joinId)];
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// node_modules/@nanobpm/workflow/dist/nodes/race.js
|
|
630
|
+
function hasSignal(spec) {
|
|
631
|
+
return "signal" in spec && spec.signal !== null && typeof spec.signal === "object";
|
|
632
|
+
}
|
|
633
|
+
function hasTimer(spec) {
|
|
634
|
+
return "timer" in spec && spec.timer !== null && typeof spec.timer === "object";
|
|
635
|
+
}
|
|
636
|
+
registerNodeKind("race", {
|
|
637
|
+
build: (api) => (arms) => {
|
|
638
|
+
if (arms === null || typeof arms !== "object") {
|
|
639
|
+
throw new Error(`race() needs an arms object { "<name>": { signal | timer, do } }`);
|
|
640
|
+
}
|
|
641
|
+
const entries = Object.entries(arms);
|
|
642
|
+
if (entries.length < 2) {
|
|
643
|
+
throw new Error(`race() needs at least two arms (an event-based gateway with fewer than two events is degenerate)`);
|
|
644
|
+
}
|
|
645
|
+
const compiled = [];
|
|
646
|
+
for (const [name, spec] of entries) {
|
|
647
|
+
if (spec === null || typeof spec !== "object") {
|
|
648
|
+
throw new Error(`race() arm "${name}" must be an object { signal | timer, do }`);
|
|
649
|
+
}
|
|
650
|
+
const isSignal = hasSignal(spec);
|
|
651
|
+
const isTimer = hasTimer(spec);
|
|
652
|
+
if (isSignal === isTimer) {
|
|
653
|
+
throw new Error(`race() arm "${name}" needs exactly one of { signal: { correlationKey } } or { timer: { after | at } }`);
|
|
654
|
+
}
|
|
655
|
+
if (typeof spec.do !== "function") {
|
|
656
|
+
throw new Error(`race() arm "${name}" needs a do block (b) => {\u2026}`);
|
|
657
|
+
}
|
|
658
|
+
api.claim(name);
|
|
659
|
+
let event;
|
|
660
|
+
if (isSignal) {
|
|
661
|
+
const rawKey = spec.signal.correlationKey;
|
|
662
|
+
if (typeof rawKey !== "string" || rawKey.trim() === "") {
|
|
663
|
+
throw new Error(`race() arm "${name}" signal needs a non-empty { correlationKey }`);
|
|
664
|
+
}
|
|
665
|
+
const correlationKey = rawKey.trim();
|
|
666
|
+
assertIdent(`race() arm "${name}" signal correlationKey`, correlationKey);
|
|
667
|
+
event = { kind: "signal", name, correlationKey, payload: api.contracts[name]?.in };
|
|
668
|
+
} else {
|
|
669
|
+
const timer = spec.timer;
|
|
670
|
+
const hasAfterKey = "after" in timer;
|
|
671
|
+
const hasAtKey = "at" in timer;
|
|
672
|
+
if (hasAfterKey === hasAtKey) {
|
|
673
|
+
throw new Error(`race() arm "${name}" timer needs exactly one of { after } (a delay) or { at } (an instant)`);
|
|
674
|
+
}
|
|
675
|
+
if ("after" in timer) {
|
|
676
|
+
if (typeof timer.after !== "string") {
|
|
677
|
+
throw new Error(`race() arm "${name}" timer { after } must be a string duration`);
|
|
678
|
+
}
|
|
679
|
+
const after = timer.after.trim();
|
|
680
|
+
assertTimerDuration(`race() arm "${name}" timer after`, after);
|
|
681
|
+
event = { kind: "timer", name, after };
|
|
682
|
+
} else {
|
|
683
|
+
if (typeof timer.at !== "string") {
|
|
684
|
+
throw new Error(`race() arm "${name}" timer { at } must be a string instant`);
|
|
685
|
+
}
|
|
686
|
+
const at = timer.at.trim();
|
|
687
|
+
assertTimerDate(`race() arm "${name}" timer at`, at);
|
|
688
|
+
event = { kind: "timer", name, at };
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
compiled.push({ event, body: api.child(spec.do, false) });
|
|
692
|
+
}
|
|
693
|
+
api.out.push({ kind: "race", arms: compiled });
|
|
694
|
+
return api.self();
|
|
695
|
+
},
|
|
696
|
+
walk: (node, recurse) => {
|
|
697
|
+
for (const arm of node.arms)
|
|
698
|
+
recurse([arm.event, ...arm.body]);
|
|
699
|
+
},
|
|
700
|
+
emit: (node, incoming, loop, api) => {
|
|
701
|
+
const gwId = `Gw_${api.nextGw()}`;
|
|
702
|
+
api.addNode(eventBasedGateway(gwId, api.currentScope()));
|
|
703
|
+
api.connect(incoming, gwId);
|
|
704
|
+
const out = [];
|
|
705
|
+
for (const arm of node.arms) {
|
|
706
|
+
const fork = api.newEdge(gwId);
|
|
707
|
+
const afterCatch = requireNodeKind(arm.event.kind).emit(arm.event, [fork], loop, api);
|
|
708
|
+
out.push(...api.emitList(arm.body, afterCatch, loop));
|
|
709
|
+
}
|
|
710
|
+
return out;
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
function eventBasedGateway(id, scope) {
|
|
714
|
+
return {
|
|
715
|
+
id,
|
|
716
|
+
scope,
|
|
717
|
+
render: (inc, outg) => ` <bpmn:eventBasedGateway id="${escapeXml(id)}">
|
|
718
|
+
` + incomingOutgoing(inc, outg) + ` </bpmn:eventBasedGateway>`
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// node_modules/@nanobpm/workflow/dist/nodes/run.js
|
|
723
|
+
registerNodeKind("run", {
|
|
724
|
+
build: (api) => (name, handler, opts) => {
|
|
725
|
+
api.claim(name);
|
|
726
|
+
if (typeof handler !== "function")
|
|
727
|
+
throw new Error(`run("${name}") needs a handler function`);
|
|
728
|
+
assertIoMapping(`run("${name}")`, opts?.io);
|
|
729
|
+
const timeoutMs = opts?.timeoutMs;
|
|
730
|
+
if (timeoutMs !== void 0 && (!Number.isInteger(timeoutMs) || timeoutMs <= 0)) {
|
|
731
|
+
throw new Error(`run("${name}"): timeoutMs must be a positive integer (ms)`);
|
|
732
|
+
}
|
|
733
|
+
api.handlers[name] = handler;
|
|
734
|
+
api.out.push({
|
|
735
|
+
kind: "run",
|
|
736
|
+
name,
|
|
737
|
+
envelopes: api.contractEnvelopes(name),
|
|
738
|
+
io: opts?.io,
|
|
739
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {}
|
|
740
|
+
});
|
|
741
|
+
return api.self();
|
|
742
|
+
},
|
|
743
|
+
emit: (node, incoming, _loop, api) => {
|
|
744
|
+
api.addServiceTask(node, node.io !== void 0 ? { extraExt: renderIoMapping(node.io) } : {});
|
|
745
|
+
api.connect(incoming, node.name);
|
|
746
|
+
return [api.newEdge(node.name)];
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
// node_modules/@nanobpm/workflow/dist/nodes/signal.js
|
|
751
|
+
registerNodeKind("signal", {
|
|
752
|
+
build: (api) => (name, opts) => {
|
|
753
|
+
api.claim(name);
|
|
754
|
+
if (!opts || typeof opts.correlationKey !== "string" || opts.correlationKey.trim() === "") {
|
|
755
|
+
throw new Error(`signal("${name}") needs { correlationKey }`);
|
|
756
|
+
}
|
|
757
|
+
const correlationKey = opts.correlationKey.trim();
|
|
758
|
+
assertIdent(`signal("${name}") correlationKey`, correlationKey);
|
|
759
|
+
api.out.push({ kind: "signal", name, correlationKey, payload: api.contracts[name]?.in });
|
|
760
|
+
return api.self();
|
|
761
|
+
},
|
|
762
|
+
emit: (node, incoming, _loop, api) => {
|
|
763
|
+
api.addCatchEvent(node);
|
|
764
|
+
api.connect(incoming, node.name);
|
|
765
|
+
api.recordEnvelope(node.payload);
|
|
766
|
+
return [api.newEdge(node.name)];
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
// node_modules/@nanobpm/workflow/dist/nodes/switch.js
|
|
771
|
+
registerNodeKind("switch", {
|
|
772
|
+
build: (api) => (subject, cases) => {
|
|
773
|
+
if (typeof subject !== "string" || subject.trim() === "") {
|
|
774
|
+
throw new Error(`switch() needs a non-empty subject expression`);
|
|
775
|
+
}
|
|
776
|
+
if (cases === null || typeof cases !== "object") {
|
|
777
|
+
throw new Error(`switch("${subject}") needs a cases object { value: (b) => {\u2026} }`);
|
|
778
|
+
}
|
|
779
|
+
const caseNodes = [];
|
|
780
|
+
for (const [value, fn] of Object.entries(cases)) {
|
|
781
|
+
if (value === "default")
|
|
782
|
+
continue;
|
|
783
|
+
if (typeof fn !== "function")
|
|
784
|
+
throw new Error(`switch("${subject}") cases must be blocks (b) => {\u2026}`);
|
|
785
|
+
caseNodes.push({ value, body: api.child(fn, false) });
|
|
786
|
+
}
|
|
787
|
+
if (caseNodes.length === 0)
|
|
788
|
+
throw new Error(`switch("${subject}") needs at least one case`);
|
|
789
|
+
if (cases.default !== void 0 && typeof cases.default !== "function") {
|
|
790
|
+
throw new Error(`switch("${subject}") default must be a block (b) => {\u2026}`);
|
|
791
|
+
}
|
|
792
|
+
const def = cases.default ? api.child(cases.default, false) : void 0;
|
|
793
|
+
api.out.push({ kind: "switch", subject, cases: caseNodes, default: def });
|
|
794
|
+
return api.self();
|
|
795
|
+
},
|
|
796
|
+
walk: (node, recurse) => {
|
|
797
|
+
for (const c of node.cases)
|
|
798
|
+
recurse(c.body);
|
|
799
|
+
if (node.default)
|
|
800
|
+
recurse(node.default);
|
|
801
|
+
},
|
|
802
|
+
emit: (node, incoming, loop, api) => {
|
|
803
|
+
const id = `Gw_${api.nextGw()}`;
|
|
804
|
+
const gw = api.addGateway(id, node.subject);
|
|
805
|
+
api.connect(incoming, id);
|
|
806
|
+
const out = [];
|
|
807
|
+
for (const c of node.cases) {
|
|
808
|
+
const e = api.newEdge(id, { condition: feelEquals(node.subject, c.value), name: c.value });
|
|
809
|
+
out.push(...api.emitList(c.body, [e], loop));
|
|
810
|
+
}
|
|
811
|
+
const de = api.newEdge(id, { name: "default" });
|
|
812
|
+
gw.defaultFlow = de.id;
|
|
813
|
+
out.push(...api.emitList(node.default ?? [], [de], loop));
|
|
814
|
+
return out;
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
// node_modules/@nanobpm/workflow/dist/nodes/timer.js
|
|
819
|
+
registerNodeKind("timer", {
|
|
820
|
+
build: (api) => (name, opts) => {
|
|
821
|
+
api.claim(name);
|
|
822
|
+
if (!opts || typeof opts !== "object") {
|
|
823
|
+
throw new Error(`timer("${name}") needs exactly one of { after } (a delay) or { at } (an instant)`);
|
|
824
|
+
}
|
|
825
|
+
const hasAfter = "after" in opts && typeof opts.after === "string";
|
|
826
|
+
const hasAt = "at" in opts && typeof opts.at === "string";
|
|
827
|
+
if (hasAfter === hasAt) {
|
|
828
|
+
throw new Error(`timer("${name}") needs exactly one of { after } (a delay) or { at } (an instant)`);
|
|
829
|
+
}
|
|
830
|
+
if ("after" in opts) {
|
|
831
|
+
const after = opts.after.trim();
|
|
832
|
+
assertTimerDuration(`timer("${name}") after`, after);
|
|
833
|
+
api.out.push({ kind: "timer", name, after });
|
|
834
|
+
} else {
|
|
835
|
+
const at = opts.at.trim();
|
|
836
|
+
assertTimerDate(`timer("${name}") at`, at);
|
|
837
|
+
api.out.push({ kind: "timer", name, at });
|
|
838
|
+
}
|
|
839
|
+
return api.self();
|
|
840
|
+
},
|
|
841
|
+
emit: (node, incoming, _loop, api) => {
|
|
842
|
+
api.addTimerCatchEvent(node);
|
|
843
|
+
api.connect(incoming, node.name);
|
|
844
|
+
return [api.newEdge(node.name)];
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
// node_modules/@nanobpm/workflow/dist/declarative.js
|
|
849
|
+
var RESERVED_PREFIXES = /^(Gw_|Loop_|Sub_|Msg_|f_|End_)/;
|
|
850
|
+
var TIMER_START_KEYS = ["cycle", "after", "at"];
|
|
851
|
+
function timerStartValue(spec, key) {
|
|
852
|
+
switch (key) {
|
|
853
|
+
case "cycle":
|
|
854
|
+
return "cycle" in spec ? spec.cycle : void 0;
|
|
855
|
+
case "after":
|
|
856
|
+
return "after" in spec ? spec.after : void 0;
|
|
857
|
+
case "at":
|
|
858
|
+
return "at" in spec ? spec.at : void 0;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
function claimName(ctx, id, name) {
|
|
862
|
+
assertIdent("step name", name);
|
|
863
|
+
if (name === "Start" || name === "End" || name === id) {
|
|
864
|
+
throw new Error(`step name "${name}" is reserved (collides with a generated BPMN id) in flow "${id}"`);
|
|
865
|
+
}
|
|
866
|
+
if (RESERVED_PREFIXES.test(name)) {
|
|
867
|
+
throw new Error(`step name "${name}" uses a reserved prefix (Gw_/Loop_/Sub_/Msg_/f_/End_ are generated ids) in flow "${id}"`);
|
|
868
|
+
}
|
|
869
|
+
if (ctx.seen.has(name))
|
|
870
|
+
throw new Error(`duplicate step name "${name}" in flow "${id}"`);
|
|
871
|
+
ctx.seen.add(name);
|
|
872
|
+
}
|
|
873
|
+
function startInput(id, contracts) {
|
|
874
|
+
const c = contracts.Start;
|
|
875
|
+
if (!c)
|
|
876
|
+
return void 0;
|
|
877
|
+
if (c.out)
|
|
878
|
+
throw new Error(`flow "${id}": the Start contract takes only \`in\` (the flow's input), not \`out\``);
|
|
879
|
+
return c.in;
|
|
880
|
+
}
|
|
881
|
+
function contractEnvelopes(ctx, name) {
|
|
882
|
+
const c = ctx.contracts[name];
|
|
883
|
+
if (!c || !c.in && !c.out)
|
|
884
|
+
return void 0;
|
|
885
|
+
return { in: c.in, out: c.out };
|
|
886
|
+
}
|
|
887
|
+
function makeBuilder(id, out, ctx, isRoot = false) {
|
|
888
|
+
const child = (fn, inLoop) => {
|
|
889
|
+
const body = [];
|
|
890
|
+
const depth = inLoop ? ctx.loopDepth + 1 : ctx.loopDepth;
|
|
891
|
+
fn(makeBuilder(id, body, { ...ctx, loopDepth: depth }));
|
|
892
|
+
return body;
|
|
893
|
+
};
|
|
894
|
+
const childScoped = (fn) => {
|
|
895
|
+
const body = [];
|
|
896
|
+
fn(makeBuilder(id, body, { ...ctx, loopDepth: 0 }));
|
|
897
|
+
return body;
|
|
898
|
+
};
|
|
899
|
+
const setStartTimer = (t) => {
|
|
900
|
+
if (!isRoot) {
|
|
901
|
+
throw new Error(`startOn() is only valid at the top level of flow "${id}" (not inside switch/branch/loop)`);
|
|
902
|
+
}
|
|
903
|
+
if (out.length !== 0)
|
|
904
|
+
throw new Error(`startOn() must be the first statement in flow "${id}"`);
|
|
905
|
+
if (ctx.startTimer)
|
|
906
|
+
throw new Error(`startOn() may be called only once in flow "${id}"`);
|
|
907
|
+
ctx.startTimer = t;
|
|
908
|
+
};
|
|
909
|
+
let builderRef;
|
|
910
|
+
const api = {
|
|
911
|
+
id,
|
|
912
|
+
isRoot,
|
|
913
|
+
out,
|
|
914
|
+
contracts: ctx.contracts,
|
|
915
|
+
handlers: ctx.handlers,
|
|
916
|
+
get loopDepth() {
|
|
917
|
+
return ctx.loopDepth;
|
|
918
|
+
},
|
|
919
|
+
self() {
|
|
920
|
+
if (!builderRef)
|
|
921
|
+
throw new Error("internal: builder method invoked before assembly");
|
|
922
|
+
return builderRef;
|
|
923
|
+
},
|
|
924
|
+
child,
|
|
925
|
+
childScoped,
|
|
926
|
+
claim(name) {
|
|
927
|
+
claimName(ctx, id, name);
|
|
928
|
+
},
|
|
929
|
+
contractEnvelopes(name) {
|
|
930
|
+
return contractEnvelopes(ctx, name);
|
|
931
|
+
},
|
|
932
|
+
setStartTimer
|
|
933
|
+
};
|
|
934
|
+
const methods = /* @__PURE__ */ Object.create(null);
|
|
935
|
+
methods.startOn = startOnMethod(api);
|
|
936
|
+
for (const [kind, handlers] of eachNodeKind()) {
|
|
937
|
+
if (!handlers.build)
|
|
938
|
+
continue;
|
|
939
|
+
const method = handlers.builderMethod ?? kind;
|
|
940
|
+
if (Object.hasOwn(methods, method)) {
|
|
941
|
+
throw new Error(`two flow-node kinds both contribute the builder method "${method}"`);
|
|
942
|
+
}
|
|
943
|
+
methods[method] = handlers.build(api);
|
|
944
|
+
}
|
|
945
|
+
if (!isFlowBuilder(methods)) {
|
|
946
|
+
throw new Error(assemblyFailureMessage(methods));
|
|
947
|
+
}
|
|
948
|
+
builderRef = methods;
|
|
949
|
+
if (!isFlowBuilder(methods)) {
|
|
950
|
+
throw new Error(assemblyFailureMessage(methods));
|
|
951
|
+
}
|
|
952
|
+
return methods;
|
|
953
|
+
}
|
|
954
|
+
var BUILTIN_BUILDER_METHODS = [
|
|
955
|
+
"startOn",
|
|
956
|
+
"run",
|
|
957
|
+
"task",
|
|
958
|
+
"signal",
|
|
959
|
+
"timer",
|
|
960
|
+
"switch",
|
|
961
|
+
"branch",
|
|
962
|
+
"loop",
|
|
963
|
+
"parallel",
|
|
964
|
+
"forEach",
|
|
965
|
+
"break",
|
|
966
|
+
"continue"
|
|
967
|
+
];
|
|
968
|
+
function isFlowBuilder(x) {
|
|
969
|
+
return missingBuilderMethods(x).length === 0 && nonFunctionOwnProperties(x).length === 0;
|
|
970
|
+
}
|
|
971
|
+
function missingBuilderMethods(x) {
|
|
972
|
+
return BUILTIN_BUILDER_METHODS.filter((method) => typeof Reflect.get(x, method) !== "function");
|
|
973
|
+
}
|
|
974
|
+
function nonFunctionOwnProperties(x) {
|
|
975
|
+
return Object.getOwnPropertyNames(x).filter((k) => typeof Reflect.get(x, k) !== "function");
|
|
976
|
+
}
|
|
977
|
+
function assemblyFailureMessage(x) {
|
|
978
|
+
const missing = missingBuilderMethods(x);
|
|
979
|
+
if (missing.length > 0) {
|
|
980
|
+
return `internal: assembled FlowBuilder is missing registered methods: ${missing.join(", ")}`;
|
|
981
|
+
}
|
|
982
|
+
const nonFunctions = nonFunctionOwnProperties(x);
|
|
983
|
+
if (nonFunctions.length > 0) {
|
|
984
|
+
const label = nonFunctions.length === 1 ? "property" : "properties";
|
|
985
|
+
return `internal: assembled FlowBuilder has non-function own-${label}: ${nonFunctions.join(", ")}`;
|
|
986
|
+
}
|
|
987
|
+
return "internal: assembled FlowBuilder failed its assembly invariant";
|
|
988
|
+
}
|
|
989
|
+
function startOnMethod(api) {
|
|
990
|
+
return (spec) => {
|
|
991
|
+
const setCount = TIMER_START_KEYS.filter((key) => typeof timerStartValue(spec, key) === "string").length;
|
|
992
|
+
if (setCount !== 1) {
|
|
993
|
+
throw new Error(`startOn() needs exactly one of { cycle }, { after }, or { at } in flow "${api.id}"`);
|
|
994
|
+
}
|
|
995
|
+
if ("cycle" in spec) {
|
|
996
|
+
const cycle = spec.cycle.trim();
|
|
997
|
+
assertTimerCycle(`startOn cycle`, cycle);
|
|
998
|
+
api.setStartTimer({ cycle });
|
|
999
|
+
} else if ("after" in spec) {
|
|
1000
|
+
const after = spec.after.trim();
|
|
1001
|
+
assertTimerDuration(`startOn after`, after);
|
|
1002
|
+
api.setStartTimer({ after });
|
|
1003
|
+
} else {
|
|
1004
|
+
const at = spec.at.trim();
|
|
1005
|
+
assertTimerDate(`startOn at`, at);
|
|
1006
|
+
api.setStartTimer({ at });
|
|
1007
|
+
}
|
|
1008
|
+
return api.self();
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
function defineFlow(id, second, third) {
|
|
1012
|
+
assertIdent("workflow id", id);
|
|
1013
|
+
if (typeof second !== "function" && (second === null || typeof second !== "object")) {
|
|
1014
|
+
throw new Error(`defineFlow("${id}"): the contracts argument must be an object`);
|
|
1015
|
+
}
|
|
1016
|
+
const contracts = typeof second === "function" ? {} : second;
|
|
1017
|
+
if (typeof second !== "function" && typeof third !== "function") {
|
|
1018
|
+
throw new Error(`defineFlow("${id}"): a build callback (w) => {\u2026} is required`);
|
|
1019
|
+
}
|
|
1020
|
+
const steps = [];
|
|
1021
|
+
const handlers = {};
|
|
1022
|
+
const ctx = { contracts, handlers, seen: /* @__PURE__ */ new Set(), loopDepth: 0 };
|
|
1023
|
+
if (typeof second === "function") {
|
|
1024
|
+
second(makeBuilder(id, steps, ctx, true));
|
|
1025
|
+
} else {
|
|
1026
|
+
const build = third;
|
|
1027
|
+
if (typeof build !== "function") {
|
|
1028
|
+
throw new Error(`defineFlow("${id}"): a build callback (w) => {\u2026} is required`);
|
|
1029
|
+
}
|
|
1030
|
+
build(makeBuilder(id, steps, ctx, true));
|
|
1031
|
+
}
|
|
1032
|
+
if (steps.length === 0)
|
|
1033
|
+
throw new Error(`flow "${id}" declared no steps`);
|
|
1034
|
+
const flow = { kind: "declarative", id, steps, handlers };
|
|
1035
|
+
if (ctx.startTimer)
|
|
1036
|
+
flow.startTimer = ctx.startTimer;
|
|
1037
|
+
const input = startInput(id, contracts);
|
|
1038
|
+
if (input)
|
|
1039
|
+
flow.input = input;
|
|
1040
|
+
return flow;
|
|
1041
|
+
}
|
|
1042
|
+
var feel = (expr) => `=${expr}`;
|
|
1043
|
+
var feelEquals = (subject, value) => `=${subject} = "${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1044
|
+
function incomingOutgoing(inc, outg) {
|
|
1045
|
+
return inc.map((f) => ` <bpmn:incoming>${f}</bpmn:incoming>
|
|
1046
|
+
`).join("") + outg.map((f) => ` <bpmn:outgoing>${f}</bpmn:outgoing>
|
|
1047
|
+
`).join("");
|
|
1048
|
+
}
|
|
1049
|
+
var outgoingOnly = (outg) => outg.map((f) => `<bpmn:outgoing>${f}</bpmn:outgoing>`).join("");
|
|
1050
|
+
|
|
1051
|
+
// node_modules/@nanobpm/workflow/dist/envelope.js
|
|
1052
|
+
var SCALARS = /* @__PURE__ */ new Set([
|
|
1053
|
+
"string",
|
|
1054
|
+
"integer",
|
|
1055
|
+
"number",
|
|
1056
|
+
"boolean",
|
|
1057
|
+
"datetime"
|
|
1058
|
+
]);
|
|
1059
|
+
var EnvelopeDef = class {
|
|
1060
|
+
name;
|
|
1061
|
+
fields;
|
|
1062
|
+
type;
|
|
1063
|
+
constructor(name, fields) {
|
|
1064
|
+
this.name = name;
|
|
1065
|
+
this.fields = fields;
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
function normaliseField(name, spec) {
|
|
1069
|
+
if (spec === null || typeof spec !== "string" && typeof spec !== "object") {
|
|
1070
|
+
throw new Error(`envelope field "${name}": must be a scalar type or a { type, optional?, list? } object`);
|
|
1071
|
+
}
|
|
1072
|
+
const raw = typeof spec === "string" ? { type: spec } : spec;
|
|
1073
|
+
if (!SCALARS.has(raw.type)) {
|
|
1074
|
+
throw new Error(`envelope field "${name}": unknown type "${raw.type}" (expected one of ${[...SCALARS].join(", ")})`);
|
|
1075
|
+
}
|
|
1076
|
+
return {
|
|
1077
|
+
name,
|
|
1078
|
+
type: raw.type,
|
|
1079
|
+
optional: typeof spec === "object" && spec.optional === true,
|
|
1080
|
+
list: typeof spec === "object" && spec.list === true
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
function envelope(name, fields) {
|
|
1084
|
+
assertIdent("envelope name", name);
|
|
1085
|
+
const list = Object.entries(fields).map(([k, v]) => normaliseField(k, v));
|
|
1086
|
+
if (list.length === 0)
|
|
1087
|
+
throw new Error(`envelope "${name}" declares no fields`);
|
|
1088
|
+
for (const f of list)
|
|
1089
|
+
assertIdent("envelope field name", f.name);
|
|
1090
|
+
return new EnvelopeDef(name, list);
|
|
1091
|
+
}
|
|
1092
|
+
var DATETIME = /^(\d{4})-(\d{2})-(\d{2})([Tt ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?([Zz]|[+-]\d{2}:?\d{2})?)?$/;
|
|
1093
|
+
function isCalendarDate(y, m, d) {
|
|
1094
|
+
const leap = y % 4 === 0 && y % 100 !== 0 || y % 400 === 0;
|
|
1095
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1096
|
+
return m >= 1 && m <= 12 && d >= 1 && d <= days[m - 1];
|
|
1097
|
+
}
|
|
1098
|
+
function isDatetime(v) {
|
|
1099
|
+
if (typeof v !== "string")
|
|
1100
|
+
return false;
|
|
1101
|
+
const m = DATETIME.exec(v);
|
|
1102
|
+
return !!m && isCalendarDate(Number(m[1]), Number(m[2]), Number(m[3])) && !Number.isNaN(Date.parse(v));
|
|
1103
|
+
}
|
|
1104
|
+
function scalarProblem(type, v) {
|
|
1105
|
+
switch (type) {
|
|
1106
|
+
case "string":
|
|
1107
|
+
return typeof v === "string" ? void 0 : "must be a string";
|
|
1108
|
+
case "boolean":
|
|
1109
|
+
return typeof v === "boolean" ? void 0 : "must be true or false";
|
|
1110
|
+
case "number":
|
|
1111
|
+
return typeof v === "number" && Number.isFinite(v) ? void 0 : "must be a number";
|
|
1112
|
+
case "integer":
|
|
1113
|
+
return typeof v === "number" && Number.isInteger(v) ? void 0 : "must be a whole number";
|
|
1114
|
+
case "datetime":
|
|
1115
|
+
return isDatetime(v) ? void 0 : "must be an ISO 8601 date or date-time";
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
function isRecord(value) {
|
|
1119
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1120
|
+
}
|
|
1121
|
+
function validateEnvelope(env, value) {
|
|
1122
|
+
if (!isRecord(value))
|
|
1123
|
+
return [{ field: "", message: `${env.name} must be an object` }];
|
|
1124
|
+
const problems = [];
|
|
1125
|
+
for (const f of env.fields) {
|
|
1126
|
+
const v = Object.hasOwn(value, f.name) ? value[f.name] : void 0;
|
|
1127
|
+
if (v === void 0 || v === null && !f.optional) {
|
|
1128
|
+
if (!f.optional)
|
|
1129
|
+
problems.push({ field: f.name, message: "is required" });
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
if (f.list) {
|
|
1133
|
+
if (!Array.isArray(v)) {
|
|
1134
|
+
problems.push({ field: f.name, message: "must be a list" });
|
|
1135
|
+
continue;
|
|
1136
|
+
}
|
|
1137
|
+
const bad = v.findIndex((item) => scalarProblem(f.type, item) !== void 0);
|
|
1138
|
+
if (bad >= 0)
|
|
1139
|
+
problems.push({ field: f.name, message: `item ${bad} ${scalarProblem(f.type, v[bad])}` });
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
const p = scalarProblem(f.type, v);
|
|
1143
|
+
if (p)
|
|
1144
|
+
problems.push({ field: f.name, message: p });
|
|
1145
|
+
}
|
|
1146
|
+
return problems;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
// src/index.ts
|
|
1150
|
+
function defineStartForm(_input, hints) {
|
|
1151
|
+
return hints;
|
|
1152
|
+
}
|
|
1153
|
+
var jobContext = globalThis[/* @__PURE__ */ Symbol.for("agent-graph.job")] ??= new AsyncLocalStorage();
|
|
1154
|
+
function jobProject() {
|
|
1155
|
+
return jobContext.getStore()?.project;
|
|
1156
|
+
}
|
|
1157
|
+
function jobSignal() {
|
|
1158
|
+
return jobContext.getStore()?.signal;
|
|
1159
|
+
}
|
|
1160
|
+
function projectPath(...parts) {
|
|
1161
|
+
return path.resolve(jobProject() ?? process.env.AGE_PROJECT ?? process.cwd(), ...parts);
|
|
1162
|
+
}
|
|
1163
|
+
function runInProject(project, fn, signal) {
|
|
1164
|
+
return jobContext.run({ project, signal }, fn);
|
|
1165
|
+
}
|
|
1166
|
+
function defineForms(forms) {
|
|
1167
|
+
return forms;
|
|
1168
|
+
}
|
|
1169
|
+
function defineAgentProfiles(profiles) {
|
|
1170
|
+
return profiles;
|
|
1171
|
+
}
|
|
1172
|
+
function defineAgents(agents) {
|
|
1173
|
+
return agents;
|
|
1174
|
+
}
|
|
1175
|
+
function sh(command, opts = {}) {
|
|
1176
|
+
return new Promise((resolve, reject) => {
|
|
1177
|
+
const child = spawn("bash", ["-c", command], {
|
|
1178
|
+
cwd: opts.cwd ?? jobProject() ?? process.env.AGE_PROJECT ?? process.cwd(),
|
|
1179
|
+
env: { ...process.env, ...opts.env },
|
|
1180
|
+
stdio: [opts.input === void 0 ? "ignore" : "pipe", "pipe", "pipe"],
|
|
1181
|
+
timeout: opts.timeoutMs,
|
|
1182
|
+
signal: jobSignal()
|
|
1183
|
+
});
|
|
1184
|
+
let stdout = "";
|
|
1185
|
+
let stderr = "";
|
|
1186
|
+
child.stdout.on("data", (d) => stdout += d);
|
|
1187
|
+
child.stderr.on("data", (d) => stderr += d);
|
|
1188
|
+
child.on("error", reject);
|
|
1189
|
+
child.on("close", (code) => {
|
|
1190
|
+
const r = { stdout, stderr, code: code ?? -1 };
|
|
1191
|
+
if (r.code !== 0 && !opts.allowFail) {
|
|
1192
|
+
reject(new Error(`sh exited ${r.code}: ${command}
|
|
1193
|
+
${stderr.slice(-2e3) || stdout.slice(-2e3)}`));
|
|
1194
|
+
} else resolve(r);
|
|
1195
|
+
});
|
|
1196
|
+
if (child.stdin) {
|
|
1197
|
+
child.stdin.on("error", () => {
|
|
1198
|
+
});
|
|
1199
|
+
child.stdin.end(opts.input);
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
async function claude(prompt, opts = {}) {
|
|
1204
|
+
const cmd = process.env.AGE_CLAUDE_CMD ?? "claude";
|
|
1205
|
+
const args = ["-p", "--output-format", "json", "--permission-mode", opts.permissionMode ?? "dontAsk"];
|
|
1206
|
+
if (opts.allowedTools?.length) args.push("--allowedTools", opts.allowedTools.join(","));
|
|
1207
|
+
if (opts.model) args.push("--model", opts.model);
|
|
1208
|
+
if (opts.system) args.push("--append-system-prompt", opts.system);
|
|
1209
|
+
if (opts.schema) args.push("--json-schema", JSON.stringify(opts.schema));
|
|
1210
|
+
const out = await new Promise((resolve, reject) => {
|
|
1211
|
+
const child = spawn(cmd, args, {
|
|
1212
|
+
cwd: opts.cwd ?? jobProject() ?? process.env.AGE_PROJECT ?? process.cwd(),
|
|
1213
|
+
env: process.env,
|
|
1214
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1215
|
+
timeout: opts.timeoutMs ?? 30 * 6e4,
|
|
1216
|
+
signal: jobSignal()
|
|
1217
|
+
});
|
|
1218
|
+
let stdout = "";
|
|
1219
|
+
let stderr = "";
|
|
1220
|
+
child.stdout.on("data", (d) => stdout += d);
|
|
1221
|
+
child.stderr.on("data", (d) => stderr += d);
|
|
1222
|
+
child.on("error", reject);
|
|
1223
|
+
child.on(
|
|
1224
|
+
"close",
|
|
1225
|
+
(code) => code === 0 ? resolve(stdout) : reject(new Error(`${cmd} exited ${code}: ${(stderr || stdout).slice(-2e3)}`))
|
|
1226
|
+
);
|
|
1227
|
+
child.stdin.on("error", () => {
|
|
1228
|
+
});
|
|
1229
|
+
child.stdin.end(prompt);
|
|
1230
|
+
});
|
|
1231
|
+
const msg = JSON.parse(out);
|
|
1232
|
+
if (msg.is_error) throw new Error(`claude: ${msg.subtype ?? "error"}: ${String(msg.result ?? "").slice(0, 2e3)}`);
|
|
1233
|
+
let result = msg.structured_output ?? msg.result;
|
|
1234
|
+
if (opts.schema && typeof result === "string") {
|
|
1235
|
+
try {
|
|
1236
|
+
result = JSON.parse(result);
|
|
1237
|
+
} catch {
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return { result, costUsd: msg.total_cost_usd, sessionId: msg.session_id, turns: msg.num_turns };
|
|
1241
|
+
}
|
|
1242
|
+
export {
|
|
1243
|
+
claude,
|
|
1244
|
+
defineAgentProfiles,
|
|
1245
|
+
defineAgents,
|
|
1246
|
+
defineFlow,
|
|
1247
|
+
defineForms,
|
|
1248
|
+
defineStartForm,
|
|
1249
|
+
envelope,
|
|
1250
|
+
jobProject,
|
|
1251
|
+
jobSignal,
|
|
1252
|
+
projectPath,
|
|
1253
|
+
runInProject,
|
|
1254
|
+
sh,
|
|
1255
|
+
validateEnvelope
|
|
1256
|
+
};
|