talon-agent 1.35.0 → 1.37.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.
Files changed (46) hide show
  1. package/package.json +3 -3
  2. package/src/backend/claude-sdk/handler.ts +6 -2
  3. package/src/backend/claude-sdk/options.ts +41 -1
  4. package/src/backend/codex/handler/events.ts +1 -1
  5. package/src/backend/codex/handler/message.ts +1 -0
  6. package/src/backend/kilo/handler/message.ts +1 -0
  7. package/src/backend/kilo/handler/turn.ts +1 -0
  8. package/src/backend/openai-agents/handler/events.ts +1 -1
  9. package/src/backend/openai-agents/handler/message.ts +5 -1
  10. package/src/backend/opencode/handler/message.ts +1 -0
  11. package/src/backend/opencode/handler/turn.ts +1 -0
  12. package/src/backend/remote-server/events.ts +3 -1
  13. package/src/backend/shared/metrics.ts +26 -51
  14. package/src/bootstrap.ts +1 -0
  15. package/src/core/engine/gateway-actions/index.ts +2 -0
  16. package/src/core/engine/gateway-actions/mesh.ts +27 -0
  17. package/src/core/engine/gateway-actions/native.ts +607 -0
  18. package/src/core/mcp-hub/index.ts +3 -0
  19. package/src/core/mcp-hub/talon-server.ts +3 -0
  20. package/src/core/mesh/persist.ts +49 -0
  21. package/src/core/mesh/registry.ts +10 -18
  22. package/src/core/mesh/service.ts +754 -42
  23. package/src/core/mesh/teleport.ts +158 -0
  24. package/src/core/mesh/transfers.ts +186 -0
  25. package/src/core/tools/bridge.ts +85 -4
  26. package/src/core/tools/index.ts +23 -2
  27. package/src/core/tools/mesh.ts +83 -1
  28. package/src/core/tools/native.ts +138 -0
  29. package/src/core/tools/types.ts +2 -1
  30. package/src/frontend/discord/commands/admin.ts +9 -2
  31. package/src/frontend/discord/helpers.ts +7 -6
  32. package/src/frontend/native/chats.ts +2 -2
  33. package/src/frontend/native/index.ts +2 -0
  34. package/src/frontend/native/server.ts +40 -1
  35. package/src/frontend/telegram/commands/admin.ts +10 -2
  36. package/src/frontend/telegram/helpers/diagnostics.ts +7 -6
  37. package/src/storage/db.ts +6 -1
  38. package/src/storage/repositories/sessions-repo.ts +20 -1
  39. package/src/storage/sessions.ts +348 -4
  40. package/src/storage/sql/db.sql +5 -0
  41. package/src/storage/sql/schema.sql +2 -1
  42. package/src/storage/sql/sessions.sql +3 -3
  43. package/src/storage/sql/statements.generated.ts +8 -4
  44. package/src/util/config.ts +10 -0
  45. package/src/util/exec-output.ts +64 -0
  46. package/src/util/metrics.ts +148 -60
@@ -7,9 +7,9 @@
7
7
  * MeshService, so the registry stays trivially testable.
8
8
  */
9
9
 
10
- import { mkdir, readFile, writeFile } from "node:fs/promises";
11
- import { dirname, resolve } from "node:path";
10
+ import { resolve } from "node:path";
12
11
  import { dirs } from "../../util/paths.js";
12
+ import { readArray, writePrivateJson } from "./persist.js";
13
13
  import {
14
14
  sanitizeCapabilities,
15
15
  toDeviceInfo,
@@ -19,7 +19,14 @@ import {
19
19
  type DevicePlatform,
20
20
  } from "./types.js";
21
21
 
22
- const PRESENCE_TIMEOUT_MS = 90_000;
22
+ /**
23
+ * A device is offline once it misses several heartbeats. The companion
24
+ * re-registers every ~60s, so 180s tolerates two dropped beats (transient
25
+ * radio/network hiccups) before flipping a device offline — wide enough that
26
+ * a single late beat never flaps presence, tight enough that a genuinely
27
+ * gone device is marked offline within ~3 minutes.
28
+ */
29
+ const PRESENCE_TIMEOUT_MS = 180_000;
23
30
  const DEVICE_FILE = resolve(dirs.root, "mesh-devices.json");
24
31
  const LOCATION_FILE = resolve(dirs.root, "mesh-locations.json");
25
32
  const HISTORY_FILE = resolve(dirs.root, "mesh-history.json");
@@ -174,21 +181,6 @@ export class MeshRegistry {
174
181
  }
175
182
  }
176
183
 
177
- async function readArray<T>(path: string): Promise<T[]> {
178
- try {
179
- const raw = await readFile(path, "utf8");
180
- const parsed = JSON.parse(raw) as unknown;
181
- return Array.isArray(parsed) ? (parsed as T[]) : [];
182
- } catch {
183
- return [];
184
- }
185
- }
186
-
187
- async function writePrivateJson(path: string, value: unknown): Promise<void> {
188
- await mkdir(dirname(path), { recursive: true });
189
- await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
190
- }
191
-
192
184
  function sanitizeDevice(
193
185
  body: Record<string, unknown>,
194
186
  now: number,