@privateclaw/privateclaw 0.1.16 → 0.1.17
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 +44 -1
- package/dist/audio-transcriber.d.ts +46 -0
- package/dist/audio-transcriber.js +433 -0
- package/dist/audio-transcriber.js.map +1 -0
- package/dist/bridges/openclaw-agent-bridge.d.ts +4 -1
- package/dist/bridges/openclaw-agent-bridge.js +81 -8
- package/dist/bridges/openclaw-agent-bridge.js.map +1 -1
- package/dist/cli.js +57 -6
- package/dist/cli.js.map +1 -1
- package/dist/openclaw-plugin.js +150 -51
- package/dist/openclaw-plugin.js.map +1 -1
- package/dist/pair-daemon.d.ts +2 -0
- package/dist/pair-daemon.js +2 -0
- package/dist/pair-daemon.js.map +1 -1
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +103 -14
- package/dist/provider.js.map +1 -1
- package/dist/session-control.d.ts +7 -0
- package/dist/session-control.js +122 -0
- package/dist/session-control.js.map +1 -1
- package/dist/text.d.ts +2 -0
- package/dist/text.js +3 -1
- package/dist/text.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
- package/src/audio-transcriber.test.ts +299 -0
- package/src/audio-transcriber.ts +615 -0
- package/src/bridges/openclaw-agent-bridge.test.ts +78 -13
- package/src/bridges/openclaw-agent-bridge.ts +109 -7
- package/src/cli.ts +73 -5
- package/src/openclaw-plugin.test.ts +12 -2
- package/src/openclaw-plugin.ts +191 -54
- package/src/pair-daemon.ts +4 -0
- package/src/provider.test.ts +304 -0
- package/src/provider.ts +146 -20
- package/src/session-control.test.ts +80 -0
- package/src/session-control.ts +151 -0
- package/src/text.ts +12 -2
- package/src/types.ts +12 -0
package/src/openclaw-plugin.ts
CHANGED
|
@@ -4,6 +4,10 @@ import {
|
|
|
4
4
|
OpenClawAgentBridge,
|
|
5
5
|
type OpenClawAgentBridgeOptions,
|
|
6
6
|
} from "./bridges/openclaw-agent-bridge.js";
|
|
7
|
+
import {
|
|
8
|
+
buildPreferredAudioTranscriber,
|
|
9
|
+
resolvePrivateClawSttConfig,
|
|
10
|
+
} from "./audio-transcriber.js";
|
|
7
11
|
import {
|
|
8
12
|
resolvePrivateClawMediaDir,
|
|
9
13
|
writeInviteQrPng,
|
|
@@ -33,6 +37,7 @@ import { DEFAULT_RELAY_BASE_URL } from "./relay-defaults.js";
|
|
|
33
37
|
import { resolveRelayEndpoints } from "./relay-endpoints.js";
|
|
34
38
|
import {
|
|
35
39
|
buildManagedSessionQrLegacyLines,
|
|
40
|
+
followManagedSessionLogFromStateDir,
|
|
36
41
|
buildManagedSessionsReportLines,
|
|
37
42
|
closeManagedSessionsFromStateDir,
|
|
38
43
|
closeManagedSessionFromStateDir,
|
|
@@ -59,10 +64,12 @@ import {
|
|
|
59
64
|
PRIVATECLAW_CLI_RELAY_OPTION_DESCRIPTION,
|
|
60
65
|
PRIVATECLAW_CLI_ROOT_DESCRIPTION,
|
|
61
66
|
PRIVATECLAW_CLI_SESSIONS_DESCRIPTION,
|
|
67
|
+
PRIVATECLAW_CLI_SESSIONS_FOLLOW_DESCRIPTION,
|
|
62
68
|
PRIVATECLAW_CLI_SESSIONS_KILL_DESCRIPTION,
|
|
63
69
|
PRIVATECLAW_CLI_SESSIONS_KILLALL_DESCRIPTION,
|
|
64
70
|
PRIVATECLAW_CLI_SESSIONS_QR_DESCRIPTION,
|
|
65
71
|
PRIVATECLAW_CLI_TTL_OPTION_DESCRIPTION,
|
|
72
|
+
PRIVATECLAW_CLI_VERBOSE_OPTION_DESCRIPTION,
|
|
66
73
|
PRIVATECLAW_COMMAND_DESCRIPTION,
|
|
67
74
|
PRIVATECLAW_INVITE_URI_LABEL,
|
|
68
75
|
PRIVATECLAW_PLUGIN_DESCRIPTION,
|
|
@@ -72,6 +79,7 @@ import type {
|
|
|
72
79
|
PrivateClawInviteBundle,
|
|
73
80
|
PrivateClawManagedSession,
|
|
74
81
|
PrivateClawProviderOptions,
|
|
82
|
+
PrivateClawVerboseController,
|
|
75
83
|
} from "./types.js";
|
|
76
84
|
|
|
77
85
|
type PrivateClawBridgeMode = "openclaw-agent" | "webhook" | "echo";
|
|
@@ -125,6 +133,7 @@ interface PrivateClawPairCliOptions {
|
|
|
125
133
|
group?: boolean;
|
|
126
134
|
open?: boolean;
|
|
127
135
|
foreground?: boolean;
|
|
136
|
+
verbose?: boolean;
|
|
128
137
|
}
|
|
129
138
|
|
|
130
139
|
interface PrivateClawSessionsQrCliOptions {
|
|
@@ -313,6 +322,7 @@ function resolvePluginConfig(
|
|
|
313
322
|
function buildBridge(
|
|
314
323
|
config: ResolvedPrivateClawPluginConfig,
|
|
315
324
|
onLog?: (message: string) => void,
|
|
325
|
+
verboseController?: PrivateClawVerboseController,
|
|
316
326
|
): PrivateClawAgentBridge {
|
|
317
327
|
if (config.bridgeMode === "webhook") {
|
|
318
328
|
if (!config.webhookUrl) {
|
|
@@ -346,10 +356,38 @@ function buildBridge(
|
|
|
346
356
|
...(typeof config.openclawAgentTimeoutSeconds === "number"
|
|
347
357
|
? { timeoutSeconds: config.openclawAgentTimeoutSeconds }
|
|
348
358
|
: {}),
|
|
359
|
+
...(verboseController ? { verboseController } : {}),
|
|
349
360
|
...(onLog ? { onLog } : {}),
|
|
350
361
|
});
|
|
351
362
|
}
|
|
352
363
|
|
|
364
|
+
function buildProviderAudioTranscriber(params: {
|
|
365
|
+
rootConfig?: unknown;
|
|
366
|
+
onLog?: (message: string) => void;
|
|
367
|
+
env?: NodeJS.ProcessEnv;
|
|
368
|
+
}) {
|
|
369
|
+
return buildPreferredAudioTranscriber({
|
|
370
|
+
rootConfig: params.rootConfig,
|
|
371
|
+
...(params.env ? { env: params.env } : {}),
|
|
372
|
+
...(params.onLog ? { onLog: params.onLog } : {}),
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function buildDirectAudioTranscriberEnv(rootConfig?: unknown): NodeJS.ProcessEnv | undefined {
|
|
377
|
+
const sttConfig = resolvePrivateClawSttConfig({ rootConfig });
|
|
378
|
+
if (!sttConfig) {
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
PRIVATECLAW_STT_BASE_URL: sttConfig.baseUrl,
|
|
383
|
+
PRIVATECLAW_STT_MODEL: sttConfig.model,
|
|
384
|
+
...(sttConfig.apiKey ? { PRIVATECLAW_STT_API_KEY: sttConfig.apiKey } : {}),
|
|
385
|
+
...(sttConfig.headers
|
|
386
|
+
? { PRIVATECLAW_STT_HEADERS: JSON.stringify(sttConfig.headers) }
|
|
387
|
+
: {}),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
353
391
|
function normalizePairCliOptions(raw: unknown): PrivateClawPairCliOptions {
|
|
354
392
|
if (!raw || typeof raw !== "object") {
|
|
355
393
|
return {};
|
|
@@ -369,6 +407,7 @@ function normalizePairCliOptions(raw: unknown): PrivateClawPairCliOptions {
|
|
|
369
407
|
...(typeof options.foreground === "boolean"
|
|
370
408
|
? { foreground: options.foreground }
|
|
371
409
|
: {}),
|
|
410
|
+
...(typeof options.verbose === "boolean" ? { verbose: options.verbose } : {}),
|
|
372
411
|
};
|
|
373
412
|
}
|
|
374
413
|
|
|
@@ -481,14 +520,19 @@ function mergeDaemonEnvForRelay(
|
|
|
481
520
|
function buildProviderOptions(
|
|
482
521
|
pluginConfig: ResolvedPrivateClawPluginConfig,
|
|
483
522
|
api: Pick<OpenClawPluginApiCompat, "logger">,
|
|
484
|
-
): {
|
|
523
|
+
): {
|
|
524
|
+
options: PrivateClawProviderOptions;
|
|
525
|
+
defaultTtlMs?: number;
|
|
526
|
+
verboseController: PrivateClawVerboseController;
|
|
527
|
+
} {
|
|
485
528
|
const relay = resolveRelayEndpoints(pluginConfig.relayBaseUrl);
|
|
486
529
|
const log = (message: string) => api.logger.info(`[privateclaw] ${message}`);
|
|
530
|
+
const verboseController = { enabled: false } satisfies PrivateClawVerboseController;
|
|
487
531
|
return {
|
|
488
532
|
options: {
|
|
489
533
|
providerWsUrl: relay.providerWsUrl,
|
|
490
534
|
appWsUrl: relay.appWsUrl,
|
|
491
|
-
bridge: buildBridge(pluginConfig, log),
|
|
535
|
+
bridge: buildBridge(pluginConfig, log, verboseController),
|
|
492
536
|
providerLabel: pluginConfig.providerLabel,
|
|
493
537
|
commandsProvider: async () => {
|
|
494
538
|
try {
|
|
@@ -501,11 +545,13 @@ function buildProviderOptions(
|
|
|
501
545
|
}
|
|
502
546
|
},
|
|
503
547
|
...(pluginConfig.welcomeMessage ? { welcomeMessage: pluginConfig.welcomeMessage } : {}),
|
|
548
|
+
verboseController,
|
|
504
549
|
onLog: log,
|
|
505
550
|
},
|
|
506
551
|
...(typeof pluginConfig.sessionTtlMs === "number"
|
|
507
552
|
? { defaultTtlMs: pluginConfig.sessionTtlMs }
|
|
508
553
|
: {}),
|
|
554
|
+
verboseController,
|
|
509
555
|
};
|
|
510
556
|
}
|
|
511
557
|
|
|
@@ -569,24 +615,48 @@ class PrivateClawPluginRuntime {
|
|
|
569
615
|
}
|
|
570
616
|
>();
|
|
571
617
|
private stateDir: string | undefined;
|
|
618
|
+
private rootConfig: unknown;
|
|
572
619
|
private controlServer: PrivateClawSessionControlServer | undefined;
|
|
573
620
|
private readonly defaultRelayBaseUrl: string;
|
|
621
|
+
private readonly verboseController: PrivateClawVerboseController | undefined;
|
|
574
622
|
|
|
575
623
|
constructor(
|
|
576
624
|
private readonly providerOptions: PrivateClawProviderOptions,
|
|
577
625
|
private readonly defaultTtlMs: number = DEFAULT_SESSION_TTL_MS,
|
|
578
626
|
private readonly daemonEnv?: NodeJS.ProcessEnv,
|
|
579
627
|
defaultRelayBaseUrl?: string,
|
|
628
|
+
verboseController?: PrivateClawVerboseController,
|
|
580
629
|
) {
|
|
581
630
|
this.defaultRelayBaseUrl =
|
|
582
631
|
readString(defaultRelayBaseUrl) ??
|
|
583
632
|
inferRelayBaseUrlFromAppWsUrl(providerOptions.appWsUrl);
|
|
633
|
+
this.verboseController = verboseController ?? providerOptions.verboseController;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
private async withVerboseLogging<T>(
|
|
637
|
+
verbose: boolean | undefined,
|
|
638
|
+
action: () => Promise<T>,
|
|
639
|
+
): Promise<T> {
|
|
640
|
+
if (!verbose || !this.verboseController) {
|
|
641
|
+
return action();
|
|
642
|
+
}
|
|
643
|
+
const previous = this.verboseController.enabled;
|
|
644
|
+
this.verboseController.enabled = true;
|
|
645
|
+
try {
|
|
646
|
+
return await action();
|
|
647
|
+
} finally {
|
|
648
|
+
this.verboseController.enabled = previous;
|
|
649
|
+
}
|
|
584
650
|
}
|
|
585
651
|
|
|
586
652
|
setStateDir(stateDir: string): void {
|
|
587
653
|
this.stateDir = stateDir;
|
|
588
654
|
}
|
|
589
655
|
|
|
656
|
+
setRootConfig(config: unknown): void {
|
|
657
|
+
this.rootConfig = config;
|
|
658
|
+
}
|
|
659
|
+
|
|
590
660
|
private ensureStateDir(): string {
|
|
591
661
|
this.stateDir = resolvePrivateClawStateDir(this.stateDir);
|
|
592
662
|
return this.stateDir;
|
|
@@ -608,11 +678,20 @@ class PrivateClawPluginRuntime {
|
|
|
608
678
|
let entry = this.providerEntries.get(resolvedRelayBaseUrl);
|
|
609
679
|
if (!entry) {
|
|
610
680
|
const relay = resolveRelayEndpoints(resolvedRelayBaseUrl);
|
|
681
|
+
const audioTranscriber =
|
|
682
|
+
this.providerOptions.audioTranscriber ??
|
|
683
|
+
buildProviderAudioTranscriber({
|
|
684
|
+
rootConfig: this.rootConfig,
|
|
685
|
+
...(this.providerOptions.onLog
|
|
686
|
+
? { onLog: this.providerOptions.onLog }
|
|
687
|
+
: {}),
|
|
688
|
+
});
|
|
611
689
|
entry = {
|
|
612
690
|
providerOptions: {
|
|
613
691
|
...this.providerOptions,
|
|
614
692
|
providerWsUrl: relay.providerWsUrl,
|
|
615
693
|
appWsUrl: relay.appWsUrl,
|
|
694
|
+
...(audioTranscriber ? { audioTranscriber } : {}),
|
|
616
695
|
},
|
|
617
696
|
};
|
|
618
697
|
this.providerEntries.set(resolvedRelayBaseUrl, entry);
|
|
@@ -768,6 +847,7 @@ class PrivateClawPluginRuntime {
|
|
|
768
847
|
groupMode?: boolean;
|
|
769
848
|
relayBaseUrl?: string;
|
|
770
849
|
openInBrowser?: boolean;
|
|
850
|
+
verbose?: boolean;
|
|
771
851
|
writeLine?: (line: string) => void;
|
|
772
852
|
}): Promise<PrivateClawInviteBundle> {
|
|
773
853
|
if (!this.daemonEnv) {
|
|
@@ -779,7 +859,10 @@ class PrivateClawPluginRuntime {
|
|
|
779
859
|
);
|
|
780
860
|
}
|
|
781
861
|
const daemonEnv = mergeDaemonEnvForRelay(
|
|
782
|
-
|
|
862
|
+
{
|
|
863
|
+
...this.daemonEnv,
|
|
864
|
+
...buildDirectAudioTranscriberEnv(this.rootConfig),
|
|
865
|
+
},
|
|
783
866
|
params?.relayBaseUrl,
|
|
784
867
|
);
|
|
785
868
|
|
|
@@ -794,6 +877,7 @@ class PrivateClawPluginRuntime {
|
|
|
794
877
|
...(params?.label ? { label: params.label } : {}),
|
|
795
878
|
...(params?.groupMode === true ? { groupMode: true } : {}),
|
|
796
879
|
...(params?.openInBrowser === true ? { openInBrowser: true } : {}),
|
|
880
|
+
...(params?.verbose === true ? { verbose: true } : {}),
|
|
797
881
|
});
|
|
798
882
|
printPairInviteBundle(bundle, params?.writeLine ?? ((line) => console.log(line)));
|
|
799
883
|
(params?.writeLine ?? ((line: string) => console.log(line)))(
|
|
@@ -813,57 +897,64 @@ class PrivateClawPluginRuntime {
|
|
|
813
897
|
relayBaseUrl?: string;
|
|
814
898
|
foreground?: boolean;
|
|
815
899
|
openInBrowser?: boolean;
|
|
900
|
+
verbose?: boolean;
|
|
816
901
|
writeLine?: (line: string) => void;
|
|
817
902
|
}): Promise<PrivateClawInviteBundle> {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
? {
|
|
836
|
-
: {}),
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
903
|
+
return this.withVerboseLogging(params?.verbose, async () => {
|
|
904
|
+
if (!params?.printOnly) {
|
|
905
|
+
await this.ensureControlServer("pair-foreground");
|
|
906
|
+
}
|
|
907
|
+
const provider = this.getProvider(params?.relayBaseUrl);
|
|
908
|
+
const handoffEnv = mergeDaemonEnvForRelay(
|
|
909
|
+
{
|
|
910
|
+
...this.daemonEnv,
|
|
911
|
+
...buildDirectAudioTranscriberEnv(this.rootConfig),
|
|
912
|
+
},
|
|
913
|
+
params?.relayBaseUrl,
|
|
914
|
+
);
|
|
915
|
+
return runPairSession({
|
|
916
|
+
provider,
|
|
917
|
+
...(typeof params?.ttlMs === "number"
|
|
918
|
+
? { ttlMs: params.ttlMs }
|
|
919
|
+
: { ttlMs: this.defaultTtlMs }),
|
|
920
|
+
...(params?.label ? { label: params.label } : {}),
|
|
921
|
+
...(typeof params?.printOnly === "boolean" ? { printOnly: params.printOnly } : {}),
|
|
922
|
+
...(params?.groupMode === true ? { groupMode: true } : {}),
|
|
923
|
+
...(typeof params?.foreground === "boolean"
|
|
924
|
+
? { foreground: params.foreground }
|
|
925
|
+
: {}),
|
|
926
|
+
...(typeof params?.openInBrowser === "boolean"
|
|
927
|
+
? { openInBrowser: params.openInBrowser }
|
|
928
|
+
: {}),
|
|
929
|
+
qrMediaDir: this.getMediaDir(),
|
|
930
|
+
...(this.daemonEnv && !params?.printOnly
|
|
931
|
+
? {
|
|
932
|
+
handoffToBackground: async () => {
|
|
933
|
+
provider.suppressReconnectsForHandoff();
|
|
934
|
+
try {
|
|
935
|
+
await handoffForegroundPairToBackground({
|
|
936
|
+
cliModuleUrl: new URL(
|
|
937
|
+
import.meta.url.endsWith(".ts") ? "./cli.ts" : "./cli.js",
|
|
938
|
+
import.meta.url,
|
|
939
|
+
).href,
|
|
940
|
+
stateDir: this.ensureStateDir(),
|
|
941
|
+
...(handoffEnv ? { env: handoffEnv } : {}),
|
|
942
|
+
...(params?.verbose === true ? { verbose: true } : {}),
|
|
943
|
+
handoffState: provider.exportHandoffState(),
|
|
944
|
+
});
|
|
945
|
+
return formatBilingualInline(
|
|
946
|
+
"当前 PrivateClaw 会话已转入后台。可使用 `openclaw privateclaw sessions` 查看,必要时用 `openclaw privateclaw sessions kill <sessionId>` 终止。",
|
|
947
|
+
"The current PrivateClaw session is now running in the background. Use `openclaw privateclaw sessions` to inspect it, and `openclaw privateclaw sessions kill <sessionId>` if you need to terminate it.",
|
|
948
|
+
);
|
|
949
|
+
} catch (error) {
|
|
950
|
+
provider.resumeReconnectsAfterHandoffFailure();
|
|
951
|
+
throw error;
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
}
|
|
955
|
+
: {}),
|
|
956
|
+
...(params?.writeLine ? { writeLine: params.writeLine } : {}),
|
|
957
|
+
});
|
|
867
958
|
});
|
|
868
959
|
}
|
|
869
960
|
|
|
@@ -871,6 +962,17 @@ class PrivateClawPluginRuntime {
|
|
|
871
962
|
return listManagedSessionsFromStateDir(this.ensureStateDir());
|
|
872
963
|
}
|
|
873
964
|
|
|
965
|
+
async followManagedSessionLog(
|
|
966
|
+
sessionId: string,
|
|
967
|
+
params?: { writeLine?: (line: string) => void },
|
|
968
|
+
) {
|
|
969
|
+
await followManagedSessionLogFromStateDir({
|
|
970
|
+
stateDir: this.ensureStateDir(),
|
|
971
|
+
sessionId,
|
|
972
|
+
...(params?.writeLine ? { writeLine: params.writeLine } : {}),
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
|
|
874
976
|
async kickManagedParticipant(sessionId: string, appId: string) {
|
|
875
977
|
return kickManagedParticipantFromStateDir({
|
|
876
978
|
stateDir: this.ensureStateDir(),
|
|
@@ -964,8 +1066,9 @@ function createPluginDefinition(
|
|
|
964
1066
|
|
|
965
1067
|
api.registerService?.({
|
|
966
1068
|
id: "privateclaw-provider",
|
|
967
|
-
start: ({ stateDir }) => {
|
|
1069
|
+
start: ({ stateDir, config }) => {
|
|
968
1070
|
runtime.setStateDir(stateDir);
|
|
1071
|
+
runtime.setRootConfig(config);
|
|
969
1072
|
},
|
|
970
1073
|
stop: async () => {
|
|
971
1074
|
await runtime.dispose();
|
|
@@ -979,6 +1082,7 @@ function createPluginDefinition(
|
|
|
979
1082
|
requireAuth: true,
|
|
980
1083
|
handler: async (ctx: OpenClawPluginCommandContextCompat) => {
|
|
981
1084
|
try {
|
|
1085
|
+
runtime.setRootConfig(ctx.config);
|
|
982
1086
|
api.logger.info(
|
|
983
1087
|
`[privateclaw] /privateclaw invoked via ${ctx.channel}${ctx.senderId ? ` by ${ctx.senderId}` : ""}`,
|
|
984
1088
|
);
|
|
@@ -1006,7 +1110,8 @@ function createPluginDefinition(
|
|
|
1006
1110
|
});
|
|
1007
1111
|
|
|
1008
1112
|
api.registerCli?.(
|
|
1009
|
-
({ program }) => {
|
|
1113
|
+
({ program, config }) => {
|
|
1114
|
+
runtime.setRootConfig(config);
|
|
1010
1115
|
const privateclaw = program
|
|
1011
1116
|
.command("privateclaw")
|
|
1012
1117
|
.description(PRIVATECLAW_CLI_ROOT_DESCRIPTION);
|
|
@@ -1021,6 +1126,7 @@ function createPluginDefinition(
|
|
|
1021
1126
|
.option("--print-only", PRIVATECLAW_CLI_PRINT_ONLY_OPTION_DESCRIPTION)
|
|
1022
1127
|
.option("--open", PRIVATECLAW_CLI_OPEN_OPTION_DESCRIPTION)
|
|
1023
1128
|
.option("--foreground", PRIVATECLAW_CLI_FOREGROUND_OPTION_DESCRIPTION)
|
|
1129
|
+
.option("--verbose", PRIVATECLAW_CLI_VERBOSE_OPTION_DESCRIPTION)
|
|
1024
1130
|
.action(async (rawOptions: unknown) => {
|
|
1025
1131
|
const options = normalizePairCliOptions(rawOptions);
|
|
1026
1132
|
const ttlMs = parsePositiveIntegerFlag(options.ttlMs, "--ttl-ms");
|
|
@@ -1037,6 +1143,9 @@ function createPluginDefinition(
|
|
|
1037
1143
|
...(typeof options.open === "boolean"
|
|
1038
1144
|
? { openInBrowser: options.open }
|
|
1039
1145
|
: {}),
|
|
1146
|
+
...(typeof options.verbose === "boolean"
|
|
1147
|
+
? { verbose: options.verbose }
|
|
1148
|
+
: {}),
|
|
1040
1149
|
writeLine: (line: string) => {
|
|
1041
1150
|
console.log(line);
|
|
1042
1151
|
},
|
|
@@ -1061,6 +1170,32 @@ function createPluginDefinition(
|
|
|
1061
1170
|
}
|
|
1062
1171
|
});
|
|
1063
1172
|
|
|
1173
|
+
sessions
|
|
1174
|
+
.command("follow")
|
|
1175
|
+
.description(PRIVATECLAW_CLI_SESSIONS_FOLLOW_DESCRIPTION)
|
|
1176
|
+
.argument("<sessionId>")
|
|
1177
|
+
.action(async (sessionIdRaw: unknown) => {
|
|
1178
|
+
try {
|
|
1179
|
+
const sessionId = readString(sessionIdRaw);
|
|
1180
|
+
if (!sessionId) {
|
|
1181
|
+
throw new Error(
|
|
1182
|
+
formatBilingualInline(
|
|
1183
|
+
"`sessions follow` 需要提供 sessionId。",
|
|
1184
|
+
"`sessions follow` requires a sessionId.",
|
|
1185
|
+
),
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
await runtime.followManagedSessionLog(sessionId, {
|
|
1189
|
+
writeLine: (line: string) => {
|
|
1190
|
+
console.log(line);
|
|
1191
|
+
},
|
|
1192
|
+
});
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
console.error(formatCommandError(error));
|
|
1195
|
+
process.exitCode = 1;
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1064
1199
|
sessions
|
|
1065
1200
|
.command("qr")
|
|
1066
1201
|
.description(PRIVATECLAW_CLI_SESSIONS_QR_DESCRIPTION)
|
|
@@ -1235,6 +1370,7 @@ export function createOpenClawCompatiblePlugin(
|
|
|
1235
1370
|
options.defaultTtlMs,
|
|
1236
1371
|
undefined,
|
|
1237
1372
|
inferRelayBaseUrlFromAppWsUrl(options.appWsUrl),
|
|
1373
|
+
options.verboseController,
|
|
1238
1374
|
),
|
|
1239
1375
|
);
|
|
1240
1376
|
}
|
|
@@ -1248,6 +1384,7 @@ export function createPrivateClawPlugin(): OpenClawExtensionPluginCompat {
|
|
|
1248
1384
|
resolved.defaultTtlMs,
|
|
1249
1385
|
buildDaemonEnvFromPluginConfig(pluginConfig),
|
|
1250
1386
|
pluginConfig.relayBaseUrl,
|
|
1387
|
+
resolved.verboseController,
|
|
1251
1388
|
);
|
|
1252
1389
|
});
|
|
1253
1390
|
}
|
package/src/pair-daemon.ts
CHANGED
|
@@ -111,6 +111,7 @@ export async function spawnBackgroundPairDaemon(params: {
|
|
|
111
111
|
label?: string;
|
|
112
112
|
groupMode?: boolean;
|
|
113
113
|
openInBrowser?: boolean;
|
|
114
|
+
verbose?: boolean;
|
|
114
115
|
}): Promise<PrivateClawInviteBundle> {
|
|
115
116
|
const tempDir = await mkdtemp(
|
|
116
117
|
path.join(os.tmpdir(), "privateclaw-pair-daemon-"),
|
|
@@ -131,6 +132,7 @@ export async function spawnBackgroundPairDaemon(params: {
|
|
|
131
132
|
...(params.label ? ["--label", params.label] : []),
|
|
132
133
|
...(params.groupMode ? ["--group"] : []),
|
|
133
134
|
...(params.openInBrowser ? ["--open"] : []),
|
|
135
|
+
...(params.verbose ? ["--verbose"] : []),
|
|
134
136
|
];
|
|
135
137
|
|
|
136
138
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -165,6 +167,7 @@ export async function handoffForegroundPairToBackground(params: {
|
|
|
165
167
|
env?: NodeJS.ProcessEnv;
|
|
166
168
|
stateDir: string;
|
|
167
169
|
handoffState: PrivateClawProviderHandoffState;
|
|
170
|
+
verbose?: boolean;
|
|
168
171
|
}): Promise<number> {
|
|
169
172
|
const tempDir = await mkdtemp(
|
|
170
173
|
path.join(os.tmpdir(), "privateclaw-pair-handoff-"),
|
|
@@ -183,6 +186,7 @@ export async function handoffForegroundPairToBackground(params: {
|
|
|
183
186
|
resultPath,
|
|
184
187
|
"--resume-snapshot-file",
|
|
185
188
|
snapshotPath,
|
|
189
|
+
...(params.verbose ? ["--verbose"] : []),
|
|
186
190
|
];
|
|
187
191
|
|
|
188
192
|
await new Promise<void>((resolve, reject) => {
|