@graphrefly/graphrefly 0.18.0 → 0.20.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/{chunk-J7S54G7I.js → chunk-2L5J6RPM.js} +7 -2
- package/dist/chunk-2L5J6RPM.js.map +1 -0
- package/dist/{chunk-LB3RYLSC.js → chunk-3N2Y6PCR.js} +197 -42
- package/dist/chunk-3N2Y6PCR.js.map +1 -0
- package/dist/{chunk-KJGUP35I.js → chunk-5PSVTDNZ.js} +22 -9
- package/dist/chunk-5PSVTDNZ.js.map +1 -0
- package/dist/{chunk-76YPZQTW.js → chunk-BJAOEU4D.js} +34 -29
- package/dist/chunk-BJAOEU4D.js.map +1 -0
- package/dist/{chunk-UVWEKTYC.js → chunk-IAPLC4NR.js} +3 -3
- package/dist/{chunk-F6ORUNO7.js → chunk-OOA2UTXF.js} +58 -2
- package/dist/chunk-OOA2UTXF.js.map +1 -0
- package/dist/{chunk-TNKODJ6E.js → chunk-PGEU5MEH.js} +7 -3
- package/dist/{chunk-TNKODJ6E.js.map → chunk-PGEU5MEH.js.map} +1 -1
- package/dist/chunk-R2LPZIY2.js +111 -0
- package/dist/chunk-R2LPZIY2.js.map +1 -0
- package/dist/{chunk-BV3TPSBK.js → chunk-XYL3GLB3.js} +742 -757
- package/dist/chunk-XYL3GLB3.js.map +1 -0
- package/dist/compat/nestjs/index.cjs +967 -811
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +4 -4
- package/dist/compat/nestjs/index.d.ts +4 -4
- package/dist/compat/nestjs/index.js +7 -7
- package/dist/core/index.cjs +653 -666
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +7 -3
- package/dist/extra/index.cjs +728 -688
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.d.cts +4 -4
- package/dist/extra/index.d.ts +4 -4
- package/dist/extra/index.js +9 -5
- package/dist/graph/index.cjs +836 -808
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +3 -3
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.js +8 -8
- package/dist/{graph-gISB9n3n.d.ts → graph-KsTe57nI.d.cts} +82 -8
- package/dist/{graph-BYFlyNpX.d.cts → graph-mILUUqW8.d.ts} +82 -8
- package/dist/{index-CgKPpiu8.d.ts → index-8a605sg9.d.ts} +2 -2
- package/dist/{index-DKaB2x0T.d.ts → index-B2SvPEbc.d.ts} +6 -65
- package/dist/{index-EmzYk-TG.d.cts → index-BHfg_Ez3.d.ts} +123 -77
- package/dist/{index-B80mMeuf.d.ts → index-Bc_diYYJ.d.cts} +123 -77
- package/dist/{index-B43mC7uY.d.cts → index-BjtlNirP.d.cts} +3 -3
- package/dist/{index-CEDaJaYE.d.ts → index-CgSiUouz.d.ts} +3 -3
- package/dist/{index-7WnwgjMu.d.ts → index-DuN3bhtm.d.ts} +82 -32
- package/dist/{index-D_tUMcpz.d.cts → index-SFzE_KTa.d.cts} +82 -32
- package/dist/{index-Ci_vPaVm.d.cts → index-UudxGnzc.d.cts} +6 -65
- package/dist/{index-BqOWSFhr.d.cts → index-VHA43cGP.d.cts} +2 -2
- package/dist/index.cjs +5936 -5522
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +644 -379
- package/dist/index.d.ts +644 -379
- package/dist/index.js +4388 -4058
- package/dist/index.js.map +1 -1
- package/dist/{meta-npl5b97j.d.cts → meta-BnG7XAaE.d.cts} +394 -236
- package/dist/{meta-npl5b97j.d.ts → meta-BnG7XAaE.d.ts} +394 -236
- package/dist/{observable-DFBCBELR.d.cts → observable-C8Kx_O6k.d.cts} +1 -1
- package/dist/{observable-oAGygKvc.d.ts → observable-DcBwQY7t.d.ts} +1 -1
- package/dist/patterns/reactive-layout/index.cjs +865 -718
- package/dist/patterns/reactive-layout/index.cjs.map +1 -1
- package/dist/patterns/reactive-layout/index.d.cts +3 -3
- package/dist/patterns/reactive-layout/index.d.ts +3 -3
- package/dist/patterns/reactive-layout/index.js +4 -4
- package/package.json +2 -2
- package/dist/chunk-76YPZQTW.js.map +0 -1
- package/dist/chunk-BV3TPSBK.js.map +0 -1
- package/dist/chunk-F6ORUNO7.js.map +0 -1
- package/dist/chunk-FCLROC4Q.js +0 -231
- package/dist/chunk-FCLROC4Q.js.map +0 -1
- package/dist/chunk-J7S54G7I.js.map +0 -1
- package/dist/chunk-KJGUP35I.js.map +0 -1
- package/dist/chunk-LB3RYLSC.js.map +0 -1
- /package/dist/{chunk-UVWEKTYC.js.map → chunk-IAPLC4NR.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { N as Node,
|
|
2
|
-
export { C as CLEANUP_RESULT,
|
|
3
|
-
import { i as index$b, c as cqrs } from './index-
|
|
1
|
+
import { N as Node, a as NodeOptions, b as NodeActions, A as Actor } from './meta-BnG7XAaE.cjs';
|
|
2
|
+
export { C as CLEANUP_RESULT, c as COMPLETE, d as CleanupResult, D as DATA, e as DEFAULT_ACTOR, f as DIRTY, g as DescribeDetail, h as DescribeField, i as DescribeNodeOutput, E as ERROR, G as GuardAction, j as GuardDenied, k as GuardDeniedDetails, H as HashFn, I as INVALIDATE, M as Message, l as Messages, m as NodeDescribeKind, n as NodeGuard, o as NodeSink, p as NodeStatus, q as NodeTransportOptions, r as NodeVersionInfo, O as OnMessageHandler, P as PAUSE, s as PolicyAllow, t as PolicyDeny, u as PolicyRuleData, R as RESOLVED, v as RESUME, S as START, w as SubscribeHints, T as TEARDOWN, V as V0, x as V1, y as VersioningLevel, z as VersioningOptions, B as accessHintForGuard, F as advanceVersion, J as cleanupResult, K as createVersioning, L as defaultHash, Q as isKnownMessageType, U as isLocalOnly, W as isPhase2Message, X as isTerminalMessage, Y as isV1, Z as knownMessageTypes, _ as messageTier, $ as normalizeActor, a0 as policy, a1 as policyFromRules, a2 as propagatesToMeta, a3 as resolveDescribeFields } from './meta-BnG7XAaE.cjs';
|
|
3
|
+
import { i as index$b, c as cqrs } from './index-BjtlNirP.cjs';
|
|
4
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-
|
|
6
|
-
export { D as DescribeFilter,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export { D as DeltaCheckpoint, E as EvictedSubgraphInfo,
|
|
12
|
-
import { M as MeasurementAdapter, i as index$c } from './index-
|
|
13
|
-
export { T as ToObservableOptions, t as toObservable } from './observable-
|
|
5
|
+
import { G as Graph, a as GraphOptions, b as GraphAutoCheckpointHandle, A as AutoCheckpointAdapter, c as GraphAutoCheckpointOptions, d as GraphProfileResult, e as GraphProfileOptions } from './graph-KsTe57nI.cjs';
|
|
6
|
+
export { D as DescribeFilter, f as GRAPH_META_SEGMENT, g as GraphActorOptions, h as GraphCheckpointRecord, i as GraphDescribeOptions, j as GraphDescribeOutput, k as GraphDiagramDirection, l as GraphDiagramOptions, m as GraphDiffChange, n as GraphDiffResult, o as GraphDumpOptions, p as GraphFactoryContext, q as GraphNodeFactory, r as GraphObserveAll, s as GraphObserveOne, t as GraphPersistSnapshot, N as NodeProfile, O as ObserveDetail, u as ObserveEvent, v as ObserveOptions, w as ObserveResult, x as ObserveTheme, y as ObserveThemeName, R as ReachableDirection, z as ReachableOptions, T as TraceEntry, B as graphProfile, C as reachable } from './graph-KsTe57nI.cjs';
|
|
7
|
+
import { N as NodeFn } from './index-Bc_diYYJ.cjs';
|
|
8
|
+
export { B as BridgeOptions, D as DEFAULT_DOWN, a as DownStrategy, b as DynGet, c as DynamicNodeFn, d as DynamicNodeImpl, e as DynamicNodeOptions, P as PipeOperator, R as ResettableTimer, f as batch, g as bridge, i as core, h as derived, j as downWithBatch, k as dynamicNode, l as effect, m as isBatching, n as monotonicNs, o as node, p as partitionForBatch, q as pipe, r as producer, s as state, w as wallClockNs } from './index-Bc_diYYJ.cjs';
|
|
9
|
+
import { N as NodeInput, D as DistillBundle, E as Extraction } from './index-SFzE_KTa.cjs';
|
|
10
|
+
export { A as AdapterHandlers, a as AsyncSourceOpts, B as BackoffPreset, b as BackoffStrategy, c as BatchMessage, d as BridgeMessage, e as BufferedSinkHandle, C as CSVRow, f as CacheEvictionPolicy, g as CacheTier, h as CascadingCache, i as CascadingCacheOptions, j as CheckpointAdapter, k as CheckpointToRedisOptions, l as CheckpointToS3Options, m as CircuitBreaker, n as CircuitBreakerOptions, o as CircuitOpenError, p as CircuitState, q as ClickHouseClientLike, r as ClickHouseInsertClientLike, s as ClickHouseRow, t as CronSchedule, u as DictCheckpointAdapter, v as DistillOptions, w as DrizzleQueryLike, x as ErrorMessage, y as EventTargetLike, z as ExponentialBackoffOptions, F as FSEvent, G as FSEventType, H as FileCheckpointAdapter, I as FileWriterLike, J as FromCSVOptions, K as FromClickHouseWatchOptions, L as FromCronOptions, M as FromDrizzleOptions, O as FromFSWatchOptions, P as FromGitHookOptions, Q as FromHTTPOptions, R as FromKafkaOptions, S as FromKyselyOptions, T as FromMCPOptions, U as FromNATSOptions, V as FromNDJSONOptions, W as FromOTelOptions, X as FromPrismaOptions, Y as FromPrometheusOptions, Z as FromPulsarOptions, _ as FromRabbitMQOptions, $ as FromRedisStreamOptions, a0 as FromSqliteOptions, a1 as FromStatsDOptions, a2 as FromSyslogOptions, a3 as GitEvent, a4 as GitHookType, a5 as HTTPBundle, a6 as IndexRow, a7 as IndexedDbCheckpointSpec, a8 as InitMessage, a9 as JitterMode, aa as KafkaConsumerLike, ab as KafkaMessage, ac as KafkaProducerLike, ad as KyselyQueryLike, ae as LokiClientLike, af as LokiStream, ag as MCPClientLike, ah as MemoryCheckpointAdapter, ai as MergeMapOptions, aj as MongoCollectionLike, ak as NATSClientLike, al as NATSMessage, am as NATSSubscriptionLike, an as NS_PER_MS, ao as NS_PER_SEC, ap as OTelBundle, aq as OTelLog, ar as OTelMetric, as as OTelRegister, at as OTelSpan, au as PostgresClientLike, av as PrismaModelLike, aw as PrometheusMetric, ax as PubSubHub, ay as PulsarConsumerLike, az as PulsarMessage, aA as PulsarProducerLike, aB as RabbitMQChannelLike, aC as RabbitMQMessage, aD as ReactiveCounterBundle, aE as ReactiveIndexBundle, aF as ReactiveIndexOptions, aG as ReactiveListBundle, aH as ReactiveListOptions, aI as ReactiveLogBundle, aJ as ReactiveLogOptions, aK as ReactiveMapBundle, aL as ReactiveMapOptions, aM as ReadyMessage, aN as RedisCheckpointClientLike, aO as RedisClientLike, aP as RedisStreamEntry, aQ as RetryOptions, aR as S3ClientLike, aS as SignalMessage, aT as SinkHandle, aU as SinkTransportError, aV as SqliteCheckpointAdapter, aW as SqliteDbLike, aX as StatsDMetric, aY as StatsDRegister, aZ as StatusValue, a_ as SyslogMessage, a$ as SyslogRegister, b0 as TapObserver, b1 as TempoClientLike, b2 as ThrottleOptions, b3 as TieredStorage, b4 as TieredStorageOptions, b5 as TimeoutError, b6 as ToCSVOptions, b7 as ToClickHouseOptions, b8 as ToFileOptions, b9 as ToKafkaOptions, ba as ToLokiOptions, bb as ToMongoOptions, bc as ToNATSOptions, bd as ToPostgresOptions, be as ToPulsarOptions, bf as ToRabbitMQOptions, bg as ToRedisStreamOptions, bh as ToS3Options, bi as ToSSEOptions, bj as ToSqliteOptions, bk as ToTempoOptions, bl as ToWebSocketOptions, bm as ToWebSocketTransportError, bn as TokenBucket, bo as ValueMessage, bp as VerifiableBundle, bq as VerifiableOptions, br as VerifyValue, bs as WatermarkController, bt as WatermarkOptions, bu as WebSocketLike, bv as WebSocketMessageEventLike, bw as WebSocketRegister, bx as WebhookRegister, by as WithBreakerBundle, bz as WithStatusBundle, bA as WorkerBridge, bB as WorkerBridgeOptions, bC as WorkerSelfHandle, bD as WorkerSelfOptions, bE as WorkerTransport, bF as audit, bG as buffer, bH as bufferCount, bI as bufferTime, bJ as cache, bK as cached, bL as cascadingCache, bM as catchError, bN as checkpointNodeValue, bO as checkpointToRedis, bP as checkpointToS3, bQ as circuitBreaker, bR as combine, bS as combineLatest, bT as concat, bU as concatMap, bV as constant, bW as createTransport, bX as createWatermarkController, bY as debounce, bZ as debounceTime, b_ as decorrelatedJitter, b$ as delay, c0 as deserializeError, c1 as distill, c2 as distinctUntilChanged, c3 as elementAt, c4 as empty, c5 as escapeRegexChar, c6 as exhaustMap, c7 as exponential, c8 as extra, c9 as fallback, ca as fibonacci, cb as filter, cc as find, cd as first, ce as firstValueFrom, cf as firstWhere, cg as flatMap, ch as forEach, ci as fromAny, cj as fromAsyncIter, ck as fromCSV, cl as fromClickHouseWatch, cm as fromCron, cn as fromDrizzle, co as fromEvent, cp as fromFSWatch, cq as fromGitHook, cr as fromHTTP, cs as fromIDBRequest, ct as fromIDBTransaction, cu as fromIter, cv as fromKafka, cw as fromKysely, cx as fromMCP, cy as fromNATS, cz as fromNDJSON, cA as fromOTel, cB as fromPrisma, cC as fromPrometheus, cD as fromPromise, cE as fromPulsar, cF as fromRabbitMQ, cG as fromRedisStream, cH as fromSqlite, cI as fromStatsD, cJ as fromSyslog, cK as fromTimer, cL as fromWebSocket, cM as fromWebhook, cN as globToRegExp, cO as interval, cP as keepalive, cQ as last, cR as linear, cS as logSlice, cT as lru, cU as map, cV as matchesAnyPattern, cW as matchesCron, cX as merge, cY as mergeMap, cZ as nameToSignal, c_ as never, c$ as of, d0 as pairwise, d1 as parseCron, d2 as parsePrometheusText, d3 as parseStatsD, d4 as parseSyslog, d5 as pausable, d6 as pubsub, d7 as race, d8 as rateLimiter, d9 as reactiveCounter, da as reactiveIndex, db as reactiveList, dc as reactiveLog, dd as reactiveMap, de as reduce, df as repeat, dg as replay, dh as rescue, di as resolveBackoffPreset, dj as restoreGraphCheckpoint, dk as restoreGraphCheckpointIndexedDb, dl as retry, dm as sample, dn as saveGraphCheckpoint, dp as saveGraphCheckpointIndexedDb, dq as scan, dr as serializeError, ds as share, dt as shareReplay, du as signalToName, dv as skip, dw as switchMap, dx as take, dy as takeUntil, dz as takeWhile, dA as tap, dB as throttle, dC as throttleTime, dD as throwError, dE as tieredStorage, dF as timeout, dG as toArray, dH as toCSV, dI as toClickHouse, dJ as toFile, dK as toKafka, dL as toLoki, dM as toMongo, dN as toNATS, dO as toPostgres, dP as toPulsar, dQ as toRabbitMQ, dR as toRedisStream, dS as toS3, dT as toSSE, dU as toSqlite, dV as toTempo, dW as toWebSocket, dX as tokenBucket, dY as tokenTracker, dZ as valve, d_ as verifiable, d$ as window, e0 as windowCount, e1 as windowTime, e2 as withBreaker, e3 as withLatestFrom, e4 as withMaxAttempts, e5 as withStatus, e6 as workerBridge, e7 as workerSelf, e8 as zip } from './index-SFzE_KTa.cjs';
|
|
11
|
+
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, s as sizeof } from './index-UudxGnzc.cjs';
|
|
12
|
+
import { M as MeasurementAdapter, i as index$c } from './index-VHA43cGP.cjs';
|
|
13
|
+
export { T as ToObservableOptions, t as toObservable } from './observable-C8Kx_O6k.cjs';
|
|
14
14
|
import '@nestjs/common';
|
|
15
15
|
import '@nestjs/core';
|
|
16
16
|
import 'rxjs';
|
|
@@ -245,7 +245,7 @@ type NodeFactory$3<K, R extends Record<string, any>> = (key: K) => {
|
|
|
245
245
|
/**
|
|
246
246
|
* Subscribe to a dynamic set of keyed node records.
|
|
247
247
|
* Re-subscribes all per-key fields whenever `keysNode` changes.
|
|
248
|
-
* Key re-sync is gated to settled batches (`messageTier >=
|
|
248
|
+
* Key re-sync is gated to settled batches (`messageTier >= 3`) to avoid DIRTY-phase churn.
|
|
249
249
|
* Guaranteed to clean up strictly with React hook lifecycle, utilizing no global mappings.
|
|
250
250
|
*
|
|
251
251
|
* @param keysNode - Node of current keys (e.g. node IDs)
|
|
@@ -374,7 +374,7 @@ type NodeFactory$2<K, R extends Record<string, any>> = (key: K) => {
|
|
|
374
374
|
/**
|
|
375
375
|
* Subscribe to a dynamic set of keyed node records as a Solid accessor.
|
|
376
376
|
* Re-subscribes all per-key fields whenever `keys` changes.
|
|
377
|
-
* Key re-sync is gated to settled batches (`messageTier >=
|
|
377
|
+
* Key re-sync is gated to settled batches (`messageTier >= 3`) to avoid DIRTY-phase churn.
|
|
378
378
|
*/
|
|
379
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
380
|
|
|
@@ -411,7 +411,7 @@ type NodeFactory$1<K, R extends Record<string, any>> = (key: K) => {
|
|
|
411
411
|
/**
|
|
412
412
|
* Subscribe to a dynamic keyed record of nodes as a Svelte readable store.
|
|
413
413
|
* Re-subscribes all per-key fields whenever `keysNode` changes.
|
|
414
|
-
* Key re-sync is gated to settled batches (`messageTier >=
|
|
414
|
+
* Key re-sync is gated to settled batches (`messageTier >= 3`) to avoid DIRTY-phase churn.
|
|
415
415
|
*/
|
|
416
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
417
|
|
|
@@ -634,6 +634,303 @@ declare namespace memory {
|
|
|
634
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
635
|
}
|
|
636
636
|
|
|
637
|
+
/**
|
|
638
|
+
* Messaging patterns (roadmap §4.2).
|
|
639
|
+
*
|
|
640
|
+
* Pulsar-inspired messaging features modeled as graph factories:
|
|
641
|
+
* - `topic()` for append-only topic streams
|
|
642
|
+
* - `subscription()` for cursor-based consumers
|
|
643
|
+
* - `jobQueue()` for queue claim/ack flow
|
|
644
|
+
*/
|
|
645
|
+
|
|
646
|
+
type TopicOptions = {
|
|
647
|
+
graph?: GraphOptions;
|
|
648
|
+
retainedLimit?: number;
|
|
649
|
+
};
|
|
650
|
+
declare class TopicGraph<T> extends Graph {
|
|
651
|
+
private readonly _log;
|
|
652
|
+
readonly events: Node<readonly T[]>;
|
|
653
|
+
readonly latest: Node<T | undefined>;
|
|
654
|
+
constructor(name: string, opts?: TopicOptions);
|
|
655
|
+
publish(value: T): void;
|
|
656
|
+
retained(): readonly T[];
|
|
657
|
+
}
|
|
658
|
+
type SubscriptionOptions = {
|
|
659
|
+
graph?: GraphOptions;
|
|
660
|
+
cursor?: number;
|
|
661
|
+
};
|
|
662
|
+
declare class SubscriptionGraph<T> extends Graph {
|
|
663
|
+
readonly source: Node<readonly T[]>;
|
|
664
|
+
readonly cursor: Node<number>;
|
|
665
|
+
readonly available: Node<readonly T[]>;
|
|
666
|
+
constructor(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions);
|
|
667
|
+
ack(count?: number): number;
|
|
668
|
+
pull(limit?: number, opts?: {
|
|
669
|
+
ack?: boolean;
|
|
670
|
+
}): readonly T[];
|
|
671
|
+
}
|
|
672
|
+
type JobState = "queued" | "inflight";
|
|
673
|
+
type JobEnvelope<T> = {
|
|
674
|
+
id: string;
|
|
675
|
+
payload: T;
|
|
676
|
+
attempts: number;
|
|
677
|
+
metadata: Readonly<Record<string, unknown>>;
|
|
678
|
+
state: JobState;
|
|
679
|
+
};
|
|
680
|
+
type JobQueueOptions = {
|
|
681
|
+
graph?: GraphOptions;
|
|
682
|
+
};
|
|
683
|
+
declare class JobQueueGraph<T> extends Graph {
|
|
684
|
+
private readonly _pending;
|
|
685
|
+
private readonly _jobs;
|
|
686
|
+
private _seq;
|
|
687
|
+
readonly pending: Node<readonly string[]>;
|
|
688
|
+
readonly jobs: Node<ReadonlyMap<string, JobEnvelope<T>>>;
|
|
689
|
+
readonly depth: Node<number>;
|
|
690
|
+
constructor(name: string, opts?: JobQueueOptions);
|
|
691
|
+
enqueue(payload: T, opts?: {
|
|
692
|
+
id?: string;
|
|
693
|
+
metadata?: Record<string, unknown>;
|
|
694
|
+
}): string;
|
|
695
|
+
claim(limit?: number): readonly JobEnvelope<T>[];
|
|
696
|
+
ack(id: string): boolean;
|
|
697
|
+
nack(id: string, opts?: {
|
|
698
|
+
requeue?: boolean;
|
|
699
|
+
}): boolean;
|
|
700
|
+
}
|
|
701
|
+
type JobFlowOptions = {
|
|
702
|
+
graph?: GraphOptions;
|
|
703
|
+
stages?: readonly string[];
|
|
704
|
+
maxPerPump?: number;
|
|
705
|
+
};
|
|
706
|
+
declare class JobFlowGraph<T> extends Graph {
|
|
707
|
+
private readonly _stageNames;
|
|
708
|
+
private readonly _queues;
|
|
709
|
+
private readonly _completed;
|
|
710
|
+
readonly completed: Node<readonly JobEnvelope<T>[]>;
|
|
711
|
+
readonly completedCount: Node<number>;
|
|
712
|
+
constructor(name: string, opts?: JobFlowOptions);
|
|
713
|
+
stages(): readonly string[];
|
|
714
|
+
queue(stage: string): JobQueueGraph<T>;
|
|
715
|
+
enqueue(payload: T, opts?: {
|
|
716
|
+
id?: string;
|
|
717
|
+
metadata?: Record<string, unknown>;
|
|
718
|
+
}): string;
|
|
719
|
+
retainedCompleted(): readonly JobEnvelope<T>[];
|
|
720
|
+
}
|
|
721
|
+
type TopicBridgeOptions<TIn, TOut> = {
|
|
722
|
+
graph?: GraphOptions;
|
|
723
|
+
cursor?: number;
|
|
724
|
+
maxPerPump?: number;
|
|
725
|
+
map?: (value: TIn) => TOut | undefined;
|
|
726
|
+
};
|
|
727
|
+
declare class TopicBridgeGraph<TIn, TOut = TIn> extends Graph {
|
|
728
|
+
private readonly _sourceSub;
|
|
729
|
+
private readonly _target;
|
|
730
|
+
readonly bridgedCount: Node<number>;
|
|
731
|
+
constructor(name: string, sourceTopic: TopicGraph<TIn>, targetTopic: TopicGraph<TOut>, opts?: TopicBridgeOptions<TIn, TOut>);
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Creates a Pulsar-inspired topic graph (append-only retained stream + latest value).
|
|
735
|
+
*/
|
|
736
|
+
declare function topic<T>(name: string, opts?: TopicOptions): TopicGraph<T>;
|
|
737
|
+
/**
|
|
738
|
+
* Creates a cursor-based subscription graph over a topic.
|
|
739
|
+
*/
|
|
740
|
+
declare function subscription<T>(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions): SubscriptionGraph<T>;
|
|
741
|
+
/**
|
|
742
|
+
* Creates a Pulsar-inspired job queue graph with claim/ack/nack workflow.
|
|
743
|
+
*/
|
|
744
|
+
declare function jobQueue<T>(name: string, opts?: JobQueueOptions): JobQueueGraph<T>;
|
|
745
|
+
/**
|
|
746
|
+
* Creates an autonomous multi-stage queue chain graph.
|
|
747
|
+
*/
|
|
748
|
+
declare function jobFlow<T>(name: string, opts?: JobFlowOptions): JobFlowGraph<T>;
|
|
749
|
+
/**
|
|
750
|
+
* Creates an autonomous cursor-based topic relay graph.
|
|
751
|
+
*/
|
|
752
|
+
declare function topicBridge<TIn, TOut = TIn>(name: string, sourceTopic: TopicGraph<TIn>, targetTopic: TopicGraph<TOut>, opts?: TopicBridgeOptions<TIn, TOut>): TopicBridgeGraph<TIn, TOut>;
|
|
753
|
+
|
|
754
|
+
type messaging_JobEnvelope<T> = JobEnvelope<T>;
|
|
755
|
+
type messaging_JobFlowGraph<T> = JobFlowGraph<T>;
|
|
756
|
+
declare const messaging_JobFlowGraph: typeof JobFlowGraph;
|
|
757
|
+
type messaging_JobFlowOptions = JobFlowOptions;
|
|
758
|
+
type messaging_JobQueueGraph<T> = JobQueueGraph<T>;
|
|
759
|
+
declare const messaging_JobQueueGraph: typeof JobQueueGraph;
|
|
760
|
+
type messaging_JobQueueOptions = JobQueueOptions;
|
|
761
|
+
type messaging_JobState = JobState;
|
|
762
|
+
type messaging_SubscriptionGraph<T> = SubscriptionGraph<T>;
|
|
763
|
+
declare const messaging_SubscriptionGraph: typeof SubscriptionGraph;
|
|
764
|
+
type messaging_SubscriptionOptions = SubscriptionOptions;
|
|
765
|
+
type messaging_TopicBridgeGraph<TIn, TOut = TIn> = TopicBridgeGraph<TIn, TOut>;
|
|
766
|
+
declare const messaging_TopicBridgeGraph: typeof TopicBridgeGraph;
|
|
767
|
+
type messaging_TopicBridgeOptions<TIn, TOut> = TopicBridgeOptions<TIn, TOut>;
|
|
768
|
+
type messaging_TopicGraph<T> = TopicGraph<T>;
|
|
769
|
+
declare const messaging_TopicGraph: typeof TopicGraph;
|
|
770
|
+
type messaging_TopicOptions = TopicOptions;
|
|
771
|
+
declare const messaging_jobFlow: typeof jobFlow;
|
|
772
|
+
declare const messaging_jobQueue: typeof jobQueue;
|
|
773
|
+
declare const messaging_subscription: typeof subscription;
|
|
774
|
+
declare const messaging_topic: typeof topic;
|
|
775
|
+
declare const messaging_topicBridge: typeof topicBridge;
|
|
776
|
+
declare namespace messaging {
|
|
777
|
+
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 };
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Orchestration patterns (roadmap §4.1).
|
|
782
|
+
*
|
|
783
|
+
* Domain-layer helpers that build workflow shapes on top of core + extra primitives.
|
|
784
|
+
* Exported under the `patterns.orchestration` namespace to avoid collisions with
|
|
785
|
+
* Phase 2 operator names (for example `gate`, `forEach`).
|
|
786
|
+
*/
|
|
787
|
+
|
|
788
|
+
type StepRef$1 = string | Node<unknown>;
|
|
789
|
+
type OrchestrationMeta = {
|
|
790
|
+
orchestration?: true;
|
|
791
|
+
orchestration_type?: string;
|
|
792
|
+
};
|
|
793
|
+
type OrchestrationStepOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
794
|
+
deps?: ReadonlyArray<StepRef$1>;
|
|
795
|
+
meta?: Record<string, unknown> & OrchestrationMeta;
|
|
796
|
+
};
|
|
797
|
+
type BranchResult<T> = {
|
|
798
|
+
branch: "then" | "else";
|
|
799
|
+
value: T;
|
|
800
|
+
};
|
|
801
|
+
type SensorControls<T> = {
|
|
802
|
+
node: Node<T>;
|
|
803
|
+
push(value: T): void;
|
|
804
|
+
error(err: unknown): void;
|
|
805
|
+
complete(): void;
|
|
806
|
+
};
|
|
807
|
+
type LoopOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
808
|
+
iterations?: number | StepRef$1;
|
|
809
|
+
};
|
|
810
|
+
type WaitOptions = Omit<OrchestrationStepOptions, "deps">;
|
|
811
|
+
type SubPipelineBuilder = (sub: Graph) => void;
|
|
812
|
+
/**
|
|
813
|
+
* Creates an orchestration graph container.
|
|
814
|
+
*/
|
|
815
|
+
declare function pipeline(name: string, opts?: GraphOptions): Graph;
|
|
816
|
+
/**
|
|
817
|
+
* Registers a workflow task node.
|
|
818
|
+
*/
|
|
819
|
+
declare function task<T>(graph: Graph, name: string, run: NodeFn<T>, opts?: OrchestrationStepOptions): Node<T>;
|
|
820
|
+
/**
|
|
821
|
+
* Emits tagged branch outcomes (`then` / `else`) for each source value.
|
|
822
|
+
*/
|
|
823
|
+
declare function branch<T>(graph: Graph, name: string, source: StepRef$1, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
824
|
+
/**
|
|
825
|
+
* Forwards source values only while `control` is truthy.
|
|
826
|
+
*/
|
|
827
|
+
declare function valve<T>(graph: Graph, name: string, source: StepRef$1, control: StepRef$1, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
828
|
+
type ApprovalOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
829
|
+
isApproved?: (value: unknown) => boolean;
|
|
830
|
+
};
|
|
831
|
+
/**
|
|
832
|
+
* Human/LLM approval gate over a source value.
|
|
833
|
+
*/
|
|
834
|
+
declare function approval<T>(graph: Graph, name: string, source: StepRef$1, approver: StepRef$1, opts?: ApprovalOptions): Node<T>;
|
|
835
|
+
interface GateOptions {
|
|
836
|
+
/** Maximum queue size. Oldest values are FIFO-dropped when exceeded. Default: Infinity. */
|
|
837
|
+
maxPending?: number;
|
|
838
|
+
/** Start in open mode (auto-approve). Default: false. */
|
|
839
|
+
startOpen?: boolean;
|
|
840
|
+
meta?: Record<string, unknown>;
|
|
841
|
+
}
|
|
842
|
+
/** Control surface returned by {@link gate}. */
|
|
843
|
+
interface GateController<T> {
|
|
844
|
+
/** The output node registered in the graph (subscribe to receive approved values). */
|
|
845
|
+
node: Node<T>;
|
|
846
|
+
/** Reactive queue of values waiting for approval. */
|
|
847
|
+
pending: Node<T[]>;
|
|
848
|
+
/** Derived count of pending items. */
|
|
849
|
+
count: Node<number>;
|
|
850
|
+
/** Whether the gate is currently open (auto-approving). */
|
|
851
|
+
isOpen: Node<boolean>;
|
|
852
|
+
/** Approve and forward the next `count` pending values (default: 1). */
|
|
853
|
+
approve(count?: number): void;
|
|
854
|
+
/** Reject (discard) the next `count` pending values (default: 1). */
|
|
855
|
+
reject(count?: number): void;
|
|
856
|
+
/**
|
|
857
|
+
* Transform and forward `count` pending values (default: 1).
|
|
858
|
+
* `fn` receives `(value, index, pending)` — Array.map-style.
|
|
859
|
+
*/
|
|
860
|
+
modify(fn: (value: T, index: number, pending: readonly T[]) => T, count?: number): void;
|
|
861
|
+
/** Flush all pending values and auto-approve future values. */
|
|
862
|
+
open(): void;
|
|
863
|
+
/** Re-enable manual gating (stop auto-approving). */
|
|
864
|
+
close(): void;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Human-in-the-loop gate: queues incoming values from `source` and lets an external
|
|
868
|
+
* controller {@link GateController.approve approve}, {@link GateController.reject reject},
|
|
869
|
+
* or {@link GateController.modify modify} them before forwarding downstream.
|
|
870
|
+
*
|
|
871
|
+
* Observable surfaces (`pending`, `count`, `isOpen`) are reactive nodes registered in
|
|
872
|
+
* the graph. The gate output node is also registered.
|
|
873
|
+
*/
|
|
874
|
+
declare function gate<T>(graph: Graph, name: string, source: StepRef$1, opts?: GateOptions): GateController<T>;
|
|
875
|
+
/**
|
|
876
|
+
* Registers a workflow side-effect step. The step remains graph-observable and forwards messages.
|
|
877
|
+
*/
|
|
878
|
+
declare function forEach<T>(graph: Graph, name: string, source: StepRef$1, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
879
|
+
/**
|
|
880
|
+
* Registers a join step that emits a tuple of latest dependency values.
|
|
881
|
+
*/
|
|
882
|
+
declare function join<T extends readonly unknown[]>(graph: Graph, name: string, deps: {
|
|
883
|
+
[K in keyof T]: StepRef$1;
|
|
884
|
+
}, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
885
|
+
/**
|
|
886
|
+
* Registers a loop step that applies `iterate` to each source value N times.
|
|
887
|
+
*/
|
|
888
|
+
declare function loop<T>(graph: Graph, name: string, source: StepRef$1, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
889
|
+
/**
|
|
890
|
+
* Mounts and returns a child workflow graph.
|
|
891
|
+
*/
|
|
892
|
+
declare function subPipeline(graph: Graph, name: string, childOrBuild?: Graph | SubPipelineBuilder, opts?: GraphOptions): Graph;
|
|
893
|
+
/**
|
|
894
|
+
* Registers a producer-style sensor source and returns imperative controls.
|
|
895
|
+
*/
|
|
896
|
+
declare function sensor<T>(graph: Graph, name: string, initial?: T, opts?: Omit<NodeOptions, "name" | "describeKind" | "meta"> & {
|
|
897
|
+
meta?: Record<string, unknown>;
|
|
898
|
+
}): SensorControls<T>;
|
|
899
|
+
/**
|
|
900
|
+
* Registers a delayed-forwarding step (value-level wait).
|
|
901
|
+
*/
|
|
902
|
+
declare function wait<T>(graph: Graph, name: string, source: StepRef$1, ms: number, opts?: WaitOptions): Node<T>;
|
|
903
|
+
/**
|
|
904
|
+
* Registers an error-recovery step for a source.
|
|
905
|
+
*/
|
|
906
|
+
declare function onFailure<T>(graph: Graph, name: string, source: StepRef$1, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
907
|
+
|
|
908
|
+
type orchestration_ApprovalOptions = ApprovalOptions;
|
|
909
|
+
type orchestration_BranchResult<T> = BranchResult<T>;
|
|
910
|
+
type orchestration_GateController<T> = GateController<T>;
|
|
911
|
+
type orchestration_GateOptions = GateOptions;
|
|
912
|
+
type orchestration_LoopOptions = LoopOptions;
|
|
913
|
+
type orchestration_OrchestrationStepOptions = OrchestrationStepOptions;
|
|
914
|
+
type orchestration_SensorControls<T> = SensorControls<T>;
|
|
915
|
+
type orchestration_SubPipelineBuilder = SubPipelineBuilder;
|
|
916
|
+
type orchestration_WaitOptions = WaitOptions;
|
|
917
|
+
declare const orchestration_approval: typeof approval;
|
|
918
|
+
declare const orchestration_branch: typeof branch;
|
|
919
|
+
declare const orchestration_forEach: typeof forEach;
|
|
920
|
+
declare const orchestration_gate: typeof gate;
|
|
921
|
+
declare const orchestration_join: typeof join;
|
|
922
|
+
declare const orchestration_loop: typeof loop;
|
|
923
|
+
declare const orchestration_onFailure: typeof onFailure;
|
|
924
|
+
declare const orchestration_pipeline: typeof pipeline;
|
|
925
|
+
declare const orchestration_sensor: typeof sensor;
|
|
926
|
+
declare const orchestration_subPipeline: typeof subPipeline;
|
|
927
|
+
declare const orchestration_task: typeof task;
|
|
928
|
+
declare const orchestration_valve: typeof valve;
|
|
929
|
+
declare const orchestration_wait: typeof wait;
|
|
930
|
+
declare namespace orchestration {
|
|
931
|
+
export { type orchestration_ApprovalOptions as ApprovalOptions, type orchestration_BranchResult as BranchResult, type orchestration_GateController as GateController, type orchestration_GateOptions as GateOptions, type orchestration_LoopOptions as LoopOptions, type orchestration_OrchestrationStepOptions as OrchestrationStepOptions, type orchestration_SensorControls as SensorControls, type StepRef$1 as StepRef, type orchestration_SubPipelineBuilder as SubPipelineBuilder, type orchestration_WaitOptions as WaitOptions, orchestration_approval as approval, orchestration_branch as branch, orchestration_forEach as forEach, orchestration_gate as gate, orchestration_join as join, orchestration_loop as loop, orchestration_onFailure as onFailure, orchestration_pipeline as pipeline, orchestration_sensor as sensor, orchestration_subPipeline as subPipeline, orchestration_task as task, orchestration_valve as valve, orchestration_wait as wait };
|
|
932
|
+
}
|
|
933
|
+
|
|
637
934
|
/**
|
|
638
935
|
* AI surface patterns (roadmap §4.4).
|
|
639
936
|
*
|
|
@@ -696,6 +993,20 @@ type ToolDefinition = {
|
|
|
696
993
|
};
|
|
697
994
|
};
|
|
698
995
|
type AgentLoopStatus = "idle" | "thinking" | "acting" | "done" | "error";
|
|
996
|
+
/**
|
|
997
|
+
* A single chunk from any streaming source (LLM tokens, WebSocket, SSE, file tail).
|
|
998
|
+
* Generic enough for any streaming source, not just LLM.
|
|
999
|
+
*/
|
|
1000
|
+
type StreamChunk = {
|
|
1001
|
+
/** Identifier for the stream source (adapter name, URL, etc.). */
|
|
1002
|
+
readonly source: string;
|
|
1003
|
+
/** This chunk's content. */
|
|
1004
|
+
readonly token: string;
|
|
1005
|
+
/** Full accumulated text so far. */
|
|
1006
|
+
readonly accumulated: string;
|
|
1007
|
+
/** 0-based chunk counter. */
|
|
1008
|
+
readonly index: number;
|
|
1009
|
+
};
|
|
699
1010
|
type FromLLMOptions = {
|
|
700
1011
|
name?: string;
|
|
701
1012
|
model?: string;
|
|
@@ -711,27 +1022,143 @@ type FromLLMOptions = {
|
|
|
711
1022
|
* Uses `switchMap` internally — new invocations cancel stale in-flight ones.
|
|
712
1023
|
*/
|
|
713
1024
|
declare function fromLLM(adapter: LLMAdapter, messages: NodeInput<readonly ChatMessage[]>, opts?: FromLLMOptions): Node<LLMResponse | null>;
|
|
714
|
-
type
|
|
1025
|
+
type StreamingPromptNodeOptions = {
|
|
1026
|
+
name?: string;
|
|
1027
|
+
model?: string;
|
|
1028
|
+
temperature?: number;
|
|
1029
|
+
maxTokens?: number;
|
|
1030
|
+
/** Output format — `"json"` attempts JSON.parse on the final accumulated text. Default: `"text"`. */
|
|
1031
|
+
format?: "text" | "json";
|
|
1032
|
+
systemPrompt?: string;
|
|
1033
|
+
};
|
|
715
1034
|
/**
|
|
716
|
-
* Bundle returned by {@link
|
|
717
|
-
* token chunks; `dispose` tears down the internal effect and log.
|
|
1035
|
+
* Bundle returned by {@link streamingPromptNode}.
|
|
718
1036
|
*/
|
|
719
|
-
type
|
|
720
|
-
/**
|
|
721
|
-
|
|
722
|
-
/**
|
|
1037
|
+
type StreamingPromptNodeHandle<T> = {
|
|
1038
|
+
/** Final parsed result (emits once per invocation, after stream completes). */
|
|
1039
|
+
output: Node<T | null>;
|
|
1040
|
+
/** Live stream topic — subscribe to `stream.latest` or `stream.events` for chunks. */
|
|
1041
|
+
stream: TopicGraph<StreamChunk>;
|
|
1042
|
+
/** Tear down the keepalive subscription and release resources. */
|
|
723
1043
|
dispose: () => void;
|
|
724
1044
|
};
|
|
725
1045
|
/**
|
|
726
|
-
* Streaming LLM
|
|
727
|
-
*
|
|
728
|
-
*
|
|
1046
|
+
* Streaming LLM transform: wraps a prompt template + adapter into a reactive
|
|
1047
|
+
* streaming pipeline. Re-invokes the LLM whenever any dep changes; the
|
|
1048
|
+
* previous in-flight stream is canceled automatically via `switchMap`.
|
|
1049
|
+
*
|
|
1050
|
+
* Each token chunk is published to a {@link TopicGraph} as a {@link StreamChunk}.
|
|
1051
|
+
* Extractors can mount on the topic independently (see {@link streamExtractor}).
|
|
1052
|
+
* Zero overhead if nobody subscribes to the stream topic.
|
|
729
1053
|
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* tear down the effect and release resources.
|
|
1054
|
+
* The `output` node emits the final parsed result (like {@link promptNode}).
|
|
1055
|
+
* The async boundary is handled by `fromAny` (spec §5.10 compliant).
|
|
733
1056
|
*/
|
|
734
|
-
declare function
|
|
1057
|
+
declare function streamingPromptNode<T = string>(adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: StreamingPromptNodeOptions): StreamingPromptNodeHandle<T>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Mounts an extractor function on a streaming topic. Returns a derived node
|
|
1060
|
+
* that emits extracted values as chunks arrive.
|
|
1061
|
+
*
|
|
1062
|
+
* `extractFn` receives the accumulated text from the latest chunk and returns
|
|
1063
|
+
* the extracted value, or `null` if nothing detected yet. This is the building
|
|
1064
|
+
* block for keyword flags, tool call detection, cost metering, etc.
|
|
1065
|
+
*
|
|
1066
|
+
* @param streamTopic - The stream topic to extract from.
|
|
1067
|
+
* @param extractFn - `(accumulated: string) => T | null`.
|
|
1068
|
+
* @param opts - Optional name.
|
|
1069
|
+
* @returns Derived node emitting extracted values.
|
|
1070
|
+
*/
|
|
1071
|
+
declare function streamExtractor<T>(streamTopic: TopicGraph<StreamChunk>, extractFn: (accumulated: string) => T | null, opts?: {
|
|
1072
|
+
name?: string;
|
|
1073
|
+
}): Node<T | null>;
|
|
1074
|
+
/** A keyword match detected in the stream. */
|
|
1075
|
+
type KeywordFlag = {
|
|
1076
|
+
readonly label: string;
|
|
1077
|
+
readonly pattern: RegExp;
|
|
1078
|
+
readonly match: string;
|
|
1079
|
+
readonly position: number;
|
|
1080
|
+
};
|
|
1081
|
+
type KeywordFlagExtractorOptions = {
|
|
1082
|
+
patterns: readonly {
|
|
1083
|
+
pattern: RegExp;
|
|
1084
|
+
label: string;
|
|
1085
|
+
}[];
|
|
1086
|
+
name?: string;
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* Mounts a keyword-flag extractor on a streaming topic. Scans accumulated text
|
|
1090
|
+
* for all configured patterns and emits an array of matches.
|
|
1091
|
+
*
|
|
1092
|
+
* Use cases: design invariant violations (`setTimeout`, `EventEmitter`), PII
|
|
1093
|
+
* detection (SSN, email, phone), toxicity keywords, off-track reasoning.
|
|
1094
|
+
*/
|
|
1095
|
+
declare function keywordFlagExtractor(streamTopic: TopicGraph<StreamChunk>, opts: KeywordFlagExtractorOptions): Node<readonly KeywordFlag[]>;
|
|
1096
|
+
/** A tool call detected in the stream. */
|
|
1097
|
+
type ExtractedToolCall = {
|
|
1098
|
+
readonly name: string;
|
|
1099
|
+
readonly arguments: Record<string, unknown>;
|
|
1100
|
+
readonly raw: string;
|
|
1101
|
+
readonly startIndex: number;
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1104
|
+
* Mounts a tool-call extractor on a streaming topic. Scans accumulated text
|
|
1105
|
+
* for complete JSON objects containing `"name"` and `"arguments"` keys (the
|
|
1106
|
+
* standard tool_call shape). Partial JSON is ignored until the closing brace.
|
|
1107
|
+
*
|
|
1108
|
+
* Feeds into the tool interception chain for reactive tool gating mid-stream.
|
|
1109
|
+
*/
|
|
1110
|
+
declare function toolCallExtractor(streamTopic: TopicGraph<StreamChunk>, opts?: {
|
|
1111
|
+
name?: string;
|
|
1112
|
+
}): Node<readonly ExtractedToolCall[]>;
|
|
1113
|
+
/** A cost meter reading from the stream. */
|
|
1114
|
+
type CostMeterReading = {
|
|
1115
|
+
readonly chunkCount: number;
|
|
1116
|
+
readonly charCount: number;
|
|
1117
|
+
readonly estimatedTokens: number;
|
|
1118
|
+
};
|
|
1119
|
+
type CostMeterOptions = {
|
|
1120
|
+
/** Characters per token approximation. Default: 4 (GPT-family). */
|
|
1121
|
+
charsPerToken?: number;
|
|
1122
|
+
name?: string;
|
|
1123
|
+
};
|
|
1124
|
+
/**
|
|
1125
|
+
* Mounts a cost meter on a streaming topic. Counts chunks, characters, and
|
|
1126
|
+
* estimates token count. Compose with `budgetGate` for hard-stop when LLM
|
|
1127
|
+
* output exceeds budget mid-generation.
|
|
1128
|
+
*/
|
|
1129
|
+
declare function costMeterExtractor(streamTopic: TopicGraph<StreamChunk>, opts?: CostMeterOptions): Node<CostMeterReading>;
|
|
1130
|
+
type GatedStreamOptions = StreamingPromptNodeOptions & {
|
|
1131
|
+
/** Gate options (maxPending, startOpen). */
|
|
1132
|
+
gate?: Omit<GateOptions, "meta">;
|
|
1133
|
+
};
|
|
1134
|
+
/**
|
|
1135
|
+
* Bundle returned by {@link gatedStream}.
|
|
1136
|
+
*/
|
|
1137
|
+
type GatedStreamHandle<T> = {
|
|
1138
|
+
/** Final parsed result (after gate approval). */
|
|
1139
|
+
output: Node<T | null>;
|
|
1140
|
+
/** Live stream topic — subscribe to `stream.latest` for chunks. */
|
|
1141
|
+
stream: TopicGraph<StreamChunk>;
|
|
1142
|
+
/** Gate controller — approve, reject (aborts in-flight stream), modify. */
|
|
1143
|
+
gate: GateController<T | null>;
|
|
1144
|
+
/** Tear down everything. */
|
|
1145
|
+
dispose: () => void;
|
|
1146
|
+
};
|
|
1147
|
+
/**
|
|
1148
|
+
* Streaming LLM transform with human-in-the-loop gate integration.
|
|
1149
|
+
*
|
|
1150
|
+
* Composes {@link streamingPromptNode} with {@link gate} so that:
|
|
1151
|
+
* - `gate.reject()` discards the pending value **and** aborts the in-flight
|
|
1152
|
+
* stream (cancels the `AbortController`).
|
|
1153
|
+
* - `gate.modify()` transforms the pending value before forwarding downstream.
|
|
1154
|
+
* - `gate.approve()` forwards the final result as normal.
|
|
1155
|
+
*
|
|
1156
|
+
* The abort-on-reject works by toggling an internal cancel signal that causes
|
|
1157
|
+
* the `switchMap` inside `streamingPromptNode` to restart with an empty message
|
|
1158
|
+
* list, which triggers the `AbortController.abort()` in the async generator's
|
|
1159
|
+
* `finally` block.
|
|
1160
|
+
*/
|
|
1161
|
+
declare function gatedStream<T = string>(graph: Graph, name: string, adapter: LLMAdapter, deps: readonly Node<unknown>[], prompt: string | ((...depValues: unknown[]) => string), opts?: GatedStreamOptions): GatedStreamHandle<T>;
|
|
735
1162
|
type PromptNodeOptions = {
|
|
736
1163
|
name?: string;
|
|
737
1164
|
model?: string;
|
|
@@ -1203,18 +1630,23 @@ type ai_ChatMessage = ChatMessage;
|
|
|
1203
1630
|
type ai_ChatStreamGraph = ChatStreamGraph;
|
|
1204
1631
|
declare const ai_ChatStreamGraph: typeof ChatStreamGraph;
|
|
1205
1632
|
type ai_ChatStreamOptions = ChatStreamOptions;
|
|
1633
|
+
type ai_CostMeterOptions = CostMeterOptions;
|
|
1634
|
+
type ai_CostMeterReading = CostMeterReading;
|
|
1635
|
+
type ai_ExtractedToolCall = ExtractedToolCall;
|
|
1206
1636
|
type ai_FromLLMOptions = FromLLMOptions;
|
|
1207
|
-
type
|
|
1637
|
+
type ai_GatedStreamHandle<T> = GatedStreamHandle<T>;
|
|
1638
|
+
type ai_GatedStreamOptions = GatedStreamOptions;
|
|
1208
1639
|
type ai_GaugesAsContextOptions = GaugesAsContextOptions;
|
|
1209
1640
|
type ai_GraphDefValidation = GraphDefValidation;
|
|
1210
1641
|
type ai_GraphFromSpecOptions = GraphFromSpecOptions;
|
|
1642
|
+
type ai_KeywordFlag = KeywordFlag;
|
|
1643
|
+
type ai_KeywordFlagExtractorOptions = KeywordFlagExtractorOptions;
|
|
1211
1644
|
type ai_KnobsAsToolsResult = KnobsAsToolsResult;
|
|
1212
1645
|
type ai_LLMAdapter = LLMAdapter;
|
|
1213
1646
|
type ai_LLMConsolidatorOptions = LLMConsolidatorOptions;
|
|
1214
1647
|
type ai_LLMExtractorOptions = LLMExtractorOptions;
|
|
1215
1648
|
type ai_LLMInvokeOptions = LLMInvokeOptions;
|
|
1216
1649
|
type ai_LLMResponse = LLMResponse;
|
|
1217
|
-
type ai_LLMStreamHandle = LLMStreamHandle;
|
|
1218
1650
|
type ai_McpToolSchema = McpToolSchema;
|
|
1219
1651
|
type ai_MemoryTier = MemoryTier;
|
|
1220
1652
|
type ai_MemoryTiersBundle<TMem> = MemoryTiersBundle<TMem>;
|
|
@@ -1227,6 +1659,9 @@ type ai_RetrievalQuery = RetrievalQuery;
|
|
|
1227
1659
|
type ai_RetrievalTrace<TMem> = RetrievalTrace<TMem>;
|
|
1228
1660
|
type ai_StrategyOperation = StrategyOperation;
|
|
1229
1661
|
type ai_StrategyPlan = StrategyPlan;
|
|
1662
|
+
type ai_StreamChunk = StreamChunk;
|
|
1663
|
+
type ai_StreamingPromptNodeHandle<T> = StreamingPromptNodeHandle<T>;
|
|
1664
|
+
type ai_StreamingPromptNodeOptions = StreamingPromptNodeOptions;
|
|
1230
1665
|
type ai_SuggestStrategyOptions = SuggestStrategyOptions;
|
|
1231
1666
|
type ai_SystemPromptHandle = SystemPromptHandle;
|
|
1232
1667
|
type ai_ToolCall = ToolCall;
|
|
@@ -1238,20 +1673,25 @@ declare const ai_admissionFilter3D: typeof admissionFilter3D;
|
|
|
1238
1673
|
declare const ai_agentLoop: typeof agentLoop;
|
|
1239
1674
|
declare const ai_agentMemory: typeof agentMemory;
|
|
1240
1675
|
declare const ai_chatStream: typeof chatStream;
|
|
1676
|
+
declare const ai_costMeterExtractor: typeof costMeterExtractor;
|
|
1241
1677
|
declare const ai_fromLLM: typeof fromLLM;
|
|
1242
|
-
declare const
|
|
1678
|
+
declare const ai_gatedStream: typeof gatedStream;
|
|
1243
1679
|
declare const ai_gaugesAsContext: typeof gaugesAsContext;
|
|
1244
1680
|
declare const ai_graphFromSpec: typeof graphFromSpec;
|
|
1681
|
+
declare const ai_keywordFlagExtractor: typeof keywordFlagExtractor;
|
|
1245
1682
|
declare const ai_knobsAsTools: typeof knobsAsTools;
|
|
1246
1683
|
declare const ai_llmConsolidator: typeof llmConsolidator;
|
|
1247
1684
|
declare const ai_llmExtractor: typeof llmExtractor;
|
|
1248
1685
|
declare const ai_promptNode: typeof promptNode;
|
|
1686
|
+
declare const ai_streamExtractor: typeof streamExtractor;
|
|
1687
|
+
declare const ai_streamingPromptNode: typeof streamingPromptNode;
|
|
1249
1688
|
declare const ai_suggestStrategy: typeof suggestStrategy;
|
|
1250
1689
|
declare const ai_systemPromptBuilder: typeof systemPromptBuilder;
|
|
1690
|
+
declare const ai_toolCallExtractor: typeof toolCallExtractor;
|
|
1251
1691
|
declare const ai_toolRegistry: typeof toolRegistry;
|
|
1252
1692
|
declare const ai_validateGraphDef: typeof validateGraphDef;
|
|
1253
1693
|
declare namespace ai {
|
|
1254
|
-
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
|
|
1694
|
+
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_CostMeterOptions as CostMeterOptions, type ai_CostMeterReading as CostMeterReading, type ai_ExtractedToolCall as ExtractedToolCall, type ai_FromLLMOptions as FromLLMOptions, type ai_GatedStreamHandle as GatedStreamHandle, type ai_GatedStreamOptions as GatedStreamOptions, type ai_GaugesAsContextOptions as GaugesAsContextOptions, type ai_GraphDefValidation as GraphDefValidation, type ai_GraphFromSpecOptions as GraphFromSpecOptions, type ai_KeywordFlag as KeywordFlag, type ai_KeywordFlagExtractorOptions as KeywordFlagExtractorOptions, 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_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_PromptNodeOptions as PromptNodeOptions, 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_StreamChunk as StreamChunk, type ai_StreamingPromptNodeHandle as StreamingPromptNodeHandle, type ai_StreamingPromptNodeOptions as StreamingPromptNodeOptions, 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_costMeterExtractor as costMeterExtractor, ai_fromLLM as fromLLM, ai_gatedStream as gatedStream, ai_gaugesAsContext as gaugesAsContext, ai_graphFromSpec as graphFromSpec, ai_keywordFlagExtractor as keywordFlagExtractor, ai_knobsAsTools as knobsAsTools, ai_llmConsolidator as llmConsolidator, ai_llmExtractor as llmExtractor, ai_promptNode as promptNode, ai_streamExtractor as streamExtractor, ai_streamingPromptNode as streamingPromptNode, ai_suggestStrategy as suggestStrategy, ai_systemPromptBuilder as systemPromptBuilder, ai_toolCallExtractor as toolCallExtractor, ai_toolRegistry as toolRegistry, ai_validateGraphDef as validateGraphDef };
|
|
1255
1695
|
}
|
|
1256
1696
|
|
|
1257
1697
|
/**
|
|
@@ -1843,199 +2283,56 @@ type LLMComposeOptions = {
|
|
|
1843
2283
|
* @returns A validated GraphSpec.
|
|
1844
2284
|
* @throws On invalid LLM output or validation failure.
|
|
1845
2285
|
*
|
|
1846
|
-
* @category patterns
|
|
1847
|
-
*/
|
|
1848
|
-
declare function llmCompose(problem: string, adapter: LLMAdapter, opts?: LLMComposeOptions): Promise<GraphSpec>;
|
|
1849
|
-
/** Options for {@link llmRefine}. */
|
|
1850
|
-
type LLMRefineOptions = LLMComposeOptions;
|
|
1851
|
-
/**
|
|
1852
|
-
* Ask an LLM to modify an existing GraphSpec based on feedback or changed requirements.
|
|
1853
|
-
*
|
|
1854
|
-
* @param currentSpec - The current GraphSpec to modify.
|
|
1855
|
-
* @param feedback - Natural language feedback or changed requirements.
|
|
1856
|
-
* @param adapter - LLM adapter for the generation call.
|
|
1857
|
-
* @param opts - Model options.
|
|
1858
|
-
* @returns A new GraphSpec incorporating the feedback.
|
|
1859
|
-
* @throws On invalid LLM output or validation failure.
|
|
1860
|
-
*
|
|
1861
|
-
* @category patterns
|
|
1862
|
-
*/
|
|
1863
|
-
declare function llmRefine(currentSpec: GraphSpec, feedback: string, adapter: LLMAdapter, opts?: LLMRefineOptions): Promise<GraphSpec>;
|
|
1864
|
-
|
|
1865
|
-
type graphspec_CatalogFnEntry = CatalogFnEntry;
|
|
1866
|
-
type graphspec_CatalogSourceEntry = CatalogSourceEntry;
|
|
1867
|
-
type graphspec_CompileSpecOptions = CompileSpecOptions;
|
|
1868
|
-
type graphspec_ConfigFieldSchema = ConfigFieldSchema;
|
|
1869
|
-
type graphspec_FnFactory = FnFactory;
|
|
1870
|
-
type graphspec_GraphSpec = GraphSpec;
|
|
1871
|
-
type graphspec_GraphSpecCatalog = GraphSpecCatalog;
|
|
1872
|
-
type graphspec_GraphSpecFeedbackEdge = GraphSpecFeedbackEdge;
|
|
1873
|
-
type graphspec_GraphSpecNode = GraphSpecNode;
|
|
1874
|
-
type graphspec_GraphSpecTemplate = GraphSpecTemplate;
|
|
1875
|
-
type graphspec_GraphSpecTemplateRef = GraphSpecTemplateRef;
|
|
1876
|
-
type graphspec_GraphSpecValidation = GraphSpecValidation;
|
|
1877
|
-
type graphspec_LLMComposeOptions = LLMComposeOptions;
|
|
1878
|
-
type graphspec_LLMRefineOptions = LLMRefineOptions;
|
|
1879
|
-
type graphspec_SourceFactory = SourceFactory;
|
|
1880
|
-
type graphspec_SpecDiffEntry = SpecDiffEntry;
|
|
1881
|
-
type graphspec_SpecDiffResult = SpecDiffResult;
|
|
1882
|
-
declare const graphspec_compileSpec: typeof compileSpec;
|
|
1883
|
-
declare const graphspec_decompileGraph: typeof decompileGraph;
|
|
1884
|
-
declare const graphspec_extractFnFactory: typeof extractFnFactory;
|
|
1885
|
-
declare const graphspec_extractSourceFactory: typeof extractSourceFactory;
|
|
1886
|
-
declare const graphspec_generateCatalogPrompt: typeof generateCatalogPrompt;
|
|
1887
|
-
declare const graphspec_isRichFnEntry: typeof isRichFnEntry;
|
|
1888
|
-
declare const graphspec_isRichSourceEntry: typeof isRichSourceEntry;
|
|
1889
|
-
declare const graphspec_llmCompose: typeof llmCompose;
|
|
1890
|
-
declare const graphspec_llmRefine: typeof llmRefine;
|
|
1891
|
-
declare const graphspec_specDiff: typeof specDiff;
|
|
1892
|
-
declare const graphspec_validateSpec: typeof validateSpec;
|
|
1893
|
-
declare const graphspec_validateSpecAgainstCatalog: typeof validateSpecAgainstCatalog;
|
|
1894
|
-
declare namespace graphspec {
|
|
1895
|
-
export { type graphspec_CatalogFnEntry as CatalogFnEntry, type graphspec_CatalogSourceEntry as CatalogSourceEntry, type graphspec_CompileSpecOptions as CompileSpecOptions, type graphspec_ConfigFieldSchema as ConfigFieldSchema, type graphspec_FnFactory as FnFactory, type graphspec_GraphSpec as GraphSpec, type graphspec_GraphSpecCatalog as GraphSpecCatalog, type graphspec_GraphSpecFeedbackEdge as GraphSpecFeedbackEdge, type graphspec_GraphSpecNode as GraphSpecNode, type graphspec_GraphSpecTemplate as GraphSpecTemplate, type graphspec_GraphSpecTemplateRef as GraphSpecTemplateRef, type graphspec_GraphSpecValidation as GraphSpecValidation, type graphspec_LLMComposeOptions as LLMComposeOptions, type graphspec_LLMRefineOptions as LLMRefineOptions, type graphspec_SourceFactory as SourceFactory, type graphspec_SpecDiffEntry as SpecDiffEntry, type graphspec_SpecDiffResult as SpecDiffResult, graphspec_compileSpec as compileSpec, graphspec_decompileGraph as decompileGraph, graphspec_extractFnFactory as extractFnFactory, graphspec_extractSourceFactory as extractSourceFactory, graphspec_generateCatalogPrompt as generateCatalogPrompt, graphspec_isRichFnEntry as isRichFnEntry, graphspec_isRichSourceEntry as isRichSourceEntry, graphspec_llmCompose as llmCompose, graphspec_llmRefine as llmRefine, graphspec_specDiff as specDiff, graphspec_validateSpec as validateSpec, graphspec_validateSpecAgainstCatalog as validateSpecAgainstCatalog };
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
/**
|
|
1899
|
-
* Messaging patterns (roadmap §4.2).
|
|
1900
|
-
*
|
|
1901
|
-
* Pulsar-inspired messaging features modeled as graph factories:
|
|
1902
|
-
* - `topic()` for append-only topic streams
|
|
1903
|
-
* - `subscription()` for cursor-based consumers
|
|
1904
|
-
* - `jobQueue()` for queue claim/ack flow
|
|
1905
|
-
*/
|
|
1906
|
-
|
|
1907
|
-
type TopicOptions = {
|
|
1908
|
-
graph?: GraphOptions;
|
|
1909
|
-
retainedLimit?: number;
|
|
1910
|
-
};
|
|
1911
|
-
declare class TopicGraph<T> extends Graph {
|
|
1912
|
-
private readonly _log;
|
|
1913
|
-
readonly events: Node<readonly T[]>;
|
|
1914
|
-
readonly latest: Node<T | undefined>;
|
|
1915
|
-
constructor(name: string, opts?: TopicOptions);
|
|
1916
|
-
publish(value: T): void;
|
|
1917
|
-
retained(): readonly T[];
|
|
1918
|
-
}
|
|
1919
|
-
type SubscriptionOptions = {
|
|
1920
|
-
graph?: GraphOptions;
|
|
1921
|
-
cursor?: number;
|
|
1922
|
-
};
|
|
1923
|
-
declare class SubscriptionGraph<T> extends Graph {
|
|
1924
|
-
readonly source: Node<readonly T[]>;
|
|
1925
|
-
readonly cursor: Node<number>;
|
|
1926
|
-
readonly available: Node<readonly T[]>;
|
|
1927
|
-
constructor(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions);
|
|
1928
|
-
ack(count?: number): number;
|
|
1929
|
-
pull(limit?: number, opts?: {
|
|
1930
|
-
ack?: boolean;
|
|
1931
|
-
}): readonly T[];
|
|
1932
|
-
}
|
|
1933
|
-
type JobState = "queued" | "inflight";
|
|
1934
|
-
type JobEnvelope<T> = {
|
|
1935
|
-
id: string;
|
|
1936
|
-
payload: T;
|
|
1937
|
-
attempts: number;
|
|
1938
|
-
metadata: Readonly<Record<string, unknown>>;
|
|
1939
|
-
state: JobState;
|
|
1940
|
-
};
|
|
1941
|
-
type JobQueueOptions = {
|
|
1942
|
-
graph?: GraphOptions;
|
|
1943
|
-
};
|
|
1944
|
-
declare class JobQueueGraph<T> extends Graph {
|
|
1945
|
-
private readonly _pending;
|
|
1946
|
-
private readonly _jobs;
|
|
1947
|
-
private _seq;
|
|
1948
|
-
readonly pending: Node<readonly string[]>;
|
|
1949
|
-
readonly jobs: Node<ReadonlyMap<string, JobEnvelope<T>>>;
|
|
1950
|
-
readonly depth: Node<number>;
|
|
1951
|
-
constructor(name: string, opts?: JobQueueOptions);
|
|
1952
|
-
enqueue(payload: T, opts?: {
|
|
1953
|
-
id?: string;
|
|
1954
|
-
metadata?: Record<string, unknown>;
|
|
1955
|
-
}): string;
|
|
1956
|
-
claim(limit?: number): readonly JobEnvelope<T>[];
|
|
1957
|
-
ack(id: string): boolean;
|
|
1958
|
-
nack(id: string, opts?: {
|
|
1959
|
-
requeue?: boolean;
|
|
1960
|
-
}): boolean;
|
|
1961
|
-
}
|
|
1962
|
-
type JobFlowOptions = {
|
|
1963
|
-
graph?: GraphOptions;
|
|
1964
|
-
stages?: readonly string[];
|
|
1965
|
-
maxPerPump?: number;
|
|
1966
|
-
};
|
|
1967
|
-
declare class JobFlowGraph<T> extends Graph {
|
|
1968
|
-
private readonly _stageNames;
|
|
1969
|
-
private readonly _queues;
|
|
1970
|
-
private readonly _completed;
|
|
1971
|
-
readonly completed: Node<readonly JobEnvelope<T>[]>;
|
|
1972
|
-
readonly completedCount: Node<number>;
|
|
1973
|
-
constructor(name: string, opts?: JobFlowOptions);
|
|
1974
|
-
stages(): readonly string[];
|
|
1975
|
-
queue(stage: string): JobQueueGraph<T>;
|
|
1976
|
-
enqueue(payload: T, opts?: {
|
|
1977
|
-
id?: string;
|
|
1978
|
-
metadata?: Record<string, unknown>;
|
|
1979
|
-
}): string;
|
|
1980
|
-
retainedCompleted(): readonly JobEnvelope<T>[];
|
|
1981
|
-
}
|
|
1982
|
-
type TopicBridgeOptions<TIn, TOut> = {
|
|
1983
|
-
graph?: GraphOptions;
|
|
1984
|
-
cursor?: number;
|
|
1985
|
-
maxPerPump?: number;
|
|
1986
|
-
map?: (value: TIn) => TOut | undefined;
|
|
1987
|
-
};
|
|
1988
|
-
declare class TopicBridgeGraph<TIn, TOut = TIn> extends Graph {
|
|
1989
|
-
private readonly _sourceSub;
|
|
1990
|
-
private readonly _target;
|
|
1991
|
-
readonly bridgedCount: Node<number>;
|
|
1992
|
-
constructor(name: string, sourceTopic: TopicGraph<TIn>, targetTopic: TopicGraph<TOut>, opts?: TopicBridgeOptions<TIn, TOut>);
|
|
1993
|
-
}
|
|
1994
|
-
/**
|
|
1995
|
-
* Creates a Pulsar-inspired topic graph (append-only retained stream + latest value).
|
|
1996
|
-
*/
|
|
1997
|
-
declare function topic<T>(name: string, opts?: TopicOptions): TopicGraph<T>;
|
|
1998
|
-
/**
|
|
1999
|
-
* Creates a cursor-based subscription graph over a topic.
|
|
2000
|
-
*/
|
|
2001
|
-
declare function subscription<T>(name: string, topicGraph: TopicGraph<T>, opts?: SubscriptionOptions): SubscriptionGraph<T>;
|
|
2002
|
-
/**
|
|
2003
|
-
* Creates a Pulsar-inspired job queue graph with claim/ack/nack workflow.
|
|
2004
|
-
*/
|
|
2005
|
-
declare function jobQueue<T>(name: string, opts?: JobQueueOptions): JobQueueGraph<T>;
|
|
2006
|
-
/**
|
|
2007
|
-
* Creates an autonomous multi-stage queue chain graph.
|
|
2286
|
+
* @category patterns
|
|
2008
2287
|
*/
|
|
2009
|
-
declare function
|
|
2288
|
+
declare function llmCompose(problem: string, adapter: LLMAdapter, opts?: LLMComposeOptions): Promise<GraphSpec>;
|
|
2289
|
+
/** Options for {@link llmRefine}. */
|
|
2290
|
+
type LLMRefineOptions = LLMComposeOptions;
|
|
2010
2291
|
/**
|
|
2011
|
-
*
|
|
2292
|
+
* Ask an LLM to modify an existing GraphSpec based on feedback or changed requirements.
|
|
2293
|
+
*
|
|
2294
|
+
* @param currentSpec - The current GraphSpec to modify.
|
|
2295
|
+
* @param feedback - Natural language feedback or changed requirements.
|
|
2296
|
+
* @param adapter - LLM adapter for the generation call.
|
|
2297
|
+
* @param opts - Model options.
|
|
2298
|
+
* @returns A new GraphSpec incorporating the feedback.
|
|
2299
|
+
* @throws On invalid LLM output or validation failure.
|
|
2300
|
+
*
|
|
2301
|
+
* @category patterns
|
|
2012
2302
|
*/
|
|
2013
|
-
declare function
|
|
2303
|
+
declare function llmRefine(currentSpec: GraphSpec, feedback: string, adapter: LLMAdapter, opts?: LLMRefineOptions): Promise<GraphSpec>;
|
|
2014
2304
|
|
|
2015
|
-
type
|
|
2016
|
-
type
|
|
2017
|
-
|
|
2018
|
-
type
|
|
2019
|
-
type
|
|
2020
|
-
|
|
2021
|
-
type
|
|
2022
|
-
type
|
|
2023
|
-
type
|
|
2024
|
-
|
|
2025
|
-
type
|
|
2026
|
-
type
|
|
2027
|
-
|
|
2028
|
-
type
|
|
2029
|
-
type
|
|
2030
|
-
|
|
2031
|
-
type
|
|
2032
|
-
declare const
|
|
2033
|
-
declare const
|
|
2034
|
-
declare const
|
|
2035
|
-
declare const
|
|
2036
|
-
declare const
|
|
2037
|
-
declare
|
|
2038
|
-
|
|
2305
|
+
type graphspec_CatalogFnEntry = CatalogFnEntry;
|
|
2306
|
+
type graphspec_CatalogSourceEntry = CatalogSourceEntry;
|
|
2307
|
+
type graphspec_CompileSpecOptions = CompileSpecOptions;
|
|
2308
|
+
type graphspec_ConfigFieldSchema = ConfigFieldSchema;
|
|
2309
|
+
type graphspec_FnFactory = FnFactory;
|
|
2310
|
+
type graphspec_GraphSpec = GraphSpec;
|
|
2311
|
+
type graphspec_GraphSpecCatalog = GraphSpecCatalog;
|
|
2312
|
+
type graphspec_GraphSpecFeedbackEdge = GraphSpecFeedbackEdge;
|
|
2313
|
+
type graphspec_GraphSpecNode = GraphSpecNode;
|
|
2314
|
+
type graphspec_GraphSpecTemplate = GraphSpecTemplate;
|
|
2315
|
+
type graphspec_GraphSpecTemplateRef = GraphSpecTemplateRef;
|
|
2316
|
+
type graphspec_GraphSpecValidation = GraphSpecValidation;
|
|
2317
|
+
type graphspec_LLMComposeOptions = LLMComposeOptions;
|
|
2318
|
+
type graphspec_LLMRefineOptions = LLMRefineOptions;
|
|
2319
|
+
type graphspec_SourceFactory = SourceFactory;
|
|
2320
|
+
type graphspec_SpecDiffEntry = SpecDiffEntry;
|
|
2321
|
+
type graphspec_SpecDiffResult = SpecDiffResult;
|
|
2322
|
+
declare const graphspec_compileSpec: typeof compileSpec;
|
|
2323
|
+
declare const graphspec_decompileGraph: typeof decompileGraph;
|
|
2324
|
+
declare const graphspec_extractFnFactory: typeof extractFnFactory;
|
|
2325
|
+
declare const graphspec_extractSourceFactory: typeof extractSourceFactory;
|
|
2326
|
+
declare const graphspec_generateCatalogPrompt: typeof generateCatalogPrompt;
|
|
2327
|
+
declare const graphspec_isRichFnEntry: typeof isRichFnEntry;
|
|
2328
|
+
declare const graphspec_isRichSourceEntry: typeof isRichSourceEntry;
|
|
2329
|
+
declare const graphspec_llmCompose: typeof llmCompose;
|
|
2330
|
+
declare const graphspec_llmRefine: typeof llmRefine;
|
|
2331
|
+
declare const graphspec_specDiff: typeof specDiff;
|
|
2332
|
+
declare const graphspec_validateSpec: typeof validateSpec;
|
|
2333
|
+
declare const graphspec_validateSpecAgainstCatalog: typeof validateSpecAgainstCatalog;
|
|
2334
|
+
declare namespace graphspec {
|
|
2335
|
+
export { type graphspec_CatalogFnEntry as CatalogFnEntry, type graphspec_CatalogSourceEntry as CatalogSourceEntry, type graphspec_CompileSpecOptions as CompileSpecOptions, type graphspec_ConfigFieldSchema as ConfigFieldSchema, type graphspec_FnFactory as FnFactory, type graphspec_GraphSpec as GraphSpec, type graphspec_GraphSpecCatalog as GraphSpecCatalog, type graphspec_GraphSpecFeedbackEdge as GraphSpecFeedbackEdge, type graphspec_GraphSpecNode as GraphSpecNode, type graphspec_GraphSpecTemplate as GraphSpecTemplate, type graphspec_GraphSpecTemplateRef as GraphSpecTemplateRef, type graphspec_GraphSpecValidation as GraphSpecValidation, type graphspec_LLMComposeOptions as LLMComposeOptions, type graphspec_LLMRefineOptions as LLMRefineOptions, type graphspec_SourceFactory as SourceFactory, type graphspec_SpecDiffEntry as SpecDiffEntry, type graphspec_SpecDiffResult as SpecDiffResult, graphspec_compileSpec as compileSpec, graphspec_decompileGraph as decompileGraph, graphspec_extractFnFactory as extractFnFactory, graphspec_extractSourceFactory as extractSourceFactory, graphspec_generateCatalogPrompt as generateCatalogPrompt, graphspec_isRichFnEntry as isRichFnEntry, graphspec_isRichSourceEntry as isRichSourceEntry, graphspec_llmCompose as llmCompose, graphspec_llmRefine as llmRefine, graphspec_specDiff as specDiff, graphspec_validateSpec as validateSpec, graphspec_validateSpecAgainstCatalog as validateSpecAgainstCatalog };
|
|
2039
2336
|
}
|
|
2040
2337
|
|
|
2041
2338
|
/**
|
|
@@ -2185,6 +2482,29 @@ interface HarnessLoopOptions {
|
|
|
2185
2482
|
* @module
|
|
2186
2483
|
*/
|
|
2187
2484
|
|
|
2485
|
+
/** Options for {@link createIntakeBridge}. */
|
|
2486
|
+
interface IntakeBridgeOptions {
|
|
2487
|
+
/** Name for the effect node (default "intake-bridge"). */
|
|
2488
|
+
name?: string;
|
|
2489
|
+
}
|
|
2490
|
+
/**
|
|
2491
|
+
* Generic source→intake bridge factory.
|
|
2492
|
+
*
|
|
2493
|
+
* Watches a source node for new values, passes each through a user-supplied
|
|
2494
|
+
* `parser` that produces zero or more `IntakeItem`s, and publishes them to
|
|
2495
|
+
* the given intake topic.
|
|
2496
|
+
*
|
|
2497
|
+
* This is the generalized pattern behind {@link evalIntakeBridge}. Use it for
|
|
2498
|
+
* CI results, test failures, Slack messages, monitoring alerts, or any domain
|
|
2499
|
+
* where structured results should flow into a harness loop.
|
|
2500
|
+
*
|
|
2501
|
+
* @param source - Reactive node emitting domain-specific data.
|
|
2502
|
+
* @param intakeTopic - TopicGraph to publish IntakeItem entries to.
|
|
2503
|
+
* @param parser - Converts source data into IntakeItem[]. Return empty array to skip.
|
|
2504
|
+
* @param opts - Optional configuration.
|
|
2505
|
+
* @returns The effect node (for lifecycle management).
|
|
2506
|
+
*/
|
|
2507
|
+
declare function createIntakeBridge<T>(source: Node<T>, intakeTopic: TopicGraph<IntakeItem>, parser: (value: T) => IntakeItem[], opts?: IntakeBridgeOptions): Node<unknown>;
|
|
2188
2508
|
/**
|
|
2189
2509
|
* Minimal eval result shape accepted by the bridge.
|
|
2190
2510
|
*
|
|
@@ -2226,160 +2546,6 @@ interface EvalIntakeBridgeOptions {
|
|
|
2226
2546
|
*/
|
|
2227
2547
|
declare function evalIntakeBridge(evalSource: Node<EvalResult | EvalResult[]>, intakeTopic: TopicGraph<IntakeItem>, opts?: EvalIntakeBridgeOptions): Node<unknown>;
|
|
2228
2548
|
|
|
2229
|
-
/**
|
|
2230
|
-
* Orchestration patterns (roadmap §4.1).
|
|
2231
|
-
*
|
|
2232
|
-
* Domain-layer helpers that build workflow shapes on top of core + extra primitives.
|
|
2233
|
-
* Exported under the `patterns.orchestration` namespace to avoid collisions with
|
|
2234
|
-
* Phase 2 operator names (for example `gate`, `forEach`).
|
|
2235
|
-
*/
|
|
2236
|
-
|
|
2237
|
-
type StepRef$1 = string | Node<unknown>;
|
|
2238
|
-
type OrchestrationMeta = {
|
|
2239
|
-
orchestration?: true;
|
|
2240
|
-
orchestration_type?: string;
|
|
2241
|
-
};
|
|
2242
|
-
type OrchestrationStepOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
2243
|
-
deps?: ReadonlyArray<StepRef$1>;
|
|
2244
|
-
meta?: Record<string, unknown> & OrchestrationMeta;
|
|
2245
|
-
};
|
|
2246
|
-
type BranchResult<T> = {
|
|
2247
|
-
branch: "then" | "else";
|
|
2248
|
-
value: T;
|
|
2249
|
-
};
|
|
2250
|
-
type SensorControls<T> = {
|
|
2251
|
-
node: Node<T>;
|
|
2252
|
-
push(value: T): void;
|
|
2253
|
-
error(err: unknown): void;
|
|
2254
|
-
complete(): void;
|
|
2255
|
-
};
|
|
2256
|
-
type LoopOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
2257
|
-
iterations?: number | StepRef$1;
|
|
2258
|
-
};
|
|
2259
|
-
type WaitOptions = Omit<OrchestrationStepOptions, "deps">;
|
|
2260
|
-
type SubPipelineBuilder = (sub: Graph) => void;
|
|
2261
|
-
/**
|
|
2262
|
-
* Creates an orchestration graph container.
|
|
2263
|
-
*/
|
|
2264
|
-
declare function pipeline(name: string, opts?: GraphOptions): Graph;
|
|
2265
|
-
/**
|
|
2266
|
-
* Registers a workflow task node.
|
|
2267
|
-
*/
|
|
2268
|
-
declare function task<T>(graph: Graph, name: string, run: NodeFn<T>, opts?: OrchestrationStepOptions): Node<T>;
|
|
2269
|
-
/**
|
|
2270
|
-
* Emits tagged branch outcomes (`then` / `else`) for each source value.
|
|
2271
|
-
*/
|
|
2272
|
-
declare function branch<T>(graph: Graph, name: string, source: StepRef$1, predicate: (value: T) => boolean, opts?: Omit<OrchestrationStepOptions, "deps">): Node<BranchResult<T>>;
|
|
2273
|
-
/**
|
|
2274
|
-
* Forwards source values only while `control` is truthy.
|
|
2275
|
-
*/
|
|
2276
|
-
declare function valve<T>(graph: Graph, name: string, source: StepRef$1, control: StepRef$1, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
2277
|
-
type ApprovalOptions = Omit<OrchestrationStepOptions, "deps"> & {
|
|
2278
|
-
isApproved?: (value: unknown) => boolean;
|
|
2279
|
-
};
|
|
2280
|
-
/**
|
|
2281
|
-
* Human/LLM approval gate over a source value.
|
|
2282
|
-
*/
|
|
2283
|
-
declare function approval<T>(graph: Graph, name: string, source: StepRef$1, approver: StepRef$1, opts?: ApprovalOptions): Node<T>;
|
|
2284
|
-
interface GateOptions {
|
|
2285
|
-
/** Maximum queue size. Oldest values are FIFO-dropped when exceeded. Default: Infinity. */
|
|
2286
|
-
maxPending?: number;
|
|
2287
|
-
/** Start in open mode (auto-approve). Default: false. */
|
|
2288
|
-
startOpen?: boolean;
|
|
2289
|
-
meta?: Record<string, unknown>;
|
|
2290
|
-
}
|
|
2291
|
-
/** Control surface returned by {@link gate}. */
|
|
2292
|
-
interface GateController<T> {
|
|
2293
|
-
/** The output node registered in the graph (subscribe to receive approved values). */
|
|
2294
|
-
node: Node<T>;
|
|
2295
|
-
/** Reactive queue of values waiting for approval. */
|
|
2296
|
-
pending: Node<T[]>;
|
|
2297
|
-
/** Derived count of pending items. */
|
|
2298
|
-
count: Node<number>;
|
|
2299
|
-
/** Whether the gate is currently open (auto-approving). */
|
|
2300
|
-
isOpen: Node<boolean>;
|
|
2301
|
-
/** Approve and forward the next `count` pending values (default: 1). */
|
|
2302
|
-
approve(count?: number): void;
|
|
2303
|
-
/** Reject (discard) the next `count` pending values (default: 1). */
|
|
2304
|
-
reject(count?: number): void;
|
|
2305
|
-
/**
|
|
2306
|
-
* Transform and forward `count` pending values (default: 1).
|
|
2307
|
-
* `fn` receives `(value, index, pending)` — Array.map-style.
|
|
2308
|
-
*/
|
|
2309
|
-
modify(fn: (value: T, index: number, pending: readonly T[]) => T, count?: number): void;
|
|
2310
|
-
/** Flush all pending values and auto-approve future values. */
|
|
2311
|
-
open(): void;
|
|
2312
|
-
/** Re-enable manual gating (stop auto-approving). */
|
|
2313
|
-
close(): void;
|
|
2314
|
-
}
|
|
2315
|
-
/**
|
|
2316
|
-
* Human-in-the-loop gate: queues incoming values from `source` and lets an external
|
|
2317
|
-
* controller {@link GateController.approve approve}, {@link GateController.reject reject},
|
|
2318
|
-
* or {@link GateController.modify modify} them before forwarding downstream.
|
|
2319
|
-
*
|
|
2320
|
-
* Observable surfaces (`pending`, `count`, `isOpen`) are reactive nodes registered in
|
|
2321
|
-
* the graph. The gate output node is also registered.
|
|
2322
|
-
*/
|
|
2323
|
-
declare function gate<T>(graph: Graph, name: string, source: StepRef$1, opts?: GateOptions): GateController<T>;
|
|
2324
|
-
/**
|
|
2325
|
-
* Registers a workflow side-effect step. The step remains graph-observable and forwards messages.
|
|
2326
|
-
*/
|
|
2327
|
-
declare function forEach<T>(graph: Graph, name: string, source: StepRef$1, run: (value: T, actions: NodeActions) => void, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
2328
|
-
/**
|
|
2329
|
-
* Registers a join step that emits a tuple of latest dependency values.
|
|
2330
|
-
*/
|
|
2331
|
-
declare function join<T extends readonly unknown[]>(graph: Graph, name: string, deps: {
|
|
2332
|
-
[K in keyof T]: StepRef$1;
|
|
2333
|
-
}, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
2334
|
-
/**
|
|
2335
|
-
* Registers a loop step that applies `iterate` to each source value N times.
|
|
2336
|
-
*/
|
|
2337
|
-
declare function loop<T>(graph: Graph, name: string, source: StepRef$1, iterate: (value: T, iteration: number, actions: NodeActions) => T, opts?: LoopOptions): Node<T>;
|
|
2338
|
-
/**
|
|
2339
|
-
* Mounts and returns a child workflow graph.
|
|
2340
|
-
*/
|
|
2341
|
-
declare function subPipeline(graph: Graph, name: string, childOrBuild?: Graph | SubPipelineBuilder, opts?: GraphOptions): Graph;
|
|
2342
|
-
/**
|
|
2343
|
-
* Registers a producer-style sensor source and returns imperative controls.
|
|
2344
|
-
*/
|
|
2345
|
-
declare function sensor<T>(graph: Graph, name: string, initial?: T, opts?: Omit<NodeOptions, "name" | "describeKind" | "meta"> & {
|
|
2346
|
-
meta?: Record<string, unknown>;
|
|
2347
|
-
}): SensorControls<T>;
|
|
2348
|
-
/**
|
|
2349
|
-
* Registers a delayed-forwarding step (value-level wait).
|
|
2350
|
-
*/
|
|
2351
|
-
declare function wait<T>(graph: Graph, name: string, source: StepRef$1, ms: number, opts?: WaitOptions): Node<T>;
|
|
2352
|
-
/**
|
|
2353
|
-
* Registers an error-recovery step for a source.
|
|
2354
|
-
*/
|
|
2355
|
-
declare function onFailure<T>(graph: Graph, name: string, source: StepRef$1, recover: (err: unknown, actions: NodeActions) => T, opts?: Omit<OrchestrationStepOptions, "deps">): Node<T>;
|
|
2356
|
-
|
|
2357
|
-
type orchestration_ApprovalOptions = ApprovalOptions;
|
|
2358
|
-
type orchestration_BranchResult<T> = BranchResult<T>;
|
|
2359
|
-
type orchestration_GateController<T> = GateController<T>;
|
|
2360
|
-
type orchestration_GateOptions = GateOptions;
|
|
2361
|
-
type orchestration_LoopOptions = LoopOptions;
|
|
2362
|
-
type orchestration_OrchestrationStepOptions = OrchestrationStepOptions;
|
|
2363
|
-
type orchestration_SensorControls<T> = SensorControls<T>;
|
|
2364
|
-
type orchestration_SubPipelineBuilder = SubPipelineBuilder;
|
|
2365
|
-
type orchestration_WaitOptions = WaitOptions;
|
|
2366
|
-
declare const orchestration_approval: typeof approval;
|
|
2367
|
-
declare const orchestration_branch: typeof branch;
|
|
2368
|
-
declare const orchestration_forEach: typeof forEach;
|
|
2369
|
-
declare const orchestration_gate: typeof gate;
|
|
2370
|
-
declare const orchestration_join: typeof join;
|
|
2371
|
-
declare const orchestration_loop: typeof loop;
|
|
2372
|
-
declare const orchestration_onFailure: typeof onFailure;
|
|
2373
|
-
declare const orchestration_pipeline: typeof pipeline;
|
|
2374
|
-
declare const orchestration_sensor: typeof sensor;
|
|
2375
|
-
declare const orchestration_subPipeline: typeof subPipeline;
|
|
2376
|
-
declare const orchestration_task: typeof task;
|
|
2377
|
-
declare const orchestration_valve: typeof valve;
|
|
2378
|
-
declare const orchestration_wait: typeof wait;
|
|
2379
|
-
declare namespace orchestration {
|
|
2380
|
-
export { type orchestration_ApprovalOptions as ApprovalOptions, type orchestration_BranchResult as BranchResult, type orchestration_GateController as GateController, type orchestration_GateOptions as GateOptions, type orchestration_LoopOptions as LoopOptions, type orchestration_OrchestrationStepOptions as OrchestrationStepOptions, type orchestration_SensorControls as SensorControls, type StepRef$1 as StepRef, type orchestration_SubPipelineBuilder as SubPipelineBuilder, type orchestration_WaitOptions as WaitOptions, orchestration_approval as approval, orchestration_branch as branch, orchestration_forEach as forEach, orchestration_gate as gate, orchestration_join as join, orchestration_loop as loop, orchestration_onFailure as onFailure, orchestration_pipeline as pipeline, orchestration_sensor as sensor, orchestration_subPipeline as subPipeline, orchestration_task as task, orchestration_valve as valve, orchestration_wait as wait };
|
|
2381
|
-
}
|
|
2382
|
-
|
|
2383
2549
|
/**
|
|
2384
2550
|
* Strategy model and priority scoring (roadmap §9.0).
|
|
2385
2551
|
*
|
|
@@ -2504,17 +2670,57 @@ declare function harnessProfile(harness: HarnessGraph, opts?: GraphProfileOption
|
|
|
2504
2670
|
* One call gives full pipeline visibility with stage labels and elapsed
|
|
2505
2671
|
* timestamps relative to the `harnessTrace()` invocation time.
|
|
2506
2672
|
*
|
|
2673
|
+
* Supports two output modes:
|
|
2674
|
+
* - **String logger** (default): rendered lines to `console.log` or a custom sink.
|
|
2675
|
+
* - **Structured events**: programmatic `TraceEvent[]` list for test assertions
|
|
2676
|
+
* and tooling. Access via `handle.events`.
|
|
2677
|
+
*
|
|
2678
|
+
* Supports configurable detail levels (`"summary"`, `"standard"`, `"full"`)
|
|
2679
|
+
* to control output verbosity without composing different tool calls.
|
|
2680
|
+
*
|
|
2507
2681
|
* @module
|
|
2508
2682
|
*/
|
|
2509
2683
|
|
|
2684
|
+
/** Event type captured by structured trace. */
|
|
2685
|
+
type TraceEventType = "data" | "error" | "complete";
|
|
2686
|
+
/** A single structured trace event. */
|
|
2687
|
+
interface TraceEvent {
|
|
2688
|
+
/** Elapsed seconds since trace was created. */
|
|
2689
|
+
elapsed: number;
|
|
2690
|
+
/** Pipeline stage label (INTAKE, TRIAGE, QUEUE, GATE, EXECUTE, VERIFY, STRATEGY). */
|
|
2691
|
+
stage: string;
|
|
2692
|
+
/** Event type. */
|
|
2693
|
+
type: TraceEventType;
|
|
2694
|
+
/** Data payload (present for "data" and "error" events). Omitted at "summary" detail. */
|
|
2695
|
+
data?: unknown;
|
|
2696
|
+
/** Human-readable summary of the data. Present at "standard" and "full" detail. */
|
|
2697
|
+
summary?: string;
|
|
2698
|
+
}
|
|
2699
|
+
/** Detail level for trace output. */
|
|
2700
|
+
type TraceDetail =
|
|
2701
|
+
/** Stage + elapsed only. No data preview. Lowest overhead. */
|
|
2702
|
+
"summary"
|
|
2703
|
+
/** Stage + elapsed + truncated data preview. Default. */
|
|
2704
|
+
| "standard"
|
|
2705
|
+
/** Stage + elapsed + full raw data. Use for debugging, not production. */
|
|
2706
|
+
| "full";
|
|
2510
2707
|
/** Handle returned by {@link harnessTrace}. Call `dispose()` to stop tracing. */
|
|
2511
2708
|
interface HarnessTraceHandle {
|
|
2709
|
+
/** Stop tracing and detach all observers. Safe to call multiple times. */
|
|
2512
2710
|
dispose(): void;
|
|
2711
|
+
/**
|
|
2712
|
+
* Structured trace events collected since creation. Plain array — no
|
|
2713
|
+
* subscription needed (COMPOSITION-GUIDE §1: avoid lazy-activation
|
|
2714
|
+
* friction for inspection tools). Populated reactively via observe().
|
|
2715
|
+
*/
|
|
2716
|
+
readonly events: readonly TraceEvent[];
|
|
2513
2717
|
}
|
|
2514
2718
|
/** Options for {@link harnessTrace}. */
|
|
2515
2719
|
interface HarnessTraceOptions {
|
|
2516
2720
|
/** Sink for rendered trace lines. Default: `console.log`. */
|
|
2517
2721
|
logger?: (line: string) => void;
|
|
2722
|
+
/** Detail level for both string and structured output. Default: `"summary"`. */
|
|
2723
|
+
detail?: TraceDetail;
|
|
2518
2724
|
}
|
|
2519
2725
|
/**
|
|
2520
2726
|
* Attach reactive trace observers to all harness pipeline stages.
|
|
@@ -2523,12 +2729,22 @@ interface HarnessTraceOptions {
|
|
|
2523
2729
|
* intercepting the logger callback to emit stage-labeled lines with
|
|
2524
2730
|
* elapsed timestamps. Surfaces DATA, ERROR, and COMPLETE events.
|
|
2525
2731
|
*
|
|
2732
|
+
* **Structured events:** Every trace event is also pushed to
|
|
2733
|
+
* `handle.events` — a plain array (not a reactive node) that tests and
|
|
2734
|
+
* tooling can inspect programmatically. To use structured events alone
|
|
2735
|
+
* without string output, pass `{ logger: null }`.
|
|
2736
|
+
*
|
|
2737
|
+
* **Detail levels:**
|
|
2738
|
+
* - `"summary"` — stage + elapsed only. Minimal overhead.
|
|
2739
|
+
* - `"standard"` (default) — stage + elapsed + truncated data preview.
|
|
2740
|
+
* - `"full"` — stage + elapsed + full raw data object in events.
|
|
2741
|
+
*
|
|
2526
2742
|
* Elapsed timestamps are relative to the `harnessTrace()` invocation time,
|
|
2527
2743
|
* not the first event.
|
|
2528
2744
|
*
|
|
2529
2745
|
* @param harness - The HarnessGraph to trace.
|
|
2530
2746
|
* @param opts - Optional configuration.
|
|
2531
|
-
* @returns Handle with `dispose()` to stop tracing.
|
|
2747
|
+
* @returns Handle with `dispose()` to stop tracing and `events` for structured access.
|
|
2532
2748
|
*/
|
|
2533
2749
|
declare function harnessTrace(harness: HarnessGraph, opts?: HarnessTraceOptions): HarnessTraceHandle;
|
|
2534
2750
|
|
|
@@ -2559,6 +2775,7 @@ type index$1_HarnessLoopOptions = HarnessLoopOptions;
|
|
|
2559
2775
|
type index$1_HarnessProfileResult = HarnessProfileResult;
|
|
2560
2776
|
type index$1_HarnessTraceHandle = HarnessTraceHandle;
|
|
2561
2777
|
type index$1_HarnessTraceOptions = HarnessTraceOptions;
|
|
2778
|
+
type index$1_IntakeBridgeOptions = IntakeBridgeOptions;
|
|
2562
2779
|
type index$1_IntakeItem = IntakeItem;
|
|
2563
2780
|
type index$1_IntakeSource = IntakeSource;
|
|
2564
2781
|
type index$1_Intervention = Intervention;
|
|
@@ -2572,8 +2789,12 @@ type index$1_StrategyEntry = StrategyEntry;
|
|
|
2572
2789
|
type index$1_StrategyKey = StrategyKey;
|
|
2573
2790
|
type index$1_StrategyModelBundle = StrategyModelBundle;
|
|
2574
2791
|
type index$1_StrategySnapshot = StrategySnapshot;
|
|
2792
|
+
type index$1_TraceDetail = TraceDetail;
|
|
2793
|
+
type index$1_TraceEvent = TraceEvent;
|
|
2794
|
+
type index$1_TraceEventType = TraceEventType;
|
|
2575
2795
|
type index$1_TriagedItem = TriagedItem;
|
|
2576
2796
|
type index$1_VerifyResult = VerifyResult;
|
|
2797
|
+
declare const index$1_createIntakeBridge: typeof createIntakeBridge;
|
|
2577
2798
|
declare const index$1_defaultErrorClassifier: typeof defaultErrorClassifier;
|
|
2578
2799
|
declare const index$1_evalIntakeBridge: typeof evalIntakeBridge;
|
|
2579
2800
|
declare const index$1_harnessLoop: typeof harnessLoop;
|
|
@@ -2583,7 +2804,7 @@ declare const index$1_priorityScore: typeof priorityScore;
|
|
|
2583
2804
|
declare const index$1_strategyKey: typeof strategyKey;
|
|
2584
2805
|
declare const index$1_strategyModel: typeof strategyModel;
|
|
2585
2806
|
declare namespace index$1 {
|
|
2586
|
-
export { index$1_DEFAULT_DECAY_RATE as DEFAULT_DECAY_RATE, index$1_DEFAULT_QUEUE_CONFIGS as DEFAULT_QUEUE_CONFIGS, index$1_DEFAULT_SEVERITY_WEIGHTS as DEFAULT_SEVERITY_WEIGHTS, type index$1_ErrorClass as ErrorClass, type index$1_ErrorClassifier as ErrorClassifier, type index$1_EvalIntakeBridgeOptions as EvalIntakeBridgeOptions, type index$1_EvalJudgeScore as EvalJudgeScore, type index$1_EvalResult as EvalResult, type index$1_EvalTaskResult as EvalTaskResult, type index$1_ExecuteOutput as ExecuteOutput, type index$1_ExecutionResult as ExecutionResult, index$1_HarnessGraph as HarnessGraph, type index$1_HarnessLoopOptions as HarnessLoopOptions, type index$1_HarnessProfileResult as HarnessProfileResult, type index$1_HarnessTraceHandle as HarnessTraceHandle, type index$1_HarnessTraceOptions as HarnessTraceOptions, type index$1_IntakeItem as IntakeItem, type index$1_IntakeSource as IntakeSource, type index$1_Intervention as Intervention, type index$1_PrioritySignals as PrioritySignals, index$1_QUEUE_NAMES as QUEUE_NAMES, type index$1_QueueConfig as QueueConfig, type index$1_QueueRoute as QueueRoute, type index$1_RootCause as RootCause, type index$1_Severity as Severity, type index$1_StrategyEntry as StrategyEntry, type index$1_StrategyKey as StrategyKey, type index$1_StrategyModelBundle as StrategyModelBundle, type index$1_StrategySnapshot as StrategySnapshot, type index$1_TriagedItem as TriagedItem, type index$1_VerifyResult as VerifyResult, index$1_defaultErrorClassifier as defaultErrorClassifier, index$1_evalIntakeBridge as evalIntakeBridge, index$1_harnessLoop as harnessLoop, index$1_harnessProfile as harnessProfile, index$1_harnessTrace as harnessTrace, index$1_priorityScore as priorityScore, index$1_strategyKey as strategyKey, index$1_strategyModel as strategyModel };
|
|
2807
|
+
export { index$1_DEFAULT_DECAY_RATE as DEFAULT_DECAY_RATE, index$1_DEFAULT_QUEUE_CONFIGS as DEFAULT_QUEUE_CONFIGS, index$1_DEFAULT_SEVERITY_WEIGHTS as DEFAULT_SEVERITY_WEIGHTS, type index$1_ErrorClass as ErrorClass, type index$1_ErrorClassifier as ErrorClassifier, type index$1_EvalIntakeBridgeOptions as EvalIntakeBridgeOptions, type index$1_EvalJudgeScore as EvalJudgeScore, type index$1_EvalResult as EvalResult, type index$1_EvalTaskResult as EvalTaskResult, type index$1_ExecuteOutput as ExecuteOutput, type index$1_ExecutionResult as ExecutionResult, index$1_HarnessGraph as HarnessGraph, type index$1_HarnessLoopOptions as HarnessLoopOptions, type index$1_HarnessProfileResult as HarnessProfileResult, type index$1_HarnessTraceHandle as HarnessTraceHandle, type index$1_HarnessTraceOptions as HarnessTraceOptions, type index$1_IntakeBridgeOptions as IntakeBridgeOptions, type index$1_IntakeItem as IntakeItem, type index$1_IntakeSource as IntakeSource, type index$1_Intervention as Intervention, type index$1_PrioritySignals as PrioritySignals, index$1_QUEUE_NAMES as QUEUE_NAMES, type index$1_QueueConfig as QueueConfig, type index$1_QueueRoute as QueueRoute, type index$1_RootCause as RootCause, type index$1_Severity as Severity, type index$1_StrategyEntry as StrategyEntry, type index$1_StrategyKey as StrategyKey, type index$1_StrategyModelBundle as StrategyModelBundle, type index$1_StrategySnapshot as StrategySnapshot, type index$1_TraceDetail as TraceDetail, type index$1_TraceEvent as TraceEvent, type index$1_TraceEventType as TraceEventType, type index$1_TriagedItem as TriagedItem, type index$1_VerifyResult as VerifyResult, index$1_createIntakeBridge as createIntakeBridge, index$1_defaultErrorClassifier as defaultErrorClassifier, index$1_evalIntakeBridge as evalIntakeBridge, index$1_harnessLoop as harnessLoop, index$1_harnessProfile as harnessProfile, index$1_harnessTrace as harnessTrace, index$1_priorityScore as priorityScore, index$1_strategyKey as strategyKey, index$1_strategyModel as strategyModel };
|
|
2587
2808
|
}
|
|
2588
2809
|
|
|
2589
2810
|
/**
|
|
@@ -2741,9 +2962,52 @@ type ScorerOptions = Omit<NodeOptions, "describeKind" | "name" | "meta"> & {
|
|
|
2741
2962
|
* @category patterns
|
|
2742
2963
|
*/
|
|
2743
2964
|
declare function scorer(sources: ReadonlyArray<Node<number>>, weights: ReadonlyArray<Node<number>>, opts?: ScorerOptions): Node<ScoredItem<number[]>>;
|
|
2965
|
+
/** A single effectiveness record for an action×context pair. */
|
|
2966
|
+
type EffectivenessEntry = {
|
|
2967
|
+
readonly key: string;
|
|
2968
|
+
readonly attempts: number;
|
|
2969
|
+
readonly successes: number;
|
|
2970
|
+
readonly successRate: number;
|
|
2971
|
+
};
|
|
2972
|
+
/** Snapshot shape for the effectiveness tracker node. */
|
|
2973
|
+
type EffectivenessSnapshot = ReadonlyMap<string, EffectivenessEntry>;
|
|
2974
|
+
/** Bundle returned by {@link effectivenessTracker}. */
|
|
2975
|
+
interface EffectivenessTrackerBundle {
|
|
2976
|
+
/** Reactive node — current effectiveness map snapshot. */
|
|
2977
|
+
readonly node: Node<EffectivenessSnapshot>;
|
|
2978
|
+
/** Record a completed action (success or failure). */
|
|
2979
|
+
record(key: string, success: boolean): void;
|
|
2980
|
+
/** Look up effectiveness for a specific key. */
|
|
2981
|
+
lookup(key: string): EffectivenessEntry | undefined;
|
|
2982
|
+
/** Tear down internal keepalive subscriptions. */
|
|
2983
|
+
dispose(): void;
|
|
2984
|
+
}
|
|
2985
|
+
/** Options for {@link effectivenessTracker}. */
|
|
2986
|
+
type EffectivenessTrackerOptions = {
|
|
2987
|
+
/** Name for the reactive map (default "effectiveness-entries"). */
|
|
2988
|
+
name?: string;
|
|
2989
|
+
};
|
|
2990
|
+
/**
|
|
2991
|
+
* Generic action×context → success rate tracker.
|
|
2992
|
+
*
|
|
2993
|
+
* Generalized from the harness `strategyModel` pattern. Tracks attempts and
|
|
2994
|
+
* successes per string key, exposes a reactive snapshot node, and provides
|
|
2995
|
+
* `record()` / `lookup()` methods.
|
|
2996
|
+
*
|
|
2997
|
+
* Use cases: A/B testing, routing optimization, cache policy tuning, retry
|
|
2998
|
+
* strategy selection — any domain that tracks effectiveness per action.
|
|
2999
|
+
*
|
|
3000
|
+
* @param opts - Optional configuration.
|
|
3001
|
+
* @returns Bundle with reactive node, record(), lookup(), dispose().
|
|
3002
|
+
*/
|
|
3003
|
+
declare function effectivenessTracker(opts?: EffectivenessTrackerOptions): EffectivenessTrackerBundle;
|
|
2744
3004
|
|
|
2745
3005
|
type reduction_BudgetConstraint<T = unknown> = BudgetConstraint<T>;
|
|
2746
3006
|
type reduction_BudgetGateOptions = BudgetGateOptions;
|
|
3007
|
+
type reduction_EffectivenessEntry = EffectivenessEntry;
|
|
3008
|
+
type reduction_EffectivenessSnapshot = EffectivenessSnapshot;
|
|
3009
|
+
type reduction_EffectivenessTrackerBundle = EffectivenessTrackerBundle;
|
|
3010
|
+
type reduction_EffectivenessTrackerOptions = EffectivenessTrackerOptions;
|
|
2747
3011
|
type reduction_FeedbackOptions = FeedbackOptions;
|
|
2748
3012
|
type reduction_FunnelOptions = FunnelOptions;
|
|
2749
3013
|
type reduction_FunnelStage = FunnelStage;
|
|
@@ -2753,12 +3017,13 @@ type reduction_StepRef = StepRef;
|
|
|
2753
3017
|
type reduction_StratifyOptions = StratifyOptions;
|
|
2754
3018
|
type reduction_StratifyRule<T> = StratifyRule<T>;
|
|
2755
3019
|
declare const reduction_budgetGate: typeof budgetGate;
|
|
3020
|
+
declare const reduction_effectivenessTracker: typeof effectivenessTracker;
|
|
2756
3021
|
declare const reduction_feedback: typeof feedback;
|
|
2757
3022
|
declare const reduction_funnel: typeof funnel;
|
|
2758
3023
|
declare const reduction_scorer: typeof scorer;
|
|
2759
3024
|
declare const reduction_stratify: typeof stratify;
|
|
2760
3025
|
declare namespace reduction {
|
|
2761
|
-
export { type reduction_BudgetConstraint as BudgetConstraint, type reduction_BudgetGateOptions as BudgetGateOptions, type reduction_FeedbackOptions as FeedbackOptions, type reduction_FunnelOptions as FunnelOptions, type reduction_FunnelStage as FunnelStage, type reduction_ScoredItem as ScoredItem, type reduction_ScorerOptions as ScorerOptions, type reduction_StepRef as StepRef, type reduction_StratifyOptions as StratifyOptions, type reduction_StratifyRule as StratifyRule, reduction_budgetGate as budgetGate, reduction_feedback as feedback, reduction_funnel as funnel, reduction_scorer as scorer, reduction_stratify as stratify };
|
|
3026
|
+
export { type reduction_BudgetConstraint as BudgetConstraint, type reduction_BudgetGateOptions as BudgetGateOptions, type reduction_EffectivenessEntry as EffectivenessEntry, type reduction_EffectivenessSnapshot as EffectivenessSnapshot, type reduction_EffectivenessTrackerBundle as EffectivenessTrackerBundle, type reduction_EffectivenessTrackerOptions as EffectivenessTrackerOptions, type reduction_FeedbackOptions as FeedbackOptions, type reduction_FunnelOptions as FunnelOptions, type reduction_FunnelStage as FunnelStage, type reduction_ScoredItem as ScoredItem, type reduction_ScorerOptions as ScorerOptions, type reduction_StepRef as StepRef, type reduction_StratifyOptions as StratifyOptions, type reduction_StratifyRule as StratifyRule, reduction_budgetGate as budgetGate, reduction_effectivenessTracker as effectivenessTracker, reduction_feedback as feedback, reduction_funnel as funnel, reduction_scorer as scorer, reduction_stratify as stratify };
|
|
2762
3027
|
}
|
|
2763
3028
|
|
|
2764
3029
|
/**
|