@mikesaintsg/core 0.0.5 → 0.0.7
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/README.md +24 -0
- package/dist/index.d.ts +425 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -168,18 +168,31 @@ Implementation classes for cross-package bridges (also available via factory fun
|
|
|
168
168
|
| `Ok<T>`, `Err<E>` | Result discriminants |
|
|
169
169
|
| `Unsubscribe` | Cleanup function type |
|
|
170
170
|
| `Destroyable` | Interface for resources with cleanup |
|
|
171
|
+
| `AbortableOptions` | Interface for cancellable operations |
|
|
171
172
|
| `SubscriptionToHook<T>` | Convert subscriptions to hooks |
|
|
173
|
+
| `ChangeSource` | Origin of state change (local/remote) |
|
|
174
|
+
| `ContentHash` | SHA-256 hex string for deduplication |
|
|
172
175
|
| `Embedding` | Float32Array embedding vector |
|
|
176
|
+
| `EmbeddingModelMetadata` | Embedding model information |
|
|
173
177
|
| `ToolCall`, `ToolResult`, `ToolSchema` | Tool-related types |
|
|
178
|
+
| `Message`, `MessageRole`, `MessageContent`| Message types for inference |
|
|
179
|
+
| `GenerationOptions`, `GenerationResult` | Generation configuration and result |
|
|
174
180
|
| `ScoredResult` | Search result with score |
|
|
175
181
|
| `ContextFrame`, `BuiltContext` | Context management types |
|
|
176
182
|
| `TokenBudgetState`, `TokenBudgetLevel` | Token budget types |
|
|
183
|
+
| `Actor`, `EngagementState` | ActionLoop shared types |
|
|
184
|
+
| `TransitionEvent`, `DwellRecord` | Transition tracking types |
|
|
185
|
+
| `ModelTier`, `ModelInfo` | Model orchestration types |
|
|
186
|
+
| `StorageInfo`, `PruneResult` | Storage utility types |
|
|
187
|
+
| `HealthStatus`, `SystemHealth` | Health check types |
|
|
188
|
+
| `CircuitState`, `LifecycleState` | System state types |
|
|
177
189
|
|
|
178
190
|
### Adapter Interfaces
|
|
179
191
|
|
|
180
192
|
| Interface | Category | Description |
|
|
181
193
|
|-------------------------------------------|---------------|--------------------------------|
|
|
182
194
|
| `EmbeddingAdapterInterface` | Source | Embedding generation |
|
|
195
|
+
| `ProviderAdapterInterface` | Source | LLM provider integration |
|
|
183
196
|
| `ToolFormatAdapterInterface` | Transform | Provider tool formatting |
|
|
184
197
|
| `SimilarityAdapterInterface` | Transform | Vector similarity computation |
|
|
185
198
|
| `DeduplicationAdapterInterface` | Transform | Frame deduplication |
|
|
@@ -187,10 +200,17 @@ Implementation classes for cross-package bridges (also available via factory fun
|
|
|
187
200
|
| `PriorityAdapterInterface` | Transform | Frame priority ordering |
|
|
188
201
|
| `RetryAdapterInterface` | Policy | Retry behavior |
|
|
189
202
|
| `RateLimitAdapterInterface` | Policy | Rate limiting |
|
|
203
|
+
| `CircuitBreakerAdapterInterface` | Policy | Cascading failure prevention |
|
|
190
204
|
| `EmbeddingCacheAdapterInterface` | Enhancement | Embedding caching |
|
|
191
205
|
| `BatchAdapterInterface` | Enhancement | Batch processing |
|
|
192
206
|
| `RerankerAdapterInterface` | Enhancement | Result reranking |
|
|
207
|
+
| `TelemetryAdapterInterface` | Observability | Monitoring and debugging |
|
|
193
208
|
| `VectorStorePersistenceAdapterInterface` | Persistence | Vector storage |
|
|
209
|
+
| `SessionPersistenceInterface` | Persistence | Session storage |
|
|
210
|
+
| `EventStorePersistenceAdapterInterface` | Persistence | Transition event storage |
|
|
211
|
+
| `WeightPersistenceAdapterInterface` | Persistence | Predictive weight storage |
|
|
212
|
+
| `StreamerAdapterInterface` | Streaming | Token emission |
|
|
213
|
+
| `SSEParserAdapterInterface` | Streaming | Server-sent events parsing |
|
|
194
214
|
|
|
195
215
|
### Minimal Cross-Package Interfaces
|
|
196
216
|
|
|
@@ -204,6 +224,10 @@ Implementation classes for cross-package bridges (also available via factory fun
|
|
|
204
224
|
| `VectorStoreMinimal<T>` | Vector store without dependency |
|
|
205
225
|
| `FormMinimal<T>` | Form state without dependency |
|
|
206
226
|
| `SerializableSession` | Session serialization interface |
|
|
227
|
+
| `TokenCounterInterface` | Token counting for models |
|
|
228
|
+
| `HealthCheckInterface` | Health check for components |
|
|
229
|
+
| `ActivityTrackerInterface` | User engagement tracking |
|
|
230
|
+
| `ShutdownManagerInterface` | Graceful shutdown coordination |
|
|
207
231
|
|
|
208
232
|
---
|
|
209
233
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,16 @@ export declare interface AbortableOptions {
|
|
|
3
3
|
readonly signal?: AbortSignal;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
/** Activity metrics for a session */
|
|
7
|
+
export declare interface ActivityMetrics {
|
|
8
|
+
readonly activeTimeMs: number;
|
|
9
|
+
readonly idleTimeMs: number;
|
|
10
|
+
readonly awayTimeMs: number;
|
|
11
|
+
readonly interactionCount: number;
|
|
12
|
+
readonly lastInteractionAt: number;
|
|
13
|
+
readonly sessionStartedAt: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
/**
|
|
7
17
|
* Activity tracker adapter interface.
|
|
8
18
|
*
|
|
@@ -16,6 +26,12 @@ export declare interface ActivityTrackerInterface extends ActivityTrackerSubscri
|
|
|
16
26
|
exitNode(): DwellRecord | undefined;
|
|
17
27
|
/** Get current engagement state */
|
|
18
28
|
getEngagementState(): EngagementState;
|
|
29
|
+
/** Get current visibility state */
|
|
30
|
+
getVisibilityState(): VisibilityState;
|
|
31
|
+
/** Get current focus state */
|
|
32
|
+
getFocusState(): FocusState;
|
|
33
|
+
/** Get activity metrics summary */
|
|
34
|
+
getMetrics(): ActivityMetrics;
|
|
19
35
|
/** Get current node ID being tracked */
|
|
20
36
|
getCurrentNodeId(): string | undefined;
|
|
21
37
|
/** Get current incomplete dwell record */
|
|
@@ -26,6 +42,10 @@ export declare interface ActivityTrackerInterface extends ActivityTrackerSubscri
|
|
|
26
42
|
getTotalActiveTime(): number;
|
|
27
43
|
/** Get total idle time across all dwells */
|
|
28
44
|
getTotalIdleTime(): number;
|
|
45
|
+
/** Record an interaction (resets idle timer) */
|
|
46
|
+
recordInteraction(): void;
|
|
47
|
+
/** Reset all tracking state */
|
|
48
|
+
reset(): void;
|
|
29
49
|
/** Clear dwell history */
|
|
30
50
|
clearHistory(): void;
|
|
31
51
|
}
|
|
@@ -44,6 +64,12 @@ export declare interface ActivityTrackerOptions extends SubscriptionToHook<Activ
|
|
|
44
64
|
export declare interface ActivityTrackerSubscriptions {
|
|
45
65
|
/** Subscribe to engagement state changes */
|
|
46
66
|
onEngagementChange(callback: (state: EngagementState, nodeId: string) => void): Unsubscribe;
|
|
67
|
+
/** Subscribe to visibility state changes */
|
|
68
|
+
onVisibilityChange(callback: (state: VisibilityState) => void): Unsubscribe;
|
|
69
|
+
/** Subscribe to focus state changes */
|
|
70
|
+
onFocusChange(callback: (state: FocusState) => void): Unsubscribe;
|
|
71
|
+
/** Subscribe to idle warnings before state changes to away */
|
|
72
|
+
onIdleWarning(callback: (idleTimeMs: number) => void): Unsubscribe;
|
|
47
73
|
/** Subscribe to completed dwell records */
|
|
48
74
|
onDwellComplete(callback: (record: DwellRecord) => void): Unsubscribe;
|
|
49
75
|
}
|
|
@@ -51,6 +77,25 @@ export declare interface ActivityTrackerSubscriptions {
|
|
|
51
77
|
/** Actor types for transition attribution */
|
|
52
78
|
export declare type Actor = 'user' | 'system' | 'automation';
|
|
53
79
|
|
|
80
|
+
/** Backpressure configuration */
|
|
81
|
+
export declare interface BackpressureConfig {
|
|
82
|
+
readonly strategy: BackpressureStrategy;
|
|
83
|
+
readonly highWaterMark: number;
|
|
84
|
+
readonly lowWaterMark?: number;
|
|
85
|
+
readonly bufferSize?: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Backpressure state */
|
|
89
|
+
export declare interface BackpressureState {
|
|
90
|
+
readonly currentSize: number;
|
|
91
|
+
readonly highWaterMark: number;
|
|
92
|
+
readonly isPaused: boolean;
|
|
93
|
+
readonly droppedCount: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Backpressure strategy */
|
|
97
|
+
export declare type BackpressureStrategy = 'drop' | 'block' | 'buffer' | 'error';
|
|
98
|
+
|
|
54
99
|
/**
|
|
55
100
|
* Batch adapter interface.
|
|
56
101
|
* Controls batching behavior for bulk operations.
|
|
@@ -107,6 +152,57 @@ export declare function chain<T, U, E>(result: Result<T, E>, fn: (value: T) => R
|
|
|
107
152
|
/** Origin of state change */
|
|
108
153
|
export declare type ChangeSource = 'local' | 'remote';
|
|
109
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Circuit breaker adapter interface.
|
|
157
|
+
* Prevents cascading failures by tracking error rates.
|
|
158
|
+
*/
|
|
159
|
+
export declare interface CircuitBreakerAdapterInterface extends CircuitBreakerSubscriptions {
|
|
160
|
+
/** Execute operation with circuit breaker protection */
|
|
161
|
+
execute<T>(operation: () => Promise<T>): Promise<T>;
|
|
162
|
+
/** Get current circuit state */
|
|
163
|
+
getState(): CircuitBreakerState;
|
|
164
|
+
/** Manually open the circuit */
|
|
165
|
+
open(): void;
|
|
166
|
+
/** Manually close the circuit */
|
|
167
|
+
close(): void;
|
|
168
|
+
/** Reset all counters and close circuit */
|
|
169
|
+
reset(): void;
|
|
170
|
+
/** Check if operation can proceed */
|
|
171
|
+
canExecute(): boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Circuit breaker configuration */
|
|
175
|
+
export declare interface CircuitBreakerConfig {
|
|
176
|
+
/** Failure threshold before opening circuit (default: 5) */
|
|
177
|
+
readonly failureThreshold: number;
|
|
178
|
+
/** Success threshold to close circuit from half-open (default: 3) */
|
|
179
|
+
readonly successThreshold: number;
|
|
180
|
+
/** Time in ms before attempting half-open (default: 30000) */
|
|
181
|
+
readonly resetTimeoutMs: number;
|
|
182
|
+
/** Time window for counting failures (default: 60000) */
|
|
183
|
+
readonly monitorWindowMs: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Circuit breaker state snapshot */
|
|
187
|
+
export declare interface CircuitBreakerState {
|
|
188
|
+
readonly state: CircuitState;
|
|
189
|
+
readonly failureCount: number;
|
|
190
|
+
readonly successCount: number;
|
|
191
|
+
readonly lastFailureTime: number | undefined;
|
|
192
|
+
readonly lastSuccessTime: number | undefined;
|
|
193
|
+
readonly nextAttemptTime: number | undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Circuit breaker subscriptions */
|
|
197
|
+
export declare interface CircuitBreakerSubscriptions {
|
|
198
|
+
onStateChange(callback: (state: CircuitState, previous: CircuitState) => void): Unsubscribe;
|
|
199
|
+
onFailure(callback: (error: unknown, failureCount: number) => void): Unsubscribe;
|
|
200
|
+
onSuccess(callback: (successCount: number) => void): Unsubscribe;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Circuit breaker state */
|
|
204
|
+
export declare type CircuitState = 'closed' | 'open' | 'half-open';
|
|
205
|
+
|
|
110
206
|
/**
|
|
111
207
|
* Compute a SHA-256 content hash for text.
|
|
112
208
|
*
|
|
@@ -121,6 +217,41 @@ export declare type ChangeSource = 'local' | 'remote';
|
|
|
121
217
|
*/
|
|
122
218
|
export declare function computeContentHash(text: string): Promise<ContentHash>;
|
|
123
219
|
|
|
220
|
+
/** Configuration validation error */
|
|
221
|
+
export declare interface ConfigValidationError {
|
|
222
|
+
readonly path: string;
|
|
223
|
+
readonly message: string;
|
|
224
|
+
readonly expected?: string;
|
|
225
|
+
readonly received?: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Configuration validation result */
|
|
229
|
+
export declare interface ConfigValidationResult {
|
|
230
|
+
readonly valid: boolean;
|
|
231
|
+
readonly errors: readonly ConfigValidationError[];
|
|
232
|
+
readonly warnings: readonly ConfigValidationWarning[];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Configuration validation warning */
|
|
236
|
+
export declare interface ConfigValidationWarning {
|
|
237
|
+
readonly path: string;
|
|
238
|
+
readonly message: string;
|
|
239
|
+
readonly suggestion?: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Configuration validator interface.
|
|
244
|
+
* Validates configuration objects against expected schemas.
|
|
245
|
+
*/
|
|
246
|
+
export declare interface ConfigValidatorInterface<T> {
|
|
247
|
+
/** Validate configuration */
|
|
248
|
+
validate(config: unknown): ConfigValidationResult;
|
|
249
|
+
/** Get validated configuration or throw */
|
|
250
|
+
validateOrThrow(config: unknown): T;
|
|
251
|
+
/** Get default configuration */
|
|
252
|
+
getDefaults(): Partial<T>;
|
|
253
|
+
}
|
|
254
|
+
|
|
124
255
|
/** Content hash for deduplication (SHA-256 hex string) */
|
|
125
256
|
export declare type ContentHash = string;
|
|
126
257
|
|
|
@@ -284,6 +415,9 @@ export declare interface Destroyable {
|
|
|
284
415
|
destroy(): void;
|
|
285
416
|
}
|
|
286
417
|
|
|
418
|
+
/** Detected intent from user input */
|
|
419
|
+
export declare type DetectedIntent = 'search' | 'question' | 'action' | 'navigation' | 'unclear';
|
|
420
|
+
|
|
287
421
|
/** Dwell record capturing time spent on a node */
|
|
288
422
|
export declare interface DwellRecord {
|
|
289
423
|
readonly nodeId: string;
|
|
@@ -466,6 +600,9 @@ export declare interface ExportedWeight {
|
|
|
466
600
|
/** Generation finish reason */
|
|
467
601
|
export declare type FinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'error';
|
|
468
602
|
|
|
603
|
+
/** Focus state for activity tracking */
|
|
604
|
+
export declare type FocusState = 'focused' | 'blurred';
|
|
605
|
+
|
|
469
606
|
/** Default form dirty guard message */
|
|
470
607
|
export declare const FORM_DIRTY_DEFAULT_MESSAGE = "You have unsaved changes. Are you sure you want to leave?";
|
|
471
608
|
|
|
@@ -567,6 +704,61 @@ export declare interface GenerationResult {
|
|
|
567
704
|
readonly aborted: boolean;
|
|
568
705
|
}
|
|
569
706
|
|
|
707
|
+
/**
|
|
708
|
+
* Health check interface for system components.
|
|
709
|
+
* Implement this to enable health monitoring.
|
|
710
|
+
*/
|
|
711
|
+
export declare interface HealthCheckInterface {
|
|
712
|
+
/** Perform health check */
|
|
713
|
+
check(): Promise<HealthCheckResult>;
|
|
714
|
+
/** Get component name */
|
|
715
|
+
getName(): string;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/** Individual health check result */
|
|
719
|
+
export declare interface HealthCheckResult {
|
|
720
|
+
readonly name: string;
|
|
721
|
+
readonly status: HealthStatus;
|
|
722
|
+
readonly message?: string;
|
|
723
|
+
readonly latencyMs?: number;
|
|
724
|
+
readonly timestamp: number;
|
|
725
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** Health status for a component */
|
|
729
|
+
export declare type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
|
|
730
|
+
|
|
731
|
+
/** Histogram bucket for distribution metrics */
|
|
732
|
+
export declare interface HistogramBucket {
|
|
733
|
+
readonly le: number;
|
|
734
|
+
readonly count: number;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/** Histogram metric data */
|
|
738
|
+
export declare interface HistogramMetric {
|
|
739
|
+
readonly name: string;
|
|
740
|
+
readonly buckets: readonly HistogramBucket[];
|
|
741
|
+
readonly sum: number;
|
|
742
|
+
readonly count: number;
|
|
743
|
+
readonly labels?: Readonly<Record<string, string>>;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Intent detection result */
|
|
747
|
+
export declare interface IntentDetectionResult {
|
|
748
|
+
readonly original: string;
|
|
749
|
+
readonly intent: DetectedIntent;
|
|
750
|
+
readonly confidence: number;
|
|
751
|
+
readonly refinedPrompt: string;
|
|
752
|
+
readonly processingTimeMs: number;
|
|
753
|
+
readonly modelTier: ModelTier;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/** Intent detector interface */
|
|
757
|
+
export declare interface IntentDetectorInterface {
|
|
758
|
+
detect(input: string, options?: AbortableOptions): Promise<IntentDetectionResult>;
|
|
759
|
+
refine(input: string, intent: DetectedIntent, options?: AbortableOptions): Promise<string>;
|
|
760
|
+
}
|
|
761
|
+
|
|
570
762
|
/**
|
|
571
763
|
* Type guard for ecosystem errors.
|
|
572
764
|
*
|
|
@@ -654,6 +846,33 @@ export declare interface JSONSchema7 {
|
|
|
654
846
|
readonly definitions?: Readonly<Record<string, JSONSchema7>>;
|
|
655
847
|
}
|
|
656
848
|
|
|
849
|
+
/**
|
|
850
|
+
* Lifecycle-aware component interface.
|
|
851
|
+
* Provides standardized lifecycle management.
|
|
852
|
+
*/
|
|
853
|
+
export declare interface LifecycleAwareInterface {
|
|
854
|
+
/** Get current lifecycle state */
|
|
855
|
+
getLifecycleState(): LifecycleState;
|
|
856
|
+
/** Subscribe to lifecycle state changes */
|
|
857
|
+
onLifecycleChange(callback: (state: LifecycleState, previous: LifecycleState) => void): Unsubscribe;
|
|
858
|
+
/** Check if component is ready for operations */
|
|
859
|
+
isReady(): boolean;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/** Component lifecycle state */
|
|
863
|
+
export declare type LifecycleState = 'created' | 'initializing' | 'ready' | 'degraded' | 'stopping' | 'stopped' | 'error';
|
|
864
|
+
|
|
865
|
+
/** Lifecycle state transition */
|
|
866
|
+
export declare interface LifecycleTransition {
|
|
867
|
+
readonly from: LifecycleState;
|
|
868
|
+
readonly to: LifecycleState;
|
|
869
|
+
readonly timestamp: number;
|
|
870
|
+
readonly reason?: string;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/** Log level for telemetry */
|
|
874
|
+
export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
875
|
+
|
|
657
876
|
/**
|
|
658
877
|
* Map a function over a success value.
|
|
659
878
|
*
|
|
@@ -706,6 +925,26 @@ export declare interface MessageMetadata {
|
|
|
706
925
|
/** Message role */
|
|
707
926
|
export declare type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
708
927
|
|
|
928
|
+
/** Metric definition */
|
|
929
|
+
export declare interface MetricDefinition {
|
|
930
|
+
readonly name: string;
|
|
931
|
+
readonly type: MetricType;
|
|
932
|
+
readonly description: string;
|
|
933
|
+
readonly unit?: string;
|
|
934
|
+
readonly labels?: readonly string[];
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/** Metric type discriminator */
|
|
938
|
+
export declare type MetricType = 'counter' | 'gauge' | 'histogram' | 'summary';
|
|
939
|
+
|
|
940
|
+
/** Recorded metric value */
|
|
941
|
+
export declare interface MetricValue {
|
|
942
|
+
readonly name: string;
|
|
943
|
+
readonly value: number;
|
|
944
|
+
readonly labels?: Readonly<Record<string, string>>;
|
|
945
|
+
readonly timestamp: number;
|
|
946
|
+
}
|
|
947
|
+
|
|
709
948
|
/**
|
|
710
949
|
* Minimal database access interface for cross-package adapters.
|
|
711
950
|
* Used by persistence adapters to access IndexedDB without
|
|
@@ -750,6 +989,58 @@ export declare interface MinimalStoreAccess<T> {
|
|
|
750
989
|
clear(): Promise<void>;
|
|
751
990
|
}
|
|
752
991
|
|
|
992
|
+
/** Model info for orchestration */
|
|
993
|
+
export declare interface ModelInfo {
|
|
994
|
+
readonly tier: ModelTier;
|
|
995
|
+
readonly modelId: string;
|
|
996
|
+
readonly state: ModelLoadingState;
|
|
997
|
+
readonly loadProgress?: number;
|
|
998
|
+
readonly sizeBytes?: number;
|
|
999
|
+
readonly loadedAt?: number;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/** Model loading state */
|
|
1003
|
+
export declare type ModelLoadingState = 'idle' | 'loading' | 'ready' | 'error';
|
|
1004
|
+
|
|
1005
|
+
/** Model orchestrator interface */
|
|
1006
|
+
export declare interface ModelOrchestratorInterface extends ModelOrchestratorSubscriptions, Destroyable {
|
|
1007
|
+
getModelInfo(tier: ModelTier): ModelInfo | undefined;
|
|
1008
|
+
isReady(tier: ModelTier): boolean;
|
|
1009
|
+
getReadyTiers(): readonly ModelTier[];
|
|
1010
|
+
getActiveTier(): ModelTier | undefined;
|
|
1011
|
+
getBestAvailableTier(): ModelTier | undefined;
|
|
1012
|
+
preload(tier: ModelTier): Promise<void>;
|
|
1013
|
+
preloadAll(): Promise<void>;
|
|
1014
|
+
estimateComplexity(prompt: string): number;
|
|
1015
|
+
selectTier(complexity: number): ModelTier;
|
|
1016
|
+
generate(prompt: string, options?: OrchestratorGenerateOptions): Promise<OrchestratorGenerateResult>;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/** Model orchestrator subscriptions */
|
|
1020
|
+
export declare interface ModelOrchestratorSubscriptions {
|
|
1021
|
+
onModelStateChange(callback: (tier: ModelTier, state: ModelLoadingState) => void): Unsubscribe;
|
|
1022
|
+
onModelSwitch(callback: (from: ModelTier, to: ModelTier, reason: string) => void): Unsubscribe;
|
|
1023
|
+
onLoadProgress(callback: (tier: ModelTier, progress: number) => void): Unsubscribe;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** Model selection strategy */
|
|
1027
|
+
export declare type ModelSelectionStrategy = 'auto' | 'local-only' | 'api-only' | 'local-first';
|
|
1028
|
+
|
|
1029
|
+
/** Model tier for progressive loading */
|
|
1030
|
+
export declare type ModelTier = 'fast' | 'balanced' | 'powerful';
|
|
1031
|
+
|
|
1032
|
+
/** Mutex for exclusive access */
|
|
1033
|
+
export declare interface MutexInterface {
|
|
1034
|
+
/** Acquire the mutex, waiting if held */
|
|
1035
|
+
acquire(): Promise<void>;
|
|
1036
|
+
/** Release the mutex */
|
|
1037
|
+
release(): void;
|
|
1038
|
+
/** Check if mutex is currently held */
|
|
1039
|
+
isLocked(): boolean;
|
|
1040
|
+
/** Execute operation with mutex held */
|
|
1041
|
+
withLock<T>(operation: () => Promise<T> | T): Promise<T>;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
753
1044
|
/**
|
|
754
1045
|
* Navigation guard function type.
|
|
755
1046
|
* Returns true to allow navigation, false to block.
|
|
@@ -777,6 +1068,27 @@ export declare interface Ok<T> {
|
|
|
777
1068
|
*/
|
|
778
1069
|
export declare function ok<T>(value: T): Ok<T>;
|
|
779
1070
|
|
|
1071
|
+
/** Model orchestrator generate options */
|
|
1072
|
+
export declare interface OrchestratorGenerateOptions extends AbortableOptions {
|
|
1073
|
+
readonly forceTier?: ModelTier;
|
|
1074
|
+
readonly system?: string;
|
|
1075
|
+
readonly tools?: readonly ToolSchema[];
|
|
1076
|
+
readonly maxTokens?: number;
|
|
1077
|
+
readonly temperature?: number;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/** Model orchestrator generate result */
|
|
1081
|
+
export declare interface OrchestratorGenerateResult {
|
|
1082
|
+
readonly text: string;
|
|
1083
|
+
readonly tier: ModelTier;
|
|
1084
|
+
readonly modelId: string;
|
|
1085
|
+
readonly latencyMs: number;
|
|
1086
|
+
readonly tokenCount?: number;
|
|
1087
|
+
readonly toolCalls?: readonly ToolCall[];
|
|
1088
|
+
readonly escalated?: boolean;
|
|
1089
|
+
readonly escalationReason?: string;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
780
1092
|
/**
|
|
781
1093
|
* Generic error data interface for package-specific errors.
|
|
782
1094
|
* Packages extend this to define their error structure.
|
|
@@ -973,6 +1285,20 @@ export declare interface ScoredResult {
|
|
|
973
1285
|
readonly embedding?: Embedding;
|
|
974
1286
|
}
|
|
975
1287
|
|
|
1288
|
+
/** Semaphore for limiting concurrent operations */
|
|
1289
|
+
export declare interface SemaphoreInterface {
|
|
1290
|
+
/** Acquire a permit, waiting if necessary */
|
|
1291
|
+
acquire(): Promise<void>;
|
|
1292
|
+
/** Try to acquire a permit without waiting */
|
|
1293
|
+
tryAcquire(): boolean;
|
|
1294
|
+
/** Release a permit */
|
|
1295
|
+
release(): void;
|
|
1296
|
+
/** Get number of available permits */
|
|
1297
|
+
availablePermits(): number;
|
|
1298
|
+
/** Get number of operations waiting for permits */
|
|
1299
|
+
queueLength(): number;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
976
1302
|
/**
|
|
977
1303
|
* Minimal session interface for serialization.
|
|
978
1304
|
* Avoids hard dependency on inference package.
|
|
@@ -1060,6 +1386,53 @@ export declare interface SessionPersistenceOptions {
|
|
|
1060
1386
|
*/
|
|
1061
1387
|
export declare function shouldSkipFormGuard<TPage extends string>(to: TPage, from: TPage, excludePages: readonly TPage[], onlyFromPages: readonly TPage[] | undefined): boolean;
|
|
1062
1388
|
|
|
1389
|
+
/** Shutdown handler registration */
|
|
1390
|
+
export declare interface ShutdownHandler {
|
|
1391
|
+
readonly name: string;
|
|
1392
|
+
readonly priority: ShutdownPriority;
|
|
1393
|
+
readonly timeoutMs?: number;
|
|
1394
|
+
readonly handler: () => Promise<void> | void;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/** Shutdown result for individual handler */
|
|
1398
|
+
export declare interface ShutdownHandlerResult {
|
|
1399
|
+
readonly name: string;
|
|
1400
|
+
readonly success: boolean;
|
|
1401
|
+
readonly durationMs: number;
|
|
1402
|
+
readonly error?: Error;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* Graceful shutdown manager interface.
|
|
1407
|
+
* Coordinates orderly shutdown of system components.
|
|
1408
|
+
*/
|
|
1409
|
+
export declare interface ShutdownManagerInterface {
|
|
1410
|
+
/** Register a shutdown handler */
|
|
1411
|
+
register(handler: ShutdownHandler): Unsubscribe;
|
|
1412
|
+
/** Initiate graceful shutdown */
|
|
1413
|
+
shutdown(timeoutMs?: number): Promise<ShutdownResult>;
|
|
1414
|
+
/** Get current shutdown phase */
|
|
1415
|
+
getPhase(): ShutdownPhase;
|
|
1416
|
+
/** Check if shutdown is in progress */
|
|
1417
|
+
isShuttingDown(): boolean;
|
|
1418
|
+
/** Subscribe to phase changes */
|
|
1419
|
+
onPhaseChange(callback: (phase: ShutdownPhase) => void): Unsubscribe;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/** Shutdown phase */
|
|
1423
|
+
export declare type ShutdownPhase = 'running' | 'draining' | 'stopping' | 'stopped';
|
|
1424
|
+
|
|
1425
|
+
/** Shutdown handler priority */
|
|
1426
|
+
export declare type ShutdownPriority = 'first' | 'normal' | 'last';
|
|
1427
|
+
|
|
1428
|
+
/** Overall shutdown result */
|
|
1429
|
+
export declare interface ShutdownResult {
|
|
1430
|
+
readonly success: boolean;
|
|
1431
|
+
readonly phase: ShutdownPhase;
|
|
1432
|
+
readonly handlers: readonly ShutdownHandlerResult[];
|
|
1433
|
+
readonly totalDurationMs: number;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1063
1436
|
/**
|
|
1064
1437
|
* Similarity adapter interface.
|
|
1065
1438
|
* Computes similarity between embedding vectors.
|
|
@@ -1205,6 +1578,53 @@ export declare type SubscriptionToHook<T> = {
|
|
|
1205
1578
|
[K in keyof T]?: T[K] extends (callback: infer CB) => Unsubscribe ? CB : never;
|
|
1206
1579
|
};
|
|
1207
1580
|
|
|
1581
|
+
/** Aggregated health status for a system */
|
|
1582
|
+
export declare interface SystemHealth {
|
|
1583
|
+
readonly status: HealthStatus;
|
|
1584
|
+
readonly checks: readonly HealthCheckResult[];
|
|
1585
|
+
readonly timestamp: number;
|
|
1586
|
+
readonly version?: string;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
/**
|
|
1590
|
+
* Telemetry adapter interface.
|
|
1591
|
+
* Provides observability hooks for monitoring and debugging.
|
|
1592
|
+
*/
|
|
1593
|
+
export declare interface TelemetryAdapterInterface {
|
|
1594
|
+
/** Start a new span for tracing */
|
|
1595
|
+
startSpan(name: string, attributes?: Readonly<Record<string, unknown>>): TelemetrySpan;
|
|
1596
|
+
/** End an active span */
|
|
1597
|
+
endSpan(span: TelemetrySpan, status?: 'ok' | 'error'): void;
|
|
1598
|
+
/** Record a log event */
|
|
1599
|
+
log(level: LogLevel, message: string, attributes?: Readonly<Record<string, unknown>>): void;
|
|
1600
|
+
/** Record a metric value */
|
|
1601
|
+
recordMetric(name: string, value: number, attributes?: Readonly<Record<string, unknown>>): void;
|
|
1602
|
+
/** Flush pending telemetry data */
|
|
1603
|
+
flush(): Promise<void>;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
/** Telemetry event for logging and metrics */
|
|
1607
|
+
export declare interface TelemetryEvent {
|
|
1608
|
+
readonly timestamp: number;
|
|
1609
|
+
readonly level: LogLevel;
|
|
1610
|
+
readonly message: string;
|
|
1611
|
+
readonly attributes?: Readonly<Record<string, unknown>>;
|
|
1612
|
+
readonly spanId?: string;
|
|
1613
|
+
readonly traceId?: string;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
/** Telemetry span for distributed tracing */
|
|
1617
|
+
export declare interface TelemetrySpan {
|
|
1618
|
+
readonly id: string;
|
|
1619
|
+
readonly traceId: string;
|
|
1620
|
+
readonly parentId?: string;
|
|
1621
|
+
readonly name: string;
|
|
1622
|
+
readonly startTime: number;
|
|
1623
|
+
readonly endTime?: number;
|
|
1624
|
+
readonly attributes?: Readonly<Record<string, unknown>>;
|
|
1625
|
+
readonly status: 'ok' | 'error' | 'unset';
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1208
1628
|
/** Timeout options for generation */
|
|
1209
1629
|
export declare interface TimeoutOptions {
|
|
1210
1630
|
readonly requestMs?: number;
|
|
@@ -1278,7 +1698,7 @@ export declare class ToolCallBridge implements ToolCallBridgeInterface {
|
|
|
1278
1698
|
|
|
1279
1699
|
/**
|
|
1280
1700
|
* Tool call bridge interface.
|
|
1281
|
-
* Connects inference tool calls to
|
|
1701
|
+
* Connects inference tool calls to contextbuilder tool registry.
|
|
1282
1702
|
*/
|
|
1283
1703
|
export declare interface ToolCallBridgeInterface {
|
|
1284
1704
|
/**
|
|
@@ -1324,7 +1744,7 @@ export declare interface ToolFormatAdapterInterface {
|
|
|
1324
1744
|
|
|
1325
1745
|
/**
|
|
1326
1746
|
* Minimal tool registry interface for bridge functions.
|
|
1327
|
-
* Avoids hard dependency on
|
|
1747
|
+
* Avoids hard dependency on contextbuilder package.
|
|
1328
1748
|
*/
|
|
1329
1749
|
export declare interface ToolRegistryMinimal {
|
|
1330
1750
|
has(name: string): boolean;
|
|
@@ -1488,6 +1908,9 @@ export declare interface VectorStoreSearchOptions<TMetadata = unknown> {
|
|
|
1488
1908
|
readonly filter?: TMetadata;
|
|
1489
1909
|
}
|
|
1490
1910
|
|
|
1911
|
+
/** Visibility state for activity tracking */
|
|
1912
|
+
export declare type VisibilityState = 'visible' | 'hidden' | 'prerender';
|
|
1913
|
+
|
|
1491
1914
|
/**
|
|
1492
1915
|
* Weight persistence adapter interface.
|
|
1493
1916
|
*
|