@graphrefly/graphrefly 0.8.0 → 0.10.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 +1135 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +405 -15
- package/dist/index.d.ts +405 -15
- package/dist/index.js +1141 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1329,6 +1329,220 @@ declare namespace demoShell$1 {
|
|
|
1329
1329
|
export { type demoShell$1_DemoShellHandle as DemoShellHandle, type demoShell$1_DemoShellOptions as DemoShellOptions, type demoShell$1_FullscreenPane as FullscreenPane, type demoShell$1_GraphLabelSize as GraphLabelSize, type demoShell$1_HighlightCallbacks as HighlightCallbacks, type demoShell$1_HoverPaneType as HoverPaneType, type demoShell$1_HoverTarget as HoverTarget, type demoShell$1_NodeRegistry as NodeRegistry, demoShell$1_demoShell as demoShell };
|
|
1330
1330
|
}
|
|
1331
1331
|
|
|
1332
|
+
/**
|
|
1333
|
+
* LLM graph composition (roadmap §8.3).
|
|
1334
|
+
*
|
|
1335
|
+
* Declarative GraphSpec schema + compiler/decompiler for graph topology.
|
|
1336
|
+
* The LLM designs graphs as JSON; compileSpec instantiates them; decompileGraph
|
|
1337
|
+
* extracts them back. Templates support reusable subgraph patterns. Feedback
|
|
1338
|
+
* edges express bounded cycles via §8.1 feedback().
|
|
1339
|
+
*
|
|
1340
|
+
* @module
|
|
1341
|
+
*/
|
|
1342
|
+
|
|
1343
|
+
/** A single node declaration in a GraphSpec. */
|
|
1344
|
+
type GraphSpecNode = {
|
|
1345
|
+
/** Node kind: state, producer, derived, effect, operator. */
|
|
1346
|
+
type: "state" | "producer" | "derived" | "effect" | "operator";
|
|
1347
|
+
/** Dependency node names (for derived/effect/operator). */
|
|
1348
|
+
deps?: string[];
|
|
1349
|
+
/** Named function from the catalog (for derived/effect/operator/producer). */
|
|
1350
|
+
fn?: string;
|
|
1351
|
+
/** Named source from the catalog (for producer). */
|
|
1352
|
+
source?: string;
|
|
1353
|
+
/** Freeform config passed to the catalog fn/source factory. */
|
|
1354
|
+
config?: Record<string, unknown>;
|
|
1355
|
+
/** Initial value (for state nodes). */
|
|
1356
|
+
initial?: unknown;
|
|
1357
|
+
/** Human/LLM-readable metadata. */
|
|
1358
|
+
meta?: Record<string, unknown>;
|
|
1359
|
+
};
|
|
1360
|
+
/** Template instantiation node — expanded at compile time. */
|
|
1361
|
+
type GraphSpecTemplateRef = {
|
|
1362
|
+
type: "template";
|
|
1363
|
+
/** Name of the template to instantiate. */
|
|
1364
|
+
template: string;
|
|
1365
|
+
/** Parameter bindings: template param name → node name. */
|
|
1366
|
+
bind: Record<string, string>;
|
|
1367
|
+
};
|
|
1368
|
+
/** A reusable subgraph pattern with parameter substitution. */
|
|
1369
|
+
type GraphSpecTemplate = {
|
|
1370
|
+
/** Parameter names (prefixed with $ in node refs). */
|
|
1371
|
+
params: string[];
|
|
1372
|
+
/** Node declarations within the template. */
|
|
1373
|
+
nodes: Record<string, GraphSpecNode>;
|
|
1374
|
+
/** Which node's output is the template's output. */
|
|
1375
|
+
output: string;
|
|
1376
|
+
};
|
|
1377
|
+
/** A feedback edge: bounded cycle from condition to reentry. */
|
|
1378
|
+
type GraphSpecFeedbackEdge = {
|
|
1379
|
+
/** Node whose DATA triggers the feedback. */
|
|
1380
|
+
from: string;
|
|
1381
|
+
/** State node that receives the feedback value. */
|
|
1382
|
+
to: string;
|
|
1383
|
+
/** Max iterations before stopping (default: 10). */
|
|
1384
|
+
maxIterations?: number;
|
|
1385
|
+
};
|
|
1386
|
+
/** Declarative graph topology for LLM composition (§8.3). */
|
|
1387
|
+
type GraphSpec = {
|
|
1388
|
+
/** Graph name. */
|
|
1389
|
+
name: string;
|
|
1390
|
+
/** Node declarations (keyed by node name). */
|
|
1391
|
+
nodes: Record<string, GraphSpecNode | GraphSpecTemplateRef>;
|
|
1392
|
+
/** Reusable subgraph templates. */
|
|
1393
|
+
templates?: Record<string, GraphSpecTemplate>;
|
|
1394
|
+
/** Feedback edges (bounded cycles). */
|
|
1395
|
+
feedback?: GraphSpecFeedbackEdge[];
|
|
1396
|
+
};
|
|
1397
|
+
/**
|
|
1398
|
+
* Factory for creating a derived/effect/operator node from catalog.
|
|
1399
|
+
* Receives resolved dep nodes and the config from the spec.
|
|
1400
|
+
*/
|
|
1401
|
+
type FnFactory = (deps: Node<unknown>[], config: Record<string, unknown>) => Node<unknown>;
|
|
1402
|
+
/**
|
|
1403
|
+
* Factory for creating a producer node from catalog.
|
|
1404
|
+
* Receives the config from the spec.
|
|
1405
|
+
*/
|
|
1406
|
+
type SourceFactory = (config: Record<string, unknown>) => Node<unknown>;
|
|
1407
|
+
/** Fn/source lookup table passed to compileSpec. */
|
|
1408
|
+
type GraphSpecCatalog = {
|
|
1409
|
+
fns?: Record<string, FnFactory>;
|
|
1410
|
+
sources?: Record<string, SourceFactory>;
|
|
1411
|
+
};
|
|
1412
|
+
/** Validation result from {@link validateSpec}. */
|
|
1413
|
+
type GraphSpecValidation = {
|
|
1414
|
+
valid: boolean;
|
|
1415
|
+
errors: string[];
|
|
1416
|
+
};
|
|
1417
|
+
/**
|
|
1418
|
+
* Validate a GraphSpec JSON object.
|
|
1419
|
+
*
|
|
1420
|
+
* Checks structural validity: required fields, node types, dep references,
|
|
1421
|
+
* template references, feedback edge targets, self-cycles, and bind completeness.
|
|
1422
|
+
*/
|
|
1423
|
+
declare function validateSpec(spec: unknown): GraphSpecValidation;
|
|
1424
|
+
/** Options for {@link compileSpec}. */
|
|
1425
|
+
type CompileSpecOptions = {
|
|
1426
|
+
/** Fn/source catalog for resolving named factories. */
|
|
1427
|
+
catalog?: GraphSpecCatalog;
|
|
1428
|
+
};
|
|
1429
|
+
/**
|
|
1430
|
+
* Instantiate a Graph from a GraphSpec.
|
|
1431
|
+
*
|
|
1432
|
+
* Handles template expansion (mounted subgraphs), feedback wiring via §8.1
|
|
1433
|
+
* feedback(), node factory lookup from the catalog, and topology validation.
|
|
1434
|
+
*
|
|
1435
|
+
* @param spec - Declarative graph topology.
|
|
1436
|
+
* @param opts - Catalog and compile options.
|
|
1437
|
+
* @returns A running Graph.
|
|
1438
|
+
* @throws On validation failure, missing catalog entries, or unresolvable deps.
|
|
1439
|
+
*
|
|
1440
|
+
* @category patterns
|
|
1441
|
+
*/
|
|
1442
|
+
declare function compileSpec(spec: GraphSpec, opts?: CompileSpecOptions): Graph;
|
|
1443
|
+
/**
|
|
1444
|
+
* Extract a GraphSpec from a running graph.
|
|
1445
|
+
*
|
|
1446
|
+
* Uses `describe({ detail: "standard" })` as a starting point, then enriches:
|
|
1447
|
+
* - Feedback edges recovered from counter node meta (`feedbackFrom`/`feedbackTo`)
|
|
1448
|
+
* - Template refs recovered from output node meta (`_templateName`/`_templateBind`)
|
|
1449
|
+
* - Structural fingerprinting as fallback for 2+ identical mounted subgraphs
|
|
1450
|
+
*
|
|
1451
|
+
* @param graph - Running graph to decompile.
|
|
1452
|
+
* @returns A GraphSpec representation.
|
|
1453
|
+
*
|
|
1454
|
+
* @category patterns
|
|
1455
|
+
*/
|
|
1456
|
+
declare function decompileGraph(graph: Graph): GraphSpec;
|
|
1457
|
+
/** A single change in a spec diff. */
|
|
1458
|
+
type SpecDiffEntry = {
|
|
1459
|
+
type: "added" | "removed" | "changed";
|
|
1460
|
+
path: string;
|
|
1461
|
+
detail?: string;
|
|
1462
|
+
};
|
|
1463
|
+
/** Structural diff between two GraphSpecs. */
|
|
1464
|
+
type SpecDiffResult = {
|
|
1465
|
+
entries: SpecDiffEntry[];
|
|
1466
|
+
summary: string;
|
|
1467
|
+
};
|
|
1468
|
+
/**
|
|
1469
|
+
* Compute a structural diff between two GraphSpecs.
|
|
1470
|
+
*
|
|
1471
|
+
* Template-aware: reports "changed template definition" vs "changed
|
|
1472
|
+
* instantiation bindings." No runtime needed — pure JSON comparison.
|
|
1473
|
+
*
|
|
1474
|
+
* @param specA - The "before" spec.
|
|
1475
|
+
* @param specB - The "after" spec.
|
|
1476
|
+
* @returns Diff entries and a human-readable summary.
|
|
1477
|
+
*
|
|
1478
|
+
* @category patterns
|
|
1479
|
+
*/
|
|
1480
|
+
declare function specDiff(specA: GraphSpec, specB: GraphSpec): SpecDiffResult;
|
|
1481
|
+
/** Options for {@link llmCompose}. */
|
|
1482
|
+
type LLMComposeOptions = {
|
|
1483
|
+
model?: string;
|
|
1484
|
+
temperature?: number;
|
|
1485
|
+
maxTokens?: number;
|
|
1486
|
+
/** Extra instructions appended to the system prompt. */
|
|
1487
|
+
systemPromptExtra?: string;
|
|
1488
|
+
/** Available fn/source catalog names for the LLM to reference. */
|
|
1489
|
+
catalogDescription?: string;
|
|
1490
|
+
};
|
|
1491
|
+
/**
|
|
1492
|
+
* Ask an LLM to compose a GraphSpec from a natural-language problem description.
|
|
1493
|
+
*
|
|
1494
|
+
* The LLM generates a GraphSpec (with templates + feedback), validated before
|
|
1495
|
+
* returning. The spec is for human review before compilation via compileSpec().
|
|
1496
|
+
*
|
|
1497
|
+
* @param problem - Natural language problem description.
|
|
1498
|
+
* @param adapter - LLM adapter for the generation call.
|
|
1499
|
+
* @param opts - Model options and catalog description.
|
|
1500
|
+
* @returns A validated GraphSpec.
|
|
1501
|
+
* @throws On invalid LLM output or validation failure.
|
|
1502
|
+
*
|
|
1503
|
+
* @category patterns
|
|
1504
|
+
*/
|
|
1505
|
+
declare function llmCompose(problem: string, adapter: LLMAdapter, opts?: LLMComposeOptions): Promise<GraphSpec>;
|
|
1506
|
+
/** Options for {@link llmRefine}. */
|
|
1507
|
+
type LLMRefineOptions = LLMComposeOptions;
|
|
1508
|
+
/**
|
|
1509
|
+
* Ask an LLM to modify an existing GraphSpec based on feedback or changed requirements.
|
|
1510
|
+
*
|
|
1511
|
+
* @param currentSpec - The current GraphSpec to modify.
|
|
1512
|
+
* @param feedback - Natural language feedback or changed requirements.
|
|
1513
|
+
* @param adapter - LLM adapter for the generation call.
|
|
1514
|
+
* @param opts - Model options.
|
|
1515
|
+
* @returns A new GraphSpec incorporating the feedback.
|
|
1516
|
+
* @throws On invalid LLM output or validation failure.
|
|
1517
|
+
*
|
|
1518
|
+
* @category patterns
|
|
1519
|
+
*/
|
|
1520
|
+
declare function llmRefine(currentSpec: GraphSpec, feedback: string, adapter: LLMAdapter, opts?: LLMRefineOptions): Promise<GraphSpec>;
|
|
1521
|
+
|
|
1522
|
+
type graphspec_CompileSpecOptions = CompileSpecOptions;
|
|
1523
|
+
type graphspec_FnFactory = FnFactory;
|
|
1524
|
+
type graphspec_GraphSpec = GraphSpec;
|
|
1525
|
+
type graphspec_GraphSpecCatalog = GraphSpecCatalog;
|
|
1526
|
+
type graphspec_GraphSpecFeedbackEdge = GraphSpecFeedbackEdge;
|
|
1527
|
+
type graphspec_GraphSpecNode = GraphSpecNode;
|
|
1528
|
+
type graphspec_GraphSpecTemplate = GraphSpecTemplate;
|
|
1529
|
+
type graphspec_GraphSpecTemplateRef = GraphSpecTemplateRef;
|
|
1530
|
+
type graphspec_GraphSpecValidation = GraphSpecValidation;
|
|
1531
|
+
type graphspec_LLMComposeOptions = LLMComposeOptions;
|
|
1532
|
+
type graphspec_LLMRefineOptions = LLMRefineOptions;
|
|
1533
|
+
type graphspec_SourceFactory = SourceFactory;
|
|
1534
|
+
type graphspec_SpecDiffEntry = SpecDiffEntry;
|
|
1535
|
+
type graphspec_SpecDiffResult = SpecDiffResult;
|
|
1536
|
+
declare const graphspec_compileSpec: typeof compileSpec;
|
|
1537
|
+
declare const graphspec_decompileGraph: typeof decompileGraph;
|
|
1538
|
+
declare const graphspec_llmCompose: typeof llmCompose;
|
|
1539
|
+
declare const graphspec_llmRefine: typeof llmRefine;
|
|
1540
|
+
declare const graphspec_specDiff: typeof specDiff;
|
|
1541
|
+
declare const graphspec_validateSpec: typeof validateSpec;
|
|
1542
|
+
declare namespace graphspec {
|
|
1543
|
+
export { type graphspec_CompileSpecOptions as CompileSpecOptions, type graphspec_FnFactory as FnFactory, type graphspec_GraphSpec as GraphSpec, type graphspec_GraphSpecCatalog as GraphSpecCatalog, type graphspec_GraphSpecFeedbackEdge as GraphSpecFeedbackEdge, type graphspec_GraphSpecNode as GraphSpecNode, type graphspec_GraphSpecTemplate as GraphSpecTemplate, type graphspec_GraphSpecTemplateRef as GraphSpecTemplateRef, type graphspec_GraphSpecValidation as GraphSpecValidation, type graphspec_LLMComposeOptions as LLMComposeOptions, type graphspec_LLMRefineOptions as LLMRefineOptions, type graphspec_SourceFactory as SourceFactory, type graphspec_SpecDiffEntry as SpecDiffEntry, type graphspec_SpecDiffResult as SpecDiffResult, graphspec_compileSpec as compileSpec, graphspec_decompileGraph as decompileGraph, graphspec_llmCompose as llmCompose, graphspec_llmRefine as llmRefine, graphspec_specDiff as specDiff, graphspec_validateSpec as validateSpec };
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1332
1546
|
/**
|
|
1333
1547
|
* Messaging patterns (roadmap §4.2).
|
|
1334
1548
|
*
|
|
@@ -1490,13 +1704,13 @@ declare namespace messaging {
|
|
|
1490
1704
|
* Phase 2 operator names (for example `gate`, `forEach`).
|
|
1491
1705
|
*/
|
|
1492
1706
|
|
|
1493
|
-
type StepRef = string | Node<unknown>;
|
|
1707
|
+
type StepRef$1 = string | Node<unknown>;
|
|
1494
1708
|
type OrchestrationMeta = {
|
|
1495
1709
|
orchestration?: true;
|
|
1496
1710
|
orchestration_type?: string;
|
|
1497
1711
|
};
|
|
1498
1712
|
type OrchestrationStepOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1499
|
-
deps?: ReadonlyArray<StepRef>;
|
|
1713
|
+
deps?: ReadonlyArray<StepRef$1>;
|
|
1500
1714
|
meta?: Record<string, unknown> & OrchestrationMeta;
|
|
1501
1715
|
};
|
|
1502
1716
|
type BranchResult<T> = {
|
|
@@ -1510,7 +1724,7 @@ type SensorControls<T> = {
|
|
|
1510
1724
|
complete(): void;
|
|
1511
1725
|
};
|
|
1512
1726
|
type LoopOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
1513
|
-
iterations?: number | StepRef;
|
|
1727
|
+
iterations?: number | StepRef$1;
|
|
1514
1728
|
};
|
|
1515
1729
|
type WaitOptions = Omit<OrchestrationStepOptions, "deps">;
|
|
1516
1730
|
type SubPipelineBuilder = (sub: Graph) => void;
|
|
@@ -1525,32 +1739,32 @@ declare function task<T>(graph: Graph, name: string, run: NodeFn<T>, opts?: Orch
|
|
|
1525
1739
|
/**
|
|
1526
1740
|
* Emits tagged branch outcomes (`then` / `else`) for each source value.
|
|
1527
1741
|
*/
|
|
1528
|
-
declare function branch<T>(graph: Graph, name: string, source: StepRef, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
1742
|
+
declare function branch<T>(graph: Graph, name: string, source: StepRef$1, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
1529
1743
|
/**
|
|
1530
1744
|
* Forwards source values only while `control` is truthy.
|
|
1531
1745
|
*/
|
|
1532
|
-
declare function gate<T>(graph: Graph, name: string, source: StepRef, control: StepRef, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1746
|
+
declare function gate<T>(graph: Graph, name: string, source: StepRef$1, control: StepRef$1, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1533
1747
|
type ApprovalOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
1534
1748
|
isApproved?: (value: unknown) => boolean;
|
|
1535
1749
|
};
|
|
1536
1750
|
/**
|
|
1537
1751
|
* Human/LLM approval gate over a source value.
|
|
1538
1752
|
*/
|
|
1539
|
-
declare function approval<T>(graph: Graph, name: string, source: StepRef, approver: StepRef, opts?: ApprovalOptions): Node<T>;
|
|
1753
|
+
declare function approval<T>(graph: Graph, name: string, source: StepRef$1, approver: StepRef$1, opts?: ApprovalOptions): Node<T>;
|
|
1540
1754
|
/**
|
|
1541
1755
|
* Registers a workflow side-effect step. The step remains graph-observable and forwards messages.
|
|
1542
1756
|
*/
|
|
1543
|
-
declare function forEach<T>(graph: Graph, name: string, source: StepRef, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1757
|
+
declare function forEach<T>(graph: Graph, name: string, source: StepRef$1, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1544
1758
|
/**
|
|
1545
1759
|
* Registers a join step that emits a tuple of latest dependency values.
|
|
1546
1760
|
*/
|
|
1547
1761
|
declare function join<T extends readonly unknown[]>(graph: Graph, name: string, deps: {
|
|
1548
|
-
[K in keyof T]: StepRef;
|
|
1762
|
+
[K in keyof T]: StepRef$1;
|
|
1549
1763
|
}, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1550
1764
|
/**
|
|
1551
1765
|
* Registers a loop step that applies `iterate` to each source value N times.
|
|
1552
1766
|
*/
|
|
1553
|
-
declare function loop<T>(graph: Graph, name: string, source: StepRef, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
1767
|
+
declare function loop<T>(graph: Graph, name: string, source: StepRef$1, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
1554
1768
|
/**
|
|
1555
1769
|
* Mounts and returns a child workflow graph.
|
|
1556
1770
|
*/
|
|
@@ -1564,18 +1778,17 @@ declare function sensor<T>(graph: Graph, name: string, initial?: T, opts?: Omit<
|
|
|
1564
1778
|
/**
|
|
1565
1779
|
* Registers a delayed-forwarding step (value-level wait).
|
|
1566
1780
|
*/
|
|
1567
|
-
declare function wait<T>(graph: Graph, name: string, source: StepRef, ms: number, opts?: WaitOptions): Node<T>;
|
|
1781
|
+
declare function wait<T>(graph: Graph, name: string, source: StepRef$1, ms: number, opts?: WaitOptions): Node<T>;
|
|
1568
1782
|
/**
|
|
1569
1783
|
* Registers an error-recovery step for a source.
|
|
1570
1784
|
*/
|
|
1571
|
-
declare function onFailure<T>(graph: Graph, name: string, source: StepRef, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1785
|
+
declare function onFailure<T>(graph: Graph, name: string, source: StepRef$1, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
1572
1786
|
|
|
1573
1787
|
type orchestration_ApprovalOptions = ApprovalOptions;
|
|
1574
1788
|
type orchestration_BranchResult<T> = BranchResult<T>;
|
|
1575
1789
|
type orchestration_LoopOptions = LoopOptions;
|
|
1576
1790
|
type orchestration_OrchestrationStepOptions = OrchestrationStepOptions;
|
|
1577
1791
|
type orchestration_SensorControls<T> = SensorControls<T>;
|
|
1578
|
-
type orchestration_StepRef = StepRef;
|
|
1579
1792
|
type orchestration_SubPipelineBuilder = SubPipelineBuilder;
|
|
1580
1793
|
type orchestration_WaitOptions = WaitOptions;
|
|
1581
1794
|
declare const orchestration_approval: typeof approval;
|
|
@@ -1591,7 +1804,182 @@ declare const orchestration_subPipeline: typeof subPipeline;
|
|
|
1591
1804
|
declare const orchestration_task: typeof task;
|
|
1592
1805
|
declare const orchestration_wait: typeof wait;
|
|
1593
1806
|
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
|
|
1807
|
+
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 };
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
/**
|
|
1811
|
+
* Reduction primitives (roadmap §8.1).
|
|
1812
|
+
*
|
|
1813
|
+
* Composable building blocks for taking heterogeneous massive inputs and producing
|
|
1814
|
+
* prioritized, auditable, human-actionable output. Each primitive is either a Graph
|
|
1815
|
+
* factory or a Node factory, built on top of core + extra primitives.
|
|
1816
|
+
*
|
|
1817
|
+
* @module
|
|
1818
|
+
*/
|
|
1819
|
+
|
|
1820
|
+
type StepRef = string | Node<unknown>;
|
|
1821
|
+
/** A single routing rule for {@link stratify}. */
|
|
1822
|
+
type StratifyRule<T> = {
|
|
1823
|
+
/** Branch name (used as node name under `branch/<name>`). */
|
|
1824
|
+
name: string;
|
|
1825
|
+
/** Classifier: returns `true` if the value belongs to this branch. */
|
|
1826
|
+
classify: (value: T) => boolean;
|
|
1827
|
+
/** Optional operator chain applied to the branch after classification. */
|
|
1828
|
+
ops?: (n: Node<T>) => Node;
|
|
1829
|
+
};
|
|
1830
|
+
/** Options for {@link stratify}. */
|
|
1831
|
+
type StratifyOptions = GraphOptions & {
|
|
1832
|
+
meta?: Record<string, unknown>;
|
|
1833
|
+
};
|
|
1834
|
+
/**
|
|
1835
|
+
* Route input to different reduction branches based on classifier functions.
|
|
1836
|
+
*
|
|
1837
|
+
* Each branch gets an independent operator chain. Rules are reactive — update
|
|
1838
|
+
* the `"rules"` state node to rewrite classification at runtime. Rule updates
|
|
1839
|
+
* affect **future items only** (streaming classification, not retroactive).
|
|
1840
|
+
*
|
|
1841
|
+
* Branch nodes are structural — created at construction time and persist for
|
|
1842
|
+
* the graph's lifetime. If a rule name is removed from the rules array, the
|
|
1843
|
+
* corresponding branch silently drops items (classifier not found). To tear
|
|
1844
|
+
* down a dead branch, call `graph.remove("branch/<name>")`.
|
|
1845
|
+
*
|
|
1846
|
+
* @param name - Graph name.
|
|
1847
|
+
* @param source - Input node (registered externally or will be added as `"source"`).
|
|
1848
|
+
* @param rules - Initial routing rules.
|
|
1849
|
+
* @param opts - Optional graph/meta options.
|
|
1850
|
+
* @returns Graph with `"source"`, `"rules"`, and `"branch/<name>"` nodes.
|
|
1851
|
+
*
|
|
1852
|
+
* @category patterns
|
|
1853
|
+
*/
|
|
1854
|
+
declare function stratify<T>(name: string, source: Node<T>, rules: ReadonlyArray<StratifyRule<T>>, opts?: StratifyOptions): Graph;
|
|
1855
|
+
/** A named stage for {@link funnel}. */
|
|
1856
|
+
type FunnelStage = {
|
|
1857
|
+
/** Stage name (mounted as subgraph). */
|
|
1858
|
+
name: string;
|
|
1859
|
+
/** Builder: receives a sub-graph, should add an `"input"` and `"output"` node. */
|
|
1860
|
+
build: (sub: Graph) => void;
|
|
1861
|
+
};
|
|
1862
|
+
/** Options for {@link funnel}. */
|
|
1863
|
+
type FunnelOptions = GraphOptions & {
|
|
1864
|
+
meta?: Record<string, unknown>;
|
|
1865
|
+
};
|
|
1866
|
+
/**
|
|
1867
|
+
* Multi-source merge with sequential reduction stages.
|
|
1868
|
+
*
|
|
1869
|
+
* Sources are merged into a single stream. Each stage is a named subgraph
|
|
1870
|
+
* (mounted via `graph.mount()`). Stages connect linearly:
|
|
1871
|
+
* `merged → stage[0].input → stage[0].output → stage[1].input → ...`
|
|
1872
|
+
*
|
|
1873
|
+
* @param name - Graph name.
|
|
1874
|
+
* @param sources - Input nodes to merge.
|
|
1875
|
+
* @param stages - Sequential reduction stages.
|
|
1876
|
+
* @param opts - Optional graph/meta options.
|
|
1877
|
+
* @returns Graph with `"merged"` and mounted stage subgraphs.
|
|
1878
|
+
*
|
|
1879
|
+
* @category patterns
|
|
1880
|
+
*/
|
|
1881
|
+
declare function funnel<T>(name: string, sources: ReadonlyArray<Node<T>>, stages: ReadonlyArray<FunnelStage>, opts?: FunnelOptions): Graph;
|
|
1882
|
+
/** Options for {@link feedback}. */
|
|
1883
|
+
type FeedbackOptions = {
|
|
1884
|
+
/** Maximum feedback iterations before stopping (default: 10). */
|
|
1885
|
+
maxIterations?: number;
|
|
1886
|
+
/** Optional budget gate node path for cost-bounded iteration. */
|
|
1887
|
+
budgetNode?: StepRef;
|
|
1888
|
+
meta?: Record<string, unknown>;
|
|
1889
|
+
};
|
|
1890
|
+
/**
|
|
1891
|
+
* Introduce a bounded reactive cycle into an existing graph.
|
|
1892
|
+
*
|
|
1893
|
+
* When `condition` emits a non-null DATA value, the feedback effect routes it
|
|
1894
|
+
* back to the `reentry` state node — creating a cycle. Bounded by
|
|
1895
|
+
* `maxIterations` (default 10). The counter node (`__feedback_<condition>`)
|
|
1896
|
+
* is the source of truth — reset it to 0 to allow more iterations.
|
|
1897
|
+
*
|
|
1898
|
+
* To remove the feedback cycle, call `graph.remove("__feedback_<condition>")`.
|
|
1899
|
+
*
|
|
1900
|
+
* @param graph - Existing graph to augment with a feedback cycle.
|
|
1901
|
+
* @param condition - Path to a node whose DATA triggers feedback.
|
|
1902
|
+
* @param reentry - Path to a state node that receives the feedback value.
|
|
1903
|
+
* @param opts - Iteration bounds and metadata.
|
|
1904
|
+
* @returns The same graph (mutated with feedback nodes added).
|
|
1905
|
+
*
|
|
1906
|
+
* @category patterns
|
|
1907
|
+
*/
|
|
1908
|
+
declare function feedback(graph: Graph, condition: string, reentry: string, opts?: FeedbackOptions): Graph;
|
|
1909
|
+
/** A reactive constraint for {@link budgetGate}. */
|
|
1910
|
+
type BudgetConstraint<T = unknown> = {
|
|
1911
|
+
/** Constraint node whose value is checked. */
|
|
1912
|
+
node: Node<T>;
|
|
1913
|
+
/** Returns `true` when the constraint is satisfied (budget available). */
|
|
1914
|
+
check: (value: T) => boolean;
|
|
1915
|
+
};
|
|
1916
|
+
/** Options for {@link budgetGate}. */
|
|
1917
|
+
type BudgetGateOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1918
|
+
meta?: Record<string, unknown>;
|
|
1919
|
+
};
|
|
1920
|
+
/**
|
|
1921
|
+
* Pass-through that respects reactive constraint nodes.
|
|
1922
|
+
*
|
|
1923
|
+
* DATA flows through when all constraints are satisfied. When any constraint
|
|
1924
|
+
* is exceeded, PAUSE is sent upstream and DATA is buffered. When constraints
|
|
1925
|
+
* relax, RESUME is sent and buffered DATA flushes.
|
|
1926
|
+
*
|
|
1927
|
+
* @param source - Input node.
|
|
1928
|
+
* @param constraints - Reactive constraint checks.
|
|
1929
|
+
* @param opts - Optional node options.
|
|
1930
|
+
* @returns Gated node.
|
|
1931
|
+
*
|
|
1932
|
+
* @category patterns
|
|
1933
|
+
*/
|
|
1934
|
+
declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): Node<T>;
|
|
1935
|
+
/** A scored item with full breakdown. */
|
|
1936
|
+
type ScoredItem<T = unknown> = {
|
|
1937
|
+
/** Original value. */
|
|
1938
|
+
value: T;
|
|
1939
|
+
/** Final weighted score. */
|
|
1940
|
+
score: number;
|
|
1941
|
+
/** Per-signal breakdown: signal index → weighted contribution. */
|
|
1942
|
+
breakdown: number[];
|
|
1943
|
+
};
|
|
1944
|
+
/** Options for {@link scorer}. */
|
|
1945
|
+
type ScorerOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
1946
|
+
meta?: Record<string, unknown>;
|
|
1947
|
+
/** Custom scoring function per signal. Default: identity (signal value IS the score). */
|
|
1948
|
+
scoreFns?: ReadonlyArray<(value: unknown) => number>;
|
|
1949
|
+
};
|
|
1950
|
+
/**
|
|
1951
|
+
* Reactive multi-signal scoring with live weights.
|
|
1952
|
+
*
|
|
1953
|
+
* Each source emits items to score. Weights are reactive state nodes that
|
|
1954
|
+
* LLM or human can adjust live. Output is sorted scored items with full
|
|
1955
|
+
* breakdown.
|
|
1956
|
+
*
|
|
1957
|
+
* @param sources - Signal nodes (each emits a numeric score dimension).
|
|
1958
|
+
* @param weights - Reactive weight nodes (one per source).
|
|
1959
|
+
* @param opts - Optional node/meta options.
|
|
1960
|
+
* @returns Node emitting scored output.
|
|
1961
|
+
*
|
|
1962
|
+
* @category patterns
|
|
1963
|
+
*/
|
|
1964
|
+
declare function scorer(sources: ReadonlyArray<Node<number>>, weights: ReadonlyArray<Node<number>>, opts?: ScorerOptions): Node<ScoredItem<number[]>>;
|
|
1965
|
+
|
|
1966
|
+
type reduction_BudgetConstraint<T = unknown> = BudgetConstraint<T>;
|
|
1967
|
+
type reduction_BudgetGateOptions = BudgetGateOptions;
|
|
1968
|
+
type reduction_FeedbackOptions = FeedbackOptions;
|
|
1969
|
+
type reduction_FunnelOptions = FunnelOptions;
|
|
1970
|
+
type reduction_FunnelStage = FunnelStage;
|
|
1971
|
+
type reduction_ScoredItem<T = unknown> = ScoredItem<T>;
|
|
1972
|
+
type reduction_ScorerOptions = ScorerOptions;
|
|
1973
|
+
type reduction_StepRef = StepRef;
|
|
1974
|
+
type reduction_StratifyOptions = StratifyOptions;
|
|
1975
|
+
type reduction_StratifyRule<T> = StratifyRule<T>;
|
|
1976
|
+
declare const reduction_budgetGate: typeof budgetGate;
|
|
1977
|
+
declare const reduction_feedback: typeof feedback;
|
|
1978
|
+
declare const reduction_funnel: typeof funnel;
|
|
1979
|
+
declare const reduction_scorer: typeof scorer;
|
|
1980
|
+
declare const reduction_stratify: typeof stratify;
|
|
1981
|
+
declare namespace reduction {
|
|
1982
|
+
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
1983
|
}
|
|
1596
1984
|
|
|
1597
1985
|
/**
|
|
@@ -1600,11 +1988,13 @@ declare namespace orchestration {
|
|
|
1600
1988
|
|
|
1601
1989
|
declare const index_ai: typeof ai;
|
|
1602
1990
|
declare const index_cqrs: typeof cqrs;
|
|
1991
|
+
declare const index_graphspec: typeof graphspec;
|
|
1603
1992
|
declare const index_memory: typeof memory;
|
|
1604
1993
|
declare const index_messaging: typeof messaging;
|
|
1605
1994
|
declare const index_orchestration: typeof orchestration;
|
|
1995
|
+
declare const index_reduction: typeof reduction;
|
|
1606
1996
|
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 };
|
|
1997
|
+
export { index_ai as ai, index_cqrs as cqrs, demoShell$1 as demoShell, index_graphspec as graphspec, index$b as layout, index_memory as memory, index_messaging as messaging, index_orchestration as orchestration, index_reduction as reduction };
|
|
1608
1998
|
}
|
|
1609
1999
|
|
|
1610
2000
|
/**
|
|
@@ -1612,4 +2002,4 @@ declare namespace index {
|
|
|
1612
2002
|
*/
|
|
1613
2003
|
declare const version = "0.0.0";
|
|
1614
2004
|
|
|
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 };
|
|
2005
|
+
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, graphspec, 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 };
|