flowneer 0.9.0 → 0.9.2
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/dist/{FlowBuilder-B_BIRk3f.d.ts → FlowBuilder-G67AbbRt.d.ts} +47 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -12
- package/dist/plugins/agent/index.d.ts +1 -1
- package/dist/plugins/config/index.d.ts +2 -2
- package/dist/plugins/dev/index.d.ts +37 -2
- package/dist/plugins/dev/index.js +32 -0
- package/dist/plugins/eval/index.d.ts +1 -1
- package/dist/plugins/graph/index.d.ts +1 -1
- package/dist/plugins/graph/index.js +481 -44
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.js +623 -178
- package/dist/plugins/llm/index.d.ts +4 -4
- package/dist/plugins/llm/index.js +47 -38
- package/dist/plugins/memory/index.d.ts +1 -1
- package/dist/plugins/messaging/index.d.ts +1 -1
- package/dist/plugins/observability/index.d.ts +4 -4
- package/dist/plugins/observability/index.js +41 -32
- package/dist/plugins/output/index.d.ts +1 -1
- package/dist/plugins/persistence/index.d.ts +4 -4
- package/dist/plugins/persistence/index.js +56 -47
- package/dist/plugins/resilience/index.d.ts +3 -3
- package/dist/plugins/resilience/index.js +38 -32
- package/dist/plugins/telemetry/index.d.ts +1 -1
- package/dist/plugins/tools/index.d.ts +1 -1
- package/dist/presets/agent/index.d.ts +1 -1
- package/dist/presets/agent/index.js +46 -12
- package/dist/presets/config/index.d.ts +25 -11
- package/dist/presets/config/index.js +107 -104
- package/dist/presets/index.d.ts +4 -4
- package/dist/presets/index.js +184 -104
- package/dist/presets/pipeline/index.d.ts +165 -2
- package/dist/presets/pipeline/index.js +123 -12
- package/dist/presets/rag/index.d.ts +1 -1
- package/dist/presets/rag/index.js +46 -12
- package/dist/{schema-DFNzcQP5.d.ts → schema-CIqQAXqY.d.ts} +10 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +46 -12
- package/package.json +1 -1
|
@@ -62,7 +62,7 @@ interface RunOptions {
|
|
|
62
62
|
/** Metadata exposed to hooks — intentionally minimal to avoid coupling. */
|
|
63
63
|
interface StepMeta {
|
|
64
64
|
index: number;
|
|
65
|
-
type: "fn" | "branch" | "loop" | "batch" | "parallel" | "anchor";
|
|
65
|
+
type: "fn" | "branch" | "loop" | "batch" | "parallel" | "anchor" | "dag";
|
|
66
66
|
label?: string;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -166,7 +166,35 @@ interface AnchorStep {
|
|
|
166
166
|
/** Maximum number of times a goto may jump to this anchor per run. */
|
|
167
167
|
maxVisits?: number;
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
/**
|
|
170
|
+
* A compiled DAG step. Produced by the graph plugin's `.compile()` and
|
|
171
|
+
* executed by the registered "dag" step handler, which traverses nodes
|
|
172
|
+
* in topological order and fires per-node lifecycle hooks natively.
|
|
173
|
+
*/
|
|
174
|
+
interface DagStep<S, P extends Record<string, unknown>> {
|
|
175
|
+
type: "dag";
|
|
176
|
+
nodes: Map<string, {
|
|
177
|
+
name: string;
|
|
178
|
+
fn: NodeFn<S, P>;
|
|
179
|
+
options?: NodeOptions<S, P>;
|
|
180
|
+
}>;
|
|
181
|
+
/** Topologically sorted node names. */
|
|
182
|
+
order: string[];
|
|
183
|
+
/** Conditional edges that point backwards (cycles). Always have a condition. */
|
|
184
|
+
backEdges: Array<{
|
|
185
|
+
from: string;
|
|
186
|
+
to: string;
|
|
187
|
+
condition: (shared: S, params: P) => boolean | Promise<boolean>;
|
|
188
|
+
}>;
|
|
189
|
+
/** Conditional edges that skip forward (not back-edges). Always have a condition. */
|
|
190
|
+
conditionalForward: Array<{
|
|
191
|
+
from: string;
|
|
192
|
+
to: string;
|
|
193
|
+
condition: (shared: S, params: P) => boolean | Promise<boolean>;
|
|
194
|
+
}>;
|
|
195
|
+
label?: string;
|
|
196
|
+
}
|
|
197
|
+
type Step<S, P extends Record<string, unknown>> = FnStep<S, P> | BranchStep<S, P> | LoopStep<S, P> | BatchStep<S, P> | ParallelStep<S, P> | AnchorStep | DagStep<S, P>;
|
|
170
198
|
|
|
171
199
|
type ResolvedHooks<S, P extends Record<string, unknown>> = {
|
|
172
200
|
beforeFlow: NonNullable<FlowHooks<S, P>["beforeFlow"]>[];
|
|
@@ -212,17 +240,30 @@ declare class CoreFlowBuilder<S = any, P extends Record<string, unknown> = Recor
|
|
|
212
240
|
private _hooksList;
|
|
213
241
|
private _hooksCache;
|
|
214
242
|
private static _stepHandlers;
|
|
243
|
+
/**
|
|
244
|
+
* Step types registered with `{ transparent: true }` are invoked directly
|
|
245
|
+
* by `_execute` without wrapping in the outer beforeStep/wrapStep/afterStep
|
|
246
|
+
* lifecycle. Use this for step types that manage per-item lifecycle
|
|
247
|
+
* internally (e.g. a DAG handler that fires hooks once per graph node).
|
|
248
|
+
*/
|
|
249
|
+
private static _transparentSteps;
|
|
215
250
|
/**
|
|
216
251
|
* Register a handler for a custom step type.
|
|
217
252
|
* Called once at module load time from each step plugin.
|
|
218
253
|
*
|
|
254
|
+
* Pass `{ transparent: true }` when the handler manages its own per-item
|
|
255
|
+
* lifecycle hooks internally and should not be wrapped by the outer
|
|
256
|
+
* beforeStep / wrapStep / afterStep guards.
|
|
257
|
+
*
|
|
219
258
|
* @example
|
|
220
259
|
* CoreFlowBuilder.registerStepType("myStep", async (step, ctx) => {
|
|
221
260
|
* await doWork(ctx.shared);
|
|
222
261
|
* return undefined;
|
|
223
262
|
* });
|
|
224
263
|
*/
|
|
225
|
-
static registerStepType(type: string, handler: StepHandler
|
|
264
|
+
static registerStepType(type: string, handler: StepHandler, options?: {
|
|
265
|
+
transparent?: boolean;
|
|
266
|
+
}): void;
|
|
226
267
|
private _hooks;
|
|
227
268
|
/**
|
|
228
269
|
* Register lifecycle hooks (called by plugin methods, not by consumers).
|
|
@@ -238,8 +279,8 @@ declare class CoreFlowBuilder<S = any, P extends Record<string, unknown> = Recor
|
|
|
238
279
|
* The base class prototype is never touched, so different `extend()`
|
|
239
280
|
* calls are fully isolated from each other.
|
|
240
281
|
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
282
|
+
* Duplicate method names across plugins (or colliding with an existing
|
|
283
|
+
* prototype method) throw immediately to prevent silent overwrites.
|
|
243
284
|
*
|
|
244
285
|
* @example
|
|
245
286
|
* const AppFlow = FlowBuilder.extend([withTiming, withRateLimit]);
|
|
@@ -354,4 +395,4 @@ declare class FlowBuilder<S = any, P extends Record<string, unknown> = Record<st
|
|
|
354
395
|
private _addFn;
|
|
355
396
|
}
|
|
356
397
|
|
|
357
|
-
export { type AnchorStep as A, type BatchStep as B, CoreFlowBuilder as C, FlowBuilder as F, type LoopStep as L, type NodeFn as N, type ParallelStep as P, type ResolvedHooks as R, type StepFilter as S, type Validator as V, type FlowneerPlugin as a, type NodeOptions as b, type FlowHooks as c, type StepMeta as d, type BranchStep as e, type FnStep as f, type NumberOrFn as g, type RunOptions as h, type Step as i, type StepContext as j, type StepHandler as k, type StreamEvent as l };
|
|
398
|
+
export { type AnchorStep as A, type BatchStep as B, CoreFlowBuilder as C, type DagStep as D, FlowBuilder as F, type LoopStep as L, type NodeFn as N, type ParallelStep as P, type ResolvedHooks as R, type StepFilter as S, type Validator as V, type FlowneerPlugin as a, type NodeOptions as b, type FlowHooks as c, type StepMeta as d, type BranchStep as e, type FnStep as f, type NumberOrFn as g, type RunOptions as h, type Step as i, type StepContext as j, type StepHandler as k, type StreamEvent as l };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { F as FlowBuilder, c as FlowHooks, a as FlowneerPlugin, N as NodeFn, b as NodeOptions, g as NumberOrFn, h as RunOptions, d as StepMeta, l as StreamEvent, V as Validator } from './FlowBuilder-
|
|
1
|
+
export { F as FlowBuilder, c as FlowHooks, a as FlowneerPlugin, N as NodeFn, b as NodeOptions, g as NumberOrFn, h as RunOptions, d as StepMeta, l as StreamEvent, V as Validator } from './FlowBuilder-G67AbbRt.js';
|
|
2
2
|
export { Fragment, fragment } from './src/index.js';
|
|
3
3
|
export { F as FlowError, I as InterruptError } from './errors-u-hq7p5N.js';
|
package/dist/index.js
CHANGED
|
@@ -23,15 +23,13 @@ var InterruptError = class extends Error {
|
|
|
23
23
|
// src/core/utils.ts
|
|
24
24
|
function matchesFilter(filter, meta) {
|
|
25
25
|
if (!Array.isArray(filter)) return filter(meta);
|
|
26
|
-
if (meta.label === void 0) return false;
|
|
27
26
|
const label = meta.label;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"^" +
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
});
|
|
27
|
+
if (label === void 0) return false;
|
|
28
|
+
return filter.some(
|
|
29
|
+
(p) => p.includes("*") ? new RegExp(
|
|
30
|
+
"^" + p.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*") + "$"
|
|
31
|
+
).test(label) : p === label
|
|
32
|
+
);
|
|
35
33
|
}
|
|
36
34
|
function resolveNumber(val, fallback, shared, params) {
|
|
37
35
|
if (val === void 0) return fallback;
|
|
@@ -124,18 +122,30 @@ var CoreFlowBuilder = class _CoreFlowBuilder {
|
|
|
124
122
|
// Step-type registry (static — shared across all instances)
|
|
125
123
|
// -------------------------------------------------------------------------
|
|
126
124
|
static _stepHandlers = /* @__PURE__ */ new Map();
|
|
125
|
+
/**
|
|
126
|
+
* Step types registered with `{ transparent: true }` are invoked directly
|
|
127
|
+
* by `_execute` without wrapping in the outer beforeStep/wrapStep/afterStep
|
|
128
|
+
* lifecycle. Use this for step types that manage per-item lifecycle
|
|
129
|
+
* internally (e.g. a DAG handler that fires hooks once per graph node).
|
|
130
|
+
*/
|
|
131
|
+
static _transparentSteps = /* @__PURE__ */ new Set();
|
|
127
132
|
/**
|
|
128
133
|
* Register a handler for a custom step type.
|
|
129
134
|
* Called once at module load time from each step plugin.
|
|
130
135
|
*
|
|
136
|
+
* Pass `{ transparent: true }` when the handler manages its own per-item
|
|
137
|
+
* lifecycle hooks internally and should not be wrapped by the outer
|
|
138
|
+
* beforeStep / wrapStep / afterStep guards.
|
|
139
|
+
*
|
|
131
140
|
* @example
|
|
132
141
|
* CoreFlowBuilder.registerStepType("myStep", async (step, ctx) => {
|
|
133
142
|
* await doWork(ctx.shared);
|
|
134
143
|
* return undefined;
|
|
135
144
|
* });
|
|
136
145
|
*/
|
|
137
|
-
static registerStepType(type, handler) {
|
|
146
|
+
static registerStepType(type, handler, options) {
|
|
138
147
|
_CoreFlowBuilder._stepHandlers.set(type, handler);
|
|
148
|
+
if (options?.transparent) _CoreFlowBuilder._transparentSteps.add(type);
|
|
139
149
|
}
|
|
140
150
|
// -------------------------------------------------------------------------
|
|
141
151
|
// Hooks & plugins
|
|
@@ -166,8 +176,8 @@ var CoreFlowBuilder = class _CoreFlowBuilder {
|
|
|
166
176
|
* The base class prototype is never touched, so different `extend()`
|
|
167
177
|
* calls are fully isolated from each other.
|
|
168
178
|
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
179
|
+
* Duplicate method names across plugins (or colliding with an existing
|
|
180
|
+
* prototype method) throw immediately to prevent silent overwrites.
|
|
171
181
|
*
|
|
172
182
|
* @example
|
|
173
183
|
* const AppFlow = FlowBuilder.extend([withTiming, withRateLimit]);
|
|
@@ -179,11 +189,16 @@ var CoreFlowBuilder = class _CoreFlowBuilder {
|
|
|
179
189
|
static extend(plugins) {
|
|
180
190
|
const Extended = class extends this {
|
|
181
191
|
};
|
|
192
|
+
const methods = {};
|
|
182
193
|
for (const plugin of plugins) {
|
|
183
194
|
for (const [name, fn] of Object.entries(plugin)) {
|
|
184
|
-
Extended.prototype
|
|
195
|
+
if (name in methods || name in Extended.prototype) {
|
|
196
|
+
throw new Error(`Plugin method collision: "${name}"`);
|
|
197
|
+
}
|
|
198
|
+
methods[name] = fn;
|
|
185
199
|
}
|
|
186
200
|
}
|
|
201
|
+
Object.assign(Extended.prototype, methods);
|
|
187
202
|
return Extended;
|
|
188
203
|
}
|
|
189
204
|
// -------------------------------------------------------------------------
|
|
@@ -260,6 +275,25 @@ var CoreFlowBuilder = class _CoreFlowBuilder {
|
|
|
260
275
|
signal?.throwIfAborted();
|
|
261
276
|
const step = this.steps[i];
|
|
262
277
|
if (step.type === "anchor") continue;
|
|
278
|
+
if (_CoreFlowBuilder._transparentSteps.has(step.type)) {
|
|
279
|
+
const handler = _CoreFlowBuilder._stepHandlers.get(step.type);
|
|
280
|
+
if (handler) {
|
|
281
|
+
const meta2 = {
|
|
282
|
+
index: i,
|
|
283
|
+
type: step.type,
|
|
284
|
+
label: step.label
|
|
285
|
+
};
|
|
286
|
+
await handler(step, {
|
|
287
|
+
shared,
|
|
288
|
+
params,
|
|
289
|
+
signal,
|
|
290
|
+
hooks,
|
|
291
|
+
meta: meta2,
|
|
292
|
+
builder: this
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
263
297
|
const stepLabel = step.label;
|
|
264
298
|
const meta = {
|
|
265
299
|
index: i,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FlowBuilder, a as FlowneerPlugin } from '../../FlowBuilder-
|
|
1
|
+
import { F as FlowBuilder, a as FlowneerPlugin } from '../../FlowBuilder-G67AbbRt.js';
|
|
2
2
|
|
|
3
3
|
interface HumanNodeOptions<S = any, P extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as FnRegistry, b as ValidationResult } from '../../schema-
|
|
2
|
-
export { A as AnchorStepConfig, B as BatchStepConfig, c as BranchStepConfig, F as FlowConfig, d as FnStepConfig, L as LoopStepConfig, P as ParallelStepConfig, S as StepConfig, V as ValidationError } from '../../schema-
|
|
1
|
+
import { a as FnRegistry, b as ValidationResult } from '../../schema-CIqQAXqY.js';
|
|
2
|
+
export { A as AnchorStepConfig, B as BatchStepConfig, c as BranchStepConfig, F as FlowConfig, d as FnStepConfig, L as LoopStepConfig, P as ParallelStepConfig, S as StepConfig, V as ValidationError } from '../../schema-CIqQAXqY.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Validate a raw config object + registry without building anything.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FlowneerPlugin, N as NodeFn, b as NodeOptions } from '../../FlowBuilder-
|
|
1
|
+
import { a as FlowneerPlugin, N as NodeFn, b as NodeOptions, S as StepFilter } from '../../FlowBuilder-G67AbbRt.js';
|
|
2
2
|
|
|
3
3
|
declare module "../../Flowneer" {
|
|
4
4
|
interface FlowBuilder<S, P> {
|
|
@@ -130,4 +130,39 @@ declare module "../../Flowneer" {
|
|
|
130
130
|
}
|
|
131
131
|
declare const withFlowAnalyzer: FlowneerPlugin;
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
interface DebuggerHooks {
|
|
134
|
+
/** Pause before a step runs. Default: `true`. */
|
|
135
|
+
beforeStep?: boolean;
|
|
136
|
+
/** Pause after a step completes. Default: `false`. */
|
|
137
|
+
afterStep?: boolean;
|
|
138
|
+
/** Pause when a step throws. Default: `false`. */
|
|
139
|
+
onError?: boolean;
|
|
140
|
+
/** Pause once before the step body and once after (inside the wrapper). Default: `false`. */
|
|
141
|
+
wrapStep?: boolean;
|
|
142
|
+
}
|
|
143
|
+
declare module "../../Flowneer" {
|
|
144
|
+
interface FlowBuilder<S, P> {
|
|
145
|
+
/**
|
|
146
|
+
* Drops a `debugger` statement at the selected lifecycle points.
|
|
147
|
+
* Attach DevTools / `--inspect` breakpoints and step through live flow state.
|
|
148
|
+
*
|
|
149
|
+
* @param filter Limit to specific steps by label or predicate (optional).
|
|
150
|
+
* @param hooks Which lifecycle points to pause at. Defaults to `{ beforeStep: true }`.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* // Pause before every step
|
|
154
|
+
* new AppFlow().withDebugger().then(myStep).run(shared);
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* // Pause only on "llm:*" steps, before and after
|
|
158
|
+
* new AppFlow()
|
|
159
|
+
* .withDebugger(["llm:*"], { beforeStep: true, afterStep: true })
|
|
160
|
+
* .then(callLlm)
|
|
161
|
+
* .run(shared);
|
|
162
|
+
*/
|
|
163
|
+
withDebugger(filter?: StepFilter, hooks?: DebuggerHooks): this;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
declare const withDebugger: FlowneerPlugin;
|
|
167
|
+
|
|
168
|
+
export { type DebuggerHooks, type PathMap, type PathNode, type TraceEvent, type TraceHandle, type TraceReport, withAtomicUpdates, withDebugger, withDryRun, withFlowAnalyzer, withMocks, withStepLimit };
|
|
@@ -179,8 +179,40 @@ var withFlowAnalyzer = {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
|
+
|
|
183
|
+
// plugins/dev/withDebugger.ts
|
|
184
|
+
var withDebugger = {
|
|
185
|
+
withDebugger(filter, hooks = { beforeStep: true }) {
|
|
186
|
+
const registered = {};
|
|
187
|
+
if (hooks.beforeStep) {
|
|
188
|
+
registered.beforeStep = (meta, shared, params) => {
|
|
189
|
+
debugger;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
if (hooks.afterStep) {
|
|
193
|
+
registered.afterStep = (meta, shared, params) => {
|
|
194
|
+
debugger;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (hooks.onError) {
|
|
198
|
+
registered.onError = (meta, error, shared, params) => {
|
|
199
|
+
debugger;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
if (hooks.wrapStep) {
|
|
203
|
+
registered.wrapStep = async (meta, next, shared, params) => {
|
|
204
|
+
debugger;
|
|
205
|
+
await next();
|
|
206
|
+
debugger;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
this._setHooks(registered, filter);
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
182
213
|
export {
|
|
183
214
|
withAtomicUpdates,
|
|
215
|
+
withDebugger,
|
|
184
216
|
withDryRun,
|
|
185
217
|
withFlowAnalyzer,
|
|
186
218
|
withMocks,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FlowneerPlugin, N as NodeFn, b as NodeOptions } from '../../FlowBuilder-
|
|
1
|
+
import { a as FlowneerPlugin, N as NodeFn, b as NodeOptions } from '../../FlowBuilder-G67AbbRt.js';
|
|
2
2
|
|
|
3
3
|
/** A single node entry in the exported graph. */
|
|
4
4
|
interface GraphNodeExport {
|