@privateclaw/privateclaw 0.1.39 → 0.1.41
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 +14 -8
- package/dist/cli.js +7 -2
- package/dist/cli.js.map +1 -1
- package/dist/pair-session.js +12 -1
- package/dist/pair-session.js.map +1 -1
- package/dist/relay-provider-client.js +14 -1
- package/dist/relay-provider-client.js.map +1 -1
- package/dist/session-control.js +7 -5
- package/dist/session-control.js.map +1 -1
- package/dist/setup.d.ts +19 -3
- package/dist/setup.js +206 -85
- package/dist/setup.js.map +1 -1
- package/dist/text.d.ts +2 -0
- package/dist/text.js +3 -0
- package/dist/text.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -2
- package/src/cli.ts +7 -1
- package/src/openclaw-plugin.test.ts +2 -0
- package/src/pair-session.ts +11 -1
- package/src/relay-provider-client.ts +13 -1
- package/src/session-control.test.ts +2 -1
- package/src/session-control.ts +7 -5
- package/src/setup.test.ts +109 -4
- package/src/setup.ts +340 -128
- package/src/text.test.ts +6 -1
- package/src/text.ts +11 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privateclaw/privateclaw",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "PrivateClaw provider runtime and OpenClaw-compatible plugin adapter. iOS App Store (YourClaw): https://apps.apple.com/us/app/yourclaw/id6760531637 ; 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",
|
|
3
|
+
"version": "0.1.41",
|
|
4
|
+
"description": "PrivateClaw provider runtime and OpenClaw-compatible plugin adapter. iOS App Store (YourClaw): https://apps.apple.com/us/app/yourclaw/id6760531637 ; 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 ; Desktop GitHub Releases (look for app-v*): https://github.com/topcheer/PrivateClaw/releases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
package/src/cli.ts
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
} from "./setup.js";
|
|
48
48
|
import {
|
|
49
49
|
appendPrivateClawAppInstallFooter,
|
|
50
|
+
PRIVATECLAW_CLI_CONFIG_OPTION_DESCRIPTION,
|
|
50
51
|
buildPrivateClawBackgroundDaemonReminder,
|
|
51
52
|
formatBilingualInline,
|
|
52
53
|
PRIVATECLAW_CLI_DURATION_OPTION_DESCRIPTION,
|
|
@@ -338,7 +339,7 @@ async function readHandoffState(
|
|
|
338
339
|
function printHelp(): void {
|
|
339
340
|
console.log(`privateclaw-provider <setup|pair|sessions|kick|killall>
|
|
340
341
|
|
|
341
|
-
setup [--group|--single] [--duration <preset>] [--ttl-ms <ms>] [--label <label>] [--relay <url>] [--open] [--foreground] [--verbose]
|
|
342
|
+
setup [--group|--single] [--duration <preset>] [--ttl-ms <ms>] [--label <label>] [--relay <url>] [--config <path>] [--open] [--foreground] [--verbose]
|
|
342
343
|
pair [--ttl-ms <ms>] [--label <label>] [--relay <url>] [--group] [--print-only] [--open] [--foreground] [--verbose]
|
|
343
344
|
sessions
|
|
344
345
|
sessions follow <sessionId>
|
|
@@ -349,6 +350,7 @@ killall
|
|
|
349
350
|
kick <sessionId> <appId>`);
|
|
350
351
|
console.log(`\nsetup: ${PRIVATECLAW_CLI_SETUP_DESCRIPTION}`);
|
|
351
352
|
console.log(`\n--relay <url>: ${PRIVATECLAW_CLI_RELAY_OPTION_DESCRIPTION}`);
|
|
353
|
+
console.log(`--config <path>: ${PRIVATECLAW_CLI_CONFIG_OPTION_DESCRIPTION}`);
|
|
352
354
|
console.log(`--duration <preset>: ${PRIVATECLAW_CLI_DURATION_OPTION_DESCRIPTION}`);
|
|
353
355
|
console.log(`--single: ${PRIVATECLAW_CLI_SINGLE_OPTION_DESCRIPTION}`);
|
|
354
356
|
console.log(`--verbose: ${PRIVATECLAW_CLI_VERBOSE_OPTION_DESCRIPTION}`);
|
|
@@ -378,6 +380,7 @@ async function runSetupCommand(args: string[]): Promise<void> {
|
|
|
378
380
|
"ttl-ms": { type: "string" },
|
|
379
381
|
label: { type: "string" },
|
|
380
382
|
relay: { type: "string", short: "r" },
|
|
383
|
+
config: { type: "string" },
|
|
381
384
|
open: { type: "boolean", default: parseBooleanFlag(process.env.PRIVATECLAW_OPEN_QR) },
|
|
382
385
|
foreground: { type: "boolean", default: false },
|
|
383
386
|
verbose: { type: "boolean", default: parseBooleanFlag(process.env.PRIVATECLAW_VERBOSE) },
|
|
@@ -433,6 +436,9 @@ async function runSetupCommand(args: string[]): Promise<void> {
|
|
|
433
436
|
...(parsed.values.relay?.trim()
|
|
434
437
|
? { relayBaseUrl: parsed.values.relay.trim() }
|
|
435
438
|
: {}),
|
|
439
|
+
...(parsed.values.config?.trim()
|
|
440
|
+
? { configPath: parsed.values.config.trim() }
|
|
441
|
+
: {}),
|
|
436
442
|
...(parsed.values.label?.trim() ? { label: parsed.values.label.trim() } : {}),
|
|
437
443
|
...(parsed.values.open ? { openInBrowser: true } : {}),
|
|
438
444
|
...(parsed.values.foreground ? { foreground: true } : {}),
|
|
@@ -841,6 +841,7 @@ test("privateclaw command writes QR media into the OpenClaw state media director
|
|
|
841
841
|
assert.match(reply.text, /App Store/i);
|
|
842
842
|
assert.match(reply.text, /Google Play/i);
|
|
843
843
|
assert.match(reply.text, /Google Group/i);
|
|
844
|
+
assert.match(reply.text, /GitHub Releases/i);
|
|
844
845
|
|
|
845
846
|
const inviteUri = reply.text.match(/privateclaw:\/\/connect\?payload=\S+/)?.[0];
|
|
846
847
|
assert.ok(inviteUri, "reply text should include a PrivateClaw invite URI");
|
|
@@ -915,6 +916,7 @@ test("privateclaw command embeds qqimg tags for QQ channel replies", async (t) =
|
|
|
915
916
|
assert.match(reply.text, /App Store/i);
|
|
916
917
|
assert.match(reply.text, /Google Play/i);
|
|
917
918
|
assert.match(reply.text, /Google Group/i);
|
|
919
|
+
assert.match(reply.text, /GitHub Releases/i);
|
|
918
920
|
|
|
919
921
|
const inviteUri = reply.text.match(/privateclaw:\/\/connect\?payload=\S+/)?.[0];
|
|
920
922
|
assert.ok(inviteUri, "reply text should include a PrivateClaw invite URI");
|
package/src/pair-session.ts
CHANGED
|
@@ -335,7 +335,17 @@ export async function runPairSession({
|
|
|
335
335
|
}
|
|
336
336
|
break;
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
const forceExitHandler = (): never => {
|
|
339
|
+
process.exit(130);
|
|
340
|
+
};
|
|
341
|
+
process.once("SIGINT", forceExitHandler);
|
|
342
|
+
process.once("SIGTERM", forceExitHandler);
|
|
343
|
+
try {
|
|
344
|
+
await provider.dispose();
|
|
345
|
+
} finally {
|
|
346
|
+
process.removeListener("SIGINT", forceExitHandler);
|
|
347
|
+
process.removeListener("SIGTERM", forceExitHandler);
|
|
348
|
+
}
|
|
339
349
|
return bundle;
|
|
340
350
|
} catch (error) {
|
|
341
351
|
await provider.dispose();
|
|
@@ -464,7 +464,19 @@ export class RelayProviderClient {
|
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
await new Promise<void>((resolve) => {
|
|
467
|
-
|
|
467
|
+
const forceCloseTimer = setTimeout(() => {
|
|
468
|
+
socket.removeAllListeners("close");
|
|
469
|
+
try {
|
|
470
|
+
socket.terminate();
|
|
471
|
+
} catch {
|
|
472
|
+
// already closed
|
|
473
|
+
}
|
|
474
|
+
resolve();
|
|
475
|
+
}, 3_000);
|
|
476
|
+
socket.once("close", () => {
|
|
477
|
+
clearTimeout(forceCloseTimer);
|
|
478
|
+
resolve();
|
|
479
|
+
});
|
|
468
480
|
socket.close(1000, "provider_shutdown");
|
|
469
481
|
});
|
|
470
482
|
}
|
|
@@ -541,6 +541,7 @@ test("session control reports append app install footer", () => {
|
|
|
541
541
|
assert.match(report, /App Store/i);
|
|
542
542
|
assert.match(report, /Google Play/i);
|
|
543
543
|
assert.match(report, /Google Group/i);
|
|
544
|
+
assert.match(report, /GitHub Releases/i);
|
|
544
545
|
});
|
|
545
546
|
|
|
546
547
|
test("session control can terminate a managed session", async (t) => {
|
|
@@ -828,7 +829,7 @@ test("session control falls back to the saved QR PNG when an older host lacks th
|
|
|
828
829
|
result,
|
|
829
830
|
notifyParticipants: true,
|
|
830
831
|
}).join("\n"),
|
|
831
|
-
/App Store|Google Play|Google Group/u,
|
|
832
|
+
/App Store|Google Play|Google Group|GitHub Releases/u,
|
|
832
833
|
);
|
|
833
834
|
});
|
|
834
835
|
|
package/src/session-control.ts
CHANGED
|
@@ -702,12 +702,14 @@ export class PrivateClawSessionControlServer {
|
|
|
702
702
|
|
|
703
703
|
async stop(): Promise<void> {
|
|
704
704
|
if (this.server) {
|
|
705
|
-
await new Promise<void>((resolve
|
|
705
|
+
await new Promise<void>((resolve) => {
|
|
706
|
+
const forceCloseTimer = setTimeout(() => {
|
|
707
|
+
this.server?.closeAllConnections?.();
|
|
708
|
+
resolve();
|
|
709
|
+
}, 3_000);
|
|
706
710
|
this.server!.close((error) => {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
+
clearTimeout(forceCloseTimer);
|
|
712
|
+
void error;
|
|
711
713
|
resolve();
|
|
712
714
|
});
|
|
713
715
|
});
|
package/src/setup.test.ts
CHANGED
|
@@ -136,6 +136,7 @@ test("resolvePrivateClawSetupSelection prompts for missing mode and duration", a
|
|
|
136
136
|
test("buildPrivateClawSetupPlan prints manual OpenClaw commands when openclaw is unavailable", () => {
|
|
137
137
|
const plan = buildPrivateClawSetupPlan({
|
|
138
138
|
packageSpec: "@privateclaw/privateclaw@0.1.26",
|
|
139
|
+
packageRoot: "/tmp/privateclaw-package",
|
|
139
140
|
status: {
|
|
140
141
|
openClawAvailable: false,
|
|
141
142
|
privateClawCommandAvailable: false,
|
|
@@ -151,15 +152,17 @@ test("buildPrivateClawSetupPlan prints manual OpenClaw commands when openclaw is
|
|
|
151
152
|
});
|
|
152
153
|
|
|
153
154
|
assert.equal(plan.localOpenClaw, false);
|
|
154
|
-
assert.equal(plan.manualSteps.length,
|
|
155
|
+
assert.equal(plan.manualSteps.length, 6);
|
|
155
156
|
assert.match(
|
|
156
157
|
renderPrivateClawSetupGuidance(plan),
|
|
157
|
-
/
|
|
158
|
+
/openclaw plugins install --dangerously-force-unsafe-install \/tmp\/privateclaw-package/,
|
|
158
159
|
);
|
|
159
160
|
assert.match(
|
|
160
161
|
renderPrivateClawSetupGuidance(plan),
|
|
161
|
-
/openclaw plugins install
|
|
162
|
+
/openclaw plugins install --dangerously-force-unsafe-install @privateclaw\/privateclaw@0\.1\.26/,
|
|
162
163
|
);
|
|
164
|
+
assert.doesNotMatch(renderPrivateClawSetupGuidance(plan), /npm pack/u);
|
|
165
|
+
assert.match(renderPrivateClawSetupGuidance(plan), /GitHub Releases/i);
|
|
163
166
|
assert.equal(
|
|
164
167
|
plan.pairingCommand.display,
|
|
165
168
|
"openclaw privateclaw pair --ttl-ms 7200000 --group --label hello --relay https://relay.example.com --open",
|
|
@@ -174,6 +177,7 @@ test("runPrivateClawSetup installs, enables, restarts, then starts pairing", asy
|
|
|
174
177
|
|
|
175
178
|
await runPrivateClawSetup({
|
|
176
179
|
packageSpec: "@privateclaw/privateclaw@0.1.26",
|
|
180
|
+
packageRoot: "/tmp/privateclaw-package",
|
|
177
181
|
selection: {
|
|
178
182
|
groupMode: true,
|
|
179
183
|
ttlMs: 8 * 60 * 60 * 1000,
|
|
@@ -216,7 +220,7 @@ test("runPrivateClawSetup installs, enables, restarts, then starts pairing", asy
|
|
|
216
220
|
});
|
|
217
221
|
|
|
218
222
|
assert.deepEqual(executed, [
|
|
219
|
-
"
|
|
223
|
+
"openclaw plugins install --dangerously-force-unsafe-install /tmp/privateclaw-package",
|
|
220
224
|
"openclaw plugins enable privateclaw",
|
|
221
225
|
"openclaw gateway restart",
|
|
222
226
|
]);
|
|
@@ -224,6 +228,106 @@ test("runPrivateClawSetup installs, enables, restarts, then starts pairing", asy
|
|
|
224
228
|
"openclaw privateclaw pair --ttl-ms 28800000 --group --label demo --relay https://relay.example.com --verbose",
|
|
225
229
|
]);
|
|
226
230
|
assert.match(logs.join("\n"), /Verified command availability/);
|
|
231
|
+
assert.match(logs.join("\n"), /GitHub Releases/i);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test("runPrivateClawSetup propagates OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH when configPath is provided", async () => {
|
|
235
|
+
const executed: string[] = [];
|
|
236
|
+
const stepEnvs: Array<NodeJS.ProcessEnv | undefined> = [];
|
|
237
|
+
const pairingEnvs: Array<NodeJS.ProcessEnv | undefined> = [];
|
|
238
|
+
let detectCalls = 0;
|
|
239
|
+
|
|
240
|
+
await runPrivateClawSetup({
|
|
241
|
+
packageSpec: "@privateclaw/privateclaw@0.1.26",
|
|
242
|
+
packageRoot: "/tmp/privateclaw-package",
|
|
243
|
+
configPath: "/tmp/openclaw-test/openclaw.json",
|
|
244
|
+
selection: {
|
|
245
|
+
groupMode: false,
|
|
246
|
+
ttlMs: 30 * 60 * 1000,
|
|
247
|
+
durationLabel: "30 分钟 / 30 minutes",
|
|
248
|
+
},
|
|
249
|
+
detectLocalOpenClawStatus: async () => {
|
|
250
|
+
detectCalls += 1;
|
|
251
|
+
if (detectCalls === 1) {
|
|
252
|
+
return {
|
|
253
|
+
openClawAvailable: true,
|
|
254
|
+
privateClawCommandAvailable: false,
|
|
255
|
+
privateClawPluginPresent: false,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
openClawAvailable: true,
|
|
260
|
+
privateClawCommandAvailable: true,
|
|
261
|
+
privateClawPluginPresent: true,
|
|
262
|
+
};
|
|
263
|
+
},
|
|
264
|
+
runStep: async (step) => {
|
|
265
|
+
executed.push(step.display);
|
|
266
|
+
stepEnvs.push(step.env);
|
|
267
|
+
},
|
|
268
|
+
runPairingCommand: async (step) => {
|
|
269
|
+
pairingEnvs.push(step.env);
|
|
270
|
+
return {
|
|
271
|
+
stdout: "",
|
|
272
|
+
stderr: "",
|
|
273
|
+
combined: "",
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
verificationTimeoutMs: 10,
|
|
277
|
+
verificationPollMs: 0,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
assert.equal(
|
|
281
|
+
executed[0],
|
|
282
|
+
"OPENCLAW_STATE_DIR=/tmp/openclaw-test OPENCLAW_CONFIG_PATH=/tmp/openclaw-test/openclaw.json openclaw plugins install --dangerously-force-unsafe-install /tmp/privateclaw-package",
|
|
283
|
+
);
|
|
284
|
+
assert.deepEqual(executed, [
|
|
285
|
+
"OPENCLAW_STATE_DIR=/tmp/openclaw-test OPENCLAW_CONFIG_PATH=/tmp/openclaw-test/openclaw.json openclaw plugins install --dangerously-force-unsafe-install /tmp/privateclaw-package",
|
|
286
|
+
"OPENCLAW_STATE_DIR=/tmp/openclaw-test OPENCLAW_CONFIG_PATH=/tmp/openclaw-test/openclaw.json openclaw plugins enable privateclaw",
|
|
287
|
+
"OPENCLAW_STATE_DIR=/tmp/openclaw-test OPENCLAW_CONFIG_PATH=/tmp/openclaw-test/openclaw.json openclaw config set gateway.mode local",
|
|
288
|
+
]);
|
|
289
|
+
assert.equal(stepEnvs[0]?.OPENCLAW_STATE_DIR, "/tmp/openclaw-test");
|
|
290
|
+
assert.equal(
|
|
291
|
+
stepEnvs[0]?.OPENCLAW_CONFIG_PATH,
|
|
292
|
+
"/tmp/openclaw-test/openclaw.json",
|
|
293
|
+
);
|
|
294
|
+
assert.equal(pairingEnvs[0]?.OPENCLAW_STATE_DIR, "/tmp/openclaw-test");
|
|
295
|
+
assert.equal(
|
|
296
|
+
pairingEnvs[0]?.OPENCLAW_CONFIG_PATH,
|
|
297
|
+
"/tmp/openclaw-test/openclaw.json",
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test("buildPrivateClawSetupPlan uses gateway run guidance instead of restart when configPath is provided", () => {
|
|
302
|
+
const plan = buildPrivateClawSetupPlan({
|
|
303
|
+
packageSpec: "@privateclaw/privateclaw@0.1.26",
|
|
304
|
+
packageRoot: "/tmp/privateclaw-package",
|
|
305
|
+
configPath: "/tmp/openclaw-test/openclaw.json",
|
|
306
|
+
status: {
|
|
307
|
+
openClawAvailable: true,
|
|
308
|
+
privateClawCommandAvailable: false,
|
|
309
|
+
privateClawPluginPresent: false,
|
|
310
|
+
},
|
|
311
|
+
selection: {
|
|
312
|
+
groupMode: false,
|
|
313
|
+
ttlMs: 30 * 60 * 1000,
|
|
314
|
+
durationLabel: "30 分钟 / 30 minutes",
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
assert.deepEqual(
|
|
319
|
+
plan.automaticSteps.map((step) => step.display),
|
|
320
|
+
[
|
|
321
|
+
"OPENCLAW_STATE_DIR=/tmp/openclaw-test OPENCLAW_CONFIG_PATH=/tmp/openclaw-test/openclaw.json openclaw plugins install --dangerously-force-unsafe-install /tmp/privateclaw-package",
|
|
322
|
+
"OPENCLAW_STATE_DIR=/tmp/openclaw-test OPENCLAW_CONFIG_PATH=/tmp/openclaw-test/openclaw.json openclaw plugins enable privateclaw",
|
|
323
|
+
"OPENCLAW_STATE_DIR=/tmp/openclaw-test OPENCLAW_CONFIG_PATH=/tmp/openclaw-test/openclaw.json openclaw config set gateway.mode local",
|
|
324
|
+
],
|
|
325
|
+
);
|
|
326
|
+
assert.match(
|
|
327
|
+
renderPrivateClawSetupGuidance(plan),
|
|
328
|
+
/OPENCLAW_STATE_DIR=\/tmp\/openclaw-test OPENCLAW_CONFIG_PATH=\/tmp\/openclaw-test\/openclaw\.json openclaw gateway run/,
|
|
329
|
+
);
|
|
330
|
+
assert.doesNotMatch(renderPrivateClawSetupGuidance(plan), /openclaw gateway restart/u);
|
|
227
331
|
});
|
|
228
332
|
|
|
229
333
|
test("runPrivateClawSetup prints guidance and fails when openclaw is unavailable locally", async () => {
|
|
@@ -248,4 +352,5 @@ test("runPrivateClawSetup prints guidance and fails when openclaw is unavailable
|
|
|
248
352
|
);
|
|
249
353
|
|
|
250
354
|
assert.match(logs.join("\n"), /Run these commands on the machine where OpenClaw is installed/i);
|
|
355
|
+
assert.match(logs.join("\n"), /GitHub Releases/i);
|
|
251
356
|
});
|