@privateclaw/privateclaw 0.1.42 → 0.1.44
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/openclaw-plugin.js +76 -31
- package/dist/openclaw-plugin.js.map +1 -1
- package/dist/provider.d.ts +5 -0
- package/dist/provider.js +27 -0
- package/dist/provider.js.map +1 -1
- package/dist/session-control.js +5 -0
- package/dist/session-control.js.map +1 -1
- package/dist/setup.js +90 -30
- package/dist/setup.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +5 -2
- package/src/openclaw-plugin.ts +78 -32
- package/src/provider.ts +40 -0
- package/src/session-control.ts +5 -0
- package/src/setup.ts +117 -41
- package/src/types.ts +1 -0
package/src/setup.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { stdin, stdout } from "node:process";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import {
|
|
9
9
|
appendPrivateClawAppInstallFooter,
|
|
10
|
+
appendPrivateClawAppInstallFooterLines,
|
|
10
11
|
formatBilingualInline,
|
|
11
12
|
} from "./text.js";
|
|
12
13
|
|
|
@@ -861,10 +862,17 @@ export function buildPrivateClawSetupPlan(params: {
|
|
|
861
862
|
privateClawCommandAvailable: true,
|
|
862
863
|
introduction:
|
|
863
864
|
`[privateclaw-provider] ${formatBilingualInline(
|
|
864
|
-
|
|
865
|
-
|
|
865
|
+
params.status.privateClawPluginPresent
|
|
866
|
+
? "检测到本机已经安装了 PrivateClaw 插件。正在检查并更新到最新版本:"
|
|
867
|
+
: "本机的 OpenClaw + PrivateClaw 已经可用,接下来直接开始配对:",
|
|
868
|
+
params.status.privateClawPluginPresent
|
|
869
|
+
? "A PrivateClaw plugin is already installed locally. Checking for updates:"
|
|
870
|
+
: "OpenClaw + PrivateClaw are already available locally. Starting pairing next:",
|
|
866
871
|
)}`,
|
|
867
|
-
automaticSteps:
|
|
872
|
+
automaticSteps: [
|
|
873
|
+
...(params.status.privateClawPluginPresent ? [updateStep] : []),
|
|
874
|
+
...(gatewayModeStep ? [gatewayModeStep] : []),
|
|
875
|
+
],
|
|
868
876
|
manualSteps: params.configPath
|
|
869
877
|
? [...(gatewayModeStep ? [gatewayModeStep] : []), startupStep, pairingCommand]
|
|
870
878
|
: [pairingCommand],
|
|
@@ -1041,24 +1049,61 @@ export async function runPrivateClawSetup(
|
|
|
1041
1049
|
const packageSpec =
|
|
1042
1050
|
options.packageSpec ?? (await resolveCurrentPrivateClawPackageSpec());
|
|
1043
1051
|
const packageRoot = options.packageRoot ?? resolveCurrentPrivateClawPackageRoot();
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
...(typeof options.groupMode === "boolean"
|
|
1048
|
-
? { groupMode: options.groupMode }
|
|
1049
|
-
: {}),
|
|
1050
|
-
...(typeof options.ttlMs === "number" ? { ttlMs: options.ttlMs } : {}),
|
|
1051
|
-
...(options.durationPreset ? { durationPreset: options.durationPreset } : {}),
|
|
1052
|
-
...(options.promptForChoice
|
|
1053
|
-
? { promptForChoice: options.promptForChoice }
|
|
1054
|
-
: {}),
|
|
1055
|
-
}));
|
|
1052
|
+
const log = options.onLog ?? ((line: string) => console.log(line));
|
|
1053
|
+
|
|
1054
|
+
// Phase 1: Detect status and prepare the plugin BEFORE asking about pairing.
|
|
1056
1055
|
const status = await detectStatus();
|
|
1057
|
-
|
|
1056
|
+
|
|
1057
|
+
// If openclaw is not available at all, show manual steps with full pairing command.
|
|
1058
|
+
// Selection is needed early here to render the correct pairing command in guidance.
|
|
1059
|
+
if (!status.openClawAvailable) {
|
|
1060
|
+
const selection =
|
|
1061
|
+
options.selection ??
|
|
1062
|
+
(await resolvePrivateClawSetupSelection({
|
|
1063
|
+
...(typeof options.groupMode === "boolean"
|
|
1064
|
+
? { groupMode: options.groupMode }
|
|
1065
|
+
: {}),
|
|
1066
|
+
...(typeof options.ttlMs === "number" ? { ttlMs: options.ttlMs } : {}),
|
|
1067
|
+
...(options.durationPreset ? { durationPreset: options.durationPreset } : {}),
|
|
1068
|
+
...(options.promptForChoice
|
|
1069
|
+
? { promptForChoice: options.promptForChoice }
|
|
1070
|
+
: {}),
|
|
1071
|
+
}));
|
|
1072
|
+
const plan = buildPrivateClawSetupPlan({
|
|
1073
|
+
packageSpec,
|
|
1074
|
+
packageRoot,
|
|
1075
|
+
status,
|
|
1076
|
+
selection,
|
|
1077
|
+
...(options.configPath ? { configPath: options.configPath } : {}),
|
|
1078
|
+
...(options.relayBaseUrl ? { relayBaseUrl: options.relayBaseUrl } : {}),
|
|
1079
|
+
...(options.label ? { label: options.label } : {}),
|
|
1080
|
+
...(options.foreground ? { foreground: true } : {}),
|
|
1081
|
+
...(options.openInBrowser ? { openInBrowser: true } : {}),
|
|
1082
|
+
...(options.verbose ? { verbose: true } : {}),
|
|
1083
|
+
});
|
|
1084
|
+
const guidance = renderPrivateClawSetupGuidance(plan);
|
|
1085
|
+
for (const line of guidance.split("\n")) {
|
|
1086
|
+
log(line);
|
|
1087
|
+
}
|
|
1088
|
+
throw new Error(
|
|
1089
|
+
formatBilingualInline(
|
|
1090
|
+
"当前机器上还没有可用的 `openclaw` 命令,无法继续自动安装 PrivateClaw 插件。",
|
|
1091
|
+
"This machine does not have a working `openclaw` command yet, so the PrivateClaw plugin cannot be installed automatically.",
|
|
1092
|
+
),
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// Build a preparation plan with a placeholder selection to get the install/update/enable steps.
|
|
1097
|
+
const placeholderSelection: PrivateClawSetupSelection = {
|
|
1098
|
+
groupMode: false,
|
|
1099
|
+
ttlMs: DAY_MS,
|
|
1100
|
+
durationLabel: formatBilingualInline("24 小时", "24 hours"),
|
|
1101
|
+
};
|
|
1102
|
+
const prepPlan = buildPrivateClawSetupPlan({
|
|
1058
1103
|
packageSpec,
|
|
1059
1104
|
packageRoot,
|
|
1060
1105
|
status,
|
|
1061
|
-
selection,
|
|
1106
|
+
selection: placeholderSelection,
|
|
1062
1107
|
...(options.configPath ? { configPath: options.configPath } : {}),
|
|
1063
1108
|
...(options.relayBaseUrl ? { relayBaseUrl: options.relayBaseUrl } : {}),
|
|
1064
1109
|
...(options.label ? { label: options.label } : {}),
|
|
@@ -1066,35 +1111,19 @@ export async function runPrivateClawSetup(
|
|
|
1066
1111
|
...(options.openInBrowser ? { openInBrowser: true } : {}),
|
|
1067
1112
|
...(options.verbose ? { verbose: true } : {}),
|
|
1068
1113
|
});
|
|
1069
|
-
const guidance = renderPrivateClawSetupGuidance(plan);
|
|
1070
|
-
const log = options.onLog ?? ((line: string) => console.log(line));
|
|
1071
|
-
for (const line of guidance.split("\n")) {
|
|
1072
|
-
log(line);
|
|
1073
|
-
}
|
|
1074
1114
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
formatBilingualInline(
|
|
1078
|
-
"当前机器上还没有可用的 `openclaw` 命令,无法继续自动安装 PrivateClaw 插件。",
|
|
1079
|
-
"This machine does not have a working `openclaw` command yet, so the PrivateClaw plugin cannot be installed automatically.",
|
|
1080
|
-
),
|
|
1081
|
-
);
|
|
1082
|
-
}
|
|
1115
|
+
// Show introduction.
|
|
1116
|
+
log(prepPlan.introduction);
|
|
1083
1117
|
|
|
1118
|
+
// Run automatic steps (install / update / enable / restart).
|
|
1084
1119
|
const runStep = options.runStep ?? runPrivateClawSetupStep;
|
|
1085
|
-
const
|
|
1086
|
-
options.runPairingCommand ??
|
|
1087
|
-
((step: PrivateClawSetupStep) =>
|
|
1088
|
-
runStreamingCommand(step.command, step.args, {
|
|
1089
|
-
...(step.env ? { env: step.env } : {}),
|
|
1090
|
-
}));
|
|
1091
|
-
|
|
1092
|
-
for (const step of plan.automaticSteps) {
|
|
1120
|
+
for (const step of prepPlan.automaticSteps) {
|
|
1093
1121
|
log(`[privateclaw-provider] ${formatBilingualInline("正在执行", "Running")}: ${step.display}`);
|
|
1094
1122
|
await runStep(step);
|
|
1095
1123
|
}
|
|
1096
1124
|
|
|
1097
|
-
|
|
1125
|
+
// Verify command availability after install/update/enable.
|
|
1126
|
+
if (!prepPlan.privateClawCommandAvailable) {
|
|
1098
1127
|
const refreshedStatus = await waitForPrivateClawCommandAvailability(
|
|
1099
1128
|
detectStatus,
|
|
1100
1129
|
options.verificationTimeoutMs ?? 15_000,
|
|
@@ -1116,8 +1145,55 @@ export async function runPrivateClawSetup(
|
|
|
1116
1145
|
);
|
|
1117
1146
|
}
|
|
1118
1147
|
|
|
1148
|
+
// Phase 2: Plugin is now ready. Ask the user for pairing preferences.
|
|
1149
|
+
const selection =
|
|
1150
|
+
options.selection ??
|
|
1151
|
+
(await resolvePrivateClawSetupSelection({
|
|
1152
|
+
...(typeof options.groupMode === "boolean"
|
|
1153
|
+
? { groupMode: options.groupMode }
|
|
1154
|
+
: {}),
|
|
1155
|
+
...(typeof options.ttlMs === "number" ? { ttlMs: options.ttlMs } : {}),
|
|
1156
|
+
...(options.durationPreset ? { durationPreset: options.durationPreset } : {}),
|
|
1157
|
+
...(options.promptForChoice
|
|
1158
|
+
? { promptForChoice: options.promptForChoice }
|
|
1159
|
+
: {}),
|
|
1160
|
+
}));
|
|
1161
|
+
|
|
1162
|
+
log(
|
|
1163
|
+
`[privateclaw-provider] ${formatBilingualInline(
|
|
1164
|
+
`配对模式:${selection.groupMode ? "群聊" : "单独会话"}`,
|
|
1165
|
+
`Pairing mode: ${selection.groupMode ? "group chat" : "single chat"}`,
|
|
1166
|
+
)}`,
|
|
1167
|
+
);
|
|
1168
|
+
log(
|
|
1169
|
+
`[privateclaw-provider] ${formatBilingualInline(
|
|
1170
|
+
`会话时长:${selection.durationLabel.split(" / ")[0]}`,
|
|
1171
|
+
`Session duration: ${selection.durationLabel.split(" / ")[1] ?? selection.durationLabel}`,
|
|
1172
|
+
)}`,
|
|
1173
|
+
);
|
|
1174
|
+
|
|
1175
|
+
// Build and run the pairing command.
|
|
1176
|
+
const pairingCommand = buildPairingCommandStep({
|
|
1177
|
+
groupMode: selection.groupMode,
|
|
1178
|
+
ttlMs: selection.ttlMs,
|
|
1179
|
+
...(options.relayBaseUrl ? { relayBaseUrl: options.relayBaseUrl } : {}),
|
|
1180
|
+
...(options.configPath ? { configPath: options.configPath } : {}),
|
|
1181
|
+
...(options.label ? { label: options.label } : {}),
|
|
1182
|
+
...(options.foreground ? { foreground: true } : {}),
|
|
1183
|
+
...(options.openInBrowser ? { openInBrowser: true } : {}),
|
|
1184
|
+
...(options.verbose ? { verbose: true } : {}),
|
|
1185
|
+
});
|
|
1119
1186
|
log(
|
|
1120
|
-
`[privateclaw-provider] ${formatBilingualInline("开始配对", "Starting pairing")}: ${
|
|
1187
|
+
`[privateclaw-provider] ${formatBilingualInline("开始配对", "Starting pairing")}: ${pairingCommand.display}`,
|
|
1121
1188
|
);
|
|
1122
|
-
|
|
1189
|
+
for (const line of appendPrivateClawAppInstallFooterLines([])) {
|
|
1190
|
+
log(line);
|
|
1191
|
+
}
|
|
1192
|
+
const runPairingCommand =
|
|
1193
|
+
options.runPairingCommand ??
|
|
1194
|
+
((step: PrivateClawSetupStep) =>
|
|
1195
|
+
runStreamingCommand(step.command, step.args, {
|
|
1196
|
+
...(step.env ? { env: step.env } : {}),
|
|
1197
|
+
}));
|
|
1198
|
+
await runPairingCommand(pairingCommand);
|
|
1123
1199
|
}
|
package/src/types.ts
CHANGED
|
@@ -121,6 +121,7 @@ export interface ProviderParticipantState extends PrivateClawParticipant {
|
|
|
121
121
|
lastUserMessageAt?: string;
|
|
122
122
|
botModeSilentJoinPromptSentAt?: string;
|
|
123
123
|
supportsThinkingTrace?: boolean;
|
|
124
|
+
supportsTypingIndicator?: boolean;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
export interface PrivateClawManagedSession {
|