Documentation
¶
Overview ¶
Package claudesessions adapts native Claude Agent SDK sessions to Orb events. Its host runs the official SDK and an unmodified Claude executable; Orb never reads, copies, refreshes or proxies Claude credentials.
Index ¶
- Constants
- Variables
- func AmbientAccount(ctx context.Context, settings *config.SettingsManager, env []string) (string, bool)
- func Configure(cfg *agent.SessionRuntimeConfig, agentDir string, env []string) (bind func(*agent.SessionRuntime), err error)
- func Factory(options Options) agent.CreateAgentSessionRuntimeFactory
- func ForgetAccount(settings *config.SettingsManager, agentDir string, env []string, ...)
- func ImportClaudeCode(id string, env []string, ...) (*session.SessionManager, error)
- func LimitsStatus(manager extensions.ReadonlySessionManager, now time.Time) string
- func Management(settings *config.SettingsManager, agentDir string, env []string) extensions.Factory
- func Model(provider, model *string, settings *config.SettingsManager) *ai.Model
- func Usage(ctx context.Context, settings *config.SettingsManager, agentDir string, ...) (usage.Snapshot, error)
- type Driver
- type Options
Constants ¶
const Name = "claude-sessions"
const SDKVersion = "0.3.280"
Variables ¶
var ErrNoClaudeCodeSession = errors.New("no Claude Code session")
ErrNoClaudeCodeSession reports an ID that names no Claude Code session.
Functions ¶
func AmbientAccount ¶ added in v0.12.0
func AmbientAccount(ctx context.Context, settings *config.SettingsManager, env []string) (string, bool)
AmbientAccount is the user's own Claude Code login as an account row, or false when it is signed out.
func Configure ¶
func Configure(cfg *agent.SessionRuntimeConfig, agentDir string, env []string) (bind func(*agent.SessionRuntime), err error)
Configure lets Claude run the turns of Claude models in the runtime every other model shares: its loop takes those turns, Orb's own loop the rest, and one conversation moves between them. bind must run before the runtime is exposed.
func Factory ¶
func Factory(options Options) agent.CreateAgentSessionRuntimeFactory
Factory rebuilds the plugin attachment for every SDK session replacement. The caller supplies storage in AgentSessionOptions and owns runtime disposal.
func ForgetAccount ¶ added in v0.12.0
func ForgetAccount(settings *config.SettingsManager, agentDir string, env []string, credential *aiauth.Credential)
ForgetAccount signs a removed or replaced Claude account out and deletes its directory.
func ImportClaudeCode ¶ added in v0.12.0
func ImportClaudeCode(id string, env []string, create func(cwd string) (*session.SessionManager, error)) (*session.SessionManager, error)
ImportClaudeCode opens a Claude Code session in a new Orb conversation: its messages to read and continue with any model, and its records for Claude to resume from. create makes the conversation in the session's directory, under the session's own ID so opening it again finds the Orb conversation.
func LimitsStatus ¶ added in v0.10.0
func LimitsStatus(manager extensions.ReadonlySessionManager, now time.Time) string
LimitsStatus formats the latest native subscription reading for local or remote UI.
func Management ¶
func Management(settings *config.SettingsManager, agentDir string, env []string) extensions.Factory
Management exposes the dormant capability through a native command and palette entry. Installing dependencies and starting sessions are explicit user actions.
func Model ¶
func Model(provider, model *string, settings *config.SettingsManager) *ai.Model
Model selects this capability only for an explicit or restored Claude session.
func Usage ¶ added in v0.12.0
func Usage(ctx context.Context, settings *config.SettingsManager, agentDir string, env []string, credential *aiauth.Credential) (usage.Snapshot, error)
Usage reads an account's plan limits as Claude's /usage shows them; a nil credential reads the user's own Claude Code login.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func (*Driver) Close ¶ added in v0.10.0
func (d *Driver) Close()
Close ends the live native session, if any.
func (*Driver) Loop ¶
func (d *Driver) Loop(ctx context.Context, prompts engine.AgentMessages, _ engine.AgentContext, config engine.AgentLoopConfig, emit engine.EventSink) error
Loop owns the complete native turn. Orb queues are drained only between native turns, so no tool is executed twice by an outer Orb agent loop.
type Options ¶
type Options struct {
Sandbox sandbox.Mode
// RenderText optionally supplies text components for SDK-hosted tool calls.
RenderText func(string) extensions.Component
Node, SDK, Claude string
Env []string
Manager *session.SessionManager
// Headless approves native asks that no UI can answer, as Orb runs its own tools.
Headless bool
// Unasked: Orb's permissions plugin is off, so Orb runs its tools without asking, and Claude's
// run the same way instead of falling back to Claude Code's own prompts.
Unasked bool
// Context is Orb's instructions that Claude does not load itself.
Context string
Ask func(context.Context, string, []string) (string, error)
// Account resolves the selected Claude account's directory through Orb's
// auth pipeline; empty runs with the user's own Claude Code login.
Account func(context.Context) string
}