claude-bridge-cli 2.0.5 → 2.0.7
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/bin/cli.js +6 -0
- package/lib/bridge.js +15 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -116,6 +116,7 @@ Usage:
|
|
|
116
116
|
claude-code-bridge install-service Register as a system service (auto-start on boot)
|
|
117
117
|
claude-code-bridge uninstall-service Remove the system service
|
|
118
118
|
claude-code-bridge --help Show this help
|
|
119
|
+
claude-code-bridge --version Print the installed version
|
|
119
120
|
|
|
120
121
|
Options:
|
|
121
122
|
--port <n> HTTP port for the local bridge (default: 8091)
|
|
@@ -152,6 +153,10 @@ function env(key, def) {
|
|
|
152
153
|
|
|
153
154
|
function main() {
|
|
154
155
|
const args = process.argv.slice(2);
|
|
156
|
+
if (args.includes("--version") || args.includes("-v") || args[0] === "version") {
|
|
157
|
+
console.log(require("../package.json").version);
|
|
158
|
+
process.exit(0);
|
|
159
|
+
}
|
|
155
160
|
if (args.includes("--help") || args.includes("-h") || args.length === 0) {
|
|
156
161
|
console.log(HELP);
|
|
157
162
|
process.exit(0);
|
|
@@ -216,6 +221,7 @@ function main() {
|
|
|
216
221
|
}
|
|
217
222
|
|
|
218
223
|
async function run(config) {
|
|
224
|
+
console.log(`[bridge] claude-bridge-cli v${require("../package.json").version}`);
|
|
219
225
|
console.log(`[bridge] Starting on http://${config.host}:${config.port}`);
|
|
220
226
|
console.log(`[bridge] Claude CWD: ${config.cwd}`);
|
|
221
227
|
|
package/lib/bridge.js
CHANGED
|
@@ -140,6 +140,15 @@ function saveSessionFile(sid, name, dataB64) {
|
|
|
140
140
|
fs.writeFileSync(fp, buf, { mode: 0o600 });
|
|
141
141
|
return { name: final, size: buf.length, mime: mimeFor(final), path: fp };
|
|
142
142
|
}
|
|
143
|
+
function deleteSessionFile(sid, name) {
|
|
144
|
+
const dir = sessionFilesDir(sid);
|
|
145
|
+
const safe = path.basename(name || "");
|
|
146
|
+
if (!safe || safe !== name || !FILE_NAME_RE.test(safe)) throw new Error("bad file name");
|
|
147
|
+
const fp = path.join(dir, safe);
|
|
148
|
+
if (!fs.existsSync(fp) || !fs.statSync(fp).isFile()) { const e = new Error("file not found"); e.notFound = true; throw e; }
|
|
149
|
+
fs.unlinkSync(fp);
|
|
150
|
+
return { deleted: safe };
|
|
151
|
+
}
|
|
143
152
|
|
|
144
153
|
function splitUserTextAndImages(text) {
|
|
145
154
|
const m = text.match(/\nThe user attached \d+ image\(s\) at these absolute paths\. Use the Read tool to view them:\n([\s\S]+)$/);
|
|
@@ -860,13 +869,18 @@ function startBridge(config) {
|
|
|
860
869
|
return;
|
|
861
870
|
}
|
|
862
871
|
}
|
|
863
|
-
// Session files — download one (
|
|
872
|
+
// Session files — download one (GET) / remove one (DELETE)
|
|
864
873
|
m = url.pathname.match(/^\/sessions\/([A-Za-z0-9._-]+)\/files\/(.+)$/);
|
|
865
874
|
if (m && req.method === "GET") {
|
|
866
875
|
try { send(200, readSessionFile(m[1], decodeURIComponent(m[2]))); }
|
|
867
876
|
catch (e) { send(e.notFound ? 404 : 400, { error: String(e.message || e) }); }
|
|
868
877
|
return;
|
|
869
878
|
}
|
|
879
|
+
if (m && req.method === "DELETE") {
|
|
880
|
+
try { send(200, deleteSessionFile(m[1], decodeURIComponent(m[2]))); }
|
|
881
|
+
catch (e) { send(e.notFound ? 404 : 400, { error: String(e.message || e) }); }
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
870
884
|
|
|
871
885
|
send(404, { error: "not found" });
|
|
872
886
|
});
|
package/package.json
CHANGED