worksession

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const WorkSessionEnvVar = "ALPACON_WORK_SESSION"

WorkSessionEnvVar is the environment variable consulted as a fallback when no --work-session flag is given. Resolution order: flag > env var > config.

Variables

View Source
var WorkSessionCmd = &cobra.Command{
	Use:     "work-session",
	Aliases: []string{"session"},
	Short:   "Create and manage work sessions",
	Long: `Create, inspect, and manage work sessions.

Work sessions are approval-gated units that authorize access-path operations on Alpacon.

Gated operations (require an active WorkSession under interactive auth):
  websh—'alpacon websh' (browser-based terminal)
  command—'alpacon exec' (remote command execution)
  webftp—'alpacon cp' (file transfer)
  tunnel—'alpacon tunnel' (port forwarding)
  sudo—'Privilege elevation' on Alpacon web (binding op: pending/approved/active allowed)

Bypass: Token auth (API token or Service token) skips the requirement for 'exec', 'cp',
'edit', and 'websh SERVER COMMAND', but cannot run an interactive 'websh' terminal,
'websh watch', 'websh join', 'websh invite', or 'tunnel'—those need 'alpacon login'
without -t.

Lifecycle:  pending → approved → active → complete | expired | revoked  (pending only → rejected | cancelled)

Error codes returned when a session check fails:
  work_session_required           no session selected for this shell
  work_session_not_active         session not active (pending, approved, completed, revoked, or cancelled)
  work_session_expired            session has expired
  work_session_scope_not_allowed  operation not in session scopes
  work_session_server_not_allowed target server not in session
  work_session_assignee_mismatch  session assigned to another principal
  work_session_agent_session_required  the CLI runs under an AI agent; use an agent session
  work_session_not_usable         session is no longer usable

Run 'alpacon whoami' to check your WorkSession requirement and active session.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		return utils.RequireSubcommand(cmd, "Approval and rejection happen in the Alpacon console (web) or Slack.")
	},
}

Functions

func MarkActive

func MarkActive(rows []wsapi.WorkSessionAttributes, activeUUID string)

MarkActive puts "*" in the Active column of the row whose ID is activeUUID unless that session has ended, since one ended outside this CLI stays in config. Safe with an empty activeUUID or slice.

func Resolve

func Resolve(flagValue string) (string, error)

Resolve returns the effective work-session UUID using flag > env var > config priority.

func ResolveOrExit added in v1.7.0

func ResolveOrExit(flagValue string) string

ResolveOrExit resolves the work-session UUID and exits on error.

func RunComplete added in v1.16.0

func RunComplete(ac *client.AlpaconClient, id string) (bool, error)

RunComplete completes the session; see endSession.

func RunCurrent

func RunCurrent(ac *client.AlpaconClient) (string, *wsapi.WorkSession, error)

RunCurrent returns the active work-session UUID and its server-side details. Returns ("", nil, nil) when nothing is set, or (uuid, nil, err) if set but unreachable.

func RunRevoke added in v1.16.0

func RunRevoke(ac *client.AlpaconClient, id string) (bool, error)

RunRevoke revokes the session; see endSession.

func RunUnset

func RunUnset() error

RunUnset clears the active work-session for the current workspace. Idempotent — no error when nothing is set.

func RunUse

func RunUse(ac *client.AlpaconClient, uuid string) (string, error)

RunUse validates the work-session via the server, then stores it in config. Returns the human-readable description on success.

func RunUseSession added in v1.6.0

func RunUseSession(ac *client.AlpaconClient, uuid string) (*wsapi.WorkSession, error)

RunUseSession validates the work-session via the server, then stores it in config.

func WriteCurrentRaw added in v1.16.0

func WriteCurrentRaw(ac *client.AlpaconClient, uuid string) error

func WriteCurrentTable added in v1.16.0

func WriteCurrentTable(ac *client.AlpaconClient, uuid string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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