@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.
@@ -14,6 +14,7 @@ import {
14
14
  PRIVATECLAW_SESSION_ENDED_MESSAGE,
15
15
  PRIVATECLAW_WAITING_FOR_APP_MESSAGE,
16
16
  PRIVATECLAW_WAITING_FOR_APP_WITH_BACKGROUND_MESSAGE,
17
+ writePrivateClawAppInstallFooter,
17
18
  } from "./text.js";
18
19
  import type { PrivateClawInviteBundle } from "./types.js";
19
20
 
@@ -129,8 +130,10 @@ export async function renderInviteBundleOutput(
129
130
  qrMediaDir?: string;
130
131
  openInBrowser?: boolean;
131
132
  writeLine?: (line: string) => void;
133
+ includeFooter?: boolean;
132
134
  },
133
135
  ): Promise<PrivateClawInviteBundle> {
136
+ const writeLine = params?.writeLine ?? ((line) => console.log(line));
134
137
  const mediaDir = params?.qrMediaDir ?? resolvePrivateClawMediaDir();
135
138
  const qrPng = await writeInviteQrPng(bundle, mediaDir);
136
139
  const renderedBundle: PrivateClawInviteBundle = {
@@ -138,7 +141,7 @@ export async function renderInviteBundleOutput(
138
141
  qrPngPath: qrPng.pngPath,
139
142
  };
140
143
 
141
- printPairInviteBundle(renderedBundle, params?.writeLine ?? ((line) => console.log(line)));
144
+ printPairInviteBundle(renderedBundle, writeLine);
142
145
 
143
146
  if (params?.openInBrowser) {
144
147
  const preview = await writeInviteQrPreviewHtml(
@@ -148,6 +151,9 @@ export async function renderInviteBundleOutput(
148
151
  );
149
152
  await openInBrowserPreview(preview.previewFileUrl);
150
153
  }
154
+ if (params?.includeFooter !== false) {
155
+ writePrivateClawAppInstallFooter(writeLine);
156
+ }
151
157
 
152
158
  return renderedBundle;
153
159
  }
@@ -175,15 +181,18 @@ export async function runPairSession({
175
181
  const bundle = await renderInviteBundleOutput(inviteBundle, {
176
182
  ...(qrMediaDir ? { qrMediaDir } : {}),
177
183
  ...(openInBrowser ? { openInBrowser: true } : {}),
184
+ includeFooter: false,
178
185
  writeLine,
179
186
  });
180
187
 
181
188
  if (printOnly) {
189
+ writePrivateClawAppInstallFooter(writeLine);
182
190
  await provider.dispose();
183
191
  return bundle;
184
192
  }
185
193
 
186
194
  if (!foreground) {
195
+ writePrivateClawAppInstallFooter(writeLine);
187
196
  return bundle;
188
197
  }
189
198
 
@@ -192,6 +201,7 @@ export async function runPairSession({
192
201
  ? PRIVATECLAW_WAITING_FOR_APP_WITH_BACKGROUND_MESSAGE
193
202
  : PRIVATECLAW_WAITING_FOR_APP_MESSAGE,
194
203
  );
204
+ writePrivateClawAppInstallFooter(writeLine);
195
205
  for (;;) {
196
206
  const outcome = await Promise.race<
197
207
  | { kind: "signal"; signal: NodeJS.Signals }
@@ -19,6 +19,7 @@ import { resolvePrivateClawMediaDir } from "./invite-qr-files.js";
19
19
  import { DEFAULT_SESSION_TTL_MS, PrivateClawProvider } from "./provider.js";
20
20
  import {
21
21
  buildManagedSessionQrLegacyLines,
22
+ buildManagedSessionsReportLines,
22
23
  closeManagedSessionsFromStateDir,
23
24
  closeManagedSessionFromStateDir,
24
25
  followManagedSessionLogFromStateDir,
@@ -408,6 +409,38 @@ test("session control can follow a managed OpenClaw session log", async (t) => {
408
409
  assert.ok(printed.includes(secondLine));
409
410
  });
410
411
 
412
+ test("session control reports append app install footer", () => {
413
+ const lines = buildManagedSessionsReportLines([
414
+ {
415
+ host: {
416
+ controlId: "control-1",
417
+ kind: "pair-daemon",
418
+ pid: 12345,
419
+ startedAt: "2026-03-22T08:00:00.000Z",
420
+ },
421
+ sessions: [
422
+ {
423
+ sessionId: "session-1",
424
+ expiresAt: "2026-03-23T08:00:00.000Z",
425
+ groupMode: false,
426
+ participantCount: 1,
427
+ participants: [
428
+ {
429
+ appId: "app-1",
430
+ displayName: "RiverCat",
431
+ },
432
+ ],
433
+ state: "awaiting_hello",
434
+ },
435
+ ],
436
+ },
437
+ ]);
438
+ const report = lines.join("\n");
439
+ assert.match(report, /TestFlight/i);
440
+ assert.match(report, /Google Play/i);
441
+ assert.match(report, /Google Group/i);
442
+ });
443
+
411
444
  test("session control can terminate a managed session", async (t) => {
412
445
  const relay = createRelayServer({
413
446
  host: "127.0.0.1",
@@ -688,4 +721,11 @@ test("session control falls back to the saved QR PNG when an older host lacks th
688
721
  }).join("\n"),
689
722
  /notified|推送/u,
690
723
  );
724
+ assert.match(
725
+ buildManagedSessionQrLegacyLines({
726
+ result,
727
+ notifyParticipants: true,
728
+ }).join("\n"),
729
+ /TestFlight|Google Play|Google Group/u,
730
+ );
691
731
  });
@@ -5,7 +5,10 @@ import { type AddressInfo } from "node:net";
5
5
  import os from "node:os";
6
6
  import path from "node:path";
7
7
  import { resolvePrivateClawMediaDir } from "./invite-qr-files.js";
8
- import { formatBilingualInline } from "./text.js";
8
+ import {
9
+ appendPrivateClawAppInstallFooterLines,
10
+ formatBilingualInline,
11
+ } from "./text.js";
9
12
  import type {
10
13
  PrivateClawInviteBundle,
11
14
  PrivateClawManagedSession,
@@ -318,12 +321,12 @@ export function buildManagedSessionsReportLines(
318
321
  })),
319
322
  );
320
323
  if (sessions.length === 0) {
321
- return [
324
+ return appendPrivateClawAppInstallFooterLines([
322
325
  formatBilingualInline(
323
326
  "当前没有活动中的 PrivateClaw 会话。",
324
327
  "No active PrivateClaw sessions.",
325
328
  ),
326
- ];
329
+ ]);
327
330
  }
328
331
 
329
332
  const lines = [
@@ -346,7 +349,7 @@ export function buildManagedSessionsReportLines(
346
349
  }
347
350
  }
348
351
 
349
- return lines;
352
+ return appendPrivateClawAppInstallFooterLines(lines);
350
353
  }
351
354
 
352
355
  export class PrivateClawSessionControlServer {
@@ -649,9 +652,9 @@ export function buildManagedSessionQrLegacyLines(params: {
649
652
  "如需直接打开这张已保存的二维码图片,可重试并追加 --open。",
650
653
  "Re-run with --open to open the saved QR image directly.",
651
654
  ),
652
- );
655
+ );
653
656
  }
654
- return lines;
657
+ return appendPrivateClawAppInstallFooterLines(lines);
655
658
  }
656
659
 
657
660
  async function waitForPidExit(params: {
@@ -0,0 +1,26 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import {
4
+ appendPrivateClawAppInstallFooter,
5
+ buildPrivateClawCommandErrorMessage,
6
+ PRIVATECLAW_APP_INSTALL_FOOTER_LINES,
7
+ } from "./text.js";
8
+
9
+ test("appendPrivateClawAppInstallFooter appends concise store links", () => {
10
+ const text = appendPrivateClawAppInstallFooter("PrivateClaw session ready.");
11
+ assert.match(text, /TestFlight/i);
12
+ assert.match(text, /Google Play/i);
13
+ assert.match(text, /Google Group/i);
14
+ assert.ok(
15
+ text.endsWith(PRIVATECLAW_APP_INSTALL_FOOTER_LINES.at(-1) ?? ""),
16
+ "footer should end with the Google Group note",
17
+ );
18
+ });
19
+
20
+ test("buildPrivateClawCommandErrorMessage also appends store links", () => {
21
+ const text = buildPrivateClawCommandErrorMessage("boom");
22
+ assert.match(text, /Failed to create a PrivateClaw session: boom/);
23
+ assert.match(text, /TestFlight/i);
24
+ assert.match(text, /Google Play/i);
25
+ assert.match(text, /Google Group/i);
26
+ });
package/src/text.ts CHANGED
@@ -9,6 +9,51 @@ export function formatBilingualInline(
9
9
  return `${chinese} / ${english}`;
10
10
  }
11
11
 
12
+ export const PRIVATECLAW_IOS_PUBLIC_BETA_URL =
13
+ "https://testflight.apple.com/join/XvgJ9c33";
14
+ export const PRIVATECLAW_ANDROID_CLOSED_TESTING_PLAY_URL =
15
+ "https://play.google.com/store/apps/details?id=gg.ai.privateclaw";
16
+ export const PRIVATECLAW_ANDROID_CLOSED_TESTING_GROUP_URL =
17
+ "https://groups.google.com/g/gg-studio-ai-products";
18
+
19
+ export const PRIVATECLAW_APP_INSTALL_FOOTER_LINES = [
20
+ formatBilingualInline(
21
+ `iOS 公开测试(TestFlight):${PRIVATECLAW_IOS_PUBLIC_BETA_URL}`,
22
+ `iOS public beta (TestFlight): ${PRIVATECLAW_IOS_PUBLIC_BETA_URL}`,
23
+ ),
24
+ formatBilingualInline(
25
+ `Android 封闭测试(Google Play):${PRIVATECLAW_ANDROID_CLOSED_TESTING_PLAY_URL}`,
26
+ `Android closed testing (Google Play): ${PRIVATECLAW_ANDROID_CLOSED_TESTING_PLAY_URL}`,
27
+ ),
28
+ formatBilingualInline(
29
+ `Android 需先加入 Google Group:${PRIVATECLAW_ANDROID_CLOSED_TESTING_GROUP_URL}`,
30
+ `Join the Google Group first for Android closed testing: ${PRIVATECLAW_ANDROID_CLOSED_TESTING_GROUP_URL}`,
31
+ ),
32
+ ];
33
+
34
+ export function appendPrivateClawAppInstallFooter(text: string): string {
35
+ const trimmed = text.trimEnd();
36
+ if (trimmed === "") {
37
+ return PRIVATECLAW_APP_INSTALL_FOOTER_LINES.join("\n");
38
+ }
39
+ return `${trimmed}\n\n${PRIVATECLAW_APP_INSTALL_FOOTER_LINES.join("\n")}`;
40
+ }
41
+
42
+ export function appendPrivateClawAppInstallFooterLines(
43
+ lines: ReadonlyArray<string>,
44
+ ): string[] {
45
+ return [...lines, "", ...PRIVATECLAW_APP_INSTALL_FOOTER_LINES];
46
+ }
47
+
48
+ export function writePrivateClawAppInstallFooter(
49
+ writeLine: (line: string) => void,
50
+ ): void {
51
+ writeLine("");
52
+ for (const line of PRIVATECLAW_APP_INSTALL_FOOTER_LINES) {
53
+ writeLine(line);
54
+ }
55
+ }
56
+
12
57
  export function buildInviteAnnouncementText(params: {
13
58
  sessionId: string;
14
59
  expiresAt: string;
@@ -191,9 +236,11 @@ export function buildPrivateClawBackgroundHandoffFailureMessage(
191
236
  }
192
237
 
193
238
  export function buildPrivateClawCommandErrorMessage(details: string): string {
194
- return formatBilingualInline(
195
- `创建 PrivateClaw 会话失败:${details}`,
196
- `Failed to create a PrivateClaw session: ${details}`,
239
+ return appendPrivateClawAppInstallFooter(
240
+ formatBilingualInline(
241
+ `创建 PrivateClaw 会话失败:${details}`,
242
+ `Failed to create a PrivateClaw session: ${details}`,
243
+ ),
197
244
  );
198
245
  }
199
246