@alfe.ai/openclaw-mobile 0.0.6 → 0.0.7
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.cjs +2 -0
- package/dist/index.d.cts +2 -0
- package/dist/plugin.cjs +121 -0
- package/dist/plugin.d.cts +42 -0
- package/dist/plugin.d.cts.map +1 -0
- package/package.json +8 -6
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
let _sinclair_typebox = require("@sinclair/typebox");
|
|
2
|
+
let _alfe_ai_config = require("@alfe.ai/config");
|
|
3
|
+
//#region src/plugin.ts
|
|
4
|
+
/**
|
|
5
|
+
* @alfe/openclaw-mobile — OpenClaw native plugin
|
|
6
|
+
*
|
|
7
|
+
* Registers mobile tools (SMS, calls) with OpenClaw. Tools call the
|
|
8
|
+
* mobile service API using the agent's API key for authentication.
|
|
9
|
+
*
|
|
10
|
+
* This plugin provides:
|
|
11
|
+
* - mobile_send_sms — send an SMS message from the agent's phone number
|
|
12
|
+
* - mobile_call — initiate an outbound phone call
|
|
13
|
+
*/
|
|
14
|
+
function ok(data) {
|
|
15
|
+
return {
|
|
16
|
+
content: [{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: JSON.stringify(data)
|
|
19
|
+
}],
|
|
20
|
+
details: data
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function errResult(message) {
|
|
24
|
+
return {
|
|
25
|
+
content: [{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: JSON.stringify({ error: message })
|
|
28
|
+
}],
|
|
29
|
+
details: { error: message }
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function defineTool(def) {
|
|
33
|
+
return {
|
|
34
|
+
name: def.name,
|
|
35
|
+
description: def.description,
|
|
36
|
+
label: def.name,
|
|
37
|
+
parameters: def.parameters,
|
|
38
|
+
execute: async (_toolCallId, params) => {
|
|
39
|
+
try {
|
|
40
|
+
return ok(await def.handler(params));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return errResult(e.message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
let apiUrl = "";
|
|
48
|
+
let apiKey = "";
|
|
49
|
+
async function mobileApi(method, path, body) {
|
|
50
|
+
const url = `${apiUrl}${path}`;
|
|
51
|
+
const headers = {
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
Authorization: `Bearer ${apiKey}`
|
|
54
|
+
};
|
|
55
|
+
const res = await fetch(url, {
|
|
56
|
+
method,
|
|
57
|
+
headers,
|
|
58
|
+
body: body ? JSON.stringify(body) : void 0
|
|
59
|
+
});
|
|
60
|
+
const json = await res.json();
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
const errorMsg = typeof json.error === "string" ? json.error : typeof json.message === "string" ? json.message : `Mobile service returned ${String(res.status)}`;
|
|
63
|
+
throw new Error(errorMsg);
|
|
64
|
+
}
|
|
65
|
+
if (json.data && typeof json.data === "object") return json.data;
|
|
66
|
+
return json;
|
|
67
|
+
}
|
|
68
|
+
const mobileTools = [defineTool({
|
|
69
|
+
name: "mobile_send_sms",
|
|
70
|
+
description: "Send an SMS text message from your phone number to the specified number. The recipient number must be in E.164 format (e.g., +12025551234).",
|
|
71
|
+
parameters: _sinclair_typebox.Type.Object({
|
|
72
|
+
to: _sinclair_typebox.Type.String({ description: "Recipient phone number in E.164 format (e.g., +12025551234)" }),
|
|
73
|
+
body: _sinclair_typebox.Type.String({ description: "The text message content to send" })
|
|
74
|
+
}),
|
|
75
|
+
handler: async (params) => {
|
|
76
|
+
const { to, body } = params;
|
|
77
|
+
return mobileApi("POST", "/mobile/sms/send", {
|
|
78
|
+
to,
|
|
79
|
+
body
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}), defineTool({
|
|
83
|
+
name: "mobile_call",
|
|
84
|
+
description: "Make an outbound phone call to the specified number. When the recipient answers, they will be connected to your voice pipeline. The number must be in E.164 format (e.g., +12025551234).",
|
|
85
|
+
parameters: _sinclair_typebox.Type.Object({ to: _sinclair_typebox.Type.String({ description: "Phone number to call in E.164 format (e.g., +12025551234)" }) }),
|
|
86
|
+
handler: async (params) => {
|
|
87
|
+
const { to } = params;
|
|
88
|
+
return mobileApi("POST", "/mobile/calls/outbound", { to });
|
|
89
|
+
}
|
|
90
|
+
})];
|
|
91
|
+
const plugin = {
|
|
92
|
+
id: "@alfe.ai/openclaw-mobile",
|
|
93
|
+
name: "Alfe Mobile Plugin",
|
|
94
|
+
description: "Mobile integration — outbound SMS and phone calls via Twilio",
|
|
95
|
+
version: "0.0.1",
|
|
96
|
+
activate(api) {
|
|
97
|
+
const log = api.logger;
|
|
98
|
+
for (const tool of mobileTools) api.registerTool(tool);
|
|
99
|
+
log.info(`Registered ${String(mobileTools.length)} mobile tools: ${mobileTools.map((t) => t.name).join(", ")}`);
|
|
100
|
+
if (!globalThis.__mobilePluginActivated) {
|
|
101
|
+
globalThis.__mobilePluginActivated = true;
|
|
102
|
+
log.info("Alfe Mobile plugin activating...");
|
|
103
|
+
try {
|
|
104
|
+
const config = (0, _alfe_ai_config.resolveConfig)();
|
|
105
|
+
apiUrl = config.apiUrl;
|
|
106
|
+
apiKey = config.apiKey;
|
|
107
|
+
} catch (err) {
|
|
108
|
+
log.error(`Failed to resolve config: ${err instanceof Error ? err.message : String(err)}`);
|
|
109
|
+
log.warn("Mobile tools will fail — no API config available");
|
|
110
|
+
}
|
|
111
|
+
log.info(`Mobile API: ${apiUrl}`);
|
|
112
|
+
}
|
|
113
|
+
log.info("Alfe Mobile plugin activated");
|
|
114
|
+
},
|
|
115
|
+
deactivate(api) {
|
|
116
|
+
globalThis.__mobilePluginActivated = false;
|
|
117
|
+
api.logger.info("Alfe Mobile plugin deactivated");
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
module.exports = plugin;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TSchema } from "@sinclair/typebox";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin.d.ts
|
|
4
|
+
|
|
5
|
+
interface Logger {
|
|
6
|
+
info(msg: string, ...args: unknown[]): void;
|
|
7
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
8
|
+
error(msg: string, ...args: unknown[]): void;
|
|
9
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
10
|
+
}
|
|
11
|
+
interface OpenClawPluginApi {
|
|
12
|
+
logger: Logger;
|
|
13
|
+
registerTool(tool: ToolDef): void;
|
|
14
|
+
registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
|
|
15
|
+
on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
|
|
16
|
+
priority?: number;
|
|
17
|
+
}): void;
|
|
18
|
+
}
|
|
19
|
+
interface ToolDef {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
label: string;
|
|
23
|
+
parameters: TSchema;
|
|
24
|
+
execute: (toolCallId: string, params: Record<string, unknown>) => Promise<{
|
|
25
|
+
content: {
|
|
26
|
+
type: "text";
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
details: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
declare const plugin: {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
version: string;
|
|
37
|
+
activate(api: OpenClawPluginApi): void;
|
|
38
|
+
deactivate(api: OpenClawPluginApi): void;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { plugin as default };
|
|
42
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;AAyBmE,UAXzD,MAAA,CAgBO;EAAA,IAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;MAIH,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;OAC0B,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;OAA4B,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;;AAAO,UAdjE,iBAAA,CAoKT;EAAA,MAAA,EAnKS,MAmKT;cAjCe,CAAA,IAAA,EAjIK,OAiIL,CAAA,EAAA,IAAA;uBA6BE,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GA7JqD,OA6JrD,CAAA,OAAA,CAAA,CAAA,EAAA,IAAA;EAAiB,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,IAAA,GA5JyB,OA4JzB,CAAA,IAAA,CAAA,EAAA,QAAA,EAAA;;;;UAvJzB,OAAA;;;;cAII;wCAC0B,4BAA4B;;;;;;;;cA+G9D;;;;;gBAMU;kBA6BE"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/openclaw-mobile",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "OpenClaw mobile plugin for Alfe — outbound SMS and phone calls via Twilio",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"import": "./dist/index.js"
|
|
12
13
|
},
|
|
13
14
|
"./plugin": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
15
|
+
"types": "./dist/plugin.d.ts",
|
|
16
|
+
"require": "./dist/plugin.cjs",
|
|
17
|
+
"import": "./dist/plugin.js"
|
|
16
18
|
}
|
|
17
19
|
},
|
|
18
20
|
"openclaw": {
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
],
|
|
27
29
|
"dependencies": {
|
|
28
30
|
"@sinclair/typebox": "^0.34.48",
|
|
29
|
-
"@alfe.ai/config": "0.0.
|
|
31
|
+
"@alfe.ai/config": "0.0.7"
|
|
30
32
|
},
|
|
31
33
|
"scripts": {
|
|
32
34
|
"build": "tsdown",
|