view

package
v1.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildReproVariants added in v0.28.1

func BuildReproVariants(providerType, binary string, argv, env []string, prompt string) map[string]string

BuildReproVariants renders all 24 reproduce commands (3 shells × headless/ interactive × full/short path × keep/strip resume) for the given binary, argv, and env. The same function serves the masked page render and the unmasked reveal endpoint — callers pass masked vs unmasked env so the keys line up exactly.

prompt is the first user message the command should carry. Empty renders the bare command (what the spawn log used to show), which for a stdin provider starts a CLI with nothing to say — claude then reports "No deferred tool marker found in the resumed session". Non-empty is delivered per the provider's ReproSpec: piped into stdin as a stream-json line for the long-lived-stdin CLIs, appended as a positional arg in interactive mode.

func HasResumeArgv added in v0.28.1

func HasResumeArgv(providerType string, argv []string) bool

HasResumeArgv reports whether argv carries a resume-session token for the provider — i.e. whether the Keep/Fresh toggle would make any difference. The first spawn of a session has no resume id, so the toggle should be hidden.

func InteractiveArgv added in v0.28.1

func InteractiveArgv(providerType string, argv []string) []string

InteractiveArgv strips the headless/programmatic tokens wick adds (per provider.ReproSpec) so the command runs in the CLI's normal interactive chat mode instead of emitting a JSON stream. Everything else (--mcp-config, --add-dir, --resume, …) is kept so the session context is identical.

func IsRunningStatus added in v1.2.9

func IsRunningStatus(status string) bool

IsRunningStatus reports whether an effectiveStatus value means "work is happening or about to": those rows sort to the top of the sidebar and carry the accent border. Idle is a warm process with nothing to do, so it sorts by age like everything else.

MIRRORED in fe/agents/shell/src/sidebarOrder.ts (isRunningStatus).

func PromptSupported added in v1.2.9

func PromptSupported(providerType string) bool

PromptSupported reports whether the Prompt control is meaningful for this provider — false when the spawn's argv already carries the message, so the UI can hide a toggle that would only duplicate it.

func RelativeAge added in v1.2.9

func RelativeAge(lastMs, nowMs int64) string

RelativeAge is the compact "last update" label on a sidebar row: "now", "3m", "2h", "5d". Deliberately terse — the row is 15rem wide and the title is the thing worth reading; the age only has to answer "is this the one I touched a minute ago or last week".

MIRRORED in fe/agents/shell/src/sidebarOrder.ts (relativeAge) — the island refreshes this label every 30s. Change both together.

func ReproKey added in v0.28.1

func ReproKey(shell string, interactive, short, resume bool) string

ReproKey names a reproduce variant by its four axes. Used as the map key in BuildReproVariants and mirrored by the front-end / reveal keys.

shell: "bash" | "powershell" | "cmd"
interactive: headless "h" vs interactive "i"
short: full path "full" vs basename "short"
resume: keep resume "res" vs fresh session "new"

func ShellReproduceBash added in v0.28.1

func ShellReproduceBash(binary string, argv, env []string, short bool, stdin string) string

ShellReproduceBash renders a POSIX/bash command: inline VAR='v' assignments on continuation lines, then the quoted command. short=true uses the binary basename (rely on PATH); otherwise the full path is rewritten to MSYS form (C:\… → /c/…) so it resolves in git-bash/msys2.

func ShellReproduceCmd added in v0.28.1

func ShellReproduceCmd(binary string, argv, env []string, short bool, stdin string) string

ShellReproduceCmd renders a cmd.exe command: one `set "KEY=v"` per line, then the command with double-quote quoting. NOTE: cmd.exe reproduction is best-effort — a JSON arg like --mcp-config contains double-quotes which must be doubled ("") inside a quoted arg, and cmd's quoting/escaping is finicky. PowerShell or bash reproduce such args more reliably.

func ShellReproducePwsh added in v0.28.1

func ShellReproducePwsh(binary string, argv, env []string, short bool, stdin string) string

ShellReproducePwsh renders a PowerShell command: one $env:KEY='v' statement per line, then the command with PowerShell single-quote quoting. The binary is invoked with the call operator `&` — a quoted string on its own is just a literal in PowerShell (it echoes, doesn't execute); `& 'path'` runs it.

func SidebarLastActiveMs added in v1.2.9

func SidebarLastActiveMs(sess session.Session, lc SessionLifecycleVM) int64

SidebarLastActiveMs is the newest activity we know of for a row: the session's persisted LastActive or the pool's in-memory one, whichever is later. The pool's moves on every turn event, the meta's only when it is saved, so taking the max keeps the label honest mid-turn.

func SidebarRowStatus added in v1.2.9

func SidebarRowStatus(sess session.Session, lc SessionLifecycleVM) string

SidebarRowStatus is the status a sidebar row renders, from the same inputs the dot uses.

func StreamJSONUserLine added in v1.2.9

func StreamJSONUserLine(text string) string

StreamJSONUserLine renders one stream-json user message — the exact line provider.Agent.Send writes to the subprocess stdin. Kept byte-identical to that envelope: reproducing a spawn means feeding the CLI what wick feeds it, not an approximation. Always a single line (json escapes any newline), which is what lets the bash/PowerShell heredocs below use a fixed delimiter.

func StripResumeArgv added in v0.28.1

func StripResumeArgv(providerType string, argv []string) []string

StripResumeArgv drops the resume-session tokens (per provider.ReproSpec) so the command starts a fresh session instead of continuing the logged one.

Types

type AgentsLayoutVM added in v0.10.0

type AgentsLayoutVM struct {
	Base             string
	ActivePage       string
	SidebarIDs       []string
	SidebarSessions  map[string]session.Session
	SidebarLifecycle map[string]SessionLifecycleVM
	SidebarLabels    map[string]string // session id → first user message preview
	ActiveSessionID  string
	IdleTimeoutMs    int64
	// Projects powers the sidebar Projects section + per-row project
	// chips. Keyed by project id; ProjectList is the display order.
	Projects    map[string]project.Project
	ProjectList []string
	// SharedOwners maps a project the viewer reaches but does not own to
	// its owner's name, for the sidebar's hover-only shared icon. Absent = theirs.
	SharedOwners map[string]string
	// SidebarOwner is the sidebar session list's scope: "me" (default)
	// shows only the caller's sessions, "all" everything they may see.
	// The two hrefs re-render the CURRENT page with ?sb= set — the toggle
	// is a pair of plain links, no script.
	SidebarOwner        string
	SidebarOwnerMeHref  string
	SidebarOwnerAllHref string
	// ScopedProjectID, when set, highlights the active project row +
	// drives the scoped breadcrumb.
	ScopedProjectID string
	// PinnedProjectID is the current user's pinned (personal-default)
	// project id, shown with a 📌 in the sidebar. Empty = none.
	PinnedProjectID string
	// FullBleed=true skips the layout's default px-6 py-6 padding
	// wrapper so the page can paint edge-to-edge. The workflow
	// editor needs the full viewport for its canvas; padded pages
	// (sessions, presets, …) leave this false.
	FullBleed bool
	// ShellAssetURL is the hashed bundle URL for the agents-shell island
	// (fe/agents/shell). AgentsLayout emits a <script type="module"> for
	// this URL so every agents page gets pin + drag-to-move sidebar
	// behaviors. Empty when the bundle has not been built yet (dev
	// machine before npm run build).
	ShellAssetURL string
	// AirouterVisible controls the "AI Router" sidebar entry. True when the
	// master switch is on AND the caller may access it (admin) — everyone
	// loses it when the AI routers are disabled.
	AirouterVisible bool

	// ProvidersVisible controls the "Providers" sidebar entry. True for
	// admins, and for anyone holding a manage tag on at least one
	// provider instance. A menu that opens onto an empty page is worse
	// than no menu, so the entry is hidden rather than shown-and-empty.
	ProvidersVisible bool
}

AgentsLayoutVM carries sidebar data for the full-screen Claude-style shell.

func (AgentsLayoutVM) NewSessionHref added in v0.14.21

func (vm AgentsLayoutVM) NewSessionHref() string

NewSessionHref is the "New session" nav target. When the sidebar is scoped to a project, it carries `?project=<id>` so the compose form auto-selects that project (mockup ②). Unscoped it carries ?view=classic: the bare landing is what "Open Team when I open Agents" sends to Team, and a click on New session from inside Agents must stay in Agents.

func (AgentsLayoutVM) ProjectIcon added in v0.14.21

func (vm AgentsLayoutVM) ProjectIcon(id string) string

ProjectIcon returns the emoji icon for a project id (📁 fallback).

func (AgentsLayoutVM) ProjectName added in v0.14.21

func (vm AgentsLayoutVM) ProjectName(id string) string

ProjectName returns the display name for a project id, or the id itself when unknown. Used by sidebar / session rows.

type AgentsNavItem added in v1.2.9

type AgentsNavItem struct {
	Href   string
	Label  string
	Active bool
}

AgentsNavItem is one row in the More group.

func AgentsMoreItems added in v1.2.9

func AgentsMoreItems(vm AgentsLayoutVM, user *entity.User) []AgentsNavItem

AgentsMoreItems returns the More group's rows in display order, already filtered by what this user may see.

Ordered by use-frequency: monitoring + everyday tools first, config/infra last.

type GateStatusVM

type GateStatusVM struct {
	Enabled bool
	Binary  string // absolute path (when enabled)
	Source  string // "sibling" | "embed" | "path" — debug aid
	Reason  string // why disabled, when Enabled=false
	Note    string // human-readable behavior summary; rendered as-is

	// PermissionMode is the active value of GateConfig.PermissionMode
	// ("on" | "bypass"). "bypass" means the spawner strips the hook
	// config and runs unguarded — UI surfaces that as a locked badge
	// so operators can't toggle individual provider hooks (no-op).
	PermissionMode string

	// BypassLocked is true when PermissionMode=="bypass". Retained for
	// templ branches that already key off this flag; equivalent to
	// PermissionMode == "bypass".
	BypassLocked bool
}

GateStatusVM is the umbrella "what is the gate doing right now?" card on the Providers page. Gate covers two sub-policies — the permission prompt and the ask_user MCP tool — so the VM carries both, plus the boot-time binary resolution state for the permission hook.

type LiveProcessVM added in v0.15.2

type LiveProcessVM struct {
	SessionID string
	AgentName string
	PID       int
	Lifecycle string // "spawning" | "working" | "idle" | "killed"
	Substate  string
}

LiveProcessVM is one row in the Active Processes panel on the Providers page.

type MCPClientStatusVM added in v0.13.0

type MCPClientStatusVM struct {
	ID          string // "claude", "cursor", "gemini", "codex", "claude-code"
	Label       string // "Claude Desktop", "Cursor", …
	Detected    bool   // client config dir exists on this host
	Installed   bool   // wick entry present in client's mcpServers
	Blocklisted bool   // user manually uninstalled — skip auto-install
	ConfigPath  string // absolute path to config file (for tooltip)
}

MCPClientStatusVM is one row in the MCP Wick card — one per detected MCP client (Claude Desktop, Cursor, Gemini CLI, etc.).

type MCPStatusVM added in v0.13.0

type MCPStatusVM struct {
	AppName string
	Clients []MCPClientStatusVM
}

MCPStatusVM is the aggregate for the MCP Wick card on the Providers page.

type ModelChoiceVM added in v0.34.0

type ModelChoiceVM struct {
	ID      string
	Label   string
	Default bool
	// Desc is a short human description shown under the model name in the
	// picker (like the CLIs' own /model menu). Empty when unknown.
	Desc string
	// Live marks a LIVE model SET rather than a single model: the picker shows
	// it as an expandable row (a 4th level) resolved by this row's ID — the
	// vendor filter itself stays server-side and is never exposed to the UI.
	Live bool
	// Caps is the vendor's raw "capabilities" object for this model (verbatim
	// JSON), used by the picker to render capability chips. Populated only for
	// live-set drill rows (they come from live discovery); nil for plain
	// registered models, which don't store caps. Raw so any vendor key survives.
	Caps json.RawMessage
}

ModelChoiceVM is one selectable model under a wick provider instance.

type ProviderCapVM added in v0.15.2

type ProviderCapVM struct {
	Used      int
	Max       int
	Unlimited bool
}

ProviderCapVM is the used / effective-max slot count for one provider instance, shown on its card as "<Used> / <Max>" — or "<Used> / ∞" when Unlimited (no finite cap at provider or global scope).

type ProviderChoiceVM

type ProviderChoiceVM struct {
	Type    string
	Name    string
	Version string
	// UsesAIRouter is true when this instance routes through the embedded
	// AI Router — the composer marks it with a badge.
	UsesAIRouter bool
	// Models lists this instance's selectable models — currently only
	// populated for wick (its custom-model registry). Empty for every
	// other provider type: the composer picker only descends to a 3rd
	// "model" level when there's more than one enabled entry here.
	Models []ModelChoiceVM
	// ModelsAt / ModelsSource stamp an omp/opencode live list (zero when
	// Models is the curated one): the picker shows "Updated … · files"
	// from the first paint.
	ModelsAt     time.Time
	ModelsSource string
}

ProviderChoiceVM is one healthy provider row — what the New Session picker offers. Disabled / unprobed / version-failed providers never reach the UI.

type SessionLifecycleVM

type SessionLifecycleVM struct {
	Lifecycle    string
	PID          int
	LastActiveMs int64
	// SubAgent is the busiest lifecycle among this session's sub-agents
	// ("working" / "spawning"), or "" when none of them is doing anything.
	// Rolled up from the pool because a child runs under its OWN session
	// id, which never appears in the sidebar — without this the row goes
	// dark the moment the leader idles, even though work continues.
	SubAgent string
}

SessionLifecycleVM is the per-row lifecycle snapshot the sessions list table renders. PID + LastActiveMs feed the countdown ring; Lifecycle is the colour key.

Directories

Path Synopsis
Package workflow holds the templ components for /tools/agents/workflows.
Package workflow holds the templ components for /tools/agents/workflows.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL