@almadar/agent 1.3.1 → 1.3.3
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/agent/index.d.ts +730 -2
- package/dist/agent/index.js +2057 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/{firestore-checkpointer-CkNKXoun.d.ts → firestore-checkpointer-BkFR-sZM.d.ts} +1 -1
- package/dist/index.d.ts +767 -5
- package/dist/index.js +3311 -1801
- package/dist/index.js.map +1 -1
- package/dist/{index-BN4d3ObG.d.ts → interrupt-config-Bib_RCTB.d.ts} +2 -3
- package/dist/persistence/index.d.ts +2 -2
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ import { DomainContext, OrbitalSchema, Orbital } from '@almadar/core/types';
|
|
|
7
7
|
export { DomainDocument, DomainToSchemaResult, ParseError, SchemaToDomainResult, SectionMapping, applySectionUpdate, convertDomainToSchema, convertSchemaToDomain, deleteSection } from '@almadar/core/domain-language';
|
|
8
8
|
import { LLMClient } from '@almadar/llm';
|
|
9
9
|
export { createCompactSystemPrompt, createSystemPrompt } from './prompts/index.js';
|
|
10
|
-
import { U as UserPreference, M as MemoryManager, G as GenerationSession } from './
|
|
11
|
-
export { C as CheckpointRecord,
|
|
12
|
-
import { S as SessionMetadata } from './firestore-checkpointer-
|
|
13
|
-
export {
|
|
10
|
+
import { U as UserPreference, M as MemoryManager, G as GenerationSession } from './interrupt-config-Bib_RCTB.js';
|
|
11
|
+
export { C as CheckpointRecord, l as ContextCompactionConfig, D as DEFAULT_COMPACTION_CONFIG, E as EVENT_BUDGETS, I as InterruptRecord, m as MemoryManagerOptions, n as MemoryOrbitalSchema, P as PatternAffinity, o as ProjectContext, S as SessionManager, a as SessionManagerOptions, b as Skill, c as SkillAgentOptions, d as SkillAgentResult, e as SkillLoader, f as SkillMeta, g as SkillRefLoader, T as ToolApprovalPreference, p as UserFeedback, h as createSkillAgent, q as createSummaryPrompt, s as estimateTokens, i as getBudgetWarningMessage, j as getEventBudget, k as getInterruptConfig, t as needsCompaction, r as resumeSkillAgent } from './interrupt-config-Bib_RCTB.js';
|
|
12
|
+
import { S as SessionMetadata } from './firestore-checkpointer-BkFR-sZM.js';
|
|
13
|
+
export { b as FirestoreCheckpointer, c as FirestoreCheckpointerOptions, F as FirestoreDb, d as FirestoreTimestamp, P as PersistenceMode, e as Session, a as SessionRecord } from './firestore-checkpointer-BkFR-sZM.js';
|
|
14
14
|
export { FirestoreSessionStore, FirestoreSessionStoreOptions, FirestoreStore, FirestoreStoreOptions, MemorySessionBackend } from './persistence/index.js';
|
|
15
15
|
export { RawAgentEvent, extractFileOperation, extractInterruptData, hasInterrupt, isFileOperation, isTodoUpdate, transformAgentEvent, transformAgentEventMulti } from './event-transformer/index.js';
|
|
16
16
|
import { EventEmitter } from 'events';
|
|
@@ -1092,4 +1092,766 @@ declare function withSync<T extends (...args: unknown[]) => unknown>(fn: T, sync
|
|
|
1092
1092
|
*/
|
|
1093
1093
|
declare function debounceSync(syncManager: StateSyncManager, delay?: number): (type: StateChangeType, threadId: string, payload: Record<string, unknown>) => void;
|
|
1094
1094
|
|
|
1095
|
-
|
|
1095
|
+
/**
|
|
1096
|
+
* Model Router Types
|
|
1097
|
+
*
|
|
1098
|
+
* @packageDocumentation
|
|
1099
|
+
*/
|
|
1100
|
+
type LLMProvider = 'anthropic' | 'openrouter' | 'openai' | 'deepseek' | 'kimi';
|
|
1101
|
+
interface RoutingDecision {
|
|
1102
|
+
/** Selected model identifier */
|
|
1103
|
+
model: string;
|
|
1104
|
+
/** Provider to use */
|
|
1105
|
+
provider: LLMProvider;
|
|
1106
|
+
/** Human-readable reasoning */
|
|
1107
|
+
reasoning: string;
|
|
1108
|
+
/** Estimated cost in USD */
|
|
1109
|
+
estimatedCost: number;
|
|
1110
|
+
/** Estimated latency in milliseconds */
|
|
1111
|
+
estimatedLatency: number;
|
|
1112
|
+
/** Fallback model if primary fails */
|
|
1113
|
+
fallback?: {
|
|
1114
|
+
model: string;
|
|
1115
|
+
provider: LLMProvider;
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
interface ProviderConfig {
|
|
1119
|
+
/** Provider identifier */
|
|
1120
|
+
name: LLMProvider;
|
|
1121
|
+
/** Model identifier */
|
|
1122
|
+
model: string;
|
|
1123
|
+
/** Cost per 1K input tokens */
|
|
1124
|
+
costPer1KInput: number;
|
|
1125
|
+
/** Cost per 1K output tokens */
|
|
1126
|
+
costPer1KOutput: number;
|
|
1127
|
+
/** Typical latency for simple request (ms) */
|
|
1128
|
+
baseLatency: number;
|
|
1129
|
+
/** Maximum orbitals this provider can handle reliably */
|
|
1130
|
+
maxOrbitals: number;
|
|
1131
|
+
/** Whether this provider supports fallback */
|
|
1132
|
+
supportsFallback: boolean;
|
|
1133
|
+
}
|
|
1134
|
+
type RoutingStrategy = 'cost-optimized' | 'latency-optimized' | 'quality-optimized';
|
|
1135
|
+
interface ModelRouterConfig {
|
|
1136
|
+
/** Primary provider configurations */
|
|
1137
|
+
providers: ProviderConfig[];
|
|
1138
|
+
/** Default routing strategy */
|
|
1139
|
+
defaultStrategy: RoutingStrategy;
|
|
1140
|
+
/** Enable automatic fallback on failure */
|
|
1141
|
+
enableFallback: boolean;
|
|
1142
|
+
/** Timeout threshold for fallback (ms) */
|
|
1143
|
+
fallbackTimeout: number;
|
|
1144
|
+
/** Enable A/B testing for routing decisions */
|
|
1145
|
+
enableABTesting: boolean;
|
|
1146
|
+
}
|
|
1147
|
+
interface OrbitalEstimation {
|
|
1148
|
+
/** Estimated number of orbitals */
|
|
1149
|
+
count: number;
|
|
1150
|
+
/** Confidence in estimation (0-1) */
|
|
1151
|
+
confidence: number;
|
|
1152
|
+
/** Detected domains/domains */
|
|
1153
|
+
domains: string[];
|
|
1154
|
+
/** Reasoning for estimation */
|
|
1155
|
+
reasoning: string;
|
|
1156
|
+
/** Optional metadata for debugging */
|
|
1157
|
+
_metadata?: {
|
|
1158
|
+
method?: 'llm' | 'heuristic';
|
|
1159
|
+
entities?: string[];
|
|
1160
|
+
complexityFactors?: string[];
|
|
1161
|
+
latencyMs?: number;
|
|
1162
|
+
tokensUsed?: number;
|
|
1163
|
+
model?: string;
|
|
1164
|
+
originalEstimate?: number;
|
|
1165
|
+
validationMethod?: string;
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Safety configuration for conservative routing
|
|
1170
|
+
*/
|
|
1171
|
+
interface SafetyConfig {
|
|
1172
|
+
/** Always round up estimates by this amount */
|
|
1173
|
+
conservativeBias: number;
|
|
1174
|
+
/** Route to Anthropic if confidence below this */
|
|
1175
|
+
minConfidenceThreshold: number;
|
|
1176
|
+
/** Validate estimations above this threshold */
|
|
1177
|
+
validationThreshold: number;
|
|
1178
|
+
/** Maximum orbitals allowed for Qwen */
|
|
1179
|
+
qwenMaxOrbitals: number;
|
|
1180
|
+
/** Keywords that force Anthropic routing */
|
|
1181
|
+
forceComplexKeywords: string[];
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Model Router with Safety Layer
|
|
1186
|
+
*
|
|
1187
|
+
* Routes generation requests to optimal LLM provider based on orbital count.
|
|
1188
|
+
* Implements Phase 1.1 of the enhancement plan.
|
|
1189
|
+
*
|
|
1190
|
+
* SAFETY FEATURES:
|
|
1191
|
+
* - Conservative bias: Always rounds up estimates
|
|
1192
|
+
* - Complex indicators: Definite keywords force Anthropic
|
|
1193
|
+
* - Confidence threshold: Low confidence → Anthropic
|
|
1194
|
+
* - Circuit breaker: Auto-fallback on repeated failures
|
|
1195
|
+
*
|
|
1196
|
+
* Test Results:
|
|
1197
|
+
* - 1 orbital: Qwen 100% quality, 68s (75% cheaper)
|
|
1198
|
+
* - 3-4 orbitals: Qwen 56/100, 169s (24% faster, same quality)
|
|
1199
|
+
* - 6+ orbitals: Qwen times out, Anthropic required
|
|
1200
|
+
*
|
|
1201
|
+
* @packageDocumentation
|
|
1202
|
+
*/
|
|
1203
|
+
|
|
1204
|
+
declare class ModelRouter {
|
|
1205
|
+
private config;
|
|
1206
|
+
private circuitBreaker;
|
|
1207
|
+
constructor(config?: Partial<ModelRouterConfig>);
|
|
1208
|
+
/**
|
|
1209
|
+
* Route request with FULL safety checks
|
|
1210
|
+
* This is the primary production routing method
|
|
1211
|
+
*/
|
|
1212
|
+
routeSafely(request: string, expectedOrbitals?: number, safetyConfig?: Partial<SafetyConfig>): Promise<RoutingDecision>;
|
|
1213
|
+
/**
|
|
1214
|
+
* Legacy method - kept for compatibility, but uses safety layer internally
|
|
1215
|
+
* @deprecated Use routeSafely() for production
|
|
1216
|
+
*/
|
|
1217
|
+
routeByOrbitalCount(request: string, expectedOrbitals?: number): Promise<RoutingDecision>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Route with pre-decomposition estimation
|
|
1220
|
+
*/
|
|
1221
|
+
routeWithDecomposition(request: string): Promise<RoutingDecision>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Generate with automatic fallback AND circuit breaker tracking
|
|
1224
|
+
*/
|
|
1225
|
+
generateWithFallback<T>(request: string, generateFn: (provider: LLMProvider, model: string) => Promise<T>, expectedOrbitals?: number): Promise<{
|
|
1226
|
+
result: T;
|
|
1227
|
+
routing: RoutingDecision;
|
|
1228
|
+
usedFallback: boolean;
|
|
1229
|
+
}>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Get cost comparison for debugging/optimization
|
|
1232
|
+
*/
|
|
1233
|
+
getCostComparison(request: string, expectedOrbitals?: number): Promise<{
|
|
1234
|
+
orbitalCount: number;
|
|
1235
|
+
recommended: RoutingDecision;
|
|
1236
|
+
alternatives: RoutingDecision[];
|
|
1237
|
+
savings: number;
|
|
1238
|
+
safetyChecks: string[];
|
|
1239
|
+
}>;
|
|
1240
|
+
/**
|
|
1241
|
+
* Get circuit breaker status for monitoring
|
|
1242
|
+
*/
|
|
1243
|
+
getCircuitBreakerStatus(): {
|
|
1244
|
+
failures: number;
|
|
1245
|
+
successes: number;
|
|
1246
|
+
isOpen: boolean;
|
|
1247
|
+
failureRate: number;
|
|
1248
|
+
};
|
|
1249
|
+
private estimateWithSafety;
|
|
1250
|
+
private createQwenDecision;
|
|
1251
|
+
private createAnthropicDecision;
|
|
1252
|
+
private executeWithTimeout;
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Factory function for creating router
|
|
1256
|
+
*/
|
|
1257
|
+
declare function createModelRouter(config?: Partial<ModelRouterConfig>): ModelRouter;
|
|
1258
|
+
declare function getModelRouter(): ModelRouter;
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* Orbital Count Estimator - LLM-Based
|
|
1262
|
+
*
|
|
1263
|
+
* Uses a fast, cheap LLM (GPT-4o-mini or GPT-5-mini) to estimate orbital complexity
|
|
1264
|
+
* from natural language requests. Much more accurate and scalable than keyword matching.
|
|
1265
|
+
*
|
|
1266
|
+
* Cost: ~$0.0001 per estimate (~500 tokens total)
|
|
1267
|
+
* Latency: ~100-200ms
|
|
1268
|
+
*
|
|
1269
|
+
* @packageDocumentation
|
|
1270
|
+
*/
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* Estimate orbital count using LLM (recommended for production)
|
|
1274
|
+
*/
|
|
1275
|
+
declare function estimateOrbitalCountLLM(request: string, options?: {
|
|
1276
|
+
model?: string;
|
|
1277
|
+
timeoutMs?: number;
|
|
1278
|
+
}): Promise<OrbitalEstimation>;
|
|
1279
|
+
/**
|
|
1280
|
+
* Heuristic estimation (no LLM required) - used as fallback
|
|
1281
|
+
* Less accurate but works offline and without API keys
|
|
1282
|
+
*/
|
|
1283
|
+
declare function estimateOrbitalCountHeuristic(request: string): OrbitalEstimation;
|
|
1284
|
+
/**
|
|
1285
|
+
* Primary estimation function - uses LLM by default, falls back to heuristic
|
|
1286
|
+
*
|
|
1287
|
+
* NOTE: LLM estimation is strongly recommended for production use.
|
|
1288
|
+
* Heuristic estimation significantly underestimates complex apps (see eval results).
|
|
1289
|
+
*/
|
|
1290
|
+
declare function estimateOrbitalCount(request: string, options?: {
|
|
1291
|
+
useLLM?: boolean;
|
|
1292
|
+
model?: string;
|
|
1293
|
+
timeoutMs?: number;
|
|
1294
|
+
}): Promise<OrbitalEstimation>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Quick synchronous estimate (always uses heuristic)
|
|
1297
|
+
*/
|
|
1298
|
+
declare function quickEstimate(request: string): number;
|
|
1299
|
+
/**
|
|
1300
|
+
* Batch estimation for multiple requests (uses LLM with batching)
|
|
1301
|
+
*/
|
|
1302
|
+
declare function estimateOrbitalCountBatch(requests: string[], options?: {
|
|
1303
|
+
model?: string;
|
|
1304
|
+
}): Promise<OrbitalEstimation[]>;
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* Model Router Safety Layer
|
|
1308
|
+
*
|
|
1309
|
+
* Prevents catastrophic underestimation that leads to Qwen timeouts.
|
|
1310
|
+
* Uses multiple safety mechanisms:
|
|
1311
|
+
* 1. Conservative bias (round up, not down)
|
|
1312
|
+
* 2. Complexity indicators (definite "complex" signals)
|
|
1313
|
+
* 3. Confidence threshold (low confidence → Anthropic)
|
|
1314
|
+
* 4. Validation layer (second opinion for borderline cases)
|
|
1315
|
+
* 5. Circuit breaker (auto-fallback on any failure)
|
|
1316
|
+
*
|
|
1317
|
+
* @packageDocumentation
|
|
1318
|
+
*/
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Check if request contains definite complex indicators
|
|
1322
|
+
*/
|
|
1323
|
+
declare function hasDefiniteComplexIndicators(request: string): boolean;
|
|
1324
|
+
/**
|
|
1325
|
+
* Apply conservative bias to estimation
|
|
1326
|
+
*/
|
|
1327
|
+
declare function applyConservativeBias(estimation: OrbitalEstimation, bias?: number): OrbitalEstimation;
|
|
1328
|
+
/**
|
|
1329
|
+
* Make final routing decision with all safety checks
|
|
1330
|
+
*/
|
|
1331
|
+
declare function makeSafeRoutingDecision(estimation: OrbitalEstimation, request: string, config?: Partial<SafetyConfig>): {
|
|
1332
|
+
finalCount: number;
|
|
1333
|
+
useAnthropic: boolean;
|
|
1334
|
+
reason: string;
|
|
1335
|
+
safetyChecks: string[];
|
|
1336
|
+
};
|
|
1337
|
+
/**
|
|
1338
|
+
* Complete safe estimation pipeline
|
|
1339
|
+
*/
|
|
1340
|
+
declare function safeEstimate(request: string, options: {
|
|
1341
|
+
estimateFn: (request: string) => Promise<OrbitalEstimation>;
|
|
1342
|
+
validateFn?: (est: OrbitalEstimation) => Promise<OrbitalEstimation>;
|
|
1343
|
+
config?: Partial<SafetyConfig>;
|
|
1344
|
+
}): Promise<{
|
|
1345
|
+
estimation: OrbitalEstimation;
|
|
1346
|
+
routing: {
|
|
1347
|
+
useAnthropic: boolean;
|
|
1348
|
+
reason: string;
|
|
1349
|
+
safetyChecks: string[];
|
|
1350
|
+
};
|
|
1351
|
+
}>;
|
|
1352
|
+
/**
|
|
1353
|
+
* Circuit breaker for Qwen calls
|
|
1354
|
+
* Monitors failure rate and forces Anthropic if too many failures
|
|
1355
|
+
*/
|
|
1356
|
+
declare class QwenCircuitBreaker {
|
|
1357
|
+
private failureThreshold;
|
|
1358
|
+
private resetTimeoutMs;
|
|
1359
|
+
private failures;
|
|
1360
|
+
private successes;
|
|
1361
|
+
private lastFailure;
|
|
1362
|
+
constructor(failureThreshold?: number, resetTimeoutMs?: number);
|
|
1363
|
+
recordSuccess(): void;
|
|
1364
|
+
recordFailure(): void;
|
|
1365
|
+
isOpen(): boolean;
|
|
1366
|
+
getStatus(): {
|
|
1367
|
+
failures: number;
|
|
1368
|
+
successes: number;
|
|
1369
|
+
isOpen: boolean;
|
|
1370
|
+
failureRate: number;
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
declare function getCircuitBreaker(): QwenCircuitBreaker;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* MCP (Model Context Protocol) Types
|
|
1377
|
+
*
|
|
1378
|
+
* Standard types for the Model Context Protocol.
|
|
1379
|
+
*
|
|
1380
|
+
* @packageDocumentation
|
|
1381
|
+
*/
|
|
1382
|
+
interface ToolDefinition {
|
|
1383
|
+
/** Tool name (must be unique) */
|
|
1384
|
+
name: string;
|
|
1385
|
+
/** Human-readable description */
|
|
1386
|
+
description: string;
|
|
1387
|
+
/** JSON Schema for tool input */
|
|
1388
|
+
inputSchema: {
|
|
1389
|
+
type: 'object';
|
|
1390
|
+
properties: Record<string, unknown>;
|
|
1391
|
+
required?: string[];
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
interface ToolCallRequest {
|
|
1395
|
+
type: 'tool_call';
|
|
1396
|
+
name: string;
|
|
1397
|
+
input: unknown;
|
|
1398
|
+
}
|
|
1399
|
+
interface ToolCallResponse {
|
|
1400
|
+
success: boolean;
|
|
1401
|
+
data?: unknown;
|
|
1402
|
+
error?: string;
|
|
1403
|
+
}
|
|
1404
|
+
interface ResourceDefinition {
|
|
1405
|
+
/** Resource URI (e.g., "schema://patterns") */
|
|
1406
|
+
uri: string;
|
|
1407
|
+
/** Human-readable name */
|
|
1408
|
+
name: string;
|
|
1409
|
+
/** MIME type of resource content */
|
|
1410
|
+
mimeType: string;
|
|
1411
|
+
/** Description of the resource */
|
|
1412
|
+
description: string;
|
|
1413
|
+
}
|
|
1414
|
+
interface ResourceRequest {
|
|
1415
|
+
type: 'resource_request';
|
|
1416
|
+
uri: string;
|
|
1417
|
+
}
|
|
1418
|
+
interface ResourceResponse {
|
|
1419
|
+
success: boolean;
|
|
1420
|
+
data?: unknown;
|
|
1421
|
+
error?: string;
|
|
1422
|
+
}
|
|
1423
|
+
interface MCPClientConfig {
|
|
1424
|
+
/** Server URL */
|
|
1425
|
+
serverUrl: string;
|
|
1426
|
+
/** Auth token if required */
|
|
1427
|
+
authToken?: string;
|
|
1428
|
+
/** Request timeout in ms */
|
|
1429
|
+
timeoutMs?: number;
|
|
1430
|
+
}
|
|
1431
|
+
interface MCPDiscoveryRequest {
|
|
1432
|
+
type: 'discovery';
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* MCP (Model Context Protocol) Server - Phase 3.1
|
|
1437
|
+
*
|
|
1438
|
+
* Exposes Almadar tools via the Model Context Protocol standard.
|
|
1439
|
+
* Allows external agents (Claude Desktop, etc.) to use our tools.
|
|
1440
|
+
*
|
|
1441
|
+
* @packageDocumentation
|
|
1442
|
+
*/
|
|
1443
|
+
|
|
1444
|
+
interface MCPServerConfig {
|
|
1445
|
+
name: string;
|
|
1446
|
+
version: string;
|
|
1447
|
+
port?: number;
|
|
1448
|
+
enableCors?: boolean;
|
|
1449
|
+
authToken?: string;
|
|
1450
|
+
}
|
|
1451
|
+
interface MCPDiscoveryResponse {
|
|
1452
|
+
name: string;
|
|
1453
|
+
version: string;
|
|
1454
|
+
tools: ToolDefinition[];
|
|
1455
|
+
resources: ResourceDefinition[];
|
|
1456
|
+
}
|
|
1457
|
+
declare class MCPToolRegistry {
|
|
1458
|
+
private tools;
|
|
1459
|
+
private handlers;
|
|
1460
|
+
registerTool<TInput = unknown, TOutput = unknown>(definition: ToolDefinition, handler: (input: TInput) => Promise<TOutput>): void;
|
|
1461
|
+
callTool(name: string, input: unknown): Promise<ToolCallResponse>;
|
|
1462
|
+
listTools(): ToolDefinition[];
|
|
1463
|
+
hasTool(name: string): boolean;
|
|
1464
|
+
}
|
|
1465
|
+
declare class MCPResourceRegistry {
|
|
1466
|
+
private resources;
|
|
1467
|
+
private handlers;
|
|
1468
|
+
registerResource(definition: ResourceDefinition, handler: () => Promise<unknown>): void;
|
|
1469
|
+
getResource(uri: string): Promise<ResourceResponse>;
|
|
1470
|
+
listResources(): ResourceDefinition[];
|
|
1471
|
+
}
|
|
1472
|
+
declare class MCPServer {
|
|
1473
|
+
private config;
|
|
1474
|
+
private toolRegistry;
|
|
1475
|
+
private resourceRegistry;
|
|
1476
|
+
constructor(config: MCPServerConfig);
|
|
1477
|
+
/**
|
|
1478
|
+
* Register an orbital generation tool
|
|
1479
|
+
*/
|
|
1480
|
+
registerOrbitalTools(): void;
|
|
1481
|
+
/**
|
|
1482
|
+
* Register MCP resources
|
|
1483
|
+
*/
|
|
1484
|
+
registerResources(): void;
|
|
1485
|
+
/**
|
|
1486
|
+
* Handle discovery request (list all tools and resources)
|
|
1487
|
+
*/
|
|
1488
|
+
handleDiscovery(): MCPDiscoveryResponse;
|
|
1489
|
+
/**
|
|
1490
|
+
* Handle tool call
|
|
1491
|
+
*/
|
|
1492
|
+
handleToolCall(request: ToolCallRequest): Promise<ToolCallResponse>;
|
|
1493
|
+
/**
|
|
1494
|
+
* Handle resource request
|
|
1495
|
+
*/
|
|
1496
|
+
handleResourceRequest(request: ResourceRequest): Promise<ResourceResponse>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Get tool registry for external access
|
|
1499
|
+
*/
|
|
1500
|
+
getToolRegistry(): MCPToolRegistry;
|
|
1501
|
+
/**
|
|
1502
|
+
* Get resource registry for external access
|
|
1503
|
+
*/
|
|
1504
|
+
getResourceRegistry(): MCPResourceRegistry;
|
|
1505
|
+
/**
|
|
1506
|
+
* Create HTTP request handler for Express/Fastify
|
|
1507
|
+
*/
|
|
1508
|
+
createRequestHandler(): (request: {
|
|
1509
|
+
method: string;
|
|
1510
|
+
body: unknown;
|
|
1511
|
+
}) => Promise<unknown>;
|
|
1512
|
+
}
|
|
1513
|
+
declare function createMCPServer(config: MCPServerConfig): MCPServer;
|
|
1514
|
+
/**
|
|
1515
|
+
* Create and configure a standard Almadar MCP server
|
|
1516
|
+
*/
|
|
1517
|
+
declare function createAlmadarMCPServer(options?: Partial<MCPServerConfig>): MCPServer;
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* MCP (Model Context Protocol) Client - Phase 3.1
|
|
1521
|
+
*
|
|
1522
|
+
* Client for calling external MCP servers.
|
|
1523
|
+
* Allows our agent to use tools from other MCP-compliant servers.
|
|
1524
|
+
*
|
|
1525
|
+
* @packageDocumentation
|
|
1526
|
+
*/
|
|
1527
|
+
|
|
1528
|
+
declare class MCPClient {
|
|
1529
|
+
private config;
|
|
1530
|
+
private cachedTools;
|
|
1531
|
+
private cachedResources;
|
|
1532
|
+
private cacheExpiry;
|
|
1533
|
+
constructor(config: MCPClientConfig);
|
|
1534
|
+
/**
|
|
1535
|
+
* Discover available tools and resources from server
|
|
1536
|
+
*/
|
|
1537
|
+
discover(): Promise<{
|
|
1538
|
+
tools: ToolDefinition[];
|
|
1539
|
+
resources: ResourceDefinition[];
|
|
1540
|
+
name: string;
|
|
1541
|
+
version: string;
|
|
1542
|
+
}>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Call a tool on the MCP server
|
|
1545
|
+
*/
|
|
1546
|
+
callTool(name: string, input: unknown): Promise<ToolCallResponse>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Get a resource from the MCP server
|
|
1549
|
+
*/
|
|
1550
|
+
getResource(uri: string): Promise<ResourceResponse>;
|
|
1551
|
+
/**
|
|
1552
|
+
* List available tools (from cache or discovery)
|
|
1553
|
+
*/
|
|
1554
|
+
listTools(): Promise<ToolDefinition[]>;
|
|
1555
|
+
/**
|
|
1556
|
+
* List available resources (from cache or discovery)
|
|
1557
|
+
*/
|
|
1558
|
+
listResources(): Promise<ResourceDefinition[]>;
|
|
1559
|
+
/**
|
|
1560
|
+
* Check if a tool is available
|
|
1561
|
+
*/
|
|
1562
|
+
hasTool(name: string): Promise<boolean>;
|
|
1563
|
+
/**
|
|
1564
|
+
* Get tool definition
|
|
1565
|
+
*/
|
|
1566
|
+
getTool(name: string): Promise<ToolDefinition | null>;
|
|
1567
|
+
/**
|
|
1568
|
+
* Clear cache and force re-discovery
|
|
1569
|
+
*/
|
|
1570
|
+
clearCache(): void;
|
|
1571
|
+
private sendRequest;
|
|
1572
|
+
}
|
|
1573
|
+
interface RegisteredMCPServer {
|
|
1574
|
+
name: string;
|
|
1575
|
+
client: MCPClient;
|
|
1576
|
+
description?: string;
|
|
1577
|
+
}
|
|
1578
|
+
declare class MCPClientManager {
|
|
1579
|
+
private servers;
|
|
1580
|
+
/**
|
|
1581
|
+
* Register an MCP server
|
|
1582
|
+
*/
|
|
1583
|
+
registerServer(name: string, config: MCPClientConfig, description?: string): void;
|
|
1584
|
+
/**
|
|
1585
|
+
* Get client for a specific server
|
|
1586
|
+
*/
|
|
1587
|
+
getClient(name: string): MCPClient | null;
|
|
1588
|
+
/**
|
|
1589
|
+
* Call a tool on a specific server
|
|
1590
|
+
*/
|
|
1591
|
+
callTool(serverName: string, toolName: string, input: unknown): Promise<ToolCallResponse>;
|
|
1592
|
+
/**
|
|
1593
|
+
* Discover all registered servers
|
|
1594
|
+
*/
|
|
1595
|
+
discoverAll(): Promise<Record<string, {
|
|
1596
|
+
tools: ToolDefinition[];
|
|
1597
|
+
resources: ResourceDefinition[];
|
|
1598
|
+
}>>;
|
|
1599
|
+
/**
|
|
1600
|
+
* List all registered servers
|
|
1601
|
+
*/
|
|
1602
|
+
listServers(): Array<{
|
|
1603
|
+
name: string;
|
|
1604
|
+
description?: string;
|
|
1605
|
+
}>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Unregister a server
|
|
1608
|
+
*/
|
|
1609
|
+
unregisterServer(name: string): void;
|
|
1610
|
+
/**
|
|
1611
|
+
* Clear all caches
|
|
1612
|
+
*/
|
|
1613
|
+
clearAllCaches(): void;
|
|
1614
|
+
}
|
|
1615
|
+
declare function createMCPClient(config: MCPClientConfig): MCPClient;
|
|
1616
|
+
declare function createMCPClientManager(): MCPClientManager;
|
|
1617
|
+
/**
|
|
1618
|
+
* Create a pre-configured client manager with common MCP servers
|
|
1619
|
+
*/
|
|
1620
|
+
declare function createDefaultMCPClientManager(): MCPClientManager;
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* Online Evaluations - Phase 3.2a: Simple Sampling
|
|
1624
|
+
*
|
|
1625
|
+
* 10% traffic sampling with async validation and basic alerting.
|
|
1626
|
+
* Non-blocking - runs in background without affecting user response.
|
|
1627
|
+
*
|
|
1628
|
+
* @packageDocumentation
|
|
1629
|
+
*/
|
|
1630
|
+
|
|
1631
|
+
interface SamplingConfig {
|
|
1632
|
+
/** Sampling rate (0.0 - 1.0) */
|
|
1633
|
+
sampleRate: number;
|
|
1634
|
+
/** Async queue size */
|
|
1635
|
+
maxQueueSize: number;
|
|
1636
|
+
/** Validation timeout */
|
|
1637
|
+
validationTimeoutMs: number;
|
|
1638
|
+
/** Alert threshold for error rate */
|
|
1639
|
+
errorRateThreshold: number;
|
|
1640
|
+
/** Alert window in ms */
|
|
1641
|
+
alertWindowMs: number;
|
|
1642
|
+
}
|
|
1643
|
+
interface EvalSample {
|
|
1644
|
+
sampleId: string;
|
|
1645
|
+
timestamp: number;
|
|
1646
|
+
request: {
|
|
1647
|
+
prompt: string;
|
|
1648
|
+
provider: string;
|
|
1649
|
+
model: string;
|
|
1650
|
+
};
|
|
1651
|
+
result: {
|
|
1652
|
+
success: boolean;
|
|
1653
|
+
schema?: unknown;
|
|
1654
|
+
error?: string;
|
|
1655
|
+
latencyMs: number;
|
|
1656
|
+
};
|
|
1657
|
+
validation?: {
|
|
1658
|
+
automatedScore: number;
|
|
1659
|
+
syntaxErrors: number;
|
|
1660
|
+
structureWarnings: number;
|
|
1661
|
+
timestamp: number;
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
interface ErrorAlert {
|
|
1665
|
+
alertId: string;
|
|
1666
|
+
timestamp: number;
|
|
1667
|
+
errorRate: number;
|
|
1668
|
+
threshold: number;
|
|
1669
|
+
windowStart: number;
|
|
1670
|
+
sampleCount: number;
|
|
1671
|
+
errorCount: number;
|
|
1672
|
+
}
|
|
1673
|
+
interface SamplingStats {
|
|
1674
|
+
totalSampled: number;
|
|
1675
|
+
totalValidated: number;
|
|
1676
|
+
averageScore: number;
|
|
1677
|
+
currentErrorRate: number;
|
|
1678
|
+
queueSize: number;
|
|
1679
|
+
isHealthy: boolean;
|
|
1680
|
+
}
|
|
1681
|
+
declare class OnlineEvalSampler extends EventEmitter {
|
|
1682
|
+
private config;
|
|
1683
|
+
private queue;
|
|
1684
|
+
private samples;
|
|
1685
|
+
private errorWindow;
|
|
1686
|
+
private isProcessing;
|
|
1687
|
+
constructor(config?: Partial<SamplingConfig>);
|
|
1688
|
+
/**
|
|
1689
|
+
* Check if a request should be sampled
|
|
1690
|
+
* Uses hash-based sampling for consistency
|
|
1691
|
+
*/
|
|
1692
|
+
shouldSample(requestId: string): boolean;
|
|
1693
|
+
/**
|
|
1694
|
+
* Add a sample to the queue for async validation
|
|
1695
|
+
*/
|
|
1696
|
+
sample(requestId: string, request: {
|
|
1697
|
+
prompt: string;
|
|
1698
|
+
provider: string;
|
|
1699
|
+
model: string;
|
|
1700
|
+
}, result: {
|
|
1701
|
+
success: boolean;
|
|
1702
|
+
schema?: unknown;
|
|
1703
|
+
error?: string;
|
|
1704
|
+
latencyMs: number;
|
|
1705
|
+
}): Promise<void>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Pull samples for manual review
|
|
1708
|
+
*/
|
|
1709
|
+
pullSamples(options?: {
|
|
1710
|
+
date?: Date;
|
|
1711
|
+
limit?: number;
|
|
1712
|
+
minScore?: number;
|
|
1713
|
+
}): Promise<EvalSample[]>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Get current stats
|
|
1716
|
+
*/
|
|
1717
|
+
getStats(): SamplingStats;
|
|
1718
|
+
/**
|
|
1719
|
+
* Stop the processor
|
|
1720
|
+
*/
|
|
1721
|
+
stop(): void;
|
|
1722
|
+
private startProcessor;
|
|
1723
|
+
private validateSample;
|
|
1724
|
+
private runAutomatedValidation;
|
|
1725
|
+
private trackError;
|
|
1726
|
+
private calculateErrorRate;
|
|
1727
|
+
}
|
|
1728
|
+
interface ReviewOptions {
|
|
1729
|
+
date?: string;
|
|
1730
|
+
limit?: number;
|
|
1731
|
+
minScore?: number;
|
|
1732
|
+
format?: 'json' | 'table';
|
|
1733
|
+
}
|
|
1734
|
+
declare function reviewSamples(sampler: OnlineEvalSampler, options?: ReviewOptions): Promise<void>;
|
|
1735
|
+
declare function createOnlineEvalSampler(config?: Partial<SamplingConfig>): OnlineEvalSampler;
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Tool Composition & Chaining - Phase 3.3
|
|
1739
|
+
*
|
|
1740
|
+
* Composable tool workflows with parallel execution, error handling,
|
|
1741
|
+
* and conditional branching.
|
|
1742
|
+
*
|
|
1743
|
+
* @packageDocumentation
|
|
1744
|
+
*/
|
|
1745
|
+
type ToolStepStatus = 'pending' | 'running' | 'success' | 'error' | 'skipped';
|
|
1746
|
+
interface ToolStep {
|
|
1747
|
+
id: string;
|
|
1748
|
+
name: string;
|
|
1749
|
+
tool: string;
|
|
1750
|
+
input: Record<string, unknown> | ((context: WorkflowContext) => Record<string, unknown>);
|
|
1751
|
+
condition?: (context: WorkflowContext) => boolean;
|
|
1752
|
+
dependsOn?: string[];
|
|
1753
|
+
status: ToolStepStatus;
|
|
1754
|
+
output?: unknown;
|
|
1755
|
+
error?: string;
|
|
1756
|
+
startTime?: number;
|
|
1757
|
+
endTime?: number;
|
|
1758
|
+
}
|
|
1759
|
+
interface WorkflowContext {
|
|
1760
|
+
workflowId: string;
|
|
1761
|
+
inputs: Record<string, unknown>;
|
|
1762
|
+
outputs: Record<string, unknown>;
|
|
1763
|
+
stepResults: Map<string, {
|
|
1764
|
+
success: boolean;
|
|
1765
|
+
output?: unknown;
|
|
1766
|
+
error?: string;
|
|
1767
|
+
}>;
|
|
1768
|
+
metadata: {
|
|
1769
|
+
startTime: number;
|
|
1770
|
+
stepsCompleted: number;
|
|
1771
|
+
stepsFailed: number;
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
interface WorkflowDefinition {
|
|
1775
|
+
name: string;
|
|
1776
|
+
description: string;
|
|
1777
|
+
inputs: Record<string, {
|
|
1778
|
+
type: string;
|
|
1779
|
+
required: boolean;
|
|
1780
|
+
default?: unknown;
|
|
1781
|
+
}>;
|
|
1782
|
+
steps: ToolStep[];
|
|
1783
|
+
onError?: 'stop' | 'continue' | 'retry';
|
|
1784
|
+
maxRetries?: number;
|
|
1785
|
+
}
|
|
1786
|
+
interface WorkflowExecutionResult {
|
|
1787
|
+
success: boolean;
|
|
1788
|
+
workflowId: string;
|
|
1789
|
+
context: WorkflowContext;
|
|
1790
|
+
steps: ToolStep[];
|
|
1791
|
+
durationMs: number;
|
|
1792
|
+
error?: string;
|
|
1793
|
+
}
|
|
1794
|
+
interface ParallelExecutionResult {
|
|
1795
|
+
stepId: string;
|
|
1796
|
+
success: boolean;
|
|
1797
|
+
output?: unknown;
|
|
1798
|
+
error?: string;
|
|
1799
|
+
durationMs: number;
|
|
1800
|
+
}
|
|
1801
|
+
interface ToolExecutor {
|
|
1802
|
+
execute(tool: string, input: Record<string, unknown>): Promise<unknown>;
|
|
1803
|
+
}
|
|
1804
|
+
declare class WorkflowEngine {
|
|
1805
|
+
private executor;
|
|
1806
|
+
private workflows;
|
|
1807
|
+
constructor(executor: ToolExecutor);
|
|
1808
|
+
/**
|
|
1809
|
+
* Register a workflow definition
|
|
1810
|
+
*/
|
|
1811
|
+
registerWorkflow(definition: WorkflowDefinition): void;
|
|
1812
|
+
/**
|
|
1813
|
+
* Execute a workflow by name
|
|
1814
|
+
*/
|
|
1815
|
+
executeWorkflow(workflowName: string, inputs: Record<string, unknown>): Promise<WorkflowExecutionResult>;
|
|
1816
|
+
/**
|
|
1817
|
+
* Execute a workflow definition directly
|
|
1818
|
+
*/
|
|
1819
|
+
runWorkflow(definition: WorkflowDefinition, inputs: Record<string, unknown>): Promise<WorkflowExecutionResult>;
|
|
1820
|
+
/**
|
|
1821
|
+
* Execute independent steps in parallel
|
|
1822
|
+
*/
|
|
1823
|
+
executeParallel(steps: Array<{
|
|
1824
|
+
id: string;
|
|
1825
|
+
tool: string;
|
|
1826
|
+
input: Record<string, unknown>;
|
|
1827
|
+
}>, context: WorkflowContext): Promise<ParallelExecutionResult[]>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Create a workflow builder for fluent API
|
|
1830
|
+
*/
|
|
1831
|
+
createWorkflow(name: string, description: string): WorkflowBuilder;
|
|
1832
|
+
private executeStep;
|
|
1833
|
+
private resolveDependencies;
|
|
1834
|
+
}
|
|
1835
|
+
declare class WorkflowBuilder {
|
|
1836
|
+
private engine;
|
|
1837
|
+
private definition;
|
|
1838
|
+
constructor(engine: WorkflowEngine, name: string, description: string);
|
|
1839
|
+
input(name: string, type: string, required?: boolean, defaultValue?: unknown): this;
|
|
1840
|
+
step(id: string, tool: string, input: Record<string, unknown> | ((context: WorkflowContext) => Record<string, unknown>), options?: {
|
|
1841
|
+
dependsOn?: string[];
|
|
1842
|
+
condition?: (context: WorkflowContext) => boolean;
|
|
1843
|
+
}): this;
|
|
1844
|
+
parallel(steps: Array<{
|
|
1845
|
+
id: string;
|
|
1846
|
+
tool: string;
|
|
1847
|
+
input: Record<string, unknown>;
|
|
1848
|
+
}>): this;
|
|
1849
|
+
onError(policy: 'stop' | 'continue' | 'retry'): this;
|
|
1850
|
+
retry(maxRetries: number): this;
|
|
1851
|
+
build(): WorkflowDefinition;
|
|
1852
|
+
execute(inputs: Record<string, unknown>): Promise<WorkflowExecutionResult>;
|
|
1853
|
+
}
|
|
1854
|
+
declare function createSchemaGenerationWorkflow(engine: WorkflowEngine): WorkflowDefinition;
|
|
1855
|
+
declare function createWorkflowEngine(executor: ToolExecutor): WorkflowEngine;
|
|
1856
|
+
|
|
1857
|
+
export { type AccessCheckResult, AgenticSearchEngine, type AgenticSearchParams, type AgenticSearchResponse, type ConflictResolution, type DeepAgentCompleteEvent, type DeepAgentErrorEvent, type DeepAgentEvent, type DeepAgentExecutionEvent, type DeepAgentSchemaEvent, type DeepAgentStartEvent, type ErrorAlert, type EvalSample, type GenerationMetrics, GenerationSession, type HealthCheckResult, type InferredPreference, type LLMProvider, MCPClient, type MCPClientConfig, MCPClientManager, type MCPDiscoveryRequest, type MCPDiscoveryResponse, MCPResourceRegistry, MCPServer, type MCPServerConfig, MCPToolRegistry, MemoryManager, MetricsCollector, type MetricsSummary, ModelRouter, type ModelRouterConfig, MultiUserManager, ObservabilityCollector, type ObservableEvent, type ObservableEventType, OnlineEvalSampler, type CombinerOptions as OrbitalCombinerOptions, type CombinerResult as OrbitalCombinerResult, type OrbitalEstimation, type OrbitalSchemaValidationResult, type ParallelExecutionResult, type PerformanceSnapshot, type PreferenceAnalysis, PreferenceLearner, type PreferenceLearnerOptions, type ProviderConfig, QwenCircuitBreaker, type RegisteredMCPServer, type ResourceDefinition, type ResourceRequest, type ResourceResponse, type ReviewOptions, type RoutingDecision, type RoutingStrategy, type SamplingConfig, type SamplingStats, type ScopedSessionMetadata, type SearchResult, type SearchStrategy, SessionMetadata, type SessionTelemetry, type StateChangeEvent, type StateChangeType, type StateSyncConfig, StateSyncManager, type StateSyncSnapshot, SubAgent, type ToolCallRequest, type ToolCallResponse, type ToolDefinition, type ToolExecutor, type ToolStep, type ToolStepStatus, type UserContext, UserPreference, type UserSessionStats, type VersionVector, WorkflowBuilder, type WorkflowContext, type WorkflowDefinition, WorkflowEngine, type WorkflowExecutionResult, analyzeFailures, applyConservativeBias, combineOrbitals, combineOrbitalsToSchema, createAgenticSearchEngine, createAlmadarMCPServer, createDefaultMCPClientManager, createErrorFixerSubagent, createMCPClient, createMCPClientManager, createMCPServer, createModelRouter, createOnlineEvalSampler, createPreferenceLearner, createSchemaGenerationWorkflow, createSchemaGeneratorSubagent, createSubagentConfigs, createSubagents, createTestAnalyzerSubagent, createUserContext, createWorkflowEngine, debounceSync, endObservabilitySession, estimateCacheSavings, estimateCombineComplexity, estimateOrbitalCount, estimateOrbitalCountBatch, estimateOrbitalCountHeuristic, estimateOrbitalCountLLM, formatSummary, generateFullOrbital, getCircuitBreaker, getModelRouter, getMultiUserManager, getObservabilityCollector, getPerformanceSnapshot, getStateSyncManager, hasDefiniteComplexIndicators, isAdmin, isCompleteEvent, isErrorEvent, isExecutionEvent, isSchemaEvent, isStartEvent, makeSafeRoutingDecision, parseDeepAgentEvent, quickEstimate, recordEvent, requireOwnership, resetMultiUserManager, resetObservabilityCollector, resetStateSyncManager, reviewSamples, safeEstimate, startObservabilitySession, withSync };
|