lazyclaw 5.4.3 → 6.0.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/channels/handoff.mjs +36 -0
  2. package/cli.mjs +73 -7399
  3. package/daemon.mjs +23 -2085
  4. package/mas/agent_turn.mjs +2 -1
  5. package/mas/index_db.mjs +82 -0
  6. package/mas/learning.mjs +17 -1
  7. package/mas/mention_router.mjs +38 -10
  8. package/mas/provider_adapters.mjs +28 -4
  9. package/mas/scrub_env.mjs +34 -0
  10. package/mas/tool_runner.mjs +23 -7
  11. package/mas/tools/bash.mjs +10 -5
  12. package/mas/tools/browser.mjs +18 -0
  13. package/mas/tools/learning.mjs +24 -14
  14. package/mas/tools/recall.mjs +5 -1
  15. package/mas/tools/web.mjs +47 -11
  16. package/mas/trajectory_store.mjs +7 -4
  17. package/package.json +3 -2
  18. package/providers/auth_store.mjs +22 -0
  19. package/providers/claude_cli.mjs +28 -2
  20. package/providers/claude_cli_detect.mjs +46 -0
  21. package/providers/custom_provider.mjs +70 -0
  22. package/providers/model_catalogue.mjs +86 -0
  23. package/providers/orchestrator.mjs +30 -9
  24. package/providers/rates.mjs +12 -2
  25. package/providers/registry.mjs +10 -7
  26. package/sandbox/confiners/landlock.mjs +14 -8
  27. package/sandbox/confiners/seatbelt.mjs +18 -2
  28. package/scripts/loop-worker.mjs +18 -7
  29. package/scripts/migrate-v5.mjs +5 -61
  30. package/sessions.mjs +0 -0
  31. package/tui/editor.mjs +44 -0
  32. package/tui/modal_filter.mjs +59 -0
  33. package/tui/modal_picker.mjs +12 -37
  34. package/tui/pickers.mjs +917 -0
  35. package/tui/provider_families.mjs +41 -0
  36. package/tui/repl.mjs +67 -36
  37. package/tui/slash_commands.mjs +8 -7
  38. package/tui/slash_dispatcher.mjs +923 -118
  39. package/tui/splash.mjs +5 -12
  40. package/tui/subcommands.mjs +17 -0
  41. package/tui/terminal_approve.mjs +37 -0
  42. package/web/dashboard.css +275 -0
  43. package/web/dashboard.html +2 -1685
  44. package/web/dashboard.js +1406 -0
  45. package/workflow/persistent.mjs +13 -6
  46. package/mas/tools/skill_view.mjs +0 -43
@@ -39,3 +39,39 @@ export async function runHandoff({ threads, channels, threadId, target, external
39
39
 
40
40
  return next;
41
41
  }
42
+
43
+ // F6 — re-point a thread to `target`/`externalId` and (optionally) notify the
44
+ // target, rolling the binding BACK to its source if that notification throws.
45
+ // Unlike runHandoff, this takes a single `send(externalId, text)` notifier
46
+ // instead of a live channel map, so the daemon HTTP route can use it without a
47
+ // per-platform SDK. When `send` is omitted (the daemon has no live channel map
48
+ // yet) the migration is simply persisted and context follows on the next
49
+ // inbound to the target — there is nothing to roll back. Preserves sessionId.
50
+ export async function handoffWithRollback({ threads, threadId, target, externalId, note = '', send }) {
51
+ const cur = threads.findByThread(threadId);
52
+ if (!cur) {
53
+ const err = new Error(`THREAD_NOT_FOUND: ${threadId}`);
54
+ err.code = 'THREAD_NOT_FOUND';
55
+ throw err;
56
+ }
57
+ if (!target || !externalId) {
58
+ throw new Error('handoff requires target and externalId');
59
+ }
60
+ const prior = { channel: cur.channel, externalId: cur.externalId };
61
+ // Persist the migration first (same ordering as runHandoff).
62
+ const next = threads.handoff(threadId, { channel: target, externalId: String(externalId) });
63
+ if (typeof send === 'function') {
64
+ try {
65
+ const tail = note ? ` — ${note}` : '';
66
+ await send(String(externalId), `resumed from ${prior.channel} (session ${next.sessionId})${tail}`);
67
+ } catch (e) {
68
+ // Target never got the resume marker — roll the binding back so the
69
+ // session isn't stranded on a channel that can't be reached.
70
+ threads.handoff(threadId, prior);
71
+ const err = new Error(`HANDOFF_SEND_FAILED: ${e?.message || e}`);
72
+ err.code = 'HANDOFF_SEND_FAILED';
73
+ throw err;
74
+ }
75
+ }
76
+ return next;
77
+ }