@particle-academy/fancy-flow 0.27.1 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -15
- package/dist/{capabilities-85Mjn4uW.d.ts → capabilities-BH7zmSQQ.d.ts} +1 -1
- package/dist/{capabilities-exVeADXz.d.cts → capabilities-BLOeLACV.d.cts} +1 -1
- package/dist/{chunk-HHFOHHAQ.js → chunk-EBE3FEAJ.js} +2 -2
- package/dist/{chunk-HHFOHHAQ.js.map → chunk-EBE3FEAJ.js.map} +1 -1
- package/dist/chunk-FKOXQP76.js +50 -0
- package/dist/chunk-FKOXQP76.js.map +1 -0
- package/dist/engine.cjs +46 -0
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.cts +1 -1
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +1 -0
- package/dist/engine.js.map +1 -1
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/llm/prism.cjs +72 -0
- package/dist/llm/prism.cjs.map +1 -0
- package/dist/llm/prism.d.cts +68 -0
- package/dist/llm/prism.d.ts +68 -0
- package/dist/llm/prism.js +65 -0
- package/dist/llm/prism.js.map +1 -0
- package/dist/llm/vercel-ai.d.cts +1 -1
- package/dist/llm/vercel-ai.d.ts +1 -1
- package/dist/registry/index.d.cts +2 -2
- package/dist/registry/index.d.ts +2 -2
- package/dist/run-cohort-CV7EcwGG.d.ts +111 -0
- package/dist/run-cohort-DitsaYgS.d.cts +111 -0
- package/dist/runtime/index.d.cts +2 -2
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime.cjs +46 -0
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +2 -1
- package/package.json +11 -1
- package/dist/run-flow-9U-gaYVF.d.ts +0 -35
- package/dist/run-flow-AXzOR-Wq.d.cts +0 -35
package/dist/runtime.cjs
CHANGED
|
@@ -198,6 +198,51 @@ function activatedPorts(node, result) {
|
|
|
198
198
|
const declared = resolveNodePorts(node, kind).outputs?.map((p) => p.id);
|
|
199
199
|
return { ports: declared?.length ? declared : ["out"], value: result };
|
|
200
200
|
}
|
|
201
|
+
|
|
202
|
+
// src/runtime/run-cohort.ts
|
|
203
|
+
async function runCohort(flows, executors, onEvent = () => {
|
|
204
|
+
}, options = {}) {
|
|
205
|
+
const { policy = "serial-guarded", guard, reason, ...runOptions } = options;
|
|
206
|
+
if (policy === "parallel") {
|
|
207
|
+
return Promise.all(
|
|
208
|
+
flows.map(async (flow, index2) => ({
|
|
209
|
+
...await runFlow(flow, executors, (e) => onEvent(e, index2), runOptions),
|
|
210
|
+
index: index2
|
|
211
|
+
}))
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
const results = [];
|
|
215
|
+
for (const [index2, flow] of flows.entries()) {
|
|
216
|
+
if (policy === "serial-guarded" && guard) {
|
|
217
|
+
const why = () => reason?.(flow, index2) ?? "trigger precondition no longer holds";
|
|
218
|
+
let passes;
|
|
219
|
+
try {
|
|
220
|
+
passes = await guard(flow, index2);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
results.push({
|
|
223
|
+
ok: false,
|
|
224
|
+
outputs: {},
|
|
225
|
+
index: index2,
|
|
226
|
+
skipped: true,
|
|
227
|
+
skippedReason: `guard could not be evaluated: ${errorText(error)}`
|
|
228
|
+
});
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (!passes) {
|
|
232
|
+
results.push({ ok: false, outputs: {}, index: index2, skipped: true, skippedReason: why() });
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
results.push({
|
|
237
|
+
...await runFlow(flow, executors, (e) => onEvent(e, index2), runOptions),
|
|
238
|
+
index: index2
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return results;
|
|
242
|
+
}
|
|
243
|
+
function errorText(error) {
|
|
244
|
+
return error instanceof Error ? error.message : String(error);
|
|
245
|
+
}
|
|
201
246
|
function useFlowRun({ maxFeed = 200 } = {}) {
|
|
202
247
|
const [statuses, setStatuses] = ReactExports.useState({});
|
|
203
248
|
const [statusText, setStatusText] = ReactExports.useState({});
|
|
@@ -9330,6 +9375,7 @@ function useFlowHistory(flow) {
|
|
|
9330
9375
|
exports.applyOutputsToNodes = applyOutputsToNodes;
|
|
9331
9376
|
exports.applyStatusesToNodes = applyStatusesToNodes;
|
|
9332
9377
|
exports.createHistory = createHistory;
|
|
9378
|
+
exports.runCohort = runCohort;
|
|
9333
9379
|
exports.runFlow = runFlow;
|
|
9334
9380
|
exports.useFlowHistory = useFlowHistory;
|
|
9335
9381
|
exports.useFlowRun = useFlowRun;
|