talon-agent 5.22.0 → 5.23.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/package.json
CHANGED
|
@@ -122,6 +122,8 @@ export type BridgeServerHandlers = {
|
|
|
122
122
|
liveTurnEvents(): BridgeEvent[];
|
|
123
123
|
/** Resolve a media id to an absolute file path (or null if unknown). */
|
|
124
124
|
mediaPath(id: string): string | null;
|
|
125
|
+
/** Best-effort original file name for a media id (or null if unknown). */
|
|
126
|
+
mediaName?(id: string): string | null;
|
|
125
127
|
/** Register/update one mesh device. */
|
|
126
128
|
registerDevice(body: Record<string, unknown>): Promise<DeviceInfo>;
|
|
127
129
|
/** Store the last-known location for one mesh device. */
|
|
@@ -38,7 +38,8 @@ import {
|
|
|
38
38
|
} from "./tls.js";
|
|
39
39
|
import { checkBridgeTokenStrength } from "./auth.js";
|
|
40
40
|
import { AuthGuard, type AuthGuardPolicy } from "./auth-guard.js";
|
|
41
|
-
import {
|
|
41
|
+
import { basename } from "node:path";
|
|
42
|
+
import { contentTypeFor, safeUploadName } from "../media/media.js";
|
|
42
43
|
import { type BridgeEvent } from "../protocol.js";
|
|
43
44
|
import { buildRoutes } from "./routes/index.js";
|
|
44
45
|
import type { BridgeServerHandlers, RouteHost } from "./routes/host.js";
|
|
@@ -609,10 +610,15 @@ export class BridgeServer {
|
|
|
609
610
|
if (!info.isFile()) {
|
|
610
611
|
return this.json(res, 404, { ok: false, error: "No such media" });
|
|
611
612
|
}
|
|
613
|
+
const rawName =
|
|
614
|
+
this.handlers.mediaName?.(id) ??
|
|
615
|
+
basename(filePath).replace(/^\d+-[0-9a-z]+-/, "");
|
|
616
|
+
const filename = safeUploadName(rawName);
|
|
612
617
|
res.writeHead(200, {
|
|
613
618
|
...this.corsHeaders(),
|
|
614
619
|
"Content-Type": contentTypeFor(filePath),
|
|
615
620
|
"Content-Length": String(info.size),
|
|
621
|
+
"Content-Disposition": `inline; filename="${filename}"`,
|
|
616
622
|
"Cache-Control": "private, max-age=3600",
|
|
617
623
|
});
|
|
618
624
|
const stream = createReadStream(filePath);
|
|
@@ -119,7 +119,19 @@ export function buildBridgeHandlers(
|
|
|
119
119
|
// which `runTurn` sets synchronously, so even a rapid second /send from
|
|
120
120
|
// any client is caught here rather than starting a concurrent turn.
|
|
121
121
|
if (isBusy(runtime, entry.id)) {
|
|
122
|
-
|
|
122
|
+
const existing = runtime.queuedByChat.get(entry.id);
|
|
123
|
+
if (existing) {
|
|
124
|
+
const combinedText = [existing.text.trim(), text.trim()]
|
|
125
|
+
.filter(Boolean)
|
|
126
|
+
.join("\n\n");
|
|
127
|
+
const combinedAttachments = [...existing.attachments, ...attachments];
|
|
128
|
+
setQueued(runtime, entry.id, {
|
|
129
|
+
text: combinedText,
|
|
130
|
+
attachments: combinedAttachments,
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
setQueued(runtime, entry.id, { text, attachments });
|
|
134
|
+
}
|
|
123
135
|
return;
|
|
124
136
|
}
|
|
125
137
|
startTurn(runtime, entry, text, { attachments });
|
|
@@ -180,6 +192,7 @@ export function buildBridgeHandlers(
|
|
|
180
192
|
readLogEntries(files.log, { limit: lines, minLevel, component }),
|
|
181
193
|
liveTurnEvents: () => liveTurnEvents(runtime),
|
|
182
194
|
mediaPath: (id) => runtime.media.get(id) ?? null,
|
|
195
|
+
mediaName: (id) => runtime.uploads.get(id)?.name ?? null,
|
|
183
196
|
// Mesh routes are thin transport shims over the shared core service —
|
|
184
197
|
// storeLocation wakes any pending fresh-fix waiters inside the service.
|
|
185
198
|
registerDevice: (body) => mesh.register(body),
|