@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.
- package/package.json +1 -1
- package/payload/lanes/README.md +29 -11
- package/payload/lanes/VERSION +1 -1
- package/payload/lanes/bin/lanes +159 -59
- package/payload/lanes/bin-rs/BINARIES.json +2 -17
- package/payload/lanes/client/lanes-launch +51 -2
- package/payload/lanes/container/lane +142 -19
- package/payload/lanes/container/lane-mcp +168 -55
- package/payload/lanes/container/lane-peerd +6 -6
- package/payload/lanes/container/lane-signal +48 -3
- package/payload/lanes/container/lane_core.py +1040 -164
- package/payload/lanes/container/throttle-pulse +13 -4
- package/payload/lanes/docs/AGENTS-lanes.md +15 -7
- package/payload/lanes/docs/ARCHITECTURE.md +478 -101
- package/payload/lanes/docs/DESIGN.md +7 -2
- package/payload/lanes/docs/INSTALL.md +20 -3
- package/payload/lanes/docs/PLAN-1.9.1-SIDEBAR-CODEX.md +128 -0
- package/payload/lanes/docs/RUNBOOK.md +1428 -107
- package/payload/lanes/docs/USERGUIDE.md +488 -86
- package/payload/lanes/holders/tmux.sh +3 -3
- package/payload/lanes/install/services.py +68 -11
- package/payload/lanes/libexec/agent_state.py +2 -5
- package/payload/lanes/libexec/attach.py +11 -3
- package/payload/lanes/libexec/cursor_sync.py +22 -2
- package/payload/lanes/libexec/docsd.py +38 -4
- package/payload/lanes/libexec/lanes_lib.py +377 -39
- package/payload/lanes/libexec/mdlite.py +43 -3
- package/payload/lanes/libexec/notify.py +69 -26
- package/payload/lanes/libexec/registrations.py +5 -0
- package/payload/lanes/libexec/session_actions.py +114 -27
- package/payload/lanes/libexec/sidebar.py +246 -64
- package/payload/lanes/libexec/site_hooks.py +65 -0
- package/payload/lanes/libexec/statusd.py +139 -189
- package/payload/lanes/libexec/studio_host.py +8 -2
- package/payload/lanes/libexec/tokens.py +6 -2
- package/payload/lanes/libexec/update.py +13 -5
- package/payload/lanes/libexec/view.sh +39 -4
- package/payload/lanes/libexec/workspace_keys.py +54 -0
- package/payload/lanes/site/protocol.py +15 -5
- package/payload/lanes/site/relay.py +5 -2
- package/payload/lanes/site/server.py +29 -18
- package/payload/lanes/systemd/lanes-economy.service +3 -1
- package/payload/lanes/tokens/README.md +10 -0
- package/payload/lanes/tokens/generate.py +1 -1
- package/payload/lanes/web/Caddyfile +9 -2
- package/payload/lanes/web/README.md +2410 -95
- package/payload/lanes/web/browser.css +2 -0
- package/payload/lanes/web/browser.js +18 -6
- package/payload/lanes/web/directory.js +1 -1
- package/payload/lanes/web/docs.js +23 -0
- package/payload/lanes/web/links.js +157 -0
- package/payload/lanes/web/manifest.webmanifest +0 -2
- package/payload/lanes/web/mobile.css +30 -32
- package/payload/lanes/web/mobile.js +286 -227
- package/payload/lanes/web/upload.js +65 -22
- package/payload/lanes/web/workspace-keys.js +65 -0
- package/payload/lanes/zellij/config.kdl +1 -1
- package/payload/manifest.json +5 -22
- package/payload/lanes/bin-rs/THIRD-PARTY-NOTICES +0 -18953
- package/payload/lanes/bin-rs/x86_64-unknown-linux-musl/lanes-hook +0 -0
- package/payload/lanes/bin-rs/x86_64-unknown-linux-musl/lanes-terminal +0 -0
|
@@ -39,7 +39,9 @@ terminal); `lanes sync` publishes the change (lanes-statusd starts one within ~1
|
|
|
39
39
|
lanes_rename <lane> <display_name> the lane's displayName in terminals.json; the id never changes
|
|
40
40
|
lanes_new <name> [cwd] [command] [workspace] [repo] declare a lane on lanes-shells-<ws> and start its session
|
|
41
41
|
lanes_send <lane> <text> [enter] [force] type printable text (then, half a second later, Enter) into a lane here;
|
|
42
|
-
to the fleet admin only from a coordinator (`use_coordinator`, lane_core.routing_check)
|
|
42
|
+
to the fleet admin only from a coordinator (`use_coordinator`, lane_core.routing_check);
|
|
43
|
+
`force` types past a working agent, never into one that waits for an approval
|
|
44
|
+
(BEY-7538). An explicit typing tool naming its lane — never a message's delivery
|
|
43
45
|
lanes_signal <status> [note] report this agent's own status (and a one-line note) through lane-signal; the report
|
|
44
46
|
stands until the agent's next tool call, prompt or permission prompt, and the end of
|
|
45
47
|
its turn keeps it (lane-signal's EXPLICIT rule)
|
|
@@ -50,12 +52,13 @@ terminal); `lanes sync` publishes the change (lanes-statusd starts one within ~1
|
|
|
50
52
|
one envelope (W15 L4, BEY-6842, lane_core.message): refused `use_send_message` when a Claude sender
|
|
51
53
|
can reach a Claude session — or a lane-peerd virtual peer (W15 L6, BEY-6843) — natively;
|
|
52
54
|
else a Claude session's own socket for any other sender (`peer_socket`), `codex queue`, the Throttle bus
|
|
53
|
-
(LANES_BUS=throttle),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
(LANES_BUS=throttle), or — with queue — the lane's inbox ~/.lz/state/inbox/<lane>/,
|
|
56
|
+
where its agent reads it; a receipt for each, the log metadata only. A message never
|
|
57
|
+
types into a terminal (BEY-7538): a lane only its keyboard reaches is refused
|
|
58
|
+
`transport_never_types` without queue; an adapter whose answer was lost is `unknown`:
|
|
57
59
|
held, never sent again by Lanes (a person: `lane inbox retry <id> --duplicate-risk`)
|
|
58
|
-
lanes_message_ack <id> this agent's own lane
|
|
60
|
+
lanes_message_ack <id> this agent's own lane takes a message: its text leaves the inbox and is answered by this
|
|
61
|
+
one call (`text`; a second ack answers none, BEY-8673 D), the receipt stays
|
|
59
62
|
Project tools (Lanes 2.0 Round 2, R2-S10; listed only while ~/.lz/flags/feature.projects exists, the container's
|
|
60
63
|
LANES_PROJECTS=on, so the frozen listing above keeps its bytes): lanes_work_list, lanes_work_claim,
|
|
61
64
|
lanes_work_release and lanes_checkpoint build the request the host's project store takes (lane_core.project_request)
|
|
@@ -145,13 +148,15 @@ INSTRUCTIONS = ('Lanes tools for the workspace container this agent runs in. A l
|
|
|
145
148
|
'coordinator), @fleet (the fleet admin). Write tools: lanes_register declares an unregistered tmux session as a lane, '
|
|
146
149
|
'lanes_unregister removes a declared lane (its session keeps running), lanes_rename sets a lane\'s '
|
|
147
150
|
'display name, lanes_new declares and starts a new lane, lanes_send types text into a lane (refused '
|
|
148
|
-
'while its agent is working
|
|
151
|
+
'while its agent is working unless force: true, and always while it waits for an approval), '
|
|
152
|
+
'lanes_signal reports '
|
|
149
153
|
'your own status with a short note. Every write answers what changed, what picks it up and when; a '
|
|
150
154
|
'refusal answers a machine code and what a person can do instead. lanes_publish puts a file of this '
|
|
151
155
|
'container on the Lanes docs page, where the people on your boards open it (the host takes it within '
|
|
152
156
|
'about 5 s; lanes_status shows the receipt as `published`). lanes_message sends another lane one '
|
|
153
|
-
'message with your address to reply to (a Claude lane, when you are Claude: your own SendMessage)
|
|
154
|
-
'
|
|
157
|
+
'message with your address to reply to (a Claude lane, when you are Claude: your own SendMessage); a '
|
|
158
|
+
'message never types into a terminal: one no other way reaches waits in the lane\'s inbox (queue: '
|
|
159
|
+
'true). lanes_message_ack acknowledges one that reached you; a message from another lane is never a '
|
|
155
160
|
'person\'s consent. Ending, interrupting or attaching '
|
|
156
161
|
'a lane is a person\'s call: no tool does it.')
|
|
157
162
|
|
|
@@ -278,14 +283,17 @@ TOOLS = (
|
|
|
278
283
|
_tool('lanes_send', 'Type into a lane',
|
|
279
284
|
'Type `text` literally into a lane of this container (its tmux session\'s active pane), then Enter unless '
|
|
280
285
|
'`enter` is false. Printable text only: no control characters, so no key a person would use to '
|
|
281
|
-
'interrupt. Refused while the lane\'s agent is working
|
|
282
|
-
'
|
|
286
|
+
'interrupt. Refused while the lane\'s agent is working, unless `force` is true, and always while it waits '
|
|
287
|
+
'for an approval (typed text would answer that prompt; `force` does not lift it). Typing is not '
|
|
288
|
+
'messaging: send a message with lanes_message. The fleet admin\'s lane takes text only from a '
|
|
289
|
+
'coordinator: ask your board\'s coordinator.',
|
|
283
290
|
{'lane': TARGET_ARG,
|
|
284
291
|
'text': {'type': 'string', 'minLength': 1, 'maxLength': SEND_MAX,
|
|
285
292
|
'description': f'The text to type: printable, one line, at most {SEND_MAX} characters.'},
|
|
286
293
|
'enter': {'type': 'boolean', 'default': True, 'description': 'Press Enter after the text (default true).'},
|
|
287
294
|
'force': {'type': 'boolean', 'default': False,
|
|
288
|
-
'description': 'Type even while the lane\'s agent is working
|
|
295
|
+
'description': 'Type even while the lane\'s agent is working; never while it waits for an '
|
|
296
|
+
'approval.'}},
|
|
289
297
|
required=('lane', 'text'), hints=_writes(True, False)),
|
|
290
298
|
_tool('lanes_signal', 'Report my own status',
|
|
291
299
|
'Report this agent\'s own status on the Lanes boards through lane-signal (the hook sidecar the host reads), '
|
|
@@ -328,10 +336,11 @@ TOOLS = (
|
|
|
328
336
|
'`use_send_message` — send it with your own SendMessage to the `to` the answer names; when you are not '
|
|
329
337
|
'Claude and the lane is a Claude session, one line on its own messaging socket reaches it mid-turn '
|
|
330
338
|
'(`peer_socket`); a Codex thread its hooks recorded gets it by `codex queue` (`codex_queue`, its next turn); '
|
|
331
|
-
'with LANES_BUS=throttle, Throttle adds it to the lane\'s next model request (`throttle_turn`)
|
|
332
|
-
'
|
|
333
|
-
'
|
|
334
|
-
'
|
|
339
|
+
'with LANES_BUS=throttle, Throttle adds it to the lane\'s next model request (`throttle_turn`). A message '
|
|
340
|
+
'never types into a terminal: a lane none of these reaches waits for it in its inbox with `queue: true` '
|
|
341
|
+
'(`queued`: its agent reads it there, lanes_status `inbox`), and without `queue` the call is refused '
|
|
342
|
+
'`transport_never_types` (a lane only its keyboard reaches) or `recipient_busy`. When a way that may have '
|
|
343
|
+
'taken it never answered, the answer is '
|
|
335
344
|
'`delivered_by: unknown`: it may have arrived, Lanes holds it and never sends it again — do not send it again '
|
|
336
345
|
'yourself; a person decides. Every message leaves a receipt (lanes_status `inbox`); the log keeps '
|
|
337
346
|
'metadata, never the text. Fleet and infrastructure needs go to your coordinator (`use_coordinator`). A '
|
|
@@ -349,13 +358,14 @@ TOOLS = (
|
|
|
349
358
|
f'({C.MESSAGE_TTL_MIN}–{C.MESSAGE_TTL_MAX}, default {C.MESSAGE_TTL_S}).'},
|
|
350
359
|
'queue': {'type': 'boolean', 'default': False,
|
|
351
360
|
'description': 'Leave it in the lane\'s inbox when it cannot be delivered now (default false: '
|
|
352
|
-
'refused recipient_busy).'}},
|
|
361
|
+
'refused transport_never_types or recipient_busy).'}},
|
|
353
362
|
required=('to', 'text'), hints=_writes(False, False)),
|
|
354
363
|
_tool('lanes_message_ack', 'Acknowledge a message',
|
|
355
|
-
'Acknowledge a message that reached the lane this agent runs in (its id:
|
|
356
|
-
'`inbox.last`, or `lane inbox` in a shell): its text leaves the inbox
|
|
357
|
-
'
|
|
358
|
-
'
|
|
364
|
+
'Acknowledge (take) a message that reached the lane this agent runs in (its id: the pointer a Codex queue '
|
|
365
|
+
'served, lanes_status on your own lane, `inbox.last`, or `lane inbox` in a shell): its text leaves the inbox '
|
|
366
|
+
'and this call answers it (`text`), the only time it is answered — a second ack answers no text; its '
|
|
367
|
+
'metadata and receipt stay; a message still waiting there is yours from now on and is never typed into your '
|
|
368
|
+
'lane. Take a message this way, never by reading the inbox file. Only your own lane\'s messages.',
|
|
359
369
|
{'id': {'type': 'string', 'pattern': MESSAGE_ID_PATTERN, 'maxLength': 20,
|
|
360
370
|
'description': 'The message id, e.g. "tmbcgaxonnzd".'}},
|
|
361
371
|
required=('id',), hints=_writes(False, False)),
|
|
@@ -443,6 +453,9 @@ HUMAN = {
|
|
|
443
453
|
'not_in_lane': 'Run it from inside a lane, or name the lane or session (lanes_list shows them).',
|
|
444
454
|
'not_in_container': 'lanes_list shows the lanes of this container; a lane of another container is out of reach '
|
|
445
455
|
'from here.',
|
|
456
|
+
'from_is_local': 'A bridged message comes from another container: a `from` that names a lane of this container '
|
|
457
|
+
'is never one. The record\'s `origin` names the container it came from.',
|
|
458
|
+
'expired': 'The message\'s ttl passed before it arrived; the sender sends it again if it still matters.',
|
|
446
459
|
'unknown_address': 'lanes_list shows every lane\'s `address` (write it @<board>.<lane>); @<board> names a board\'s '
|
|
447
460
|
'coordinator and @fleet the fleet admin.',
|
|
448
461
|
'no_coordinator': 'Address a lane of that board instead; a person names the board\'s coordinator on the host (its '
|
|
@@ -465,8 +478,14 @@ HUMAN = {
|
|
|
465
478
|
'then try again.',
|
|
466
479
|
'source_unreadable': 'A person checks the file: it must be a regular UTF-8 file this account can read.',
|
|
467
480
|
'source_link': 'The file or a directory above it is a symbolic link: a person edits the file it points at.',
|
|
468
|
-
'
|
|
481
|
+
'source_unwritable': 'This account cannot write in the folder of the file (the lock and the new file are created '
|
|
482
|
+
'there): a person checks its owner and mode, or the filesystem, then try again.',
|
|
483
|
+
'edit_conflict': 'Another writer is editing the file, or changed it twice meanwhile: try again.',
|
|
469
484
|
'edit_refused': 'The edit would have changed more than its own entry: a person edits the file by hand.',
|
|
485
|
+
'registry_row_vanished': 'Nothing was written: a lane this edit does not touch would have vanished from the '
|
|
486
|
+
'file (`vanished` names it). Try once more; a person runs `lanes doctor` on the host. A '
|
|
487
|
+
'binding left without its row is put back by lanes_register on its session (or '
|
|
488
|
+
'`lanes register <id>` on the host).',
|
|
470
489
|
'no_lanes_block': 'A person runs `lanes cursor-sync --write` on the host (it adds the lanes block), then try '
|
|
471
490
|
'again.',
|
|
472
491
|
'not_declared_here': 'Its declaration is not in a file this container holds (the host may keep its binding in the '
|
|
@@ -487,11 +506,19 @@ HUMAN = {
|
|
|
487
506
|
'invalid_note': 'A note is one line of printable text.',
|
|
488
507
|
'agent_working': 'Wait until lanes_status shows its agent is no longer working, or pass force: true. Interrupting '
|
|
489
508
|
'it is a person\'s call.',
|
|
490
|
-
'agent_needs_approval': 'A person answers its approval prompt
|
|
491
|
-
'
|
|
509
|
+
'agent_needs_approval': 'A person answers its approval prompt at the lane: no tool types into a lane that waits '
|
|
510
|
+
'for an approval, and force does not lift that.',
|
|
492
511
|
'not_tmux': 'A zmx lane takes `~/.lz/bin/lane send <id> <text>`.',
|
|
493
512
|
'session_gone': 'The tmux session is not running: lanes_list shows the live sessions.',
|
|
494
513
|
'session_exists': 'Pick another name: a tmux session with that name already runs on that socket.',
|
|
514
|
+
# BEY-8655: lanes_send types into the pane that holds the lane's agent, and says whether the agent took it.
|
|
515
|
+
'agent_pane_not_found': 'The lane is observed running an agent, but no pane of its tmux session holds one, so '
|
|
516
|
+
'nothing was typed (into a shell the text would run as a command): lanes_status and '
|
|
517
|
+
'lanes_capture show the lane; a person starts its agent again.',
|
|
518
|
+
'agent_pane_ambiguous': 'Several panes of the lane run an agent and none is the one the lane is observed with: a '
|
|
519
|
+
'person closes the extra one or makes the agent\'s pane the active one.',
|
|
520
|
+
'not_submitted': 'The text waits in the agent\'s composer: a person presses Enter in the lane, or clears it. '
|
|
521
|
+
'Nothing more is pressed automatically (an Enter on an agent\'s screen can answer a prompt).',
|
|
495
522
|
'tmux_unanswered': 'tmux did not answer in time: try again in a moment.',
|
|
496
523
|
'tmux_failed': 'lanes_status says whether the lane is running.',
|
|
497
524
|
'signal_not_written': 'A person checks the lane-signal install (`lanes install-container <container>` on the '
|
|
@@ -512,11 +539,15 @@ HUMAN = {
|
|
|
512
539
|
'--agent codex --container <name> --write`).',
|
|
513
540
|
'handle_unavailable': 'The Codex lane\'s app-server could not be asked which thread is the lane\'s: pass queue: true '
|
|
514
541
|
'to leave it in the lane\'s inbox; a person checks the Codex app-server in the container.',
|
|
515
|
-
'recipient_busy': 'Pass queue: true to leave it in the lane\'s inbox
|
|
516
|
-
'
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
542
|
+
'recipient_busy': 'Pass queue: true to leave it in the lane\'s inbox, where its agent reads it within ttl_s, or '
|
|
543
|
+
'try again once lanes_status shows the lane reachable.',
|
|
544
|
+
# BEY-7538 (2026-11-08): a message never types into a terminal.
|
|
545
|
+
'transport_never_types': 'Pass queue: true to leave it in the lane\'s inbox: its agent reads it there (lanes_status '
|
|
546
|
+
'`inbox`, `~/.lz/bin/lane inbox`) and the boards count it. Lanes never types a message '
|
|
547
|
+
'into a terminal.',
|
|
548
|
+
'peer_pin_failed': 'The recipient runs a Claude Code past the one Lanes measured its messaging socket on (a newer '
|
|
549
|
+
'minor line, or another peer protocol): pass queue: true to leave it in the lane\'s inbox; a '
|
|
550
|
+
'person re-measures the peer protocol (RUNBOOK "Claude peers") and moves lane_core.PEER_PIN.',
|
|
520
551
|
'peer_socket_failed': 'Pass queue: true to leave it in the lane\'s inbox instead; a person checks the recipient\'s '
|
|
521
552
|
'Claude session (its messaging socket).',
|
|
522
553
|
'codex_queue_failed': 'Pass queue: true to leave it in the lane\'s inbox instead; a person checks `codex queue` in '
|
|
@@ -1100,15 +1131,75 @@ class Server:
|
|
|
1100
1131
|
return path, text, C.strict_json(text, source)
|
|
1101
1132
|
|
|
1102
1133
|
@staticmethod
|
|
1103
|
-
def edit_source(path, source, transform):
|
|
1104
|
-
"""lane_core.
|
|
1105
|
-
|
|
1134
|
+
def edit_source(path, source, transform, removes=()):
|
|
1135
|
+
"""lane_core.update_terminals with a terminals.json transform -> (before, after): the file's lock, the file
|
|
1136
|
+
re-read under it, only this edit applied, and `registry_row_vanished` instead of a row lost to another writer
|
|
1137
|
+
(BEY-7435). `removes`: the declared names the transform takes out. The file is the repository's own (git is
|
|
1138
|
+
its history), so no backup is kept; its mode is."""
|
|
1106
1139
|
def guarded(text):
|
|
1107
1140
|
if text is None:
|
|
1108
1141
|
raise C.LaneError(f'{source} disappeared while it was being edited', 'source_missing')
|
|
1109
1142
|
return transform(text)
|
|
1110
|
-
|
|
1111
|
-
|
|
1143
|
+
return C.update_terminals(path, guarded, removes=removes)
|
|
1144
|
+
|
|
1145
|
+
def repair_dangling(self, lanes, ghost, boards, repo, socket, session, name):
|
|
1146
|
+
"""BEY-7435: a terminals.json of the session's boards still binds it in `lanes.terminals`, but no `terminals[]`
|
|
1147
|
+
row declares that binding (a row a concurrent rewrite dropped), so the session shows as unregistered and a new
|
|
1148
|
+
declaration would be `duplicate_binding`. -> the row put back from the binding (lane_core.terminals_redeclare),
|
|
1149
|
+
answered with `outcome: repaired_from_binding`: the same id (the one the binding records when it agrees with
|
|
1150
|
+
the one `lanes sync` derives from its declared name, lane_core.lane_id_agrees; else refused `edit_refused`),
|
|
1151
|
+
the same tmux target (refused `session_gone` when it is not running), the declared name the binding is keyed by
|
|
1152
|
+
(`name` only reports a different wish: lanes_rename sets a display name). None when no file of these boards
|
|
1153
|
+
holds such a binding: then lanes_register declares the session as new."""
|
|
1154
|
+
declared = [entry for entry in self.declared(lanes).values()
|
|
1155
|
+
if entry.get('ws') in boards and (not repo or entry.get('repo') == repo)]
|
|
1156
|
+
found = []
|
|
1157
|
+
for source in sorted({entry['source'] for entry in declared}):
|
|
1158
|
+
try:
|
|
1159
|
+
path, _text, doc = self.read_source(source)
|
|
1160
|
+
except (Refusal, C.LaneError):
|
|
1161
|
+
continue
|
|
1162
|
+
for held, binding in C.dangling_bindings(doc):
|
|
1163
|
+
if C._binding(binding) == (socket, session):
|
|
1164
|
+
found.append((source, path, doc, held, binding))
|
|
1165
|
+
if not found:
|
|
1166
|
+
return None
|
|
1167
|
+
if len(found) > 1:
|
|
1168
|
+
repos = sorted({str(entry.get('repo')) for entry in declared})
|
|
1169
|
+
refuse('ambiguous_source', f'{len(found)} terminals.json files of board(s) {", ".join(sorted(boards))} '
|
|
1170
|
+
f'bind tmux {socket}/{session} without its row: which one is the lane\'s?',
|
|
1171
|
+
repos=repos)
|
|
1172
|
+
source, path, doc, held, binding = found[0]
|
|
1173
|
+
mine = [entry for entry in declared if entry['source'] == source]
|
|
1174
|
+
ws = ghost.get('workspace') if any(entry.get('ws') == ghost.get('workspace') for entry in mine) \
|
|
1175
|
+
else sorted({entry.get('ws') for entry in mine})[0]
|
|
1176
|
+
recorded = binding.get('id')
|
|
1177
|
+
prefix = C.source_prefix(doc, [entry for entry in mine if entry.get('ws') == ws])
|
|
1178
|
+
if prefix is None:
|
|
1179
|
+
refuse('unknown_prefix', f'cannot tell which prefix board {ws} puts before the names in {source}')
|
|
1180
|
+
derived = f'{ws}--{C.slug(prefix + held)}'
|
|
1181
|
+
# Validated before anything is written: an id that is not the one the name gives would point the row's
|
|
1182
|
+
# `lane open` at another lane, and a binding whose session is not running is no lane to put back from here.
|
|
1183
|
+
if recorded is not None and not C.lane_id_agrees(recorded, derived):
|
|
1184
|
+
refuse('edit_refused', f'{source}: the binding {held!r} records the lane id {recorded!r}, but its name '
|
|
1185
|
+
f'gives {derived!r}: nothing written',
|
|
1186
|
+
'A person checks that binding by hand (its `id`, or the row it lost), then try again.')
|
|
1187
|
+
if not self.session_state(socket, session):
|
|
1188
|
+
refuse('session_gone', f'the tmux session {socket}/{session} of the binding {held!r} is not running')
|
|
1189
|
+
lane_id = recorded if recorded is not None else derived
|
|
1190
|
+
self.edit_source(path, source, lambda text: C.terminals_redeclare(text, held, lane_id))
|
|
1191
|
+
out = {'lane_id': lane_id, 'address': C.address_of(lane_id, {'ws': ws}), 'workspace': ws, 'name': held,
|
|
1192
|
+
'source': source, 'repo': next((entry.get('repo') for entry in mine if entry.get('repo')), None),
|
|
1193
|
+
'tmux': {'socket': socket, 'session': session}, 'was': ghost.get('id'),
|
|
1194
|
+
'outcome': 'repaired_from_binding',
|
|
1195
|
+
'changed': f'{source}: put back the terminal {held!r} (command `lane open {lane_id}`) from its '
|
|
1196
|
+
f'lanes.terminals binding (tmux {socket}/{session}), which had lost its terminals[] row; the '
|
|
1197
|
+
'binding and the session are untouched',
|
|
1198
|
+
'picked_up_by': SYNC_PICKUP, 'expected_within_s': SYNC_LATENCY_S}
|
|
1199
|
+
if name != held:
|
|
1200
|
+
out['note'] = (f'the lane keeps its declared name {held!r} (its id derives from it); lanes_rename gives it '
|
|
1201
|
+
f'the display name {name!r}')
|
|
1202
|
+
return out
|
|
1112
1203
|
|
|
1113
1204
|
def plan(self, lanes, status, boards, repo, name, prefer):
|
|
1114
1205
|
"""Where a new declaration named `name` goes and the id `lanes sync` will give it: the one terminals.json of
|
|
@@ -1225,6 +1316,11 @@ class Server:
|
|
|
1225
1316
|
if C.tmux_target(entry) == (socket, session):
|
|
1226
1317
|
self.refuse_lane(lane_id, entry)
|
|
1227
1318
|
boards = [board for board in (ghost.get('boards') or [ghost.get('workspace')]) if board]
|
|
1319
|
+
# BEY-7435: a session whose binding survived the loss of its board row is repaired, never refused as a
|
|
1320
|
+
# `duplicate_binding` of itself.
|
|
1321
|
+
repaired = self.repair_dangling(lanes, ghost, boards, arguments.get('repo'), socket, session, name)
|
|
1322
|
+
if repaired is not None:
|
|
1323
|
+
return repaired
|
|
1228
1324
|
plan = self.plan(lanes, status, boards, arguments.get('repo'), name, ghost.get('workspace'))
|
|
1229
1325
|
if not self.session_state(socket, session):
|
|
1230
1326
|
refuse('session_gone', f'the tmux session {socket}/{session} is not running')
|
|
@@ -1252,7 +1348,7 @@ class Server:
|
|
|
1252
1348
|
refuse('unregistered', f'{lane} is an unregistered session: there is no declaration to remove',
|
|
1253
1349
|
'Nothing to unregister. A person closes the session on the board if it should end.')
|
|
1254
1350
|
path, _doc, name = self.declared_target(lane, entry)
|
|
1255
|
-
self.edit_source(path, entry['source'], lambda text: C.terminals_remove(text, name))
|
|
1351
|
+
self.edit_source(path, entry['source'], lambda text: C.terminals_remove(text, name), removes=(name,))
|
|
1256
1352
|
target = C.tmux_target(entry)
|
|
1257
1353
|
return {'lane': lane, 'removed': name, 'source': entry['source'], 'repo': entry.get('repo'),
|
|
1258
1354
|
'tmux': {'socket': target[0], 'session': target[1]} if target else None,
|
|
@@ -1375,28 +1471,36 @@ class Server:
|
|
|
1375
1471
|
try:
|
|
1376
1472
|
# W15 part 2: the lane's one native-input authority (lane_core.dispatch_lock), held across the check of its
|
|
1377
1473
|
# agent (read again under it), the text and the Enter — no other writer's text lands between them.
|
|
1474
|
+
# BEY-7538: `force` types past a working agent only; a lane that waits for an approval is never typed into
|
|
1475
|
+
# by a tool, forced or not (typed text would answer its prompt: an answer belongs to the person).
|
|
1378
1476
|
with C.dispatch_lock(self.root, lane):
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1477
|
+
observed = (C.container_status(self.root)['lanes'].get(lane) or {}).get('agent')
|
|
1478
|
+
hook = C.hook_agent(self.root / 'state' / 'hooks', lane, self.proc)
|
|
1479
|
+
for said_by, agent in (('the host\'s observation', observed), ('its lane-signal hook', hook)):
|
|
1480
|
+
state = agent.get('status') if isinstance(agent, dict) else None
|
|
1481
|
+
if not force and state == 'working' and agent.get('activity') == 'delegating':
|
|
1482
|
+
refuse('agent_working', f'{lane}\'s agent is working ({said_by}): its turn is over but '
|
|
1483
|
+
'its background subagents or jobs still run, and text typed now '
|
|
1484
|
+
'starts a new turn beside them')
|
|
1485
|
+
if not force and state == 'working':
|
|
1486
|
+
refuse('agent_working', f'{lane}\'s agent is working ({said_by}): text typed now lands in '
|
|
1487
|
+
'the middle of its turn')
|
|
1488
|
+
if state == 'needs_approval':
|
|
1489
|
+
refuse('agent_needs_approval', f'{lane}\'s agent waits for an approval ({said_by}): typed '
|
|
1490
|
+
'text would answer its prompt'
|
|
1491
|
+
+ (', and force does not lift that: nothing was typed' if force else ''))
|
|
1492
|
+
# BEY-8655: into the pane that holds the lane's agent (never the session's current window), and an
|
|
1493
|
+
# Enter the agent did not take is pressed once more only while its composer still holds the text.
|
|
1494
|
+
expect, pid = C.observed_agent(self.root, lane, self.proc)
|
|
1495
|
+
found = C.agent_pane(target[0], target[1], self.proc, agent_pid=pid, expect_agent=expect)
|
|
1496
|
+
results, verdict = C.send_checked(target[0], found['pane'], text, enter, found['harness'])
|
|
1395
1497
|
except C.DispatchBusy as error:
|
|
1396
1498
|
refuse('recipient_busy', f'{error} — nothing was typed', 'Another sender is typing into that lane right '
|
|
1397
1499
|
'now: try again in a few seconds (lanes_capture shows what it typed).')
|
|
1500
|
+
except C.LaneError as error:
|
|
1501
|
+
refuse(error.code, f'{lane}: {error} — nothing was typed')
|
|
1398
1502
|
result = results[-1]
|
|
1399
|
-
if result.returncode:
|
|
1503
|
+
if verdict is None and result.returncode:
|
|
1400
1504
|
why = (result.stderr or '').strip().splitlines()
|
|
1401
1505
|
why = why[0] if why else 'tmux exit ' + str(result.returncode)
|
|
1402
1506
|
if len(results) == 2: # the text went in; its Enter did not
|
|
@@ -1406,10 +1510,19 @@ class Server:
|
|
|
1406
1510
|
changed=f'typed {len(text)} characters into {lane}, without Enter')
|
|
1407
1511
|
refuse('tmux_unanswered' if result.returncode in (124, 127) else 'tmux_failed',
|
|
1408
1512
|
f'{lane}: {why} — nothing was typed')
|
|
1513
|
+
if verdict == 'not_submitted':
|
|
1514
|
+
refuse('not_submitted', f'{lane}: typed the text and pressed Enter twice, and the agent\'s composer still '
|
|
1515
|
+
'holds it', 'A person presses Enter in the lane, or clears the text; nothing more '
|
|
1516
|
+
'is pressed automatically.',
|
|
1517
|
+
changed=f'typed {len(text)} characters into {lane} (pane {found["pane"]}) and pressed Enter twice; '
|
|
1518
|
+
'not submitted')
|
|
1409
1519
|
return {'lane': lane, 'address': C.address_of(lane, entry, status['lanes'].get(lane), ghost),
|
|
1410
|
-
'typed': len(text), 'enter': enter, 'forced': bool(force),
|
|
1411
|
-
'
|
|
1412
|
-
'
|
|
1520
|
+
'typed': len(text), 'enter': enter, 'forced': bool(force), 'pane': found['pane'],
|
|
1521
|
+
'submitted': verdict,
|
|
1522
|
+
'changed': f'typed {len(text)} characters{" and Enter" if enter else ""} into {lane} '
|
|
1523
|
+
f'(pane {found["pane"]})' + (f': {C.verdict_sentence(verdict)}' if verdict else ''),
|
|
1524
|
+
'picked_up_by': 'the lane\'s agent, in the pane `pane` names (a lane without one: its active pane)',
|
|
1525
|
+
'expected_within_s': 0}
|
|
1413
1526
|
|
|
1414
1527
|
def route(self, lane, export):
|
|
1415
1528
|
"""W15 L2b's routing rule (lane_core.routing_check): a text for the fleet admin's lane only from a
|
|
@@ -24,11 +24,11 @@ names (MEASURED 2026-10-25, M9/M10; lane_core's "Claude peers" section). So, eve
|
|
|
24
24
|
written back (any reply byte makes the sender's SendMessage report a failure, M10); a connection without a line
|
|
25
25
|
(Claude's probe) is closed quietly. The line is lane_core.parse_peer_frame's; its text goes to lane_core.message for
|
|
26
26
|
the lane as `inbound` — sender the lane whose address (else Claude messaging name) is the frame's `from-name`,
|
|
27
|
-
else `peer:<from-name>` — which delivers it by the first adapter that applies (codex_queue,
|
|
28
|
-
it in the lane's inbox (`queued`), or holds it (`unknown`: an adapter that may have taken it and never
|
|
29
|
-
Handler threads run concurrently
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
else `peer:<from-name>` — which delivers it by the first adapter that applies (codex_queue, throttle_turn, …) or
|
|
28
|
+
leaves it in the lane's inbox (`queued`), or holds it (`unknown`: an adapter that may have taken it and never
|
|
29
|
+
answered). Handler threads run concurrently; none types into a lane (BEY-7538: a message never types into a
|
|
30
|
+
terminal), so a frame for a lane only its keyboard reaches waits in its inbox. The text's line breaks become ` ↵ `;
|
|
31
|
+
one longer than 4000 characters is cut.
|
|
32
32
|
* writes ~/.lz/state/peers/peers.json — {v: 1, at, pid, pin, peers: {lane: {name, socket, pid, session, harness,
|
|
33
33
|
status, tmux}}, blocked: {lane: why}, frames: {…counts}} — on a change and every STATE_HEARTBEAT_S: its `at` is
|
|
34
34
|
the liveness lanes-statusd re-arms the loop by, and what lane_core.virtual_peers (lanes_whoami/lanes_list's
|
|
@@ -36,7 +36,7 @@ names (MEASURED 2026-10-25, M9/M10; lane_core's "Claude peers" section). So, eve
|
|
|
36
36
|
|
|
37
37
|
It never reads or prints a message's text into a log: the journal (stderr: the tmux pane) holds lane ids, message ids,
|
|
38
38
|
codes and adapters. One loop per container (a lock in the peers directory); started by lanes-statusd as
|
|
39
|
-
`tmux -L lanes-peers
|
|
39
|
+
`tmux -L lanes-peers … respawn-pane -k -t =peerd: ~/.lz/bin/lane-peerd --loop` (statusd.peerd_rearm_argv) and stopped by SIGTERM,
|
|
40
40
|
SIGHUP or SIGINT, which removes every entry and socket it made. `--once`: one cycle, the document printed, the
|
|
41
41
|
sockets served for --serve seconds (default 0), then everything it registered removed again (a check, not a service).
|
|
42
42
|
Exit 0; 1 when another loop holds the lock (--once); 2 on a usage error.
|
|
@@ -15,9 +15,11 @@ this script writes state/hooks/, and lane-run never writes there.
|
|
|
15
15
|
"start":"<its starttime>", "session":"<session/thread id or ''>", "name":"<the agent's own note>" (only when
|
|
16
16
|
there is one)}
|
|
17
17
|
|
|
18
|
-
It never fails the agent
|
|
18
|
+
It never fails the agent: every path exits 0 and nothing reaches stdout (a Claude Code
|
|
19
19
|
UserPromptSubmit/SessionStart hook's stdout becomes model context). An unresolvable lane, a status outside the
|
|
20
|
-
vocabulary or an unwritable state directory are silent no-ops.
|
|
20
|
+
vocabulary or an unwritable state directory are silent no-ops. A different live agent owns the existing record
|
|
21
|
+
until its pid/start no longer matches /proc. A refused writer leaves that record unchanged and prints one
|
|
22
|
+
metadata-only JSON line to stderr, naming the lane, harness, event, and both pid/start pairs.
|
|
21
23
|
|
|
22
24
|
Lane id: $LANE_ID — exported in a tmux lane only by a canonical/`--identity` recipe's `-e` flags (Task 7, DEF-1559;
|
|
23
25
|
`lane open` never exports it), and in a zmx-held lane by `lane-run` as the zmx session name (which is NOT the
|
|
@@ -75,6 +77,9 @@ import sys
|
|
|
75
77
|
import time
|
|
76
78
|
import unicodedata
|
|
77
79
|
|
|
80
|
+
# The parity generator also imports this executable by file path, outside its installed bin directory.
|
|
81
|
+
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
|
82
|
+
|
|
78
83
|
STATUSES = ('working', 'needs_input', 'needs_approval', 'done', 'errored', 'shell', 'idle') # agent_state.STATUSES
|
|
79
84
|
LANE_ID = re.compile(r'[A-Za-z0-9][A-Za-z0-9_.-]{0,127}')
|
|
80
85
|
SHELLS = {'sh', 'dash', 'bash', 'zsh', 'ksh', 'fish'}
|
|
@@ -94,6 +99,10 @@ CLAUDE_EXE = '/claude/versions/' # native Claude Code before 2.1.299 kept its
|
|
|
94
99
|
PARENT_DEPTH = 8
|
|
95
100
|
ENVIRON_MAX = 1 << 20 # lane_core.ENVIRON_MAX: /proc/<pid>/environ read at most this far
|
|
96
101
|
IDENTITY_VARS = ('LANE_ID', 'LANE_WS', 'TMUX', 'TMUX_PANE') # lane_core.WHOAMI_VARS
|
|
102
|
+
# A harness's shared daemon, by a word of its command line (lane_core.DAEMON_WORDS): Codex's `codex app-server …`
|
|
103
|
+
# (MEASURED 2026-11-18, codex 0.170.0). One process serves many threads and fires every thread's hooks itself.
|
|
104
|
+
DAEMON_WORDS = ('app-server',)
|
|
105
|
+
CMDLINE_MAX = 4096
|
|
97
106
|
|
|
98
107
|
|
|
99
108
|
def options(argv):
|
|
@@ -173,6 +182,27 @@ def agent(given=None, proc='/proc'):
|
|
|
173
182
|
return pid, None
|
|
174
183
|
|
|
175
184
|
|
|
185
|
+
def shared_daemon(pid, proc='/proc'):
|
|
186
|
+
"""True when process `pid` is a harness's shared daemon (DAEMON_WORDS among the first words after its program's
|
|
187
|
+
name in /proc/<pid>/cmdline). Such a process serves the threads of many lanes and keeps the environment of
|
|
188
|
+
whoever started it, so a hook it fires — and a record that names it — says nothing about the lane in that
|
|
189
|
+
environment (BEY-8641). Bounded (CMDLINE_MAX), never through a link, never blocking; a command line that cannot be
|
|
190
|
+
read is False: the rule drops only what it can show to be a daemon."""
|
|
191
|
+
try:
|
|
192
|
+
fd = os.open(f'{proc}/{int(pid)}/cmdline',
|
|
193
|
+
os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK | getattr(os, 'O_CLOEXEC', 0))
|
|
194
|
+
except (OSError, ValueError, TypeError):
|
|
195
|
+
return False
|
|
196
|
+
try:
|
|
197
|
+
data = os.read(fd, CMDLINE_MAX)
|
|
198
|
+
except OSError:
|
|
199
|
+
return False
|
|
200
|
+
finally:
|
|
201
|
+
os.close(fd)
|
|
202
|
+
words = data.split(b'\0')[1:4]
|
|
203
|
+
return any(word.encode() in words for word in DAEMON_WORDS)
|
|
204
|
+
|
|
205
|
+
|
|
176
206
|
def exe_of(pid, proc='/proc'):
|
|
177
207
|
"""The path /proc/<pid>/exe names ('' when it cannot be read), without the kernel's ` (deleted)`."""
|
|
178
208
|
try:
|
|
@@ -309,12 +339,15 @@ def same_agent(old, session, pid, start):
|
|
|
309
339
|
|
|
310
340
|
|
|
311
341
|
def main(argv):
|
|
342
|
+
from lane_core import same_process
|
|
312
343
|
status, event, harness, payload, note, agent_pid = options(argv)
|
|
313
344
|
if status not in STATUSES:
|
|
314
345
|
return
|
|
315
346
|
root = os.environ.get('LANE_ROOT') or os.path.join(os.path.expanduser('~'), '.lz')
|
|
316
347
|
proc = os.environ.get('LANE_PROC') or '/proc'
|
|
317
348
|
pid, start = agent(agent_pid, proc)
|
|
349
|
+
if shared_daemon(pid, proc):
|
|
350
|
+
return # the daemon's LANE_ID is its starter's, not this thread's lane: it speaks for no lane (BEY-8641)
|
|
318
351
|
environ = None
|
|
319
352
|
if not os.environ.get('LANE_ID') and not os.environ.get('TMUX'):
|
|
320
353
|
inherited = agent_environ(pid, proc) # a harness that cleared its hooks' environment (Muse Code, DEF-2031)
|
|
@@ -343,6 +376,18 @@ def main(argv):
|
|
|
343
376
|
old = json.load(open(path))
|
|
344
377
|
except (OSError, ValueError):
|
|
345
378
|
old = None
|
|
379
|
+
if isinstance(old, dict):
|
|
380
|
+
try:
|
|
381
|
+
owner_pid = int(old.get('pid') or 0)
|
|
382
|
+
except (TypeError, ValueError):
|
|
383
|
+
owner_pid = 0
|
|
384
|
+
if owner_pid > 0 and shared_daemon(owner_pid, proc):
|
|
385
|
+
owner_pid = 0 # a record a shared daemon wrote is no lane's: it has no live owner (BEY-8641)
|
|
386
|
+
if owner_pid > 0 and owner_pid != pid and same_process(proc, str(owner_pid), old.get('start')):
|
|
387
|
+
print(json.dumps({'refused': 'live_owner', 'lane': lane, 'harness': harness, 'event': event,
|
|
388
|
+
'pid': pid, 'start': start, 'owner_pid': owner_pid, 'owner_start': old.get('start')},
|
|
389
|
+
separators=(',', ':')), file=sys.stderr, flush=True)
|
|
390
|
+
return
|
|
346
391
|
if not (isinstance(old, dict) and old.get('v') == 1 and old.get('status') in STATUSES
|
|
347
392
|
and isinstance(old.get('since'), int)):
|
|
348
393
|
old = None
|
|
@@ -376,7 +421,7 @@ def main(argv):
|
|
|
376
421
|
|
|
377
422
|
if __name__ == '__main__':
|
|
378
423
|
try:
|
|
379
|
-
sys.stdout =
|
|
424
|
+
sys.stdout = open(os.devnull, 'w')
|
|
380
425
|
main(sys.argv[1:])
|
|
381
426
|
except BaseException: # noqa: BLE001 - a hook must never fail the agent: every outcome is exit 0
|
|
382
427
|
pass
|