@vibelord/lanes 1.8.0 → 1.9.3

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 (61) hide show
  1. package/package.json +1 -1
  2. package/payload/lanes/README.md +29 -11
  3. package/payload/lanes/VERSION +1 -1
  4. package/payload/lanes/bin/lanes +159 -59
  5. package/payload/lanes/bin-rs/BINARIES.json +2 -17
  6. package/payload/lanes/client/lanes-launch +51 -2
  7. package/payload/lanes/container/lane +142 -19
  8. package/payload/lanes/container/lane-mcp +168 -55
  9. package/payload/lanes/container/lane-peerd +6 -6
  10. package/payload/lanes/container/lane-signal +48 -3
  11. package/payload/lanes/container/lane_core.py +1040 -164
  12. package/payload/lanes/container/throttle-pulse +13 -4
  13. package/payload/lanes/docs/AGENTS-lanes.md +15 -7
  14. package/payload/lanes/docs/ARCHITECTURE.md +478 -101
  15. package/payload/lanes/docs/DESIGN.md +7 -2
  16. package/payload/lanes/docs/INSTALL.md +20 -3
  17. package/payload/lanes/docs/PLAN-1.9.1-SIDEBAR-CODEX.md +128 -0
  18. package/payload/lanes/docs/RUNBOOK.md +1428 -107
  19. package/payload/lanes/docs/USERGUIDE.md +488 -86
  20. package/payload/lanes/holders/tmux.sh +3 -3
  21. package/payload/lanes/install/services.py +68 -11
  22. package/payload/lanes/libexec/agent_state.py +2 -5
  23. package/payload/lanes/libexec/attach.py +11 -3
  24. package/payload/lanes/libexec/cursor_sync.py +22 -2
  25. package/payload/lanes/libexec/docsd.py +38 -4
  26. package/payload/lanes/libexec/lanes_lib.py +377 -39
  27. package/payload/lanes/libexec/mdlite.py +43 -3
  28. package/payload/lanes/libexec/notify.py +69 -26
  29. package/payload/lanes/libexec/registrations.py +5 -0
  30. package/payload/lanes/libexec/session_actions.py +114 -27
  31. package/payload/lanes/libexec/sidebar.py +246 -64
  32. package/payload/lanes/libexec/site_hooks.py +65 -0
  33. package/payload/lanes/libexec/statusd.py +139 -189
  34. package/payload/lanes/libexec/studio_host.py +8 -2
  35. package/payload/lanes/libexec/tokens.py +6 -2
  36. package/payload/lanes/libexec/update.py +13 -5
  37. package/payload/lanes/libexec/view.sh +39 -4
  38. package/payload/lanes/libexec/workspace_keys.py +54 -0
  39. package/payload/lanes/site/protocol.py +15 -5
  40. package/payload/lanes/site/relay.py +5 -2
  41. package/payload/lanes/site/server.py +29 -18
  42. package/payload/lanes/systemd/lanes-economy.service +3 -1
  43. package/payload/lanes/tokens/README.md +10 -0
  44. package/payload/lanes/tokens/generate.py +1 -1
  45. package/payload/lanes/web/Caddyfile +9 -2
  46. package/payload/lanes/web/README.md +2410 -95
  47. package/payload/lanes/web/browser.css +2 -0
  48. package/payload/lanes/web/browser.js +18 -6
  49. package/payload/lanes/web/directory.js +1 -1
  50. package/payload/lanes/web/docs.js +23 -0
  51. package/payload/lanes/web/links.js +157 -0
  52. package/payload/lanes/web/manifest.webmanifest +0 -2
  53. package/payload/lanes/web/mobile.css +30 -32
  54. package/payload/lanes/web/mobile.js +286 -227
  55. package/payload/lanes/web/upload.js +65 -22
  56. package/payload/lanes/web/workspace-keys.js +65 -0
  57. package/payload/lanes/zellij/config.kdl +1 -1
  58. package/payload/manifest.json +5 -22
  59. package/payload/lanes/bin-rs/THIRD-PARTY-NOTICES +0 -18953
  60. package/payload/lanes/bin-rs/x86_64-unknown-linux-musl/lanes-hook +0 -0
  61. package/payload/lanes/bin-rs/x86_64-unknown-linux-musl/lanes-terminal +0 -0
@@ -5,6 +5,9 @@
5
5
  # lanes-launch <device> --viewports N a wide view session: N (2-3) viewports side by side per workspace
6
6
  # lanes-launch <device> [--ascii] [--theme T] [--glyphs M] [--color C] [--notify 1|0] [--dim 90|2] [--device-only] look (lanes attach)
7
7
  # [--editor micro|hx|nvim|vim|auto] and the editor quick edit (Ctrl-Alt-e) starts (auto: none chosen)
8
+ # lanes-launch <device> --mosh, or LANES_TRANSPORT=mosh lanes-launch … a window (also `lane <id>`) through mosh
9
+ # instead of ssh: keys show at once on a slow path. Off unless asked for; it needs mosh
10
+ # here and mosh-server on the server, else the window says so in one line and uses ssh
8
11
  # lanes-launch lane <lane-id> attach straight to ONE lane, no multiplexer in between
9
12
  # lanes-launch ls list lanes with live status
10
13
  # lanes-launch here [device] show here the lane you opened last on another device of yours (`lanes here`; default:
@@ -29,6 +32,9 @@ primary=$host
29
32
  # Tried in this order after two immediate connect failures, each only when the ssh config defines it: lanes-ip (the
30
33
  # server's tailnet address, when `lanes` names it by its MagicDNS name), then lanes-public (the site's public path).
31
34
  fallbacks=${LANES_FALLBACK_HOST:-lanes-ip lanes-public}
35
+ # The window's transport as asked for (choose_transport decides it): '' ssh, as always; mosh by LANES_TRANSPORT=mosh or
36
+ # --mosh after the device; any other value of the variable is said and is ssh.
37
+ case "${LANES_TRANSPORT:-}" in ''|ssh) asked= ;; mosh) asked=mosh ;; *) asked=unknown ;; esac
32
38
  remote='$HOME/.local/bin/lanes'
33
39
  config=${XDG_CONFIG_HOME:-$HOME/.config}/lanes
34
40
  state=${XDG_STATE_HOME:-$HOME/.local/state}/lanes-client # logs and helper.alive; `install.sh --check` reads them
@@ -343,8 +349,11 @@ if [ "$mode" = attach ] && [ $# -gt 1 ]; then
343
349
  --glyphs) case "${2:-}" in unicode|ascii|emoji) extra="$extra --glyphs $2"; shift ;; *) echo '--glyphs takes unicode, ascii or emoji' >&2; exit 64 ;; esac ;;
344
350
  --color) case "${2:-}" in truecolor|256|16|none) extra="$extra --color $2"; shift ;; *) echo '--color takes truecolor, 256, 16 or none' >&2; exit 64 ;; esac ;;
345
351
  --notify) case "${2:-}" in 1|0) extra="$extra --notify $2"; shift ;; *) echo '--notify takes 1 or 0' >&2; exit 64 ;; esac ;;
352
+ --sidebar-order) case "${2:-}" in attention|coordinator|pinned) extra="$extra --sidebar-order $2"; shift ;; *) echo '--sidebar-order takes attention, coordinator or pinned' >&2; exit 64 ;; esac ;;
353
+ --workspace-keys) case "${2:-}" in on|off) extra="$extra --workspace-keys $2"; shift ;; *) echo '--workspace-keys takes on or off' >&2; exit 64 ;; esac ;;
346
354
  --dim) case "${2:-}" in 90|2) extra="$extra --dim $2"; shift ;; *) echo '--dim takes 90 or 2' >&2; exit 64 ;; esac ;;
347
355
  --device-only) extra="$extra --device-only" ;;
356
+ --mosh) asked=mosh ;; # this client's own: never spliced into the remote command line
348
357
  # Quick edit's editor (Ctrl-Alt-e, W9 E2): the server's own five values. A server older than `lanes edit`
349
358
  # takes it as an unknown flag and records nothing, which costs nothing there: it has no quick edit.
350
359
  --editor) case "${2:-}" in micro|hx|nvim|vim|auto) extra="$extra --editor $2"; shift ;; *) echo '--editor takes micro, hx, nvim, vim or auto' >&2; exit 64 ;; esac ;;
@@ -574,6 +583,38 @@ next_host() {
574
583
  done
575
584
  printf '%s' "$primary"
576
585
  }
586
+ # ---- transport: ssh, or mosh when asked for (Fleet's ask on Christian's word, 18 Nov 2026) --------------------------
587
+ # On a path of 185-350 ms per round trip an ssh window shows each key only after a whole round trip; mosh echoes it at
588
+ # once. Asked for only ($asked: LANES_TRANSPORT=mosh or --mosh), never by default: the tailnet must also carry mosh's
589
+ # UDP. Decided BEFORE a connection to a host it was not yet decided for, never during one: mosh on this machine, then
590
+ # one bounded question to the same host with the self-update's ssh options — whether its login shell finds
591
+ # mosh-server — else ssh. Said in one line on the screen and in the log, so nobody types into a transport that changed
592
+ # without a word. $transport: ssh or mosh, for $transport_host.
593
+ transport=ssh
594
+ transport_host=
595
+ choose_transport() {
596
+ transport=ssh transport_host=$host ct_why=
597
+ case "$asked" in
598
+ '') return 0 ;;
599
+ unknown) ct_why="LANES_TRANSPORT=$(printf '%s' "$LANES_TRANSPORT" | tr -cd 'A-Za-z0-9_.-') is not a transport: ssh or mosh" ;;
600
+ mosh)
601
+ if ! command -v mosh >/dev/null 2>&1; then
602
+ ct_why='mosh asked for: no mosh on this machine'
603
+ else
604
+ limit=10
605
+ run ssh -n -o RequestTTY=no -o BatchMode=yes -o ConnectTimeout=5 "$host" 'command -v mosh-server' >/dev/null 2>&1 || :
606
+ limit=
607
+ case "$rc" in
608
+ 0) transport=mosh ;;
609
+ 1|127) ct_why="mosh asked for: $host has no mosh-server" ;;
610
+ *) ct_why="mosh asked for: $host did not say whether it has mosh-server (exit $rc)" ;;
611
+ esac
612
+ fi ;;
613
+ esac
614
+ if [ "$transport" = mosh ]; then ct_line="transport mosh to $host"; else ct_line="transport ssh to $host ($ct_why)"; fi
615
+ printf '\033[2mlanes: %s\033[0m\r\n' "$ct_line"
616
+ log "$ct_line"
617
+ }
577
618
  # ---- upload helper: serves the sidebar's upload box ------------------------------------------------------------
578
619
  # A drop on the terminal only gives the SERVER a local path string; the file lives here. This helper waits for
579
620
  # such requests and uploads the files with lanes-upload. It is the security boundary: it reads ONLY from folders
@@ -727,13 +768,21 @@ while :; do
727
768
  printf '\033]0;lanes · %s\007' "$target"
728
769
  # Said before ssh draws anything: a server under pressure needs many seconds for banner and key exchange, and a
729
770
  # window that stays blank meanwhile reads as dead. It names this client's release (client_version's charset).
771
+ [ "$transport_host" = "$host" ] || choose_transport
730
772
  printf '\033[2mlanes%s: connecting to %s…\033[0m\r\n' "${release:+ $release}" "$host"
731
773
  log "connecting: $mode $target via $host"
732
774
  started=$(date +%s)
733
775
  if [ "$mode" = attach ]; then
734
- run ssh "$host" "$remote attach $target --client $client --default-device $(default_device)$version $extra" || :
776
+ command_line="$remote attach $target --client $client --default-device $(default_device)$version $extra"
777
+ else
778
+ command_line="$remote open $target"
779
+ fi
780
+ if [ "$transport" = mosh ]; then
781
+ # mosh-server runs its command without a shell: sh -c gives the command line the shell ssh's would have had
782
+ # (it starts with $HOME). Only the host the ssh path uses, no other option and nothing secret.
783
+ run mosh --ssh="ssh -o RequestTTY=no" "$host" -- sh -c "$command_line" || :
735
784
  else
736
- run ssh "$host" "$remote open $target" || :
785
+ run ssh "$host" "$command_line" || :
737
786
  fi
738
787
  lasted=$(( $(date +%s) - started ))
739
788
  log "ended: exit $rc after ${lasted}s via $host"
@@ -35,17 +35,33 @@ a `holder: tmux` lane through its exact socket and session; any other id is a zm
35
35
  lane message <address> [--ttl S] [--queue] <text...>
36
36
  one message from the lane this runs in to a lane of this container (W15 L4, BEY-6842,
37
37
  lane_core.message, what lanes_message does): prints the answer as JSON — `delivered_by`
38
- codex_queue, throttle_turn, typed or (with --queue) queued, with `expected_within_s`, or
38
+ codex_queue, throttle_turn or (with --queue) queued, with `expected_within_s`, or
39
39
  unknown (an adapter whose answer was lost: held, never sent again by Lanes);
40
- from a Claude agent to a Claude session: refused use_send_message (its own SendMessage)
40
+ from a Claude agent to a Claude session: refused use_send_message (its own SendMessage);
41
+ never typed into a terminal (BEY-7538): a lane only its keyboard reaches is refused
42
+ transport_never_types without --queue
41
43
  lane inbox [--json] this lane's inbox (~/.lz/state/inbox/<lane>/): each message's id, sender, time, how it
42
44
  was delivered and its text until acknowledged (every message not yet settled, and the
43
- newest 512 settled ones)
44
- lane inbox ack <id> this lane has the message: its text leaves the inbox, its receipt stays
45
+ newest 512 settled ones); one an adapter already handed to this lane's agent is listed
46
+ as history without its words (BEY-8673; --json keeps them and adds each row's state)
47
+ lane inbox ack <id> this lane takes the message: its text is printed (`text`) on this one call and leaves
48
+ the inbox, its receipt stays; a second ack prints no text (BEY-8673 D)
45
49
  lane inbox retry <id> --duplicate-risk [--lane <id>]
46
50
  a person hands a held message (receipt unknown) of this lane's inbox, or of --lane's,
47
- back to the inbox (queued: lanes-statusd types it when the lane is next idle); it may
51
+ back to the inbox (queued: it waits there for the lane's agent to read it); it may
48
52
  have arrived already, so it may arrive twice — --duplicate-risk says you accept that
53
+ lane outbox [--json] this lane's outbox (~/.lz/state/outbox/<lane>/, DM-LANES-OUTBOX): what it sent to a lane
54
+ of another container (lane message @fleet, @<board> of another container: delivered_by
55
+ outbox) and what the site's bridge made of it (bridged, expired)
56
+ lane outbox pending --json the bridge's listing: every message waiting in any lane's outbox here (expired ones are
57
+ settled first)
58
+ lane outbox settle <lane> <id> --bridged <container>:<id> | --failed <why>
59
+ the bridge's word on one outbox message: it is in the recipient's inbox on that
60
+ container (the text leaves the outbox), or the attempt failed (it waits for the next pass)
61
+ lane inbox deliver --from-container <name>
62
+ the bridge's write here: one DM-LANES-MESSAGE record (JSON on stdin) from a lane of
63
+ container <name> into the inbox of the lane its `to` names here (queued; idempotent on
64
+ the origin's container and id); prints the answer as JSON
49
65
  lane mcp install [--agent claude|codex|kimi|grok|grok-cli|muse|zcode|all] [--write]
50
66
  add the Lanes MCP server (~/.lz/bin/lane-mcp) to ~/.claude.json (mcpServers.lanes) and
51
67
  ~/.codex/config.toml ([mcp_servers.lanes], with env_vars passing LANE_ID, LANE_WS, TMUX
@@ -335,15 +351,25 @@ def cmd_send(args):
335
351
  held = tmux_lane('send', name)
336
352
  if held:
337
353
  _, socket, session = held
338
- try: # W15 part 2: the lane's one native-input authority, held across the text and its Enter
354
+ try: # W15 part 2: the lane's one native-input authority, held across the pane's look-up, the text, its
355
+ # Enter and the check of the agent's screen (BEY-8655: into the agent's pane, and an Enter it did not take
356
+ # is pressed once more only while its composer still holds the text)
339
357
  with C.dispatch_lock(ROOT, name):
340
- results = C.send_keys(socket, session, text, enter, run=tmux_run)
358
+ expect, pid = C.observed_agent(ROOT, name, PROC)
359
+ found = C.agent_pane(socket, session, PROC, run=tmux_run, agent_pid=pid, expect_agent=expect)
360
+ results, verdict = C.send_checked(socket, found['pane'], text, enter, found['harness'], run=tmux_run)
341
361
  except C.DispatchBusy as error:
342
362
  sys.exit(f'lane send: {error} — nothing was typed')
363
+ except C.LaneError as error: # tmux's own status when it did not list the panes (124: no answer), else 1
364
+ sys.stderr.write(f'lane send: {error} ({error.code}) — nothing was typed\n')
365
+ sys.exit(getattr(error, 'rc', None) or 1)
343
366
  sys.stderr.write(''.join(result.stderr for result in results))
344
- if len(results) == 2 and results[1].returncode:
345
- sys.stderr.write('lane send: the text was typed; Enter was not pressed\n')
346
- sys.exit(results[-1].returncode)
367
+ if verdict is None:
368
+ if len(results) == 2 and results[1].returncode:
369
+ sys.stderr.write('lane send: the text was typed; Enter was not pressed\n')
370
+ sys.exit(results[-1].returncode)
371
+ sys.stderr.write(f'lane send: {C.verdict_sentence(verdict)} ({verdict}, pane {found["pane"]})\n')
372
+ sys.exit(1 if verdict == 'not_submitted' else 0)
347
373
  result = zmx('send', zmx_name('send', name), text) # zmx: the bytes as given, never an Enter of its own
348
374
  sys.stderr.write(result.stderr)
349
375
  sys.exit(result.returncode)
@@ -703,7 +729,10 @@ def cmd_address(args):
703
729
 
704
730
 
705
731
  MESSAGE_USAGE = 'usage: lane message <address> [--ttl S] [--queue] <text...>'
706
- INBOX_USAGE = 'usage: lane inbox [--json] | lane inbox ack <id> | lane inbox retry <id> --duplicate-risk [--lane <id>]'
732
+ INBOX_USAGE = ('usage: lane inbox [--json] | lane inbox ack <id> | lane inbox retry <id> --duplicate-risk [--lane <id>] | '
733
+ 'lane inbox deliver --from-container <name> < record.json')
734
+ OUTBOX_USAGE = ('usage: lane outbox [--json] | lane outbox pending --json | '
735
+ 'lane outbox settle <lane> <id> --bridged <container>:<id> | lane outbox settle <lane> <id> --failed <why>')
707
736
 
708
737
 
709
738
  def own_lane(verb):
@@ -754,9 +783,26 @@ def cmd_message(args):
754
783
 
755
784
  def cmd_inbox(args):
756
785
  """`lane inbox [--json]` lists this lane's inbox (oldest first: id, sender, time, delivered_by, the text until it
757
- is acknowledged); `lane inbox ack <id>` acknowledges one (lane_core.message_ack); `lane inbox retry <id>
758
- --duplicate-risk [--lane <id>]` hands a held (`unknown`) message back to its inbox (lane_core.message_retry)."""
786
+ is acknowledged — except a message an adapter already handed to the agent (lane_core.inbox_state `delivered`),
787
+ whose line says how and that it is history, never its words (BEY-8673); `--json` keeps every text and adds `state`,
788
+ and `thread` for `codex_queue`); `lane inbox ack <id>` takes one (lane_core.message_ack), printing its text on the
789
+ call that removes it and never again (BEY-8673 D: the Codex adapter's pointer names this verb first); `lane inbox
790
+ retry <id> --duplicate-risk [--lane <id>]` hands a held (`unknown`) message back to its inbox
791
+ (lane_core.message_retry)."""
759
792
  lane = None
793
+ if args[:1] == ['deliver']: # DM-LANES-OUTBOX: the bridge's write into a lane of this container
794
+ if args[1:2] != ['--from-container'] or len(args) != 3:
795
+ sys.exit(INBOX_USAGE)
796
+ try:
797
+ record = json.loads(sys.stdin.read(C.INBOX_FILE_MAX + 1))
798
+ except ValueError:
799
+ sys.exit('lane inbox deliver: stdin holds no JSON record (invalid_arguments)')
800
+ try:
801
+ out = C.bridge_deliver(ROOT, record, args[2])
802
+ except C.LaneError as error:
803
+ sys.exit(f'lane inbox deliver: {error} ({error.code})')
804
+ print(json.dumps(out, ensure_ascii=False, indent=1))
805
+ return
760
806
  if args[:1] == ['retry']:
761
807
  rest, risk, lane = list(args[1:]), False, None
762
808
  while '--duplicate-risk' in rest:
@@ -787,25 +833,102 @@ def cmd_inbox(args):
787
833
  if args not in ([], ['--json']):
788
834
  sys.exit(INBOX_USAGE)
789
835
  lane = own_lane('inbox')
790
- rows = []
836
+ rows, now = [], time.time()
791
837
  for entry in C.inbox_entries(ROOT, lane):
792
838
  record, receipt = entry.get('record') or {}, entry.get('receipt') or {}
793
839
  rows.append({'id': entry['id'], 'from': record.get('from'), 'at': record.get('at'),
794
840
  'delivered_by': receipt.get('delivered_by'), 'acked': record.get('acked'),
795
- 'text': record.get('text')})
841
+ 'text': record.get('text'),
842
+ **({'origin': record['origin']} if isinstance(record.get('origin'), dict) else {}),
843
+ 'state': C.inbox_state(entry, now)})
844
+ thread = ((record.get('attempt') or {}).get('recipient') or {}).get('thread')
845
+ if receipt.get('delivered_by') == 'codex_queue' and isinstance(thread, str):
846
+ rows[-1]['thread'] = thread
796
847
  if args:
797
848
  print(json.dumps({'lane': lane, 'messages': rows}, ensure_ascii=False, indent=1))
798
849
  return
799
850
  if not rows:
800
851
  print(f'{lane}: no messages')
801
852
  for row in rows:
802
- said = row['text'] if row['text'] is not None else ('(acknowledged)' if row['acked'] else '(no text)')
803
- print(f"{row['id']} {row['at'] or '-'} @{row['from'] or '-'} {row['delivered_by'] or 'on its way'} {said}")
853
+ if row['state'] == 'delivered': # BEY-8673: history, never an order to carry out again
854
+ said = f'(delivered: {delivered_how(row)}. History, not a new order; its words: lane inbox --json)'
855
+ else:
856
+ said = row['text'] if row['text'] is not None else ('(acknowledged)' if row['acked'] else '(no text)')
857
+ origin = row.get('origin') or {}
858
+ came = f" (bridged from {origin.get('container')})" if origin.get('kind') == 'bridge' else ''
859
+ print(f"{row['id']} {row['at'] or '-'} @{row['from'] or '-'}{came} {row['delivered_by'] or 'on its way'} {said}")
860
+
861
+
862
+ def delivered_how(row):
863
+ """How a delivered message (lane_core.inbox_state `delivered`) reached this lane's agent, for `lane inbox`."""
864
+ return {'codex_queue': f"handed to codex queue for thread {row.get('thread') or '(not recorded)'}, which serves it "
865
+ 'at its next turn',
866
+ 'peer_socket': 'written into your Claude session mid-turn',
867
+ 'throttle_turn': 'handed to Throttle for your next model request',
868
+ 'typed': 'typed into your lane'}.get(row['delivered_by'], row['delivered_by'])
869
+
870
+
871
+ def cmd_outbox(args):
872
+ """`lane outbox [--json]` lists this lane's outbox (DM-LANES-OUTBOX: what it sent to lanes of other containers);
873
+ `lane outbox pending --json` is the bridge's listing of every waiting message here (lane_core.outbox_pending);
874
+ `lane outbox settle <lane> <id> --bridged <container>:<id> | --failed <why>` its word on one (lane_core.outbox_settle)."""
875
+ if args[:1] == ['pending']:
876
+ if args != ['pending', '--json']:
877
+ sys.exit(OUTBOX_USAGE)
878
+ rows = [{'lane': item['lane'], 'id': item['id'], 'record': item['record']} for item in C.outbox_pending(ROOT)]
879
+ print(json.dumps({'pending': rows}, ensure_ascii=False, indent=1))
880
+ return
881
+ if args[:1] == ['settle']:
882
+ if len(args) != 5 or args[3] not in ('--bridged', '--failed'):
883
+ sys.exit(OUTBOX_USAGE)
884
+ lane, message_id, word, value = lane_id(args[1]), args[2], args[3], args[4]
885
+ bridged = failed = None
886
+ if word == '--bridged':
887
+ container, _, remote_id = value.partition(':')
888
+ bridged = {'container': container, 'id': remote_id}
889
+ else:
890
+ failed = value
891
+ try:
892
+ out = C.outbox_settle(ROOT, lane, message_id, bridged=bridged, failed=failed)
893
+ except C.LaneError as error:
894
+ sys.exit(f'lane outbox settle: {error} ({error.code})')
895
+ print(json.dumps(out, ensure_ascii=False, indent=1))
896
+ return
897
+ if args not in ([], ['--json']):
898
+ sys.exit(OUTBOX_USAGE)
899
+ lane = own_lane('outbox')
900
+ rows = []
901
+ for entry in C.outbox_entries(ROOT, lane):
902
+ record, receipt = entry.get('record') or {}, entry.get('receipt') or {}
903
+ rows.append({'id': entry['id'], 'to': record.get('to'), 'at': record.get('at'),
904
+ 'delivered_by': receipt.get('delivered_by'), 'bridged': record.get('bridged'),
905
+ 'text': record.get('text')})
906
+ if args:
907
+ print(json.dumps({'lane': lane, 'messages': rows}, ensure_ascii=False, indent=1))
908
+ return
909
+ if not rows:
910
+ print(f'{lane}: no messages in its outbox')
911
+ for row in rows:
912
+ said = row['text'] if row['text'] is not None else (
913
+ f"(bridged: message {row['bridged']['id']} on {row['bridged']['container']})" if row['bridged'] else '(no text)')
914
+ print(f"{row['id']} {row['at'] or '-'} @{row['to'] or '-'} {row['delivered_by'] or 'on its way'} {said}")
915
+
916
+
917
+ def cmd_codex_shadow(args):
918
+ if args and (len(args) != 2 or args[0] != '--probe' or not Path(args[1]).is_absolute()):
919
+ sys.exit('usage: lane codex-status-shadow [--probe /path/to/lanes-codex-shadow]')
920
+ probe = Path(args[1]) if args else ROOT / 'bin' / 'lanes-codex-shadow'
921
+ try:
922
+ facts = C.codex_shadow_facts(ROOT, PROC, time.time())
923
+ completed = subprocess.run([str(probe)], input=json.dumps(facts), text=True, timeout=5)
924
+ except (C.LaneError, OSError, subprocess.TimeoutExpired) as error:
925
+ sys.exit(f'lane: shadow comparison unavailable: {error}')
926
+ sys.exit(completed.returncode)
804
927
 
805
928
 
806
- COMMANDS = {'new': cmd_new, 'open': cmd_open, 'attach': cmd_attach, 'send': cmd_send, 'capture': cmd_capture, 'ls': cmd_ls,
929
+ COMMANDS = {'codex-status-shadow': cmd_codex_shadow, 'new': cmd_new, 'open': cmd_open, 'attach': cmd_attach, 'send': cmd_send, 'capture': cmd_capture, 'ls': cmd_ls,
807
930
  'status': cmd_status, 'kill': cmd_kill, 'gc': cmd_gc, 'mcp': cmd_mcp, 'publish': cmd_publish,
808
- 'address': cmd_address, 'message': cmd_message, 'inbox': cmd_inbox}
931
+ 'address': cmd_address, 'message': cmd_message, 'inbox': cmd_inbox, 'outbox': cmd_outbox}
809
932
 
810
933
  if __name__ == '__main__':
811
934
  if len(sys.argv) < 2 or sys.argv[1] not in COMMANDS: