sessionworkspace

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sessionworkspace stores a per-session "workspace": a set of ephemeral connector instances cloned from a base module (httprest, custom API defs, …). It backs the wick_session_workspace MCP tool and the session Config tab.

A session instance is a throwaway clone: it has its own id, a base module key, a label, and a config map — exactly the configurable fields of the base module, filled in for this session only. It shows up in wick_list / wick_get / wick_execute only when the caller passes the owning session_id, behaving like a brand-new connector that lives and dies with the session dir.

Secret config values are stored as wick_cenc_ MASTER tokens (system decryptable only) — callers encrypt BEFORE Set/Add; this package never sees or persists plaintext secrets. The whole file dies with the session, which is the intended instance lifetime.

Index

Constants

View Source
const IDPrefix = "sw_"

IDPrefix marks a connector id as a session-workspace instance, so MCP handlers can route it to the workspace resolver instead of the DB.

Variables

This section is empty.

Functions

func IsInstanceID

func IsInstanceID(id string) bool

IsInstanceID reports whether an id refers to a session-workspace instance (vs a real DB connector row).

func NewInstanceID

func NewInstanceID() string

NewInstanceID mints a fresh session-instance id.

func Remove

func Remove(layout agentconfig.Layout, sessionID, instanceID string) (bool, error)

Remove deletes an instance. ok=false when it wasn't there.

func SetConfig

func SetConfig(layout agentconfig.Layout, sessionID, instanceID string, values map[string]string) error

SetConfig merges config values into an instance and persists. Keys not present in values are kept. Returns os.ErrNotExist-wrapped error when the instance is gone.

func SetLabel added in v0.18.0

func SetLabel(layout agentconfig.Layout, sessionID, instanceID, label string) error

SetLabel renames an instance. Returns an os.ErrNotExist-wrapped error when the instance is gone. Empty label is rejected — the caller should fall back to a default before calling.

Types

type Instance

type Instance struct {
	ID      string `json:"id"`       // "sw_<uuid>"
	BaseKey string `json:"base_key"` // module key it clones (e.g. "httprest")
	Label   string `json:"label"`
	// Config holds the instance's config field values. Secret fields are
	// wick_cenc_ master tokens; non-secret fields are plaintext.
	Config map[string]string `json:"config"`
	// CreatedBy is "ai" (added via the MCP tool) or "user" (added in the
	// Config tab) — drives the "agent added this, please fill it" notice.
	CreatedBy string `json:"created_by,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
}

Instance is one ephemeral connector clone scoped to a session.

func Add

func Add(layout agentconfig.Layout, sessionID string, in Instance) (Instance, error)

Add appends a new instance and persists it. The id is minted here if empty. Returns the stored instance (with its final id).

func Get

func Get(layout agentconfig.Layout, sessionID, instanceID string) (Instance, bool, error)

Get returns one instance by id. ok=false when it doesn't exist.

func List

func List(layout agentconfig.Layout, sessionID string) ([]Instance, error)

List returns all instances in a session, in stored order.

type Workspace

type Workspace struct {
	Instances []Instance `json:"instances"`
}

Workspace is the full per-session document.

func Load

func Load(layout agentconfig.Layout, sessionID string) (Workspace, error)

Load reads the full workspace for one session. A missing file is an empty workspace, not an error.

Jump to

Keyboard shortcuts

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