@elizaos/plugin-secrets-manager 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1461 -0
- package/dist/index.js +4171 -0
- package/dist/index.js.map +1 -0
- package/package.json +82 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1461 @@
|
|
|
1
|
+
import { IAgentRuntime, ServiceTypeName, Service, Plugin, World, UUID, Memory, Provider, Action } from '@elizaos/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plugin Secrets Manager - Shared Type Definitions
|
|
5
|
+
*
|
|
6
|
+
* This module defines all core types for the multi-level secrets management system.
|
|
7
|
+
* Designed for ElizaOS native storage: character settings, world metadata, and components.
|
|
8
|
+
*/
|
|
9
|
+
declare const SECRET_KEY_MAX_LENGTH = 256;
|
|
10
|
+
declare const SECRET_VALUE_MAX_LENGTH = 65536;
|
|
11
|
+
declare const SECRET_DESCRIPTION_MAX_LENGTH = 1024;
|
|
12
|
+
declare const SECRET_KEY_PATTERN: RegExp;
|
|
13
|
+
declare const MAX_ACCESS_LOG_ENTRIES = 1000;
|
|
14
|
+
type SecretLevel = "global" | "world" | "user";
|
|
15
|
+
type SecretType = "api_key" | "private_key" | "public_key" | "url" | "credential" | "token" | "config" | "secret";
|
|
16
|
+
type SecretStatus = "missing" | "generating" | "validating" | "invalid" | "valid" | "expired" | "revoked";
|
|
17
|
+
type SecretPermissionType = "read" | "write" | "delete" | "share";
|
|
18
|
+
type ValidationStrategy = "none" | "api_key:openai" | "api_key:anthropic" | "api_key:groq" | "api_key:google" | "api_key:mistral" | "api_key:cohere" | "url:valid" | "url:reachable" | "custom";
|
|
19
|
+
type StorageBackend = "memory" | "character" | "world" | "component";
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for a single secret/environment variable
|
|
22
|
+
*/
|
|
23
|
+
interface SecretConfig {
|
|
24
|
+
/** Type classification of the secret */
|
|
25
|
+
type: SecretType;
|
|
26
|
+
/** Whether this secret is required for the plugin to function */
|
|
27
|
+
required: boolean;
|
|
28
|
+
/** Human-readable description */
|
|
29
|
+
description: string;
|
|
30
|
+
/** Whether this secret can be auto-generated */
|
|
31
|
+
canGenerate: boolean;
|
|
32
|
+
/** Validation method to use */
|
|
33
|
+
validationMethod?: ValidationStrategy;
|
|
34
|
+
/** Current status of the secret */
|
|
35
|
+
status: SecretStatus;
|
|
36
|
+
/** Last error message if validation failed */
|
|
37
|
+
lastError?: string;
|
|
38
|
+
/** Number of validation attempts */
|
|
39
|
+
attempts: number;
|
|
40
|
+
/** Timestamp when secret was created */
|
|
41
|
+
createdAt?: number;
|
|
42
|
+
/** Timestamp when secret was last validated */
|
|
43
|
+
validatedAt?: number;
|
|
44
|
+
/** Plugin that declared this secret requirement */
|
|
45
|
+
plugin: string;
|
|
46
|
+
/** Storage level (global, world, or user) */
|
|
47
|
+
level: SecretLevel;
|
|
48
|
+
/** Owner entity ID for user-level secrets */
|
|
49
|
+
ownerId?: string;
|
|
50
|
+
/** World ID for world-level secrets */
|
|
51
|
+
worldId?: string;
|
|
52
|
+
/** Whether the value is encrypted */
|
|
53
|
+
encrypted?: boolean;
|
|
54
|
+
/** Explicit permissions granted to other entities */
|
|
55
|
+
permissions?: SecretPermission[];
|
|
56
|
+
/** List of entity IDs with shared access */
|
|
57
|
+
sharedWith?: string[];
|
|
58
|
+
/** Optional expiration timestamp */
|
|
59
|
+
expiresAt?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Stored secret with value and config
|
|
63
|
+
*/
|
|
64
|
+
interface StoredSecret {
|
|
65
|
+
/** The secret value (may be encrypted) */
|
|
66
|
+
value: string | EncryptedSecret;
|
|
67
|
+
/** Secret configuration */
|
|
68
|
+
config: SecretConfig;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Context for secret operations - determines access level and scope
|
|
72
|
+
*/
|
|
73
|
+
interface SecretContext {
|
|
74
|
+
/** Storage level to operate on */
|
|
75
|
+
level: SecretLevel;
|
|
76
|
+
/** World ID (required for world-level operations) */
|
|
77
|
+
worldId?: string;
|
|
78
|
+
/** User ID (required for user-level operations) */
|
|
79
|
+
userId?: string;
|
|
80
|
+
/** Agent ID (always required) */
|
|
81
|
+
agentId: string;
|
|
82
|
+
/** Entity making the request (for permission checks) */
|
|
83
|
+
requesterId?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Permission grant for a secret
|
|
87
|
+
*/
|
|
88
|
+
interface SecretPermission {
|
|
89
|
+
/** Entity ID that has this permission */
|
|
90
|
+
entityId: string;
|
|
91
|
+
/** List of allowed operations */
|
|
92
|
+
permissions: SecretPermissionType[];
|
|
93
|
+
/** Entity that granted this permission */
|
|
94
|
+
grantedBy: string;
|
|
95
|
+
/** Timestamp when permission was granted */
|
|
96
|
+
grantedAt: number;
|
|
97
|
+
/** Optional expiration timestamp */
|
|
98
|
+
expiresAt?: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Metadata collection for multiple secrets (without values)
|
|
102
|
+
*/
|
|
103
|
+
interface SecretMetadata {
|
|
104
|
+
[key: string]: SecretConfig;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Access log entry for auditing
|
|
108
|
+
*/
|
|
109
|
+
interface SecretAccessLog {
|
|
110
|
+
/** Secret key that was accessed */
|
|
111
|
+
secretKey: string;
|
|
112
|
+
/** Entity that performed the access */
|
|
113
|
+
accessedBy: string;
|
|
114
|
+
/** Type of access operation */
|
|
115
|
+
action: SecretPermissionType;
|
|
116
|
+
/** Timestamp of access */
|
|
117
|
+
timestamp: number;
|
|
118
|
+
/** Context of the access */
|
|
119
|
+
context: SecretContext;
|
|
120
|
+
/** Whether the access succeeded */
|
|
121
|
+
success: boolean;
|
|
122
|
+
/** Error message if access failed */
|
|
123
|
+
error?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Encrypted secret container
|
|
127
|
+
*/
|
|
128
|
+
interface EncryptedSecret {
|
|
129
|
+
/** Encrypted value (base64) */
|
|
130
|
+
value: string;
|
|
131
|
+
/** Initialization vector (base64) */
|
|
132
|
+
iv: string;
|
|
133
|
+
/** Authentication tag for GCM mode (base64) */
|
|
134
|
+
authTag?: string;
|
|
135
|
+
/** Encryption algorithm used */
|
|
136
|
+
algorithm: "aes-256-gcm" | "aes-256-cbc";
|
|
137
|
+
/** Key identifier for key rotation */
|
|
138
|
+
keyId: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Key derivation parameters
|
|
142
|
+
*/
|
|
143
|
+
interface KeyDerivationParams {
|
|
144
|
+
/** Salt for key derivation (base64) */
|
|
145
|
+
salt: string;
|
|
146
|
+
/** Number of iterations for PBKDF2 */
|
|
147
|
+
iterations: number;
|
|
148
|
+
/** Algorithm used for derivation */
|
|
149
|
+
algorithm: "pbkdf2-sha256" | "argon2id";
|
|
150
|
+
/** Key length in bytes */
|
|
151
|
+
keyLength: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Secret requirement declared by a plugin
|
|
155
|
+
*/
|
|
156
|
+
interface PluginSecretRequirement {
|
|
157
|
+
/** Human-readable description */
|
|
158
|
+
description: string;
|
|
159
|
+
/** Type of secret */
|
|
160
|
+
type: SecretType;
|
|
161
|
+
/** Whether the secret is required for plugin to function */
|
|
162
|
+
required: boolean;
|
|
163
|
+
/** Validation method to use */
|
|
164
|
+
validationMethod?: ValidationStrategy;
|
|
165
|
+
/** Environment variable name (for backward compatibility) */
|
|
166
|
+
envVar?: string;
|
|
167
|
+
/** Whether this secret can be auto-generated */
|
|
168
|
+
canGenerate?: boolean;
|
|
169
|
+
/** Generation script if auto-generatable */
|
|
170
|
+
generationScript?: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Status of plugin requirements
|
|
174
|
+
*/
|
|
175
|
+
interface PluginRequirementStatus {
|
|
176
|
+
/** Plugin identifier */
|
|
177
|
+
pluginId: string;
|
|
178
|
+
/** Whether all required secrets are available */
|
|
179
|
+
ready: boolean;
|
|
180
|
+
/** List of missing required secrets */
|
|
181
|
+
missingRequired: string[];
|
|
182
|
+
/** List of missing optional secrets */
|
|
183
|
+
missingOptional: string[];
|
|
184
|
+
/** List of invalid secrets */
|
|
185
|
+
invalid: string[];
|
|
186
|
+
/** Overall status message */
|
|
187
|
+
message: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Callback for secret changes
|
|
191
|
+
*/
|
|
192
|
+
type SecretChangeCallback = (key: string, value: string | null, context: SecretContext) => Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Plugin activation registration
|
|
195
|
+
*/
|
|
196
|
+
interface PendingPluginActivation {
|
|
197
|
+
/** Plugin identifier */
|
|
198
|
+
pluginId: string;
|
|
199
|
+
/** Required secrets for activation */
|
|
200
|
+
requiredSecrets: string[];
|
|
201
|
+
/** Callback to invoke when ready */
|
|
202
|
+
callback: () => Promise<void>;
|
|
203
|
+
/** Registration timestamp */
|
|
204
|
+
registeredAt: number;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Storage backend interface
|
|
208
|
+
*/
|
|
209
|
+
interface ISecretStorage {
|
|
210
|
+
/** Storage backend type */
|
|
211
|
+
readonly storageType: StorageBackend;
|
|
212
|
+
/** Initialize the storage backend */
|
|
213
|
+
initialize(): Promise<void>;
|
|
214
|
+
/** Check if a secret exists */
|
|
215
|
+
exists(key: string, context: SecretContext): Promise<boolean>;
|
|
216
|
+
/** Get a secret value */
|
|
217
|
+
get(key: string, context: SecretContext): Promise<string | null>;
|
|
218
|
+
/** Set a secret value */
|
|
219
|
+
set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
220
|
+
/** Delete a secret */
|
|
221
|
+
delete(key: string, context: SecretContext): Promise<boolean>;
|
|
222
|
+
/** List all secrets in a context */
|
|
223
|
+
list(context: SecretContext): Promise<SecretMetadata>;
|
|
224
|
+
/** Get secret configuration without value */
|
|
225
|
+
getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
226
|
+
/** Update secret configuration */
|
|
227
|
+
updateConfig(key: string, context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Result of secret validation
|
|
231
|
+
*/
|
|
232
|
+
interface ValidationResult {
|
|
233
|
+
/** Whether the value is valid */
|
|
234
|
+
isValid: boolean;
|
|
235
|
+
/** Error message if invalid */
|
|
236
|
+
error?: string;
|
|
237
|
+
/** Additional details */
|
|
238
|
+
details?: string;
|
|
239
|
+
/** Validation timestamp */
|
|
240
|
+
validatedAt: number;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Custom validation function signature
|
|
244
|
+
*/
|
|
245
|
+
type CustomValidator = (key: string, value: string) => Promise<ValidationResult>;
|
|
246
|
+
/**
|
|
247
|
+
* Validation strategy registry entry
|
|
248
|
+
*/
|
|
249
|
+
interface ValidationStrategyEntry {
|
|
250
|
+
/** Strategy identifier */
|
|
251
|
+
id: ValidationStrategy;
|
|
252
|
+
/** Human-readable name */
|
|
253
|
+
name: string;
|
|
254
|
+
/** Description of validation */
|
|
255
|
+
description: string;
|
|
256
|
+
/** Validator function */
|
|
257
|
+
validate: CustomValidator;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Script for auto-generating secrets
|
|
261
|
+
*/
|
|
262
|
+
interface GenerationScript {
|
|
263
|
+
/** Variable name to generate */
|
|
264
|
+
variableName: string;
|
|
265
|
+
/** Plugin that owns this script */
|
|
266
|
+
pluginName: string;
|
|
267
|
+
/** Script content (shell/node) */
|
|
268
|
+
script: string;
|
|
269
|
+
/** Required dependencies */
|
|
270
|
+
dependencies: string[];
|
|
271
|
+
/** Number of generation attempts */
|
|
272
|
+
attempts: number;
|
|
273
|
+
/** Last output */
|
|
274
|
+
output?: string;
|
|
275
|
+
/** Last error */
|
|
276
|
+
error?: string;
|
|
277
|
+
/** Current status */
|
|
278
|
+
status: "pending" | "running" | "success" | "failed";
|
|
279
|
+
/** Creation timestamp */
|
|
280
|
+
createdAt: number;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Secrets service configuration
|
|
284
|
+
*/
|
|
285
|
+
interface SecretsServiceConfig {
|
|
286
|
+
/** Whether to enable encryption */
|
|
287
|
+
enableEncryption: boolean;
|
|
288
|
+
/** Salt for key derivation */
|
|
289
|
+
encryptionSalt?: string;
|
|
290
|
+
/** Whether to enable access logging */
|
|
291
|
+
enableAccessLogging: boolean;
|
|
292
|
+
/** Maximum access log entries to keep */
|
|
293
|
+
maxAccessLogEntries: number;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Plugin activator service configuration
|
|
297
|
+
*/
|
|
298
|
+
interface PluginActivatorConfig {
|
|
299
|
+
/** Whether to enable auto-activation */
|
|
300
|
+
enableAutoActivation: boolean;
|
|
301
|
+
/** Polling interval for checking requirements (ms) */
|
|
302
|
+
pollingIntervalMs: number;
|
|
303
|
+
/** Maximum time to wait for secrets (ms, 0 = forever) */
|
|
304
|
+
maxWaitMs: number;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Secret change event
|
|
308
|
+
*/
|
|
309
|
+
interface SecretChangeEvent {
|
|
310
|
+
/** Event type */
|
|
311
|
+
type: "created" | "updated" | "deleted" | "expired";
|
|
312
|
+
/** Secret key */
|
|
313
|
+
key: string;
|
|
314
|
+
/** New value (null for deleted) */
|
|
315
|
+
value: string | null;
|
|
316
|
+
/** Previous value (if updated) */
|
|
317
|
+
previousValue?: string;
|
|
318
|
+
/** Context of the change */
|
|
319
|
+
context: SecretContext;
|
|
320
|
+
/** Timestamp */
|
|
321
|
+
timestamp: number;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Plugin activation event
|
|
325
|
+
*/
|
|
326
|
+
interface PluginActivationEvent {
|
|
327
|
+
/** Event type */
|
|
328
|
+
type: "queued" | "activated" | "failed" | "timeout";
|
|
329
|
+
/** Plugin identifier */
|
|
330
|
+
pluginId: string;
|
|
331
|
+
/** Missing secrets (if queued/failed) */
|
|
332
|
+
missingSecrets?: string[];
|
|
333
|
+
/** Error message (if failed) */
|
|
334
|
+
error?: string;
|
|
335
|
+
/** Timestamp */
|
|
336
|
+
timestamp: number;
|
|
337
|
+
}
|
|
338
|
+
type FormFieldType = "text" | "password" | "textarea" | "select" | "checkbox" | "radio" | "file" | "hidden";
|
|
339
|
+
interface FormValidationRule {
|
|
340
|
+
/** Rule type */
|
|
341
|
+
type: "required" | "minLength" | "maxLength" | "pattern" | "custom";
|
|
342
|
+
/** Value for the rule */
|
|
343
|
+
value?: string | number | boolean;
|
|
344
|
+
/** Error message */
|
|
345
|
+
message: string;
|
|
346
|
+
}
|
|
347
|
+
interface FormField {
|
|
348
|
+
/** Field name (becomes secret key) */
|
|
349
|
+
name: string;
|
|
350
|
+
/** Field label */
|
|
351
|
+
label: string;
|
|
352
|
+
/** Field type */
|
|
353
|
+
type: FormFieldType;
|
|
354
|
+
/** Placeholder text */
|
|
355
|
+
placeholder?: string;
|
|
356
|
+
/** Default value */
|
|
357
|
+
defaultValue?: string;
|
|
358
|
+
/** Help text */
|
|
359
|
+
helpText?: string;
|
|
360
|
+
/** Options for select/radio */
|
|
361
|
+
options?: Array<{
|
|
362
|
+
value: string;
|
|
363
|
+
label: string;
|
|
364
|
+
}>;
|
|
365
|
+
/** Validation rules */
|
|
366
|
+
validation?: FormValidationRule[];
|
|
367
|
+
/** Whether field is disabled */
|
|
368
|
+
disabled?: boolean;
|
|
369
|
+
/** Custom CSS classes */
|
|
370
|
+
className?: string;
|
|
371
|
+
}
|
|
372
|
+
interface FormSchema {
|
|
373
|
+
/** Form title */
|
|
374
|
+
title: string;
|
|
375
|
+
/** Form description */
|
|
376
|
+
description?: string;
|
|
377
|
+
/** Form fields */
|
|
378
|
+
fields: FormField[];
|
|
379
|
+
/** Submit button text */
|
|
380
|
+
submitText?: string;
|
|
381
|
+
/** Cancel button text */
|
|
382
|
+
cancelText?: string;
|
|
383
|
+
/** Success message */
|
|
384
|
+
successMessage?: string;
|
|
385
|
+
/** Redirect URL after success */
|
|
386
|
+
redirectUrl?: string;
|
|
387
|
+
}
|
|
388
|
+
interface FormSession {
|
|
389
|
+
/** Session ID */
|
|
390
|
+
id: string;
|
|
391
|
+
/** Form schema */
|
|
392
|
+
schema: FormSchema;
|
|
393
|
+
/** Context for storing secrets */
|
|
394
|
+
context: SecretContext;
|
|
395
|
+
/** Expiration timestamp */
|
|
396
|
+
expiresAt: number;
|
|
397
|
+
/** Created timestamp */
|
|
398
|
+
createdAt: number;
|
|
399
|
+
/** Public URL for form access */
|
|
400
|
+
publicUrl?: string;
|
|
401
|
+
/** Tunnel ID (if using ngrok) */
|
|
402
|
+
tunnelId?: string;
|
|
403
|
+
/** Whether form has been submitted */
|
|
404
|
+
submitted: boolean;
|
|
405
|
+
/** Submission timestamp */
|
|
406
|
+
submittedAt?: number;
|
|
407
|
+
}
|
|
408
|
+
interface FormSubmission {
|
|
409
|
+
/** Session ID */
|
|
410
|
+
sessionId: string;
|
|
411
|
+
/** Submitted values */
|
|
412
|
+
values: Record<string, string>;
|
|
413
|
+
/** Submission timestamp */
|
|
414
|
+
submittedAt: number;
|
|
415
|
+
/** Client IP address */
|
|
416
|
+
clientIp?: string;
|
|
417
|
+
/** User agent */
|
|
418
|
+
userAgent?: string;
|
|
419
|
+
}
|
|
420
|
+
declare class SecretsError extends Error {
|
|
421
|
+
readonly code: string;
|
|
422
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
423
|
+
constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
|
|
424
|
+
}
|
|
425
|
+
declare class PermissionDeniedError extends SecretsError {
|
|
426
|
+
constructor(key: string, action: SecretPermissionType, context: SecretContext);
|
|
427
|
+
}
|
|
428
|
+
declare class SecretNotFoundError extends SecretsError {
|
|
429
|
+
constructor(key: string, context: SecretContext);
|
|
430
|
+
}
|
|
431
|
+
declare class ValidationError extends SecretsError {
|
|
432
|
+
constructor(key: string, message: string, details?: Record<string, unknown>);
|
|
433
|
+
}
|
|
434
|
+
declare class EncryptionError extends SecretsError {
|
|
435
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
436
|
+
}
|
|
437
|
+
declare class StorageError extends SecretsError {
|
|
438
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Encryption module for secrets management
|
|
443
|
+
*
|
|
444
|
+
* Provides AES-256-GCM encryption with secure key derivation for protecting sensitive data.
|
|
445
|
+
* Compatible with the OpenClaw encryption approach while providing additional security features.
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Generate a cryptographically secure random salt
|
|
450
|
+
*/
|
|
451
|
+
declare function generateSalt(length?: number): string;
|
|
452
|
+
/**
|
|
453
|
+
* Generate a random encryption key
|
|
454
|
+
*/
|
|
455
|
+
declare function generateKey(): Buffer;
|
|
456
|
+
/**
|
|
457
|
+
* Derive an encryption key from a password/passphrase using PBKDF2
|
|
458
|
+
*
|
|
459
|
+
* @param password - The password or passphrase to derive from
|
|
460
|
+
* @param salt - The salt (should be unique per key)
|
|
461
|
+
* @param iterations - Number of PBKDF2 iterations (default: 100000)
|
|
462
|
+
* @returns The derived key as a Buffer
|
|
463
|
+
*/
|
|
464
|
+
declare function deriveKeyPbkdf2(password: string, salt: string | Buffer, iterations?: number): Buffer;
|
|
465
|
+
/**
|
|
466
|
+
* Derive a key from agent ID and salt (OpenClaw compatible)
|
|
467
|
+
*
|
|
468
|
+
* This method provides backward compatibility with OpenClaw's key derivation approach.
|
|
469
|
+
* For new implementations, prefer deriveKeyPbkdf2 or deriveKeyScrypt.
|
|
470
|
+
*
|
|
471
|
+
* @param agentId - The agent's unique identifier
|
|
472
|
+
* @param salt - Optional salt (defaults to 'default-salt')
|
|
473
|
+
* @returns The derived key as a Buffer
|
|
474
|
+
*/
|
|
475
|
+
declare function deriveKeyFromAgentId(agentId: string, salt?: string): Buffer;
|
|
476
|
+
/**
|
|
477
|
+
* Encrypt a value using the default algorithm (GCM)
|
|
478
|
+
*/
|
|
479
|
+
declare function encrypt(plaintext: string, key: Buffer, keyId?: string): EncryptedSecret;
|
|
480
|
+
/**
|
|
481
|
+
* Decrypt a value using the appropriate algorithm
|
|
482
|
+
*
|
|
483
|
+
* @param encrypted - The encrypted secret container (or raw string for backward compat)
|
|
484
|
+
* @param key - The decryption key (32 bytes)
|
|
485
|
+
* @returns The decrypted plaintext
|
|
486
|
+
*/
|
|
487
|
+
declare function decrypt(encrypted: EncryptedSecret | string, key: Buffer): string;
|
|
488
|
+
/**
|
|
489
|
+
* Check if a value appears to be an encrypted secret
|
|
490
|
+
*/
|
|
491
|
+
declare function isEncryptedSecret(value: unknown): value is EncryptedSecret;
|
|
492
|
+
/**
|
|
493
|
+
* Generate a secure random string for tokens, IDs, etc.
|
|
494
|
+
*/
|
|
495
|
+
declare function generateSecureToken(length?: number): string;
|
|
496
|
+
/**
|
|
497
|
+
* Manages encryption keys with support for rotation and multiple key IDs
|
|
498
|
+
*/
|
|
499
|
+
declare class KeyManager {
|
|
500
|
+
private keys;
|
|
501
|
+
private currentKeyId;
|
|
502
|
+
private derivationParams;
|
|
503
|
+
constructor(options?: {
|
|
504
|
+
primaryKey?: Buffer;
|
|
505
|
+
primaryKeyId?: string;
|
|
506
|
+
derivationParams?: KeyDerivationParams;
|
|
507
|
+
});
|
|
508
|
+
/**
|
|
509
|
+
* Initialize with a password-derived key
|
|
510
|
+
*/
|
|
511
|
+
initializeFromPassword(password: string, salt?: string): void;
|
|
512
|
+
/**
|
|
513
|
+
* Initialize with an agent ID (OpenClaw compatible)
|
|
514
|
+
*/
|
|
515
|
+
initializeFromAgentId(agentId: string, salt?: string): void;
|
|
516
|
+
/**
|
|
517
|
+
* Add a key for decryption (supports key rotation)
|
|
518
|
+
*/
|
|
519
|
+
addKey(keyId: string, key: Buffer): void;
|
|
520
|
+
/**
|
|
521
|
+
* Set the current key for encryption
|
|
522
|
+
*/
|
|
523
|
+
setCurrentKey(keyId: string): void;
|
|
524
|
+
/**
|
|
525
|
+
* Get the current key ID
|
|
526
|
+
*/
|
|
527
|
+
getCurrentKeyId(): string;
|
|
528
|
+
/**
|
|
529
|
+
* Get a key by ID
|
|
530
|
+
*/
|
|
531
|
+
getKey(keyId: string): Buffer | undefined;
|
|
532
|
+
/**
|
|
533
|
+
* Get the current encryption key
|
|
534
|
+
*/
|
|
535
|
+
getCurrentKey(): Buffer;
|
|
536
|
+
/**
|
|
537
|
+
* Get derivation parameters (for storage)
|
|
538
|
+
*/
|
|
539
|
+
getDerivationParams(): KeyDerivationParams | null;
|
|
540
|
+
/**
|
|
541
|
+
* Encrypt a value with the current key
|
|
542
|
+
*/
|
|
543
|
+
encrypt(plaintext: string): EncryptedSecret;
|
|
544
|
+
/**
|
|
545
|
+
* Decrypt a value (automatically selects the correct key)
|
|
546
|
+
*/
|
|
547
|
+
decrypt(encrypted: EncryptedSecret | string): string;
|
|
548
|
+
/**
|
|
549
|
+
* Re-encrypt a value with the current key (for key rotation)
|
|
550
|
+
*/
|
|
551
|
+
reencrypt(encrypted: EncryptedSecret): EncryptedSecret;
|
|
552
|
+
/**
|
|
553
|
+
* Clear all keys from memory
|
|
554
|
+
*/
|
|
555
|
+
clear(): void;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Storage Interface Definitions
|
|
560
|
+
*
|
|
561
|
+
* Defines the contract that all storage backends must implement.
|
|
562
|
+
* Designed for ElizaOS native storage patterns.
|
|
563
|
+
*/
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Abstract base class for secret storage implementations
|
|
567
|
+
*
|
|
568
|
+
* Provides common functionality and enforces the storage interface.
|
|
569
|
+
*/
|
|
570
|
+
declare abstract class BaseSecretStorage implements ISecretStorage {
|
|
571
|
+
abstract readonly storageType: StorageBackend;
|
|
572
|
+
abstract initialize(): Promise<void>;
|
|
573
|
+
abstract exists(key: string, context: SecretContext): Promise<boolean>;
|
|
574
|
+
abstract get(key: string, context: SecretContext): Promise<string | null>;
|
|
575
|
+
abstract set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
576
|
+
abstract delete(key: string, context: SecretContext): Promise<boolean>;
|
|
577
|
+
abstract list(context: SecretContext): Promise<SecretMetadata>;
|
|
578
|
+
abstract getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
579
|
+
abstract updateConfig(key: string, context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
580
|
+
/**
|
|
581
|
+
* Create a default secret configuration
|
|
582
|
+
*/
|
|
583
|
+
protected createDefaultConfig(key: string, context: SecretContext, partial?: Partial<SecretConfig>): SecretConfig;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Composite storage that delegates to multiple backends based on context
|
|
587
|
+
*/
|
|
588
|
+
declare class CompositeSecretStorage implements ISecretStorage {
|
|
589
|
+
readonly storageType: StorageBackend;
|
|
590
|
+
private globalStorage;
|
|
591
|
+
private worldStorage;
|
|
592
|
+
private userStorage;
|
|
593
|
+
constructor(options: {
|
|
594
|
+
globalStorage: ISecretStorage;
|
|
595
|
+
worldStorage: ISecretStorage;
|
|
596
|
+
userStorage: ISecretStorage;
|
|
597
|
+
});
|
|
598
|
+
initialize(): Promise<void>;
|
|
599
|
+
private getStorageForContext;
|
|
600
|
+
exists(key: string, context: SecretContext): Promise<boolean>;
|
|
601
|
+
get(key: string, context: SecretContext): Promise<string | null>;
|
|
602
|
+
set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
603
|
+
delete(key: string, context: SecretContext): Promise<boolean>;
|
|
604
|
+
list(context: SecretContext): Promise<SecretMetadata>;
|
|
605
|
+
getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
606
|
+
updateConfig(key: string, context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Memory-based Secret Storage
|
|
611
|
+
*
|
|
612
|
+
* In-memory storage backend for secrets. Useful for testing and
|
|
613
|
+
* ephemeral environments where persistence is not required.
|
|
614
|
+
*/
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Memory-based secret storage implementation
|
|
618
|
+
*/
|
|
619
|
+
declare class MemorySecretStorage extends BaseSecretStorage {
|
|
620
|
+
readonly storageType: StorageBackend;
|
|
621
|
+
private store;
|
|
622
|
+
initialize(): Promise<void>;
|
|
623
|
+
exists(key: string, context: SecretContext): Promise<boolean>;
|
|
624
|
+
get(key: string, context: SecretContext): Promise<string | null>;
|
|
625
|
+
set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
626
|
+
delete(key: string, context: SecretContext): Promise<boolean>;
|
|
627
|
+
list(context: SecretContext): Promise<SecretMetadata>;
|
|
628
|
+
getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
629
|
+
updateConfig(key: string, context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
630
|
+
/**
|
|
631
|
+
* Generate a storage key from the secret key and context
|
|
632
|
+
*/
|
|
633
|
+
private generateStorageKey;
|
|
634
|
+
/**
|
|
635
|
+
* Get the storage key prefix for a context level
|
|
636
|
+
*/
|
|
637
|
+
private getContextPrefix;
|
|
638
|
+
/**
|
|
639
|
+
* Extract the original key from a storage key
|
|
640
|
+
*/
|
|
641
|
+
private extractOriginalKey;
|
|
642
|
+
/**
|
|
643
|
+
* Clear all stored secrets (for testing)
|
|
644
|
+
*/
|
|
645
|
+
clear(): void;
|
|
646
|
+
/**
|
|
647
|
+
* Get the number of stored secrets (for testing)
|
|
648
|
+
*/
|
|
649
|
+
size(): number;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Character Settings Storage
|
|
654
|
+
*
|
|
655
|
+
* Stores global secrets in the character's settings.secrets object.
|
|
656
|
+
* This is the primary storage for agent-level configuration and API keys.
|
|
657
|
+
*
|
|
658
|
+
* Note: This implementation directly accesses character.settings rather than
|
|
659
|
+
* using getSetting()/setSetting() because those methods don't support object
|
|
660
|
+
* values - they only return primitives (string | boolean | number | null).
|
|
661
|
+
*/
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Character settings-based storage for global secrets
|
|
665
|
+
*
|
|
666
|
+
* Secrets are stored in character.settings.secrets with metadata
|
|
667
|
+
* tracked separately for configuration management.
|
|
668
|
+
*/
|
|
669
|
+
declare class CharacterSettingsStorage extends BaseSecretStorage {
|
|
670
|
+
readonly storageType: StorageBackend;
|
|
671
|
+
private runtime;
|
|
672
|
+
private keyManager;
|
|
673
|
+
private initialized;
|
|
674
|
+
constructor(runtime: IAgentRuntime, keyManager: KeyManager);
|
|
675
|
+
initialize(): Promise<void>;
|
|
676
|
+
/**
|
|
677
|
+
* Ensure the character.settings.secrets structure exists
|
|
678
|
+
*/
|
|
679
|
+
private ensureSettingsStructure;
|
|
680
|
+
exists(key: string, _context: SecretContext): Promise<boolean>;
|
|
681
|
+
get(key: string, context: SecretContext): Promise<string | null>;
|
|
682
|
+
set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
683
|
+
delete(key: string, _context: SecretContext): Promise<boolean>;
|
|
684
|
+
list(_context: SecretContext): Promise<SecretMetadata>;
|
|
685
|
+
getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
686
|
+
updateConfig(key: string, _context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
687
|
+
/**
|
|
688
|
+
* Get the secrets object from character settings
|
|
689
|
+
*
|
|
690
|
+
* Accesses character.settings.secrets directly instead of using getSetting()
|
|
691
|
+
* because getSetting() only returns primitives, not objects.
|
|
692
|
+
*/
|
|
693
|
+
private getSecretsObject;
|
|
694
|
+
/**
|
|
695
|
+
* Migrate legacy environment variable format to new format
|
|
696
|
+
*/
|
|
697
|
+
migrateFromEnvVars(envVarPrefix?: string): Promise<number>;
|
|
698
|
+
/**
|
|
699
|
+
* Get a secret as an environment variable (for backward compatibility)
|
|
700
|
+
*/
|
|
701
|
+
getAsEnvVar(key: string): Promise<string | null>;
|
|
702
|
+
/**
|
|
703
|
+
* Sync a secret to process.env (for plugins that read env vars directly)
|
|
704
|
+
*/
|
|
705
|
+
syncToEnv(key: string, envVarName?: string): Promise<boolean>;
|
|
706
|
+
/**
|
|
707
|
+
* Sync all secrets to process.env
|
|
708
|
+
*/
|
|
709
|
+
syncAllToEnv(): Promise<number>;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* World Metadata Storage
|
|
714
|
+
*
|
|
715
|
+
* Stores world-level secrets in the world's metadata.secrets object.
|
|
716
|
+
* This is used for server/channel-specific configuration like Discord tokens.
|
|
717
|
+
*/
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* World metadata-based storage for world-level secrets
|
|
721
|
+
*
|
|
722
|
+
* Secrets are stored in world.metadata.secrets with access control
|
|
723
|
+
* based on world roles (OWNER/ADMIN can write, all members can read).
|
|
724
|
+
*/
|
|
725
|
+
declare class WorldMetadataStorage extends BaseSecretStorage {
|
|
726
|
+
readonly storageType: StorageBackend;
|
|
727
|
+
private runtime;
|
|
728
|
+
private keyManager;
|
|
729
|
+
private worldCache;
|
|
730
|
+
constructor(runtime: IAgentRuntime, keyManager: KeyManager);
|
|
731
|
+
initialize(): Promise<void>;
|
|
732
|
+
exists(key: string, context: SecretContext): Promise<boolean>;
|
|
733
|
+
get(key: string, context: SecretContext): Promise<string | null>;
|
|
734
|
+
set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
735
|
+
delete(key: string, context: SecretContext): Promise<boolean>;
|
|
736
|
+
list(context: SecretContext): Promise<SecretMetadata>;
|
|
737
|
+
getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
738
|
+
updateConfig(key: string, context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
739
|
+
/**
|
|
740
|
+
* Get a world from cache or database
|
|
741
|
+
*/
|
|
742
|
+
private getWorld;
|
|
743
|
+
/**
|
|
744
|
+
* Get secrets object from world metadata
|
|
745
|
+
*/
|
|
746
|
+
private getWorldSecrets;
|
|
747
|
+
/**
|
|
748
|
+
* Check if a user has write permission in a world
|
|
749
|
+
*/
|
|
750
|
+
private checkWritePermission;
|
|
751
|
+
/**
|
|
752
|
+
* Clear the world cache
|
|
753
|
+
*/
|
|
754
|
+
clearCache(): void;
|
|
755
|
+
/**
|
|
756
|
+
* Invalidate a specific world in the cache
|
|
757
|
+
*/
|
|
758
|
+
invalidateWorld(worldId: string): void;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Component Storage
|
|
763
|
+
*
|
|
764
|
+
* Stores user-level secrets as Components in the ElizaOS database.
|
|
765
|
+
* Each user's secrets are isolated via the component's entityId.
|
|
766
|
+
*/
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Component-based storage for user-level secrets
|
|
770
|
+
*
|
|
771
|
+
* Each secret is stored as a Component with type='secret' and entityId
|
|
772
|
+
* set to the user's ID, providing natural isolation per user.
|
|
773
|
+
*/
|
|
774
|
+
declare class ComponentSecretStorage extends BaseSecretStorage {
|
|
775
|
+
readonly storageType: StorageBackend;
|
|
776
|
+
private runtime;
|
|
777
|
+
private keyManager;
|
|
778
|
+
constructor(runtime: IAgentRuntime, keyManager: KeyManager);
|
|
779
|
+
initialize(): Promise<void>;
|
|
780
|
+
exists(key: string, context: SecretContext): Promise<boolean>;
|
|
781
|
+
get(key: string, context: SecretContext): Promise<string | null>;
|
|
782
|
+
set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
783
|
+
delete(key: string, context: SecretContext): Promise<boolean>;
|
|
784
|
+
list(context: SecretContext): Promise<SecretMetadata>;
|
|
785
|
+
getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
786
|
+
updateConfig(key: string, context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
787
|
+
/**
|
|
788
|
+
* Find a secret component for a user by key
|
|
789
|
+
*/
|
|
790
|
+
private findSecretComponent;
|
|
791
|
+
/**
|
|
792
|
+
* Get all secret keys for a user
|
|
793
|
+
*/
|
|
794
|
+
listKeys(userId: string): Promise<string[]>;
|
|
795
|
+
/**
|
|
796
|
+
* Delete all secrets for a user
|
|
797
|
+
*/
|
|
798
|
+
deleteAllForUser(userId: string): Promise<number>;
|
|
799
|
+
/**
|
|
800
|
+
* Count secrets for a user
|
|
801
|
+
*/
|
|
802
|
+
countForUser(userId: string): Promise<number>;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Secrets Service
|
|
807
|
+
*
|
|
808
|
+
* Core service for multi-level secret management in ElizaOS.
|
|
809
|
+
* Provides unified API for accessing global, world, and user secrets
|
|
810
|
+
* with encryption, access control, and change notification support.
|
|
811
|
+
*/
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Service type identifier
|
|
815
|
+
*/
|
|
816
|
+
declare const SECRETS_SERVICE_TYPE: ServiceTypeName;
|
|
817
|
+
/**
|
|
818
|
+
* Secrets Service
|
|
819
|
+
*
|
|
820
|
+
* Unified service for managing secrets at all levels:
|
|
821
|
+
* - Global: Stored in character settings (agent-wide config, API keys)
|
|
822
|
+
* - World: Stored in world metadata (server/channel-specific)
|
|
823
|
+
* - User: Stored as components (per-user secrets)
|
|
824
|
+
*/
|
|
825
|
+
declare class SecretsService extends Service {
|
|
826
|
+
static serviceType: ServiceTypeName;
|
|
827
|
+
capabilityDescription: string;
|
|
828
|
+
private secretsConfig;
|
|
829
|
+
private keyManager;
|
|
830
|
+
private storage;
|
|
831
|
+
private globalStorage;
|
|
832
|
+
private worldStorage;
|
|
833
|
+
private userStorage;
|
|
834
|
+
private accessLogs;
|
|
835
|
+
private changeCallbacks;
|
|
836
|
+
private globalChangeCallbacks;
|
|
837
|
+
constructor(runtime?: IAgentRuntime, config?: Partial<SecretsServiceConfig>);
|
|
838
|
+
/**
|
|
839
|
+
* Start the service
|
|
840
|
+
*/
|
|
841
|
+
static start(runtime: IAgentRuntime, config?: Partial<SecretsServiceConfig>): Promise<SecretsService>;
|
|
842
|
+
/**
|
|
843
|
+
* Initialize the service
|
|
844
|
+
*/
|
|
845
|
+
private initialize;
|
|
846
|
+
/**
|
|
847
|
+
* Stop the service
|
|
848
|
+
*/
|
|
849
|
+
stop(): Promise<void>;
|
|
850
|
+
/**
|
|
851
|
+
* Get a secret value
|
|
852
|
+
*/
|
|
853
|
+
get(key: string, context: SecretContext): Promise<string | null>;
|
|
854
|
+
/**
|
|
855
|
+
* Set a secret value
|
|
856
|
+
*/
|
|
857
|
+
set(key: string, value: string, context: SecretContext, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
858
|
+
/**
|
|
859
|
+
* Delete a secret
|
|
860
|
+
*/
|
|
861
|
+
delete(key: string, context: SecretContext): Promise<boolean>;
|
|
862
|
+
/**
|
|
863
|
+
* Check if a secret exists
|
|
864
|
+
*/
|
|
865
|
+
exists(key: string, context: SecretContext): Promise<boolean>;
|
|
866
|
+
/**
|
|
867
|
+
* List secrets (metadata only, no values)
|
|
868
|
+
*/
|
|
869
|
+
list(context: SecretContext): Promise<SecretMetadata>;
|
|
870
|
+
/**
|
|
871
|
+
* Get secret configuration
|
|
872
|
+
*/
|
|
873
|
+
getConfig(key: string, context: SecretContext): Promise<SecretConfig | null>;
|
|
874
|
+
/**
|
|
875
|
+
* Update secret configuration
|
|
876
|
+
*/
|
|
877
|
+
updateConfig(key: string, context: SecretContext, config: Partial<SecretConfig>): Promise<boolean>;
|
|
878
|
+
/**
|
|
879
|
+
* Get a global secret (agent-level)
|
|
880
|
+
*/
|
|
881
|
+
getGlobal(key: string): Promise<string | null>;
|
|
882
|
+
/**
|
|
883
|
+
* Set a global secret (agent-level)
|
|
884
|
+
*/
|
|
885
|
+
setGlobal(key: string, value: string, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
886
|
+
/**
|
|
887
|
+
* Get a world secret
|
|
888
|
+
*/
|
|
889
|
+
getWorld(key: string, worldId: string): Promise<string | null>;
|
|
890
|
+
/**
|
|
891
|
+
* Set a world secret
|
|
892
|
+
*/
|
|
893
|
+
setWorld(key: string, value: string, worldId: string, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
894
|
+
/**
|
|
895
|
+
* Get a user secret
|
|
896
|
+
*/
|
|
897
|
+
getUser(key: string, userId: string): Promise<string | null>;
|
|
898
|
+
/**
|
|
899
|
+
* Set a user secret
|
|
900
|
+
*/
|
|
901
|
+
setUser(key: string, value: string, userId: string, config?: Partial<SecretConfig>): Promise<boolean>;
|
|
902
|
+
/**
|
|
903
|
+
* Validate a secret value
|
|
904
|
+
*/
|
|
905
|
+
validate(key: string, value: string, strategy?: string): Promise<ValidationResult>;
|
|
906
|
+
/**
|
|
907
|
+
* Get available validation strategies
|
|
908
|
+
*/
|
|
909
|
+
getValidationStrategies(): string[];
|
|
910
|
+
/**
|
|
911
|
+
* Check which secrets are missing for a plugin
|
|
912
|
+
*/
|
|
913
|
+
checkPluginRequirements(pluginId: string, requirements: Record<string, PluginSecretRequirement>): Promise<{
|
|
914
|
+
ready: boolean;
|
|
915
|
+
missingRequired: string[];
|
|
916
|
+
missingOptional: string[];
|
|
917
|
+
invalid: string[];
|
|
918
|
+
}>;
|
|
919
|
+
/**
|
|
920
|
+
* Get missing secrets for a set of keys
|
|
921
|
+
*/
|
|
922
|
+
getMissingSecrets(keys: string[], level?: "global" | "world" | "user"): Promise<string[]>;
|
|
923
|
+
/**
|
|
924
|
+
* Register a callback for changes to a specific secret
|
|
925
|
+
*/
|
|
926
|
+
onSecretChanged(key: string, callback: SecretChangeCallback): () => void;
|
|
927
|
+
/**
|
|
928
|
+
* Register a callback for all secret changes
|
|
929
|
+
*/
|
|
930
|
+
onAnySecretChanged(callback: SecretChangeCallback): () => void;
|
|
931
|
+
/**
|
|
932
|
+
* Emit a change event to registered callbacks
|
|
933
|
+
*/
|
|
934
|
+
private emitChangeEvent;
|
|
935
|
+
/**
|
|
936
|
+
* Log a secret access attempt
|
|
937
|
+
*/
|
|
938
|
+
private logAccess;
|
|
939
|
+
/**
|
|
940
|
+
* Get access logs
|
|
941
|
+
*/
|
|
942
|
+
getAccessLogs(filter?: {
|
|
943
|
+
key?: string;
|
|
944
|
+
action?: string;
|
|
945
|
+
context?: Partial<SecretContext>;
|
|
946
|
+
since?: number;
|
|
947
|
+
}): SecretAccessLog[];
|
|
948
|
+
/**
|
|
949
|
+
* Clear access logs
|
|
950
|
+
*/
|
|
951
|
+
clearAccessLogs(): void;
|
|
952
|
+
/**
|
|
953
|
+
* Get the global storage backend
|
|
954
|
+
*/
|
|
955
|
+
getGlobalStorage(): CharacterSettingsStorage;
|
|
956
|
+
/**
|
|
957
|
+
* Get the world storage backend
|
|
958
|
+
*/
|
|
959
|
+
getWorldStorage(): WorldMetadataStorage;
|
|
960
|
+
/**
|
|
961
|
+
* Get the user storage backend
|
|
962
|
+
*/
|
|
963
|
+
getUserStorage(): ComponentSecretStorage;
|
|
964
|
+
/**
|
|
965
|
+
* Get the key manager (for advanced use cases)
|
|
966
|
+
*/
|
|
967
|
+
getKeyManager(): KeyManager;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Plugin Activator Service
|
|
972
|
+
*
|
|
973
|
+
* Enables dynamic plugin activation when required secrets become available.
|
|
974
|
+
* Plugins can register for activation with their secret requirements,
|
|
975
|
+
* and will be activated automatically once all secrets are present.
|
|
976
|
+
*/
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Service type identifier
|
|
980
|
+
*/
|
|
981
|
+
declare const PLUGIN_ACTIVATOR_SERVICE_TYPE: ServiceTypeName;
|
|
982
|
+
/**
|
|
983
|
+
* Extended Plugin interface with secret requirements
|
|
984
|
+
*/
|
|
985
|
+
interface PluginWithSecrets extends Plugin {
|
|
986
|
+
/** Required secrets for this plugin to function */
|
|
987
|
+
requiredSecrets?: Record<string, PluginSecretRequirement>;
|
|
988
|
+
/** Called when all required secrets become available */
|
|
989
|
+
onSecretsReady?: (runtime: IAgentRuntime) => Promise<void>;
|
|
990
|
+
/** Called when a required secret changes */
|
|
991
|
+
onSecretChanged?: (key: string, value: string | null, runtime: IAgentRuntime) => Promise<void>;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Plugin Activator Service
|
|
995
|
+
*
|
|
996
|
+
* Manages the lifecycle of plugins that depend on secrets:
|
|
997
|
+
* - Tracks plugins waiting for secrets
|
|
998
|
+
* - Automatically activates plugins when requirements are met
|
|
999
|
+
* - Notifies plugins when their secrets change
|
|
1000
|
+
*/
|
|
1001
|
+
declare class PluginActivatorService extends Service {
|
|
1002
|
+
static serviceType: ServiceTypeName;
|
|
1003
|
+
capabilityDescription: string;
|
|
1004
|
+
private activatorConfig;
|
|
1005
|
+
private secretsService;
|
|
1006
|
+
private pendingPlugins;
|
|
1007
|
+
private activatedPlugins;
|
|
1008
|
+
private pluginSecretMapping;
|
|
1009
|
+
private pollingInterval;
|
|
1010
|
+
private unsubscribeSecretChanges;
|
|
1011
|
+
constructor(runtime?: IAgentRuntime, config?: Partial<PluginActivatorConfig>);
|
|
1012
|
+
/**
|
|
1013
|
+
* Start the service
|
|
1014
|
+
*/
|
|
1015
|
+
static start(runtime: IAgentRuntime, config?: Partial<PluginActivatorConfig>): Promise<PluginActivatorService>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Initialize the service
|
|
1018
|
+
*/
|
|
1019
|
+
private initialize;
|
|
1020
|
+
/**
|
|
1021
|
+
* Stop the service
|
|
1022
|
+
*/
|
|
1023
|
+
stop(): Promise<void>;
|
|
1024
|
+
/**
|
|
1025
|
+
* Register a plugin for activation when secrets are ready
|
|
1026
|
+
*/
|
|
1027
|
+
registerPlugin(plugin: PluginWithSecrets, activationCallback?: () => Promise<void>): Promise<boolean>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Unregister a pending plugin
|
|
1030
|
+
*/
|
|
1031
|
+
unregisterPlugin(pluginId: string): boolean;
|
|
1032
|
+
/**
|
|
1033
|
+
* Activate a plugin
|
|
1034
|
+
*/
|
|
1035
|
+
private activatePlugin;
|
|
1036
|
+
/**
|
|
1037
|
+
* Check requirements for a plugin
|
|
1038
|
+
*/
|
|
1039
|
+
checkPluginRequirements(plugin: PluginWithSecrets): Promise<PluginRequirementStatus>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Get status of all registered plugins
|
|
1042
|
+
*/
|
|
1043
|
+
getPluginStatuses(): Map<string, {
|
|
1044
|
+
pending: boolean;
|
|
1045
|
+
activated: boolean;
|
|
1046
|
+
missingSecrets: string[];
|
|
1047
|
+
}>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Handle secret change event
|
|
1050
|
+
*/
|
|
1051
|
+
private onSecretChanged;
|
|
1052
|
+
/**
|
|
1053
|
+
* Get missing secrets from a list
|
|
1054
|
+
*/
|
|
1055
|
+
private getMissingSecrets;
|
|
1056
|
+
/**
|
|
1057
|
+
* Start polling for pending plugins
|
|
1058
|
+
*/
|
|
1059
|
+
private startPolling;
|
|
1060
|
+
/**
|
|
1061
|
+
* Stop polling
|
|
1062
|
+
*/
|
|
1063
|
+
private stopPolling;
|
|
1064
|
+
/**
|
|
1065
|
+
* Check all pending plugins
|
|
1066
|
+
*/
|
|
1067
|
+
private checkPendingPlugins;
|
|
1068
|
+
/**
|
|
1069
|
+
* Get list of pending plugins
|
|
1070
|
+
*/
|
|
1071
|
+
getPendingPlugins(): string[];
|
|
1072
|
+
/**
|
|
1073
|
+
* Get list of activated plugins
|
|
1074
|
+
*/
|
|
1075
|
+
getActivatedPlugins(): string[];
|
|
1076
|
+
/**
|
|
1077
|
+
* Check if a plugin is pending
|
|
1078
|
+
*/
|
|
1079
|
+
isPending(pluginId: string): boolean;
|
|
1080
|
+
/**
|
|
1081
|
+
* Check if a plugin is activated
|
|
1082
|
+
*/
|
|
1083
|
+
isActivated(pluginId: string): boolean;
|
|
1084
|
+
/**
|
|
1085
|
+
* Get secrets required by pending plugins
|
|
1086
|
+
*/
|
|
1087
|
+
getRequiredSecrets(): Set<string>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Get plugins waiting for a specific secret
|
|
1090
|
+
*/
|
|
1091
|
+
getPluginsWaitingFor(secretKey: string): string[];
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Onboarding configuration types and utilities.
|
|
1096
|
+
*
|
|
1097
|
+
* Provides the structure for defining secret requirements per agent/plugin,
|
|
1098
|
+
* supporting both conversational and form-based collection flows.
|
|
1099
|
+
*/
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Setting definition for onboarding.
|
|
1103
|
+
* Compatible with the-org OnboardingConfig format.
|
|
1104
|
+
*/
|
|
1105
|
+
interface OnboardingSetting {
|
|
1106
|
+
/** Display name */
|
|
1107
|
+
name: string;
|
|
1108
|
+
/** Description for LLM context */
|
|
1109
|
+
description: string;
|
|
1110
|
+
/** Prompt shown when asking user for this setting */
|
|
1111
|
+
usageDescription?: string;
|
|
1112
|
+
/** Whether this is a secret (should be encrypted) */
|
|
1113
|
+
secret: boolean;
|
|
1114
|
+
/** Whether this should be visible in non-onboarding contexts */
|
|
1115
|
+
public: boolean;
|
|
1116
|
+
/** Whether this setting is required */
|
|
1117
|
+
required: boolean;
|
|
1118
|
+
/** Settings that must be configured first */
|
|
1119
|
+
dependsOn: string[];
|
|
1120
|
+
/** Validation function */
|
|
1121
|
+
validation?: (value: string) => boolean;
|
|
1122
|
+
/** Validation method name (openai, anthropic, url, etc.) */
|
|
1123
|
+
validationMethod?: string;
|
|
1124
|
+
/** Secret type */
|
|
1125
|
+
type?: SecretType;
|
|
1126
|
+
/** Environment variable to sync to */
|
|
1127
|
+
envVar?: string;
|
|
1128
|
+
/** Default value if not set */
|
|
1129
|
+
defaultValue?: string;
|
|
1130
|
+
/** Current value (set during onboarding) */
|
|
1131
|
+
value?: string | null;
|
|
1132
|
+
/** Conditional visibility based on other settings */
|
|
1133
|
+
visibleIf?: (settings: Record<string, OnboardingSetting>) => boolean;
|
|
1134
|
+
/** Callback when value is set */
|
|
1135
|
+
onSetAction?: (value: string | boolean) => string | void;
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Onboarding configuration for an agent or plugin.
|
|
1139
|
+
*/
|
|
1140
|
+
interface OnboardingConfig {
|
|
1141
|
+
/** Setting definitions */
|
|
1142
|
+
settings: Record<string, OnboardingSetting>;
|
|
1143
|
+
/** Optional platform-specific messages */
|
|
1144
|
+
messages?: {
|
|
1145
|
+
welcome?: string[];
|
|
1146
|
+
askSetting?: string;
|
|
1147
|
+
settingUpdated?: string;
|
|
1148
|
+
allComplete?: string;
|
|
1149
|
+
error?: string;
|
|
1150
|
+
};
|
|
1151
|
+
/** Onboarding flow mode */
|
|
1152
|
+
mode?: "conversational" | "form" | "hybrid";
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Default onboarding messages.
|
|
1156
|
+
*/
|
|
1157
|
+
declare const DEFAULT_ONBOARDING_MESSAGES: {
|
|
1158
|
+
welcome: string[];
|
|
1159
|
+
askSetting: string;
|
|
1160
|
+
settingUpdated: string;
|
|
1161
|
+
allComplete: string;
|
|
1162
|
+
error: string;
|
|
1163
|
+
};
|
|
1164
|
+
/**
|
|
1165
|
+
* Common API key settings for quick setup.
|
|
1166
|
+
*/
|
|
1167
|
+
declare const COMMON_API_KEY_SETTINGS: Record<string, Partial<OnboardingSetting>>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Create an onboarding config from a list of required secret keys.
|
|
1170
|
+
*/
|
|
1171
|
+
declare function createOnboardingConfig(requiredKeys: string[], optionalKeys?: string[], customSettings?: Record<string, Partial<OnboardingSetting>>): OnboardingConfig;
|
|
1172
|
+
/**
|
|
1173
|
+
* Get unconfigured required settings from an onboarding config.
|
|
1174
|
+
*/
|
|
1175
|
+
declare function getUnconfiguredRequired(config: OnboardingConfig): Array<[string, OnboardingSetting]>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Get unconfigured optional settings from an onboarding config.
|
|
1178
|
+
*/
|
|
1179
|
+
declare function getUnconfiguredOptional(config: OnboardingConfig): Array<[string, OnboardingSetting]>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Check if all required settings are configured.
|
|
1182
|
+
*/
|
|
1183
|
+
declare function isOnboardingComplete(config: OnboardingConfig): boolean;
|
|
1184
|
+
/**
|
|
1185
|
+
* Get the next setting to configure (respects dependencies).
|
|
1186
|
+
*/
|
|
1187
|
+
declare function getNextSetting(config: OnboardingConfig): [string, OnboardingSetting] | null;
|
|
1188
|
+
/**
|
|
1189
|
+
* Generate a prompt for the LLM to ask for a specific setting.
|
|
1190
|
+
*/
|
|
1191
|
+
declare function generateSettingPrompt(key: string, setting: OnboardingSetting, agentName: string): string;
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Onboarding Service
|
|
1195
|
+
*
|
|
1196
|
+
* Manages the secrets onboarding flow across platforms (Discord, Telegram, etc.)
|
|
1197
|
+
* Supports both conversational and form-based collection modes.
|
|
1198
|
+
*/
|
|
1199
|
+
|
|
1200
|
+
declare const ONBOARDING_SERVICE_TYPE: ServiceTypeName;
|
|
1201
|
+
/**
|
|
1202
|
+
* Onboarding session state.
|
|
1203
|
+
*/
|
|
1204
|
+
interface OnboardingSession {
|
|
1205
|
+
worldId: UUID;
|
|
1206
|
+
userId: UUID;
|
|
1207
|
+
roomId: UUID;
|
|
1208
|
+
config: OnboardingConfig;
|
|
1209
|
+
currentSettingKey: string | null;
|
|
1210
|
+
startedAt: number;
|
|
1211
|
+
lastActivityAt: number;
|
|
1212
|
+
platform: "discord" | "telegram" | "other";
|
|
1213
|
+
mode: "conversational" | "form" | "hybrid";
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Onboarding Service for secrets collection.
|
|
1217
|
+
*/
|
|
1218
|
+
declare class OnboardingService extends Service {
|
|
1219
|
+
static serviceType: ServiceTypeName;
|
|
1220
|
+
capabilityDescription: string;
|
|
1221
|
+
private secretsService;
|
|
1222
|
+
private sessions;
|
|
1223
|
+
constructor(runtime?: IAgentRuntime);
|
|
1224
|
+
/**
|
|
1225
|
+
* Start the service
|
|
1226
|
+
*/
|
|
1227
|
+
static start(runtime: IAgentRuntime): Promise<OnboardingService>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Initialize the service
|
|
1230
|
+
*/
|
|
1231
|
+
private initialize;
|
|
1232
|
+
stop(): Promise<void>;
|
|
1233
|
+
/**
|
|
1234
|
+
* Register platform-specific event handlers.
|
|
1235
|
+
*/
|
|
1236
|
+
private registerEvents;
|
|
1237
|
+
/**
|
|
1238
|
+
* Initialize onboarding for a world with the given config.
|
|
1239
|
+
*/
|
|
1240
|
+
initializeOnboarding(world: World, config: OnboardingConfig): Promise<void>;
|
|
1241
|
+
/**
|
|
1242
|
+
* Start onboarding via DM (Discord).
|
|
1243
|
+
*/
|
|
1244
|
+
startDiscordOnboardingDM(serverId: string, ownerId: string, worldId: UUID, config: OnboardingConfig): Promise<void>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Start onboarding via deep link (Telegram).
|
|
1247
|
+
*/
|
|
1248
|
+
startTelegramOnboarding(world: World, chat: {
|
|
1249
|
+
id: string | number;
|
|
1250
|
+
}, entities: Array<{
|
|
1251
|
+
metadata?: {
|
|
1252
|
+
telegram?: {
|
|
1253
|
+
id: string;
|
|
1254
|
+
username: string;
|
|
1255
|
+
adminTitle?: string;
|
|
1256
|
+
};
|
|
1257
|
+
};
|
|
1258
|
+
}>, botUsername: string): Promise<void>;
|
|
1259
|
+
/**
|
|
1260
|
+
* Start a new onboarding session.
|
|
1261
|
+
*/
|
|
1262
|
+
startSession(worldId: UUID, userId: UUID, roomId: UUID, config: OnboardingConfig, platform?: "discord" | "telegram" | "other", mode?: "conversational" | "form" | "hybrid"): Promise<OnboardingSession>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Get an active session by room ID.
|
|
1265
|
+
*/
|
|
1266
|
+
getSession(roomId: UUID): OnboardingSession | null;
|
|
1267
|
+
/**
|
|
1268
|
+
* Process a user message during onboarding.
|
|
1269
|
+
*/
|
|
1270
|
+
processMessage(roomId: UUID, message: Memory): Promise<{
|
|
1271
|
+
shouldRespond: boolean;
|
|
1272
|
+
response?: string;
|
|
1273
|
+
updatedKey?: string;
|
|
1274
|
+
complete?: boolean;
|
|
1275
|
+
}>;
|
|
1276
|
+
/**
|
|
1277
|
+
* End an onboarding session.
|
|
1278
|
+
*/
|
|
1279
|
+
endSession(roomId: UUID): void;
|
|
1280
|
+
/**
|
|
1281
|
+
* Get the onboarding status for a world.
|
|
1282
|
+
*/
|
|
1283
|
+
getOnboardingStatus(worldId: UUID): Promise<{
|
|
1284
|
+
initialized: boolean;
|
|
1285
|
+
complete: boolean;
|
|
1286
|
+
configuredCount: number;
|
|
1287
|
+
requiredCount: number;
|
|
1288
|
+
missingRequired: string[];
|
|
1289
|
+
}>;
|
|
1290
|
+
/**
|
|
1291
|
+
* Generate the SETTINGS provider context for LLM.
|
|
1292
|
+
*/
|
|
1293
|
+
generateSettingsContext(config: OnboardingConfig, isOnboarding: boolean, agentName: string): string;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* Onboarding Provider
|
|
1298
|
+
*
|
|
1299
|
+
* Provides onboarding status and context to the LLM during secret collection.
|
|
1300
|
+
* Injects prompts about required settings into the agent's context.
|
|
1301
|
+
*/
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* Onboarding settings provider - injects onboarding context into LLM prompts.
|
|
1305
|
+
*/
|
|
1306
|
+
declare const onboardingSettingsProvider: Provider;
|
|
1307
|
+
/**
|
|
1308
|
+
* Provider that shows what secrets are still needed.
|
|
1309
|
+
*/
|
|
1310
|
+
declare const missingSecretsProvider: Provider;
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Update Settings Action
|
|
1314
|
+
*
|
|
1315
|
+
* Extracts and saves setting values from natural language user messages.
|
|
1316
|
+
* Uses LLM to parse user responses and map them to settings.
|
|
1317
|
+
*/
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* UPDATE_SETTINGS Action - extracts and saves settings from natural language.
|
|
1321
|
+
*/
|
|
1322
|
+
declare const updateSettingsAction: Action;
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Secret Validation Module
|
|
1326
|
+
*
|
|
1327
|
+
* Provides validation strategies for different types of secrets
|
|
1328
|
+
* including API keys, URLs, and custom validation.
|
|
1329
|
+
*/
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Validation strategy implementations
|
|
1333
|
+
*/
|
|
1334
|
+
declare const ValidationStrategies: Record<string, CustomValidator>;
|
|
1335
|
+
/**
|
|
1336
|
+
* Register a custom validator
|
|
1337
|
+
*/
|
|
1338
|
+
declare function registerValidator(name: string, validator: CustomValidator): void;
|
|
1339
|
+
/**
|
|
1340
|
+
* Unregister a custom validator
|
|
1341
|
+
*/
|
|
1342
|
+
declare function unregisterValidator(name: string): boolean;
|
|
1343
|
+
/**
|
|
1344
|
+
* Validate a secret value
|
|
1345
|
+
*/
|
|
1346
|
+
declare function validateSecret(key: string, value: string, strategy?: string): Promise<ValidationResult>;
|
|
1347
|
+
/**
|
|
1348
|
+
* Infer validation strategy from secret key name
|
|
1349
|
+
*/
|
|
1350
|
+
declare function inferValidationStrategy(key: string): ValidationStrategy;
|
|
1351
|
+
|
|
1352
|
+
/**
|
|
1353
|
+
* Secrets Manager Plugin
|
|
1354
|
+
*
|
|
1355
|
+
* Comprehensive secret management for ElizaOS with:
|
|
1356
|
+
* - Multi-level storage (global, world, user)
|
|
1357
|
+
* - Encryption at rest
|
|
1358
|
+
* - Dynamic plugin activation when secrets become available
|
|
1359
|
+
* - Natural language secret management
|
|
1360
|
+
* - Conversational onboarding flow (Discord, Telegram)
|
|
1361
|
+
*/
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Plugin configuration
|
|
1365
|
+
*/
|
|
1366
|
+
interface SecretsManagerPluginConfig {
|
|
1367
|
+
/** Enable encryption for stored secrets (default: true) */
|
|
1368
|
+
enableEncryption?: boolean;
|
|
1369
|
+
/** Custom salt for encryption key derivation */
|
|
1370
|
+
encryptionSalt?: string;
|
|
1371
|
+
/** Enable access logging (default: true) */
|
|
1372
|
+
enableAccessLogging?: boolean;
|
|
1373
|
+
/** Enable automatic plugin activation when secrets are available (default: true) */
|
|
1374
|
+
enableAutoActivation?: boolean;
|
|
1375
|
+
/** Polling interval for checking plugin requirements (ms, default: 5000) */
|
|
1376
|
+
activationPollingMs?: number;
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* Secrets Manager Plugin
|
|
1380
|
+
*
|
|
1381
|
+
* Provides comprehensive secret management capabilities:
|
|
1382
|
+
*
|
|
1383
|
+
* **Storage Levels:**
|
|
1384
|
+
* - Global: Agent-wide secrets (API keys, tokens) stored in character settings
|
|
1385
|
+
* - World: Server/channel-specific secrets stored in world metadata
|
|
1386
|
+
* - User: Per-user secrets stored as components
|
|
1387
|
+
*
|
|
1388
|
+
* **Features:**
|
|
1389
|
+
* - Automatic encryption using AES-256-GCM
|
|
1390
|
+
* - Natural language secret management via actions
|
|
1391
|
+
* - Plugin activation when required secrets become available
|
|
1392
|
+
* - Access logging and auditing
|
|
1393
|
+
* - Backward compatibility with ENV_ prefixed settings
|
|
1394
|
+
*
|
|
1395
|
+
* **Usage:**
|
|
1396
|
+
* ```typescript
|
|
1397
|
+
* import { secretsManagerPlugin } from '@elizaos/plugin-secrets-manager';
|
|
1398
|
+
*
|
|
1399
|
+
* const runtime = createAgentRuntime({
|
|
1400
|
+
* plugins: [secretsManagerPlugin],
|
|
1401
|
+
* });
|
|
1402
|
+
*
|
|
1403
|
+
* // Get the secrets service
|
|
1404
|
+
* const secrets = runtime.getService<SecretsService>('SECRETS');
|
|
1405
|
+
*
|
|
1406
|
+
* // Set a global secret
|
|
1407
|
+
* await secrets.setGlobal('OPENAI_API_KEY', 'sk-...');
|
|
1408
|
+
*
|
|
1409
|
+
* // Get a global secret
|
|
1410
|
+
* const apiKey = await secrets.getGlobal('OPENAI_API_KEY');
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
declare const secretsManagerPlugin: Plugin;
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* Set Secret Action
|
|
1417
|
+
*
|
|
1418
|
+
* Allows the agent to set secrets from user input through natural language.
|
|
1419
|
+
* Extracts key-value pairs and stores them at the appropriate level.
|
|
1420
|
+
*/
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* Set Secret Action
|
|
1424
|
+
*/
|
|
1425
|
+
declare const setSecretAction: Action;
|
|
1426
|
+
|
|
1427
|
+
/**
|
|
1428
|
+
* Manage Secret Action
|
|
1429
|
+
*
|
|
1430
|
+
* Comprehensive action for managing secrets through natural language.
|
|
1431
|
+
* Supports get, set, delete, and list operations at different levels.
|
|
1432
|
+
*/
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* Manage Secret Action
|
|
1436
|
+
*/
|
|
1437
|
+
declare const manageSecretAction: Action;
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Secrets Status Provider
|
|
1441
|
+
*
|
|
1442
|
+
* Provides context about the agent's secret configuration status
|
|
1443
|
+
* to help the LLM understand what capabilities are available.
|
|
1444
|
+
*/
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Secrets Status Provider
|
|
1448
|
+
*
|
|
1449
|
+
* Adds information about configured secrets to the agent's context,
|
|
1450
|
+
* without exposing actual secret values.
|
|
1451
|
+
*/
|
|
1452
|
+
declare const secretsStatusProvider: Provider;
|
|
1453
|
+
/**
|
|
1454
|
+
* Secrets Info Provider
|
|
1455
|
+
*
|
|
1456
|
+
* Provides detailed information about specific secrets when relevant
|
|
1457
|
+
* to the current conversation context.
|
|
1458
|
+
*/
|
|
1459
|
+
declare const secretsInfoProvider: Provider;
|
|
1460
|
+
|
|
1461
|
+
export { BaseSecretStorage, COMMON_API_KEY_SETTINGS, CharacterSettingsStorage, ComponentSecretStorage, CompositeSecretStorage, type CustomValidator, DEFAULT_ONBOARDING_MESSAGES, type EncryptedSecret, EncryptionError, type FormField, type FormFieldType, type FormSchema, type FormSession, type FormSubmission, type FormValidationRule, type GenerationScript, type ISecretStorage, type KeyDerivationParams, KeyManager, MAX_ACCESS_LOG_ENTRIES, MemorySecretStorage, ONBOARDING_SERVICE_TYPE, type OnboardingConfig, OnboardingService, type OnboardingSetting, PLUGIN_ACTIVATOR_SERVICE_TYPE, type PendingPluginActivation, PermissionDeniedError, type PluginActivationEvent, type PluginActivatorConfig, PluginActivatorService, type PluginRequirementStatus, type PluginSecretRequirement, type PluginWithSecrets, SECRETS_SERVICE_TYPE, SECRET_DESCRIPTION_MAX_LENGTH, SECRET_KEY_MAX_LENGTH, SECRET_KEY_PATTERN, SECRET_VALUE_MAX_LENGTH, type SecretAccessLog, type SecretChangeCallback, type SecretChangeEvent, type SecretConfig, type SecretContext, type SecretLevel, type SecretMetadata, SecretNotFoundError, type SecretPermission, type SecretPermissionType, type SecretStatus, type SecretType, SecretsError, type SecretsManagerPluginConfig, SecretsService, type SecretsServiceConfig, type StorageBackend, StorageError, type StoredSecret, ValidationError, type ValidationResult, ValidationStrategies, type ValidationStrategy, type ValidationStrategyEntry, WorldMetadataStorage, createOnboardingConfig, decrypt, secretsManagerPlugin as default, deriveKeyFromAgentId, deriveKeyPbkdf2, encrypt, generateKey, generateSalt, generateSecureToken, generateSettingPrompt, getNextSetting, getUnconfiguredOptional, getUnconfiguredRequired, inferValidationStrategy, isEncryptedSecret, isOnboardingComplete, manageSecretAction, missingSecretsProvider, onboardingSettingsProvider, registerValidator, secretsInfoProvider, secretsManagerPlugin, secretsStatusProvider, setSecretAction, unregisterValidator, updateSettingsAction, validateSecret };
|