@alfe.ai/integrations 0.0.1
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 +103 -0
- package/dist/index.d.ts +695 -0
- package/dist/index.js +1351 -0
- package/package.json +31 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
//#region src/registry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Registry — fetches the integration registry index from the integrations service.
|
|
4
|
+
*
|
|
5
|
+
* Calls GET /integrations/registry (public, no auth required) and caches the result.
|
|
6
|
+
* The API URL can be passed explicitly or set via ALFE_API_URL env var.
|
|
7
|
+
*/
|
|
8
|
+
interface RegistryEntry {
|
|
9
|
+
/** Human-readable display name (e.g. 'Alfe Voice') */
|
|
10
|
+
name?: string;
|
|
11
|
+
repo: string;
|
|
12
|
+
/** GitHub repository URL (HTTPS, no .git suffix) for public clone */
|
|
13
|
+
repository?: string;
|
|
14
|
+
/** Pinned commit SHA — when present, install uses this exact commit instead of a tag */
|
|
15
|
+
commit?: string;
|
|
16
|
+
/** Subdirectory within the repo where the integration lives (for monorepos) */
|
|
17
|
+
subdir?: string;
|
|
18
|
+
versions: string[];
|
|
19
|
+
latest: string;
|
|
20
|
+
description: string;
|
|
21
|
+
/** Agent runtimes this integration supports. Empty/absent = universal. */
|
|
22
|
+
supported_agents?: string[];
|
|
23
|
+
}
|
|
24
|
+
interface RegistryIndex {
|
|
25
|
+
version: number;
|
|
26
|
+
integrations: Record<string, RegistryEntry>;
|
|
27
|
+
}
|
|
28
|
+
declare class Registry {
|
|
29
|
+
private index;
|
|
30
|
+
private apiUrl;
|
|
31
|
+
/**
|
|
32
|
+
* @param apiUrl - Base URL for the Alfe API (e.g. "https://api.alfe.ai").
|
|
33
|
+
* Falls back to ALFE_API_URL env var, then the production URL.
|
|
34
|
+
*/
|
|
35
|
+
constructor(apiUrl?: string);
|
|
36
|
+
/**
|
|
37
|
+
* Load the registry index. Uses cache if already loaded.
|
|
38
|
+
*/
|
|
39
|
+
load(): Promise<RegistryIndex>;
|
|
40
|
+
/**
|
|
41
|
+
* Force reload the index (bypass cache).
|
|
42
|
+
*/
|
|
43
|
+
reload(): Promise<RegistryIndex>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a specific integration entry by name.
|
|
46
|
+
*/
|
|
47
|
+
get(id: string): Promise<RegistryEntry | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* List all integrations in the registry.
|
|
50
|
+
*/
|
|
51
|
+
list(): Promise<({
|
|
52
|
+
id: string;
|
|
53
|
+
} & RegistryEntry)[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Search integrations by name or description substring.
|
|
56
|
+
*/
|
|
57
|
+
search(query: string): Promise<({
|
|
58
|
+
id: string;
|
|
59
|
+
} & RegistryEntry)[]>;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/resolver.d.ts
|
|
63
|
+
interface ResolvedIntegration {
|
|
64
|
+
id: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
repo: string;
|
|
67
|
+
version: string;
|
|
68
|
+
tag: string;
|
|
69
|
+
/** Pinned commit SHA — when present, installer uses this instead of tag */
|
|
70
|
+
commit?: string;
|
|
71
|
+
/** Subdirectory within the repo where the integration lives (for monorepos) */
|
|
72
|
+
subdir?: string;
|
|
73
|
+
description: string;
|
|
74
|
+
}
|
|
75
|
+
declare class RegistryResolveError extends Error {
|
|
76
|
+
constructor(message: string);
|
|
77
|
+
}
|
|
78
|
+
declare class Resolver {
|
|
79
|
+
private registry;
|
|
80
|
+
constructor(registry: Registry);
|
|
81
|
+
/**
|
|
82
|
+
* Resolve an integration name (+ optional version) to a git clone target.
|
|
83
|
+
*
|
|
84
|
+
* @param name - Integration name (e.g. "discord")
|
|
85
|
+
* @param version - Specific version (e.g. "1.0.0") or undefined for latest
|
|
86
|
+
* @returns Resolved integration with repo URL and git tag
|
|
87
|
+
*/
|
|
88
|
+
resolve(id: string, version?: string): Promise<ResolvedIntegration>;
|
|
89
|
+
/**
|
|
90
|
+
* Check if an integration exists in the registry.
|
|
91
|
+
*/
|
|
92
|
+
exists(id: string): Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* Get all available versions for an integration.
|
|
95
|
+
*/
|
|
96
|
+
versions(id: string): Promise<string[]>;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/installer.d.ts
|
|
100
|
+
interface InstalledInfo {
|
|
101
|
+
id: string;
|
|
102
|
+
name?: string;
|
|
103
|
+
version: string;
|
|
104
|
+
path: string;
|
|
105
|
+
}
|
|
106
|
+
declare class InstallerError extends Error {
|
|
107
|
+
constructor(message: string);
|
|
108
|
+
}
|
|
109
|
+
declare class Installer {
|
|
110
|
+
private basePath;
|
|
111
|
+
/** Tracks subdir overrides per integration id */
|
|
112
|
+
private subdirs;
|
|
113
|
+
/**
|
|
114
|
+
* @param basePath - Override the integrations directory (for testing).
|
|
115
|
+
* Defaults to ~/.alfe/integrations/
|
|
116
|
+
*/
|
|
117
|
+
constructor(basePath?: string);
|
|
118
|
+
/**
|
|
119
|
+
* Get the path where an integration's content lives.
|
|
120
|
+
* When a subdir is set, returns the subdir within the clone.
|
|
121
|
+
*/
|
|
122
|
+
getInstallPath(name: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Get the root clone path (without subdir).
|
|
125
|
+
*/
|
|
126
|
+
getClonePath(name: string): string;
|
|
127
|
+
/**
|
|
128
|
+
* Install an integration by cloning its git repo and checking out the version tag.
|
|
129
|
+
* Returns the effective install path (with subdir if present).
|
|
130
|
+
*/
|
|
131
|
+
install(resolved: ResolvedIntegration): Promise<string>;
|
|
132
|
+
/**
|
|
133
|
+
* Update an installed integration to a new version.
|
|
134
|
+
*/
|
|
135
|
+
update(name: string, resolved: ResolvedIntegration): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* Remove an installed integration.
|
|
138
|
+
*/
|
|
139
|
+
remove(name: string): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* List all locally installed integrations.
|
|
142
|
+
*/
|
|
143
|
+
list(): InstalledInfo[];
|
|
144
|
+
/**
|
|
145
|
+
* Check if an integration is installed.
|
|
146
|
+
*/
|
|
147
|
+
isInstalled(name: string): boolean;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region ../integration-manifest/dist/index.d.ts
|
|
151
|
+
//#region src/types.d.ts
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* TypeScript types for the Alfe integration manifest (`alfe-integration.yaml`).
|
|
155
|
+
*
|
|
156
|
+
* These are the canonical types used by all packages that interact with
|
|
157
|
+
* integration manifests -- registry, lifecycle manager, CLI, etc.
|
|
158
|
+
*/
|
|
159
|
+
type ConfigFieldType = 'secret' | 'string' | 'number' | 'boolean' | 'enum' | 'select' | 'multi_select' | 'oauth_connect' | 'phone_number_picker';
|
|
160
|
+
interface SelectOption {
|
|
161
|
+
value: string;
|
|
162
|
+
label: string;
|
|
163
|
+
}
|
|
164
|
+
interface ConfigSchemaField {
|
|
165
|
+
key: string;
|
|
166
|
+
type: ConfigFieldType;
|
|
167
|
+
label: string;
|
|
168
|
+
description?: string;
|
|
169
|
+
required: boolean;
|
|
170
|
+
default?: string | number | boolean;
|
|
171
|
+
/** Who can mutate this field at runtime. Default: 'admin' */
|
|
172
|
+
editable: 'admin' | 'agent';
|
|
173
|
+
/** Only used when type === 'enum' */
|
|
174
|
+
options?: string[];
|
|
175
|
+
/** Structured options for select/multi_select fields */
|
|
176
|
+
select_options?: SelectOption[];
|
|
177
|
+
/** OAuth provider identifier for oauth_connect fields */
|
|
178
|
+
oauth_provider?: string;
|
|
179
|
+
/** Only show this field if another field has a truthy value (string) or matches a specific value (object) */
|
|
180
|
+
depends_on_field?: string | {
|
|
181
|
+
key: string;
|
|
182
|
+
value: string | number | boolean;
|
|
183
|
+
};
|
|
184
|
+
/** Only show this field if a specific integration is installed */
|
|
185
|
+
depends_on_integration?: string;
|
|
186
|
+
}
|
|
187
|
+
interface SkillInstall {
|
|
188
|
+
/** Relative path within the integration repo to the skill directory */
|
|
189
|
+
path: string;
|
|
190
|
+
}
|
|
191
|
+
interface PluginInstall {
|
|
192
|
+
/** npm package name to install */
|
|
193
|
+
package: string;
|
|
194
|
+
}
|
|
195
|
+
type AgentRuntime = 'openclaw' | 'nanoclaw' | (string & {});
|
|
196
|
+
interface RuntimeInstall {
|
|
197
|
+
plugins?: PluginInstall[];
|
|
198
|
+
skills?: SkillInstall[];
|
|
199
|
+
/** Deep-merged into the runtime's agent config on activation */
|
|
200
|
+
config?: Record<string, unknown>;
|
|
201
|
+
}
|
|
202
|
+
interface InstallTargets {
|
|
203
|
+
/** Universal skills — applied to all runtimes */
|
|
204
|
+
skills?: SkillInstall[];
|
|
205
|
+
/** Universal plugins — applied to all runtimes */
|
|
206
|
+
plugins?: PluginInstall[];
|
|
207
|
+
/** Per-runtime installs */
|
|
208
|
+
runtimes?: Record<AgentRuntime, RuntimeInstall>;
|
|
209
|
+
}
|
|
210
|
+
interface IntegrationHooks {
|
|
211
|
+
pre_install?: string;
|
|
212
|
+
post_install?: string;
|
|
213
|
+
pre_uninstall?: string;
|
|
214
|
+
post_uninstall?: string;
|
|
215
|
+
health_check?: string;
|
|
216
|
+
}
|
|
217
|
+
interface IntegrationPricingPlan {
|
|
218
|
+
name: string;
|
|
219
|
+
price: number;
|
|
220
|
+
currency?: string;
|
|
221
|
+
interval?: 'month' | 'year';
|
|
222
|
+
}
|
|
223
|
+
interface IntegrationPricing {
|
|
224
|
+
type: 'free' | 'paid';
|
|
225
|
+
/** Single price (shorthand for integrations with one plan) */
|
|
226
|
+
price?: number;
|
|
227
|
+
currency?: string;
|
|
228
|
+
interval?: 'month' | 'year';
|
|
229
|
+
/** Multiple plans/tiers (e.g., starter, growth, scale) */
|
|
230
|
+
plans?: Record<string, IntegrationPricingPlan>;
|
|
231
|
+
}
|
|
232
|
+
interface IntegrationAuthor {
|
|
233
|
+
name: string;
|
|
234
|
+
url?: string;
|
|
235
|
+
}
|
|
236
|
+
interface IntegrationManifest {
|
|
237
|
+
id: string;
|
|
238
|
+
name: string;
|
|
239
|
+
version: string;
|
|
240
|
+
description: string;
|
|
241
|
+
/** Simple author string (legacy) or structured author object */
|
|
242
|
+
author: string | IntegrationAuthor;
|
|
243
|
+
license: string;
|
|
244
|
+
depends_on: string[];
|
|
245
|
+
min_gateway_version: string;
|
|
246
|
+
installs: InstallTargets;
|
|
247
|
+
config_schema: ConfigSchemaField[];
|
|
248
|
+
capabilities: string[];
|
|
249
|
+
hooks: IntegrationHooks;
|
|
250
|
+
/**
|
|
251
|
+
* Agent runtimes this integration supports.
|
|
252
|
+
* If omitted or empty, the integration is considered universal (all runtimes).
|
|
253
|
+
* Example: ['openclaw'] means this integration only works with OpenClaw.
|
|
254
|
+
*/
|
|
255
|
+
supported_agents?: AgentRuntime[];
|
|
256
|
+
/** Marketplace metadata */
|
|
257
|
+
publisherId?: string;
|
|
258
|
+
icon?: string;
|
|
259
|
+
pricing?: IntegrationPricing;
|
|
260
|
+
preview_images?: string[];
|
|
261
|
+
/** Long-form features list for the detail view */
|
|
262
|
+
features?: string[];
|
|
263
|
+
}
|
|
264
|
+
type IntegrationStatus = 'installing' | 'installed' | 'configured' | 'active' | 'error';
|
|
265
|
+
interface IntegrationStateEntry {
|
|
266
|
+
status: IntegrationStatus;
|
|
267
|
+
version: string;
|
|
268
|
+
installedAt: string;
|
|
269
|
+
config: Record<string, unknown>;
|
|
270
|
+
error?: string;
|
|
271
|
+
}
|
|
272
|
+
interface IntegrationsStateFile {
|
|
273
|
+
version: number;
|
|
274
|
+
integrations: Record<string, IntegrationStateEntry>;
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/runtime-applier.d.ts
|
|
278
|
+
/**
|
|
279
|
+
* RuntimeApplier — interface for applying/removing plugins and skills
|
|
280
|
+
* to a specific agent runtime (OpenClaw, NanoClaw, etc.).
|
|
281
|
+
*/
|
|
282
|
+
interface RuntimeApplier {
|
|
283
|
+
/** The runtime identifier (e.g. 'openclaw', 'nanoclaw') */
|
|
284
|
+
readonly runtime: string;
|
|
285
|
+
/** Install a plugin package into this runtime */
|
|
286
|
+
applyPlugin(pkg: string, integrationInstallPath: string): Promise<void>;
|
|
287
|
+
/** Remove a plugin package from this runtime */
|
|
288
|
+
removePlugin(pkg: string): Promise<void>;
|
|
289
|
+
/** Copy a skill directory into this runtime's skills location */
|
|
290
|
+
applySkill(name: string, srcPath: string): Promise<void>;
|
|
291
|
+
/** Remove a skill directory from this runtime */
|
|
292
|
+
removeSkill(name: string): Promise<void>;
|
|
293
|
+
/** Deep-merge config into the runtime's agent configuration */
|
|
294
|
+
applyConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
|
|
295
|
+
/** Remove config previously applied by an integration */
|
|
296
|
+
removeConfig(integrationId: string): Promise<void>;
|
|
297
|
+
/** Check if this runtime is available (e.g. workspace directory exists) */
|
|
298
|
+
isAvailable(): Promise<boolean>;
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/types.d.ts
|
|
302
|
+
/**
|
|
303
|
+
* Integration command parameter types.
|
|
304
|
+
*
|
|
305
|
+
* These define the payloads for integration lifecycle operations.
|
|
306
|
+
*/
|
|
307
|
+
interface IntegrationInstallParams {
|
|
308
|
+
name: string;
|
|
309
|
+
version?: string;
|
|
310
|
+
config?: Record<string, unknown>;
|
|
311
|
+
}
|
|
312
|
+
interface IntegrationRemoveParams {
|
|
313
|
+
name: string;
|
|
314
|
+
}
|
|
315
|
+
interface IntegrationConfigureParams {
|
|
316
|
+
name: string;
|
|
317
|
+
config: Record<string, unknown>;
|
|
318
|
+
}
|
|
319
|
+
interface IntegrationHealthParams {
|
|
320
|
+
name?: string;
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/integration-manager.d.ts
|
|
324
|
+
interface IntegrationManagerOptions {
|
|
325
|
+
/** @deprecated Logger is now created internally via @auriclabs/logger */
|
|
326
|
+
logger?: unknown;
|
|
327
|
+
statePath?: string;
|
|
328
|
+
integrationsDir?: string;
|
|
329
|
+
skillsDir?: string;
|
|
330
|
+
/** Runtime appliers keyed by runtime name */
|
|
331
|
+
runtimeAppliers?: Map<string, RuntimeApplier>;
|
|
332
|
+
/** Override lock file path (defaults to ~/.alfe/runtime-lock.json) */
|
|
333
|
+
lockPath?: string;
|
|
334
|
+
}
|
|
335
|
+
interface ManagerResponse {
|
|
336
|
+
ok: boolean;
|
|
337
|
+
payload?: unknown;
|
|
338
|
+
error?: {
|
|
339
|
+
code: string;
|
|
340
|
+
message: string;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
interface IntegrationInfo {
|
|
344
|
+
id: string;
|
|
345
|
+
name?: string;
|
|
346
|
+
version?: string;
|
|
347
|
+
status: IntegrationStatus;
|
|
348
|
+
installedAt?: string;
|
|
349
|
+
config?: Record<string, unknown>;
|
|
350
|
+
error?: string;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Merge universal installs with runtime-specific installs from the manifest.
|
|
354
|
+
*/
|
|
355
|
+
declare function resolveInstallsForRuntime(manifest: IntegrationManifest, runtime: string): {
|
|
356
|
+
plugins: PluginInstall[];
|
|
357
|
+
skills: SkillInstall[];
|
|
358
|
+
config?: Record<string, unknown>;
|
|
359
|
+
};
|
|
360
|
+
declare class IntegrationManager {
|
|
361
|
+
private log;
|
|
362
|
+
private state;
|
|
363
|
+
private registry;
|
|
364
|
+
private resolver;
|
|
365
|
+
private installer;
|
|
366
|
+
private runtimeAppliers;
|
|
367
|
+
private lockManager;
|
|
368
|
+
/** In-memory secret store — NEVER persisted to disk */
|
|
369
|
+
private secrets;
|
|
370
|
+
constructor(options?: IntegrationManagerOptions);
|
|
371
|
+
/**
|
|
372
|
+
* Install an integration from the registry.
|
|
373
|
+
*
|
|
374
|
+
* 1. Resolve from registry
|
|
375
|
+
* 2. Git clone via registry installer
|
|
376
|
+
* 3. Parse + validate alfe-integration.yaml
|
|
377
|
+
* 4. Check depends_on are already installed
|
|
378
|
+
* 5. Run pre_install hook
|
|
379
|
+
* 6. Run post_install hook
|
|
380
|
+
* 7. Persist state to integrations.json
|
|
381
|
+
*
|
|
382
|
+
* Note: Skills and plugins are NOT applied during install.
|
|
383
|
+
* They are applied during activate() via runtime appliers.
|
|
384
|
+
*/
|
|
385
|
+
install(params: IntegrationInstallParams): Promise<ManagerResponse>;
|
|
386
|
+
/**
|
|
387
|
+
* Configure an installed integration.
|
|
388
|
+
*
|
|
389
|
+
* 1. Load manifest for this integration
|
|
390
|
+
* 2. Validate config against config_schema
|
|
391
|
+
* 3. Store non-secret values in state file
|
|
392
|
+
* 4. Store secret values in memory only (NEVER disk)
|
|
393
|
+
*/
|
|
394
|
+
configure(params: IntegrationConfigureParams): ManagerResponse;
|
|
395
|
+
/**
|
|
396
|
+
* Activate an installed + configured integration.
|
|
397
|
+
*
|
|
398
|
+
* 1. Check integration is installed + configured
|
|
399
|
+
* 2. For each registered runtime applier, apply plugins + skills
|
|
400
|
+
* 3. Update lock file
|
|
401
|
+
* 4. Run health_check hook if present
|
|
402
|
+
* 5. Mark as active in state
|
|
403
|
+
*/
|
|
404
|
+
activate(integrationId: string): Promise<ManagerResponse>;
|
|
405
|
+
/**
|
|
406
|
+
* Deactivate a running integration.
|
|
407
|
+
*
|
|
408
|
+
* 1. Read lock file to find all entries for this integration
|
|
409
|
+
* 2. For each runtime's applier, remove plugins + skills
|
|
410
|
+
* 3. Update lock file
|
|
411
|
+
* 4. Set state to configured
|
|
412
|
+
*/
|
|
413
|
+
deactivate(integrationId: string): Promise<ManagerResponse>;
|
|
414
|
+
/**
|
|
415
|
+
* Uninstall an integration completely.
|
|
416
|
+
*
|
|
417
|
+
* 1. Deactivate first (removes plugins/skills via appliers)
|
|
418
|
+
* 2. Run pre_uninstall hook
|
|
419
|
+
* 3. Run post_uninstall hook
|
|
420
|
+
* 4. Remove git clone from ~/.alfe/integrations/
|
|
421
|
+
* 5. Remove from state file
|
|
422
|
+
*/
|
|
423
|
+
uninstall(params: IntegrationRemoveParams): Promise<ManagerResponse>;
|
|
424
|
+
/**
|
|
425
|
+
* Run health checks for one or all integrations.
|
|
426
|
+
*/
|
|
427
|
+
health(params: IntegrationHealthParams): Promise<ManagerResponse>;
|
|
428
|
+
/**
|
|
429
|
+
* List all installed integrations.
|
|
430
|
+
*/
|
|
431
|
+
list(): IntegrationInfo[];
|
|
432
|
+
/**
|
|
433
|
+
* Get a specific integration by name.
|
|
434
|
+
*/
|
|
435
|
+
get(name: string): IntegrationInfo | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Clear in-memory secrets (called on daemon restart).
|
|
438
|
+
*/
|
|
439
|
+
clear(): void;
|
|
440
|
+
private checkHealth;
|
|
441
|
+
private err;
|
|
442
|
+
}
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region src/state.d.ts
|
|
445
|
+
declare class StateManager {
|
|
446
|
+
private filePath;
|
|
447
|
+
private lockHeld;
|
|
448
|
+
constructor(filePath?: string);
|
|
449
|
+
/**
|
|
450
|
+
* Read the current state file. Returns empty state if file doesn't exist.
|
|
451
|
+
*/
|
|
452
|
+
read(): IntegrationsStateFile;
|
|
453
|
+
/**
|
|
454
|
+
* Write the state file atomically.
|
|
455
|
+
*/
|
|
456
|
+
write(state: IntegrationsStateFile): void;
|
|
457
|
+
/**
|
|
458
|
+
* Get a specific integration's state.
|
|
459
|
+
*/
|
|
460
|
+
get(name: string): IntegrationStateEntry | undefined;
|
|
461
|
+
/**
|
|
462
|
+
* Set an integration's state (read-modify-write).
|
|
463
|
+
*/
|
|
464
|
+
set(name: string, entry: IntegrationStateEntry): void;
|
|
465
|
+
/**
|
|
466
|
+
* Update only specific fields of an integration's state.
|
|
467
|
+
*/
|
|
468
|
+
update(name: string, partial: Partial<IntegrationStateEntry>): void;
|
|
469
|
+
/**
|
|
470
|
+
* Update integration status.
|
|
471
|
+
*/
|
|
472
|
+
setStatus(name: string, status: IntegrationStatus, error?: string): void;
|
|
473
|
+
/**
|
|
474
|
+
* Remove an integration from the state file.
|
|
475
|
+
*/
|
|
476
|
+
remove(name: string): void;
|
|
477
|
+
/**
|
|
478
|
+
* List all integrations in the state file.
|
|
479
|
+
*/
|
|
480
|
+
list(): ({
|
|
481
|
+
id: string;
|
|
482
|
+
} & IntegrationStateEntry)[];
|
|
483
|
+
/**
|
|
484
|
+
* Check if an integration is in a given status.
|
|
485
|
+
*/
|
|
486
|
+
hasStatus(name: string, ...statuses: IntegrationStatus[]): boolean;
|
|
487
|
+
}
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/hooks.d.ts
|
|
490
|
+
/**
|
|
491
|
+
* Hook Runner — executes integration lifecycle hook scripts.
|
|
492
|
+
*
|
|
493
|
+
* Hooks are shell scripts defined in the integration manifest.
|
|
494
|
+
* They run as child processes with a 30-second timeout.
|
|
495
|
+
* stdout/stderr are captured and returned.
|
|
496
|
+
*
|
|
497
|
+
* The runner injects standard environment variables:
|
|
498
|
+
* - ALFE_INTEGRATION_DIR — path to the integration install directory
|
|
499
|
+
* - ALFE_STATE_DIR — path to the integration state directory (created if needed)
|
|
500
|
+
* - ALFE_<NAME>_<KEY> — config values (non-secret AND secret, both injected as env vars)
|
|
501
|
+
*
|
|
502
|
+
* Secrets are acceptable as env vars because:
|
|
503
|
+
* - Child process env is ephemeral (dies with the process)
|
|
504
|
+
* - Same security model as Docker secrets / systemd credentials
|
|
505
|
+
* - Never written to disk
|
|
506
|
+
*/
|
|
507
|
+
interface HookResult {
|
|
508
|
+
exitCode: number;
|
|
509
|
+
stdout: string;
|
|
510
|
+
stderr: string;
|
|
511
|
+
timedOut: boolean;
|
|
512
|
+
}
|
|
513
|
+
interface HookEnvOptions {
|
|
514
|
+
/** Integration name (e.g. "voice") */
|
|
515
|
+
integrationName: string;
|
|
516
|
+
/** Non-secret config key-value pairs */
|
|
517
|
+
config?: Record<string, unknown>;
|
|
518
|
+
/** Secret key-value pairs (in-memory only, injected as env vars) */
|
|
519
|
+
secrets?: Map<string, unknown>;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Build the environment variables for a hook script execution.
|
|
523
|
+
*
|
|
524
|
+
* Injects:
|
|
525
|
+
* - ALFE_INTEGRATION_DIR=~/.alfe/integrations/{name}/
|
|
526
|
+
* - ALFE_STATE_DIR=~/.alfe/state/{name}/ (creates dir if needed)
|
|
527
|
+
* - ALFE_<NAME_UPPER>_<KEY_UPPER>=value for each config entry
|
|
528
|
+
* - ALFE_<NAME_UPPER>_<KEY_UPPER>=value for each secret entry
|
|
529
|
+
*/
|
|
530
|
+
declare function buildHookEnv(options: HookEnvOptions, additionalEnv?: Record<string, string>): Record<string, string>;
|
|
531
|
+
/**
|
|
532
|
+
* Run a hook script from an integration directory.
|
|
533
|
+
*
|
|
534
|
+
* @param integrationPath - Base path of the integration (where alfe-integration.yaml lives)
|
|
535
|
+
* @param hookScript - Relative path to the hook script (e.g. "scripts/activate.sh")
|
|
536
|
+
* @param env - Additional environment variables to pass to the script
|
|
537
|
+
* @returns Hook execution result
|
|
538
|
+
*/
|
|
539
|
+
declare function runHook(integrationPath: string, hookScript: string, env?: Record<string, string>): Promise<HookResult>;
|
|
540
|
+
/**
|
|
541
|
+
* Run a hook script with full integration context (config + secrets as env vars).
|
|
542
|
+
*
|
|
543
|
+
* This is the preferred method for running lifecycle hooks (activate, deactivate, health).
|
|
544
|
+
* It builds the complete environment including ALFE_INTEGRATION_DIR, ALFE_STATE_DIR,
|
|
545
|
+
* and all config/secret values as ALFE_<NAME>_<KEY> env vars.
|
|
546
|
+
*
|
|
547
|
+
* @param integrationPath - Base path of the integration
|
|
548
|
+
* @param hookScript - Relative path to the hook script
|
|
549
|
+
* @param options - Integration name, config, and secrets
|
|
550
|
+
* @returns Hook execution result
|
|
551
|
+
*/
|
|
552
|
+
declare function runHookWithContext(integrationPath: string, hookScript: string, options: HookEnvOptions): Promise<HookResult>;
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/appliers/openclaw-applier.d.ts
|
|
555
|
+
interface OpenClawApplierOptions {
|
|
556
|
+
/** Path to the OpenClaw workspace directory (e.g. ~/.openclaw) */
|
|
557
|
+
workspace: string;
|
|
558
|
+
/** Override skills directory (defaults to ~/.alfe/skills/) */
|
|
559
|
+
skillsDir?: string;
|
|
560
|
+
/** Path to the OpenClaw agent config file (defaults to {workspace}/config.json) */
|
|
561
|
+
configPath?: string;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Resolve LLM provider runtime config based on mode.
|
|
565
|
+
*
|
|
566
|
+
* - "alfe_credits": keep manifest config as-is (baseUrl points to local proxy,
|
|
567
|
+
* apiKey is a dummy — the proxy injects the real key)
|
|
568
|
+
* - "byok": remove baseUrl (SDK uses provider default), set apiKey from
|
|
569
|
+
* decrypted secret
|
|
570
|
+
*
|
|
571
|
+
* Non-LLM integrations pass through unchanged.
|
|
572
|
+
*/
|
|
573
|
+
|
|
574
|
+
declare class OpenClawApplier implements RuntimeApplier {
|
|
575
|
+
readonly runtime = "openclaw";
|
|
576
|
+
private workspace;
|
|
577
|
+
private skillsDir;
|
|
578
|
+
private configPath;
|
|
579
|
+
constructor(options: OpenClawApplierOptions);
|
|
580
|
+
applyPlugin(pkg: string): Promise<void>;
|
|
581
|
+
removePlugin(pkg: string): Promise<void>;
|
|
582
|
+
applySkill(name: string, srcPath: string): Promise<void>;
|
|
583
|
+
removeSkill(name: string): Promise<void>;
|
|
584
|
+
/**
|
|
585
|
+
* Deep-merge integration config into the OpenClaw agent config file.
|
|
586
|
+
*
|
|
587
|
+
* Each integration's config contribution is tracked in
|
|
588
|
+
* `_integrations.{integrationId}` within the config file so it can be
|
|
589
|
+
* cleanly removed later.
|
|
590
|
+
*/
|
|
591
|
+
applyConfig(integrationId: string, config: Record<string, unknown>): Promise<void>;
|
|
592
|
+
/**
|
|
593
|
+
* Remove config previously applied by an integration.
|
|
594
|
+
*
|
|
595
|
+
* Rebuilds the config by re-merging all remaining integrations' configs,
|
|
596
|
+
* ensuring clean removal without orphaned keys.
|
|
597
|
+
*/
|
|
598
|
+
removeConfig(integrationId: string): Promise<void>;
|
|
599
|
+
isAvailable(): Promise<boolean>;
|
|
600
|
+
private readConfig;
|
|
601
|
+
private writeConfig;
|
|
602
|
+
/**
|
|
603
|
+
* Extract the base config by stripping all keys that were contributed
|
|
604
|
+
* by integrations. This is done by removing each integration's keys
|
|
605
|
+
* from the current config.
|
|
606
|
+
*/
|
|
607
|
+
private getBaseConfig;
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/lock.d.ts
|
|
611
|
+
interface RuntimePluginEntry {
|
|
612
|
+
package: string;
|
|
613
|
+
sourceIntegration: string;
|
|
614
|
+
integrationVersion: string;
|
|
615
|
+
}
|
|
616
|
+
interface RuntimeSkillEntry {
|
|
617
|
+
name: string;
|
|
618
|
+
sourcePath: string;
|
|
619
|
+
sourceIntegration: string;
|
|
620
|
+
integrationVersion: string;
|
|
621
|
+
}
|
|
622
|
+
interface RuntimeDesiredState {
|
|
623
|
+
plugins: RuntimePluginEntry[];
|
|
624
|
+
skills: RuntimeSkillEntry[];
|
|
625
|
+
}
|
|
626
|
+
interface RuntimeLockFile {
|
|
627
|
+
version: 1;
|
|
628
|
+
runtimes: Record<string, RuntimeDesiredState>;
|
|
629
|
+
updatedAt: string;
|
|
630
|
+
}
|
|
631
|
+
declare class LockManager {
|
|
632
|
+
private filePath;
|
|
633
|
+
constructor(filePath?: string);
|
|
634
|
+
/**
|
|
635
|
+
* Read the current lock file. Returns empty lock if file doesn't exist.
|
|
636
|
+
*/
|
|
637
|
+
read(): RuntimeLockFile;
|
|
638
|
+
/**
|
|
639
|
+
* Write the lock file atomically.
|
|
640
|
+
*/
|
|
641
|
+
write(lock: RuntimeLockFile): void;
|
|
642
|
+
/**
|
|
643
|
+
* Add entries for an integration activation in a specific runtime.
|
|
644
|
+
*/
|
|
645
|
+
addEntries(runtime: string, integrationId: string, version: string, plugins: PluginInstall[], skills: SkillInstall[], installPath: string): void;
|
|
646
|
+
/**
|
|
647
|
+
* Remove all entries for a given integration across all runtimes.
|
|
648
|
+
* Returns what was removed, keyed by runtime.
|
|
649
|
+
*/
|
|
650
|
+
removeEntries(integrationId: string): Record<string, {
|
|
651
|
+
plugins: RuntimePluginEntry[];
|
|
652
|
+
skills: RuntimeSkillEntry[];
|
|
653
|
+
}>;
|
|
654
|
+
/**
|
|
655
|
+
* Get the full desired state for a specific runtime.
|
|
656
|
+
*/
|
|
657
|
+
getDesiredState(runtime: string): RuntimeDesiredState;
|
|
658
|
+
}
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/adapter.d.ts
|
|
661
|
+
/**
|
|
662
|
+
* Minimal interface for the integration manager that the reconciliation engine depends on.
|
|
663
|
+
* This abstraction allows testing without the full IntegrationManager.
|
|
664
|
+
*/
|
|
665
|
+
interface IIntegrationManager {
|
|
666
|
+
/** Get all currently installed integration IDs with their versions */
|
|
667
|
+
getInstalledIntegrations(): Promise<{
|
|
668
|
+
id: string;
|
|
669
|
+
version: string;
|
|
670
|
+
status: string;
|
|
671
|
+
}[]>;
|
|
672
|
+
/** Install an integration at a specific version with config */
|
|
673
|
+
install(integrationId: string, version: string, config: unknown): Promise<void>;
|
|
674
|
+
/** Activate an installed integration */
|
|
675
|
+
activate(integrationId: string): Promise<void>;
|
|
676
|
+
/** Deactivate a running integration */
|
|
677
|
+
deactivate(integrationId: string): Promise<void>;
|
|
678
|
+
/** Uninstall an integration */
|
|
679
|
+
uninstall(integrationId: string): Promise<void>;
|
|
680
|
+
}
|
|
681
|
+
declare class IntegrationManagerAdapter implements IIntegrationManager {
|
|
682
|
+
private readonly manager;
|
|
683
|
+
constructor(manager: IntegrationManager);
|
|
684
|
+
getInstalledIntegrations(): Promise<{
|
|
685
|
+
id: string;
|
|
686
|
+
version: string;
|
|
687
|
+
status: string;
|
|
688
|
+
}[]>;
|
|
689
|
+
install(integrationId: string, version: string, config: unknown): Promise<void>;
|
|
690
|
+
activate(integrationId: string): Promise<void>;
|
|
691
|
+
deactivate(integrationId: string): Promise<void>;
|
|
692
|
+
uninstall(integrationId: string): Promise<void>;
|
|
693
|
+
}
|
|
694
|
+
//#endregion
|
|
695
|
+
export { type HookEnvOptions, type HookResult, type IIntegrationManager, type InstalledInfo, Installer, InstallerError, type IntegrationConfigureParams, type IntegrationHealthParams, type IntegrationInfo, type IntegrationInstallParams, IntegrationManager, IntegrationManagerAdapter, type IntegrationManagerOptions, type IntegrationRemoveParams, LockManager, OpenClawApplier, type OpenClawApplierOptions, Registry, type RegistryEntry, type RegistryIndex, RegistryResolveError, type ResolvedIntegration, Resolver, type RuntimeApplier, type RuntimeDesiredState, type RuntimeLockFile, type RuntimePluginEntry, type RuntimeSkillEntry, StateManager, buildHookEnv, resolveInstallsForRuntime, runHook, runHookWithContext };
|