@rethinkingstudio/clawpilot 1.0.17 → 1.0.18
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/index.js +1 -1
- package/dist/relay/relay-manager.js +37 -4
- package/dist/relay/relay-manager.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/relay/relay-manager.ts +45 -4
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { runCommand } from "./commands/run.js";
|
|
|
5
5
|
import { installCommand, uninstallCommand, stopCommand, restartCommand, resetCommand } from "./commands/install.js";
|
|
6
6
|
import { statusCommand } from "./commands/status.js";
|
|
7
7
|
import { setTokenCommand } from "./commands/set-token.js";
|
|
8
|
-
const version = "1.0.
|
|
8
|
+
const version = "1.0.18";
|
|
9
9
|
const program = new Command();
|
|
10
10
|
program
|
|
11
11
|
.name("clawpilot")
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { WebSocket } from "ws";
|
|
2
2
|
import { OpenClawGatewayClient } from "./gateway-client.js";
|
|
3
3
|
import { handleLocalCommand } from "../commands/local-handlers.js";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Constants
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
const OUTBOUND_DIR = join(homedir(), ".openclaw", "media", "outbound");
|
|
4
12
|
// ---------------------------------------------------------------------------
|
|
5
13
|
// Main entry point
|
|
6
14
|
// ---------------------------------------------------------------------------
|
|
@@ -53,7 +61,7 @@ export async function runRelayManager(opts) {
|
|
|
53
61
|
});
|
|
54
62
|
gatewayClient.start();
|
|
55
63
|
});
|
|
56
|
-
relayWs.on("message", (raw) => {
|
|
64
|
+
relayWs.on("message", async (raw) => {
|
|
57
65
|
let msg;
|
|
58
66
|
try {
|
|
59
67
|
msg = JSON.parse(raw.toString());
|
|
@@ -78,12 +86,37 @@ export async function runRelayManager(opts) {
|
|
|
78
86
|
}
|
|
79
87
|
return;
|
|
80
88
|
}
|
|
81
|
-
//
|
|
89
|
+
// Handle chat.send with attachments - save to disk and add path reference
|
|
82
90
|
if (msg.method === "chat.send") {
|
|
83
91
|
const params = msg.params;
|
|
84
92
|
if (params.attachments && params.attachments.length > 0) {
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
const fileReferences = [];
|
|
94
|
+
// Ensure outbound directory exists
|
|
95
|
+
await mkdir(OUTBOUND_DIR, { recursive: true });
|
|
96
|
+
// Save each attachment to disk and create path reference
|
|
97
|
+
for (const att of params.attachments) {
|
|
98
|
+
try {
|
|
99
|
+
// Decode base64 to buffer
|
|
100
|
+
const buffer = Buffer.from(att.content, "base64");
|
|
101
|
+
const ext = att.mimeType === "image/png" ? ".png" : ".jpg";
|
|
102
|
+
const stagedFileName = `${randomUUID()}${ext}`;
|
|
103
|
+
const stagedPath = join(OUTBOUND_DIR, stagedFileName);
|
|
104
|
+
// Write to disk
|
|
105
|
+
await writeFile(stagedPath, buffer);
|
|
106
|
+
console.log(`[relay] Saved attachment to: ${stagedPath}`);
|
|
107
|
+
// Create path reference (same format as ClawX)
|
|
108
|
+
fileReferences.push(`[media attached: ${stagedPath} (${att.mimeType}) | ${stagedPath}]`);
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
console.error(`[relay] Failed to save attachment: ${err}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Append file references to message
|
|
115
|
+
if (fileReferences.length > 0) {
|
|
116
|
+
const refs = fileReferences.join("\n");
|
|
117
|
+
params.message = params.message ? `${params.message}\n\n${refs}` : refs;
|
|
118
|
+
console.log(`[relay] Added file references to message`);
|
|
119
|
+
}
|
|
87
120
|
}
|
|
88
121
|
}
|
|
89
122
|
gatewayClient
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay-manager.js","sourceRoot":"","sources":["../../src/relay/relay-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"relay-manager.js","sourceRoot":"","sources":["../../src/relay/relay-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAoCvE,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAyB;IAC7D,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAEnF,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;QACtC,IAAI,OAAkB,CAAC;QACvB,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,GAAG,EAAE,CA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E,EAAE,CAAC,CAAC;YACrE,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YACxB,aAAa,EAAE,IAAI,EAAE,CAAC;YACtB,aAAa,GAAG,IAAI,CAAC;YACrB,uEAAuE;YACvE,sEAAsE;YACtE,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC1B,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YACrD,0BAA0B;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,SAAiB,EAAE,SAAiB,EAAE,WAAmB;IAC9E,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClE,OAAO,GAAG,IAAI,UAAU,SAAS,WAAW,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;AAChF,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { installCommand, uninstallCommand, stopCommand, restartCommand, resetCom
|
|
|
6
6
|
import { statusCommand } from "./commands/status.js";
|
|
7
7
|
import { setTokenCommand } from "./commands/set-token.js";
|
|
8
8
|
|
|
9
|
-
const version = "1.0.
|
|
9
|
+
const version = "1.0.18";
|
|
10
10
|
|
|
11
11
|
const program = new Command();
|
|
12
12
|
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { WebSocket } from "ws";
|
|
2
2
|
import { OpenClawGatewayClient } from "./gateway-client.js";
|
|
3
3
|
import { handleLocalCommand } from "../commands/local-handlers.js";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Constants
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
const OUTBOUND_DIR = join(homedir(), ".openclaw", "media", "outbound");
|
|
4
14
|
|
|
5
15
|
// ---------------------------------------------------------------------------
|
|
6
16
|
// Messages: relay client ↔ relay server
|
|
@@ -98,7 +108,7 @@ export async function runRelayManager(opts: RelayManagerOptions): Promise<boolea
|
|
|
98
108
|
gatewayClient.start();
|
|
99
109
|
});
|
|
100
110
|
|
|
101
|
-
relayWs.on("message", (raw) => {
|
|
111
|
+
relayWs.on("message", async (raw) => {
|
|
102
112
|
let msg: FromServer;
|
|
103
113
|
try {
|
|
104
114
|
msg = JSON.parse(raw.toString()) as FromServer;
|
|
@@ -124,12 +134,43 @@ export async function runRelayManager(opts: RelayManagerOptions): Promise<boolea
|
|
|
124
134
|
return;
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
//
|
|
137
|
+
// Handle chat.send with attachments - save to disk and add path reference
|
|
128
138
|
if (msg.method === "chat.send") {
|
|
129
139
|
const params = msg.params as any;
|
|
130
140
|
if (params.attachments && params.attachments.length > 0) {
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
const fileReferences: string[] = [];
|
|
142
|
+
|
|
143
|
+
// Ensure outbound directory exists
|
|
144
|
+
await mkdir(OUTBOUND_DIR, { recursive: true });
|
|
145
|
+
|
|
146
|
+
// Save each attachment to disk and create path reference
|
|
147
|
+
for (const att of params.attachments) {
|
|
148
|
+
try {
|
|
149
|
+
// Decode base64 to buffer
|
|
150
|
+
const buffer = Buffer.from(att.content, "base64");
|
|
151
|
+
const ext = att.mimeType === "image/png" ? ".png" : ".jpg";
|
|
152
|
+
const stagedFileName = `${randomUUID()}${ext}`;
|
|
153
|
+
const stagedPath = join(OUTBOUND_DIR, stagedFileName);
|
|
154
|
+
|
|
155
|
+
// Write to disk
|
|
156
|
+
await writeFile(stagedPath, buffer);
|
|
157
|
+
console.log(`[relay] Saved attachment to: ${stagedPath}`);
|
|
158
|
+
|
|
159
|
+
// Create path reference (same format as ClawX)
|
|
160
|
+
fileReferences.push(
|
|
161
|
+
`[media attached: ${stagedPath} (${att.mimeType}) | ${stagedPath}]`
|
|
162
|
+
);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
console.error(`[relay] Failed to save attachment: ${err}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Append file references to message
|
|
169
|
+
if (fileReferences.length > 0) {
|
|
170
|
+
const refs = fileReferences.join("\n");
|
|
171
|
+
params.message = params.message ? `${params.message}\n\n${refs}` : refs;
|
|
172
|
+
console.log(`[relay] Added file references to message`);
|
|
173
|
+
}
|
|
133
174
|
}
|
|
134
175
|
}
|
|
135
176
|
|