Documentation
¶
Overview ¶
Package session manages on-disk session entries at `<BaseDir>/sessions/<id>/`. A session is one Slack thread or one UI conversation: routing key, status, agent registry, log files, and an optional reference to a workspace whose folder is the agent cwd.
Sessions own no workspace files of their own — workspace is a shared folder (see internal/agents/workspace) that the pool resolves to a cwd at spawn time. See agents-design.md §0.2 for the refactor that removed the per-session git worktree.
Files in this package:
- session.go — Meta + lifecycle (Create/Load/Save/Delete/SwitchWorkspace)
- agents.go — per-session AgentEntry + Add/SetActive
Index ¶
- func AddAgent(layout config.Layout, id, name, provider string) error
- func Delete(_ context.Context, layout config.Layout, id string) error
- func List(layout config.Layout) ([]string, error)
- func SaveAgents(layout config.Layout, id string, agents []AgentEntry) error
- func SaveMeta(layout config.Layout, id string, meta Meta) error
- func SetActiveAgent(layout config.Layout, id, name string) error
- func SwitchWorkspace(_ context.Context, layout config.Layout, id, newWorkspace string) error
- type AgentEntry
- type CreateOptions
- type Meta
- type Origin
- type Session
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAgent ¶
AddAgent appends a new agent entry. Errors on duplicate name within the same session.
func Delete ¶
Delete removes the session folder. The workspace it points at is left untouched — workspaces are shared, so deleting a session must not delete its files.
func SaveAgents ¶
func SaveAgents(layout config.Layout, id string, agents []AgentEntry) error
SaveAgents atomically rewrites sessions/<id>/agents.json. nil becomes an empty array on disk so consumers don't have to handle `null`.
func SetActiveAgent ¶
SetActiveAgent updates meta.json's active_agent field. The named agent must already exist in agents.json.
func SwitchWorkspace ¶
SwitchWorkspace changes the workspace a session points at. No filesystem work — the next agent spawn will resolve the new workspace path. Conversation, agent registry, and logs are preserved.
Types ¶
type AgentEntry ¶
type AgentEntry struct {
Name string `json:"name"`
Provider string `json:"provider"`
CLISessionID string `json:"cli_session_id,omitempty"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
LastActive time.Time `json:"last_active,omitempty"`
}
AgentEntry is one row in sessions/<id>/agents.json. CLISessionID is the resume key — wick captures it from the first stream-json event emitted by the CLI and persists it so subsequent spawns can pass `--resume <id>`. See agents-design.md §5.2.
type CreateOptions ¶
type CreateOptions struct {
ID string
Workspace string
Origin Origin
ChannelID string
// Preset is the preset name to associate with this session.
// Stored in meta.json; factory loads content from presets/<name>/agent.md on spawn.
Preset string
}
CreateOptions describes a new session. Workspace is optional — a session may be created without one, in which case the pool falls back to the tools-config default workspace (or a per-session temp dir if no default is set).
type Meta ¶
type Meta struct {
Workspace string `json:"workspace,omitempty"`
Origin Origin `json:"origin"`
ChannelID string `json:"channel_id,omitempty"`
ActiveAgent string `json:"active_agent,omitempty"`
Status Status `json:"status"`
CreatedAt time.Time `json:"created_at"`
LastActive time.Time `json:"last_active"`
PendingInput []string `json:"pending_input,omitempty"`
// Label is the first user message truncated to 60 runes, cached here
// so sidebar rendering never needs to open conversation.jsonl.
Label string `json:"label,omitempty"`
// Preset is the name of the preset active for this session.
// Factory reads the preset content from presets/<name>/agent.md on
// every spawn so edits to the preset take effect on next respawn.
Preset string `json:"preset,omitempty"`
}
Meta is the persisted-on-disk shape of a session. PendingInput is the message buffer that survives wick restart so a session that was queued at shutdown gets its messages drained on next boot.
type Origin ¶
type Origin string
Origin identifies where the session was first created from. Slack threads use thread_ts as the session ID; UI/API sessions use a UUID generated by wick.
type Session ¶
type Session struct {
ID string `json:"id"`
Meta Meta `json:"meta"`
Agents []AgentEntry `json:"agents"`
}
Session is the in-memory view: ID + meta + agent registry. Mirrors the trio of files at sessions/<id>/.