@privateclaw/privateclaw 0.1.29 → 0.1.32
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/README.md +6 -6
- package/dist/audio-transcriber.js +98 -20
- package/dist/audio-transcriber.js.map +1 -1
- package/dist/cli.js +17 -5
- package/dist/cli.js.map +1 -1
- package/dist/openclaw-plugin.js +25 -12
- package/dist/openclaw-plugin.js.map +1 -1
- package/dist/pair-session.d.ts +1 -0
- package/dist/pair-session.js +10 -2
- package/dist/pair-session.js.map +1 -1
- package/dist/session-control.js +5 -5
- package/dist/session-control.js.map +1 -1
- package/dist/text.d.ts +7 -0
- package/dist/text.js +25 -1
- package/dist/text.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/audio-transcriber.test.ts +152 -0
- package/src/audio-transcriber.ts +116 -23
- package/src/cli.ts +21 -4
- package/src/openclaw-plugin.test.ts +6 -0
- package/src/openclaw-plugin.ts +29 -11
- package/src/pair-session.ts +11 -1
- package/src/session-control.test.ts +40 -0
- package/src/session-control.ts +9 -6
- package/src/text.test.ts +26 -0
- package/src/text.ts +50 -3
package/dist/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,OAAe;IAClE,OAAO,GAAG,OAAO,KAAK,OAAO,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,OAAe;IAEf,OAAO,GAAG,OAAO,MAAM,OAAO,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAI3C;IACC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,mBAAmB,CACxB,oBAAoB,MAAM,CAAC,SAAS,aAAa,MAAM,CAAC,SAAS,oCAAoC,EACrG,6BAA6B,MAA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B,CAC1B,MAAM,SAAS,oDAAoD,aAAa,yBAAyB,aAAa,kBAAkB,SAAS,QAAQ,EACzJ,WAAW,SAAS,8FAA8F,aAAa,oCAAoC,aAAa,kBAAkB,SAAS,iCAAiC,CAC7O,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,iCAAiC,GAAG,qBAAqB,CACpE,oBAAoB,EACpB,oCAAoC,CACrC,CAAC;AAEF,MAAM,UAAU,+BAA+B,CAAC,MAAc;IAC5D,OAAO,0BAA0B,qBAAqB,CACpD,MAAM,MAAM,OAAO,EACnB,YAAY,MAAM,iBAAiB,CACpC,EAAE,CAAC;AACN,CAAC;AAED,MAAM,UAAU,+CAA+C,CAC7D,OAAe;IAEf,OAAO,0BAA0B,qBAAqB,CACpD,UAAU,OAAO,EAAE,EACnB,mDAAmD,OAAO,EAAE,CAC7D,EAAE,CAAC;AACN,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,OAAe;IACjE,OAAO,iCAAiC,CACtC,qBAAqB,CACnB,uBAAuB,OAAO,EAAE,EAChC,2CAA2C,OAAO,EAAE,CACrD,CACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,qCAAqC,GAAG,qBAAqB,CACxE,uCAAuC,EACvC,iFAAiF,CAClF,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,qBAAqB,CACrE,kCAAkC,EAClC,sEAAsE,CACvE,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAG,qBAAqB,CACnE,kBAAkB,EAClB,uCAAuC,CACxC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,qBAAqB,CACrE,kBAAkB,EAClB,wCAAwC,CACzC,CAAC"}
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privateclaw/privateclaw",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "PrivateClaw provider runtime and OpenClaw-compatible plugin adapter. iOS public beta: https://testflight.apple.com/join/XvgJ9c33 ; Android closed alpha requires joining https://groups.google.com/g/gg-studio-ai-products before installing https://play.google.com/store/apps/details?id=gg.ai.privateclaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
buildPreferredAudioTranscriber,
|
|
9
9
|
createOpenAICompatibleAudioTranscriber,
|
|
10
10
|
resolvePrivateClawSttConfig,
|
|
11
|
+
resolvePrivateClawWhisperCliConfig,
|
|
11
12
|
} from "./audio-transcriber.js";
|
|
12
13
|
|
|
13
14
|
test("resolvePrivateClawSttConfig reads the default OpenClaw audio model config", () => {
|
|
@@ -73,6 +74,49 @@ test("resolvePrivateClawSttConfig accepts inline audio-model headers", () => {
|
|
|
73
74
|
});
|
|
74
75
|
});
|
|
75
76
|
|
|
77
|
+
test("resolvePrivateClawWhisperCliConfig accepts recognizable help text even when the CLI exits non-zero", () => {
|
|
78
|
+
const resolved = resolvePrivateClawWhisperCliConfig({
|
|
79
|
+
env: {
|
|
80
|
+
PRIVATECLAW_WHISPER_MODEL: "large-v3",
|
|
81
|
+
},
|
|
82
|
+
spawnSyncImpl: (() =>
|
|
83
|
+
({
|
|
84
|
+
pid: 123,
|
|
85
|
+
output: [null, "", "usage: whisper [options]\n --model MODEL\n --output_dir OUTPUT_DIR\n --task TASK\n"],
|
|
86
|
+
stdout: "",
|
|
87
|
+
stderr:
|
|
88
|
+
"usage: whisper [options]\n --model MODEL\n --output_dir OUTPUT_DIR\n --task TASK\n",
|
|
89
|
+
status: 2,
|
|
90
|
+
signal: null,
|
|
91
|
+
}) as ReturnType<typeof import("node:child_process").spawnSync>),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
assert.deepEqual(resolved, {
|
|
95
|
+
command: "whisper",
|
|
96
|
+
model: "large-v3",
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("resolvePrivateClawWhisperCliConfig rejects timed-out help probes", () => {
|
|
101
|
+
const timeoutError = Object.assign(new Error("whisper probe timed out"), {
|
|
102
|
+
code: "ETIMEDOUT",
|
|
103
|
+
});
|
|
104
|
+
const resolved = resolvePrivateClawWhisperCliConfig({
|
|
105
|
+
spawnSyncImpl: (() =>
|
|
106
|
+
({
|
|
107
|
+
pid: 123,
|
|
108
|
+
output: [null, "usage: whisper\n", ""],
|
|
109
|
+
stdout: "usage: whisper\n",
|
|
110
|
+
stderr: "",
|
|
111
|
+
status: null,
|
|
112
|
+
signal: "SIGTERM",
|
|
113
|
+
error: timeoutError,
|
|
114
|
+
}) as ReturnType<typeof import("node:child_process").spawnSync>),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
assert.equal(resolved, undefined);
|
|
118
|
+
});
|
|
119
|
+
|
|
76
120
|
test("OpenAI-compatible audio transcriber posts audio attachments to /audio/transcriptions", async (t) => {
|
|
77
121
|
const requests: Array<{
|
|
78
122
|
url: string;
|
|
@@ -155,6 +199,114 @@ test("OpenAI-compatible audio transcriber posts audio attachments to /audio/tran
|
|
|
155
199
|
assert.match(requests[1]?.body ?? "", /filename="voice-b\.mp3"/u);
|
|
156
200
|
});
|
|
157
201
|
|
|
202
|
+
test("OpenAI-compatible audio transcriber accepts nested JSON and plain-text transcripts", async (t) => {
|
|
203
|
+
let requestCount = 0;
|
|
204
|
+
const server = createServer((request, response) => {
|
|
205
|
+
void (async () => {
|
|
206
|
+
requestCount += 1;
|
|
207
|
+
response.statusCode = 200;
|
|
208
|
+
if (requestCount === 1) {
|
|
209
|
+
response.setHeader("content-type", "application/json; charset=utf-8");
|
|
210
|
+
response.end(
|
|
211
|
+
JSON.stringify({
|
|
212
|
+
output: [
|
|
213
|
+
{
|
|
214
|
+
content: [{ type: "output_text", text: "nested transcript" }],
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
}),
|
|
218
|
+
);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
response.setHeader("content-type", "text/plain; charset=utf-8");
|
|
222
|
+
response.end("plain transcript");
|
|
223
|
+
})().catch((error) => {
|
|
224
|
+
response.statusCode = 500;
|
|
225
|
+
response.end(String(error));
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
server.listen(0, "127.0.0.1");
|
|
229
|
+
await once(server, "listening");
|
|
230
|
+
const address = server.address();
|
|
231
|
+
if (!address || typeof address === "string") {
|
|
232
|
+
throw new Error("Expected an AddressInfo from the nested-transcript test server.");
|
|
233
|
+
}
|
|
234
|
+
t.after(() => {
|
|
235
|
+
server.close();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const transcriber = createOpenAICompatibleAudioTranscriber({
|
|
239
|
+
baseUrl: `http://127.0.0.1:${address.port}`,
|
|
240
|
+
model: "whisper-1",
|
|
241
|
+
});
|
|
242
|
+
const transcript = await transcriber.transcribeAudioAttachments({
|
|
243
|
+
sessionId: "privateclaw-session",
|
|
244
|
+
requestId: "voice-request-nested",
|
|
245
|
+
attachments: [
|
|
246
|
+
{
|
|
247
|
+
id: "voice-1",
|
|
248
|
+
name: "voice-a.m4a",
|
|
249
|
+
mimeType: "audio/mp4",
|
|
250
|
+
sizeBytes: 4,
|
|
251
|
+
dataBase64: Buffer.from("AAAA").toString("base64"),
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: "voice-2",
|
|
255
|
+
name: "voice-b.mp3",
|
|
256
|
+
mimeType: "audio/mpeg",
|
|
257
|
+
sizeBytes: 4,
|
|
258
|
+
dataBase64: Buffer.from("BBBB").toString("base64"),
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
assert.equal(transcript, "nested transcript\n\nplain transcript");
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test("OpenAI-compatible audio transcriber surfaces missing transcript text in HTTP 200 responses", async (t) => {
|
|
267
|
+
const server = createServer((request, response) => {
|
|
268
|
+
void (async () => {
|
|
269
|
+
response.statusCode = 200;
|
|
270
|
+
response.setHeader("content-type", "application/json; charset=utf-8");
|
|
271
|
+
response.end(JSON.stringify({ ok: true }));
|
|
272
|
+
})().catch((error) => {
|
|
273
|
+
response.statusCode = 500;
|
|
274
|
+
response.end(String(error));
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
server.listen(0, "127.0.0.1");
|
|
278
|
+
await once(server, "listening");
|
|
279
|
+
const address = server.address();
|
|
280
|
+
if (!address || typeof address === "string") {
|
|
281
|
+
throw new Error("Expected an AddressInfo from the missing-transcript test server.");
|
|
282
|
+
}
|
|
283
|
+
t.after(() => {
|
|
284
|
+
server.close();
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const transcriber = createOpenAICompatibleAudioTranscriber({
|
|
288
|
+
baseUrl: `http://127.0.0.1:${address.port}`,
|
|
289
|
+
model: "whisper-1",
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
await assert.rejects(
|
|
293
|
+
transcriber.transcribeAudioAttachments({
|
|
294
|
+
sessionId: "privateclaw-session",
|
|
295
|
+
requestId: "voice-request-missing-transcript",
|
|
296
|
+
attachments: [
|
|
297
|
+
{
|
|
298
|
+
id: "voice-1",
|
|
299
|
+
name: "voice-a.m4a",
|
|
300
|
+
mimeType: "audio/mp4",
|
|
301
|
+
sizeBytes: 4,
|
|
302
|
+
dataBase64: Buffer.from("AAAA").toString("base64"),
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
}),
|
|
306
|
+
/without transcript text/u,
|
|
307
|
+
);
|
|
308
|
+
});
|
|
309
|
+
|
|
158
310
|
test("buildPreferredAudioTranscriber prefers whisper CLI over configured direct STT", async (t) => {
|
|
159
311
|
let directRequestCount = 0;
|
|
160
312
|
const server = createServer((request, response) => {
|
package/src/audio-transcriber.ts
CHANGED
|
@@ -168,6 +168,31 @@ function coerceText(value: string | Buffer | null | undefined): string {
|
|
|
168
168
|
return "";
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
function looksLikeJsonPayload(value: string): boolean {
|
|
172
|
+
const trimmed = value.trimStart();
|
|
173
|
+
return trimmed.startsWith("{") || trimmed.startsWith("[") || trimmed.startsWith('"');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function looksLikeHtmlPayload(value: string): boolean {
|
|
177
|
+
const trimmed = value.trimStart().toLowerCase();
|
|
178
|
+
return trimmed.startsWith("<!doctype html") || trimmed.startsWith("<html") || trimmed.startsWith("<body");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function looksLikeWhisperHelpText(value: string): boolean {
|
|
182
|
+
const trimmed = value.trim();
|
|
183
|
+
if (trimmed === "") {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
return (
|
|
187
|
+
/(?:^|\n)\s*usage:\s*(?:(?:python(?:\d+(?:\.\d+)*)?(?:\s+-m)?)\s+)?(?:openai-)?whisper\b/iu.test(
|
|
188
|
+
trimmed,
|
|
189
|
+
) ||
|
|
190
|
+
(/--model\b/iu.test(trimmed) &&
|
|
191
|
+
/--output_(?:dir|format)\b/iu.test(trimmed) &&
|
|
192
|
+
/--(?:language|task)\b/iu.test(trimmed))
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
171
196
|
function truncateLogDetail(value: string, maxLength = 300): string {
|
|
172
197
|
return value.length > maxLength ? `${value.slice(0, maxLength)}...` : value;
|
|
173
198
|
}
|
|
@@ -218,25 +243,75 @@ function execFileText(
|
|
|
218
243
|
});
|
|
219
244
|
}
|
|
220
245
|
|
|
221
|
-
function
|
|
222
|
-
const
|
|
223
|
-
text?: unknown;
|
|
224
|
-
segments?: Array<{ text?: unknown }>;
|
|
225
|
-
};
|
|
226
|
-
const directText = readString(parsed.text);
|
|
227
|
-
if (directText) {
|
|
228
|
-
return directText;
|
|
229
|
-
}
|
|
230
|
-
const segmentText = Array.isArray(parsed.segments)
|
|
231
|
-
? parsed.segments.flatMap((segment) => {
|
|
232
|
-
const value = readString(segment?.text);
|
|
233
|
-
return value ? [value] : [];
|
|
234
|
-
})
|
|
235
|
-
: [];
|
|
236
|
-
const combined = segmentText.join("").trim();
|
|
246
|
+
function combineTranscriptFragments(fragments: ReadonlyArray<string>): string | null {
|
|
247
|
+
const combined = fragments.join("").trim();
|
|
237
248
|
return combined === "" ? null : combined;
|
|
238
249
|
}
|
|
239
250
|
|
|
251
|
+
function extractTranscriptText(value: unknown, depth = 0): string | null {
|
|
252
|
+
if (depth > 6 || value == null) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
if (typeof value === "string") {
|
|
256
|
+
return readString(value) ?? null;
|
|
257
|
+
}
|
|
258
|
+
if (Array.isArray(value)) {
|
|
259
|
+
const fragments = value.flatMap((entry) => {
|
|
260
|
+
const transcript = extractTranscriptText(entry, depth + 1);
|
|
261
|
+
return transcript ? [transcript] : [];
|
|
262
|
+
});
|
|
263
|
+
return combineTranscriptFragments(fragments);
|
|
264
|
+
}
|
|
265
|
+
if (typeof value !== "object") {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
const parsed = value as Record<string, unknown>;
|
|
269
|
+
for (const key of ["text", "transcript", "output_text"] as const) {
|
|
270
|
+
const directText = readString(parsed[key]);
|
|
271
|
+
if (directText) {
|
|
272
|
+
return directText;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
for (const key of ["segments", "content", "results", "alternatives"] as const) {
|
|
276
|
+
const transcript = extractTranscriptText(parsed[key], depth + 1);
|
|
277
|
+
if (transcript) {
|
|
278
|
+
return transcript;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
for (const key of ["result", "data", "response", "output", "message"] as const) {
|
|
282
|
+
const transcript = extractTranscriptText(parsed[key], depth + 1);
|
|
283
|
+
if (transcript) {
|
|
284
|
+
return transcript;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function parseTranscriptJsonPayload(payload: string): string | null {
|
|
291
|
+
return extractTranscriptText(JSON.parse(payload) as unknown);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function parseTranscriptionResponsePayload(params: {
|
|
295
|
+
payload: string;
|
|
296
|
+
contentType?: string | null;
|
|
297
|
+
}): string | null {
|
|
298
|
+
const trimmedPayload = params.payload.trim();
|
|
299
|
+
if (trimmedPayload === "") {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
const normalizedContentType = params.contentType?.toLowerCase() ?? "";
|
|
303
|
+
if (
|
|
304
|
+
normalizedContentType.includes("json") ||
|
|
305
|
+
looksLikeJsonPayload(trimmedPayload)
|
|
306
|
+
) {
|
|
307
|
+
return parseTranscriptJsonPayload(trimmedPayload);
|
|
308
|
+
}
|
|
309
|
+
if (looksLikeHtmlPayload(trimmedPayload)) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
return trimmedPayload;
|
|
313
|
+
}
|
|
314
|
+
|
|
240
315
|
function buildWhisperOutputFilePath(outputDir: string, fileName: string): string {
|
|
241
316
|
return path.join(
|
|
242
317
|
outputDir,
|
|
@@ -311,6 +386,7 @@ export function resolvePrivateClawWhisperCliConfig(params?: {
|
|
|
311
386
|
spawnSyncImpl?: typeof spawnSync;
|
|
312
387
|
}): PrivateClawWhisperCliConfig | undefined {
|
|
313
388
|
const env = params?.env ?? process.env;
|
|
389
|
+
const probeEnv = params?.env ? { ...process.env, ...params.env } : env;
|
|
314
390
|
const command =
|
|
315
391
|
readString(params?.command) ??
|
|
316
392
|
readString(env.PRIVATECLAW_WHISPER_BIN) ??
|
|
@@ -319,14 +395,15 @@ export function resolvePrivateClawWhisperCliConfig(params?: {
|
|
|
319
395
|
const probe = spawnSyncImpl(command, ["--help"], {
|
|
320
396
|
encoding: "utf8",
|
|
321
397
|
stdio: "pipe",
|
|
322
|
-
timeout:
|
|
323
|
-
env,
|
|
398
|
+
timeout: 30_000,
|
|
399
|
+
env: probeEnv,
|
|
400
|
+
windowsHide: true,
|
|
324
401
|
});
|
|
325
|
-
if (probe.error) {
|
|
402
|
+
if (probe.error || probe.signal) {
|
|
326
403
|
return undefined;
|
|
327
404
|
}
|
|
328
405
|
const helpText = `${coerceText(probe.stdout)}\n${coerceText(probe.stderr)}`;
|
|
329
|
-
if ((
|
|
406
|
+
if (!looksLikeWhisperHelpText(helpText)) {
|
|
330
407
|
return undefined;
|
|
331
408
|
}
|
|
332
409
|
const model =
|
|
@@ -386,8 +463,24 @@ async function transcribeSingleAttachment(params: {
|
|
|
386
463
|
);
|
|
387
464
|
}
|
|
388
465
|
|
|
389
|
-
const
|
|
390
|
-
|
|
466
|
+
const responsePayload = await response.text();
|
|
467
|
+
let transcript: string | null;
|
|
468
|
+
try {
|
|
469
|
+
transcript = parseTranscriptionResponsePayload({
|
|
470
|
+
payload: responsePayload,
|
|
471
|
+
contentType: response.headers.get("content-type"),
|
|
472
|
+
});
|
|
473
|
+
} catch (error) {
|
|
474
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
475
|
+
throw new Error(
|
|
476
|
+
`STT returned an unreadable transcript payload for ${fileName}: ${truncateLogDetail(detail)}`,
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
if (!transcript) {
|
|
480
|
+
throw new Error(
|
|
481
|
+
`STT returned HTTP ${response.status} without transcript text for ${fileName}: ${truncateLogDetail(responsePayload)}`,
|
|
482
|
+
);
|
|
483
|
+
}
|
|
391
484
|
params.onLog?.(
|
|
392
485
|
`[stt] transcribe_complete session=${params.request.sessionId} request=${params.request.requestId} file=${JSON.stringify(fileName)} transcriptChars=${transcript?.length ?? 0}`,
|
|
393
486
|
);
|
|
@@ -444,7 +537,7 @@ async function transcribeSingleAttachmentWithWhisperCli(params: {
|
|
|
444
537
|
maxBuffer: 64 * 1024 * 1024,
|
|
445
538
|
});
|
|
446
539
|
const transcriptPayload = await readFile(outputPath, "utf8");
|
|
447
|
-
const transcript =
|
|
540
|
+
const transcript = parseTranscriptJsonPayload(transcriptPayload);
|
|
448
541
|
params.onLog?.(
|
|
449
542
|
`[stt] whisper_transcribe_complete session=${params.request.sessionId} request=${params.request.requestId} file=${JSON.stringify(fileName)} transcriptChars=${transcript?.length ?? 0}`,
|
|
450
543
|
);
|
package/src/cli.ts
CHANGED
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
runPrivateClawSetup,
|
|
46
46
|
} from "./setup.js";
|
|
47
47
|
import {
|
|
48
|
+
appendPrivateClawAppInstallFooter,
|
|
48
49
|
buildPrivateClawBackgroundDaemonReminder,
|
|
49
50
|
formatBilingualInline,
|
|
50
51
|
PRIVATECLAW_CLI_DURATION_OPTION_DESCRIPTION,
|
|
@@ -57,6 +58,7 @@ import {
|
|
|
57
58
|
PRIVATECLAW_CLI_SESSIONS_QR_DESCRIPTION,
|
|
58
59
|
PRIVATECLAW_CLI_SINGLE_OPTION_DESCRIPTION,
|
|
59
60
|
PRIVATECLAW_CLI_VERBOSE_OPTION_DESCRIPTION,
|
|
61
|
+
writePrivateClawAppInstallFooter,
|
|
60
62
|
} from "./text.js";
|
|
61
63
|
import type {
|
|
62
64
|
PrivateClawProviderHandoffState,
|
|
@@ -340,6 +342,13 @@ kick <sessionId> <appId>`);
|
|
|
340
342
|
console.log(`sessions kill: ${PRIVATECLAW_CLI_SESSIONS_KILL_DESCRIPTION}`);
|
|
341
343
|
console.log(`sessions killall: ${PRIVATECLAW_CLI_SESSIONS_KILLALL_DESCRIPTION}`);
|
|
342
344
|
console.log(`killall: ${PRIVATECLAW_CLI_SESSIONS_KILLALL_DESCRIPTION}`);
|
|
345
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function formatCliErrorWithFooter(error: unknown): string {
|
|
349
|
+
return appendPrivateClawAppInstallFooter(
|
|
350
|
+
error instanceof Error ? error.message : String(error),
|
|
351
|
+
);
|
|
343
352
|
}
|
|
344
353
|
|
|
345
354
|
async function runSetupCommand(args: string[]): Promise<void> {
|
|
@@ -603,6 +612,7 @@ async function runPairCommand(args: string[]): Promise<void> {
|
|
|
603
612
|
bundle.invite.sessionId,
|
|
604
613
|
),
|
|
605
614
|
);
|
|
615
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
606
616
|
}
|
|
607
617
|
|
|
608
618
|
async function runSessionsCommand(args: string[]): Promise<void> {
|
|
@@ -709,6 +719,7 @@ async function runSessionsKillCommand(args: string[]): Promise<void> {
|
|
|
709
719
|
`Session ${result.session.sessionId} has been terminated.`,
|
|
710
720
|
),
|
|
711
721
|
);
|
|
722
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
712
723
|
}
|
|
713
724
|
|
|
714
725
|
async function runSessionsKillallCommand(args: string[]): Promise<void> {
|
|
@@ -745,6 +756,7 @@ async function runSessionsKillallCommand(args: string[]): Promise<void> {
|
|
|
745
756
|
"There are no background daemon sessions to terminate.",
|
|
746
757
|
),
|
|
747
758
|
);
|
|
759
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
748
760
|
return;
|
|
749
761
|
}
|
|
750
762
|
|
|
@@ -787,6 +799,7 @@ async function runSessionsKillallCommand(args: string[]): Promise<void> {
|
|
|
787
799
|
}
|
|
788
800
|
process.exitCode = 1;
|
|
789
801
|
}
|
|
802
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
790
803
|
}
|
|
791
804
|
|
|
792
805
|
async function runSessionsQrCommand(args: string[]): Promise<void> {
|
|
@@ -833,12 +846,14 @@ async function runSessionsQrCommand(args: string[]): Promise<void> {
|
|
|
833
846
|
}
|
|
834
847
|
return;
|
|
835
848
|
}
|
|
849
|
+
const writeLine = (line: string) => {
|
|
850
|
+
console.log(line);
|
|
851
|
+
};
|
|
836
852
|
await renderInviteBundleOutput(result.bundle, {
|
|
837
853
|
qrMediaDir: resolvePrivateClawMediaDir(),
|
|
838
854
|
...(parsed.values.open ? { openInBrowser: true } : {}),
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
},
|
|
855
|
+
includeFooter: false,
|
|
856
|
+
writeLine,
|
|
842
857
|
});
|
|
843
858
|
if (parsed.values.notify) {
|
|
844
859
|
console.log(
|
|
@@ -848,6 +863,7 @@ async function runSessionsQrCommand(args: string[]): Promise<void> {
|
|
|
848
863
|
),
|
|
849
864
|
);
|
|
850
865
|
}
|
|
866
|
+
writePrivateClawAppInstallFooter(writeLine);
|
|
851
867
|
}
|
|
852
868
|
|
|
853
869
|
async function runKickCommand(args: string[]): Promise<void> {
|
|
@@ -894,6 +910,7 @@ async function runKickCommand(args: string[]): Promise<void> {
|
|
|
894
910
|
`Removed ${result.participant.displayName} (${result.participant.appId}) from session ${result.session.sessionId}.`,
|
|
895
911
|
),
|
|
896
912
|
);
|
|
913
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
897
914
|
}
|
|
898
915
|
|
|
899
916
|
const argv = process.argv.slice(2);
|
|
@@ -921,6 +938,6 @@ try {
|
|
|
921
938
|
throw new Error(`Unsupported privateclaw-provider command: ${command}`);
|
|
922
939
|
}
|
|
923
940
|
} catch (error) {
|
|
924
|
-
console.error(
|
|
941
|
+
console.error(formatCliErrorWithFooter(error));
|
|
925
942
|
process.exitCode = 1;
|
|
926
943
|
}
|
|
@@ -168,6 +168,9 @@ test("privateclaw command writes QR media into the OpenClaw state media director
|
|
|
168
168
|
assert.ok(!reply.text.includes("<qqimg>"));
|
|
169
169
|
assert.match(reply.text, /邀请链接 \/ Invite URI/);
|
|
170
170
|
assert.match(reply.text, /PrivateClaw 会话|PrivateClaw session/);
|
|
171
|
+
assert.match(reply.text, /TestFlight/i);
|
|
172
|
+
assert.match(reply.text, /Google Play/i);
|
|
173
|
+
assert.match(reply.text, /Google Group/i);
|
|
171
174
|
|
|
172
175
|
const inviteUri = reply.text.match(/privateclaw:\/\/connect\?payload=\S+/)?.[0];
|
|
173
176
|
assert.ok(inviteUri, "reply text should include a PrivateClaw invite URI");
|
|
@@ -239,6 +242,9 @@ test("privateclaw command embeds qqimg tags for QQ channel replies", async (t) =
|
|
|
239
242
|
assert.ok(reply.text);
|
|
240
243
|
assert.equal(reply.mediaUrl, undefined);
|
|
241
244
|
assert.match(reply.text, /<qqimg>[^<]+<\/qqimg>/);
|
|
245
|
+
assert.match(reply.text, /TestFlight/i);
|
|
246
|
+
assert.match(reply.text, /Google Play/i);
|
|
247
|
+
assert.match(reply.text, /Google Group/i);
|
|
242
248
|
|
|
243
249
|
const inviteUri = reply.text.match(/privateclaw:\/\/connect\?payload=\S+/)?.[0];
|
|
244
250
|
assert.ok(inviteUri, "reply text should include a PrivateClaw invite URI");
|
package/src/openclaw-plugin.ts
CHANGED
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
type PrivateClawControlHostKind,
|
|
51
51
|
} from "./session-control.js";
|
|
52
52
|
import {
|
|
53
|
+
appendPrivateClawAppInstallFooter,
|
|
53
54
|
buildPrivateClawBackgroundDaemonReminder,
|
|
54
55
|
buildPrivateClawCommandErrorMessage,
|
|
55
56
|
formatBilingualInline,
|
|
@@ -73,6 +74,7 @@ import {
|
|
|
73
74
|
PRIVATECLAW_COMMAND_DESCRIPTION,
|
|
74
75
|
PRIVATECLAW_INVITE_URI_LABEL,
|
|
75
76
|
PRIVATECLAW_PLUGIN_DESCRIPTION,
|
|
77
|
+
writePrivateClawAppInstallFooter,
|
|
76
78
|
} from "./text.js";
|
|
77
79
|
import type {
|
|
78
80
|
PrivateClawAgentBridge,
|
|
@@ -180,12 +182,12 @@ function buildCommandReplyText(params: {
|
|
|
180
182
|
}): string {
|
|
181
183
|
const baseText =
|
|
182
184
|
`${params.announcementText}\n\n${PRIVATECLAW_INVITE_URI_LABEL}:\n${params.inviteUri}`;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
const text = !channelRequiresInlineImageReply(params.channel)
|
|
186
|
+
? baseText
|
|
187
|
+
: `${baseText}\n\n<qqimg>${params.qrImagePath}</qqimg>`;
|
|
186
188
|
|
|
187
189
|
// QQ command replies expand images from inline <qqimg> tags instead of mediaUrl payloads.
|
|
188
|
-
return
|
|
190
|
+
return appendPrivateClawAppInstallFooter(text);
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
function readNumber(value: unknown): number | undefined {
|
|
@@ -932,6 +934,9 @@ class PrivateClawPluginRuntime {
|
|
|
932
934
|
bundle.invite.sessionId,
|
|
933
935
|
),
|
|
934
936
|
);
|
|
937
|
+
writePrivateClawAppInstallFooter(
|
|
938
|
+
params?.writeLine ?? ((line: string) => console.log(line)),
|
|
939
|
+
);
|
|
935
940
|
return bundle;
|
|
936
941
|
}
|
|
937
942
|
|
|
@@ -1072,6 +1077,7 @@ class PrivateClawPluginRuntime {
|
|
|
1072
1077
|
const bundle = await renderInviteBundleOutput(result.bundle, {
|
|
1073
1078
|
qrMediaDir: this.getMediaDir(),
|
|
1074
1079
|
...(params?.openInBrowser ? { openInBrowser: true } : {}),
|
|
1080
|
+
includeFooter: false,
|
|
1075
1081
|
...(params?.writeLine ? { writeLine: params.writeLine } : {}),
|
|
1076
1082
|
});
|
|
1077
1083
|
return {
|
|
@@ -1099,6 +1105,10 @@ function formatCommandError(error: unknown): string {
|
|
|
1099
1105
|
return error instanceof Error ? error.message : String(error);
|
|
1100
1106
|
}
|
|
1101
1107
|
|
|
1108
|
+
function formatCommandErrorWithFooter(error: unknown): string {
|
|
1109
|
+
return appendPrivateClawAppInstallFooter(formatCommandError(error));
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1102
1112
|
function createPluginDefinition(
|
|
1103
1113
|
runtimeFactory: (api: OpenClawPluginApiCompat) => PrivateClawPluginRuntime,
|
|
1104
1114
|
): OpenClawExtensionPluginCompat {
|
|
@@ -1237,7 +1247,7 @@ function createPluginDefinition(
|
|
|
1237
1247
|
},
|
|
1238
1248
|
});
|
|
1239
1249
|
} catch (error) {
|
|
1240
|
-
console.error(
|
|
1250
|
+
console.error(formatCommandErrorWithFooter(error));
|
|
1241
1251
|
process.exitCode = 1;
|
|
1242
1252
|
}
|
|
1243
1253
|
});
|
|
@@ -1250,6 +1260,9 @@ function createPluginDefinition(
|
|
|
1250
1260
|
.option("--notify", PRIVATECLAW_CLI_NOTIFY_OPTION_DESCRIPTION)
|
|
1251
1261
|
.action(async (sessionIdRaw: unknown, rawOptions: unknown) => {
|
|
1252
1262
|
try {
|
|
1263
|
+
const writeLine = (line: string) => {
|
|
1264
|
+
console.log(line);
|
|
1265
|
+
};
|
|
1253
1266
|
const sessionId = readString(sessionIdRaw);
|
|
1254
1267
|
if (!sessionId) {
|
|
1255
1268
|
throw new Error(
|
|
@@ -1263,9 +1276,7 @@ function createPluginDefinition(
|
|
|
1263
1276
|
const result = await runtime.printManagedSessionQr(sessionId, {
|
|
1264
1277
|
...(options.notify ? { notifyParticipants: true } : {}),
|
|
1265
1278
|
...(options.open ? { openInBrowser: true } : {}),
|
|
1266
|
-
writeLine
|
|
1267
|
-
console.log(line);
|
|
1268
|
-
},
|
|
1279
|
+
writeLine,
|
|
1269
1280
|
});
|
|
1270
1281
|
if (options.notify && !isManagedSessionQrLegacyResult(result)) {
|
|
1271
1282
|
console.log(
|
|
@@ -1277,8 +1288,11 @@ function createPluginDefinition(
|
|
|
1277
1288
|
} else if (options.notify && isManagedSessionQrLegacyResult(result)) {
|
|
1278
1289
|
process.exitCode = 1;
|
|
1279
1290
|
}
|
|
1291
|
+
if (!isManagedSessionQrLegacyResult(result)) {
|
|
1292
|
+
writePrivateClawAppInstallFooter(writeLine);
|
|
1293
|
+
}
|
|
1280
1294
|
} catch (error) {
|
|
1281
|
-
console.error(
|
|
1295
|
+
console.error(formatCommandErrorWithFooter(error));
|
|
1282
1296
|
process.exitCode = 1;
|
|
1283
1297
|
}
|
|
1284
1298
|
});
|
|
@@ -1310,8 +1324,9 @@ function createPluginDefinition(
|
|
|
1310
1324
|
`Session ${result.session.sessionId} has been terminated.`,
|
|
1311
1325
|
),
|
|
1312
1326
|
);
|
|
1327
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
1313
1328
|
} catch (error) {
|
|
1314
|
-
console.error(
|
|
1329
|
+
console.error(formatCommandErrorWithFooter(error));
|
|
1315
1330
|
process.exitCode = 1;
|
|
1316
1331
|
}
|
|
1317
1332
|
});
|
|
@@ -1329,6 +1344,7 @@ function createPluginDefinition(
|
|
|
1329
1344
|
"There are no background daemon sessions to terminate.",
|
|
1330
1345
|
),
|
|
1331
1346
|
);
|
|
1347
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
1332
1348
|
return;
|
|
1333
1349
|
}
|
|
1334
1350
|
if (result.closed.length > 0) {
|
|
@@ -1369,8 +1385,9 @@ function createPluginDefinition(
|
|
|
1369
1385
|
}
|
|
1370
1386
|
process.exitCode = 1;
|
|
1371
1387
|
}
|
|
1388
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
1372
1389
|
} catch (error) {
|
|
1373
|
-
console.error(
|
|
1390
|
+
console.error(formatCommandErrorWithFooter(error));
|
|
1374
1391
|
process.exitCode = 1;
|
|
1375
1392
|
}
|
|
1376
1393
|
});
|
|
@@ -1398,6 +1415,7 @@ function createPluginDefinition(
|
|
|
1398
1415
|
`Removed ${result.participant.displayName} (${result.participant.appId}) from session ${result.session.sessionId}.`,
|
|
1399
1416
|
),
|
|
1400
1417
|
);
|
|
1418
|
+
writePrivateClawAppInstallFooter((line) => console.log(line));
|
|
1401
1419
|
});
|
|
1402
1420
|
},
|
|
1403
1421
|
{ commands: ["privateclaw"] },
|