@agentfield/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,823 @@
1
+ import express from 'express';
2
+ import http from 'node:http';
3
+ import { ZodSchema } from 'zod';
4
+
5
+ interface AIRequestOptions {
6
+ system?: string;
7
+ schema?: ZodSchema<any>;
8
+ model?: string;
9
+ temperature?: number;
10
+ maxTokens?: number;
11
+ provider?: AIConfig['provider'];
12
+ }
13
+ type AIStream = AsyncIterable<string>;
14
+ interface AIEmbeddingOptions {
15
+ model?: string;
16
+ provider?: AIConfig['provider'];
17
+ }
18
+ declare class AIClient {
19
+ private readonly config;
20
+ private rateLimiter?;
21
+ constructor(config?: AIConfig);
22
+ generate<T = any>(prompt: string, options?: AIRequestOptions): Promise<T | string>;
23
+ stream(prompt: string, options?: AIRequestOptions): Promise<AIStream>;
24
+ embed(value: string, options?: AIEmbeddingOptions): Promise<number[]>;
25
+ embedMany(values: string[], options?: AIEmbeddingOptions): Promise<number[][]>;
26
+ private buildModel;
27
+ private buildEmbeddingModel;
28
+ private getRateLimiter;
29
+ private withRateLimitRetry;
30
+ }
31
+
32
+ interface MemoryRequestMetadata {
33
+ workflowId?: string;
34
+ sessionId?: string;
35
+ actorId?: string;
36
+ runId?: string;
37
+ executionId?: string;
38
+ parentExecutionId?: string;
39
+ callerDid?: string;
40
+ targetDid?: string;
41
+ agentNodeDid?: string;
42
+ agentNodeId?: string;
43
+ }
44
+ interface MemoryRequestOptions {
45
+ scope?: MemoryScope;
46
+ scopeId?: string;
47
+ metadata?: MemoryRequestMetadata;
48
+ headers?: Record<string, string | number | boolean | undefined>;
49
+ }
50
+ interface VectorSearchOptions extends MemoryRequestOptions {
51
+ topK?: number;
52
+ filters?: Record<string, any>;
53
+ }
54
+ interface VectorSearchResult {
55
+ key: string;
56
+ scope: string;
57
+ scopeId: string;
58
+ score: number;
59
+ metadata?: Record<string, any>;
60
+ }
61
+ declare class MemoryClient {
62
+ private readonly http;
63
+ private readonly defaultHeaders;
64
+ constructor(baseUrl: string, defaultHeaders?: Record<string, string | number | boolean | undefined>);
65
+ set(key: string, data: any, options?: MemoryRequestOptions): Promise<void>;
66
+ get<T = any>(key: string, options?: MemoryRequestOptions): Promise<T | undefined>;
67
+ delete(key: string, options?: MemoryRequestOptions): Promise<void>;
68
+ listKeys(scope: MemoryScope, options?: MemoryRequestOptions): Promise<string[]>;
69
+ exists(key: string, options?: MemoryRequestOptions): Promise<boolean>;
70
+ setVector(key: string, embedding: number[], metadata?: any, options?: MemoryRequestOptions): Promise<void>;
71
+ deleteVector(key: string, options?: MemoryRequestOptions): Promise<void>;
72
+ searchVector(queryEmbedding: number[], options?: VectorSearchOptions): Promise<VectorSearchResult[]>;
73
+ private buildHeaders;
74
+ private scopeToHeader;
75
+ private resolveScopeId;
76
+ private sanitizeHeaders;
77
+ }
78
+
79
+ type MemoryEventHandler = (event: MemoryChangeEvent) => Promise<void> | void;
80
+ declare class MemoryEventClient {
81
+ private readonly url;
82
+ private ws?;
83
+ private handlers;
84
+ private reconnectDelay;
85
+ private closed;
86
+ private readonly headers;
87
+ constructor(baseUrl: string, headers?: Record<string, string | number | boolean | undefined>);
88
+ start(): void;
89
+ onEvent(handler: MemoryEventHandler): void;
90
+ stop(): void;
91
+ private connect;
92
+ private scheduleReconnect;
93
+ private buildForwardHeaders;
94
+ }
95
+
96
+ interface MemoryChangeEvent {
97
+ key: string;
98
+ data: any;
99
+ scope: MemoryScope;
100
+ scopeId: string;
101
+ timestamp: string | Date;
102
+ agentId: string;
103
+ }
104
+ type MemoryWatchHandler = (event: MemoryChangeEvent) => Promise<void> | void;
105
+ declare class MemoryInterface {
106
+ private readonly client;
107
+ private readonly eventClient?;
108
+ private readonly aiClient?;
109
+ private readonly defaultScope;
110
+ private readonly defaultScopeId?;
111
+ private readonly metadata?;
112
+ constructor(params: {
113
+ client: MemoryClient;
114
+ eventClient?: MemoryEventClient;
115
+ aiClient?: AIClient;
116
+ defaultScope?: MemoryScope;
117
+ defaultScopeId?: string;
118
+ metadata?: MemoryRequestMetadata;
119
+ });
120
+ set(key: string, data: any, scope?: MemoryScope, scopeId?: string | undefined): Promise<void>;
121
+ get<T = any>(key: string, scope?: MemoryScope, scopeId?: string | undefined): Promise<T | undefined>;
122
+ getWithFallback<T = any>(key: string): Promise<(Awaited<T> & ({} | null)) | undefined>;
123
+ setVector(key: string, embedding: number[], metadata?: any, scope?: MemoryScope, scopeId?: string | undefined): Promise<void>;
124
+ deleteVector(key: string, scope?: MemoryScope, scopeId?: string | undefined): Promise<void>;
125
+ searchVector(queryEmbedding: number[], options?: Omit<VectorSearchOptions, 'metadata'>): Promise<VectorSearchResult[]>;
126
+ delete(key: string, scope?: MemoryScope, scopeId?: string | undefined): Promise<void>;
127
+ exists(key: string, scope?: MemoryScope, scopeId?: string | undefined): Promise<boolean>;
128
+ listKeys(scope?: MemoryScope, scopeId?: string | undefined): Promise<string[]>;
129
+ embedText(text: string, options?: AIEmbeddingOptions): Promise<number[]>;
130
+ embedTexts(texts: string[], options?: AIEmbeddingOptions): Promise<number[][]>;
131
+ embedAndSet(key: string, text: string, metadata?: any, scope?: MemoryScope, scopeId?: string | undefined, embeddingOptions?: AIEmbeddingOptions): Promise<number[]>;
132
+ deleteVectors(keys: string[], scope?: MemoryScope, scopeId?: string | undefined): Promise<void>;
133
+ workflow(scopeId: string): MemoryInterface;
134
+ session(scopeId: string): MemoryInterface;
135
+ actor(scopeId: string): MemoryInterface;
136
+ get globalScope(): MemoryInterface;
137
+ onEvent(handler: MemoryWatchHandler): void;
138
+ private cloneWithScope;
139
+ private getScopeOrder;
140
+ private resolveScopeId;
141
+ }
142
+
143
+ interface ExecutionStatusUpdate {
144
+ status?: string;
145
+ result?: Record<string, any>;
146
+ error?: string;
147
+ durationMs?: number;
148
+ progress?: number;
149
+ }
150
+ declare class AgentFieldClient {
151
+ private readonly http;
152
+ private readonly config;
153
+ private readonly defaultHeaders;
154
+ constructor(config: AgentConfig);
155
+ register(payload: any): Promise<void>;
156
+ heartbeat(status?: 'starting' | 'ready' | 'degraded' | 'offline'): Promise<HealthStatus>;
157
+ execute<T = any>(target: string, input: any, metadata?: {
158
+ runId?: string;
159
+ workflowId?: string;
160
+ parentExecutionId?: string;
161
+ sessionId?: string;
162
+ actorId?: string;
163
+ callerDid?: string;
164
+ targetDid?: string;
165
+ agentNodeDid?: string;
166
+ agentNodeId?: string;
167
+ }): Promise<T>;
168
+ publishWorkflowEvent(event: {
169
+ executionId: string;
170
+ runId: string;
171
+ workflowId?: string;
172
+ reasonerId: string;
173
+ agentNodeId: string;
174
+ status: 'running' | 'succeeded' | 'failed';
175
+ parentExecutionId?: string;
176
+ parentWorkflowId?: string;
177
+ inputData?: Record<string, any>;
178
+ result?: any;
179
+ error?: string;
180
+ durationMs?: number;
181
+ }): Promise<void>;
182
+ updateExecutionStatus(executionId: string, update: ExecutionStatusUpdate): Promise<void>;
183
+ discoverCapabilities(options?: DiscoveryOptions): Promise<DiscoveryResult>;
184
+ private mapDiscoveryResponse;
185
+ private mapCompactDiscovery;
186
+ private sanitizeHeaders;
187
+ private mergeHeaders;
188
+ }
189
+
190
+ interface WorkflowMetadata {
191
+ executionId: string;
192
+ runId?: string;
193
+ workflowId?: string;
194
+ agentNodeId?: string;
195
+ reasonerId?: string;
196
+ }
197
+ interface WorkflowProgressOptions {
198
+ status?: string;
199
+ result?: Record<string, any>;
200
+ error?: string;
201
+ durationMs?: number;
202
+ }
203
+ declare class WorkflowReporter {
204
+ private readonly client;
205
+ private readonly metadata;
206
+ constructor(client: AgentFieldClient, metadata: WorkflowMetadata);
207
+ progress(progress: number, options?: WorkflowProgressOptions): Promise<void>;
208
+ }
209
+
210
+ interface ExecutionMetadata {
211
+ executionId: string;
212
+ runId?: string;
213
+ sessionId?: string;
214
+ actorId?: string;
215
+ workflowId?: string;
216
+ parentExecutionId?: string;
217
+ callerDid?: string;
218
+ targetDid?: string;
219
+ agentNodeDid?: string;
220
+ }
221
+ declare class ExecutionContext {
222
+ readonly input: any;
223
+ readonly metadata: ExecutionMetadata;
224
+ readonly req: express.Request;
225
+ readonly res: express.Response;
226
+ readonly agent: Agent;
227
+ constructor(params: {
228
+ input: any;
229
+ metadata: ExecutionMetadata;
230
+ req: express.Request;
231
+ res: express.Response;
232
+ agent: Agent;
233
+ });
234
+ static run<T>(ctx: ExecutionContext, fn: () => T): T;
235
+ static getCurrent(): ExecutionContext | undefined;
236
+ }
237
+
238
+ interface ExecutionCredential {
239
+ vcId: string;
240
+ executionId: string;
241
+ workflowId: string;
242
+ sessionId?: string;
243
+ issuerDid?: string;
244
+ targetDid?: string;
245
+ callerDid?: string;
246
+ vcDocument: any;
247
+ signature?: string;
248
+ inputHash?: string;
249
+ outputHash?: string;
250
+ status: string;
251
+ createdAt: string;
252
+ }
253
+ interface WorkflowCredential {
254
+ workflowId: string;
255
+ sessionId?: string;
256
+ componentVcs: string[];
257
+ workflowVcId: string;
258
+ status: string;
259
+ startTime: string;
260
+ endTime?: string;
261
+ totalSteps: number;
262
+ completedSteps: number;
263
+ }
264
+ interface AuditTrailFilters {
265
+ workflowId?: string;
266
+ sessionId?: string;
267
+ issuerDid?: string;
268
+ status?: string;
269
+ limit?: number;
270
+ }
271
+ interface AuditTrailExport {
272
+ agentDids: string[];
273
+ executionVcs: Array<{
274
+ vcId: string;
275
+ executionId: string;
276
+ workflowId: string;
277
+ sessionId?: string;
278
+ issuerDid?: string;
279
+ targetDid?: string;
280
+ callerDid?: string;
281
+ status: string;
282
+ createdAt: string;
283
+ }>;
284
+ workflowVcs: WorkflowCredential[];
285
+ totalCount: number;
286
+ filtersApplied?: Record<string, any>;
287
+ }
288
+ interface GenerateCredentialParams {
289
+ executionContext: {
290
+ executionId: string;
291
+ workflowId?: string;
292
+ sessionId?: string;
293
+ callerDid?: string;
294
+ targetDid?: string;
295
+ agentNodeDid?: string;
296
+ timestamp?: string | Date;
297
+ };
298
+ inputData?: any;
299
+ outputData?: any;
300
+ status?: string;
301
+ errorMessage?: string;
302
+ durationMs?: number;
303
+ headers?: Record<string, string>;
304
+ }
305
+ declare class DidClient {
306
+ private readonly http;
307
+ private readonly defaultHeaders;
308
+ constructor(baseUrl: string, defaultHeaders?: Record<string, string | number | boolean | undefined>);
309
+ generateCredential(params: GenerateCredentialParams): Promise<ExecutionCredential>;
310
+ exportAuditTrail(filters?: AuditTrailFilters): Promise<AuditTrailExport>;
311
+ private serializeDataForJson;
312
+ private mapExecutionCredential;
313
+ private cleanFilters;
314
+ private mergeHeaders;
315
+ private sanitizeHeaders;
316
+ }
317
+
318
+ interface GenerateCredentialOptions {
319
+ inputData?: any;
320
+ outputData?: any;
321
+ status?: string;
322
+ errorMessage?: string;
323
+ durationMs?: number;
324
+ timestamp?: string | Date;
325
+ callerDid?: string;
326
+ targetDid?: string;
327
+ agentNodeDid?: string;
328
+ workflowId?: string;
329
+ sessionId?: string;
330
+ executionId?: string;
331
+ headers?: Record<string, string>;
332
+ }
333
+ declare class DidInterface {
334
+ private readonly client;
335
+ private readonly metadata;
336
+ private readonly enabled;
337
+ private readonly defaultInput;
338
+ constructor(params: {
339
+ client: DidClient;
340
+ metadata: ExecutionMetadata;
341
+ enabled: boolean;
342
+ defaultInput?: any;
343
+ });
344
+ generateCredential(options?: GenerateCredentialOptions): Promise<ExecutionCredential>;
345
+ exportAuditTrail(filters?: AuditTrailFilters): Promise<AuditTrailExport>;
346
+ }
347
+
348
+ declare class ReasonerContext<TInput = any> {
349
+ readonly input: TInput;
350
+ readonly executionId: string;
351
+ readonly runId?: string;
352
+ readonly sessionId?: string;
353
+ readonly actorId?: string;
354
+ readonly workflowId?: string;
355
+ readonly parentExecutionId?: string;
356
+ readonly callerDid?: string;
357
+ readonly targetDid?: string;
358
+ readonly agentNodeDid?: string;
359
+ readonly req: express.Request;
360
+ readonly res: express.Response;
361
+ readonly agent: Agent;
362
+ readonly aiClient: AIClient;
363
+ readonly memory: MemoryInterface;
364
+ readonly workflow: WorkflowReporter;
365
+ readonly did: DidInterface;
366
+ constructor(params: {
367
+ input: TInput;
368
+ executionId: string;
369
+ runId?: string;
370
+ sessionId?: string;
371
+ actorId?: string;
372
+ workflowId?: string;
373
+ parentExecutionId?: string;
374
+ callerDid?: string;
375
+ targetDid?: string;
376
+ agentNodeDid?: string;
377
+ req: express.Request;
378
+ res: express.Response;
379
+ agent: Agent;
380
+ aiClient: AIClient;
381
+ memory: MemoryInterface;
382
+ workflow: WorkflowReporter;
383
+ did: DidInterface;
384
+ });
385
+ ai(prompt: string, options?: AIRequestOptions): Promise<any>;
386
+ aiStream(prompt: string, options?: AIRequestOptions): Promise<AIStream>;
387
+ call(target: string, input: any): Promise<any>;
388
+ discover(options?: DiscoveryOptions): Promise<DiscoveryResult>;
389
+ }
390
+ declare function getCurrentContext<TInput = any>(): ReasonerContext<TInput> | undefined;
391
+
392
+ interface ReasonerDefinition<TInput = any, TOutput = any> {
393
+ name: string;
394
+ handler: ReasonerHandler<TInput, TOutput>;
395
+ options?: ReasonerOptions;
396
+ }
397
+ type ReasonerHandler<TInput = any, TOutput = any> = (ctx: ReasonerContext<TInput>) => Promise<TOutput> | TOutput;
398
+ interface ReasonerOptions {
399
+ tags?: string[];
400
+ description?: string;
401
+ inputSchema?: any;
402
+ outputSchema?: any;
403
+ trackWorkflow?: boolean;
404
+ memoryConfig?: any;
405
+ }
406
+
407
+ declare class SkillContext<TInput = any> {
408
+ readonly input: TInput;
409
+ readonly executionId: string;
410
+ readonly sessionId?: string;
411
+ readonly workflowId?: string;
412
+ readonly callerDid?: string;
413
+ readonly agentNodeDid?: string;
414
+ readonly req: express.Request;
415
+ readonly res: express.Response;
416
+ readonly agent: Agent;
417
+ readonly memory: MemoryInterface;
418
+ readonly workflow: WorkflowReporter;
419
+ readonly did: DidInterface;
420
+ constructor(params: {
421
+ input: TInput;
422
+ executionId: string;
423
+ sessionId?: string;
424
+ workflowId?: string;
425
+ callerDid?: string;
426
+ agentNodeDid?: string;
427
+ req: express.Request;
428
+ res: express.Response;
429
+ agent: Agent;
430
+ memory: MemoryInterface;
431
+ workflow: WorkflowReporter;
432
+ did: DidInterface;
433
+ });
434
+ discover(options?: DiscoveryOptions): Promise<DiscoveryResult>;
435
+ }
436
+ declare function getCurrentSkillContext<TInput = any>(): SkillContext<TInput> | undefined;
437
+
438
+ interface SkillDefinition<TInput = any, TOutput = any> {
439
+ name: string;
440
+ handler: SkillHandler<TInput, TOutput>;
441
+ options?: SkillOptions;
442
+ }
443
+ type SkillHandler<TInput = any, TOutput = any> = (ctx: SkillContext<TInput>) => Awaitable<TOutput>;
444
+ interface SkillOptions {
445
+ tags?: string[];
446
+ description?: string;
447
+ inputSchema?: any;
448
+ outputSchema?: any;
449
+ }
450
+
451
+ type DeploymentType = 'long_running' | 'serverless';
452
+ interface AgentConfig {
453
+ nodeId: string;
454
+ version?: string;
455
+ teamId?: string;
456
+ agentFieldUrl?: string;
457
+ port?: number;
458
+ host?: string;
459
+ publicUrl?: string;
460
+ aiConfig?: AIConfig;
461
+ memoryConfig?: MemoryConfig;
462
+ didEnabled?: boolean;
463
+ devMode?: boolean;
464
+ heartbeatIntervalMs?: number;
465
+ defaultHeaders?: Record<string, string | number | boolean | undefined>;
466
+ mcp?: MCPConfig;
467
+ deploymentType?: DeploymentType;
468
+ }
469
+ interface AIConfig {
470
+ provider?: 'openai' | 'anthropic' | 'openrouter' | 'ollama';
471
+ model?: string;
472
+ embeddingModel?: string;
473
+ apiKey?: string;
474
+ baseUrl?: string;
475
+ temperature?: number;
476
+ maxTokens?: number;
477
+ enableRateLimitRetry?: boolean;
478
+ rateLimitMaxRetries?: number;
479
+ rateLimitBaseDelay?: number;
480
+ rateLimitMaxDelay?: number;
481
+ rateLimitJitterFactor?: number;
482
+ rateLimitCircuitBreakerThreshold?: number;
483
+ rateLimitCircuitBreakerTimeout?: number;
484
+ }
485
+ interface MemoryConfig {
486
+ defaultScope?: MemoryScope;
487
+ ttl?: number;
488
+ }
489
+ type MemoryScope = 'workflow' | 'session' | 'actor' | 'global';
490
+ interface MCPServerConfig {
491
+ alias: string;
492
+ url?: string;
493
+ port?: number;
494
+ transport?: 'http' | 'bridge';
495
+ headers?: Record<string, string>;
496
+ }
497
+ interface MCPConfig {
498
+ servers?: MCPServerConfig[];
499
+ autoRegisterTools?: boolean;
500
+ namespace?: string;
501
+ tags?: string[];
502
+ }
503
+ interface AgentCapability {
504
+ agentId: string;
505
+ baseUrl: string;
506
+ version: string;
507
+ healthStatus: string;
508
+ deploymentType?: string;
509
+ lastHeartbeat?: string;
510
+ reasoners: ReasonerCapability[];
511
+ skills: SkillCapability[];
512
+ }
513
+ interface ReasonerCapability {
514
+ id: string;
515
+ description?: string;
516
+ tags: string[];
517
+ inputSchema?: any;
518
+ outputSchema?: any;
519
+ examples?: any[];
520
+ invocationTarget: string;
521
+ }
522
+ interface SkillCapability {
523
+ id: string;
524
+ description?: string;
525
+ tags: string[];
526
+ inputSchema?: any;
527
+ invocationTarget: string;
528
+ }
529
+ interface DiscoveryResponse {
530
+ discoveredAt: string;
531
+ totalAgents: number;
532
+ totalReasoners: number;
533
+ totalSkills: number;
534
+ pagination: DiscoveryPagination;
535
+ capabilities: AgentCapability[];
536
+ }
537
+ interface DiscoveryPagination {
538
+ limit: number;
539
+ offset: number;
540
+ hasMore: boolean;
541
+ }
542
+ interface CompactCapability {
543
+ id: string;
544
+ agentId: string;
545
+ target: string;
546
+ tags: string[];
547
+ }
548
+ interface CompactDiscoveryResponse {
549
+ discoveredAt: string;
550
+ reasoners: CompactCapability[];
551
+ skills: CompactCapability[];
552
+ }
553
+ type DiscoveryFormat = 'json' | 'compact' | 'xml';
554
+ interface DiscoveryResult {
555
+ format: DiscoveryFormat;
556
+ raw: string;
557
+ json?: DiscoveryResponse;
558
+ compact?: CompactDiscoveryResponse;
559
+ xml?: string;
560
+ }
561
+ interface DiscoveryOptions {
562
+ agent?: string;
563
+ nodeId?: string;
564
+ agentIds?: string[];
565
+ nodeIds?: string[];
566
+ reasoner?: string;
567
+ skill?: string;
568
+ tags?: string[];
569
+ includeInputSchema?: boolean;
570
+ includeOutputSchema?: boolean;
571
+ includeDescriptions?: boolean;
572
+ includeExamples?: boolean;
573
+ format?: DiscoveryFormat;
574
+ healthStatus?: string;
575
+ limit?: number;
576
+ offset?: number;
577
+ headers?: Record<string, string>;
578
+ }
579
+ interface AgentState {
580
+ reasoners: Map<string, ReasonerDefinition>;
581
+ skills: Map<string, SkillDefinition>;
582
+ memoryWatchers: Array<{
583
+ pattern: string;
584
+ handler: MemoryWatchHandler;
585
+ scope?: string;
586
+ scopeId?: string;
587
+ }>;
588
+ }
589
+ interface HealthStatus {
590
+ status: 'ok' | 'running';
591
+ nodeId: string;
592
+ version?: string;
593
+ }
594
+ interface ServerlessEvent {
595
+ path?: string;
596
+ rawPath?: string;
597
+ httpMethod?: string;
598
+ method?: string;
599
+ action?: string;
600
+ headers?: Record<string, string | undefined>;
601
+ queryStringParameters?: Record<string, string | undefined>;
602
+ target?: string;
603
+ reasoner?: string;
604
+ skill?: string;
605
+ type?: 'reasoner' | 'skill';
606
+ body?: any;
607
+ input?: any;
608
+ executionContext?: Partial<ExecutionMetadata>;
609
+ execution_context?: Partial<ExecutionMetadata>;
610
+ }
611
+ interface ServerlessResponse {
612
+ statusCode: number;
613
+ headers?: Record<string, string>;
614
+ body: any;
615
+ }
616
+ type AgentHandler = (event: ServerlessEvent | http.IncomingMessage, res?: http.ServerResponse) => Promise<ServerlessResponse | void> | ServerlessResponse | void;
617
+ type Awaitable<T> = T | Promise<T>;
618
+
619
+ interface AgentRouterOptions {
620
+ prefix?: string;
621
+ tags?: string[];
622
+ }
623
+ declare class AgentRouter {
624
+ readonly prefix?: string;
625
+ readonly tags?: string[];
626
+ readonly reasoners: ReasonerDefinition[];
627
+ readonly skills: SkillDefinition[];
628
+ constructor(options?: AgentRouterOptions);
629
+ reasoner<TInput = any, TOutput = any>(name: string, handler: ReasonerHandler<TInput, TOutput>, options?: ReasonerOptions): this;
630
+ skill<TInput = any, TOutput = any>(name: string, handler: SkillHandler<TInput, TOutput>, options?: SkillOptions): this;
631
+ }
632
+
633
+ declare class ReasonerRegistry {
634
+ private readonly reasoners;
635
+ register<TInput = any, TOutput = any>(name: string, handler: ReasonerHandler<TInput, TOutput>, options?: ReasonerOptions): void;
636
+ includeRouter(router: AgentRouter): void;
637
+ get(name: string): ReasonerDefinition<any, any> | undefined;
638
+ all(): ReasonerDefinition<any, any>[];
639
+ }
640
+
641
+ declare class SkillRegistry {
642
+ private readonly skills;
643
+ register<TInput = any, TOutput = any>(name: string, handler: SkillHandler<TInput, TOutput>, options?: SkillOptions): void;
644
+ includeRouter(router: AgentRouter): void;
645
+ get(name: string): SkillDefinition<any, any> | undefined;
646
+ all(): SkillDefinition<any, any>[];
647
+ }
648
+
649
+ interface MCPTool {
650
+ name: string;
651
+ description?: string;
652
+ inputSchema?: any;
653
+ input_schema?: any;
654
+ }
655
+ interface MCPToolRegistration {
656
+ server: string;
657
+ skillName: string;
658
+ tool: MCPTool;
659
+ }
660
+ interface MCPHealthSummary {
661
+ status: 'ok' | 'degraded' | 'disabled';
662
+ totalServers: number;
663
+ healthyServers: number;
664
+ servers: Array<{
665
+ alias: string;
666
+ baseUrl: string;
667
+ transport: 'http' | 'bridge';
668
+ healthy: boolean;
669
+ }>;
670
+ }
671
+
672
+ declare class Agent {
673
+ readonly config: AgentConfig;
674
+ readonly app: express.Express;
675
+ readonly reasoners: ReasonerRegistry;
676
+ readonly skills: SkillRegistry;
677
+ private server?;
678
+ private heartbeatTimer?;
679
+ private readonly aiClient;
680
+ private readonly agentFieldClient;
681
+ private readonly memoryClient;
682
+ private readonly memoryEventClient;
683
+ private readonly didClient;
684
+ private readonly memoryWatchers;
685
+ private readonly mcpClientRegistry?;
686
+ private readonly mcpToolRegistrar?;
687
+ constructor(config: AgentConfig);
688
+ reasoner<TInput = any, TOutput = any>(name: string, handler: ReasonerHandler<TInput, TOutput>, options?: ReasonerOptions): this;
689
+ skill<TInput = any, TOutput = any>(name: string, handler: SkillHandler<TInput, TOutput>, options?: SkillOptions): this;
690
+ includeRouter(router: AgentRouter): void;
691
+ handler(): AgentHandler;
692
+ watchMemory(pattern: string | string[], handler: MemoryWatchHandler, options?: {
693
+ scope?: string;
694
+ scopeId?: string;
695
+ }): void;
696
+ discover(options?: DiscoveryOptions): Promise<DiscoveryResult>;
697
+ registerMcpTools(): Promise<{
698
+ registered: MCPToolRegistration[];
699
+ }>;
700
+ getAIClient(): AIClient;
701
+ getMemoryInterface(metadata?: ExecutionMetadata): MemoryInterface;
702
+ getWorkflowReporter(metadata: ExecutionMetadata): WorkflowReporter;
703
+ getDidInterface(metadata: ExecutionMetadata, defaultInput?: any): DidInterface;
704
+ serve(): Promise<void>;
705
+ shutdown(): Promise<void>;
706
+ call(target: string, input: any): Promise<any>;
707
+ private registerDefaultRoutes;
708
+ private executeReasoner;
709
+ private executeSkill;
710
+ private buildMetadata;
711
+ private executeServerlessHttp;
712
+ private buildMetadataFromHeaders;
713
+ private handleHttpRequest;
714
+ private handleServerlessEvent;
715
+ private normalizeEventBody;
716
+ private mergeExecutionContext;
717
+ private extractInvocationDetails;
718
+ private parsePathTarget;
719
+ private parseBody;
720
+ private normalizeInputPayload;
721
+ private firstDefined;
722
+ private reasonerDefinitions;
723
+ private skillDefinitions;
724
+ private discoveryPayload;
725
+ private executeInvocation;
726
+ private runReasoner;
727
+ private runSkill;
728
+ private registerWithControlPlane;
729
+ private startHeartbeat;
730
+ private health;
731
+ private mcpStatus;
732
+ private dispatchMemoryEvent;
733
+ private parseTarget;
734
+ }
735
+
736
+ declare class MCPClient {
737
+ readonly alias: string;
738
+ readonly baseUrl: string;
739
+ readonly transport: 'http' | 'bridge';
740
+ private readonly http;
741
+ private readonly devMode;
742
+ private lastHealthy;
743
+ constructor(config: MCPServerConfig, devMode?: boolean);
744
+ healthCheck(): Promise<boolean>;
745
+ listTools(): Promise<MCPTool[]>;
746
+ callTool(toolName: string, arguments_?: Record<string, any>): Promise<any>;
747
+ get lastHealthStatus(): boolean;
748
+ private normalizeTools;
749
+ }
750
+
751
+ declare class MCPClientRegistry {
752
+ private readonly clients;
753
+ private readonly devMode;
754
+ constructor(devMode?: boolean);
755
+ register(config: MCPServerConfig): MCPClient;
756
+ get(alias: string): MCPClient | undefined;
757
+ list(): MCPClient[];
758
+ healthSummary(): Promise<MCPHealthSummary>;
759
+ }
760
+
761
+ interface MCPToolRegistrarOptions {
762
+ namespace?: string;
763
+ tags?: string[];
764
+ devMode?: boolean;
765
+ }
766
+ declare class MCPToolRegistrar {
767
+ private readonly agent;
768
+ private readonly registry;
769
+ private readonly options;
770
+ private readonly registered;
771
+ private readonly devMode;
772
+ constructor(agent: Agent, registry: MCPClientRegistry, options?: MCPToolRegistrarOptions);
773
+ registerServers(servers: MCPServerConfig[]): void;
774
+ registerAll(): Promise<{
775
+ registered: MCPToolRegistration[];
776
+ }>;
777
+ private buildTags;
778
+ private buildSkillName;
779
+ private sanitize;
780
+ }
781
+
782
+ declare class RateLimitError extends Error {
783
+ retryAfter?: number;
784
+ constructor(message: string, retryAfter?: number);
785
+ }
786
+ interface RateLimiterOptions {
787
+ maxRetries?: number;
788
+ baseDelay?: number;
789
+ maxDelay?: number;
790
+ jitterFactor?: number;
791
+ circuitBreakerThreshold?: number;
792
+ circuitBreakerTimeout?: number;
793
+ }
794
+ /**
795
+ * Stateless rate limiter with adaptive exponential backoff.
796
+ *
797
+ * Designed to work across many containers without coordination.
798
+ * Uses container-specific jitter to naturally distribute load.
799
+ */
800
+ declare class StatelessRateLimiter {
801
+ readonly maxRetries: number;
802
+ readonly baseDelay: number;
803
+ readonly maxDelay: number;
804
+ readonly jitterFactor: number;
805
+ readonly circuitBreakerThreshold: number;
806
+ readonly circuitBreakerTimeout: number;
807
+ protected _containerSeed: number;
808
+ protected _consecutiveFailures: number;
809
+ protected _circuitOpenTime?: number;
810
+ constructor(options?: RateLimiterOptions);
811
+ protected _getContainerSeed(): number;
812
+ protected _isRateLimitError(error: unknown): boolean;
813
+ protected _extractRetryAfter(error: unknown): number | undefined;
814
+ protected _createJitterRng(seed: number): () => number;
815
+ protected _calculateBackoffDelay(attempt: number, retryAfter?: number): number;
816
+ protected _checkCircuitBreaker(): boolean;
817
+ protected _updateCircuitBreaker(success: boolean): void;
818
+ protected _sleep(delaySeconds: number): Promise<void>;
819
+ protected _now(): number;
820
+ executeWithRetry<T>(fn: () => Promise<T>): Promise<T>;
821
+ }
822
+
823
+ export { AIClient, type AIConfig, type AIEmbeddingOptions, type AIRequestOptions, type AIStream, Agent, type AgentCapability, type AgentConfig, type AgentHandler, AgentRouter, type AgentRouterOptions, type AgentState, type AuditTrailExport, type AuditTrailFilters, type Awaitable, type CompactCapability, type CompactDiscoveryResponse, type DeploymentType, DidClient, DidInterface, type DiscoveryFormat, type DiscoveryOptions, type DiscoveryPagination, type DiscoveryResponse, type DiscoveryResult, ExecutionContext, type ExecutionCredential, type ExecutionMetadata, type GenerateCredentialOptions, type GenerateCredentialParams, type HealthStatus, MCPClient, MCPClientRegistry, type MCPConfig, type MCPHealthSummary, type MCPServerConfig, type MCPTool, MCPToolRegistrar, type MCPToolRegistrarOptions, type MCPToolRegistration, type MemoryChangeEvent, MemoryClient, type MemoryConfig, MemoryEventClient, type MemoryEventHandler, MemoryInterface, type MemoryRequestMetadata, type MemoryRequestOptions, type MemoryScope, type MemoryWatchHandler, RateLimitError, type RateLimiterOptions, type ReasonerCapability, ReasonerContext, type ReasonerDefinition, type ReasonerHandler, type ReasonerOptions, type ServerlessEvent, type ServerlessResponse, type SkillCapability, SkillContext, type SkillDefinition, type SkillHandler, type SkillOptions, StatelessRateLimiter, type VectorSearchOptions, type VectorSearchResult, type WorkflowCredential, type WorkflowMetadata, type WorkflowProgressOptions, WorkflowReporter, getCurrentContext, getCurrentSkillContext };