openclaw-pine-voice 0.1.10 → 0.2.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/auth.d.ts +8 -0
- package/dist/auth.js +63 -37
- package/package.json +4 -2
- package/skills/pine-voice-auth/SKILL.md +1 -1
package/dist/auth.d.ts
CHANGED
|
@@ -8,5 +8,13 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Delegates to the pine-voice SDK for actual API calls.
|
|
10
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Build an updated config that stores credentials and ensures voice tools
|
|
13
|
+
* are present in `tools.allow`. Pure function — no side effects.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildAuthConfig(cfg: Record<string, any>, accessToken: string, userId: string): {
|
|
16
|
+
updatedConfig: Record<string, any>;
|
|
17
|
+
addedTools: string[];
|
|
18
|
+
};
|
|
11
19
|
export declare function registerAuthTools(api: any): void;
|
|
12
20
|
export declare function registerAuthCommands(api: any): void;
|
package/dist/auth.js
CHANGED
|
@@ -16,6 +16,53 @@ import { PineVoice, AuthError } from "pine-voice";
|
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
17
|
const pendingAuth = new Map(); // email → requestToken
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
|
+
// Shared helpers
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
const VOICE_TOOLS = [
|
|
22
|
+
"pine_voice_call_and_wait",
|
|
23
|
+
"pine_voice_call",
|
|
24
|
+
"pine_voice_call_status",
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Build an updated config that stores credentials and ensures voice tools
|
|
28
|
+
* are present in `tools.allow`. Pure function — no side effects.
|
|
29
|
+
*/
|
|
30
|
+
export function buildAuthConfig(cfg, accessToken, userId) {
|
|
31
|
+
const plugins = (cfg.plugins ?? {});
|
|
32
|
+
const entries = (plugins.entries ?? {});
|
|
33
|
+
const pluginEntry = (entries["openclaw-pine-voice"] ?? {});
|
|
34
|
+
const tools = (cfg.tools ?? {});
|
|
35
|
+
const existingAllow = Array.isArray(tools.allow)
|
|
36
|
+
? tools.allow.filter((t) => typeof t === "string")
|
|
37
|
+
: [];
|
|
38
|
+
const addedTools = VOICE_TOOLS.filter(t => !existingAllow.includes(t));
|
|
39
|
+
const mergedAllow = [...existingAllow, ...addedTools];
|
|
40
|
+
return {
|
|
41
|
+
updatedConfig: {
|
|
42
|
+
...cfg,
|
|
43
|
+
plugins: {
|
|
44
|
+
...plugins,
|
|
45
|
+
entries: {
|
|
46
|
+
...entries,
|
|
47
|
+
"openclaw-pine-voice": {
|
|
48
|
+
...pluginEntry,
|
|
49
|
+
config: {
|
|
50
|
+
...(pluginEntry.config ?? {}),
|
|
51
|
+
access_token: accessToken,
|
|
52
|
+
user_id: userId,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
tools: {
|
|
58
|
+
...tools,
|
|
59
|
+
allow: mergedAllow,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
addedTools: [...addedTools],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
19
66
|
// Tool registration (primary path)
|
|
20
67
|
// ---------------------------------------------------------------------------
|
|
21
68
|
export function registerAuthTools(api) {
|
|
@@ -85,36 +132,22 @@ export function registerAuthTools(api) {
|
|
|
85
132
|
}
|
|
86
133
|
try {
|
|
87
134
|
const { accessToken, userId } = await PineVoice.auth.verifyCode(params.email, requestToken, params.code);
|
|
88
|
-
// Write credentials to openclaw.json
|
|
89
135
|
const cfg = api.runtime.config.loadConfig();
|
|
90
|
-
const
|
|
91
|
-
const entries = (plugins.entries ?? {});
|
|
92
|
-
const pluginEntry = (entries["openclaw-pine-voice"] ?? {});
|
|
93
|
-
const updatedConfig = {
|
|
94
|
-
...cfg,
|
|
95
|
-
plugins: {
|
|
96
|
-
...plugins,
|
|
97
|
-
entries: {
|
|
98
|
-
...entries,
|
|
99
|
-
"openclaw-pine-voice": {
|
|
100
|
-
...pluginEntry,
|
|
101
|
-
config: {
|
|
102
|
-
...(pluginEntry.config ?? {}),
|
|
103
|
-
access_token: accessToken,
|
|
104
|
-
user_id: userId,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
};
|
|
136
|
+
const { updatedConfig, addedTools } = buildAuthConfig(cfg, accessToken, userId);
|
|
110
137
|
await api.runtime.config.writeConfigFile(updatedConfig);
|
|
111
138
|
pendingAuth.delete(params.email);
|
|
139
|
+
const toolsNote = addedTools.length > 0
|
|
140
|
+
? ` Voice tools (${addedTools.join(", ")}) have been added to tools.allow.`
|
|
141
|
+
: "";
|
|
112
142
|
api.log?.info?.(`pine-voice: auth successful for ${params.email}, credentials saved`);
|
|
143
|
+
if (addedTools.length > 0) {
|
|
144
|
+
api.log?.info?.(`pine-voice: added ${addedTools.join(", ")} to tools.allow`);
|
|
145
|
+
}
|
|
113
146
|
return {
|
|
114
147
|
content: [
|
|
115
148
|
{
|
|
116
149
|
type: "text",
|
|
117
|
-
text:
|
|
150
|
+
text: `Authentication successful! Credentials have been saved to openclaw.json.${toolsNote} ` +
|
|
118
151
|
"Tell the user to restart the gateway for the changes to take effect:\n\n" +
|
|
119
152
|
" openclaw gateway restart",
|
|
120
153
|
},
|
|
@@ -177,21 +210,14 @@ export function registerAuthCommands(api) {
|
|
|
177
210
|
}
|
|
178
211
|
try {
|
|
179
212
|
const { accessToken, userId } = await PineVoice.auth.verifyCode(opts.email, opts.requestToken || "", opts.code);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
console.log(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
console.log(
|
|
188
|
-
console.log(` "user_id": "${userId}"`);
|
|
189
|
-
console.log(` }`);
|
|
190
|
-
console.log(` }`);
|
|
191
|
-
console.log(` }`);
|
|
192
|
-
console.log(` }`);
|
|
193
|
-
console.log("");
|
|
194
|
-
console.log("Then restart the gateway:");
|
|
213
|
+
const cfg = api.runtime.config.loadConfig();
|
|
214
|
+
const { updatedConfig, addedTools } = buildAuthConfig(cfg, accessToken, userId);
|
|
215
|
+
await api.runtime.config.writeConfigFile(updatedConfig);
|
|
216
|
+
console.log("Authentication successful! Credentials saved to openclaw.json.");
|
|
217
|
+
if (addedTools.length > 0) {
|
|
218
|
+
console.log(`Voice tools (${addedTools.join(", ")}) added to tools.allow.`);
|
|
219
|
+
}
|
|
220
|
+
console.log("\nRestart the gateway for changes to take effect:");
|
|
195
221
|
console.log(" openclaw gateway restart");
|
|
196
222
|
}
|
|
197
223
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-pine-voice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Make phone calls via Pine AI voice agent from OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "tsc",
|
|
28
|
+
"test": "vitest run",
|
|
28
29
|
"prepublishOnly": "npm run build"
|
|
29
30
|
},
|
|
30
31
|
"keywords": [
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"pine-voice": "^0.1.3"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"typescript": "^5.0.0"
|
|
56
|
+
"typescript": "^5.0.0",
|
|
57
|
+
"vitest": "^4.0.18"
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -60,7 +60,7 @@ Call the `pine_voice_auth_verify` tool with the email and code:
|
|
|
60
60
|
pine_voice_auth_verify({ email: "user@example.com", code: "123456" })
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
The tool verifies the code, saves the credentials to `~/.openclaw/openclaw.json
|
|
63
|
+
The tool verifies the code, saves the credentials to `~/.openclaw/openclaw.json`, and automatically adds the voice tools (`pine_voice_call_and_wait`, `pine_voice_call`, `pine_voice_call_status`) to `tools.allow` if they are not already present.
|
|
64
64
|
|
|
65
65
|
**If verification fails:**
|
|
66
66
|
- Invalid code — ask the user to double-check the code and try again (call `pine_voice_auth_verify` with the corrected code).
|