Merge branch 'main' into worktree-agent-a3ec65b20dc3028b9
This commit is contained in:
@@ -812,6 +812,11 @@ type ChatAccountUsage struct {
|
||||
AsOf int64 `json:"as_of,omitempty"`
|
||||
Windows []ChatQuotaWindow `json:"windows,omitempty"`
|
||||
Unsupported bool `json:"unsupported,omitempty"`
|
||||
// SwitchedAt is when the operator last switched the chat's Claude account
|
||||
// to this one (epoch milliseconds). The report then stands for the new
|
||||
// account even with no windows yet, and a usage-limit refusal the chat
|
||||
// received before it no longer applies.
|
||||
SwitchedAt int64 `json:"switched_at,omitempty"`
|
||||
}
|
||||
|
||||
// ChatQuotaWindow is one rolling quota window. UsedPercent is 0-100 (it can
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package protocol
|
||||
|
||||
// Claude account switching for a chat whose directory selects its own Claude
|
||||
// Code home (CLAUDE_CONFIG_DIR, for example from a direnv .envrc). Each request
|
||||
// body is ClaudeAccountRequest naming the chat; the server resolves the chat's
|
||||
// directory environment to that config directory and replies with
|
||||
// ClaudeAccountList. Saved accounts live in <config dir>/pipelines-accounts/.
|
||||
// Using one changes the same files `/login` changes, in place, so running
|
||||
// Claude Code processes continue on the new account without a restart. No
|
||||
// reply or log ever carries a token.
|
||||
const (
|
||||
// ClaudeAccounts lists the saved accounts and the active login.
|
||||
ClaudeAccounts = "claude_accounts"
|
||||
// ClaudeAccountSave snapshots the active login as a saved account; Name
|
||||
// defaults to its email.
|
||||
ClaudeAccountSave = "claude_account_save"
|
||||
// ClaudeAccountUse makes the saved account Name the active login, first
|
||||
// writing the current login's refreshed tokens back to its own slot.
|
||||
ClaudeAccountUse = "claude_account_use"
|
||||
// ClaudeAccountRemove deletes the saved account Name. The active login is
|
||||
// unchanged.
|
||||
ClaudeAccountRemove = "claude_account_remove"
|
||||
)
|
||||
|
||||
// ClaudeAccountRequest is the body of every claude_account* request.
|
||||
type ClaudeAccountRequest struct {
|
||||
SessionID string `json:"session_id"`
|
||||
// Name is the saved account (its name, slug or email); for a save, the
|
||||
// name to save under ("" uses the email).
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// ClaudeAccount describes one Claude login without its credentials.
|
||||
type ClaudeAccount struct {
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Organization string `json:"organization,omitempty"`
|
||||
// Plan is the subscription type the login reports ("max", "pro").
|
||||
Plan string `json:"plan,omitempty"`
|
||||
// Active is set on the account the config directory is signed in with.
|
||||
Active bool `json:"active,omitempty"`
|
||||
// Saved is false for an active login that has no saved slot yet.
|
||||
Saved bool `json:"saved"`
|
||||
}
|
||||
|
||||
// ClaudeAccountList is the reply to every claude_account* request.
|
||||
type ClaudeAccountList struct {
|
||||
// ConfigDir is the Claude Code home the chat's directory selects.
|
||||
ConfigDir string `json:"config_dir"`
|
||||
// Active is the current login (saved or not); nil when signed out.
|
||||
Active *ClaudeAccount `json:"active,omitempty"`
|
||||
// Accounts are the saved accounts, sorted by name.
|
||||
Accounts []ClaudeAccount `json:"accounts"`
|
||||
// Usage is the newly active account's latest known quota after a
|
||||
// claude_account_use (see ChatAccountUsage.SwitchedAt).
|
||||
Usage *ChatAccountUsage `json:"usage,omitempty"`
|
||||
}
|
||||
@@ -250,6 +250,10 @@ type Message struct {
|
||||
ChatModels []ChatModel `json:"chat_models,omitempty"`
|
||||
// ChatCommands is the chat_commands reply: the session's slash commands.
|
||||
ChatCommands []ChatCommand `json:"chat_commands,omitempty"`
|
||||
// ClaudeAccount is the body of the claude_account* requests and
|
||||
// ClaudeAccounts their reply (claude_accounts.go).
|
||||
ClaudeAccount *ClaudeAccountRequest `json:"claude_account,omitempty"`
|
||||
ClaudeAccounts *ClaudeAccountList `json:"claude_accounts,omitempty"`
|
||||
// ModelRequest is the chat_model body and echoed selection.
|
||||
ModelRequest *ChatModelRequest `json:"chat_model,omitempty"`
|
||||
// ChatModes is the chat_modes reply: the permission modes the session's
|
||||
|
||||
Reference in New Issue
Block a user