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