Merge main into run token usage branch

This commit is contained in:
2026-11-03 22:21:38 +00:00
118 changed files with 4294 additions and 1483 deletions
+27
View File
@@ -85,6 +85,13 @@ const (
// shared list metadata (colour, star, title) changes, carrying the updated
// registry row in ChatSession, so each device's list updates live.
ChatSessionChanged = "chat_session_changed"
// ChatActivityChanged is pushed to every open connection (not only the
// session's room subscribers) when a chat's live activity changes: its turn
// starts or ends, or its count of running background tasks changes. The
// body is ChatActivity. It is sent on those transitions only, never per
// output chunk; a client applies a push only when its Seq is newer than the
// activity it already holds for that session.
ChatActivityChanged = "chat_activity"
// ChatSubscribe attaches a connection to one session's shared live stream so
// it receives every frame any client's turn produces (its own and the other
// devices'), not only the frames of a turn it prompted itself. Any number of
@@ -320,6 +327,26 @@ type ChatSession struct {
// the operator started a fresh session. Clients replace the row with that
// id by this one; it is never part of a listed row.
PreviousID string `json:"previous_id,omitempty"`
// Activity is the server's live view of the session. A server that tracks
// it sets it on every chat_sessions row (its presence, even as an empty
// object, tells a client the server also pushes chat_activity). Older
// servers omit it.
Activity *ChatActivity `json:"activity,omitempty"`
}
// ChatActivity is one session's live activity as the server observes it: a
// turn in flight, and how many background tasks (shells, background commands,
// subagents) the harness reports still running. It rides on chat_sessions rows
// and is pushed as chat_activity. Seq orders one session's snapshots across
// the list reply and the pushes (a later snapshot has a larger Seq, also
// across a server restart); a client keeps the snapshot with the largest Seq.
// Background tasks are counted only while the server observes the session's
// stream, so an unobserved session reports none rather than a stale count.
type ChatActivity struct {
SessionID string `json:"session_id,omitempty"`
TurnRunning bool `json:"turn_running,omitempty"`
BackgroundTasks int `json:"background_tasks,omitempty"`
Seq int64 `json:"seq,omitempty"`
}
// Chat export formats accepted by chat_export.
+2
View File
@@ -198,6 +198,8 @@ type Message struct {
// requests themselves ride on ChatQuery (the session id), matching
// chat_messages/chat_interrupt.
ChatClose *ChatCloseResult `json:"chat_close,omitempty"`
// ChatActivity is the chat_activity push: one session's live activity.
ChatActivity *ChatActivity `json:"chat_activity,omitempty"`
// ChatAnswer is the chat_answer body; the form update arrives through the
// normal chat_event stream.
ChatAnswer *ChatAnswerRequest `json:"chat_answer,omitempty"`