@graphrefly/graphrefly 0.30.0 → 0.31.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/{cascading-dNCtjW8j.d.cts → cascading-BfQmSmjU.d.cts} +21 -2
- package/dist/{cascading-BszPheHD.d.ts → cascading-D3sapjue.d.ts} +21 -2
- package/dist/{chunk-T5SHIKJD.js → chunk-3JRKP4BH.js} +1 -1
- package/dist/{chunk-GJR3P6JG.js → chunk-3Q2WXM6X.js} +1 -1
- package/dist/chunk-4KAUNEKV.js +3 -0
- package/dist/{chunk-SLMYTGTU.js → chunk-4UUDNFYG.js} +1 -1
- package/dist/chunk-4VXL3UZK.js +1 -0
- package/dist/{chunk-AV3PIDFQ.js → chunk-4ZPO2EL5.js} +1 -1
- package/dist/{chunk-VWPRPPKR.js → chunk-5LJAQTSS.js} +1 -1
- package/dist/{chunk-W4TSQ6RJ.js → chunk-7AJKUA36.js} +1 -1
- package/dist/{chunk-RD52SNH2.js → chunk-7EJTWGKW.js} +1 -1
- package/dist/{chunk-GNCBXARM.js → chunk-7EQPXQ7H.js} +1 -1
- package/dist/chunk-7QMVU3IX.js +1 -0
- package/dist/{chunk-BA5URFYW.js → chunk-A4JT4SAD.js} +1 -1
- package/dist/chunk-ASDKRNOJ.js +60 -0
- package/dist/{chunk-Y32RJO24.js → chunk-CZVYLXFK.js} +1 -1
- package/dist/{chunk-567NWZ3T.js → chunk-DWIAG62L.js} +1 -1
- package/dist/{chunk-33FA6V4B.js → chunk-EBQ6FXKW.js} +1 -1
- package/dist/chunk-FTA5TB2A.js +1 -0
- package/dist/{chunk-P7JXGKDO.js → chunk-GF5T7PGC.js} +1 -1
- package/dist/{chunk-WANIEEKV.js → chunk-I4U3TPK2.js} +1 -1
- package/dist/{chunk-KA6MMXIY.js → chunk-JMGGCSIC.js} +1 -1
- package/dist/chunk-JXRZXP3N.js +1 -0
- package/dist/{chunk-5Z4HDCO6.js → chunk-K54OKWNY.js} +1 -1
- package/dist/{chunk-DDPYNMGG.js → chunk-KN4Q5MQO.js} +1 -1
- package/dist/chunk-LWGLBCMU.js +1 -0
- package/dist/{chunk-TWMEGG45.js → chunk-N2KKISCE.js} +1 -1
- package/dist/{chunk-4OFIQ66T.js → chunk-OKQUPJRY.js} +1 -1
- package/dist/chunk-PNTBXOQ6.js +5 -0
- package/dist/chunk-PSQNYY72.js +7 -0
- package/dist/{chunk-XHVB6G6M.js → chunk-PZP4MEXK.js} +1 -1
- package/dist/{chunk-7TDOES3L.js → chunk-Q2SY7M7K.js} +1 -1
- package/dist/{chunk-OL33ZI6R.js → chunk-RWGJQQLT.js} +1 -1
- package/dist/chunk-SGS4OJGS.js +1 -0
- package/dist/chunk-UMH3HSP7.js +1 -0
- package/dist/{chunk-BZP5T4X6.js → chunk-W6FQIFVE.js} +1 -1
- package/dist/{chunk-SHYH5SXV.js → chunk-WLPVGXQ6.js} +1 -1
- package/dist/chunk-WQ7I7JVU.js +1 -0
- package/dist/{chunk-XQAXYVXX.js → chunk-WYJTXYWX.js} +1 -1
- package/dist/{chunk-3NEPQO2E.js → chunk-X2VHDT26.js} +1 -1
- package/dist/{chunk-GLSM33ZM.js → chunk-XEFAMCEA.js} +1 -1
- package/dist/{chunk-AUY2YKCO.js → chunk-XRSHMHEG.js} +1 -1
- package/dist/chunk-Y26UN6J5.js +18 -0
- package/dist/{chunk-BKPLTBL5.js → chunk-YQJPYEAL.js} +1 -1
- package/dist/{chunk-73Z3W2RN.js → chunk-YZ6VYLFD.js} +1 -1
- package/dist/{chunk-4JJCCD5S.js → chunk-YZKGGMPT.js} +1 -1
- package/dist/chunk-Z3UWIJ3A.js +1 -0
- package/dist/{chunk-Y36UZ5VS.js → chunk-ZM7C2FUM.js} +1 -1
- package/dist/compat/index.cjs +1 -1
- package/dist/compat/index.js +1 -1
- package/dist/compat/jotai/index.cjs +1 -1
- package/dist/compat/jotai/index.js +1 -1
- package/dist/compat/nanostores/index.cjs +1 -1
- package/dist/compat/nanostores/index.js +1 -1
- package/dist/compat/nestjs/index.cjs +5 -5
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/zustand/index.cjs +1 -1
- package/dist/compat/zustand/index.js +1 -1
- package/dist/{composite-DGspwCqk.d.ts → composite-BY9hMxN7.d.ts} +1 -1
- package/dist/{composite-nrRumJ7l.d.cts → composite-CH0S8DFn.d.cts} +1 -1
- package/dist/content-addressed-storage-BUiREIuj.d.ts +124 -0
- package/dist/content-addressed-storage-DqIWCmZG.d.cts +124 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +1 -1
- package/dist/extra/browser.cjs +1 -1
- package/dist/extra/browser.js +1 -1
- package/dist/extra/index.cjs +18 -18
- package/dist/extra/index.d.cts +6 -5
- package/dist/extra/index.d.ts +6 -5
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.cjs +2 -2
- package/dist/extra/node.js +1 -1
- package/dist/extra/operators.cjs +1 -1
- package/dist/extra/operators.d.cts +41 -1
- package/dist/extra/operators.d.ts +41 -1
- package/dist/extra/operators.js +1 -1
- package/dist/extra/reactive.cjs +1 -1
- package/dist/extra/reactive.d.cts +1 -1
- package/dist/extra/reactive.d.ts +1 -1
- package/dist/extra/reactive.js +1 -1
- package/dist/extra/sources.cjs +1 -1
- package/dist/extra/sources.d.cts +62 -2
- package/dist/extra/sources.d.ts +62 -2
- package/dist/extra/sources.js +1 -1
- package/dist/extra/storage-browser.cjs +1 -1
- package/dist/extra/storage-browser.js +1 -1
- package/dist/{fallback-BaTS7vVY.d.cts → fallback-Cb3GH1O7.d.cts} +6 -14
- package/dist/{fallback-eOm3LNxP.d.ts → fallback-DRjJ_ZM8.d.ts} +6 -14
- package/dist/graph/index.cjs +4 -4
- package/dist/graph/index.js +1 -1
- package/dist/{index-ClB7TCfL.d.cts → index-BMe3pCom.d.cts} +1 -1
- package/dist/{index-Dljd76bC.d.ts → index-BXzl1NDD.d.ts} +1 -1
- package/dist/{index-ClgKmOHe.d.ts → index-Bd6oFZqO.d.ts} +223 -115
- package/dist/{index-BJHQUCZx.d.ts → index-CJymKyzT.d.ts} +81 -6
- package/dist/{index-D6ajK8Mh.d.cts → index-CZChc85Q.d.cts} +223 -115
- package/dist/{index-BXbQUn4n.d.ts → index-CcS0t-l2.d.ts} +1 -1
- package/dist/{index-B2HBxvMb.d.ts → index-CwhcFzTA.d.ts} +1 -1
- package/dist/{index-B8Aj_z8S.d.cts → index-D-kHVedZ.d.cts} +1 -1
- package/dist/{index-ybtSyjWB.d.cts → index-DD7RhHNJ.d.cts} +1 -1
- package/dist/{index-BHu_Wba0.d.cts → index-Dm3_D5Ta.d.cts} +1 -1
- package/dist/{index-Cc8VQIgL.d.ts → index-DxMS0cHM.d.ts} +1 -1
- package/dist/{index-BS220yqj.d.cts → index-gJQqJTKx.d.cts} +81 -6
- package/dist/index.cjs +99 -121
- package/dist/index.d.cts +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/index.js +1 -1
- package/dist/patterns/ai/browser.cjs +5 -22
- package/dist/patterns/ai/browser.d.cts +3 -3
- package/dist/patterns/ai/browser.d.ts +3 -3
- package/dist/patterns/ai/browser.js +1 -1
- package/dist/patterns/ai/index.cjs +27 -44
- package/dist/patterns/ai/index.d.cts +9 -7
- package/dist/patterns/ai/index.d.ts +9 -7
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.cjs +2 -2
- package/dist/patterns/ai/node.d.cts +5 -4
- package/dist/patterns/ai/node.d.ts +5 -4
- package/dist/patterns/ai/node.js +1 -1
- package/dist/patterns/audit/index.cjs +3 -3
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +6 -6
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +1 -1
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.cjs +4 -4
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.cjs +6 -6
- package/dist/patterns/graphspec/index.d.cts +2 -2
- package/dist/patterns/graphspec/index.d.ts +2 -2
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +7 -7
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +11 -11
- package/dist/patterns/harness/index.d.cts +2 -2
- package/dist/patterns/harness/index.d.ts +2 -2
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +5 -5
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +5 -5
- package/dist/patterns/lens/index.d.cts +2 -2
- package/dist/patterns/lens/index.d.ts +2 -2
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +4 -4
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +5 -5
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +1 -1
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +1 -1
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.cjs +5 -5
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.cjs +8 -8
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.cjs +1 -1
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +7 -7
- package/dist/patterns/surface/index.d.cts +3 -3
- package/dist/patterns/surface/index.d.ts +3 -3
- package/dist/patterns/surface/index.js +1 -1
- package/dist/{reactive-map-BvDrRuwt.d.ts → reactive-map-CtRaCddO.d.ts} +59 -1
- package/dist/{reactive-map-CmlPPKHN.d.cts → reactive-map-IJIfZxoh.d.cts} +59 -1
- package/dist/{resilience-XRUF267O.js → resilience-IVNDYORD.js} +1 -1
- package/dist/{types-O3GzJY2U.d.cts → types-BgMqbc7N.d.cts} +41 -14
- package/dist/{types-u64Ose53.d.ts → types-CdfO2QTt.d.ts} +41 -14
- package/package.json +1 -1
- package/dist/chunk-2GQREQ6C.js +0 -1
- package/dist/chunk-4C2OR2GH.js +0 -18
- package/dist/chunk-5JDE5JHE.js +0 -1
- package/dist/chunk-7JDLFI6N.js +0 -1
- package/dist/chunk-AMBYCIOH.js +0 -3
- package/dist/chunk-ISCENNXS.js +0 -1
- package/dist/chunk-IUK4EFCE.js +0 -1
- package/dist/chunk-KASHOCF5.js +0 -1
- package/dist/chunk-LI3E75VE.js +0 -64
- package/dist/chunk-MGKAO4EK.js +0 -7
- package/dist/chunk-NSG4C6BF.js +0 -23
- package/dist/chunk-VIEUJSTT.js +0 -1
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { T as TokenUsage, L as LLMAdapter, P as PricingFn, C as ChatMessage, a as LLMInvokeOptions, d as ToolDefinition, b as LLMResponse, c as ToolCall, e as CapabilitiesRegistry, M as ModelCapabilities, f as ModelFeatures, g as ModelLimits, h as ModelPricing, i as PriceBreakdown, j as PricingRegistry, R as Rate,
|
|
2
|
-
import { a as CascadeExhaustionReport, A as AdapterProvider, b as AdapterTier, d as AllTiersExhaustedError, C as CascadingLlmAdapterOptions, e as CreateAdapterOptions, O as OpenAICompatAdapterOptions, f as OpenAICompatPreset, g as OpenAISdkLike, h as cascadingLlmAdapter, c as createAdapter, o as openAICompatAdapter } from './cascading-
|
|
1
|
+
import { T as TokenUsage, L as LLMAdapter, P as PricingFn, C as ChatMessage, a as LLMInvokeOptions, d as ToolDefinition, b as LLMResponse, S as StreamDelta, c as ToolCall, e as CapabilitiesRegistry, M as ModelCapabilities, f as ModelFeatures, g as ModelLimits, h as ModelPricing, i as PriceBreakdown, j as PricingRegistry, R as Rate, k as TieredRate, l as composePricing, m as computePrice, n as createCapabilitiesRegistry, o as createPricingRegistry, p as pricingFor, r as registryPricing, z as zeroPrice } from './types-CdfO2QTt.js';
|
|
2
|
+
import { a as CascadeExhaustionReport, A as AdapterProvider, b as AdapterTier, d as AllTiersExhaustedError, C as CascadingLlmAdapterOptions, e as CreateAdapterOptions, O as OpenAICompatAdapterOptions, f as OpenAICompatPreset, g as OpenAISdkLike, h as cascadingLlmAdapter, c as createAdapter, o as openAICompatAdapter, t as tier } from './cascading-D3sapjue.js';
|
|
3
3
|
import { a as Node, A as Actor } from './node-BVV7G1bq.js';
|
|
4
4
|
import { R as ReactiveLogBundle } from './reactive-log-BOJDCI5x.js';
|
|
5
5
|
import { a as CircuitBreakerOptions, e as CircuitBreaker, f as CircuitOpenError } from './resilience-CludlzcP.js';
|
|
6
6
|
import { NodeInput } from './extra/sources.js';
|
|
7
|
-
import { F as FallbackAdapterOptions, a as FallbackFixture, b as FallbackMissError, c as FallbackMissPolicy, R as ReplayCacheKeyContext, d as ReplayCacheMissError, e as ReplayCacheMode,
|
|
7
|
+
import { W as WithReplayCacheOptions, F as FallbackAdapterOptions, a as FallbackFixture, b as FallbackMissError, c as FallbackMissPolicy, R as ReplayCacheKeyContext, d as ReplayCacheMissError, e as ReplayCacheMode, f as canonicalJson, g as fallbackAdapter, w as withReplayCache } from './fallback-DRjJ_ZM8.js';
|
|
8
8
|
import { G as Graph, a as GraphOptions, h as GraphAttachStorageOptions } from './graph-CWeI0aHd.js';
|
|
9
9
|
import { T as TopicGraph } from './index-CvS9IuTG.js';
|
|
10
10
|
import { G as GateController, a as GateOptions } from './index-CFW32Dy1.js';
|
|
11
|
-
import { D as DistillBundle, E as Extraction } from './composite-
|
|
11
|
+
import { D as DistillBundle, E as Extraction } from './composite-BY9hMxN7.js';
|
|
12
12
|
import { V as VectorSearchResult, L as LightCollectionBundle, a as VectorIndexBundle, K as KnowledgeGraphGraph } from './index-DnrZghBB.js';
|
|
13
13
|
import { StorageHandle, StorageTier } from './extra/storage-core.js';
|
|
14
|
+
import { c as GraphSpecCatalog } from './index-CcS0t-l2.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Observable adapter wrapper — the "inverted statistics" surface.
|
|
17
18
|
*
|
|
18
19
|
* The library emits structured facts (token counts, latency, timestamps)
|
|
19
20
|
* as reactive nodes. Users compose interpretation (pricing, dashboards,
|
|
20
|
-
* telemetry, budget breakers) as derived layers on top.
|
|
21
|
-
* `archive/docs/SESSION-rigor-infrastructure-plan.md` §"v2: reactive LLM
|
|
22
|
-
* statistics + pluggable pricing".
|
|
21
|
+
* telemetry, budget breakers) as derived layers on top.
|
|
23
22
|
*/
|
|
24
23
|
|
|
25
24
|
/** One call's structured statistics — emitted after `invoke()` / `stream()` settles. */
|
|
@@ -58,20 +57,28 @@ interface AdapterStats {
|
|
|
58
57
|
readonly totalOutputTokens: Node<number>;
|
|
59
58
|
/** Reset all counters + clear the log. */
|
|
60
59
|
reset(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Release the internal keepalive subscriptions on the three counter
|
|
62
|
+
* derives (`totalCalls` / `totalInputTokens` / `totalOutputTokens`) so the
|
|
63
|
+
* bundle can be GC'd when the caller discards it. Idempotent. Long-lived
|
|
64
|
+
* adapter bundles (module-level singletons) can ignore; transient bundles
|
|
65
|
+
* (per-request / per-user) should call on teardown.
|
|
66
|
+
*/
|
|
67
|
+
dispose(): void;
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* Wrap any {@link LLMAdapter} with a reactive stats bundle.
|
|
64
71
|
*
|
|
65
|
-
* Implementation:
|
|
66
|
-
* - `stats.lastCall` is a `state<CallStatsEvent |
|
|
67
|
-
* null-filtering derived so consumers see a typed `Node<CallStatsEvent>`.
|
|
72
|
+
* Implementation (Unit 10 B):
|
|
73
|
+
* - `stats.lastCall` is a `state<CallStatsEvent | null>`.
|
|
68
74
|
* - Counters (`totalCalls` / `totalInputTokens` / `totalOutputTokens`) are
|
|
69
|
-
*
|
|
75
|
+
* **derived views** over `allCalls.entries` — self-maintaining, no manual
|
|
76
|
+
* `.cache + 1 + emit` pattern, visible topology in `describe()`.
|
|
70
77
|
* - `stats.allCalls` is a `reactiveLog<CallStatsEvent>` — bounded, supports
|
|
71
78
|
* `tail(n)` / `slice(start, stop)` for dashboard views.
|
|
72
|
-
* - The wrapped adapter passes DATA through via
|
|
73
|
-
*
|
|
74
|
-
*
|
|
79
|
+
* - The wrapped adapter passes DATA through via `adaptInvokeResult`, which
|
|
80
|
+
* uses `onFirstData` internally to guard against re-subscription double-fire
|
|
81
|
+
* and wires `.catch` for Promise-path error recording (Unit 10 A).
|
|
75
82
|
*/
|
|
76
83
|
declare function observableAdapter(inner: LLMAdapter, opts?: {
|
|
77
84
|
logMax?: number;
|
|
@@ -115,6 +122,11 @@ declare function withBreaker(inner: LLMAdapter, opts?: WithBreakerOptions): {
|
|
|
115
122
|
* throws `BudgetExhaustedError` without hitting the wrapped adapter. On
|
|
116
123
|
* success, the call's usage is appended to the log AND debits the running
|
|
117
124
|
* totals in a single synchronous update.
|
|
125
|
+
*
|
|
126
|
+
* Wave A Unit 11 Q4: rejected-Promise path now wires `.catch` (via
|
|
127
|
+
* `adaptInvokeResult.onError`) so failed invoke calls record a CallStatsEvent
|
|
128
|
+
* with `error` populated. Prior code silently dropped rejection from the
|
|
129
|
+
* `totals` / `log` surface.
|
|
118
130
|
*/
|
|
119
131
|
|
|
120
132
|
declare class BudgetExhaustedError extends Error {
|
|
@@ -489,6 +501,14 @@ interface ResilientAdapterOptions {
|
|
|
489
501
|
* is set. Threaded directly to the inner {@link cascadingLlmAdapter}.
|
|
490
502
|
*/
|
|
491
503
|
onExhausted?: (report: CascadeExhaustionReport) => void;
|
|
504
|
+
/**
|
|
505
|
+
* Content-addressed replay cache wrapped OUTERMOST — a cache HIT short-
|
|
506
|
+
* circuits the entire stack (rate-limit / budget / breaker / retry /
|
|
507
|
+
* fallback), saving money and latency. Cache MISSes flow through the
|
|
508
|
+
* normal stack; the successful result is stored on success. See
|
|
509
|
+
* {@link withReplayCache}.
|
|
510
|
+
*/
|
|
511
|
+
cache?: WithReplayCacheOptions;
|
|
492
512
|
}
|
|
493
513
|
/** Output bundle of {@link resilientAdapter}. */
|
|
494
514
|
interface ResilientAdapterBundle {
|
|
@@ -767,23 +787,6 @@ interface GeminiUsage {
|
|
|
767
787
|
}
|
|
768
788
|
declare function googleAdapter(opts?: GoogleAdapterOptions): LLMAdapter;
|
|
769
789
|
|
|
770
|
-
/**
|
|
771
|
-
* Curated `cascadingLlmAdapter` presets — Node/browser-safe subset.
|
|
772
|
-
*
|
|
773
|
-
* Thin compositions over `cascadingLlmAdapter` + `createAdapter`. No new
|
|
774
|
-
* logic — just convenient defaults. Users needing finer control call
|
|
775
|
-
* `cascadingLlmAdapter` directly.
|
|
776
|
-
*
|
|
777
|
-
* Presets that depend on browser-only adapters (WebLLM, Chrome Nano) have
|
|
778
|
-
* been split out to [`./browser-presets.ts`](./browser-presets.ts) and are
|
|
779
|
-
* exported from the `@graphrefly/graphrefly/patterns/ai/browser`
|
|
780
|
-
* subpath so they don't leak into Node bundles.
|
|
781
|
-
*
|
|
782
|
-
* @module
|
|
783
|
-
*/
|
|
784
|
-
|
|
785
|
-
declare function dryRunPreset(): LLMAdapter;
|
|
786
|
-
|
|
787
790
|
/**
|
|
788
791
|
* `fromLLM` — reactive LLM invocation sugar.
|
|
789
792
|
*
|
|
@@ -889,34 +892,56 @@ type PromptNodeOptions = {
|
|
|
889
892
|
declare function promptNode<T = string>(adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: PromptNodeOptions): Node<T | null>;
|
|
890
893
|
|
|
891
894
|
/**
|
|
892
|
-
* `streamingPromptNode` + `gatedStream` — streaming LLM transforms
|
|
893
|
-
*
|
|
895
|
+
* `streamingPromptNode` + `gatedStream` — streaming LLM transforms.
|
|
896
|
+
*
|
|
897
|
+
* **Wave A Unit 2 rewrite:**
|
|
898
|
+
* - `StreamChunk` retired. The live stream surface is now `deltaTopic:
|
|
899
|
+
* TopicGraph<StreamDelta & {seq, ts}>` — every adapter delta (token,
|
|
900
|
+
* thinking, tool-call, usage, finish) is published in order. The previous
|
|
901
|
+
* shape retained the accumulated text per-chunk, producing O(N²) memory;
|
|
902
|
+
* the new shape stores only per-delta payloads (O(N)).
|
|
903
|
+
* - New `accumulatedText: Node<string>` on the bundle — lazy-built via
|
|
904
|
+
* `ctx.store` over token-type deltas. Text-only extractors (`streamExtractor`,
|
|
905
|
+
* `keywordFlagExtractor`, `toolCallExtractor`) consume this node.
|
|
906
|
+
* - `retainedLimit?: number` option exposed for the delta topic (no default —
|
|
907
|
+
* session scale is domain-specific per Unit 2 Q2).
|
|
908
|
+
* - Unconditional `keepalive(output)` removed — callers subscribe as needed.
|
|
909
|
+
* - System-prompt double-send fixed (matches promptNode Unit 1 fix).
|
|
910
|
+
* - `format: "json"` throws on parse error with a content-preview diagnostic
|
|
911
|
+
* (parity with `promptNode`).
|
|
912
|
+
* - Shared body between `streamingPromptNode` and `gatedStream` extracted
|
|
913
|
+
* into `streamingInvoke` per Unit 2 locked scope.
|
|
894
914
|
*
|
|
895
915
|
* @module
|
|
896
916
|
*/
|
|
897
917
|
|
|
898
918
|
/**
|
|
899
|
-
* A single
|
|
900
|
-
*
|
|
919
|
+
* A single delta published to the `deltaTopic`. Every adapter emission is
|
|
920
|
+
* forwarded — not just token deltas — so consumers see the full event log
|
|
921
|
+
* (thinking, tool-call-delta, usage, finish).
|
|
901
922
|
*/
|
|
902
|
-
type
|
|
903
|
-
/**
|
|
904
|
-
readonly
|
|
905
|
-
/**
|
|
906
|
-
readonly
|
|
907
|
-
/** Full accumulated text so far. */
|
|
908
|
-
readonly accumulated: string;
|
|
909
|
-
/** 0-based chunk counter. */
|
|
910
|
-
readonly index: number;
|
|
923
|
+
type StampedDelta = StreamDelta & {
|
|
924
|
+
/** Monotonic per-stream counter starting at 0. */
|
|
925
|
+
readonly seq: number;
|
|
926
|
+
/** Wall-clock nanoseconds at publish time (spec §5.11 central timer). */
|
|
927
|
+
readonly ts: number;
|
|
911
928
|
};
|
|
912
929
|
type StreamingPromptNodeOptions = {
|
|
913
930
|
name?: string;
|
|
914
931
|
model?: string;
|
|
915
932
|
temperature?: number;
|
|
916
933
|
maxTokens?: number;
|
|
917
|
-
/** Output format — `"json"` attempts JSON.parse on
|
|
934
|
+
/** Output format — `"json"` attempts JSON.parse on accumulated text. Throws on parse failure. Default: `"text"`. */
|
|
918
935
|
format?: "text" | "json";
|
|
919
936
|
systemPrompt?: string;
|
|
937
|
+
meta?: Record<string, unknown>;
|
|
938
|
+
/**
|
|
939
|
+
* Optional retention cap on the delta topic. Omit for unbounded retention
|
|
940
|
+
* (the topic grows until `dispose()`). Recommended values: `8_192` for
|
|
941
|
+
* single-shot 8K-token responses, `1_000_000` for persistent session
|
|
942
|
+
* topics, or explicit `dispose()` for worker-pool patterns.
|
|
943
|
+
*/
|
|
944
|
+
retainedLimit?: number;
|
|
920
945
|
};
|
|
921
946
|
/**
|
|
922
947
|
* Bundle returned by {@link streamingPromptNode}.
|
|
@@ -924,9 +949,15 @@ type StreamingPromptNodeOptions = {
|
|
|
924
949
|
type StreamingPromptNodeHandle<T> = {
|
|
925
950
|
/** Final parsed result (emits once per invocation, after stream completes). */
|
|
926
951
|
output: Node<T | null>;
|
|
927
|
-
/** Live
|
|
928
|
-
|
|
929
|
-
/**
|
|
952
|
+
/** Live delta topic — every adapter delta in order, stamped with `seq` + `ts`. */
|
|
953
|
+
deltaTopic: TopicGraph<StampedDelta>;
|
|
954
|
+
/**
|
|
955
|
+
* Reactive accumulated-text view — lazy-built over `deltaTopic.latest`
|
|
956
|
+
* filtered on `type === "token"`. Text-only extractors compose on this.
|
|
957
|
+
* Emits the empty string before any token arrives.
|
|
958
|
+
*/
|
|
959
|
+
accumulatedText: Node<string>;
|
|
960
|
+
/** Tear down the delta topic and release resources. */
|
|
930
961
|
dispose: () => void;
|
|
931
962
|
};
|
|
932
963
|
/**
|
|
@@ -934,12 +965,12 @@ type StreamingPromptNodeHandle<T> = {
|
|
|
934
965
|
* streaming pipeline. Re-invokes the LLM whenever any dep changes; the
|
|
935
966
|
* previous in-flight stream is canceled automatically via `switchMap`.
|
|
936
967
|
*
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
968
|
+
* Every adapter delta is published to `deltaTopic` stamped with `seq` + `ts`.
|
|
969
|
+
* Text consumers subscribe to `accumulatedText` (auto-maintained). Delta-
|
|
970
|
+
* specific consumers (`costMeterExtractor` on `usage` deltas) subscribe to
|
|
971
|
+
* `deltaTopic` directly and filter by `delta.type`.
|
|
940
972
|
*
|
|
941
|
-
* The
|
|
942
|
-
* The async boundary is handled by `fromAny` (spec §5.10 compliant).
|
|
973
|
+
* The async boundary is handled by `fromAny(asyncGenerator)` (spec §5.10).
|
|
943
974
|
*/
|
|
944
975
|
declare function streamingPromptNode<T = string>(adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: StreamingPromptNodeOptions): StreamingPromptNodeHandle<T>;
|
|
945
976
|
type GatedStreamOptions = StreamingPromptNodeOptions & {
|
|
@@ -952,11 +983,13 @@ type GatedStreamOptions = StreamingPromptNodeOptions & {
|
|
|
952
983
|
type GatedStreamHandle<T> = {
|
|
953
984
|
/** Final parsed result (after gate approval). */
|
|
954
985
|
output: Node<T | null>;
|
|
955
|
-
/** Live
|
|
956
|
-
|
|
986
|
+
/** Live delta topic — every adapter delta in order, stamped with `seq` + `ts`. */
|
|
987
|
+
deltaTopic: TopicGraph<StampedDelta>;
|
|
988
|
+
/** Reactive accumulated-text view. */
|
|
989
|
+
accumulatedText: Node<string>;
|
|
957
990
|
/** Gate controller — approve, reject (aborts in-flight stream), modify. */
|
|
958
991
|
gate: GateController<T | null>;
|
|
959
|
-
/** Tear down
|
|
992
|
+
/** Tear down the delta topic + gate keepalive. */
|
|
960
993
|
dispose: () => void;
|
|
961
994
|
};
|
|
962
995
|
/**
|
|
@@ -964,14 +997,13 @@ type GatedStreamHandle<T> = {
|
|
|
964
997
|
*
|
|
965
998
|
* Composes {@link streamingPromptNode} with `gate` so that:
|
|
966
999
|
* - `gate.reject()` discards the pending value **and** aborts the in-flight
|
|
967
|
-
* stream (
|
|
1000
|
+
* stream (toggles an internal cancel signal → switchMap restart → abort).
|
|
968
1001
|
* - `gate.modify()` transforms the pending value before forwarding downstream.
|
|
969
1002
|
* - `gate.approve()` forwards the final result as normal.
|
|
970
1003
|
*
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
* `finally` block.
|
|
1004
|
+
* Wave A Unit 2 defers full `gatedStream` review to Wave B Unit 17 (the
|
|
1005
|
+
* `gate()` primitive itself is reviewed there). This implementation retains
|
|
1006
|
+
* the existing gate API while adopting the Unit 2 delta-topic shape.
|
|
975
1007
|
*/
|
|
976
1008
|
declare function gatedStream<T = string>(graph: Graph, name: string, adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: GatedStreamOptions): GatedStreamHandle<T>;
|
|
977
1009
|
|
|
@@ -994,7 +1026,15 @@ declare function systemPromptBuilder(sections: readonly NodeInput<string>[], opt
|
|
|
994
1026
|
}): SystemPromptHandle;
|
|
995
1027
|
|
|
996
1028
|
/**
|
|
997
|
-
* Cost meter extractor —
|
|
1029
|
+
* Cost meter extractor — derives live cost readings from the delta topic.
|
|
1030
|
+
*
|
|
1031
|
+
* **Wave A Unit 3 rewrite:** signature takes `deltaTopic: TopicGraph<StampedDelta>`
|
|
1032
|
+
* instead of the old `TopicGraph<StreamChunk>`. The meter prefers real
|
|
1033
|
+
* `usage` deltas from the adapter; when no `usage` has been seen yet it
|
|
1034
|
+
* falls back to a char-based estimate over token deltas and stamps
|
|
1035
|
+
* `estimated: true` on the reading. Chunk count is the count of
|
|
1036
|
+
* token-type deltas seen (was `chunk.index + 1`).
|
|
1037
|
+
*
|
|
998
1038
|
* @module
|
|
999
1039
|
*/
|
|
1000
1040
|
|
|
@@ -1003,6 +1043,12 @@ type CostMeterReading = {
|
|
|
1003
1043
|
readonly chunkCount: number;
|
|
1004
1044
|
readonly charCount: number;
|
|
1005
1045
|
readonly estimatedTokens: number;
|
|
1046
|
+
/**
|
|
1047
|
+
* `true` when no adapter `usage` delta has been observed yet —
|
|
1048
|
+
* `estimatedTokens` is a char-based heuristic and should be treated as an
|
|
1049
|
+
* approximation. Flips to `false` once a real `usage` delta arrives.
|
|
1050
|
+
*/
|
|
1051
|
+
readonly estimated: boolean;
|
|
1006
1052
|
};
|
|
1007
1053
|
type CostMeterOptions = {
|
|
1008
1054
|
/** Characters per token approximation. Default: 4 (GPT-family). */
|
|
@@ -1010,14 +1056,14 @@ type CostMeterOptions = {
|
|
|
1010
1056
|
name?: string;
|
|
1011
1057
|
};
|
|
1012
1058
|
/**
|
|
1013
|
-
* Mounts a cost meter on
|
|
1014
|
-
*
|
|
1015
|
-
*
|
|
1059
|
+
* Mounts a cost meter on the delta topic. Prefers real `usage` deltas from
|
|
1060
|
+
* the provider; falls back to char-based estimation on token deltas alone
|
|
1061
|
+
* (with `meta.estimated: true` on the reading).
|
|
1016
1062
|
*
|
|
1017
1063
|
* Default structural equals suppresses DATA emission when two consecutive
|
|
1018
|
-
* readings are identical
|
|
1064
|
+
* readings are identical.
|
|
1019
1065
|
*/
|
|
1020
|
-
declare function costMeterExtractor(
|
|
1066
|
+
declare function costMeterExtractor(deltaTopic: TopicGraph<StampedDelta>, opts?: CostMeterOptions): Node<CostMeterReading>;
|
|
1021
1067
|
|
|
1022
1068
|
/**
|
|
1023
1069
|
* Keyword-flag extractor — scans accumulated stream text for configured patterns.
|
|
@@ -1045,38 +1091,52 @@ type KeywordFlagExtractorOptions = {
|
|
|
1045
1091
|
maxPatternLength?: number;
|
|
1046
1092
|
};
|
|
1047
1093
|
/**
|
|
1048
|
-
* Mounts a keyword-flag extractor on
|
|
1049
|
-
*
|
|
1094
|
+
* Mounts a keyword-flag extractor on accumulated text. Scans for all
|
|
1095
|
+
* configured patterns and emits an array of matches.
|
|
1096
|
+
*
|
|
1097
|
+
* **Wave A Unit 3 rewrite:** signature takes `accumulatedText: Node<string>`
|
|
1098
|
+
* instead of the old `TopicGraph<StreamChunk>`. Patterns are compiled once
|
|
1099
|
+
* at factory time (was per-chunk). `maxPatternLength` is validated at
|
|
1100
|
+
* factory time — any pattern whose source exceeds the window throws
|
|
1101
|
+
* immediately.
|
|
1050
1102
|
*
|
|
1051
1103
|
* Use cases: design invariant violations (`setTimeout`, `EventEmitter`), PII
|
|
1052
1104
|
* detection (SSN, email, phone), toxicity keywords, off-track reasoning.
|
|
1053
1105
|
*
|
|
1054
|
-
* **Streaming optimization.** Maintains a cursor across
|
|
1055
|
-
* so each
|
|
1056
|
-
* maxPatternLength)` — not the full string.
|
|
1057
|
-
*
|
|
1106
|
+
* **Streaming optimization.** Maintains a cursor across waves in `ctx.store`
|
|
1107
|
+
* so each emission scans only the delta region `accumulated.slice(scannedTo -
|
|
1108
|
+
* maxPatternLength)` — not the full string. Reactivation clears `ctx.store`
|
|
1109
|
+
* and resumes from offset 0 (COMPOSITION-GUIDE §20 RAM semantics).
|
|
1110
|
+
*
|
|
1111
|
+
* Default structural equals suppresses DATA emission when no new flags were
|
|
1112
|
+
* found this wave.
|
|
1058
1113
|
*/
|
|
1059
|
-
declare function keywordFlagExtractor(
|
|
1114
|
+
declare function keywordFlagExtractor(accumulatedText: Node<string>, opts: KeywordFlagExtractorOptions): Node<readonly KeywordFlag[]>;
|
|
1060
1115
|
|
|
1061
1116
|
/**
|
|
1062
|
-
* Generic stream extractor — mounts an extract function on
|
|
1117
|
+
* Generic stream extractor — mounts an extract function on accumulated text.
|
|
1118
|
+
*
|
|
1119
|
+
* **Wave A Unit 3 rewrite:** signature changed from
|
|
1120
|
+
* `streamExtractor(topic: TopicGraph<StreamChunk>, fn)` to
|
|
1121
|
+
* `streamExtractor(accumulatedText: Node<string>, fn)`. The Unit 2 delta-
|
|
1122
|
+
* topic redesign removed the per-chunk `accumulated` field; callers pass
|
|
1123
|
+
* `streamingPromptNode(...).accumulatedText` (or any other `Node<string>`
|
|
1124
|
+
* source of accumulated text). Source-agnostic — the extractor doesn't care
|
|
1125
|
+
* whether the text came from an LLM, WebSocket, SSE tail, or file reader.
|
|
1126
|
+
*
|
|
1063
1127
|
* @module
|
|
1064
1128
|
*/
|
|
1065
1129
|
|
|
1066
1130
|
/**
|
|
1067
|
-
* Mounts an extractor function on a
|
|
1068
|
-
* that emits extracted values as
|
|
1069
|
-
*
|
|
1070
|
-
* `extractFn` receives the accumulated text from the latest chunk and returns
|
|
1071
|
-
* the extracted value, or `null` if nothing detected yet. This is the building
|
|
1072
|
-
* block for keyword flags, tool call detection, cost metering, etc.
|
|
1131
|
+
* Mounts an extractor function on a reactive accumulated-text source. Returns
|
|
1132
|
+
* a derived node that emits extracted values as the text grows.
|
|
1073
1133
|
*
|
|
1074
|
-
* @param
|
|
1134
|
+
* @param accumulatedText - Reactive `Node<string>` of accumulated text.
|
|
1075
1135
|
* @param extractFn - `(accumulated: string) => T | null`.
|
|
1076
|
-
* @param opts - Optional name.
|
|
1136
|
+
* @param opts - Optional name + structural equals.
|
|
1077
1137
|
* @returns Derived node emitting extracted values.
|
|
1078
1138
|
*/
|
|
1079
|
-
declare function streamExtractor<T>(
|
|
1139
|
+
declare function streamExtractor<T>(accumulatedText: Node<string>, extractFn: (accumulated: string) => T | null, opts?: {
|
|
1080
1140
|
name?: string;
|
|
1081
1141
|
/**
|
|
1082
1142
|
* Optional structural equals for the extractor output. When two
|
|
@@ -1114,7 +1174,7 @@ type ExtractedToolCall = {
|
|
|
1114
1174
|
* are not re-parsed. Default structural equals suppresses DATA emission when
|
|
1115
1175
|
* no new tool call completed this chunk.
|
|
1116
1176
|
*/
|
|
1117
|
-
declare function toolCallExtractor(
|
|
1177
|
+
declare function toolCallExtractor(accumulatedText: Node<string>, opts?: {
|
|
1118
1178
|
name?: string;
|
|
1119
1179
|
}): Node<readonly ExtractedToolCall[]>;
|
|
1120
1180
|
|
|
@@ -1139,23 +1199,31 @@ type ContentGateOptions = {
|
|
|
1139
1199
|
* Derived node that classifies accumulated stream text as `"allow"`,
|
|
1140
1200
|
* `"review"`, or `"block"` based on a classifier score.
|
|
1141
1201
|
*
|
|
1142
|
-
*
|
|
1202
|
+
* **Wave A Unit 3 rewrite:** signature now takes `accumulatedText: Node<string>`
|
|
1203
|
+
* instead of a `TopicGraph<StreamChunk>` (the `StreamChunk` shape was retired
|
|
1204
|
+
* when the delta topic replaced the per-chunk accumulated-text shape).
|
|
1205
|
+
*
|
|
1206
|
+
* Emits a three-way decision on every text change:
|
|
1143
1207
|
* - `"allow"` — score below `threshold`
|
|
1144
1208
|
* - `"review"` — score in `[threshold, threshold × hardMultiplier)`
|
|
1145
1209
|
* - `"block"` — score at or above `threshold × hardMultiplier`
|
|
1146
1210
|
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1151
|
-
* @param
|
|
1152
|
-
* a `Node<number>` for live scores.
|
|
1153
|
-
* @param threshold - Score at which output becomes "review" or "block".
|
|
1211
|
+
* @param accumulatedText - Reactive accumulated-text source
|
|
1212
|
+
* (`streamingPromptNode(...).accumulatedText`).
|
|
1213
|
+
* @param classifier - `(accumulated: string) => number` scoring function, or
|
|
1214
|
+
* a `Node<number>` for live scores.
|
|
1215
|
+
* @param threshold - Score at which output becomes `"review"` or `"block"`.
|
|
1154
1216
|
*/
|
|
1155
|
-
declare function contentGate(
|
|
1217
|
+
declare function contentGate(accumulatedText: Node<string>, classifier: ((accumulated: string) => number) | Node<number>, threshold: number, opts?: ContentGateOptions): Node<ContentDecision>;
|
|
1156
1218
|
|
|
1157
1219
|
/**
|
|
1158
1220
|
* Redactor — stream extractor that replaces matched patterns in accumulated text.
|
|
1221
|
+
*
|
|
1222
|
+
* **Wave A Unit 3 rewrite:** signature now takes `accumulatedText: Node<string>`
|
|
1223
|
+
* instead of the retired `TopicGraph<StreamChunk>`. The output is a
|
|
1224
|
+
* `Node<string>` carrying the sanitized accumulated text — compose with
|
|
1225
|
+
* `contentGate` or downstream UI directly.
|
|
1226
|
+
*
|
|
1159
1227
|
* @module
|
|
1160
1228
|
*/
|
|
1161
1229
|
|
|
@@ -1164,19 +1232,14 @@ type RedactorOptions = {
|
|
|
1164
1232
|
name?: string;
|
|
1165
1233
|
};
|
|
1166
1234
|
/**
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1169
|
-
* Returns a derived node emitting a sanitized `StreamChunk` on every chunk:
|
|
1170
|
-
* `accumulated` and `token` have matched substrings replaced by `replaceFn`.
|
|
1171
|
-
* The default `replaceFn` replaces with `"[REDACTED]"`.
|
|
1235
|
+
* Derived node that replaces matched patterns in accumulated text.
|
|
1172
1236
|
*
|
|
1173
|
-
*
|
|
1174
|
-
*
|
|
1175
|
-
* @param
|
|
1176
|
-
* @
|
|
1177
|
-
* @param replaceFn - Replacement producer (default: always `"[REDACTED]"`).
|
|
1237
|
+
* @param accumulatedText - Reactive accumulated-text source.
|
|
1238
|
+
* @param patterns - Array of RegExps to match against the text.
|
|
1239
|
+
* @param replaceFn - Replacement producer (default: always `"[REDACTED]"`).
|
|
1240
|
+
* @returns `Node<string>` emitting the sanitized accumulated text.
|
|
1178
1241
|
*/
|
|
1179
|
-
declare function redactor(
|
|
1242
|
+
declare function redactor(accumulatedText: Node<string>, patterns: RegExp[], replaceFn?: (match: string, pattern: RegExp) => string, opts?: RedactorOptions): Node<string>;
|
|
1180
1243
|
|
|
1181
1244
|
type ChatStreamOptions = {
|
|
1182
1245
|
graph?: GraphOptions;
|
|
@@ -1198,13 +1261,47 @@ declare function chatStream(name: string, opts?: ChatStreamOptions): ChatStreamG
|
|
|
1198
1261
|
type ToolRegistryOptions = {
|
|
1199
1262
|
graph?: GraphOptions;
|
|
1200
1263
|
};
|
|
1264
|
+
/**
|
|
1265
|
+
* `ToolRegistryGraph` — name-keyed registry of {@link ToolDefinition}s.
|
|
1266
|
+
*
|
|
1267
|
+
* **Wave A Unit 6 refactor:** internal storage migrated from `state<Map>`
|
|
1268
|
+
* (O(N) Map-copy per mutation) to `ReactiveMapBundle<string, ToolDefinition>`
|
|
1269
|
+
* (O(1) mutations + version counter). Public API unchanged for existing
|
|
1270
|
+
* consumers. Adds a new reactive `executeReactive(name, args): Node<unknown>`
|
|
1271
|
+
* alongside the imperative `execute(name, args): Promise<unknown>` so
|
|
1272
|
+
* composing factories (`toolExecution`, `agentLoop`) can consume the tool
|
|
1273
|
+
* handler as a reactive source without bridging through `firstDataFromNode`.
|
|
1274
|
+
*/
|
|
1201
1275
|
declare class ToolRegistryGraph extends Graph {
|
|
1202
1276
|
readonly definitions: Node<ReadonlyMap<string, ToolDefinition>>;
|
|
1203
1277
|
readonly schemas: Node<readonly ToolDefinition[]>;
|
|
1278
|
+
private readonly _bundle;
|
|
1204
1279
|
constructor(name: string, opts?: ToolRegistryOptions);
|
|
1205
1280
|
register(tool: ToolDefinition): void;
|
|
1206
1281
|
unregister(name: string): void;
|
|
1282
|
+
/**
|
|
1283
|
+
* Imperative boundary: await the handler result as a Promise. Safe for
|
|
1284
|
+
* non-reactive callers; reactive consumers prefer {@link executeReactive}.
|
|
1285
|
+
*/
|
|
1207
1286
|
execute(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Reactive execution — returns a `Node<unknown>` that emits the handler
|
|
1289
|
+
* result. Uses `fromAny` to bridge Promise / Node / AsyncIterable handler
|
|
1290
|
+
* return shapes uniformly. Composes cleanly inside `switchMap` /
|
|
1291
|
+
* `retrySource` / `rescue` chains where the legacy imperative `execute()`
|
|
1292
|
+
* would force a `firstDataFromNode` round-trip.
|
|
1293
|
+
*
|
|
1294
|
+
* The returned node is a one-shot: it emits the first DATA from the
|
|
1295
|
+
* handler result (or ERROR on handler throw) and then relies on the
|
|
1296
|
+
* caller's switchMap / subscription chain for teardown. For repeated
|
|
1297
|
+
* invocations, call `executeReactive` again — each call mints a fresh
|
|
1298
|
+
* node tied to a fresh `handler(args)` invocation.
|
|
1299
|
+
*
|
|
1300
|
+
* @throws `Error` synchronously when `name` is not registered (no node is
|
|
1301
|
+
* constructed — the caller gets a pre-wiring failure rather than a
|
|
1302
|
+
* silent ERROR wave on an empty graph).
|
|
1303
|
+
*/
|
|
1304
|
+
executeReactive(name: string, args: Record<string, unknown>): Node<unknown>;
|
|
1208
1305
|
getDefinition(name: string): ToolDefinition | undefined;
|
|
1209
1306
|
}
|
|
1210
1307
|
declare function toolRegistry(name: string, opts?: ToolRegistryOptions): ToolRegistryGraph;
|
|
@@ -1406,6 +1503,15 @@ type HandoffOptions = {
|
|
|
1406
1503
|
* @returns Node emitting the specialist's output when the gate is open, or
|
|
1407
1504
|
* `from`'s value when the gate is closed. Null when `from` is null.
|
|
1408
1505
|
*
|
|
1506
|
+
* **Performance caveat (Wave A Unit 5):** the specialist is mounted per
|
|
1507
|
+
* source emission — each `v != null` DATA on `from` allocates a fresh
|
|
1508
|
+
* `state<T>(v)` + invokes `toFactory`, and switchMap cancels the prior
|
|
1509
|
+
* branch. For per-turn routing (≤1 emit/sec) this is negligible. For
|
|
1510
|
+
* high-frequency sources (per-token routing, tight event loops), batch
|
|
1511
|
+
* upstream (e.g. via `audit`, `throttle`, or `distinctUntilChanged`) before
|
|
1512
|
+
* handing off — each mount/unmount cycle spins up full subgraphs
|
|
1513
|
+
* (`messagesNode` + adapter bridge + output for a `promptNode` specialist).
|
|
1514
|
+
*
|
|
1409
1515
|
* @category patterns.ai
|
|
1410
1516
|
*/
|
|
1411
1517
|
declare function handoff<T>(from: NodeInput<T | null>, toFactory: (input: Node<T>) => Node<T | null>, opts?: HandoffOptions): Node<T | null>;
|
|
@@ -1739,22 +1845,23 @@ type GraphFromSpecOptions = {
|
|
|
1739
1845
|
model?: string;
|
|
1740
1846
|
temperature?: number;
|
|
1741
1847
|
maxTokens?: number;
|
|
1742
|
-
/**
|
|
1743
|
-
|
|
1848
|
+
/** Fn/source catalog for resolving named node factories from the LLM-generated spec. */
|
|
1849
|
+
catalog?: GraphSpecCatalog;
|
|
1744
1850
|
/** Extra instructions appended to the system prompt. */
|
|
1745
1851
|
systemPromptExtra?: string;
|
|
1746
1852
|
};
|
|
1747
1853
|
/**
|
|
1748
1854
|
* Ask an LLM to compose a Graph from a natural-language description.
|
|
1749
1855
|
*
|
|
1750
|
-
* The LLM returns a JSON
|
|
1751
|
-
*
|
|
1856
|
+
* The LLM returns a JSON {@link GraphSpec} which is validated, catalog-expanded,
|
|
1857
|
+
* and instantiated via {@link compileSpec} (gains catalog validation, template
|
|
1858
|
+
* expansion, and feedback wiring that `Graph.fromSnapshot` bypasses).
|
|
1752
1859
|
*
|
|
1753
1860
|
* @param naturalLanguage - The problem/use-case description.
|
|
1754
1861
|
* @param adapter - LLM adapter for the generation call.
|
|
1755
|
-
* @param opts - Model options and optional
|
|
1862
|
+
* @param opts - Model options and optional catalog for named node factories.
|
|
1756
1863
|
* @returns A constructed Graph.
|
|
1757
|
-
* @throws On invalid LLM output or
|
|
1864
|
+
* @throws On invalid LLM output, validation failure, or unresolvable deps.
|
|
1758
1865
|
*/
|
|
1759
1866
|
declare function graphFromSpec(naturalLanguage: string, adapter: LLMAdapter, opts?: GraphFromSpecOptions): Promise<Graph>;
|
|
1760
1867
|
|
|
@@ -1975,9 +2082,9 @@ type index_RetrievalEntry<TMem> = RetrievalEntry<TMem>;
|
|
|
1975
2082
|
type index_RetrievalPipelineOptions<TMem> = RetrievalPipelineOptions<TMem>;
|
|
1976
2083
|
type index_RetrievalQuery = RetrievalQuery;
|
|
1977
2084
|
type index_RetrievalTrace<TMem> = RetrievalTrace<TMem>;
|
|
2085
|
+
type index_StampedDelta = StampedDelta;
|
|
1978
2086
|
type index_StrategyOperation = StrategyOperation;
|
|
1979
2087
|
type index_StrategyPlan = StrategyPlan;
|
|
1980
|
-
type index_StreamChunk = StreamChunk;
|
|
1981
2088
|
declare const index_StreamDelta: typeof StreamDelta;
|
|
1982
2089
|
type index_StreamingPromptNodeHandle<T> = StreamingPromptNodeHandle<T>;
|
|
1983
2090
|
type index_StreamingPromptNodeOptions = StreamingPromptNodeOptions;
|
|
@@ -2014,7 +2121,6 @@ declare const index_createAdapter: typeof createAdapter;
|
|
|
2014
2121
|
declare const index_createCapabilitiesRegistry: typeof createCapabilitiesRegistry;
|
|
2015
2122
|
declare const index_createPricingRegistry: typeof createPricingRegistry;
|
|
2016
2123
|
declare const index_dryRunAdapter: typeof dryRunAdapter;
|
|
2017
|
-
declare const index_dryRunPreset: typeof dryRunPreset;
|
|
2018
2124
|
declare const index_fallbackAdapter: typeof fallbackAdapter;
|
|
2019
2125
|
declare const index_fromLLM: typeof fromLLM;
|
|
2020
2126
|
declare const index_frozenContext: typeof frozenContext;
|
|
@@ -2030,6 +2136,7 @@ declare const index_llmExtractor: typeof llmExtractor;
|
|
|
2030
2136
|
declare const index_observableAdapter: typeof observableAdapter;
|
|
2031
2137
|
declare const index_openAICompatAdapter: typeof openAICompatAdapter;
|
|
2032
2138
|
declare const index_parseRateLimitFromError: typeof parseRateLimitFromError;
|
|
2139
|
+
declare const index_pricingFor: typeof pricingFor;
|
|
2033
2140
|
declare const index_promptNode: typeof promptNode;
|
|
2034
2141
|
declare const index_redactor: typeof redactor;
|
|
2035
2142
|
declare const index_registryPricing: typeof registryPricing;
|
|
@@ -2038,6 +2145,7 @@ declare const index_streamExtractor: typeof streamExtractor;
|
|
|
2038
2145
|
declare const index_streamingPromptNode: typeof streamingPromptNode;
|
|
2039
2146
|
declare const index_suggestStrategy: typeof suggestStrategy;
|
|
2040
2147
|
declare const index_systemPromptBuilder: typeof systemPromptBuilder;
|
|
2148
|
+
declare const index_tier: typeof tier;
|
|
2041
2149
|
declare const index_toolCallExtractor: typeof toolCallExtractor;
|
|
2042
2150
|
declare const index_toolRegistry: typeof toolRegistry;
|
|
2043
2151
|
declare const index_toolSelector: typeof toolSelector;
|
|
@@ -2051,7 +2159,7 @@ declare const index_withRetry: typeof withRetry;
|
|
|
2051
2159
|
declare const index_withTimeout: typeof withTimeout;
|
|
2052
2160
|
declare const index_zeroPrice: typeof zeroPrice;
|
|
2053
2161
|
declare namespace index {
|
|
2054
|
-
export { index_AdapterProvider as AdapterProvider, type index_AdapterStats as AdapterStats, index_AdapterTier as AdapterTier, type index_AdmissionScore3DOptions as AdmissionScore3DOptions, type index_AdmissionScores as AdmissionScores, index_AgentLoopGraph as AgentLoopGraph, type index_AgentLoopOptions as AgentLoopOptions, type index_AgentLoopStatus as AgentLoopStatus, type index_AgentMemoryGraph as AgentMemoryGraph, type index_AgentMemoryOptions as AgentMemoryOptions, index_AllTiersExhaustedError as AllTiersExhaustedError, type index_AnthropicAdapterOptions as AnthropicAdapterOptions, type index_AnthropicSdkLike as AnthropicSdkLike, type index_BudgetCaps as BudgetCaps, index_BudgetExhaustedError as BudgetExhaustedError, type index_BudgetGateBundle as BudgetGateBundle, type index_BudgetTotals as BudgetTotals, type index_CallStatsEvent as CallStatsEvent, index_CapabilitiesRegistry as CapabilitiesRegistry, index_CascadeExhaustionReport as CascadeExhaustionReport, index_CascadingLlmAdapterOptions as CascadingLlmAdapterOptions, index_ChatMessage as ChatMessage, index_ChatStreamGraph as ChatStreamGraph, type index_ChatStreamOptions as ChatStreamOptions, index_CircuitOpenError as CircuitOpenError, type index_ContentDecision as ContentDecision, type index_ContentGateOptions as ContentGateOptions, type index_CostMeterOptions as CostMeterOptions, type index_CostMeterReading as CostMeterReading, index_CreateAdapterOptions as CreateAdapterOptions, index_DEFAULT_DECAY_RATE as DEFAULT_DECAY_RATE, type index_DryRunAdapterOptions as DryRunAdapterOptions, type index_ExtractedToolCall as ExtractedToolCall, index_FallbackAdapterOptions as FallbackAdapterOptions, index_FallbackFixture as FallbackFixture, index_FallbackMissError as FallbackMissError, index_FallbackMissPolicy as FallbackMissPolicy, type index_FromLLMOptions as FromLLMOptions, type index_FrozenContextOptions as FrozenContextOptions, type index_GatedStreamHandle as GatedStreamHandle, type index_GatedStreamOptions as GatedStreamOptions, type index_GaugesAsContextOptions as GaugesAsContextOptions, type index_GoogleAdapterOptions as GoogleAdapterOptions, type index_GoogleSdkLike as GoogleSdkLike, type index_GraphDefValidation as GraphDefValidation, type index_GraphFromSpecOptions as GraphFromSpecOptions, type index_HandoffOptions as HandoffOptions, type index_HttpErrorLike as HttpErrorLike, type index_KeywordFlag as KeywordFlag, type index_KeywordFlagExtractorOptions as KeywordFlagExtractorOptions, type index_KnobsAsToolsResult as KnobsAsToolsResult, index_LLMAdapter as LLMAdapter, type index_LLMConsolidatorOptions as LLMConsolidatorOptions, type index_LLMExtractorOptions as LLMExtractorOptions, index_LLMInvokeOptions as LLMInvokeOptions, index_LLMResponse as LLMResponse, index_LLMTimeoutError as LLMTimeoutError, type index_McpToolSchema as McpToolSchema, type index_MemoryTier as MemoryTier, type index_MemoryTiersBundle as MemoryTiersBundle, type index_MemoryTiersOptions as MemoryTiersOptions, index_ModelCapabilities as ModelCapabilities, index_ModelFeatures as ModelFeatures, index_ModelLimits as ModelLimits, index_ModelPricing as ModelPricing, index_OpenAICompatAdapterOptions as OpenAICompatAdapterOptions, index_OpenAICompatPreset as OpenAICompatPreset, index_OpenAISdkLike as OpenAISdkLike, type index_OpenAIToolSchema as OpenAIToolSchema, index_PriceBreakdown as PriceBreakdown, index_PricingFn as PricingFn, index_PricingRegistry as PricingRegistry, type index_PromptNodeOptions as PromptNodeOptions, index_Rate as Rate, type index_RedactorOptions as RedactorOptions, index_ReplayCacheKeyContext as ReplayCacheKeyContext, index_ReplayCacheMissError as ReplayCacheMissError, index_ReplayCacheMode as ReplayCacheMode, type index_ResilientAdapterBundle as ResilientAdapterBundle, type index_ResilientAdapterOptions as ResilientAdapterOptions, type index_RetrievalEntry as RetrievalEntry, type index_RetrievalPipelineOptions as RetrievalPipelineOptions, type index_RetrievalQuery as RetrievalQuery, type index_RetrievalTrace as RetrievalTrace, type
|
|
2162
|
+
export { index_AdapterProvider as AdapterProvider, type index_AdapterStats as AdapterStats, index_AdapterTier as AdapterTier, type index_AdmissionScore3DOptions as AdmissionScore3DOptions, type index_AdmissionScores as AdmissionScores, index_AgentLoopGraph as AgentLoopGraph, type index_AgentLoopOptions as AgentLoopOptions, type index_AgentLoopStatus as AgentLoopStatus, type index_AgentMemoryGraph as AgentMemoryGraph, type index_AgentMemoryOptions as AgentMemoryOptions, index_AllTiersExhaustedError as AllTiersExhaustedError, type index_AnthropicAdapterOptions as AnthropicAdapterOptions, type index_AnthropicSdkLike as AnthropicSdkLike, type index_BudgetCaps as BudgetCaps, index_BudgetExhaustedError as BudgetExhaustedError, type index_BudgetGateBundle as BudgetGateBundle, type index_BudgetTotals as BudgetTotals, type index_CallStatsEvent as CallStatsEvent, index_CapabilitiesRegistry as CapabilitiesRegistry, index_CascadeExhaustionReport as CascadeExhaustionReport, index_CascadingLlmAdapterOptions as CascadingLlmAdapterOptions, index_ChatMessage as ChatMessage, index_ChatStreamGraph as ChatStreamGraph, type index_ChatStreamOptions as ChatStreamOptions, index_CircuitOpenError as CircuitOpenError, type index_ContentDecision as ContentDecision, type index_ContentGateOptions as ContentGateOptions, type index_CostMeterOptions as CostMeterOptions, type index_CostMeterReading as CostMeterReading, index_CreateAdapterOptions as CreateAdapterOptions, index_DEFAULT_DECAY_RATE as DEFAULT_DECAY_RATE, type index_DryRunAdapterOptions as DryRunAdapterOptions, type index_ExtractedToolCall as ExtractedToolCall, index_FallbackAdapterOptions as FallbackAdapterOptions, index_FallbackFixture as FallbackFixture, index_FallbackMissError as FallbackMissError, index_FallbackMissPolicy as FallbackMissPolicy, type index_FromLLMOptions as FromLLMOptions, type index_FrozenContextOptions as FrozenContextOptions, type index_GatedStreamHandle as GatedStreamHandle, type index_GatedStreamOptions as GatedStreamOptions, type index_GaugesAsContextOptions as GaugesAsContextOptions, type index_GoogleAdapterOptions as GoogleAdapterOptions, type index_GoogleSdkLike as GoogleSdkLike, type index_GraphDefValidation as GraphDefValidation, type index_GraphFromSpecOptions as GraphFromSpecOptions, type index_HandoffOptions as HandoffOptions, type index_HttpErrorLike as HttpErrorLike, type index_KeywordFlag as KeywordFlag, type index_KeywordFlagExtractorOptions as KeywordFlagExtractorOptions, type index_KnobsAsToolsResult as KnobsAsToolsResult, index_LLMAdapter as LLMAdapter, type index_LLMConsolidatorOptions as LLMConsolidatorOptions, type index_LLMExtractorOptions as LLMExtractorOptions, index_LLMInvokeOptions as LLMInvokeOptions, index_LLMResponse as LLMResponse, index_LLMTimeoutError as LLMTimeoutError, type index_McpToolSchema as McpToolSchema, type index_MemoryTier as MemoryTier, type index_MemoryTiersBundle as MemoryTiersBundle, type index_MemoryTiersOptions as MemoryTiersOptions, index_ModelCapabilities as ModelCapabilities, index_ModelFeatures as ModelFeatures, index_ModelLimits as ModelLimits, index_ModelPricing as ModelPricing, index_OpenAICompatAdapterOptions as OpenAICompatAdapterOptions, index_OpenAICompatPreset as OpenAICompatPreset, index_OpenAISdkLike as OpenAISdkLike, type index_OpenAIToolSchema as OpenAIToolSchema, index_PriceBreakdown as PriceBreakdown, index_PricingFn as PricingFn, index_PricingRegistry as PricingRegistry, type index_PromptNodeOptions as PromptNodeOptions, index_Rate as Rate, type index_RedactorOptions as RedactorOptions, index_ReplayCacheKeyContext as ReplayCacheKeyContext, index_ReplayCacheMissError as ReplayCacheMissError, index_ReplayCacheMode as ReplayCacheMode, type index_ResilientAdapterBundle as ResilientAdapterBundle, type index_ResilientAdapterOptions as ResilientAdapterOptions, type index_RetrievalEntry as RetrievalEntry, type index_RetrievalPipelineOptions as RetrievalPipelineOptions, type index_RetrievalQuery as RetrievalQuery, type index_RetrievalTrace as RetrievalTrace, type index_StampedDelta as StampedDelta, type index_StrategyOperation as StrategyOperation, type index_StrategyPlan as StrategyPlan, index_StreamDelta as StreamDelta, type index_StreamingPromptNodeHandle as StreamingPromptNodeHandle, type index_StreamingPromptNodeOptions as StreamingPromptNodeOptions, type index_SuggestStrategyOptions as SuggestStrategyOptions, type index_SystemPromptHandle as SystemPromptHandle, index_TieredRate as TieredRate, index_TokenUsage as TokenUsage, index_ToolCall as ToolCall, index_ToolDefinition as ToolDefinition, index_ToolRegistryGraph as ToolRegistryGraph, type index_ToolRegistryOptions as ToolRegistryOptions, type index_ToolResult as ToolResult, type index_ToolSelectorOptions as ToolSelectorOptions, type index_WithBreakerOptions as WithBreakerOptions, type index_WithBudgetGateOptions as WithBudgetGateOptions, type index_WithDryRunBundle as WithDryRunBundle, type index_WithDryRunOptions as WithDryRunOptions, type index_WithRateLimiterOptions as WithRateLimiterOptions, index_WithReplayCacheOptions as WithReplayCacheOptions, type index_WithRetryOptions as WithRetryOptions, index_admissionFilter3D as admissionFilter3D, index_agentLoop as agentLoop, index_agentMemory as agentMemory, index_anthropicAdapter as anthropicAdapter, index_canonicalJson as canonicalJson, index_cascadingLlmAdapter as cascadingLlmAdapter, index_chatStream as chatStream, index_composePricing as composePricing, index_computePrice as computePrice, index_contentGate as contentGate, index_costMeterExtractor as costMeterExtractor, index_createAdapter as createAdapter, index_createCapabilitiesRegistry as createCapabilitiesRegistry, index_createPricingRegistry as createPricingRegistry, index_dryRunAdapter as dryRunAdapter, index_fallbackAdapter as fallbackAdapter, index_fromLLM as fromLLM, index_frozenContext as frozenContext, index_gatedStream as gatedStream, index_gaugesAsContext as gaugesAsContext, index_googleAdapter as googleAdapter, index_graphFromSpec as graphFromSpec, index_handoff as handoff, index_keywordFlagExtractor as keywordFlagExtractor, index_knobsAsTools as knobsAsTools, index_llmConsolidator as llmConsolidator, index_llmExtractor as llmExtractor, index_observableAdapter as observableAdapter, index_openAICompatAdapter as openAICompatAdapter, index_parseRateLimitFromError as parseRateLimitFromError, index_pricingFor as pricingFor, index_promptNode as promptNode, index_redactor as redactor, index_registryPricing as registryPricing, index_resilientAdapter as resilientAdapter, index_streamExtractor as streamExtractor, index_streamingPromptNode as streamingPromptNode, index_suggestStrategy as suggestStrategy, index_systemPromptBuilder as systemPromptBuilder, index_tier as tier, index_toolCallExtractor as toolCallExtractor, index_toolRegistry as toolRegistry, index_toolSelector as toolSelector, index_validateGraphDef as validateGraphDef, index_withBreaker as withBreaker, index_withBudgetGate as withBudgetGate, index_withDryRun as withDryRun, index_withRateLimiter as withRateLimiter, index_withReplayCache as withReplayCache, index_withRetry as withRetry, index_withTimeout as withTimeout, index_zeroPrice as zeroPrice };
|
|
2055
2163
|
}
|
|
2056
2164
|
|
|
2057
|
-
export { type RetrievalQuery as $, type AdapterStats as A, type BudgetCaps as B, type CallStatsEvent as C, DEFAULT_DECAY_RATE as D, type ExtractedToolCall as E, type FromLLMOptions as F, type GatedStreamHandle as G, type GraphFromSpecOptions as H, type HandoffOptions as I, type HttpErrorLike as J, type KeywordFlag as K, type KeywordFlagExtractorOptions as L, type KnobsAsToolsResult as M, type LLMConsolidatorOptions as N, type LLMExtractorOptions as O, LLMTimeoutError as P, type McpToolSchema as Q, type MemoryTier as R, type MemoryTiersBundle as S, type MemoryTiersOptions as T, type OpenAIToolSchema as U, type PromptNodeOptions as V, type RedactorOptions as W, type ResilientAdapterBundle as X, type ResilientAdapterOptions as Y, type RetrievalEntry as Z, type RetrievalPipelineOptions as _, type AdmissionScore3DOptions as a, type RetrievalTrace as a0, type
|
|
2165
|
+
export { type RetrievalQuery as $, type AdapterStats as A, type BudgetCaps as B, type CallStatsEvent as C, DEFAULT_DECAY_RATE as D, type ExtractedToolCall as E, type FromLLMOptions as F, type GatedStreamHandle as G, type GraphFromSpecOptions as H, type HandoffOptions as I, type HttpErrorLike as J, type KeywordFlag as K, type KeywordFlagExtractorOptions as L, type KnobsAsToolsResult as M, type LLMConsolidatorOptions as N, type LLMExtractorOptions as O, LLMTimeoutError as P, type McpToolSchema as Q, type MemoryTier as R, type MemoryTiersBundle as S, type MemoryTiersOptions as T, type OpenAIToolSchema as U, type PromptNodeOptions as V, type RedactorOptions as W, type ResilientAdapterBundle as X, type ResilientAdapterOptions as Y, type RetrievalEntry as Z, type RetrievalPipelineOptions as _, type AdmissionScore3DOptions as a, type RetrievalTrace as a0, type StampedDelta as a1, type StrategyOperation as a2, type StrategyPlan as a3, type StreamingPromptNodeHandle as a4, type StreamingPromptNodeOptions as a5, type SuggestStrategyOptions as a6, type SystemPromptHandle as a7, ToolRegistryGraph as a8, type ToolRegistryOptions as a9, llmExtractor as aA, observableAdapter as aB, parseRateLimitFromError as aC, promptNode as aD, redactor as aE, resilientAdapter as aF, streamExtractor as aG, streamingPromptNode as aH, suggestStrategy as aI, systemPromptBuilder as aJ, toolCallExtractor as aK, toolRegistry as aL, toolSelector as aM, validateGraphDef as aN, withBreaker as aO, withBudgetGate as aP, withDryRun as aQ, withRateLimiter as aR, withRetry as aS, withTimeout as aT, type ToolResult as aa, type ToolSelectorOptions as ab, type WithBreakerOptions as ac, type WithBudgetGateOptions as ad, type WithDryRunBundle as ae, type WithDryRunOptions as af, type WithRateLimiterOptions as ag, type WithRetryOptions as ah, admissionFilter3D as ai, agentLoop as aj, agentMemory as ak, anthropicAdapter as al, chatStream as am, contentGate as an, costMeterExtractor as ao, dryRunAdapter as ap, fromLLM as aq, frozenContext as ar, gatedStream as as, gaugesAsContext as at, googleAdapter as au, graphFromSpec as av, handoff as aw, keywordFlagExtractor as ax, knobsAsTools as ay, llmConsolidator as az, type AdmissionScores as b, AgentLoopGraph as c, type AgentLoopOptions as d, type AgentLoopStatus as e, type AgentMemoryGraph as f, type AgentMemoryOptions as g, type AnthropicAdapterOptions as h, index as i, type AnthropicSdkLike as j, BudgetExhaustedError as k, type BudgetGateBundle as l, type BudgetTotals as m, ChatStreamGraph as n, type ChatStreamOptions as o, type ContentDecision as p, type ContentGateOptions as q, type CostMeterOptions as r, type CostMeterReading as s, type DryRunAdapterOptions as t, type FrozenContextOptions as u, type GatedStreamOptions as v, type GaugesAsContextOptions as w, type GoogleAdapterOptions as x, type GoogleSdkLike as y, type GraphDefValidation as z };
|