Repository navigation
Commit 48b01aa
authored
Let the connector do the work itself, on the coding agent you choose (#1026)
* Let the handoff deliver each request before it closes the record
The handoff writes a trusted request to stdout and then closes its record,
which is all a reader of the lines needs. A run that does the work itself
needs the request kept somewhere of its own first: closed before it is kept,
a crash between the two loses a request that was already acknowledged.
HandoffOptions.Deliver is called after the line is written and before the
record is closed, and returns once the request is kept. A delivery that fails
leaves the record open, so the request is delivered again. Nil delivers
nowhere, which is every run today.
* Add the connector's runner: an orchestrator and workers on a coding agent's CLI
The basecamp-connect skill runs in a Claude Code session and leans on two
things only that harness has: a monitor that wakes the session for each
request line, and background subagents. The runner supplies both from the CLI,
so the same skill can run on any coding agent that takes a prompt without a
terminal, runs shell commands and continues an earlier session.
Each request the connector hands off is kept in the runner's state and given
to an orchestrator, one turn of a headless session at a time. The orchestrator
follows SKILL.md as it ships and hands the work to a worker, a session of its
own that follows subagent.md and reports back as another turn. The runner adds
only a table that maps the mechanisms the skill names onto its commands.
An adapter is one CLI: the arguments of a turn and how its event stream reads.
A turn is one process, started through driver.StartWorker as the leader of a
process group the runner can end whole.
- A later request on the same card, to-do, message or chat goes to the worker
that handled the first, continued in its session, and waits its turn if that
worker is busy. A new worker starts only when that session cannot take it.
- A worker a stop interrupted is continued at the next start and told so. A
process a crash left running is ended, by its recorded process group, before
its session is continued.
- runner.json, beside connect.json, chooses a worker's coding agent, model and
effort by repo, project, card table, to-do list, containing recording or
Ping, and keeps what the connector was last started with.
- Permissions are one switch. Full starts each CLI with its prompts off, since
a headless turn has nobody to answer one. Guarded starts each under its own
unattended guardrails, and refuses a CLI that has none.
The adapters are held to the installed CLIs by an opt-in test:
go test -tags runner_live ./internal/connector/runner -run TestInstalled
* Run the connector with an orchestrator, and add the commands its agents use
basecamp connect -P <profile> --orchestrator <agent> does the work itself
instead of printing requests for a session to read. --worker names another
coding agent for the work, the model and effort flags choose those, and
--permissions chooses full or guarded. What a start names is kept for the
profile, and --run starts with it. Without any of these the connector is what
it was.
The orchestrator's tools are commands that reach the running connector over a
unix socket in its state directory: dispatch hands a request to a worker,
workers list, send and stop see and steer them, say talks to the orchestrator
from a terminal, and stop and restart end the connector or start it again.
An agent the connector starts is told which runner started it, so these
commands reach the socket from inside a coding agent's sandbox, where the
ownership of connect.json cannot be checked. The check is unchanged.
* Describe running without a session in the basecamp-connect skill
The skill said running the connector requires Claude Code. Watching it from a
session still does. A new section, after everything a session following the
original flow reads, says how to start the connector with an orchestrator
instead: which coding agent, that the choice is kept, that it has to be started
where it outlives the session, what full and guarded permissions mean, and the
commands for checking on it.
The per-request steps stay inside the compaction budget, and the new hidden
commands and flags are acknowledged in the drift baseline with the rest of
connect.
* Close the races and gaps the reviews found in the runner
One request, one worker. Dispatch let go of its lock to read what a request
sits under and did not ask again, under the lock, whether the event had got a
worker meanwhile, so two dispatches arriving together could start two. A
worker also has one goroutine now, whatever it is told: a message sent just
after a stop, before the stopped turn had ended, started a second one on the
same session.
A leftover process is always ended. Starting with another orchestrator reset
the session and, with it, the record of a process the last run had left, which
then ran on beside the new one.
What never ran is not counted. A turn refused under guarded permissions
reached no agent, and no longer uses up one of a message's attempts. A `say`
that could not be saved is taken back out, so a retry is not answered twice.
Requests still waiting, or being worked on, are not pruned with the history. A
rule's relative repo is refused when the file is read, since it could never
match. What a request sits under is cached only when it was read, so a rule
added later still gets its answer, and a card on hold is followed to its
column and card table, which its On Hold section does not name.
The socket no longer gives up on the first failed accept, and a client that
sends half a request no longer holds a stop open. Standard input past its
limit is refused rather than cut. A dispatch waits as long as its lookups can
take. What a start names is kept once the start has its lock, not before.
A failed turn's stderr has the agent's environment taken out of it, and the
help's example and its claim about what is read again are corrected.
* Hold the runner with the connector, and never continue beside a leftover
A hold means nothing is dispatched or posted until it is released. The
handoff honored it and the runner did not: started under a hold, it went on
giving its orchestrator the messages it already held and starting the workers
that were waiting. It now starts no agent while the hold stands, and takes up
where it was when the hold is released.
A process a crashed run left is ended before its session is continued. When it
could not be confirmed ended, the session was continued all the same, beside
whatever was still running. The recorded group now gets the rule's last step
as well, which ends what a vanished leader left behind, and a group that still
cannot be confirmed gone keeps its record: a worker is closed as failed, which
the orchestrator is told, and an orchestrator's stops the start.
The comments said a crash between writing a request and keeping it repeats the
request. That holds only for a start within the handoff's grace: an older
record is not run late, with a runner or without. They now say so.
* Confirm every leftover ended, and keep the runner's socket to its owner
A start now confirms each process a crash left is gone, after the signal
as well as when the leader had already gone, and one that cannot be
confirmed stops the start whichever session it was. A worker that was
only set aside could still be told more, or take a later request on its
thread, beside the process nobody ended.
The socket's directory is checked wherever it is listened on or called:
a real directory, this user's, closed to everyone else. The fallback for
a long path sits under XDG_RUNTIME_DIR when there is one, and an agent is
given the socket's path itself rather than the directory to derive it
from.
A failed lookup of a card's On Hold section is logged, and the accept
loop only reads the run's end as the reason for an error when there was
one.
* Say where the runner's socket is, and vouch for nothing off Unix
A socket that cannot sit in the runner's directory, because the path is
too long for an address, went wherever the environment of the moment
said, so a command started with another environment looked somewhere
else and reported the running connector absent. The connector now keeps
where it listens beside its state, and a call reads that.
The runtime directory is used only when the whole path fits an address.
The directory check compares the effective user, as the connector's
other ownership checks do, and off Unix it refuses rather than passing
everything.
* Hold each turn to the rule a start keeps, and undo what could not be saved
A start does not begin beside a process it cannot confirm ended. A turn
is now held to the same:
- The record of a turn's process goes only once nothing of its process
group is left. One that stays fails its worker, is asked after again
before that session's next turn, orchestrator or worker, and is the
next start's to end.
- An agent whose process could not be written to the state is ended
before it is told anything, and reported as one that could not run.
A worker continued after a stop is given what it was last on along with
the notice that it was interrupted: a stop just after its turn began may
have come before its session had the request.
A dispatch to a thread's earlier worker, or a message sent to a worker,
that could not be saved leaves the worker as it was, rather than queued
with nobody to run it.
* Say plainly why an interrupted worker is given its request again
* Keep a finished worker whose process is still named1 parent 6e7d817 commit 48b01aa
28 files changed
Lines changed: 6801 additions & 4 deletions
File tree
- internal
- commands
- connector
- runner
- skills
- basecamp-connect
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
62 | 118 | | |
63 | 119 | | |
64 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
67 | 117 | | |
68 | 118 | | |
69 | 119 | | |
| |||
100 | 150 | | |
101 | 151 | | |
102 | 152 | | |
103 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
104 | 160 | | |
105 | 161 | | |
106 | 162 | | |
107 | 163 | | |
108 | | - | |
| 164 | + | |
| 165 | + | |
109 | 166 | | |
110 | 167 | | |
111 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| |||
216 | 222 | | |
217 | 223 | | |
218 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
219 | 237 | | |
220 | 238 | | |
221 | 239 | | |
| |||
317 | 335 | | |
318 | 336 | | |
319 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
320 | 345 | | |
321 | 346 | | |
322 | 347 | | |
| |||
365 | 390 | | |
366 | 391 | | |
367 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
368 | 407 | | |
369 | 408 | | |
370 | 409 | | |
| |||
429 | 468 | | |
430 | 469 | | |
431 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
432 | 492 | | |
433 | 493 | | |
434 | 494 | | |
| |||
483 | 543 | | |
484 | 544 | | |
485 | 545 | | |
| 546 | + | |
486 | 547 | | |
487 | 548 | | |
488 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
489 | 553 | | |
490 | 554 | | |
491 | 555 | | |
| |||
504 | 568 | | |
505 | 569 | | |
506 | 570 | | |
| 571 | + | |
| 572 | + | |
507 | 573 | | |
508 | 574 | | |
509 | 575 | | |
| |||
0 commit comments