@graphrefly/graphrefly 0.8.0 → 0.9.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/dist/compat/nestjs/index.js +1 -1
- package/dist/index.cjs +275 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +190 -15
- package/dist/index.d.ts +190 -15
- package/dist/index.js +277 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1490,13 +1490,13 @@ declare namespace messaging {
|
|
|
1490
1490
|
* Phase 2 operator names (for example `gate`, `forEach`).
|
|
1491
1491
|
*/
|
|
1492
1492
|
|
|
1493
|
-
type StepRef = string | Node<unknown>;
|
|
1493
|
+
type StepRef$1 = string | Node<unknown>;
|
|
1494
1494
|
type OrchestrationMeta = {
|
|
1495
1495
|
orchestration?: true;
|
|
1496
1496
|
orchestration_type?: string;
|
|
1497
1497
|
};
|
|
1498
1498
|
type OrchestrationStepOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1499
|
-
deps?: ReadonlyArray<StepRef>;
|
|
1499
|
+
deps?: ReadonlyArray<StepRef$1>;
|
|
1500
1500
|
meta?: Record<string, unknown> & OrchestrationMeta;
|
|
1501
1501
|
};
|
|
1502
1502
|
type BranchResult<T> = {
|
|
@@ -1510,7 +1510,7 @@ type SensorControls<T> = {
|
|
|
1510
1510
|
complete(): void;
|
|
1511
1511
|
};
|
|
1512
1512
|
type LoopOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
1513
|
-
iterations?: number | StepRef;
|
|
1513
|
+
iterations?: number | StepRef$1;
|
|
1514
1514
|
};
|
|
1515
1515
|
type WaitOptions = Omit<OrchestrationStepOptions, "deps">;
|
|
1516
1516
|
type SubPipelineBuilder = (sub: Graph) => void;
|
|
@@ -1525,32 +1525,32 @@ declare function task<T>(graph: Graph, name: string, run: NodeFn<T>, opts?: Orch
|
|
|
1525
1525
|
/**
|
|
1526
1526
|
* Emits tagged branch outcomes (`then` / `else`) for each source value.
|
|
1527
1527
|
*/
|
|
1528
|
-
declare function branch<T>(graph: Graph, name: string, source: StepRef, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
1528
|
+
declare function branch<T>(graph: Graph, name: string, source: StepRef$1, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
1529
1529
|
/**
|
|
1530
1530
|
* Forwards source values only while `control` is truthy.
|
|
1531
1531
|
*/
|
|
1532
|
-
declare function gate<T>(graph: Graph, name: string, source: StepRef, control: StepRef, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1532
|
+
declare function gate<T>(graph: Graph, name: string, source: StepRef$1, control: StepRef$1, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1533
1533
|
type ApprovalOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
1534
1534
|
isApproved?: (value: unknown) => boolean;
|
|
1535
1535
|
};
|
|
1536
1536
|
/**
|
|
1537
1537
|
* Human/LLM approval gate over a source value.
|
|
1538
1538
|
*/
|
|
1539
|
-
declare function approval<T>(graph: Graph, name: string, source: StepRef, approver: StepRef, opts?: ApprovalOptions): Node<T>;
|
|
1539
|
+
declare function approval<T>(graph: Graph, name: string, source: StepRef$1, approver: StepRef$1, opts?: ApprovalOptions): Node<T>;
|
|
1540
1540
|
/**
|
|
1541
1541
|
* Registers a workflow side-effect step. The step remains graph-observable and forwards messages.
|
|
1542
1542
|
*/
|
|
1543
|
-
declare function forEach<T>(graph: Graph, name: string, source: StepRef, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1543
|
+
declare function forEach<T>(graph: Graph, name: string, source: StepRef$1, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1544
1544
|
/**
|
|
1545
1545
|
* Registers a join step that emits a tuple of latest dependency values.
|
|
1546
1546
|
*/
|
|
1547
1547
|
declare function join<T extends readonly unknown[]>(graph: Graph, name: string, deps: {
|
|
1548
|
-
[K in keyof T]: StepRef;
|
|
1548
|
+
[K in keyof T]: StepRef$1;
|
|
1549
1549
|
}, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1550
1550
|
/**
|
|
1551
1551
|
* Registers a loop step that applies `iterate` to each source value N times.
|
|
1552
1552
|
*/
|
|
1553
|
-
declare function loop<T>(graph: Graph, name: string, source: StepRef, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
1553
|
+
declare function loop<T>(graph: Graph, name: string, source: StepRef$1, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
1554
1554
|
/**
|
|
1555
1555
|
* Mounts and returns a child workflow graph.
|
|
1556
1556
|
*/
|
|
@@ -1564,18 +1564,17 @@ declare function sensor<T>(graph: Graph, name: string, initial?: T, opts?: Omit<
|
|
|
1564
1564
|
/**
|
|
1565
1565
|
* Registers a delayed-forwarding step (value-level wait).
|
|
1566
1566
|
*/
|
|
1567
|
-
declare function wait<T>(graph: Graph, name: string, source: StepRef, ms: number, opts?: WaitOptions): Node<T>;
|
|
1567
|
+
declare function wait<T>(graph: Graph, name: string, source: StepRef$1, ms: number, opts?: WaitOptions): Node<T>;
|
|
1568
1568
|
/**
|
|
1569
1569
|
* Registers an error-recovery step for a source.
|
|
1570
1570
|
*/
|
|
1571
|
-
declare function onFailure<T>(graph: Graph, name: string, source: StepRef, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1571
|
+
declare function onFailure<T>(graph: Graph, name: string, source: StepRef$1, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1572
1572
|
|
|
1573
1573
|
type orchestration_ApprovalOptions = ApprovalOptions;
|
|
1574
1574
|
type orchestration_BranchResult<T> = BranchResult<T>;
|
|
1575
1575
|
type orchestration_LoopOptions = LoopOptions;
|
|
1576
1576
|
type orchestration_OrchestrationStepOptions = OrchestrationStepOptions;
|
|
1577
1577
|
type orchestration_SensorControls<T> = SensorControls<T>;
|
|
1578
|
-
type orchestration_StepRef = StepRef;
|
|
1579
1578
|
type orchestration_SubPipelineBuilder = SubPipelineBuilder;
|
|
1580
1579
|
type orchestration_WaitOptions = WaitOptions;
|
|
1581
1580
|
declare const orchestration_approval: typeof approval;
|
|
@@ -1591,7 +1590,182 @@ declare const orchestration_subPipeline: typeof subPipeline;
|
|
|
1591
1590
|
declare const orchestration_task: typeof task;
|
|
1592
1591
|
declare const orchestration_wait: typeof wait;
|
|
1593
1592
|
declare namespace orchestration {
|
|
1594
|
-
export { type orchestration_ApprovalOptions as ApprovalOptions, type orchestration_BranchResult as BranchResult, type orchestration_LoopOptions as LoopOptions, type orchestration_OrchestrationStepOptions as OrchestrationStepOptions, type orchestration_SensorControls as SensorControls, type
|
|
1593
|
+
export { type orchestration_ApprovalOptions as ApprovalOptions, type orchestration_BranchResult as BranchResult, type orchestration_LoopOptions as LoopOptions, type orchestration_OrchestrationStepOptions as OrchestrationStepOptions, type orchestration_SensorControls as SensorControls, type StepRef$1 as StepRef, type orchestration_SubPipelineBuilder as SubPipelineBuilder, type orchestration_WaitOptions as WaitOptions, orchestration_approval as approval, orchestration_branch as branch, orchestration_forEach as forEach, orchestration_gate as gate, orchestration_join as join, orchestration_loop as loop, orchestration_onFailure as onFailure, orchestration_pipeline as pipeline, orchestration_sensor as sensor, orchestration_subPipeline as subPipeline, orchestration_task as task, orchestration_wait as wait };
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Reduction primitives (roadmap §8.1).
|
|
1598
|
+
*
|
|
1599
|
+
* Composable building blocks for taking heterogeneous massive inputs and producing
|
|
1600
|
+
* prioritized, auditable, human-actionable output. Each primitive is either a Graph
|
|
1601
|
+
* factory or a Node factory, built on top of core + extra primitives.
|
|
1602
|
+
*
|
|
1603
|
+
* @module
|
|
1604
|
+
*/
|
|
1605
|
+
|
|
1606
|
+
type StepRef = string | Node<unknown>;
|
|
1607
|
+
/** A single routing rule for {@link stratify}. */
|
|
1608
|
+
type StratifyRule<T> = {
|
|
1609
|
+
/** Branch name (used as node name under `branch/<name>`). */
|
|
1610
|
+
name: string;
|
|
1611
|
+
/** Classifier: returns `true` if the value belongs to this branch. */
|
|
1612
|
+
classify: (value: T) => boolean;
|
|
1613
|
+
/** Optional operator chain applied to the branch after classification. */
|
|
1614
|
+
ops?: (n: Node<T>) => Node;
|
|
1615
|
+
};
|
|
1616
|
+
/** Options for {@link stratify}. */
|
|
1617
|
+
type StratifyOptions = GraphOptions & {
|
|
1618
|
+
meta?: Record<string, unknown>;
|
|
1619
|
+
};
|
|
1620
|
+
/**
|
|
1621
|
+
* Route input to different reduction branches based on classifier functions.
|
|
1622
|
+
*
|
|
1623
|
+
* Each branch gets an independent operator chain. Rules are reactive — update
|
|
1624
|
+
* the `"rules"` state node to rewrite classification at runtime. Rule updates
|
|
1625
|
+
* affect **future items only** (streaming classification, not retroactive).
|
|
1626
|
+
*
|
|
1627
|
+
* Branch nodes are structural — created at construction time and persist for
|
|
1628
|
+
* the graph's lifetime. If a rule name is removed from the rules array, the
|
|
1629
|
+
* corresponding branch silently drops items (classifier not found). To tear
|
|
1630
|
+
* down a dead branch, call `graph.remove("branch/<name>")`.
|
|
1631
|
+
*
|
|
1632
|
+
* @param name - Graph name.
|
|
1633
|
+
* @param source - Input node (registered externally or will be added as `"source"`).
|
|
1634
|
+
* @param rules - Initial routing rules.
|
|
1635
|
+
* @param opts - Optional graph/meta options.
|
|
1636
|
+
* @returns Graph with `"source"`, `"rules"`, and `"branch/<name>"` nodes.
|
|
1637
|
+
*
|
|
1638
|
+
* @category patterns
|
|
1639
|
+
*/
|
|
1640
|
+
declare function stratify<T>(name: string, source: Node<T>, rules: ReadonlyArray<StratifyRule<T>>, opts?: StratifyOptions): Graph;
|
|
1641
|
+
/** A named stage for {@link funnel}. */
|
|
1642
|
+
type FunnelStage = {
|
|
1643
|
+
/** Stage name (mounted as subgraph). */
|
|
1644
|
+
name: string;
|
|
1645
|
+
/** Builder: receives a sub-graph, should add an `"input"` and `"output"` node. */
|
|
1646
|
+
build: (sub: Graph) => void;
|
|
1647
|
+
};
|
|
1648
|
+
/** Options for {@link funnel}. */
|
|
1649
|
+
type FunnelOptions = GraphOptions & {
|
|
1650
|
+
meta?: Record<string, unknown>;
|
|
1651
|
+
};
|
|
1652
|
+
/**
|
|
1653
|
+
* Multi-source merge with sequential reduction stages.
|
|
1654
|
+
*
|
|
1655
|
+
* Sources are merged into a single stream. Each stage is a named subgraph
|
|
1656
|
+
* (mounted via `graph.mount()`). Stages connect linearly:
|
|
1657
|
+
* `merged → stage[0].input → stage[0].output → stage[1].input → ...`
|
|
1658
|
+
*
|
|
1659
|
+
* @param name - Graph name.
|
|
1660
|
+
* @param sources - Input nodes to merge.
|
|
1661
|
+
* @param stages - Sequential reduction stages.
|
|
1662
|
+
* @param opts - Optional graph/meta options.
|
|
1663
|
+
* @returns Graph with `"merged"` and mounted stage subgraphs.
|
|
1664
|
+
*
|
|
1665
|
+
* @category patterns
|
|
1666
|
+
*/
|
|
1667
|
+
declare function funnel<T>(name: string, sources: ReadonlyArray<Node<T>>, stages: ReadonlyArray<FunnelStage>, opts?: FunnelOptions): Graph;
|
|
1668
|
+
/** Options for {@link feedback}. */
|
|
1669
|
+
type FeedbackOptions = {
|
|
1670
|
+
/** Maximum feedback iterations before stopping (default: 10). */
|
|
1671
|
+
maxIterations?: number;
|
|
1672
|
+
/** Optional budget gate node path for cost-bounded iteration. */
|
|
1673
|
+
budgetNode?: StepRef;
|
|
1674
|
+
meta?: Record<string, unknown>;
|
|
1675
|
+
};
|
|
1676
|
+
/**
|
|
1677
|
+
* Introduce a bounded reactive cycle into an existing graph.
|
|
1678
|
+
*
|
|
1679
|
+
* When `condition` emits a non-null DATA value, the feedback effect routes it
|
|
1680
|
+
* back to the `reentry` state node — creating a cycle. Bounded by
|
|
1681
|
+
* `maxIterations` (default 10). The counter node (`__feedback_<condition>`)
|
|
1682
|
+
* is the source of truth — reset it to 0 to allow more iterations.
|
|
1683
|
+
*
|
|
1684
|
+
* To remove the feedback cycle, call `graph.remove("__feedback_<condition>")`.
|
|
1685
|
+
*
|
|
1686
|
+
* @param graph - Existing graph to augment with a feedback cycle.
|
|
1687
|
+
* @param condition - Path to a node whose DATA triggers feedback.
|
|
1688
|
+
* @param reentry - Path to a state node that receives the feedback value.
|
|
1689
|
+
* @param opts - Iteration bounds and metadata.
|
|
1690
|
+
* @returns The same graph (mutated with feedback nodes added).
|
|
1691
|
+
*
|
|
1692
|
+
* @category patterns
|
|
1693
|
+
*/
|
|
1694
|
+
declare function feedback(graph: Graph, condition: string, reentry: string, opts?: FeedbackOptions): Graph;
|
|
1695
|
+
/** A reactive constraint for {@link budgetGate}. */
|
|
1696
|
+
type BudgetConstraint<T = unknown> = {
|
|
1697
|
+
/** Constraint node whose value is checked. */
|
|
1698
|
+
node: Node<T>;
|
|
1699
|
+
/** Returns `true` when the constraint is satisfied (budget available). */
|
|
1700
|
+
check: (value: T) => boolean;
|
|
1701
|
+
};
|
|
1702
|
+
/** Options for {@link budgetGate}. */
|
|
1703
|
+
type BudgetGateOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1704
|
+
meta?: Record<string, unknown>;
|
|
1705
|
+
};
|
|
1706
|
+
/**
|
|
1707
|
+
* Pass-through that respects reactive constraint nodes.
|
|
1708
|
+
*
|
|
1709
|
+
* DATA flows through when all constraints are satisfied. When any constraint
|
|
1710
|
+
* is exceeded, PAUSE is sent upstream and DATA is buffered. When constraints
|
|
1711
|
+
* relax, RESUME is sent and buffered DATA flushes.
|
|
1712
|
+
*
|
|
1713
|
+
* @param source - Input node.
|
|
1714
|
+
* @param constraints - Reactive constraint checks.
|
|
1715
|
+
* @param opts - Optional node options.
|
|
1716
|
+
* @returns Gated node.
|
|
1717
|
+
*
|
|
1718
|
+
* @category patterns
|
|
1719
|
+
*/
|
|
1720
|
+
declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
|
|
1721
|
+
/** A scored item with full breakdown. */
|
|
1722
|
+
type ScoredItem<T = unknown> = {
|
|
1723
|
+
/** Original value. */
|
|
1724
|
+
value: T;
|
|
1725
|
+
/** Final weighted score. */
|
|
1726
|
+
score: number;
|
|
1727
|
+
/** Per-signal breakdown: signal index → weighted contribution. */
|
|
1728
|
+
breakdown: number[];
|
|
1729
|
+
};
|
|
1730
|
+
/** Options for {@link scorer}. */
|
|
1731
|
+
type ScorerOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1732
|
+
meta?: Record<string, unknown>;
|
|
1733
|
+
/** Custom scoring function per signal. Default: identity (signal value IS the score). */
|
|
1734
|
+
scoreFns?: ReadonlyArray<(value: unknown) => number>;
|
|
1735
|
+
};
|
|
1736
|
+
/**
|
|
1737
|
+
* Reactive multi-signal scoring with live weights.
|
|
1738
|
+
*
|
|
1739
|
+
* Each source emits items to score. Weights are reactive state nodes that
|
|
1740
|
+
* LLM or human can adjust live. Output is sorted scored items with full
|
|
1741
|
+
* breakdown.
|
|
1742
|
+
*
|
|
1743
|
+
* @param sources - Signal nodes (each emits a numeric score dimension).
|
|
1744
|
+
* @param weights - Reactive weight nodes (one per source).
|
|
1745
|
+
* @param opts - Optional node/meta options.
|
|
1746
|
+
* @returns Node emitting scored output.
|
|
1747
|
+
*
|
|
1748
|
+
* @category patterns
|
|
1749
|
+
*/
|
|
1750
|
+
declare function scorer(sources: ReadonlyArray<Node<number>>, weights: ReadonlyArray<Node<number>>, opts?: ScorerOptions): Node<ScoredItem<number[]>>;
|
|
1751
|
+
|
|
1752
|
+
type reduction_BudgetConstraint<T = unknown> = BudgetConstraint<T>;
|
|
1753
|
+
type reduction_BudgetGateOptions = BudgetGateOptions;
|
|
1754
|
+
type reduction_FeedbackOptions = FeedbackOptions;
|
|
1755
|
+
type reduction_FunnelOptions = FunnelOptions;
|
|
1756
|
+
type reduction_FunnelStage = FunnelStage;
|
|
1757
|
+
type reduction_ScoredItem<T = unknown> = ScoredItem<T>;
|
|
1758
|
+
type reduction_ScorerOptions = ScorerOptions;
|
|
1759
|
+
type reduction_StepRef = StepRef;
|
|
1760
|
+
type reduction_StratifyOptions = StratifyOptions;
|
|
1761
|
+
type reduction_StratifyRule<T> = StratifyRule<T>;
|
|
1762
|
+
declare const reduction_budgetGate: typeof budgetGate;
|
|
1763
|
+
declare const reduction_feedback: typeof feedback;
|
|
1764
|
+
declare const reduction_funnel: typeof funnel;
|
|
1765
|
+
declare const reduction_scorer: typeof scorer;
|
|
1766
|
+
declare const reduction_stratify: typeof stratify;
|
|
1767
|
+
declare namespace reduction {
|
|
1768
|
+
export { type reduction_BudgetConstraint as BudgetConstraint, type reduction_BudgetGateOptions as BudgetGateOptions, type reduction_FeedbackOptions as FeedbackOptions, type reduction_FunnelOptions as FunnelOptions, type reduction_FunnelStage as FunnelStage, type reduction_ScoredItem as ScoredItem, type reduction_ScorerOptions as ScorerOptions, type reduction_StepRef as StepRef, type reduction_StratifyOptions as StratifyOptions, type reduction_StratifyRule as StratifyRule, reduction_budgetGate as budgetGate, reduction_feedback as feedback, reduction_funnel as funnel, reduction_scorer as scorer, reduction_stratify as stratify };
|
|
1595
1769
|
}
|
|
1596
1770
|
|
|
1597
1771
|
/**
|
|
@@ -1603,8 +1777,9 @@ declare const index_cqrs: typeof cqrs;
|
|
|
1603
1777
|
declare const index_memory: typeof memory;
|
|
1604
1778
|
declare const index_messaging: typeof messaging;
|
|
1605
1779
|
declare const index_orchestration: typeof orchestration;
|
|
1780
|
+
declare const index_reduction: typeof reduction;
|
|
1606
1781
|
declare namespace index {
|
|
1607
|
-
export { index_ai as ai, index_cqrs as cqrs, demoShell$1 as demoShell, index$b as layout, index_memory as memory, index_messaging as messaging, index_orchestration as orchestration };
|
|
1782
|
+
export { index_ai as ai, index_cqrs as cqrs, demoShell$1 as demoShell, index$b as layout, index_memory as memory, index_messaging as messaging, index_orchestration as orchestration, index_reduction as reduction };
|
|
1608
1783
|
}
|
|
1609
1784
|
|
|
1610
1785
|
/**
|
|
@@ -1612,4 +1787,4 @@ declare namespace index {
|
|
|
1612
1787
|
*/
|
|
1613
1788
|
declare const version = "0.0.0";
|
|
1614
1789
|
|
|
1615
|
-
export { Actor, AutoCheckpointAdapter, DistillBundle, Extraction, Graph, GraphAutoCheckpointHandle, GraphAutoCheckpointOptions, GraphOptions, Node, NodeActions, NodeFn, NodeInput, NodeOptions, ReactiveListSnapshot, ReactiveLogSnapshot, ReactiveMapSnapshot, ai, index$1 as compat, cqrs, demoShell$1 as demoShell, index$9 as jotai, index$b as layout, memory, messaging, index$8 as nanostores, index$a as nestjs, orchestration, index as patterns, index$7 as react, index$6 as signals, index$5 as solid, index$4 as svelte, version, index$3 as vue, index$2 as zustand };
|
|
1790
|
+
export { Actor, AutoCheckpointAdapter, DistillBundle, Extraction, Graph, GraphAutoCheckpointHandle, GraphAutoCheckpointOptions, GraphOptions, Node, NodeActions, NodeFn, NodeInput, NodeOptions, ReactiveListSnapshot, ReactiveLogSnapshot, ReactiveMapSnapshot, ai, index$1 as compat, cqrs, demoShell$1 as demoShell, index$9 as jotai, index$b as layout, memory, messaging, index$8 as nanostores, index$a as nestjs, orchestration, index as patterns, index$7 as react, reduction, index$6 as signals, index$5 as solid, index$4 as svelte, version, index$3 as vue, index$2 as zustand };
|
package/dist/index.d.ts
CHANGED
|
@@ -1490,13 +1490,13 @@ declare namespace messaging {
|
|
|
1490
1490
|
* Phase 2 operator names (for example `gate`, `forEach`).
|
|
1491
1491
|
*/
|
|
1492
1492
|
|
|
1493
|
-
type StepRef = string | Node<unknown>;
|
|
1493
|
+
type StepRef$1 = string | Node<unknown>;
|
|
1494
1494
|
type OrchestrationMeta = {
|
|
1495
1495
|
orchestration?: true;
|
|
1496
1496
|
orchestration_type?: string;
|
|
1497
1497
|
};
|
|
1498
1498
|
type OrchestrationStepOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1499
|
-
deps?: ReadonlyArray<StepRef>;
|
|
1499
|
+
deps?: ReadonlyArray<StepRef$1>;
|
|
1500
1500
|
meta?: Record<string, unknown> & OrchestrationMeta;
|
|
1501
1501
|
};
|
|
1502
1502
|
type BranchResult<T> = {
|
|
@@ -1510,7 +1510,7 @@ type SensorControls<T> = {
|
|
|
1510
1510
|
complete(): void;
|
|
1511
1511
|
};
|
|
1512
1512
|
type LoopOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
1513
|
-
iterations?: number | StepRef;
|
|
1513
|
+
iterations?: number | StepRef$1;
|
|
1514
1514
|
};
|
|
1515
1515
|
type WaitOptions = Omit<OrchestrationStepOptions, "deps">;
|
|
1516
1516
|
type SubPipelineBuilder = (sub: Graph) => void;
|
|
@@ -1525,32 +1525,32 @@ declare function task<T>(graph: Graph, name: string, run: NodeFn<T>, opts?: Orch
|
|
|
1525
1525
|
/**
|
|
1526
1526
|
* Emits tagged branch outcomes (`then` / `else`) for each source value.
|
|
1527
1527
|
*/
|
|
1528
|
-
declare function branch<T>(graph: Graph, name: string, source: StepRef, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
1528
|
+
declare function branch<T>(graph: Graph, name: string, source: StepRef$1, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
1529
1529
|
/**
|
|
1530
1530
|
* Forwards source values only while `control` is truthy.
|
|
1531
1531
|
*/
|
|
1532
|
-
declare function gate<T>(graph: Graph, name: string, source: StepRef, control: StepRef, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1532
|
+
declare function gate<T>(graph: Graph, name: string, source: StepRef$1, control: StepRef$1, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1533
1533
|
type ApprovalOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
1534
1534
|
isApproved?: (value: unknown) => boolean;
|
|
1535
1535
|
};
|
|
1536
1536
|
/**
|
|
1537
1537
|
* Human/LLM approval gate over a source value.
|
|
1538
1538
|
*/
|
|
1539
|
-
declare function approval<T>(graph: Graph, name: string, source: StepRef, approver: StepRef, opts?: ApprovalOptions): Node<T>;
|
|
1539
|
+
declare function approval<T>(graph: Graph, name: string, source: StepRef$1, approver: StepRef$1, opts?: ApprovalOptions): Node<T>;
|
|
1540
1540
|
/**
|
|
1541
1541
|
* Registers a workflow side-effect step. The step remains graph-observable and forwards messages.
|
|
1542
1542
|
*/
|
|
1543
|
-
declare function forEach<T>(graph: Graph, name: string, source: StepRef, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1543
|
+
declare function forEach<T>(graph: Graph, name: string, source: StepRef$1, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1544
1544
|
/**
|
|
1545
1545
|
* Registers a join step that emits a tuple of latest dependency values.
|
|
1546
1546
|
*/
|
|
1547
1547
|
declare function join<T extends readonly unknown[]>(graph: Graph, name: string, deps: {
|
|
1548
|
-
[K in keyof T]: StepRef;
|
|
1548
|
+
[K in keyof T]: StepRef$1;
|
|
1549
1549
|
}, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1550
1550
|
/**
|
|
1551
1551
|
* Registers a loop step that applies `iterate` to each source value N times.
|
|
1552
1552
|
*/
|
|
1553
|
-
declare function loop<T>(graph: Graph, name: string, source: StepRef, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
1553
|
+
declare function loop<T>(graph: Graph, name: string, source: StepRef$1, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
1554
1554
|
/**
|
|
1555
1555
|
* Mounts and returns a child workflow graph.
|
|
1556
1556
|
*/
|
|
@@ -1564,18 +1564,17 @@ declare function sensor<T>(graph: Graph, name: string, initial?: T, opts?: Omit<
|
|
|
1564
1564
|
/**
|
|
1565
1565
|
* Registers a delayed-forwarding step (value-level wait).
|
|
1566
1566
|
*/
|
|
1567
|
-
declare function wait<T>(graph: Graph, name: string, source: StepRef, ms: number, opts?: WaitOptions): Node<T>;
|
|
1567
|
+
declare function wait<T>(graph: Graph, name: string, source: StepRef$1, ms: number, opts?: WaitOptions): Node<T>;
|
|
1568
1568
|
/**
|
|
1569
1569
|
* Registers an error-recovery step for a source.
|
|
1570
1570
|
*/
|
|
1571
|
-
declare function onFailure<T>(graph: Graph, name: string, source: StepRef, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1571
|
+
declare function onFailure<T>(graph: Graph, name: string, source: StepRef$1, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1572
1572
|
|
|
1573
1573
|
type orchestration_ApprovalOptions = ApprovalOptions;
|
|
1574
1574
|
type orchestration_BranchResult<T> = BranchResult<T>;
|
|
1575
1575
|
type orchestration_LoopOptions = LoopOptions;
|
|
1576
1576
|
type orchestration_OrchestrationStepOptions = OrchestrationStepOptions;
|
|
1577
1577
|
type orchestration_SensorControls<T> = SensorControls<T>;
|
|
1578
|
-
type orchestration_StepRef = StepRef;
|
|
1579
1578
|
type orchestration_SubPipelineBuilder = SubPipelineBuilder;
|
|
1580
1579
|
type orchestration_WaitOptions = WaitOptions;
|
|
1581
1580
|
declare const orchestration_approval: typeof approval;
|
|
@@ -1591,7 +1590,182 @@ declare const orchestration_subPipeline: typeof subPipeline;
|
|
|
1591
1590
|
declare const orchestration_task: typeof task;
|
|
1592
1591
|
declare const orchestration_wait: typeof wait;
|
|
1593
1592
|
declare namespace orchestration {
|
|
1594
|
-
export { type orchestration_ApprovalOptions as ApprovalOptions, type orchestration_BranchResult as BranchResult, type orchestration_LoopOptions as LoopOptions, type orchestration_OrchestrationStepOptions as OrchestrationStepOptions, type orchestration_SensorControls as SensorControls, type
|
|
1593
|
+
export { type orchestration_ApprovalOptions as ApprovalOptions, type orchestration_BranchResult as BranchResult, type orchestration_LoopOptions as LoopOptions, type orchestration_OrchestrationStepOptions as OrchestrationStepOptions, type orchestration_SensorControls as SensorControls, type StepRef$1 as StepRef, type orchestration_SubPipelineBuilder as SubPipelineBuilder, type orchestration_WaitOptions as WaitOptions, orchestration_approval as approval, orchestration_branch as branch, orchestration_forEach as forEach, orchestration_gate as gate, orchestration_join as join, orchestration_loop as loop, orchestration_onFailure as onFailure, orchestration_pipeline as pipeline, orchestration_sensor as sensor, orchestration_subPipeline as subPipeline, orchestration_task as task, orchestration_wait as wait };
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Reduction primitives (roadmap §8.1).
|
|
1598
|
+
*
|
|
1599
|
+
* Composable building blocks for taking heterogeneous massive inputs and producing
|
|
1600
|
+
* prioritized, auditable, human-actionable output. Each primitive is either a Graph
|
|
1601
|
+
* factory or a Node factory, built on top of core + extra primitives.
|
|
1602
|
+
*
|
|
1603
|
+
* @module
|
|
1604
|
+
*/
|
|
1605
|
+
|
|
1606
|
+
type StepRef = string | Node<unknown>;
|
|
1607
|
+
/** A single routing rule for {@link stratify}. */
|
|
1608
|
+
type StratifyRule<T> = {
|
|
1609
|
+
/** Branch name (used as node name under `branch/<name>`). */
|
|
1610
|
+
name: string;
|
|
1611
|
+
/** Classifier: returns `true` if the value belongs to this branch. */
|
|
1612
|
+
classify: (value: T) => boolean;
|
|
1613
|
+
/** Optional operator chain applied to the branch after classification. */
|
|
1614
|
+
ops?: (n: Node<T>) => Node;
|
|
1615
|
+
};
|
|
1616
|
+
/** Options for {@link stratify}. */
|
|
1617
|
+
type StratifyOptions = GraphOptions & {
|
|
1618
|
+
meta?: Record<string, unknown>;
|
|
1619
|
+
};
|
|
1620
|
+
/**
|
|
1621
|
+
* Route input to different reduction branches based on classifier functions.
|
|
1622
|
+
*
|
|
1623
|
+
* Each branch gets an independent operator chain. Rules are reactive — update
|
|
1624
|
+
* the `"rules"` state node to rewrite classification at runtime. Rule updates
|
|
1625
|
+
* affect **future items only** (streaming classification, not retroactive).
|
|
1626
|
+
*
|
|
1627
|
+
* Branch nodes are structural — created at construction time and persist for
|
|
1628
|
+
* the graph's lifetime. If a rule name is removed from the rules array, the
|
|
1629
|
+
* corresponding branch silently drops items (classifier not found). To tear
|
|
1630
|
+
* down a dead branch, call `graph.remove("branch/<name>")`.
|
|
1631
|
+
*
|
|
1632
|
+
* @param name - Graph name.
|
|
1633
|
+
* @param source - Input node (registered externally or will be added as `"source"`).
|
|
1634
|
+
* @param rules - Initial routing rules.
|
|
1635
|
+
* @param opts - Optional graph/meta options.
|
|
1636
|
+
* @returns Graph with `"source"`, `"rules"`, and `"branch/<name>"` nodes.
|
|
1637
|
+
*
|
|
1638
|
+
* @category patterns
|
|
1639
|
+
*/
|
|
1640
|
+
declare function stratify<T>(name: string, source: Node<T>, rules: ReadonlyArray<StratifyRule<T>>, opts?: StratifyOptions): Graph;
|
|
1641
|
+
/** A named stage for {@link funnel}. */
|
|
1642
|
+
type FunnelStage = {
|
|
1643
|
+
/** Stage name (mounted as subgraph). */
|
|
1644
|
+
name: string;
|
|
1645
|
+
/** Builder: receives a sub-graph, should add an `"input"` and `"output"` node. */
|
|
1646
|
+
build: (sub: Graph) => void;
|
|
1647
|
+
};
|
|
1648
|
+
/** Options for {@link funnel}. */
|
|
1649
|
+
type FunnelOptions = GraphOptions & {
|
|
1650
|
+
meta?: Record<string, unknown>;
|
|
1651
|
+
};
|
|
1652
|
+
/**
|
|
1653
|
+
* Multi-source merge with sequential reduction stages.
|
|
1654
|
+
*
|
|
1655
|
+
* Sources are merged into a single stream. Each stage is a named subgraph
|
|
1656
|
+
* (mounted via `graph.mount()`). Stages connect linearly:
|
|
1657
|
+
* `merged → stage[0].input → stage[0].output → stage[1].input → ...`
|
|
1658
|
+
*
|
|
1659
|
+
* @param name - Graph name.
|
|
1660
|
+
* @param sources - Input nodes to merge.
|
|
1661
|
+
* @param stages - Sequential reduction stages.
|
|
1662
|
+
* @param opts - Optional graph/meta options.
|
|
1663
|
+
* @returns Graph with `"merged"` and mounted stage subgraphs.
|
|
1664
|
+
*
|
|
1665
|
+
* @category patterns
|
|
1666
|
+
*/
|
|
1667
|
+
declare function funnel<T>(name: string, sources: ReadonlyArray<Node<T>>, stages: ReadonlyArray<FunnelStage>, opts?: FunnelOptions): Graph;
|
|
1668
|
+
/** Options for {@link feedback}. */
|
|
1669
|
+
type FeedbackOptions = {
|
|
1670
|
+
/** Maximum feedback iterations before stopping (default: 10). */
|
|
1671
|
+
maxIterations?: number;
|
|
1672
|
+
/** Optional budget gate node path for cost-bounded iteration. */
|
|
1673
|
+
budgetNode?: StepRef;
|
|
1674
|
+
meta?: Record<string, unknown>;
|
|
1675
|
+
};
|
|
1676
|
+
/**
|
|
1677
|
+
* Introduce a bounded reactive cycle into an existing graph.
|
|
1678
|
+
*
|
|
1679
|
+
* When `condition` emits a non-null DATA value, the feedback effect routes it
|
|
1680
|
+
* back to the `reentry` state node — creating a cycle. Bounded by
|
|
1681
|
+
* `maxIterations` (default 10). The counter node (`__feedback_<condition>`)
|
|
1682
|
+
* is the source of truth — reset it to 0 to allow more iterations.
|
|
1683
|
+
*
|
|
1684
|
+
* To remove the feedback cycle, call `graph.remove("__feedback_<condition>")`.
|
|
1685
|
+
*
|
|
1686
|
+
* @param graph - Existing graph to augment with a feedback cycle.
|
|
1687
|
+
* @param condition - Path to a node whose DATA triggers feedback.
|
|
1688
|
+
* @param reentry - Path to a state node that receives the feedback value.
|
|
1689
|
+
* @param opts - Iteration bounds and metadata.
|
|
1690
|
+
* @returns The same graph (mutated with feedback nodes added).
|
|
1691
|
+
*
|
|
1692
|
+
* @category patterns
|
|
1693
|
+
*/
|
|
1694
|
+
declare function feedback(graph: Graph, condition: string, reentry: string, opts?: FeedbackOptions): Graph;
|
|
1695
|
+
/** A reactive constraint for {@link budgetGate}. */
|
|
1696
|
+
type BudgetConstraint<T = unknown> = {
|
|
1697
|
+
/** Constraint node whose value is checked. */
|
|
1698
|
+
node: Node<T>;
|
|
1699
|
+
/** Returns `true` when the constraint is satisfied (budget available). */
|
|
1700
|
+
check: (value: T) => boolean;
|
|
1701
|
+
};
|
|
1702
|
+
/** Options for {@link budgetGate}. */
|
|
1703
|
+
type BudgetGateOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1704
|
+
meta?: Record<string, unknown>;
|
|
1705
|
+
};
|
|
1706
|
+
/**
|
|
1707
|
+
* Pass-through that respects reactive constraint nodes.
|
|
1708
|
+
*
|
|
1709
|
+
* DATA flows through when all constraints are satisfied. When any constraint
|
|
1710
|
+
* is exceeded, PAUSE is sent upstream and DATA is buffered. When constraints
|
|
1711
|
+
* relax, RESUME is sent and buffered DATA flushes.
|
|
1712
|
+
*
|
|
1713
|
+
* @param source - Input node.
|
|
1714
|
+
* @param constraints - Reactive constraint checks.
|
|
1715
|
+
* @param opts - Optional node options.
|
|
1716
|
+
* @returns Gated node.
|
|
1717
|
+
*
|
|
1718
|
+
* @category patterns
|
|
1719
|
+
*/
|
|
1720
|
+
declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
|
|
1721
|
+
/** A scored item with full breakdown. */
|
|
1722
|
+
type ScoredItem<T = unknown> = {
|
|
1723
|
+
/** Original value. */
|
|
1724
|
+
value: T;
|
|
1725
|
+
/** Final weighted score. */
|
|
1726
|
+
score: number;
|
|
1727
|
+
/** Per-signal breakdown: signal index → weighted contribution. */
|
|
1728
|
+
breakdown: number[];
|
|
1729
|
+
};
|
|
1730
|
+
/** Options for {@link scorer}. */
|
|
1731
|
+
type ScorerOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1732
|
+
meta?: Record<string, unknown>;
|
|
1733
|
+
/** Custom scoring function per signal. Default: identity (signal value IS the score). */
|
|
1734
|
+
scoreFns?: ReadonlyArray<(value: unknown) => number>;
|
|
1735
|
+
};
|
|
1736
|
+
/**
|
|
1737
|
+
* Reactive multi-signal scoring with live weights.
|
|
1738
|
+
*
|
|
1739
|
+
* Each source emits items to score. Weights are reactive state nodes that
|
|
1740
|
+
* LLM or human can adjust live. Output is sorted scored items with full
|
|
1741
|
+
* breakdown.
|
|
1742
|
+
*
|
|
1743
|
+
* @param sources - Signal nodes (each emits a numeric score dimension).
|
|
1744
|
+
* @param weights - Reactive weight nodes (one per source).
|
|
1745
|
+
* @param opts - Optional node/meta options.
|
|
1746
|
+
* @returns Node emitting scored output.
|
|
1747
|
+
*
|
|
1748
|
+
* @category patterns
|
|
1749
|
+
*/
|
|
1750
|
+
declare function scorer(sources: ReadonlyArray<Node<number>>, weights: ReadonlyArray<Node<number>>, opts?: ScorerOptions): Node<ScoredItem<number[]>>;
|
|
1751
|
+
|
|
1752
|
+
type reduction_BudgetConstraint<T = unknown> = BudgetConstraint<T>;
|
|
1753
|
+
type reduction_BudgetGateOptions = BudgetGateOptions;
|
|
1754
|
+
type reduction_FeedbackOptions = FeedbackOptions;
|
|
1755
|
+
type reduction_FunnelOptions = FunnelOptions;
|
|
1756
|
+
type reduction_FunnelStage = FunnelStage;
|
|
1757
|
+
type reduction_ScoredItem<T = unknown> = ScoredItem<T>;
|
|
1758
|
+
type reduction_ScorerOptions = ScorerOptions;
|
|
1759
|
+
type reduction_StepRef = StepRef;
|
|
1760
|
+
type reduction_StratifyOptions = StratifyOptions;
|
|
1761
|
+
type reduction_StratifyRule<T> = StratifyRule<T>;
|
|
1762
|
+
declare const reduction_budgetGate: typeof budgetGate;
|
|
1763
|
+
declare const reduction_feedback: typeof feedback;
|
|
1764
|
+
declare const reduction_funnel: typeof funnel;
|
|
1765
|
+
declare const reduction_scorer: typeof scorer;
|
|
1766
|
+
declare const reduction_stratify: typeof stratify;
|
|
1767
|
+
declare namespace reduction {
|
|
1768
|
+
export { type reduction_BudgetConstraint as BudgetConstraint, type reduction_BudgetGateOptions as BudgetGateOptions, type reduction_FeedbackOptions as FeedbackOptions, type reduction_FunnelOptions as FunnelOptions, type reduction_FunnelStage as FunnelStage, type reduction_ScoredItem as ScoredItem, type reduction_ScorerOptions as ScorerOptions, type reduction_StepRef as StepRef, type reduction_StratifyOptions as StratifyOptions, type reduction_StratifyRule as StratifyRule, reduction_budgetGate as budgetGate, reduction_feedback as feedback, reduction_funnel as funnel, reduction_scorer as scorer, reduction_stratify as stratify };
|
|
1595
1769
|
}
|
|
1596
1770
|
|
|
1597
1771
|
/**
|
|
@@ -1603,8 +1777,9 @@ declare const index_cqrs: typeof cqrs;
|
|
|
1603
1777
|
declare const index_memory: typeof memory;
|
|
1604
1778
|
declare const index_messaging: typeof messaging;
|
|
1605
1779
|
declare const index_orchestration: typeof orchestration;
|
|
1780
|
+
declare const index_reduction: typeof reduction;
|
|
1606
1781
|
declare namespace index {
|
|
1607
|
-
export { index_ai as ai, index_cqrs as cqrs, demoShell$1 as demoShell, index$b as layout, index_memory as memory, index_messaging as messaging, index_orchestration as orchestration };
|
|
1782
|
+
export { index_ai as ai, index_cqrs as cqrs, demoShell$1 as demoShell, index$b as layout, index_memory as memory, index_messaging as messaging, index_orchestration as orchestration, index_reduction as reduction };
|
|
1608
1783
|
}
|
|
1609
1784
|
|
|
1610
1785
|
/**
|
|
@@ -1612,4 +1787,4 @@ declare namespace index {
|
|
|
1612
1787
|
*/
|
|
1613
1788
|
declare const version = "0.0.0";
|
|
1614
1789
|
|
|
1615
|
-
export { Actor, AutoCheckpointAdapter, DistillBundle, Extraction, Graph, GraphAutoCheckpointHandle, GraphAutoCheckpointOptions, GraphOptions, Node, NodeActions, NodeFn, NodeInput, NodeOptions, ReactiveListSnapshot, ReactiveLogSnapshot, ReactiveMapSnapshot, ai, index$1 as compat, cqrs, demoShell$1 as demoShell, index$9 as jotai, index$b as layout, memory, messaging, index$8 as nanostores, index$a as nestjs, orchestration, index as patterns, index$7 as react, index$6 as signals, index$5 as solid, index$4 as svelte, version, index$3 as vue, index$2 as zustand };
|
|
1790
|
+
export { Actor, AutoCheckpointAdapter, DistillBundle, Extraction, Graph, GraphAutoCheckpointHandle, GraphAutoCheckpointOptions, GraphOptions, Node, NodeActions, NodeFn, NodeInput, NodeOptions, ReactiveListSnapshot, ReactiveLogSnapshot, ReactiveMapSnapshot, ai, index$1 as compat, cqrs, demoShell$1 as demoShell, index$9 as jotai, index$b as layout, memory, messaging, index$8 as nanostores, index$a as nestjs, orchestration, index as patterns, index$7 as react, reduction, index$6 as signals, index$5 as solid, index$4 as svelte, version, index$3 as vue, index$2 as zustand };
|