@graphrefly/graphrefly 0.1.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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/dist/chunk-5X3LAO3B.js +1571 -0
  4. package/dist/chunk-5X3LAO3B.js.map +1 -0
  5. package/dist/chunk-6W5SGIGB.js +1793 -0
  6. package/dist/chunk-6W5SGIGB.js.map +1 -0
  7. package/dist/chunk-CP6MNKAA.js +97 -0
  8. package/dist/chunk-CP6MNKAA.js.map +1 -0
  9. package/dist/chunk-HP7OKEOE.js +107 -0
  10. package/dist/chunk-HP7OKEOE.js.map +1 -0
  11. package/dist/chunk-KWXPDASV.js +781 -0
  12. package/dist/chunk-KWXPDASV.js.map +1 -0
  13. package/dist/chunk-O3PI7W45.js +68 -0
  14. package/dist/chunk-O3PI7W45.js.map +1 -0
  15. package/dist/chunk-QW7H3ICI.js +1372 -0
  16. package/dist/chunk-QW7H3ICI.js.map +1 -0
  17. package/dist/chunk-VPS7L64N.js +4785 -0
  18. package/dist/chunk-VPS7L64N.js.map +1 -0
  19. package/dist/chunk-Z4Y4FMQN.js +1097 -0
  20. package/dist/chunk-Z4Y4FMQN.js.map +1 -0
  21. package/dist/compat/nestjs/index.cjs +4883 -0
  22. package/dist/compat/nestjs/index.cjs.map +1 -0
  23. package/dist/compat/nestjs/index.d.cts +7 -0
  24. package/dist/compat/nestjs/index.d.ts +7 -0
  25. package/dist/compat/nestjs/index.js +84 -0
  26. package/dist/compat/nestjs/index.js.map +1 -0
  27. package/dist/core/index.cjs +1632 -0
  28. package/dist/core/index.cjs.map +1 -0
  29. package/dist/core/index.d.cts +2 -0
  30. package/dist/core/index.d.ts +2 -0
  31. package/dist/core/index.js +90 -0
  32. package/dist/core/index.js.map +1 -0
  33. package/dist/extra/index.cjs +6885 -0
  34. package/dist/extra/index.cjs.map +1 -0
  35. package/dist/extra/index.d.cts +5 -0
  36. package/dist/extra/index.d.ts +5 -0
  37. package/dist/extra/index.js +290 -0
  38. package/dist/extra/index.js.map +1 -0
  39. package/dist/graph/index.cjs +3225 -0
  40. package/dist/graph/index.cjs.map +1 -0
  41. package/dist/graph/index.d.cts +3 -0
  42. package/dist/graph/index.d.ts +3 -0
  43. package/dist/graph/index.js +25 -0
  44. package/dist/graph/index.js.map +1 -0
  45. package/dist/graph-CL_ZDAj9.d.cts +605 -0
  46. package/dist/graph-D18qmsNm.d.ts +605 -0
  47. package/dist/index-B6SsZs2h.d.cts +3463 -0
  48. package/dist/index-B7eOdgEx.d.ts +449 -0
  49. package/dist/index-BHUvlQ3v.d.ts +3463 -0
  50. package/dist/index-BtK55IE2.d.ts +231 -0
  51. package/dist/index-BvhgZRHK.d.cts +231 -0
  52. package/dist/index-Bvy_6CaN.d.ts +452 -0
  53. package/dist/index-C3BMRmmp.d.cts +449 -0
  54. package/dist/index-C5mqLhMX.d.cts +452 -0
  55. package/dist/index-CP_QvbWu.d.ts +940 -0
  56. package/dist/index-D_geH2Bm.d.cts +940 -0
  57. package/dist/index.cjs +14843 -0
  58. package/dist/index.cjs.map +1 -0
  59. package/dist/index.d.cts +1517 -0
  60. package/dist/index.d.ts +1517 -0
  61. package/dist/index.js +3649 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/meta-BsF6Sag9.d.cts +607 -0
  64. package/dist/meta-BsF6Sag9.d.ts +607 -0
  65. package/dist/patterns/reactive-layout/index.cjs +4143 -0
  66. package/dist/patterns/reactive-layout/index.cjs.map +1 -0
  67. package/dist/patterns/reactive-layout/index.d.cts +3 -0
  68. package/dist/patterns/reactive-layout/index.d.ts +3 -0
  69. package/dist/patterns/reactive-layout/index.js +38 -0
  70. package/dist/patterns/reactive-layout/index.js.map +1 -0
  71. package/dist/reactive-log-BfvfNWQh.d.cts +137 -0
  72. package/dist/reactive-log-ohLmTXoZ.d.ts +137 -0
  73. package/package.json +256 -0
@@ -0,0 +1,1517 @@
1
+ import { N as Node, A as Actor, a as NodeOptions, b as NodeActions, c as NodeFn } from './meta-BsF6Sag9.cjs';
2
+ export { C as COMPLETE, D as DATA, d as DEFAULT_ACTOR, e as DIRTY, f as DescribeNodeOutput, E as ERROR, G as GuardAction, g as GuardDenied, h as GuardDeniedDetails, H as HashFn, I as INVALIDATE, M as Message, i as Messages, j as NodeDescribeKind, k as NodeGuard, l as NodeSink, m as NodeStatus, n as NodeTransportOptions, o as NodeVersionInfo, O as OnMessageHandler, P as PAUSE, p as PolicyAllow, q as PolicyDeny, r as PolicyRuleData, R as RESOLVED, s as RESUME, S as SubscribeHints, T as TEARDOWN, V as V0, t as V1, u as VersioningLevel, v as VersioningOptions, w as accessHintForGuard, x as advanceVersion, y as createVersioning, z as defaultHash, B as describeNode, F as isKnownMessageType, J as isPhase2Message, K as isTerminalMessage, L as isV1, Q as knownMessageTypes, U as messageTier, W as metaSnapshot, X as node, Y as normalizeActor, Z as policy, _ as policyFromRules, $ as propagatesToMeta } from './meta-BsF6Sag9.cjs';
3
+ import { i as index$a, c as cqrs } from './index-D_geH2Bm.cjs';
4
+ import { Ref, WatchSource } from 'vue';
5
+ import { G as Graph, a as GraphOptions, b as GraphAutoCheckpointHandle, A as AutoCheckpointAdapter, c as GraphAutoCheckpointOptions } from './graph-CL_ZDAj9.cjs';
6
+ export { D as DescribeFilter, d as GRAPH_META_SEGMENT, e as GraphActorOptions, f as GraphCheckpointRecord, g as GraphDescribeOutput, h as GraphDiagramDirection, i as GraphDiagramOptions, j as GraphDiffChange, k as GraphDiffResult, l as GraphDumpOptions, m as GraphFactoryContext, n as GraphNodeFactory, o as GraphObserveAll, p as GraphObserveOne, q as GraphPersistSnapshot, r as GraphSpyHandle, s as GraphSpyOptions, t as GraphSpyTheme, u as GraphSpyThemeName, O as ObserveEvent, v as ObserveOptions, w as ObserveResult, R as ReachableDirection, x as ReachableOptions, T as TraceEntry, y as reachable } from './graph-CL_ZDAj9.cjs';
7
+ export { D as DynGet, a as DynamicNodeFn, b as DynamicNodeImpl, c as DynamicNodeOptions, P as PipeOperator, d as batch, i as core, e as derived, f as dynamicNode, g as effect, h as emitWithBatch, j as isBatching, m as monotonicNs, p as partitionForBatch, k as pipe, l as producer, s as state, w as wallClockNs } from './index-C5mqLhMX.cjs';
8
+ import { N as NodeInput, D as DistillBundle, E as Extraction, R as ReactiveListSnapshot, a as ReactiveMapSnapshot } from './index-B6SsZs2h.cjs';
9
+ export { A as AdapterHandlers, b as AsyncSourceOpts, B as BackoffPreset, c as BackoffStrategy, d as BatchMessage, e as BridgeMessage, C as CSVRow, f as CheckpointAdapter, g as CircuitBreaker, h as CircuitBreakerOptions, i as CircuitOpenError, j as CircuitState, k as ClickHouseClientLike, l as ClickHouseRow, m as CronSchedule, n as DictCheckpointAdapter, o as DistillOptions, p as ErrorMessage, q as EventTargetLike, r as ExponentialBackoffOptions, F as FSEvent, s as FSEventType, t as FileCheckpointAdapter, u as FromCSVOptions, v as FromClickHouseWatchOptions, w as FromCronOptions, x as FromFSWatchOptions, y as FromGitHookOptions, z as FromHTTPOptions, G as FromKafkaOptions, H as FromMCPOptions, I as FromNDJSONOptions, J as FromOTelOptions, K as FromPrometheusOptions, L as FromRedisStreamOptions, M as FromStatsDOptions, O as FromSyslogOptions, P as GitEvent, Q as GitHookType, S as HTTPBundle, T as IndexRow, U as IndexedDbCheckpointSpec, V as InitMessage, W as JitterMode, X as KafkaConsumerLike, Y as KafkaMessage, Z as KafkaProducerLike, _ as MCPClientLike, $ as MemoryCheckpointAdapter, a0 as MergeMapOptions, a1 as NS_PER_MS, a2 as NS_PER_SEC, a3 as OTelBundle, a4 as OTelLog, a5 as OTelMetric, a6 as OTelRegister, a7 as OTelSpan, a8 as PrometheusMetric, a9 as PubSubHub, aa as ReactiveIndexBundle, ab as ReactiveIndexOptions, ac as ReactiveIndexSnapshot, ad as ReactiveListBundle, ae as ReactiveListOptions, af as ReactiveMapBundle, ag as ReactiveMapOptions, ah as ReadyMessage, ai as RedisClientLike, aj as RedisStreamEntry, ak as RetryOptions, al as SignalMessage, am as SinkTransportError, an as SqliteCheckpointAdapter, ao as StatsDMetric, ap as StatsDRegister, aq as StatusValue, ar as SyslogMessage, as as SyslogRegister, at as TapObserver, au as ThrottleOptions, av as ToKafkaOptions, aw as ToRedisStreamOptions, ax as ToSSEOptions, ay as ToWebSocketOptions, az as ToWebSocketTransportError, aA as TokenBucket, aB as ValueMessage, aC as VerifiableBundle, aD as VerifiableOptions, aE as VerifyValue, aF as WatermarkController, aG as WatermarkOptions, aH as WebSocketLike, aI as WebSocketMessageEventLike, aJ as WebSocketRegister, aK as WebhookRegister, aL as WithBreakerBundle, aM as WithStatusBundle, aN as WorkerBridge, aO as WorkerBridgeOptions, aP as WorkerSelfHandle, aQ as WorkerSelfOptions, aR as WorkerTransport, aS as audit, aT as buffer, aU as bufferCount, aV as bufferTime, aW as cached, aX as catchError, aY as checkpointNodeValue, aZ as circuitBreaker, a_ as combine, a$ as combineLatest, b0 as concat, b1 as concatMap, b2 as constant, b3 as createTransport, b4 as createWatermarkController, b5 as debounce, b6 as debounceTime, b7 as decorrelatedJitter, b8 as delay, b9 as deserializeError, ba as distill, bb as distinctUntilChanged, bc as elementAt, bd as empty, be as escapeRegexChar, bf as exhaustMap, bg as exponential, bh as extra, bi as fibonacci, bj as filter, bk as find, bl as first, bm as firstValueFrom, bn as flatMap, bo as forEach, bp as fromAny, bq as fromAsyncIter, br as fromCSV, bs as fromClickHouseWatch, bt as fromCron, bu as fromEvent, bv as fromFSWatch, bw as fromGitHook, bx as fromHTTP, by as fromIDBRequest, bz as fromIDBTransaction, bA as fromIter, bB as fromKafka, bC as fromMCP, bD as fromNDJSON, bE as fromOTel, bF as fromPrometheus, bG as fromPromise, bH as fromRedisStream, bI as fromStatsD, bJ as fromSyslog, bK as fromTimer, bL as fromWebSocket, bM as fromWebhook, bN as gate, bO as globToRegExp, bP as interval, bQ as last, bR as linear, bS as map, bT as matchesAnyPattern, bU as matchesCron, bV as merge, bW as mergeMap, bX as nameToSignal, bY as never, bZ as of, b_ as pairwise, b$ as parseCron, c0 as parsePrometheusText, c1 as parseStatsD, c2 as parseSyslog, c3 as pausable, c4 as pubsub, c5 as race, c6 as rateLimiter, c7 as reactiveIndex, c8 as reactiveList, c9 as reactiveMap, ca as reduce, cb as repeat, cc as replay, cd as rescue, ce as resolveBackoffPreset, cf as restoreGraphCheckpoint, cg as restoreGraphCheckpointIndexedDb, ch as retry, ci as sample, cj as saveGraphCheckpoint, ck as saveGraphCheckpointIndexedDb, cl as scan, cm as serializeError, cn as share, co as shareReplay, cp as signalToName, cq as skip, cr as startWith, cs as switchMap, ct as take, cu as takeUntil, cv as takeWhile, cw as tap, cx as throttle, cy as throttleTime, cz as throwError, cA as timeout, cB as toArray, cC as toKafka, cD as toRedisStream, cE as toSSE, cF as toWebSocket, cG as tokenBucket, cH as tokenTracker, cI as verifiable, cJ as window, cK as windowCount, cL as windowTime, cM as withBreaker, cN as withLatestFrom, cO as withMaxAttempts, cP as withStatus, cQ as workerBridge, cR as workerSelf, cS as zip } from './index-B6SsZs2h.cjs';
10
+ export { D as DeltaCheckpoint, E as EvictedSubgraphInfo, a as EvictionPolicy, G as GraphCodec, J as JsonCodec, L as LazyGraphCodec, W as WALEntry, c as createDagCborCodec, b as createDagCborZstdCodec, i as graph, n as negotiateCodec, r as replayWAL } from './index-BvhgZRHK.cjs';
11
+ import { R as ReactiveLogSnapshot } from './reactive-log-BfvfNWQh.cjs';
12
+ export { a as ReactiveLogBundle, b as ReactiveLogOptions, l as logSlice, o as observeGraph$, c as observeNode$, r as reactiveLog, t as toMessages$, d as toObservable } from './reactive-log-BfvfNWQh.cjs';
13
+ import { i as index$b } from './index-C3BMRmmp.cjs';
14
+ import '@nestjs/common';
15
+ import '@nestjs/core';
16
+ import 'rxjs';
17
+
18
+ /**
19
+ * Options for creating an atom.
20
+ *
21
+ * @category compat
22
+ */
23
+ interface AtomOptions {
24
+ /** Optional identifier for the underlying node. */
25
+ name?: string;
26
+ /** Optional companion meta nodes. */
27
+ meta?: Record<string, unknown>;
28
+ }
29
+ /**
30
+ * A read-only Jotai-compatible atom.
31
+ *
32
+ * @category compat
33
+ */
34
+ interface ReadableAtom<T> {
35
+ /** Returns the current cached value. */
36
+ get(): T;
37
+ /** Subscribes to value changes. Returns an unsubscribe function. */
38
+ subscribe(callback: (value: T) => void): () => void;
39
+ /** Access to companion meta nodes. */
40
+ readonly meta: Record<string, Node>;
41
+ /** @internal The underlying GraphReFly node. */
42
+ _node: Node<T>;
43
+ }
44
+ /**
45
+ * A writable Jotai-compatible atom.
46
+ *
47
+ * @category compat
48
+ */
49
+ interface WritableAtom<T> extends ReadableAtom<T> {
50
+ /** Sets a new value. */
51
+ set(value: T): void;
52
+ /** Updates the value using a transformation function. */
53
+ update(fn: (current: T) => T): void;
54
+ }
55
+ /** Function type for reading other atoms inside a derived atom. */
56
+ type GetFn = <V>(a: ReadableAtom<V>) => V;
57
+ /** Function type for writing to other atoms inside a writable derived atom. */
58
+ type SetFn = <V>(a: WritableAtom<V>, value: V) => void;
59
+ /** Function that computes the atom's value. */
60
+ type ReadFn<T> = (get: GetFn) => T;
61
+ /** Function that handles writes to the atom. */
62
+ type WriteFn<T> = (get: GetFn, set: SetFn, value: T) => void;
63
+ /**
64
+ * Creates a Jotai-compatible atom built on GraphReFly primitives.
65
+ *
66
+ * Supports three overloads:
67
+ * 1. `atom(initial)` — Writable primitive atom (wraps `state()`).
68
+ * 2. `atom(read)` — Read-only derived atom (wraps `dynamicNode()`).
69
+ * 3. `atom(read, write)` — Writable derived atom.
70
+ *
71
+ * @param initialOrRead - Initial value or a read function.
72
+ * @param writeOrOptions - Write function or options object.
73
+ * @param options - Optional configuration.
74
+ * @returns WritableAtom or ReadableAtom.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const count = atom(0);
79
+ * count.set(1);
80
+ * const doubled = atom((get) => get(count)! * 2);
81
+ * ```
82
+ *
83
+ * @category compat
84
+ */
85
+ declare function atom$1<T>(initial: T, options?: AtomOptions): WritableAtom<T>;
86
+ declare function atom$1<T>(read: ReadFn<T>, options?: AtomOptions): ReadableAtom<T>;
87
+ declare function atom$1<T>(read: ReadFn<T>, write: WriteFn<T>, options?: AtomOptions): WritableAtom<T>;
88
+
89
+ type index$9_AtomOptions = AtomOptions;
90
+ type index$9_GetFn = GetFn;
91
+ type index$9_ReadFn<T> = ReadFn<T>;
92
+ type index$9_ReadableAtom<T> = ReadableAtom<T>;
93
+ type index$9_SetFn = SetFn;
94
+ type index$9_WritableAtom<T> = WritableAtom<T>;
95
+ type index$9_WriteFn<T> = WriteFn<T>;
96
+ declare namespace index$9 {
97
+ export { type index$9_AtomOptions as AtomOptions, type index$9_GetFn as GetFn, type index$9_ReadFn as ReadFn, type index$9_ReadableAtom as ReadableAtom, type index$9_SetFn as SetFn, type index$9_WritableAtom as WritableAtom, type index$9_WriteFn as WriteFn, atom$1 as atom };
98
+ }
99
+
100
+ /**
101
+ * A Nanostores-compatible atom.
102
+ *
103
+ * @category compat
104
+ */
105
+ interface NanoAtom<T> {
106
+ /** Get current value. */
107
+ get(): T;
108
+ /** Set a new value (writable atoms only). */
109
+ set(value: T): void;
110
+ /** Subscribe to value changes. Callback receives the new value.
111
+ * Returns unsubscribe function. Called immediately with current value. */
112
+ subscribe(cb: (value: T) => void): () => void;
113
+ /** Listen to value changes (no immediate call). Returns unsubscribe. */
114
+ listen(cb: (value: T) => void): () => void;
115
+ /** The underlying GraphReFly node. */
116
+ readonly _node: Node<T>;
117
+ }
118
+ /**
119
+ * A Nanostores-compatible computed store.
120
+ *
121
+ * @category compat
122
+ */
123
+ interface NanoComputed<T> {
124
+ /** Get current value. */
125
+ get(): T;
126
+ /** Subscribe to value changes. Called immediately with current value.
127
+ * Returns unsubscribe function. */
128
+ subscribe(cb: (value: T) => void): () => void;
129
+ /** Listen to value changes (no immediate call). Returns unsubscribe. */
130
+ listen(cb: (value: T) => void): () => void;
131
+ /** The underlying GraphReFly node. */
132
+ readonly _node: Node<T>;
133
+ }
134
+ /**
135
+ * A Nanostores-compatible map.
136
+ *
137
+ * @category compat
138
+ */
139
+ interface NanoMap<T extends Record<string, unknown>> extends NanoAtom<T> {
140
+ /** Set a single key. */
141
+ setKey<K extends keyof T>(key: K, value: T[K]): void;
142
+ }
143
+ /**
144
+ * Creates a nanostores-compatible atom.
145
+ *
146
+ * @param initial - Initial value.
147
+ * @returns `NanoAtom<T>`
148
+ *
149
+ * @category compat
150
+ */
151
+ declare function atom<T>(initial: T): NanoAtom<T>;
152
+ /**
153
+ * Creates a nanostores-compatible computed store.
154
+ *
155
+ * @param stores - One or more atoms/computed stores.
156
+ * @param fn - Compute function.
157
+ * @returns `NanoComputed<T>`
158
+ *
159
+ * @category compat
160
+ */
161
+ declare function computed<T, A>(storeA: NanoAtom<A> | NanoComputed<A>, fn: (a: A) => T): NanoComputed<T>;
162
+ declare function computed<T, A, B>(stores: [NanoAtom<A> | NanoComputed<A>, NanoAtom<B> | NanoComputed<B>], fn: (a: A, b: B) => T): NanoComputed<T>;
163
+ declare function computed<T, A, B, C>(stores: [
164
+ NanoAtom<A> | NanoComputed<A>,
165
+ NanoAtom<B> | NanoComputed<B>,
166
+ NanoAtom<C> | NanoComputed<C>
167
+ ], fn: (a: A, b: B, c: C) => T): NanoComputed<T>;
168
+ /**
169
+ * Creates a nanostores-compatible map.
170
+ *
171
+ * @param initial - Initial object value.
172
+ * @returns `NanoMap<T>`
173
+ *
174
+ * @category compat
175
+ */
176
+ declare function map<T extends Record<string, unknown>>(initial: T): NanoMap<T>;
177
+ /**
178
+ * Returns the current value of the store.
179
+ *
180
+ * @category compat
181
+ */
182
+ declare function getValue<T>(store: NanoAtom<T> | NanoComputed<T>): T;
183
+ /**
184
+ * Adds a listener for the store start (first listener connected).
185
+ *
186
+ * @category compat
187
+ */
188
+ declare function onStart(store: NanoAtom<any> | NanoComputed<any>, cb: () => void): void;
189
+ /**
190
+ * Adds a listener for the store stop (last listener disconnected).
191
+ *
192
+ * @category compat
193
+ */
194
+ declare function onStop(store: NanoAtom<any> | NanoComputed<any>, cb: () => void): void;
195
+ /**
196
+ * Adds a listener for the store mount (first listener connected).
197
+ *
198
+ * @returns A cleanup function called when the last listener is removed.
199
+ * @category compat
200
+ */
201
+ declare function onMount(store: NanoAtom<any> | NanoComputed<any>, cb: () => (() => void) | undefined): void;
202
+ /**
203
+ * Batches multiple store updates.
204
+ *
205
+ * @category compat
206
+ */
207
+ declare function action<Args extends any[], Return>(_store: NanoAtom<any> | NanoComputed<any>, _name: string, fn: (...args: Args) => Return): (...args: Args) => Return;
208
+
209
+ type index$8_NanoAtom<T> = NanoAtom<T>;
210
+ type index$8_NanoComputed<T> = NanoComputed<T>;
211
+ type index$8_NanoMap<T extends Record<string, unknown>> = NanoMap<T>;
212
+ declare const index$8_action: typeof action;
213
+ declare const index$8_atom: typeof atom;
214
+ declare const index$8_computed: typeof computed;
215
+ declare const index$8_getValue: typeof getValue;
216
+ declare const index$8_map: typeof map;
217
+ declare const index$8_onMount: typeof onMount;
218
+ declare const index$8_onStart: typeof onStart;
219
+ declare const index$8_onStop: typeof onStop;
220
+ declare namespace index$8 {
221
+ export { type index$8_NanoAtom as NanoAtom, type index$8_NanoComputed as NanoComputed, type index$8_NanoMap as NanoMap, index$8_action as action, index$8_atom as atom, index$8_computed as computed, index$8_getValue as getValue, index$8_map as map, index$8_onMount as onMount, index$8_onStart as onStart, index$8_onStop as onStop };
222
+ }
223
+
224
+ /**
225
+ * Subscribe to a read-only `Node<T>` as a React value. Re-renders on node value settlement.
226
+ * Subscription lifecycle is tied to React mount/unmount (not node terminal messages).
227
+ *
228
+ * @param node - Any `Node<T>`.
229
+ * @returns `T | undefined` — the current node value, kept in sync via `useSyncExternalStore`.
230
+ */
231
+ declare function useSubscribe$3<T>(node: Node<T>): T | undefined;
232
+ /**
233
+ * Bind a writable `Node<T>` as a React `[value, setter]` tuple.
234
+ * Setting the value always pushes `[[DIRTY], [DATA, value]]`, including `value === undefined`.
235
+ * Subscription lifecycle is tied to React mount/unmount (not node terminal messages).
236
+ *
237
+ * @param node - A `Node<T>` (e.g. state node).
238
+ * @returns `[T | undefined, (value: T) => void]` — current value and setter function.
239
+ */
240
+ declare function useStore$3<T>(node: Node<T>): [T | undefined, (value: T) => void];
241
+ /** Maps a key to an object of nodes. Used by `useSubscribeRecord`. */
242
+ type NodeFactory$3<K, R extends Record<string, any>> = (key: K) => {
243
+ [P in keyof R]: Node<R[P]>;
244
+ };
245
+ /**
246
+ * Subscribe to a dynamic set of keyed node records.
247
+ * Re-subscribes all per-key fields whenever `keysNode` changes.
248
+ * Key re-sync is gated to settled batches (`messageTier >= 2`) to avoid DIRTY-phase churn.
249
+ * Guaranteed to clean up strictly with React hook lifecycle, utilizing no global mappings.
250
+ *
251
+ * @param keysNode - Node of current keys (e.g. node IDs)
252
+ * @param factory - Function returning `{ [field]: Node<V> }` for each key.
253
+ * @returns `Record<K, R>` — snapshot of resolved values for all keys.
254
+ */
255
+ declare function useSubscribeRecord$3<K extends string, R extends Record<string, any>>(keysNode: Node<K[]>, factory: NodeFactory$3<K, R>): Record<K, R>;
256
+
257
+ declare namespace index$7 {
258
+ export { type NodeFactory$3 as NodeFactory, useStore$3 as useStore, useSubscribe$3 as useSubscribe, useSubscribeRecord$3 as useSubscribeRecord };
259
+ }
260
+
261
+ /**
262
+ * Options for creating signals.
263
+ *
264
+ * @category compat
265
+ */
266
+ interface SignalOptions {
267
+ /** Optional identifier for the underlying node. */
268
+ name?: string;
269
+ /** Custom equality function for change detection. */
270
+ equals?: (a: any, b: any) => boolean;
271
+ }
272
+ /**
273
+ * Common interface for all reactive signals.
274
+ *
275
+ * @category compat
276
+ */
277
+ interface AnySignal<T> {
278
+ /** Returns the current value of the signal. */
279
+ get(): T;
280
+ /** @internal The underlying GraphReFly node. */
281
+ _node: Node<T>;
282
+ }
283
+ /**
284
+ * TC39 `Signal.State` — a writable signal backed by a GraphReFly `state` node.
285
+ * Automatically registers itself as a dependency if read inside a `Computed`.
286
+ *
287
+ * @example
288
+ * ```ts
289
+ * const count = new Signal.State(0);
290
+ * count.get(); // 0
291
+ * count.set(1);
292
+ * count.get(); // 1
293
+ * ```
294
+ */
295
+ declare class SignalState<T> implements AnySignal<T> {
296
+ /** @internal */
297
+ _node: Node<T>;
298
+ private readonly _equals;
299
+ constructor(initial: T, opts?: SignalOptions);
300
+ get(): T;
301
+ set(value: T): void;
302
+ }
303
+ /**
304
+ * TC39 `Signal.Computed` — a read-only signal backed by `dynamicNode`.
305
+ * Automatically tracks dependencies when `get()` is called on other signals
306
+ * during its computation.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * const count = new Signal.State(0);
311
+ * const doubled = new Signal.Computed(() => count.get() * 2);
312
+ * ```
313
+ */
314
+ declare class SignalComputed<T> implements AnySignal<T> {
315
+ /** @internal */
316
+ _node: Node<T>;
317
+ constructor(computation: () => T, opts?: SignalOptions);
318
+ get(): T;
319
+ }
320
+ /**
321
+ * TC39 Signals-compatible namespace. Wraps GraphReFly primitives.
322
+ * Provides auto-tracking conforming to the TS39 signals proposal.
323
+ *
324
+ * @category compat
325
+ */
326
+ declare const Signal: {
327
+ readonly State: typeof SignalState;
328
+ readonly Computed: typeof SignalComputed;
329
+ /**
330
+ * Subscribes to changes on a signal.
331
+ * Returns an unsubscribe callback.
332
+ *
333
+ * @example
334
+ * ```ts
335
+ * const count = new Signal.State(0);
336
+ * const unsub = Signal.sub(count, v => console.log(v));
337
+ * ```
338
+ */
339
+ readonly sub: <T>(signal: AnySignal<T>, callback: ((value: T) => void) | {
340
+ data?: (value: T) => void;
341
+ error?: (err: unknown) => void;
342
+ complete?: () => void;
343
+ }) => (() => void);
344
+ };
345
+
346
+ type index$6_AnySignal<T> = AnySignal<T>;
347
+ declare const index$6_Signal: typeof Signal;
348
+ type index$6_SignalComputed<T> = SignalComputed<T>;
349
+ declare const index$6_SignalComputed: typeof SignalComputed;
350
+ type index$6_SignalOptions = SignalOptions;
351
+ type index$6_SignalState<T> = SignalState<T>;
352
+ declare const index$6_SignalState: typeof SignalState;
353
+ declare namespace index$6 {
354
+ export { type index$6_AnySignal as AnySignal, index$6_Signal as Signal, index$6_SignalComputed as SignalComputed, type index$6_SignalOptions as SignalOptions, index$6_SignalState as SignalState };
355
+ }
356
+
357
+ /** Solid accessor function — returns current value when called. */
358
+ type Accessor<T> = () => T;
359
+ /**
360
+ * Subscribe to a `Node<T>` as a Solid signal. Auto-cleans up with the owning scope.
361
+ * Subscription lifecycle is tied to Solid scope cleanup (not node terminal messages).
362
+ */
363
+ declare function useSubscribe$2<T>(node: Node<T>): Accessor<T | undefined>;
364
+ /**
365
+ * Bind a writable `Node<T>` as a Solid resource tuple `[accessor, setter]`.
366
+ * Setter always forwards `[[DIRTY], [DATA, value]]`, including `value === undefined`.
367
+ * Subscription lifecycle is tied to Solid scope cleanup (not node terminal messages).
368
+ */
369
+ declare function useStore$2<T>(node: Node<T>): [Accessor<T | undefined>, (v: T) => void];
370
+ /** Maps a key to an object of nodes. Used by `useSubscribeRecord`. */
371
+ type NodeFactory$2<K, R extends Record<string, any>> = (key: K) => {
372
+ [P in keyof R]: Node<R[P]>;
373
+ };
374
+ /**
375
+ * Subscribe to a dynamic set of keyed node records as a Solid accessor.
376
+ * Re-subscribes all per-key fields whenever `keys` changes.
377
+ * Key re-sync is gated to settled batches (`messageTier >= 2`) to avoid DIRTY-phase churn.
378
+ */
379
+ declare function useSubscribeRecord$2<K extends string, R extends Record<string, any>>(keysNode: Node<K[]>, factory: NodeFactory$2<K, R>): Accessor<Record<K, R>>;
380
+
381
+ type index$5_Accessor<T> = Accessor<T>;
382
+ declare namespace index$5 {
383
+ export { type index$5_Accessor as Accessor, type NodeFactory$2 as NodeFactory, useStore$2 as useStore, useSubscribe$2 as useSubscribe, useSubscribeRecord$2 as useSubscribeRecord };
384
+ }
385
+
386
+ /** Svelte store contract — implements the minimal `subscribe` method. */
387
+ interface SvelteReadable<T> {
388
+ subscribe(run: (value: T) => void): () => void;
389
+ }
390
+ /** Svelte writable store contract. */
391
+ interface SvelteWritable<T> extends SvelteReadable<T> {
392
+ set(value: T): void;
393
+ update(updater: (value: T) => T): void;
394
+ }
395
+ /**
396
+ * Subscribe to a `Node<T>` as a Svelte readable store (implements Svelte store contract).
397
+ * Subscription lifecycle is tied to Svelte store unsubscription (not node terminal messages).
398
+ */
399
+ declare function useSubscribe$1<T>(node: Node<T>): SvelteReadable<T | undefined>;
400
+ /**
401
+ * Bind a writable `Node<T>` as a Svelte writable store.
402
+ * Reads and writes adapt seamlessly.
403
+ * Setter/update always forward `[[DIRTY], [DATA, value]]`, including `value === undefined`.
404
+ * Subscription lifecycle is tied to Svelte store unsubscription (not node terminal messages).
405
+ */
406
+ declare function useStore$1<T>(node: Node<T>): SvelteWritable<T | undefined>;
407
+ /** Maps a key to an object of nodes. Used by `useSubscribeRecord`. */
408
+ type NodeFactory$1<K, R extends Record<string, any>> = (key: K) => {
409
+ [P in keyof R]: Node<R[P]>;
410
+ };
411
+ /**
412
+ * Subscribe to a dynamic keyed record of nodes as a Svelte readable store.
413
+ * Re-subscribes all per-key fields whenever `keysNode` changes.
414
+ * Key re-sync is gated to settled batches (`messageTier >= 2`) to avoid DIRTY-phase churn.
415
+ */
416
+ declare function useSubscribeRecord$1<K extends string, R extends Record<string, any>>(keysNode: Node<K[]>, factory: NodeFactory$1<K, R>): SvelteReadable<Record<K, R>>;
417
+
418
+ type index$4_SvelteReadable<T> = SvelteReadable<T>;
419
+ type index$4_SvelteWritable<T> = SvelteWritable<T>;
420
+ declare namespace index$4 {
421
+ export { type NodeFactory$1 as NodeFactory, type index$4_SvelteReadable as SvelteReadable, type index$4_SvelteWritable as SvelteWritable, useStore$1 as useStore, useSubscribe$1 as useSubscribe, useSubscribeRecord$1 as useSubscribeRecord };
422
+ }
423
+
424
+ /**
425
+ * Subscribe to a read-only `Node<T>` as a Vue `Ref<T>`. Auto-unsubscribes on scope disposal.
426
+ * Subscription lifecycle is tied to Vue scope disposal (not node terminal messages).
427
+ */
428
+ declare function useSubscribe<T>(node: Node<T>): Readonly<Ref<T | undefined>>;
429
+ /**
430
+ * Bind a writable `Node<T>` as a Vue `Ref<T>`. Reads and writes are bidirectional.
431
+ * Value sets always dispatch `[[DIRTY], [DATA, value]]`, including `value === undefined`.
432
+ * Subscription lifecycle is tied to Vue scope disposal (not node terminal messages).
433
+ */
434
+ declare function useStore<T>(node: Node<T>): Ref<T | undefined>;
435
+ /** Maps a key to an object of nodes. Used by `useSubscribeRecord` factory. */
436
+ type NodeFactory<K, R extends Record<string, any>> = (key: K) => {
437
+ [P in keyof R]: Node<R[P]>;
438
+ };
439
+ /**
440
+ * Subscribe to a dynamic set of keyed node records. When keys change,
441
+ * old subscriptions are torn down and new ones created automatically.
442
+ * Must be called during Vue `setup()`.
443
+ */
444
+ declare function useSubscribeRecord<K extends string, R extends Record<string, any>>(keys: WatchSource<K[] | undefined>, factory: NodeFactory<K, R>): Readonly<Ref<Record<K, R>>>;
445
+
446
+ type index$3_NodeFactory<K, R extends Record<string, any>> = NodeFactory<K, R>;
447
+ declare const index$3_useStore: typeof useStore;
448
+ declare const index$3_useSubscribe: typeof useSubscribe;
449
+ declare const index$3_useSubscribeRecord: typeof useSubscribeRecord;
450
+ declare namespace index$3 {
451
+ export { type index$3_NodeFactory as NodeFactory, index$3_useStore as useStore, index$3_useSubscribe as useSubscribe, index$3_useSubscribeRecord as useSubscribeRecord };
452
+ }
453
+
454
+ /** Zustand-compatible Store API. */
455
+ interface StoreApi<T> {
456
+ getState: () => T;
457
+ setState: (partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean) => void;
458
+ getInitialState: () => T;
459
+ subscribe: (listener: (state: T, prevState: T) => void) => () => void;
460
+ destroy: () => void;
461
+ }
462
+ /** Function type for initializing the store. */
463
+ type StateCreator<T> = (set: StoreApi<T>["setState"], get: StoreApi<T>["getState"], api: StoreApi<T>) => T;
464
+ /**
465
+ * Creates a Zustand-compatible store backed by a GraphReFly state node.
466
+ * returns an object that is both a Graph and a StoreApi.
467
+ *
468
+ * @example
469
+ * ```ts
470
+ * const store = create((set) => ({
471
+ * count: 0,
472
+ * inc: () => set((s) => ({ count: s.count + 1 }))
473
+ * }));
474
+ * store.getState().inc();
475
+ * ```
476
+ *
477
+ * @category compat
478
+ */
479
+ declare function create<T extends object>(initializer: StateCreator<T>): Graph & StoreApi<T>;
480
+
481
+ type index$2_StateCreator<T> = StateCreator<T>;
482
+ type index$2_StoreApi<T> = StoreApi<T>;
483
+ declare const index$2_create: typeof create;
484
+ declare namespace index$2 {
485
+ export { type index$2_StateCreator as StateCreator, type index$2_StoreApi as StoreApi, index$2_create as create };
486
+ }
487
+
488
+ /**
489
+ * Compat layer: compatibility wrappers for other state management libraries (Phase 5.1b).
490
+ *
491
+ * Framework adapters are optional peers. Install only what you use:
492
+ * - `@graphrefly/graphrefly-ts/compat/react` -> `react`, `react-dom`
493
+ * - `@graphrefly/graphrefly-ts/compat/vue` -> `vue`
494
+ * - `@graphrefly/graphrefly-ts/compat/svelte` -> `svelte`
495
+ * - `@graphrefly/graphrefly-ts/compat/solid` -> `solid-js`
496
+ */
497
+
498
+ declare namespace index$1 {
499
+ export { index$9 as jotai, index$8 as nanostores, index$a as nestjs, index$7 as react, index$6 as signals, index$5 as solid, index$4 as svelte, index$3 as vue, index$2 as zustand };
500
+ }
501
+
502
+ /**
503
+ * Memory patterns (roadmap §4.3).
504
+ *
505
+ * Domain-layer helpers composed from GraphRefly primitives. `vectorIndex` uses
506
+ * an exact-search backend by default; an HNSW adapter can be injected as an
507
+ * optional dependency.
508
+ */
509
+
510
+ type CollectionPolicy = "fifo" | "lru";
511
+ type VectorBackend = "flat" | "hnsw";
512
+ type LightCollectionEntry<T> = {
513
+ readonly id: string;
514
+ readonly value: T;
515
+ readonly createdAtNs: number;
516
+ readonly lastAccessNs: number;
517
+ };
518
+ type LightCollectionOptions = {
519
+ name?: string;
520
+ maxSize?: number;
521
+ policy?: CollectionPolicy;
522
+ };
523
+ type LightCollectionBundle<T> = {
524
+ readonly entries: Node<ReadonlyMap<string, LightCollectionEntry<T>>>;
525
+ upsert: (id: string, value: T) => void;
526
+ remove: (id: string) => void;
527
+ clear: () => void;
528
+ get: (id: string) => T | undefined;
529
+ has: (id: string) => boolean;
530
+ };
531
+ type CollectionEntry<T> = LightCollectionEntry<T> & {
532
+ readonly baseScore: number;
533
+ };
534
+ type RankedCollectionEntry<T> = CollectionEntry<T> & {
535
+ readonly score: number;
536
+ };
537
+ type CollectionOptions<T> = {
538
+ maxSize?: number;
539
+ policy?: CollectionPolicy;
540
+ /**
541
+ * Produces a base score at insert/update time.
542
+ */
543
+ score?: (value: T) => number;
544
+ /**
545
+ * Exponential decay rate per second. 0 disables decay.
546
+ */
547
+ decayRate?: number;
548
+ /**
549
+ * Minimum score floor after decay.
550
+ */
551
+ minScore?: number;
552
+ };
553
+ type CollectionGraph<T> = Graph & {
554
+ upsert: (id: string, value: T, opts?: {
555
+ score?: number;
556
+ }) => void;
557
+ remove: (id: string) => void;
558
+ clear: () => void;
559
+ getItem: (id: string) => CollectionEntry<T> | undefined;
560
+ };
561
+ type VectorRecord<TMeta> = {
562
+ readonly id: string;
563
+ readonly vector: readonly number[];
564
+ readonly meta?: TMeta;
565
+ };
566
+ type VectorSearchResult<TMeta> = {
567
+ readonly id: string;
568
+ readonly score: number;
569
+ readonly meta?: TMeta;
570
+ };
571
+ type HnswAdapter<TMeta> = {
572
+ upsert: (id: string, vector: readonly number[], meta?: TMeta) => void;
573
+ remove: (id: string) => void;
574
+ clear: () => void;
575
+ search: (query: readonly number[], k: number) => ReadonlyArray<VectorSearchResult<TMeta>>;
576
+ };
577
+ type VectorIndexOptions<TMeta> = {
578
+ backend?: VectorBackend;
579
+ dimension?: number;
580
+ /**
581
+ * Optional dependency seam for HNSW.
582
+ */
583
+ hnswFactory?: () => HnswAdapter<TMeta>;
584
+ };
585
+ type VectorIndexBundle<TMeta> = {
586
+ readonly backend: VectorBackend;
587
+ readonly entries: Node<ReadonlyMap<string, VectorRecord<TMeta>>>;
588
+ upsert: (id: string, vector: readonly number[], meta?: TMeta) => void;
589
+ remove: (id: string) => void;
590
+ clear: () => void;
591
+ search: (query: readonly number[], k?: number) => ReadonlyArray<VectorSearchResult<TMeta>>;
592
+ };
593
+ type KnowledgeEdge<TRelation extends string = string> = {
594
+ readonly from: string;
595
+ readonly to: string;
596
+ readonly relation: TRelation;
597
+ readonly weight: number;
598
+ };
599
+ type KnowledgeGraphGraph<TEntity, TRelation extends string = string> = Graph & {
600
+ upsertEntity: (id: string, value: TEntity) => void;
601
+ removeEntity: (id: string) => void;
602
+ link: (from: string, to: string, relation: TRelation, weight?: number) => void;
603
+ unlink: (from: string, to: string, relation?: TRelation) => void;
604
+ related: (id: string, relation?: TRelation) => ReadonlyArray<KnowledgeEdge<TRelation>>;
605
+ };
606
+ declare function decay(baseScore: number, ageSeconds: number, ratePerSecond: number, minScore?: number): number;
607
+ declare function lightCollection<T>(opts?: LightCollectionOptions): LightCollectionBundle<T>;
608
+ declare function collection<T>(name: string, opts?: CollectionOptions<T>): CollectionGraph<T>;
609
+ declare function vectorIndex<TMeta>(opts?: VectorIndexOptions<TMeta>): VectorIndexBundle<TMeta>;
610
+ declare function knowledgeGraph<TEntity, TRelation extends string = string>(name: string): KnowledgeGraphGraph<TEntity, TRelation>;
611
+
612
+ type memory_CollectionEntry<T> = CollectionEntry<T>;
613
+ type memory_CollectionGraph<T> = CollectionGraph<T>;
614
+ type memory_CollectionOptions<T> = CollectionOptions<T>;
615
+ type memory_CollectionPolicy = CollectionPolicy;
616
+ type memory_HnswAdapter<TMeta> = HnswAdapter<TMeta>;
617
+ type memory_KnowledgeEdge<TRelation extends string = string> = KnowledgeEdge<TRelation>;
618
+ type memory_KnowledgeGraphGraph<TEntity, TRelation extends string = string> = KnowledgeGraphGraph<TEntity, TRelation>;
619
+ type memory_LightCollectionBundle<T> = LightCollectionBundle<T>;
620
+ type memory_LightCollectionEntry<T> = LightCollectionEntry<T>;
621
+ type memory_LightCollectionOptions = LightCollectionOptions;
622
+ type memory_RankedCollectionEntry<T> = RankedCollectionEntry<T>;
623
+ type memory_VectorBackend = VectorBackend;
624
+ type memory_VectorIndexBundle<TMeta> = VectorIndexBundle<TMeta>;
625
+ type memory_VectorIndexOptions<TMeta> = VectorIndexOptions<TMeta>;
626
+ type memory_VectorRecord<TMeta> = VectorRecord<TMeta>;
627
+ type memory_VectorSearchResult<TMeta> = VectorSearchResult<TMeta>;
628
+ declare const memory_collection: typeof collection;
629
+ declare const memory_decay: typeof decay;
630
+ declare const memory_knowledgeGraph: typeof knowledgeGraph;
631
+ declare const memory_lightCollection: typeof lightCollection;
632
+ declare const memory_vectorIndex: typeof vectorIndex;
633
+ declare namespace memory {
634
+ export { type memory_CollectionEntry as CollectionEntry, type memory_CollectionGraph as CollectionGraph, type memory_CollectionOptions as CollectionOptions, type memory_CollectionPolicy as CollectionPolicy, type memory_HnswAdapter as HnswAdapter, type memory_KnowledgeEdge as KnowledgeEdge, type memory_KnowledgeGraphGraph as KnowledgeGraphGraph, type memory_LightCollectionBundle as LightCollectionBundle, type memory_LightCollectionEntry as LightCollectionEntry, type memory_LightCollectionOptions as LightCollectionOptions, type memory_RankedCollectionEntry as RankedCollectionEntry, type memory_VectorBackend as VectorBackend, type memory_VectorIndexBundle as VectorIndexBundle, type memory_VectorIndexOptions as VectorIndexOptions, type memory_VectorRecord as VectorRecord, type memory_VectorSearchResult as VectorSearchResult, memory_collection as collection, memory_decay as decay, memory_knowledgeGraph as knowledgeGraph, memory_lightCollection as lightCollection, memory_vectorIndex as vectorIndex };
635
+ }
636
+
637
+ /**
638
+ * AI surface patterns (roadmap §4.4).
639
+ *
640
+ * Domain-layer factories for LLM-backed agents, chat, tool registries, and
641
+ * agentic memory. Composed from core + extra + Phase 3–4.3 primitives.
642
+ */
643
+
644
+ /** A single chat message in a conversation. */
645
+ type ChatMessage = {
646
+ readonly role: "system" | "user" | "assistant" | "tool";
647
+ readonly content: string;
648
+ readonly name?: string;
649
+ readonly toolCallId?: string;
650
+ readonly toolCalls?: readonly ToolCall[];
651
+ readonly metadata?: Record<string, unknown>;
652
+ };
653
+ /** A tool invocation request from an LLM. */
654
+ type ToolCall = {
655
+ readonly id: string;
656
+ readonly name: string;
657
+ readonly arguments: Record<string, unknown>;
658
+ };
659
+ /** The response from an LLM invocation. */
660
+ type LLMResponse = {
661
+ readonly content: string;
662
+ readonly toolCalls?: readonly ToolCall[];
663
+ readonly usage?: {
664
+ readonly inputTokens: number;
665
+ readonly outputTokens: number;
666
+ };
667
+ readonly finishReason?: string;
668
+ readonly metadata?: Record<string, unknown>;
669
+ };
670
+ /** Provider-agnostic LLM client adapter protocol. */
671
+ type LLMAdapter = {
672
+ invoke(messages: readonly ChatMessage[], opts?: LLMInvokeOptions): NodeInput<LLMResponse>;
673
+ stream(messages: readonly ChatMessage[], opts?: LLMInvokeOptions): AsyncIterable<string>;
674
+ };
675
+ type LLMInvokeOptions = {
676
+ model?: string;
677
+ temperature?: number;
678
+ maxTokens?: number;
679
+ tools?: readonly ToolDefinition[];
680
+ systemPrompt?: string;
681
+ signal?: AbortSignal;
682
+ };
683
+ /** A tool definition for LLM consumption. */
684
+ type ToolDefinition = {
685
+ readonly name: string;
686
+ readonly description: string;
687
+ readonly parameters: Record<string, unknown>;
688
+ readonly handler: (args: Record<string, unknown>) => NodeInput<unknown>;
689
+ /**
690
+ * V0 version of the backing node at `knobsAsTools()` call time (§6.0b).
691
+ * Snapshot — re-call `knobsAsTools()` to refresh.
692
+ */
693
+ readonly version?: {
694
+ id: string;
695
+ version: number;
696
+ };
697
+ };
698
+ type AgentLoopStatus = "idle" | "thinking" | "acting" | "done" | "error";
699
+ type FromLLMOptions = {
700
+ name?: string;
701
+ model?: string;
702
+ temperature?: number;
703
+ maxTokens?: number;
704
+ tools?: readonly ToolDefinition[];
705
+ systemPrompt?: string;
706
+ };
707
+ /**
708
+ * Reactive LLM invocation adapter. Returns a derived node that re-invokes
709
+ * the LLM whenever the messages dep changes.
710
+ *
711
+ * Uses `switchMap` internally — new invocations cancel stale in-flight ones.
712
+ */
713
+ declare function fromLLM(adapter: LLMAdapter, messages: NodeInput<readonly ChatMessage[]>, opts?: FromLLMOptions): Node<LLMResponse | null>;
714
+ type FromLLMStreamOptions = FromLLMOptions;
715
+ /**
716
+ * Bundle returned by {@link fromLLMStream}. `node` is the reactive log of
717
+ * token chunks; `dispose` tears down the internal effect and log.
718
+ */
719
+ type LLMStreamHandle = {
720
+ /** Reactive log node accumulating token chunks. */
721
+ node: Node<ReactiveLogSnapshot<string>>;
722
+ /** Tear down the internal effect, abort any in-flight stream, and release resources. */
723
+ dispose: () => void;
724
+ };
725
+ /**
726
+ * Streaming LLM invocation. Returns a `{ node, dispose }` bundle where
727
+ * `node` is a `reactiveLog`-backed node that accumulates token chunks as
728
+ * they arrive from `adapter.stream()`.
729
+ *
730
+ * An `effect` watches the messages input; new values abort the in-flight
731
+ * stream and clear the log before starting a new one. Call `dispose()` to
732
+ * tear down the effect and release resources.
733
+ */
734
+ declare function fromLLMStream(adapter: LLMAdapter, messages: NodeInput<readonly ChatMessage[]>, opts?: FromLLMStreamOptions): LLMStreamHandle;
735
+ type ChatStreamOptions = {
736
+ graph?: GraphOptions;
737
+ maxMessages?: number;
738
+ };
739
+ declare class ChatStreamGraph extends Graph {
740
+ private readonly _log;
741
+ private readonly _keepaliveSubs;
742
+ readonly messages: Node<ReactiveLogSnapshot<ChatMessage>>;
743
+ readonly latest: Node<ChatMessage | undefined>;
744
+ readonly messageCount: Node<number>;
745
+ constructor(name: string, opts?: ChatStreamOptions);
746
+ append(role: ChatMessage["role"], content: string, extra?: Partial<ChatMessage>): void;
747
+ appendToolResult(callId: string, content: string): void;
748
+ clear(): void;
749
+ allMessages(): readonly ChatMessage[];
750
+ destroy(): void;
751
+ }
752
+ declare function chatStream(name: string, opts?: ChatStreamOptions): ChatStreamGraph;
753
+ type ToolRegistryOptions = {
754
+ graph?: GraphOptions;
755
+ };
756
+ declare class ToolRegistryGraph extends Graph {
757
+ readonly definitions: Node<ReadonlyMap<string, ToolDefinition>>;
758
+ readonly schemas: Node<readonly ToolDefinition[]>;
759
+ private readonly _keepaliveSubs;
760
+ constructor(name: string, opts?: ToolRegistryOptions);
761
+ register(tool: ToolDefinition): void;
762
+ unregister(name: string): void;
763
+ execute(name: string, args: Record<string, unknown>): Promise<unknown>;
764
+ getDefinition(name: string): ToolDefinition | undefined;
765
+ destroy(): void;
766
+ }
767
+ declare function toolRegistry(name: string, opts?: ToolRegistryOptions): ToolRegistryGraph;
768
+ /**
769
+ * Assembles a system prompt from reactive sections. Each section is a
770
+ * `NodeInput<string>` — the prompt updates when any section changes.
771
+ */
772
+ type SystemPromptHandle = Node<string> & {
773
+ dispose: () => void;
774
+ };
775
+ declare function systemPromptBuilder(sections: readonly NodeInput<string>[], opts?: {
776
+ separator?: string;
777
+ name?: string;
778
+ }): SystemPromptHandle;
779
+ type LLMExtractorOptions = {
780
+ adapter: LLMAdapter;
781
+ model?: string;
782
+ temperature?: number;
783
+ maxTokens?: number;
784
+ };
785
+ /**
786
+ * Returns an `extractFn` callback for `distill()` that invokes an LLM to
787
+ * extract structured memories from raw input.
788
+ *
789
+ * The system prompt should instruct the LLM to return JSON matching
790
+ * `Extraction<TMem>` shape: `{ upsert: [{ key, value }], remove?: [key] }`.
791
+ */
792
+ declare function llmExtractor<TRaw, TMem>(systemPrompt: string, opts: LLMExtractorOptions): (raw: TRaw, existing: ReadonlyMap<string, TMem>) => NodeInput<Extraction<TMem>>;
793
+ type LLMConsolidatorOptions = LLMExtractorOptions;
794
+ /**
795
+ * Returns a `consolidateFn` callback for `distill()` that invokes an LLM to
796
+ * cluster and merge related memories.
797
+ */
798
+ declare function llmConsolidator<TMem>(systemPrompt: string, opts: LLMConsolidatorOptions): (entries: ReadonlyMap<string, TMem>) => NodeInput<Extraction<TMem>>;
799
+ /** Scores for the three admission dimensions. Each 0–1. */
800
+ type AdmissionScores = {
801
+ readonly persistence: number;
802
+ readonly structure: number;
803
+ readonly personalValue: number;
804
+ };
805
+ type AdmissionScore3DOptions = {
806
+ /** Custom scoring function. Default: rule-based (all dimensions 0.5). */
807
+ scoreFn?: (raw: unknown) => AdmissionScores;
808
+ /** Minimum persistence score to admit (default 0.3). */
809
+ persistenceThreshold?: number;
810
+ /** Minimum personalValue score to admit (default 0.3). */
811
+ personalValueThreshold?: number;
812
+ /** Require structure score > 0 to admit (default false). */
813
+ requireStructured?: boolean;
814
+ };
815
+ /**
816
+ * Creates a 3D admission filter function compatible with `agentMemory`'s
817
+ * `admissionFilter` option. Scores each candidate on persistence, structure,
818
+ * and personalValue, then applies thresholds.
819
+ */
820
+ declare function admissionFilter3D(opts?: AdmissionScore3DOptions): (raw: unknown) => boolean;
821
+ type MemoryTier = "permanent" | "active" | "archived";
822
+ type MemoryTiersOptions<TMem> = {
823
+ /** Exponential decay rate per second for active tier.
824
+ * Default: 7-day half-life ≈ ln(2)/(7×86400) ≈ 0.00000114. */
825
+ decayRate?: number;
826
+ /** Max entries in the active tier before archiving lowest-scored (default 1000). */
827
+ maxActive?: number;
828
+ /** Score threshold below which active entries get archived (default 0.1). */
829
+ archiveThreshold?: number;
830
+ /** Predicate: true → entry belongs in permanent tier (default: never). */
831
+ permanentFilter?: (key: string, mem: TMem) => boolean;
832
+ /** Persistence adapter for the archive tier. Omit to disable archiving. */
833
+ archiveAdapter?: AutoCheckpointAdapter;
834
+ /** Auto-checkpoint options for archive adapter. */
835
+ archiveCheckpointOptions?: GraphAutoCheckpointOptions;
836
+ };
837
+ type MemoryTiersBundle<TMem> = {
838
+ /** Permanent tier: never evicted. */
839
+ readonly permanent: LightCollectionBundle<TMem>;
840
+ /** Active entries node (reactive, holds ReactiveMapSnapshot). */
841
+ readonly activeEntries: Node<unknown>;
842
+ /** Archive checkpoint handle (null if no adapter). */
843
+ readonly archiveHandle: GraphAutoCheckpointHandle | null;
844
+ /** Classify a key into its current tier. */
845
+ tierOf: (key: string) => MemoryTier;
846
+ /** Move a key to the permanent tier. */
847
+ markPermanent: (key: string, value: TMem) => void;
848
+ };
849
+ type RetrievalQuery = {
850
+ readonly text?: string;
851
+ readonly vector?: readonly number[];
852
+ readonly entityIds?: readonly string[];
853
+ };
854
+ type RetrievalPipelineOptions<TMem> = {
855
+ /** Max candidates from vector search (default 20). */
856
+ topK?: number;
857
+ /** KG expansion depth in hops (default 1). */
858
+ graphDepth?: number;
859
+ /** Token budget for final packing (default 2000). */
860
+ budget?: number;
861
+ /** Cost function for budget packing. */
862
+ cost: (mem: TMem) => number;
863
+ /** Score function for ranking. */
864
+ score: (mem: TMem, context: unknown) => number;
865
+ };
866
+ /** A single entry in the retrieval result, with causal trace metadata. */
867
+ type RetrievalEntry<TMem> = {
868
+ readonly key: string;
869
+ readonly value: TMem;
870
+ readonly score: number;
871
+ readonly sources: ReadonlyArray<"vector" | "graph" | "store">;
872
+ };
873
+ /** Causal trace for a retrieval run. */
874
+ type RetrievalTrace<TMem> = {
875
+ readonly vectorCandidates: ReadonlyArray<VectorSearchResult<TMem>>;
876
+ readonly graphExpanded: ReadonlyArray<string>;
877
+ readonly ranked: ReadonlyArray<RetrievalEntry<TMem>>;
878
+ readonly packed: ReadonlyArray<RetrievalEntry<TMem>>;
879
+ };
880
+ type AgentMemoryOptions<TMem = unknown> = {
881
+ graph?: GraphOptions;
882
+ /** LLM adapter for extraction and consolidation. */
883
+ adapter?: LLMAdapter;
884
+ /** System prompt for the extractor LLM. */
885
+ extractPrompt?: string;
886
+ /** Custom extractFn (overrides adapter + extractPrompt). */
887
+ extractFn?: (raw: unknown, existing: ReadonlyMap<string, TMem>) => NodeInput<Extraction<TMem>>;
888
+ /** System prompt for the consolidation LLM. */
889
+ consolidatePrompt?: string;
890
+ /** Custom consolidateFn (overrides adapter + consolidatePrompt). */
891
+ consolidateFn?: (entries: ReadonlyMap<string, TMem>) => NodeInput<Extraction<TMem>>;
892
+ /** Reactive trigger for consolidation (caller supplies e.g. `fromTimer`). */
893
+ consolidateTrigger?: NodeInput<unknown>;
894
+ /** Score function for budget packing (required). */
895
+ score: (mem: TMem, context: unknown) => number;
896
+ /** Cost function for budget packing (required). */
897
+ cost: (mem: TMem) => number;
898
+ /** Token budget for compact view (default 2000). */
899
+ budget?: number;
900
+ /** Context node for scoring. */
901
+ context?: NodeInput<unknown>;
902
+ /** Admission filter (default: admit all). */
903
+ admissionFilter?: (candidate: unknown) => boolean;
904
+ /** Vector index dimensions (> 0 enables vector index for retrieval). */
905
+ vectorDimensions?: number;
906
+ /** Extract embedding vector from a memory entry (enables vector index). */
907
+ embedFn?: (mem: TMem) => readonly number[] | undefined;
908
+ /** Enable knowledge graph for entity/relation tracking. */
909
+ enableKnowledgeGraph?: boolean;
910
+ /** Extract entities and relations from a memory entry. */
911
+ entityFn?: (key: string, mem: TMem) => {
912
+ entities?: Array<{
913
+ id: string;
914
+ value: unknown;
915
+ }>;
916
+ relations?: Array<{
917
+ from: string;
918
+ to: string;
919
+ relation: string;
920
+ weight?: number;
921
+ }>;
922
+ } | undefined;
923
+ /** 3-tier storage configuration. Omit to use single-tier (existing behavior). */
924
+ tiers?: MemoryTiersOptions<TMem>;
925
+ /** Retrieval pipeline configuration. Requires vector index or knowledge graph. */
926
+ retrieval?: {
927
+ /** Max candidates from vector search (default 20). */
928
+ topK?: number;
929
+ /** KG expansion depth in hops (default 1). */
930
+ graphDepth?: number;
931
+ };
932
+ /** Periodic reflection/consolidation configuration. */
933
+ reflection?: {
934
+ /** Interval in ms between consolidation runs (default 300_000 = 5 min). */
935
+ interval?: number;
936
+ /** Enable/disable periodic reflection (default true when consolidateFn is available). */
937
+ enabled?: boolean;
938
+ };
939
+ };
940
+ type AgentMemoryGraph<TMem = unknown> = Graph & {
941
+ readonly distillBundle: DistillBundle<TMem>;
942
+ readonly compact: Node<Array<{
943
+ key: string;
944
+ value: TMem;
945
+ score: number;
946
+ }>>;
947
+ readonly size: Node<number>;
948
+ /** Vector index bundle (null if not enabled). */
949
+ readonly vectors: VectorIndexBundle<TMem> | null;
950
+ /** Knowledge graph (null if not enabled). */
951
+ readonly kg: KnowledgeGraphGraph<unknown, string> | null;
952
+ /** Memory tiers bundle (null if not configured). */
953
+ readonly memoryTiers: MemoryTiersBundle<TMem> | null;
954
+ /** Retrieval result node (null if no retrieval pipeline configured). */
955
+ readonly retrieval: Node<ReadonlyArray<RetrievalEntry<TMem>>> | null;
956
+ /** Latest retrieval trace for observability (null if no retrieval pipeline). */
957
+ readonly retrievalTrace: Node<RetrievalTrace<TMem> | null> | null;
958
+ /** Execute a retrieval query (null if no retrieval pipeline). */
959
+ readonly retrieve: ((query: RetrievalQuery) => ReadonlyArray<RetrievalEntry<TMem>>) | null;
960
+ };
961
+ declare function agentMemory<TMem = unknown>(name: string, source: NodeInput<unknown>, opts: AgentMemoryOptions<TMem>): AgentMemoryGraph<TMem>;
962
+ type AgentLoopOptions = {
963
+ graph?: GraphOptions;
964
+ adapter: LLMAdapter;
965
+ tools?: readonly ToolDefinition[];
966
+ systemPrompt?: string;
967
+ maxTurns?: number;
968
+ stopWhen?: (response: LLMResponse) => boolean;
969
+ onToolCall?: (call: ToolCall) => void;
970
+ maxMessages?: number;
971
+ model?: string;
972
+ temperature?: number;
973
+ maxTokens?: number;
974
+ };
975
+ declare class AgentLoopGraph extends Graph {
976
+ readonly chat: ChatStreamGraph;
977
+ readonly tools: ToolRegistryGraph;
978
+ readonly status: Node<AgentLoopStatus>;
979
+ readonly turnCount: Node<number>;
980
+ readonly lastResponse: Node<LLMResponse | null>;
981
+ private readonly _statusState;
982
+ private readonly _turnCountState;
983
+ private readonly _adapter;
984
+ private readonly _maxTurns;
985
+ private readonly _stopWhen?;
986
+ private readonly _onToolCall?;
987
+ private readonly _systemPrompt?;
988
+ private readonly _model?;
989
+ private readonly _temperature?;
990
+ private readonly _maxTokens?;
991
+ private _running;
992
+ private _abortController;
993
+ constructor(name: string, opts: AgentLoopOptions);
994
+ /**
995
+ * Start the agent loop with a user message. The loop runs reactively:
996
+ * think (LLM call) → act (tool execution) → repeat until done.
997
+ *
998
+ * Messages accumulate across calls. Call `chat.clear()` before `run()`
999
+ * to reset conversation history.
1000
+ */
1001
+ run(userMessage: string): Promise<LLMResponse | null>;
1002
+ private _invokeLLM;
1003
+ private _shouldStop;
1004
+ destroy(): void;
1005
+ }
1006
+ declare function agentLoop(name: string, opts: AgentLoopOptions): AgentLoopGraph;
1007
+ /** OpenAI function-calling tool schema. */
1008
+ type OpenAIToolSchema = {
1009
+ readonly type: "function";
1010
+ readonly function: {
1011
+ readonly name: string;
1012
+ readonly description: string;
1013
+ readonly parameters: Record<string, unknown>;
1014
+ };
1015
+ };
1016
+ /** MCP (Model Context Protocol) tool schema. */
1017
+ type McpToolSchema = {
1018
+ readonly name: string;
1019
+ readonly description: string;
1020
+ readonly inputSchema: Record<string, unknown>;
1021
+ };
1022
+ /** Result of {@link knobsAsTools}. */
1023
+ type KnobsAsToolsResult = {
1024
+ /** OpenAI function-calling tool schemas. */
1025
+ readonly openai: readonly OpenAIToolSchema[];
1026
+ /** MCP tool schemas. */
1027
+ readonly mcp: readonly McpToolSchema[];
1028
+ /** GraphReFly ToolDefinitions with handlers that call `graph.set()`. */
1029
+ readonly definitions: readonly ToolDefinition[];
1030
+ };
1031
+ /**
1032
+ * Derive tool schemas from a graph's writable (knob) nodes.
1033
+ *
1034
+ * Knobs are state nodes whose `meta.access` is `"llm"`, `"both"`, or absent
1035
+ * (default: writable). Each knob becomes a tool that calls `graph.set()`.
1036
+ *
1037
+ * Speaks **domain language** (spec §5.4): the returned schemas use node names
1038
+ * and meta descriptions — no protocol internals exposed.
1039
+ *
1040
+ * @param graph - The graph to introspect.
1041
+ * @param actor - Optional actor for guard-scoped describe.
1042
+ * @returns OpenAI, MCP, and GraphReFly tool schemas.
1043
+ */
1044
+ declare function knobsAsTools(graph: Graph, actor?: Actor): KnobsAsToolsResult;
1045
+ type GaugesAsContextOptions = {
1046
+ /** Group gauges by `meta.tags` (default true). */
1047
+ groupByTags?: boolean;
1048
+ /** Separator between gauge lines (default "\n"). */
1049
+ separator?: string;
1050
+ /**
1051
+ * V0 delta mode (§6.0b): only include nodes whose `v.version` exceeds
1052
+ * the corresponding entry in this map. Nodes without V0 or not in the
1053
+ * map are always included. Callers maintain this map across calls.
1054
+ *
1055
+ * The `id` field guards against node replacement: if a node is removed
1056
+ * and re-added under the same name (new id), it is always included.
1057
+ */
1058
+ sinceVersion?: ReadonlyMap<string, {
1059
+ id: string;
1060
+ version: number;
1061
+ }>;
1062
+ };
1063
+ /**
1064
+ * Format a graph's readable (gauge) nodes as a context string for LLM
1065
+ * system prompts.
1066
+ *
1067
+ * Gauges are nodes with `meta.description` or `meta.format`. Values are
1068
+ * formatted using `meta.format` and `meta.unit` hints.
1069
+ *
1070
+ * @param graph - The graph to introspect.
1071
+ * @param actor - Optional actor for guard-scoped describe.
1072
+ * @param options - Formatting options.
1073
+ * @returns A formatted string ready for system prompt injection.
1074
+ */
1075
+ declare function gaugesAsContext(graph: Graph, actor?: Actor, options?: GaugesAsContextOptions): string;
1076
+ /** Validation result from {@link validateGraphDef}. */
1077
+ type GraphDefValidation = {
1078
+ readonly valid: boolean;
1079
+ readonly errors: readonly string[];
1080
+ };
1081
+ /**
1082
+ * Validate an LLM-generated graph definition before passing to
1083
+ * `Graph.fromSnapshot()`.
1084
+ *
1085
+ * Checks:
1086
+ * - Required fields: `name`, `nodes`, `edges`
1087
+ * - Node types are valid enum values
1088
+ * - Edge `from`/`to` reference existing nodes
1089
+ * - No duplicate edge entries
1090
+ *
1091
+ * @param def - The graph definition to validate (parsed JSON).
1092
+ * @returns Validation result with errors array.
1093
+ */
1094
+ declare function validateGraphDef(def: unknown): GraphDefValidation;
1095
+ type GraphFromSpecOptions = {
1096
+ model?: string;
1097
+ temperature?: number;
1098
+ maxTokens?: number;
1099
+ /** Callback to construct topology before values are applied (passed to `Graph.fromSnapshot`). */
1100
+ build?: (g: Graph) => void;
1101
+ /** Extra instructions appended to the system prompt. */
1102
+ systemPromptExtra?: string;
1103
+ };
1104
+ /**
1105
+ * Ask an LLM to compose a Graph from a natural-language description.
1106
+ *
1107
+ * The LLM returns a JSON graph definition which is validated and then
1108
+ * constructed via `Graph.fromSnapshot()`.
1109
+ *
1110
+ * @param naturalLanguage - The problem/use-case description.
1111
+ * @param adapter - LLM adapter for the generation call.
1112
+ * @param opts - Model options and optional `build` callback for node factories.
1113
+ * @returns A constructed Graph.
1114
+ * @throws On invalid LLM output or validation failure.
1115
+ */
1116
+ declare function graphFromSpec(naturalLanguage: string, adapter: LLMAdapter, opts?: GraphFromSpecOptions): Promise<Graph>;
1117
+ /** A single operation in a strategy plan. */
1118
+ type StrategyOperation = {
1119
+ readonly type: "add_node";
1120
+ readonly name: string;
1121
+ readonly nodeType: string;
1122
+ readonly meta?: Record<string, unknown>;
1123
+ readonly initial?: unknown;
1124
+ } | {
1125
+ readonly type: "remove_node";
1126
+ readonly name: string;
1127
+ } | {
1128
+ readonly type: "connect";
1129
+ readonly from: string;
1130
+ readonly to: string;
1131
+ } | {
1132
+ readonly type: "disconnect";
1133
+ readonly from: string;
1134
+ readonly to: string;
1135
+ } | {
1136
+ readonly type: "set_value";
1137
+ readonly name: string;
1138
+ readonly value: unknown;
1139
+ } | {
1140
+ readonly type: "update_meta";
1141
+ readonly name: string;
1142
+ readonly key: string;
1143
+ readonly value: unknown;
1144
+ };
1145
+ /** Structured strategy plan returned by {@link suggestStrategy}. */
1146
+ type StrategyPlan = {
1147
+ readonly summary: string;
1148
+ readonly operations: readonly StrategyOperation[];
1149
+ readonly reasoning: string;
1150
+ };
1151
+ type SuggestStrategyOptions = {
1152
+ model?: string;
1153
+ temperature?: number;
1154
+ maxTokens?: number;
1155
+ actor?: Actor;
1156
+ };
1157
+ /**
1158
+ * Ask an LLM to analyze a graph and suggest topology/parameter changes
1159
+ * to solve a stated problem.
1160
+ *
1161
+ * Returns a structured plan — does NOT auto-apply. The caller reviews
1162
+ * and selectively applies operations.
1163
+ *
1164
+ * @param graph - The graph to analyze.
1165
+ * @param problem - Natural-language problem statement.
1166
+ * @param adapter - LLM adapter for the analysis call.
1167
+ * @param opts - Model and actor options.
1168
+ * @returns A structured strategy plan.
1169
+ * @throws On invalid LLM output.
1170
+ */
1171
+ declare function suggestStrategy(graph: Graph, problem: string, adapter: LLMAdapter, opts?: SuggestStrategyOptions): Promise<StrategyPlan>;
1172
+
1173
+ type ai_AdmissionScore3DOptions = AdmissionScore3DOptions;
1174
+ type ai_AdmissionScores = AdmissionScores;
1175
+ type ai_AgentLoopGraph = AgentLoopGraph;
1176
+ declare const ai_AgentLoopGraph: typeof AgentLoopGraph;
1177
+ type ai_AgentLoopOptions = AgentLoopOptions;
1178
+ type ai_AgentLoopStatus = AgentLoopStatus;
1179
+ type ai_AgentMemoryGraph<TMem = unknown> = AgentMemoryGraph<TMem>;
1180
+ type ai_AgentMemoryOptions<TMem = unknown> = AgentMemoryOptions<TMem>;
1181
+ type ai_ChatMessage = ChatMessage;
1182
+ type ai_ChatStreamGraph = ChatStreamGraph;
1183
+ declare const ai_ChatStreamGraph: typeof ChatStreamGraph;
1184
+ type ai_ChatStreamOptions = ChatStreamOptions;
1185
+ type ai_FromLLMOptions = FromLLMOptions;
1186
+ type ai_FromLLMStreamOptions = FromLLMStreamOptions;
1187
+ type ai_GaugesAsContextOptions = GaugesAsContextOptions;
1188
+ type ai_GraphDefValidation = GraphDefValidation;
1189
+ type ai_GraphFromSpecOptions = GraphFromSpecOptions;
1190
+ type ai_KnobsAsToolsResult = KnobsAsToolsResult;
1191
+ type ai_LLMAdapter = LLMAdapter;
1192
+ type ai_LLMConsolidatorOptions = LLMConsolidatorOptions;
1193
+ type ai_LLMExtractorOptions = LLMExtractorOptions;
1194
+ type ai_LLMInvokeOptions = LLMInvokeOptions;
1195
+ type ai_LLMResponse = LLMResponse;
1196
+ type ai_LLMStreamHandle = LLMStreamHandle;
1197
+ type ai_McpToolSchema = McpToolSchema;
1198
+ type ai_MemoryTier = MemoryTier;
1199
+ type ai_MemoryTiersBundle<TMem> = MemoryTiersBundle<TMem>;
1200
+ type ai_MemoryTiersOptions<TMem> = MemoryTiersOptions<TMem>;
1201
+ type ai_OpenAIToolSchema = OpenAIToolSchema;
1202
+ type ai_RetrievalEntry<TMem> = RetrievalEntry<TMem>;
1203
+ type ai_RetrievalPipelineOptions<TMem> = RetrievalPipelineOptions<TMem>;
1204
+ type ai_RetrievalQuery = RetrievalQuery;
1205
+ type ai_RetrievalTrace<TMem> = RetrievalTrace<TMem>;
1206
+ type ai_StrategyOperation = StrategyOperation;
1207
+ type ai_StrategyPlan = StrategyPlan;
1208
+ type ai_SuggestStrategyOptions = SuggestStrategyOptions;
1209
+ type ai_SystemPromptHandle = SystemPromptHandle;
1210
+ type ai_ToolCall = ToolCall;
1211
+ type ai_ToolDefinition = ToolDefinition;
1212
+ type ai_ToolRegistryGraph = ToolRegistryGraph;
1213
+ declare const ai_ToolRegistryGraph: typeof ToolRegistryGraph;
1214
+ type ai_ToolRegistryOptions = ToolRegistryOptions;
1215
+ declare const ai_admissionFilter3D: typeof admissionFilter3D;
1216
+ declare const ai_agentLoop: typeof agentLoop;
1217
+ declare const ai_agentMemory: typeof agentMemory;
1218
+ declare const ai_chatStream: typeof chatStream;
1219
+ declare const ai_fromLLM: typeof fromLLM;
1220
+ declare const ai_fromLLMStream: typeof fromLLMStream;
1221
+ declare const ai_gaugesAsContext: typeof gaugesAsContext;
1222
+ declare const ai_graphFromSpec: typeof graphFromSpec;
1223
+ declare const ai_knobsAsTools: typeof knobsAsTools;
1224
+ declare const ai_llmConsolidator: typeof llmConsolidator;
1225
+ declare const ai_llmExtractor: typeof llmExtractor;
1226
+ declare const ai_suggestStrategy: typeof suggestStrategy;
1227
+ declare const ai_systemPromptBuilder: typeof systemPromptBuilder;
1228
+ declare const ai_toolRegistry: typeof toolRegistry;
1229
+ declare const ai_validateGraphDef: typeof validateGraphDef;
1230
+ declare namespace ai {
1231
+ export { type ai_AdmissionScore3DOptions as AdmissionScore3DOptions, type ai_AdmissionScores as AdmissionScores, ai_AgentLoopGraph as AgentLoopGraph, type ai_AgentLoopOptions as AgentLoopOptions, type ai_AgentLoopStatus as AgentLoopStatus, type ai_AgentMemoryGraph as AgentMemoryGraph, type ai_AgentMemoryOptions as AgentMemoryOptions, type ai_ChatMessage as ChatMessage, ai_ChatStreamGraph as ChatStreamGraph, type ai_ChatStreamOptions as ChatStreamOptions, type ai_FromLLMOptions as FromLLMOptions, type ai_FromLLMStreamOptions as FromLLMStreamOptions, type ai_GaugesAsContextOptions as GaugesAsContextOptions, type ai_GraphDefValidation as GraphDefValidation, type ai_GraphFromSpecOptions as GraphFromSpecOptions, type ai_KnobsAsToolsResult as KnobsAsToolsResult, type ai_LLMAdapter as LLMAdapter, type ai_LLMConsolidatorOptions as LLMConsolidatorOptions, type ai_LLMExtractorOptions as LLMExtractorOptions, type ai_LLMInvokeOptions as LLMInvokeOptions, type ai_LLMResponse as LLMResponse, type ai_LLMStreamHandle as LLMStreamHandle, type ai_McpToolSchema as McpToolSchema, type ai_MemoryTier as MemoryTier, type ai_MemoryTiersBundle as MemoryTiersBundle, type ai_MemoryTiersOptions as MemoryTiersOptions, type ai_OpenAIToolSchema as OpenAIToolSchema, type ai_RetrievalEntry as RetrievalEntry, type ai_RetrievalPipelineOptions as RetrievalPipelineOptions, type ai_RetrievalQuery as RetrievalQuery, type ai_RetrievalTrace as RetrievalTrace, type ai_StrategyOperation as StrategyOperation, type ai_StrategyPlan as StrategyPlan, type ai_SuggestStrategyOptions as SuggestStrategyOptions, type ai_SystemPromptHandle as SystemPromptHandle, type ai_ToolCall as ToolCall, type ai_ToolDefinition as ToolDefinition, ai_ToolRegistryGraph as ToolRegistryGraph, type ai_ToolRegistryOptions as ToolRegistryOptions, ai_admissionFilter3D as admissionFilter3D, ai_agentLoop as agentLoop, ai_agentMemory as agentMemory, ai_chatStream as chatStream, ai_fromLLM as fromLLM, ai_fromLLMStream as fromLLMStream, ai_gaugesAsContext as gaugesAsContext, ai_graphFromSpec as graphFromSpec, ai_knobsAsTools as knobsAsTools, ai_llmConsolidator as llmConsolidator, ai_llmExtractor as llmExtractor, ai_suggestStrategy as suggestStrategy, ai_systemPromptBuilder as systemPromptBuilder, ai_toolRegistry as toolRegistry, ai_validateGraphDef as validateGraphDef };
1232
+ }
1233
+
1234
+ /**
1235
+ * Messaging patterns (roadmap §4.2).
1236
+ *
1237
+ * Pulsar-inspired messaging features modeled as graph factories:
1238
+ * - `topic()` for append-only topic streams
1239
+ * - `subscription()` for cursor-based consumers
1240
+ * - `jobQueue()` for queue claim/ack flow
1241
+ */
1242
+
1243
+ type TopicOptions = {
1244
+ graph?: GraphOptions;
1245
+ retainedLimit?: number;
1246
+ };
1247
+ declare class TopicGraph<T> extends Graph {
1248
+ private readonly _log;
1249
+ private readonly _keepaliveDisposers;
1250
+ readonly events: Node<ReactiveLogSnapshot<T>>;
1251
+ readonly latest: Node<T | undefined>;
1252
+ constructor(name: string, opts?: TopicOptions);
1253
+ destroy(): void;
1254
+ publish(value: T): void;
1255
+ retained(): readonly T[];
1256
+ }
1257
+ type SubscriptionOptions = {
1258
+ graph?: GraphOptions;
1259
+ cursor?: number;
1260
+ };
1261
+ declare class SubscriptionGraph<T> extends Graph {
1262
+ private readonly _keepaliveDisposers;
1263
+ readonly source: Node<ReactiveLogSnapshot<T>>;
1264
+ readonly cursor: Node<number>;
1265
+ readonly available: Node<readonly T[]>;
1266
+ constructor(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions);
1267
+ destroy(): void;
1268
+ ack(count?: number): number;
1269
+ pull(limit?: number, opts?: {
1270
+ ack?: boolean;
1271
+ }): readonly T[];
1272
+ }
1273
+ type JobState = "queued" | "inflight";
1274
+ type JobEnvelope<T> = {
1275
+ id: string;
1276
+ payload: T;
1277
+ attempts: number;
1278
+ metadata: Readonly<Record<string, unknown>>;
1279
+ state: JobState;
1280
+ };
1281
+ type JobQueueOptions = {
1282
+ graph?: GraphOptions;
1283
+ };
1284
+ declare class JobQueueGraph<T> extends Graph {
1285
+ private readonly _pending;
1286
+ private readonly _jobs;
1287
+ private readonly _keepaliveDisposers;
1288
+ private _seq;
1289
+ readonly pending: Node<ReactiveListSnapshot<string>>;
1290
+ readonly jobs: Node<ReactiveMapSnapshot<string, JobEnvelope<T>>>;
1291
+ readonly depth: Node<number>;
1292
+ constructor(name: string, opts?: JobQueueOptions);
1293
+ destroy(): void;
1294
+ enqueue(payload: T, opts?: {
1295
+ id?: string;
1296
+ metadata?: Record<string, unknown>;
1297
+ }): string;
1298
+ claim(limit?: number): readonly JobEnvelope<T>[];
1299
+ ack(id: string): boolean;
1300
+ nack(id: string, opts?: {
1301
+ requeue?: boolean;
1302
+ }): boolean;
1303
+ }
1304
+ type JobFlowOptions = {
1305
+ graph?: GraphOptions;
1306
+ stages?: readonly string[];
1307
+ maxPerPump?: number;
1308
+ };
1309
+ declare class JobFlowGraph<T> extends Graph {
1310
+ private readonly _stageNames;
1311
+ private readonly _queues;
1312
+ private readonly _keepaliveDisposers;
1313
+ private readonly _completed;
1314
+ readonly completed: Node<ReactiveLogSnapshot<JobEnvelope<T>>>;
1315
+ readonly completedCount: Node<number>;
1316
+ constructor(name: string, opts?: JobFlowOptions);
1317
+ destroy(): void;
1318
+ stages(): readonly string[];
1319
+ queue(stage: string): JobQueueGraph<T>;
1320
+ enqueue(payload: T, opts?: {
1321
+ id?: string;
1322
+ metadata?: Record<string, unknown>;
1323
+ }): string;
1324
+ retainedCompleted(): readonly JobEnvelope<T>[];
1325
+ }
1326
+ type TopicBridgeOptions<TIn, TOut> = {
1327
+ graph?: GraphOptions;
1328
+ cursor?: number;
1329
+ maxPerPump?: number;
1330
+ map?: (value: TIn) => TOut | undefined;
1331
+ };
1332
+ declare class TopicBridgeGraph<TIn, TOut = TIn> extends Graph {
1333
+ private readonly _sourceSub;
1334
+ private readonly _target;
1335
+ private readonly _keepaliveDisposers;
1336
+ readonly bridgedCount: Node<number>;
1337
+ constructor(name: string, sourceTopic: TopicGraph<TIn>, targetTopic: TopicGraph<TOut>, opts?: TopicBridgeOptions<TIn, TOut>);
1338
+ destroy(): void;
1339
+ }
1340
+ /**
1341
+ * Creates a Pulsar-inspired topic graph (append-only retained stream + latest value).
1342
+ */
1343
+ declare function topic<T>(name: string, opts?: TopicOptions): TopicGraph<T>;
1344
+ /**
1345
+ * Creates a cursor-based subscription graph over a topic.
1346
+ */
1347
+ declare function subscription<T>(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions): SubscriptionGraph<T>;
1348
+ /**
1349
+ * Creates a Pulsar-inspired job queue graph with claim/ack/nack workflow.
1350
+ */
1351
+ declare function jobQueue<T>(name: string, opts?: JobQueueOptions): JobQueueGraph<T>;
1352
+ /**
1353
+ * Creates an autonomous multi-stage queue chain graph.
1354
+ */
1355
+ declare function jobFlow<T>(name: string, opts?: JobFlowOptions): JobFlowGraph<T>;
1356
+ /**
1357
+ * Creates an autonomous cursor-based topic relay graph.
1358
+ */
1359
+ declare function topicBridge<TIn, TOut = TIn>(name: string, sourceTopic: TopicGraph<TIn>, targetTopic: TopicGraph<TOut>, opts?: TopicBridgeOptions<TIn, TOut>): TopicBridgeGraph<TIn, TOut>;
1360
+
1361
+ type messaging_JobEnvelope<T> = JobEnvelope<T>;
1362
+ type messaging_JobFlowGraph<T> = JobFlowGraph<T>;
1363
+ declare const messaging_JobFlowGraph: typeof JobFlowGraph;
1364
+ type messaging_JobFlowOptions = JobFlowOptions;
1365
+ type messaging_JobQueueGraph<T> = JobQueueGraph<T>;
1366
+ declare const messaging_JobQueueGraph: typeof JobQueueGraph;
1367
+ type messaging_JobQueueOptions = JobQueueOptions;
1368
+ type messaging_JobState = JobState;
1369
+ type messaging_SubscriptionGraph<T> = SubscriptionGraph<T>;
1370
+ declare const messaging_SubscriptionGraph: typeof SubscriptionGraph;
1371
+ type messaging_SubscriptionOptions = SubscriptionOptions;
1372
+ type messaging_TopicBridgeGraph<TIn, TOut = TIn> = TopicBridgeGraph<TIn, TOut>;
1373
+ declare const messaging_TopicBridgeGraph: typeof TopicBridgeGraph;
1374
+ type messaging_TopicBridgeOptions<TIn, TOut> = TopicBridgeOptions<TIn, TOut>;
1375
+ type messaging_TopicGraph<T> = TopicGraph<T>;
1376
+ declare const messaging_TopicGraph: typeof TopicGraph;
1377
+ type messaging_TopicOptions = TopicOptions;
1378
+ declare const messaging_jobFlow: typeof jobFlow;
1379
+ declare const messaging_jobQueue: typeof jobQueue;
1380
+ declare const messaging_subscription: typeof subscription;
1381
+ declare const messaging_topic: typeof topic;
1382
+ declare const messaging_topicBridge: typeof topicBridge;
1383
+ declare namespace messaging {
1384
+ export { type messaging_JobEnvelope as JobEnvelope, messaging_JobFlowGraph as JobFlowGraph, type messaging_JobFlowOptions as JobFlowOptions, messaging_JobQueueGraph as JobQueueGraph, type messaging_JobQueueOptions as JobQueueOptions, type messaging_JobState as JobState, messaging_SubscriptionGraph as SubscriptionGraph, type messaging_SubscriptionOptions as SubscriptionOptions, messaging_TopicBridgeGraph as TopicBridgeGraph, type messaging_TopicBridgeOptions as TopicBridgeOptions, messaging_TopicGraph as TopicGraph, type messaging_TopicOptions as TopicOptions, messaging_jobFlow as jobFlow, messaging_jobQueue as jobQueue, messaging_subscription as subscription, messaging_topic as topic, messaging_topicBridge as topicBridge };
1385
+ }
1386
+
1387
+ /**
1388
+ * Orchestration patterns (roadmap §4.1).
1389
+ *
1390
+ * Domain-layer helpers that build workflow shapes on top of core + extra primitives.
1391
+ * Exported under the `patterns.orchestration` namespace to avoid collisions with
1392
+ * Phase 2 operator names (for example `gate`, `forEach`).
1393
+ */
1394
+
1395
+ type StepRef = string | Node<unknown>;
1396
+ type OrchestrationMeta = {
1397
+ orchestration?: true;
1398
+ orchestration_type?: string;
1399
+ };
1400
+ type OrchestrationStepOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
1401
+ deps?: ReadonlyArray<StepRef>;
1402
+ meta?: Record<string, unknown> & OrchestrationMeta;
1403
+ };
1404
+ type BranchResult<T> = {
1405
+ branch: "then" | "else";
1406
+ value: T;
1407
+ };
1408
+ type SensorControls<T> = {
1409
+ node: Node<T>;
1410
+ push(value: T): void;
1411
+ error(err: unknown): void;
1412
+ complete(): void;
1413
+ };
1414
+ type LoopOptions = Omit<OrchestrationStepOptions, "deps"> & {
1415
+ iterations?: number | StepRef;
1416
+ };
1417
+ type WaitOptions = Omit<OrchestrationStepOptions, "deps">;
1418
+ type SubPipelineBuilder = (sub: Graph) => void;
1419
+ /**
1420
+ * Creates an orchestration graph container.
1421
+ */
1422
+ declare function pipeline(name: string, opts?: GraphOptions): Graph;
1423
+ /**
1424
+ * Registers a workflow task node.
1425
+ */
1426
+ declare function task<T>(graph: Graph, name: string, run: NodeFn<T>, opts?: OrchestrationStepOptions): Node<T>;
1427
+ /**
1428
+ * Emits tagged branch outcomes (`then` / `else`) for each source value.
1429
+ */
1430
+ declare function branch<T>(graph: Graph, name: string, source: StepRef, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
1431
+ /**
1432
+ * Forwards source values only while `control` is truthy.
1433
+ */
1434
+ declare function gate<T>(graph: Graph, name: string, source: StepRef, control: StepRef, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
1435
+ type ApprovalOptions = Omit<OrchestrationStepOptions, "deps"> & {
1436
+ isApproved?: (value: unknown) => boolean;
1437
+ };
1438
+ /**
1439
+ * Human/LLM approval gate over a source value.
1440
+ */
1441
+ declare function approval<T>(graph: Graph, name: string, source: StepRef, approver: StepRef, opts?: ApprovalOptions): Node<T>;
1442
+ /**
1443
+ * Registers a workflow side-effect step. The step remains graph-observable and forwards messages.
1444
+ */
1445
+ declare function forEach<T>(graph: Graph, name: string, source: StepRef, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
1446
+ /**
1447
+ * Registers a join step that emits a tuple of latest dependency values.
1448
+ */
1449
+ declare function join<T extends readonly unknown[]>(graph: Graph, name: string, deps: {
1450
+ [K in keyof T]: StepRef;
1451
+ }, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
1452
+ /**
1453
+ * Registers a loop step that applies `iterate` to each source value N times.
1454
+ */
1455
+ declare function loop<T>(graph: Graph, name: string, source: StepRef, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
1456
+ /**
1457
+ * Mounts and returns a child workflow graph.
1458
+ */
1459
+ declare function subPipeline(graph: Graph, name: string, childOrBuild?: Graph | SubPipelineBuilder, opts?: GraphOptions): Graph;
1460
+ /**
1461
+ * Registers a producer-style sensor source and returns imperative controls.
1462
+ */
1463
+ declare function sensor<T>(graph: Graph, name: string, initial?: T, opts?: Omit<NodeOptions, "name" | "describeKind" | "meta"> & {
1464
+ meta?: Record<string, unknown>;
1465
+ }): SensorControls<T>;
1466
+ /**
1467
+ * Registers a delayed-forwarding step (value-level wait).
1468
+ */
1469
+ declare function wait<T>(graph: Graph, name: string, source: StepRef, ms: number, opts?: WaitOptions): Node<T>;
1470
+ /**
1471
+ * Registers an error-recovery step for a source.
1472
+ */
1473
+ declare function onFailure<T>(graph: Graph, name: string, source: StepRef, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
1474
+
1475
+ type orchestration_ApprovalOptions = ApprovalOptions;
1476
+ type orchestration_BranchResult<T> = BranchResult<T>;
1477
+ type orchestration_LoopOptions = LoopOptions;
1478
+ type orchestration_OrchestrationStepOptions = OrchestrationStepOptions;
1479
+ type orchestration_SensorControls<T> = SensorControls<T>;
1480
+ type orchestration_StepRef = StepRef;
1481
+ type orchestration_SubPipelineBuilder = SubPipelineBuilder;
1482
+ type orchestration_WaitOptions = WaitOptions;
1483
+ declare const orchestration_approval: typeof approval;
1484
+ declare const orchestration_branch: typeof branch;
1485
+ declare const orchestration_forEach: typeof forEach;
1486
+ declare const orchestration_gate: typeof gate;
1487
+ declare const orchestration_join: typeof join;
1488
+ declare const orchestration_loop: typeof loop;
1489
+ declare const orchestration_onFailure: typeof onFailure;
1490
+ declare const orchestration_pipeline: typeof pipeline;
1491
+ declare const orchestration_sensor: typeof sensor;
1492
+ declare const orchestration_subPipeline: typeof subPipeline;
1493
+ declare const orchestration_task: typeof task;
1494
+ declare const orchestration_wait: typeof wait;
1495
+ declare namespace orchestration {
1496
+ 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 orchestration_StepRef 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 };
1497
+ }
1498
+
1499
+ /**
1500
+ * Patterns layer: domain/solution helpers (Phase 4+).
1501
+ */
1502
+
1503
+ declare const index_ai: typeof ai;
1504
+ declare const index_cqrs: typeof cqrs;
1505
+ declare const index_memory: typeof memory;
1506
+ declare const index_messaging: typeof messaging;
1507
+ declare const index_orchestration: typeof orchestration;
1508
+ declare namespace index {
1509
+ export { index_ai as ai, index_cqrs as cqrs, index$b as layout, index_memory as memory, index_messaging as messaging, index_orchestration as orchestration };
1510
+ }
1511
+
1512
+ /**
1513
+ * GraphRefly — public API surface.
1514
+ */
1515
+ declare const version = "0.0.0";
1516
+
1517
+ export { Actor, AutoCheckpointAdapter, DistillBundle, Extraction, Graph, GraphAutoCheckpointHandle, GraphAutoCheckpointOptions, GraphOptions, Node, NodeActions, NodeFn, NodeInput, NodeOptions, ReactiveListSnapshot, ReactiveLogSnapshot, ReactiveMapSnapshot, ai, index$1 as compat, cqrs, 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 };