@alfe.ai/openclaw 0.0.1 → 0.0.2
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 +1 -1
- package/dist/plugin2.js +49 -57
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ declare abstract class BaseAgentClient {
|
|
|
129
129
|
get isConnected(): boolean;
|
|
130
130
|
start(): Promise<void>;
|
|
131
131
|
stop(): void;
|
|
132
|
-
request(method: string, params:
|
|
132
|
+
request(method: string, params: object, opts?: {
|
|
133
133
|
expectFinal?: boolean;
|
|
134
134
|
timeoutMs?: number;
|
|
135
135
|
}): Promise<unknown>;
|
package/dist/plugin2.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { Type } from "@sinclair/typebox";
|
|
4
|
+
import { AlfeApiClient, IntegrationsService } from "@alfe/api-client";
|
|
4
5
|
import { createConnection } from "node:net";
|
|
5
6
|
import { randomUUID } from "node:crypto";
|
|
6
7
|
import { EventEmitter } from "node:events";
|
|
@@ -303,8 +304,6 @@ async function registerWithDaemon(client, log) {
|
|
|
303
304
|
*/
|
|
304
305
|
const DEFAULT_SOCKET_PATH = join(homedir(), ".alfe", "gateway.sock");
|
|
305
306
|
let ipcClient = null;
|
|
306
|
-
let integrationsApiUrl = "";
|
|
307
|
-
let integrationsApiKey = "";
|
|
308
307
|
let pluginAgentId = "";
|
|
309
308
|
function ok(result) {
|
|
310
309
|
return { content: [{
|
|
@@ -333,57 +332,46 @@ function defineTool(def) {
|
|
|
333
332
|
}
|
|
334
333
|
};
|
|
335
334
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
const text = await res.text().catch(() => "");
|
|
348
|
-
throw new Error(`Integrations API ${String(res.status)}: ${text}`);
|
|
349
|
-
}
|
|
350
|
-
return res.json();
|
|
351
|
-
}
|
|
352
|
-
const integrationTools = [
|
|
353
|
-
defineTool({
|
|
354
|
-
name: "list_integrations",
|
|
355
|
-
description: "List all integrations installed for this agent, including their status and available config fields.",
|
|
356
|
-
parameters: Type.Object({}),
|
|
357
|
-
handler: async () => {
|
|
358
|
-
return integrationsApiFetch(`/integrations/agents/${pluginAgentId}`);
|
|
359
|
-
}
|
|
360
|
-
}),
|
|
361
|
-
defineTool({
|
|
362
|
-
name: "get_integration_config",
|
|
363
|
-
description: "Get the current configuration and editable fields for a specific integration.",
|
|
364
|
-
parameters: Type.Object({ integrationId: Type.String({ description: "The integration to inspect (e.g. \"voice\", \"slack\")" }) }),
|
|
365
|
-
handler: async (params) => {
|
|
366
|
-
const integrationId = params.integrationId;
|
|
367
|
-
return integrationsApiFetch(`/integrations/agents/${pluginAgentId}/${integrationId}/config`);
|
|
368
|
-
}
|
|
369
|
-
}),
|
|
370
|
-
defineTool({
|
|
371
|
-
name: "update_integration_config",
|
|
372
|
-
description: "Update configuration for an installed integration. Only agent-editable fields can be changed.",
|
|
373
|
-
parameters: Type.Object({
|
|
374
|
-
integrationId: Type.String({ description: "The integration to update" }),
|
|
375
|
-
fields: Type.Record(Type.String(), Type.Unknown(), { description: "Key-value pairs of config fields to update" })
|
|
335
|
+
function buildIntegrationTools(svc) {
|
|
336
|
+
return [
|
|
337
|
+
defineTool({
|
|
338
|
+
name: "list_integrations",
|
|
339
|
+
description: "List all integrations installed for this agent, including their status and available config fields.",
|
|
340
|
+
parameters: Type.Object({}),
|
|
341
|
+
handler: async () => {
|
|
342
|
+
const result = await svc.listIntegrations(pluginAgentId);
|
|
343
|
+
if (!result.ok) throw new Error(result.error);
|
|
344
|
+
return result.data;
|
|
345
|
+
}
|
|
376
346
|
}),
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
347
|
+
defineTool({
|
|
348
|
+
name: "get_integration_config",
|
|
349
|
+
description: "Get the current configuration and editable fields for a specific integration.",
|
|
350
|
+
parameters: Type.Object({ integrationId: Type.String({ description: "The integration to inspect (e.g. \"voice\", \"slack\")" }) }),
|
|
351
|
+
handler: async (params) => {
|
|
352
|
+
const integrationId = params.integrationId;
|
|
353
|
+
const result = await svc.getIntegrationConfig(pluginAgentId, integrationId);
|
|
354
|
+
if (!result.ok) throw new Error(result.error);
|
|
355
|
+
return result.data;
|
|
356
|
+
}
|
|
357
|
+
}),
|
|
358
|
+
defineTool({
|
|
359
|
+
name: "update_integration_config",
|
|
360
|
+
description: "Update configuration for an installed integration. Only agent-editable fields can be changed.",
|
|
361
|
+
parameters: Type.Object({
|
|
362
|
+
integrationId: Type.String({ description: "The integration to update" }),
|
|
363
|
+
fields: Type.Record(Type.String(), Type.Unknown(), { description: "Key-value pairs of config fields to update" })
|
|
364
|
+
}),
|
|
365
|
+
handler: async (params) => {
|
|
366
|
+
const integrationId = params.integrationId;
|
|
367
|
+
const fields = params.fields;
|
|
368
|
+
const result = await svc.updateIntegration(pluginAgentId, integrationId, { config: fields });
|
|
369
|
+
if (!result.ok) throw new Error(result.error);
|
|
370
|
+
return result.data;
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
];
|
|
374
|
+
}
|
|
387
375
|
const plugin = {
|
|
388
376
|
id: "@alfe.ai/openclaw",
|
|
389
377
|
name: "Alfe OpenClaw Plugin",
|
|
@@ -394,12 +382,16 @@ const plugin = {
|
|
|
394
382
|
log.info("Alfe OpenClaw Plugin activating...");
|
|
395
383
|
const pluginConfig = (api.config ?? {}).plugins?.entries?.["@alfe.ai/openclaw"]?.config ?? {};
|
|
396
384
|
const socketPath = pluginConfig.socketPath ?? process.env.ALFE_GATEWAY_SOCKET ?? DEFAULT_SOCKET_PATH;
|
|
397
|
-
|
|
398
|
-
|
|
385
|
+
const apiUrl = pluginConfig.apiUrl ?? process.env.ALFE_API_URL ?? "";
|
|
386
|
+
const apiKey = pluginConfig.apiKey ?? process.env.ALFE_API_KEY ?? "";
|
|
399
387
|
pluginAgentId = pluginConfig.agentId ?? process.env.ALFE_AGENT_ID ?? "";
|
|
400
|
-
if (
|
|
401
|
-
|
|
402
|
-
|
|
388
|
+
if (apiUrl && apiKey && pluginAgentId) {
|
|
389
|
+
const tools = buildIntegrationTools(new IntegrationsService(new AlfeApiClient({
|
|
390
|
+
apiBaseUrl: apiUrl,
|
|
391
|
+
getToken: () => Promise.resolve(apiKey)
|
|
392
|
+
})));
|
|
393
|
+
for (const tool of tools) api.registerTool(tool);
|
|
394
|
+
log.info(`Registered ${String(tools.length)} integration tools: ${tools.map((t) => t.name).join(", ")}`);
|
|
403
395
|
} else log.warn("Integration tools not registered — missing apiUrl, apiKey, or agentId config");
|
|
404
396
|
ipcClient = new IPCClient(socketPath);
|
|
405
397
|
ipcClient.on("event", (event, payload) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/openclaw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "OpenClaw plugin for Alfe — connects to local gateway daemon via IPC for integration management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@auriclabs/logger": "^0.1.1",
|
|
25
25
|
"@sinclair/typebox": "^0.34.48",
|
|
26
|
-
"@alfe
|
|
26
|
+
"@alfe/api-client": "0.1.0",
|
|
27
|
+
"@alfe.ai/integrations": "^0.0.2"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@alfe/agent-client": "0.1.0"
|