@rethinkingstudio/clawpilot 1.1.17 → 2.0.0-beta.1
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/commands/install.js +17 -18
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/openclaw-cli.js +23 -3
- package/dist/commands/openclaw-cli.js.map +1 -1
- package/dist/commands/pair.js +8 -1
- package/dist/commands/pair.js.map +1 -1
- package/dist/commands/status.js +3 -0
- package/dist/commands/status.js.map +1 -1
- package/dist/i18n/index.js +6 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/platform/service-manager.d.ts +6 -0
- package/dist/platform/service-manager.js +384 -42
- package/dist/platform/service-manager.js.map +1 -1
- package/package.json +8 -1
- package/src/commands/assistant-send.ts +0 -91
- package/src/commands/install.ts +0 -128
- package/src/commands/local-handlers.ts +0 -533
- package/src/commands/openclaw-cli.ts +0 -329
- package/src/commands/pair.ts +0 -120
- package/src/commands/provider-config.ts +0 -275
- package/src/commands/provider-handlers.ts +0 -184
- package/src/commands/provider-registry.ts +0 -138
- package/src/commands/run.ts +0 -34
- package/src/commands/send.ts +0 -42
- package/src/commands/session-key.ts +0 -77
- package/src/commands/set-token.ts +0 -45
- package/src/commands/status.ts +0 -154
- package/src/commands/upload.ts +0 -141
- package/src/config/config.ts +0 -137
- package/src/generated/build-config.ts +0 -1
- package/src/i18n/index.ts +0 -179
- package/src/index.ts +0 -166
- package/src/media/assistant-attachments.ts +0 -205
- package/src/media/oss-uploader.ts +0 -306
- package/src/platform/service-manager.ts +0 -570
- package/src/relay/gateway-client.ts +0 -359
- package/src/relay/reconnect.ts +0 -37
- package/src/relay/relay-manager.ts +0 -328
- package/test-chat.mjs +0 -64
- package/test-direct.mjs +0 -171
- package/tsconfig.json +0 -16
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { basename } from "path";
|
|
2
|
-
import { randomUUID } from "crypto";
|
|
3
|
-
import { readConfig } from "../config/config.js";
|
|
4
|
-
import { resolveSessionKeyFromStatus } from "./session-key.js";
|
|
5
|
-
|
|
6
|
-
export interface AssistantSendCommandOptions {
|
|
7
|
-
sessionKey?: string;
|
|
8
|
-
url?: string;
|
|
9
|
-
mimeType?: string;
|
|
10
|
-
fileName?: string;
|
|
11
|
-
message?: string;
|
|
12
|
-
thumbnailUrl?: string;
|
|
13
|
-
width?: string;
|
|
14
|
-
height?: string;
|
|
15
|
-
size?: string;
|
|
16
|
-
durationMs?: string;
|
|
17
|
-
json?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface AssistantSendResult {
|
|
21
|
-
runId: string;
|
|
22
|
-
sessionKey: string;
|
|
23
|
-
messageId: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function parseOptionalInt(value: string | undefined, label: string): number | undefined {
|
|
27
|
-
if (value == null || value.trim() === "") return undefined;
|
|
28
|
-
const parsed = Number.parseInt(value, 10);
|
|
29
|
-
if (!Number.isFinite(parsed)) {
|
|
30
|
-
throw new Error(`${label} must be an integer`);
|
|
31
|
-
}
|
|
32
|
-
return parsed;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export async function sendSyntheticAssistantMessage(
|
|
36
|
-
options: AssistantSendCommandOptions
|
|
37
|
-
): Promise<AssistantSendResult> {
|
|
38
|
-
const config = readConfig();
|
|
39
|
-
const sessionKey = options.sessionKey?.trim() || resolveSessionKeyFromStatus();
|
|
40
|
-
const hasAttachment = Boolean(options.url?.trim());
|
|
41
|
-
const text = options.message?.trim() ?? "";
|
|
42
|
-
|
|
43
|
-
if (!hasAttachment && !text) {
|
|
44
|
-
throw new Error("assistant-send requires either --url or --message");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const attachments = hasAttachment
|
|
48
|
-
? [{
|
|
49
|
-
url: options.url!.trim(),
|
|
50
|
-
mimeType: (options.mimeType?.trim() || "application/octet-stream"),
|
|
51
|
-
fileName: options.fileName?.trim() || basename(options.url!.trim()),
|
|
52
|
-
thumbnailUrl: options.thumbnailUrl?.trim() || undefined,
|
|
53
|
-
width: parseOptionalInt(options.width, "width"),
|
|
54
|
-
height: parseOptionalInt(options.height, "height"),
|
|
55
|
-
size: parseOptionalInt(options.size, "size"),
|
|
56
|
-
durationMs: parseOptionalInt(options.durationMs, "durationMs"),
|
|
57
|
-
}]
|
|
58
|
-
: [];
|
|
59
|
-
|
|
60
|
-
const body = {
|
|
61
|
-
gatewayId: config.gatewayId,
|
|
62
|
-
relaySecret: config.relaySecret,
|
|
63
|
-
sessionKey,
|
|
64
|
-
runId: randomUUID(),
|
|
65
|
-
message: text || (attachments.length > 0 ? "uploaded file" : ""),
|
|
66
|
-
attachments,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const response = await fetch(`${config.relayServerUrl.replace(/\/$/, "")}/api/relay/assistant-message`, {
|
|
70
|
-
method: "POST",
|
|
71
|
-
headers: { "Content-Type": "application/json" },
|
|
72
|
-
body: JSON.stringify(body),
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
if (!response.ok) {
|
|
76
|
-
const errorText = await response.text().catch(() => "");
|
|
77
|
-
throw new Error(`assistant-send failed: ${response.status} ${errorText}`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return await response.json() as AssistantSendResult;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export async function assistantSendCommand(options: AssistantSendCommandOptions): Promise<void> {
|
|
84
|
-
const payload = await sendSyntheticAssistantMessage(options);
|
|
85
|
-
if (options.json) {
|
|
86
|
-
console.log(JSON.stringify(payload));
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log(`Assistant message sent: runId=${payload.runId} sessionKey=${payload.sessionKey} messageId=${payload.messageId}`);
|
|
91
|
-
}
|
package/src/commands/install.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { existsSync, unlinkSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { homedir } from "os";
|
|
4
|
-
import { t } from "../i18n/index.js";
|
|
5
|
-
import {
|
|
6
|
-
getServicePlatform,
|
|
7
|
-
getServiceStatus,
|
|
8
|
-
installService,
|
|
9
|
-
restartService,
|
|
10
|
-
stopService,
|
|
11
|
-
uninstallService,
|
|
12
|
-
servicePaths,
|
|
13
|
-
} from "../platform/service-manager.js";
|
|
14
|
-
|
|
15
|
-
export function isInstalled(): boolean {
|
|
16
|
-
const platform = getServicePlatform();
|
|
17
|
-
if (platform === "macos") return existsSync(servicePaths.macPlistPath);
|
|
18
|
-
if (platform === "linux") {
|
|
19
|
-
return existsSync(servicePaths.linuxServicePath) || existsSync(servicePaths.linuxNohupStartScriptPath);
|
|
20
|
-
}
|
|
21
|
-
if (platform === "windows") {
|
|
22
|
-
return existsSync(servicePaths.windowsPidPath);
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function installCommand(): void {
|
|
28
|
-
const platform = getServicePlatform();
|
|
29
|
-
if (platform === "unsupported") {
|
|
30
|
-
console.log(t("install.unsupported", process.platform));
|
|
31
|
-
console.log(t("install.runForeground"));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const started = installService();
|
|
36
|
-
if (started) {
|
|
37
|
-
const service = getServiceStatus();
|
|
38
|
-
console.log(t("install.serviceStarted", service.manager));
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
console.log(t("install.installFailed", platformName(platform)));
|
|
43
|
-
if (platform === "macos") {
|
|
44
|
-
console.log(t("install.serviceFileWritten", servicePaths.macPlistPath));
|
|
45
|
-
console.log(t("install.startManually", `launchctl load -w "${servicePaths.macPlistPath}"`));
|
|
46
|
-
} else if (platform === "linux") {
|
|
47
|
-
console.log(t("install.serviceFileWritten", servicePaths.linuxServicePath));
|
|
48
|
-
console.log(t("install.startManually", "systemctl --user daemon-reload && systemctl --user enable --now clawpilot.service"));
|
|
49
|
-
console.log(t("install.startManually", `bash "${servicePaths.linuxNohupStartScriptPath}"`));
|
|
50
|
-
} else if (platform === "windows") {
|
|
51
|
-
console.log(t("install.serviceFileWritten", servicePaths.windowsPidPath));
|
|
52
|
-
console.log(t("install.startManually", "clawpilot install"));
|
|
53
|
-
console.log(t("install.startManually", "clawpilot run"));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function restartCommand(): void {
|
|
58
|
-
console.log(t("install.restarting"));
|
|
59
|
-
const platform = getServicePlatform();
|
|
60
|
-
if (platform === "unsupported") {
|
|
61
|
-
console.log(t("install.unsupported", process.platform));
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (restartService()) {
|
|
65
|
-
console.log(t("install.serviceRestarted", platformName(platform)));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
console.log(t("install.restartFailed", platformName(platform)));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function uninstallCommand(): void {
|
|
72
|
-
const platform = getServicePlatform();
|
|
73
|
-
if (platform === "unsupported") {
|
|
74
|
-
console.log(t("install.unsupported", process.platform));
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const changed = uninstallService();
|
|
78
|
-
if (changed) {
|
|
79
|
-
console.log(t("install.stoppedAndRemoved", platformName(platform)));
|
|
80
|
-
} else {
|
|
81
|
-
console.log(t("install.noService"));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function stopCommand(): void {
|
|
86
|
-
const platform = getServicePlatform();
|
|
87
|
-
if (platform === "unsupported") {
|
|
88
|
-
console.log(t("install.unsupported", process.platform));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const changed = stopService();
|
|
92
|
-
if (changed) {
|
|
93
|
-
console.log(t("install.stopped", platformName(platform)));
|
|
94
|
-
} else {
|
|
95
|
-
console.log(t("install.noService"));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function resetCommand(): void {
|
|
100
|
-
stopCommand();
|
|
101
|
-
|
|
102
|
-
const configPath = join(homedir(), ".clawai", "config.json");
|
|
103
|
-
if (existsSync(configPath)) {
|
|
104
|
-
try {
|
|
105
|
-
unlinkSync(configPath);
|
|
106
|
-
console.log(t("install.configRemoved", configPath));
|
|
107
|
-
} catch (err) {
|
|
108
|
-
console.error(t("install.removeConfigFailed"), err);
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
console.log(t("install.noConfig"));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
console.log(t("install.resetComplete"));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function platformName(platform: ReturnType<typeof getServicePlatform>): string {
|
|
118
|
-
switch (platform) {
|
|
119
|
-
case "macos":
|
|
120
|
-
return "launchd";
|
|
121
|
-
case "linux":
|
|
122
|
-
return "systemd/nohup";
|
|
123
|
-
case "windows":
|
|
124
|
-
return "windows-detached";
|
|
125
|
-
default:
|
|
126
|
-
return process.platform;
|
|
127
|
-
}
|
|
128
|
-
}
|