@alfe.ai/openclaw-voice 0.0.10 → 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 -8
- package/dist/plugin.d.cts +11 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.js +31 -8
- package/package.json +1 -1
package/dist/plugin.cjs
CHANGED
|
@@ -140,17 +140,17 @@ const plugin = {
|
|
|
140
140
|
version: "0.2.0",
|
|
141
141
|
activate(api) {
|
|
142
142
|
const log = api.logger;
|
|
143
|
-
if (api.registrationMode === "cli-metadata") {
|
|
144
|
-
log.debug("CLI metadata mode — skipping voice resource init");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
143
|
for (const tool of voiceTools) api.registerTool(tool);
|
|
148
144
|
log.info(`Registered ${String(voiceTools.length)} voice tools: ${voiceTools.map((t) => t.name).join(", ")}`);
|
|
149
|
-
|
|
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
|
+
}
|
|
150
152
|
globalThis.__voiceGatewayActivated = true;
|
|
151
153
|
log.info("Alfe Voice plugin activating...");
|
|
152
|
-
const fullConfig = api.config ?? {};
|
|
153
|
-
const pluginConfig = fullConfig.plugins?.entries?.["@alfe.ai/openclaw-voice"]?.config ?? fullConfig.plugins?.entries?.["voice-gateway"]?.config ?? {};
|
|
154
154
|
voiceServiceUrl = pluginConfig.voiceServiceUrl ?? `http://localhost:${String(pluginConfig.voiceServicePort ?? "3100")}`;
|
|
155
155
|
voiceServiceApiKey = pluginConfig.voiceServiceApiKey ?? "";
|
|
156
156
|
log.info(`Voice service: ${voiceServiceUrl}`);
|
|
@@ -163,7 +163,20 @@ const plugin = {
|
|
|
163
163
|
}).catch((err) => {
|
|
164
164
|
log.debug(`Daemon connect failed: ${err.message}`);
|
|
165
165
|
});
|
|
166
|
-
}
|
|
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
|
+
};
|
|
167
180
|
api.registerGatewayMethod("voice.speak", async (...args) => {
|
|
168
181
|
const { text } = args[0];
|
|
169
182
|
log.info(`voice.speak RPC → text=${text?.slice(0, 50) ?? "(none)"}...`);
|
|
@@ -175,6 +188,16 @@ const plugin = {
|
|
|
175
188
|
const event = eventArgs[0];
|
|
176
189
|
if (eventArgs[1].channelId.includes("voice")) log.debug(`Voice-related message from ${event.from}: ${event.content.slice(0, 100)}`);
|
|
177
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();
|
|
178
201
|
log.info("Alfe Voice plugin activated");
|
|
179
202
|
},
|
|
180
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,17 +140,17 @@ const plugin = {
|
|
|
140
140
|
version: "0.2.0",
|
|
141
141
|
activate(api) {
|
|
142
142
|
const log = api.logger;
|
|
143
|
-
if (api.registrationMode === "cli-metadata") {
|
|
144
|
-
log.debug("CLI metadata mode — skipping voice resource init");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
143
|
for (const tool of voiceTools) api.registerTool(tool);
|
|
148
144
|
log.info(`Registered ${String(voiceTools.length)} voice tools: ${voiceTools.map((t) => t.name).join(", ")}`);
|
|
149
|
-
|
|
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
|
+
}
|
|
150
152
|
globalThis.__voiceGatewayActivated = true;
|
|
151
153
|
log.info("Alfe Voice plugin activating...");
|
|
152
|
-
const fullConfig = api.config ?? {};
|
|
153
|
-
const pluginConfig = fullConfig.plugins?.entries?.["@alfe.ai/openclaw-voice"]?.config ?? fullConfig.plugins?.entries?.["voice-gateway"]?.config ?? {};
|
|
154
154
|
voiceServiceUrl = pluginConfig.voiceServiceUrl ?? `http://localhost:${String(pluginConfig.voiceServicePort ?? "3100")}`;
|
|
155
155
|
voiceServiceApiKey = pluginConfig.voiceServiceApiKey ?? "";
|
|
156
156
|
log.info(`Voice service: ${voiceServiceUrl}`);
|
|
@@ -163,7 +163,20 @@ const plugin = {
|
|
|
163
163
|
}).catch((err) => {
|
|
164
164
|
log.debug(`Daemon connect failed: ${err.message}`);
|
|
165
165
|
});
|
|
166
|
-
}
|
|
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
|
+
};
|
|
167
180
|
api.registerGatewayMethod("voice.speak", async (...args) => {
|
|
168
181
|
const { text } = args[0];
|
|
169
182
|
log.info(`voice.speak RPC → text=${text?.slice(0, 50) ?? "(none)"}...`);
|
|
@@ -175,6 +188,16 @@ const plugin = {
|
|
|
175
188
|
const event = eventArgs[0];
|
|
176
189
|
if (eventArgs[1].channelId.includes("voice")) log.debug(`Voice-related message from ${event.from}: ${event.content.slice(0, 100)}`);
|
|
177
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();
|
|
178
201
|
log.info("Alfe Voice plugin activated");
|
|
179
202
|
},
|
|
180
203
|
deactivate(api) {
|