@alfe.ai/openclaw-voice 0.0.11 → 0.0.12
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/plugin.cjs +31 -5
- package/dist/plugin.d.cts +11 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.js +31 -5
- package/package.json +1 -1
package/dist/plugin.cjs
CHANGED
|
@@ -140,14 +140,17 @@ const plugin = {
|
|
|
140
140
|
version: "0.2.0",
|
|
141
141
|
activate(api) {
|
|
142
142
|
const log = api.logger;
|
|
143
|
-
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
144
143
|
for (const tool of voiceTools) api.registerTool(tool);
|
|
145
144
|
log.info(`Registered ${String(voiceTools.length)} voice tools: ${voiceTools.map((t) => t.name).join(", ")}`);
|
|
146
|
-
|
|
145
|
+
const fullConfig = api.config ?? {};
|
|
146
|
+
const pluginConfig = fullConfig.plugins?.entries?.["@alfe.ai/openclaw-voice"]?.config ?? fullConfig.plugins?.entries?.["voice-gateway"]?.config ?? {};
|
|
147
|
+
const startVoiceService = () => {
|
|
148
|
+
if (globalThis.__voiceGatewayActivated === true) {
|
|
149
|
+
log.debug("Alfe Voice plugin already activated — skipping duplicate");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
147
152
|
globalThis.__voiceGatewayActivated = true;
|
|
148
153
|
log.info("Alfe Voice plugin activating...");
|
|
149
|
-
const fullConfig = api.config ?? {};
|
|
150
|
-
const pluginConfig = fullConfig.plugins?.entries?.["@alfe.ai/openclaw-voice"]?.config ?? fullConfig.plugins?.entries?.["voice-gateway"]?.config ?? {};
|
|
151
154
|
voiceServiceUrl = pluginConfig.voiceServiceUrl ?? `http://localhost:${String(pluginConfig.voiceServicePort ?? "3100")}`;
|
|
152
155
|
voiceServiceApiKey = pluginConfig.voiceServiceApiKey ?? "";
|
|
153
156
|
log.info(`Voice service: ${voiceServiceUrl}`);
|
|
@@ -160,7 +163,20 @@ const plugin = {
|
|
|
160
163
|
}).catch((err) => {
|
|
161
164
|
log.debug(`Daemon connect failed: ${err.message}`);
|
|
162
165
|
});
|
|
163
|
-
}
|
|
166
|
+
};
|
|
167
|
+
const stopVoiceService = () => {
|
|
168
|
+
globalThis.__voiceGatewayActivated = false;
|
|
169
|
+
if (daemonIpcClient) {
|
|
170
|
+
try {
|
|
171
|
+
daemonIpcClient.stop();
|
|
172
|
+
log.info("Disconnected from Alfe daemon");
|
|
173
|
+
} catch (err) {
|
|
174
|
+
log.debug(`Error disconnecting from daemon: ${err.message}`);
|
|
175
|
+
}
|
|
176
|
+
daemonIpcClient = null;
|
|
177
|
+
}
|
|
178
|
+
log.info("Alfe Voice plugin deactivated");
|
|
179
|
+
};
|
|
164
180
|
api.registerGatewayMethod("voice.speak", async (...args) => {
|
|
165
181
|
const { text } = args[0];
|
|
166
182
|
log.info(`voice.speak RPC → text=${text?.slice(0, 50) ?? "(none)"}...`);
|
|
@@ -172,6 +188,16 @@ const plugin = {
|
|
|
172
188
|
const event = eventArgs[0];
|
|
173
189
|
if (eventArgs[1].channelId.includes("voice")) log.debug(`Voice-related message from ${event.from}: ${event.content.slice(0, 100)}`);
|
|
174
190
|
});
|
|
191
|
+
if (api.registerService) api.registerService({
|
|
192
|
+
id: "alfe-voice-daemon",
|
|
193
|
+
start: () => {
|
|
194
|
+
startVoiceService();
|
|
195
|
+
},
|
|
196
|
+
stop: () => {
|
|
197
|
+
stopVoiceService();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
else if (!globalThis.__voiceGatewayActivated) startVoiceService();
|
|
175
201
|
log.info("Alfe Voice plugin activated");
|
|
176
202
|
},
|
|
177
203
|
deactivate(api) {
|
package/dist/plugin.d.cts
CHANGED
|
@@ -25,12 +25,23 @@ interface OpenClawConfig {
|
|
|
25
25
|
};
|
|
26
26
|
[key: string]: unknown;
|
|
27
27
|
}
|
|
28
|
+
interface PluginServiceContext {
|
|
29
|
+
config: Record<string, unknown>;
|
|
30
|
+
workspaceDir?: string;
|
|
31
|
+
stateDir: string;
|
|
32
|
+
logger: Logger;
|
|
33
|
+
}
|
|
28
34
|
interface OpenClawPluginApi {
|
|
29
35
|
logger: Logger;
|
|
30
36
|
registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
|
|
31
37
|
config?: OpenClawConfig;
|
|
32
38
|
registerTool(tool: ToolDef): void;
|
|
33
39
|
registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
|
|
40
|
+
registerService?(service: {
|
|
41
|
+
id: string;
|
|
42
|
+
start: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
43
|
+
stop?: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
44
|
+
}): void;
|
|
34
45
|
on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
|
|
35
46
|
priority?: number;
|
|
36
47
|
}): void;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -25,12 +25,23 @@ interface OpenClawConfig {
|
|
|
25
25
|
};
|
|
26
26
|
[key: string]: unknown;
|
|
27
27
|
}
|
|
28
|
+
interface PluginServiceContext {
|
|
29
|
+
config: Record<string, unknown>;
|
|
30
|
+
workspaceDir?: string;
|
|
31
|
+
stateDir: string;
|
|
32
|
+
logger: Logger;
|
|
33
|
+
}
|
|
28
34
|
interface OpenClawPluginApi {
|
|
29
35
|
logger: Logger;
|
|
30
36
|
registrationMode?: 'full' | 'setup-only' | 'setup-runtime' | 'cli-metadata';
|
|
31
37
|
config?: OpenClawConfig;
|
|
32
38
|
registerTool(tool: ToolDef): void;
|
|
33
39
|
registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
|
|
40
|
+
registerService?(service: {
|
|
41
|
+
id: string;
|
|
42
|
+
start: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
43
|
+
stop?: (ctx: PluginServiceContext) => void | Promise<void>;
|
|
44
|
+
}): void;
|
|
34
45
|
on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
|
|
35
46
|
priority?: number;
|
|
36
47
|
}): void;
|
package/dist/plugin.js
CHANGED
|
@@ -140,14 +140,17 @@ const plugin = {
|
|
|
140
140
|
version: "0.2.0",
|
|
141
141
|
activate(api) {
|
|
142
142
|
const log = api.logger;
|
|
143
|
-
if (api.registrationMode && api.registrationMode !== "full") return;
|
|
144
143
|
for (const tool of voiceTools) api.registerTool(tool);
|
|
145
144
|
log.info(`Registered ${String(voiceTools.length)} voice tools: ${voiceTools.map((t) => t.name).join(", ")}`);
|
|
146
|
-
|
|
145
|
+
const fullConfig = api.config ?? {};
|
|
146
|
+
const pluginConfig = fullConfig.plugins?.entries?.["@alfe.ai/openclaw-voice"]?.config ?? fullConfig.plugins?.entries?.["voice-gateway"]?.config ?? {};
|
|
147
|
+
const startVoiceService = () => {
|
|
148
|
+
if (globalThis.__voiceGatewayActivated === true) {
|
|
149
|
+
log.debug("Alfe Voice plugin already activated — skipping duplicate");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
147
152
|
globalThis.__voiceGatewayActivated = true;
|
|
148
153
|
log.info("Alfe Voice plugin activating...");
|
|
149
|
-
const fullConfig = api.config ?? {};
|
|
150
|
-
const pluginConfig = fullConfig.plugins?.entries?.["@alfe.ai/openclaw-voice"]?.config ?? fullConfig.plugins?.entries?.["voice-gateway"]?.config ?? {};
|
|
151
154
|
voiceServiceUrl = pluginConfig.voiceServiceUrl ?? `http://localhost:${String(pluginConfig.voiceServicePort ?? "3100")}`;
|
|
152
155
|
voiceServiceApiKey = pluginConfig.voiceServiceApiKey ?? "";
|
|
153
156
|
log.info(`Voice service: ${voiceServiceUrl}`);
|
|
@@ -160,7 +163,20 @@ const plugin = {
|
|
|
160
163
|
}).catch((err) => {
|
|
161
164
|
log.debug(`Daemon connect failed: ${err.message}`);
|
|
162
165
|
});
|
|
163
|
-
}
|
|
166
|
+
};
|
|
167
|
+
const stopVoiceService = () => {
|
|
168
|
+
globalThis.__voiceGatewayActivated = false;
|
|
169
|
+
if (daemonIpcClient) {
|
|
170
|
+
try {
|
|
171
|
+
daemonIpcClient.stop();
|
|
172
|
+
log.info("Disconnected from Alfe daemon");
|
|
173
|
+
} catch (err) {
|
|
174
|
+
log.debug(`Error disconnecting from daemon: ${err.message}`);
|
|
175
|
+
}
|
|
176
|
+
daemonIpcClient = null;
|
|
177
|
+
}
|
|
178
|
+
log.info("Alfe Voice plugin deactivated");
|
|
179
|
+
};
|
|
164
180
|
api.registerGatewayMethod("voice.speak", async (...args) => {
|
|
165
181
|
const { text } = args[0];
|
|
166
182
|
log.info(`voice.speak RPC → text=${text?.slice(0, 50) ?? "(none)"}...`);
|
|
@@ -172,6 +188,16 @@ const plugin = {
|
|
|
172
188
|
const event = eventArgs[0];
|
|
173
189
|
if (eventArgs[1].channelId.includes("voice")) log.debug(`Voice-related message from ${event.from}: ${event.content.slice(0, 100)}`);
|
|
174
190
|
});
|
|
191
|
+
if (api.registerService) api.registerService({
|
|
192
|
+
id: "alfe-voice-daemon",
|
|
193
|
+
start: () => {
|
|
194
|
+
startVoiceService();
|
|
195
|
+
},
|
|
196
|
+
stop: () => {
|
|
197
|
+
stopVoiceService();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
else if (!globalThis.__voiceGatewayActivated) startVoiceService();
|
|
175
201
|
log.info("Alfe Voice plugin activated");
|
|
176
202
|
},
|
|
177
203
|
deactivate(api) {
|