talon-agent 1.34.0 → 1.35.0

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.
@@ -30,6 +30,8 @@ import {
30
30
  type BridgeStatus,
31
31
  type ClientChat,
32
32
  type ClientMessage,
33
+ type DeviceInfo,
34
+ type DeviceLocation,
33
35
  type LogEntry,
34
36
  type LogLevel,
35
37
  type ModelOption,
@@ -105,6 +107,16 @@ export type BridgeServerHandlers = {
105
107
  liveTurnEvents(): BridgeEvent[];
106
108
  /** Resolve a media id to an absolute file path (or null if unknown). */
107
109
  mediaPath(id: string): string | null;
110
+ /** Register/update one mesh device. */
111
+ registerDevice(body: Record<string, unknown>): Promise<DeviceInfo>;
112
+ /** Store the last-known location for one mesh device. */
113
+ storeLocation(body: Record<string, unknown>): Promise<DeviceLocation>;
114
+ /** List mesh devices and their last-known locations. */
115
+ listDevices():
116
+ | { devices: DeviceInfo[]; locations: DeviceLocation[] }
117
+ | Promise<{ devices: DeviceInfo[]; locations: DeviceLocation[] }>;
118
+ /** A device answered a device_command; true when a call was waiting. */
119
+ completeCommand(body: Record<string, unknown>): boolean;
108
120
  };
109
121
 
110
122
  const SSE_PING_MS = 25_000;
@@ -256,6 +268,7 @@ export class BridgeServer {
256
268
  backend: s.backend,
257
269
  model: s.model,
258
270
  activeChats: s.activeChats,
271
+ capabilities: ["mesh", "mesh-commands"],
259
272
  });
260
273
  }
261
274
 
@@ -356,6 +369,31 @@ export class BridgeServer {
356
369
  return this.json(res, 202, { ok: true });
357
370
  }
358
371
 
372
+ if (method === "POST" && path === "/devices/register") {
373
+ const body = await this.readJson(req);
374
+ const device = await this.handlers.registerDevice(body);
375
+ return this.json(res, 200, { ok: true, deviceId: device.id });
376
+ }
377
+
378
+ if (method === "POST" && path === "/location") {
379
+ const body = await this.readJson(req);
380
+ await this.handlers.storeLocation(body);
381
+ return this.json(res, 200, { ok: true });
382
+ }
383
+
384
+ if (method === "GET" && path === "/devices") {
385
+ return this.json(res, 200, await this.handlers.listDevices());
386
+ }
387
+
388
+ if (method === "POST" && path === "/devices/command-result") {
389
+ const body = await this.readJson(req);
390
+ // ok:false for a late/unknown correlation id — not an HTTP error,
391
+ // the device's POST was well-formed; nothing was waiting anymore.
392
+ return this.json(res, 200, {
393
+ ok: this.handlers.completeCommand(body),
394
+ });
395
+ }
396
+
359
397
  if (method === "POST" && path === "/upload") {
360
398
  const filename = url.searchParams.get("filename") ?? "upload";
361
399
  const contentType =