Repository navigation
feat: move RPC, ACP and CLI onto threads - #113
Merged
Merged
Conversation
ThreadInfo carries the thread's own billed usage. The session store's new `rebase` is the only place that works out where a session's or a thread's directory lands under another root; the embedder relink and the store relink both use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- RPC: ThreadInfo gains `usage`; `session.relink` answers with the addressed thread (main when absent); `event.subscribe` and `session.log` take an optional `threadId` filter. - ACP: every thread is an ACP session (main keeps the session id, others use their thread id) for list, load, prompt and cancel; `session/fork` forks at the last committed entry. - CLI: `thread list`, `thread fork --at|--before`, and `session relink [--thread]`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Leaves the docs site as it was; it is updated separately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ACP `session/fork` cuts at the last committed entry of any type, as the harness does, so a trailing tool result or compaction comes along. - The ACP one-prompt-at-a-time guard is keyed by thread, since main answers to both its session id and its thread id. - `session relink -C` says what it does: the checkout to move into, with the work keeping its position under it. - Contract docs: cost is in US dollars; a fork's filtered `session.log` starts at its `thread.forked`. - The ACP fork artifact no longer records an idle cancel that proved nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`thread.forked` and `thread.configured` become `session.thread.forked` and `session.thread.configured`, like every other event in the session's log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the server RPC, ACP and CLI surfaces in
packages/codeworkonto the thread model (session = container of linear threads). The apps (apps/web,apps/widget, desktop) follow in a separate PR;apps/still compiles and stays wire-compatible.RPC
ThreadInfo.usage={ cost, input, output, cacheRead, cacheWrite }, counting the thread's own entries only (the inherited prefix counts for its source).session.relinkreturns the thread: it answers withThreadInfofor the giventhreadId(main when absent), so itsplacementand embedded session show where it now runs, with no second call. The directory rebase lives in one place: the store's newrebase, used by both the embedder relink and the store relink.event.subscribeandsession.logtake an optionalthreadId. Only events whose data names that thread pass.server.connectedstill comes first andlog.syncedstill ends the replay. There is still one session log and no new method; every thread-scoped event already carriesthreadId.Client.runnow subscribes filtered.ACP: each thread is an ACP session
The installed SDK (1.5.1) has
session/fork, but only as "fork this session": it takes no entry, so on its own it can't reach forks made elsewhere (CLI, RPC). So every thread is an ACP session of its own:session/listlists threads (a fork with no title shows its source's title).loadreplays the thread's whole line.prompt,cancelandset_config_optionaddress that thread.session/forkis advertised and forks at the line's last committed entry. With no messages yet it fails withinvalidRequest.CLI
codework thread list <session>: id, origin, model, tokens and cost, title.--jsonprints the wire form.codework thread fork <session> [--thread <id|main>] (--at <entry> | --before <entry>): prints the new thread id, and for--beforethe text to edit.codework session relink <session> [--thread <id|main>] [-C <dir>] [--sandbox-id <id>]--threadparsing is shared withrun. The new verbs talk to a running server, likesession link.Docs: the
packages/codeworkandpackages/harnessREADMEs describe threads. The docs site (sites/) is left for a separate update.Tests (E2E, with
__artifacts__/snapshots)server.threads.json: per-thread usage on the wire, a liveevent.subscribe({ threadId })seeing only the fork while main also runs,session.logfiltered, and relink placement for a thread vs. the session.server.cli-threads.json:thread fork --at/--before,session relink --thread,thread list(text and--jsondecoded with the contract), and the error paths.acp.fork.json: ACPsession/fork, prompting the fork, listing both, and loading each with its line. It runs against a local fake chat-completions endpoint, so no live key is needed.acp.jsonnow includes theforkcapability.vp checkpasses.vp run typecheckpasses exceptsites/wwwunder parallel runs (exit 137, out of memory); it passes when run alone. Known unrelated failures: livedeepseek(OpenRouter credits), andtui.test.ts"registration another server took over", because port 7610 is held by an orphaned server from another worktree on this machine. The ACP live case "streams, runs tools, cancels…" sometimes hits its 180s timeout, onopenaiin one run and onopenai-codexin another; it does the same with this PR's cancel swapped back to the old session-wide interrupt.🤖 Generated with Claude Code