Documentation
¶
Overview ¶
Package web controls sessions on a running DSH Web instance. Unlike the one-shot CLI handoff, callers can persist a session ID before submitting input and reuse it for follow-ups and browser-launch retries.
Index ¶
- Constants
- func IsRunner(runner string) bool
- func NormalizeBrowser(raw string) (string, error)
- type Client
- func (c Client) Create(ctx context.Context, directory, sessionID string) (string, error)
- func (c Client) CreateWithOptions(ctx context.Context, opts CreateOptions) (CreatedSession, error)
- func (c Client) ModelCatalog(ctx context.Context) (ModelCatalog, error)
- func (c Client) Open(sessionID, browser string) error
- func (c Client) Send(ctx context.Context, sessionID, requestID, text string, noSubmit bool) error
- type CreateOptions
- type CreatedSession
- type FileStore
- type Listen
- type ModelCatalog
- type ModelCatalogFailure
- type ModelCatalogModel
- type ModelProviderGroup
- type ModelReasoning
- type ModelReasoningEffort
- type ModelSelection
- type Record
- type Result
- type SendOptions
- type Service
- type SessionOptions
- type State
- type Store
- type Warning
Constants ¶
const Runner = "dsh-web"
Variables ¶
This section is empty.
Functions ¶
func NormalizeBrowser ¶
Types ¶
type Client ¶
type Client struct {
Home string
ReadListen func() (Listen, error)
HTTPClient *http.Client
OpenBrowser func(rawURL, browser string) error
}
Client has injectable transport/discovery/opener boundaries for in-process tests. Its zero value uses DSH_HOME (or ~/.dsh), a bounded HTTP client, and the OS opener.
func (Client) Create ¶
Create registers a workspace and an empty session under a caller-persisted identity. A retry can reuse that blank session. No prompt is submitted and no browser is opened: the caller must durably save the returned ID first.
func (Client) CreateWithOptions ¶
func (c Client) CreateWithOptions(ctx context.Context, opts CreateOptions) (CreatedSession, error)
CreateWithOptions initializes a reserved session and verifies the Host accepted an explicit model before any caller can submit input or open the browser.
func (Client) ModelCatalog ¶
func (c Client) ModelCatalog(ctx context.Context) (ModelCatalog, error)
ModelCatalog reads the live registry through the existing authenticated Web API. Provider failures are data, not a reason to discard healthy groups.
type CreateOptions ¶
type CreateOptions struct {
Workspace string
SessionID string
ModelSelection *ModelSelection
}
CreateOptions describes a reserved blank session. ModelSelection, if present, initializes only this session; it never calls session/selectModel.
type CreatedSession ¶
type CreatedSession struct {
SessionID string `json:"sessionId"`
ModelSelection *ModelSelection `json:"modelSelection,omitempty"`
}
CreatedSession echoes the Host's installed initial selection when requested. The echo prevents an older Host silently ignoring an explicit override.
type FileStore ¶
FileStore uses <Dir>/<key>/<FileName>. The caller chooses Dir; there is no implicit Marcus, agent-run, or global home. An empty FileName means session.json. Existing flat binding records remain readable, including non-DSH runner pins.
func (FileStore) WithSession ¶
WithSession holds a filesystem lock across network operations AND intermediate saves. Distinct Service/FileStore objects and separate processes share the same lock; an OS-released lock is not mistaken for a completed checkpoint.
type Listen ¶
Listen contains discovery credentials. Never persist or log Token in a consumer's session binding; read the current record on each operation.
type ModelCatalog ¶
type ModelCatalog struct {
Default ModelSelection `json:"default"`
RoutableProviders []string `json:"routableProviders"`
Groups []ModelProviderGroup `json:"groups"`
Failures []ModelCatalogFailure `json:"failures"`
}
ModelCatalog describes this running DSH deployment, including partial failures. A listed model is selectable only when Unavailable is empty. Listing does not create a session, open a browser, or save global/default configuration.
type ModelCatalogFailure ¶
type ModelCatalogModel ¶
type ModelCatalogModel struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Reasoning *ModelReasoning `json:"reasoning,omitempty"`
}
type ModelProviderGroup ¶
type ModelProviderGroup struct {
ID string `json:"id"`
Name string `json:"name"`
Models []ModelCatalogModel `json:"models"`
}
type ModelReasoning ¶
type ModelReasoning struct {
Efforts []ModelReasoningEffort `json:"efforts"`
DefaultEffort string `json:"defaultEffort,omitempty"`
}
type ModelReasoningEffort ¶
type ModelSelection ¶
type ModelSelection struct {
Provider string `json:"provider"`
Model string `json:"model"`
ReasoningEffort string `json:"reasoningEffort,omitempty"`
}
ModelSelection identifies an exact DSH provider route. Empty ReasoningEffort follows that model's adapter default; it is not a Codex effort alias.
type Record ¶
Record permits multiple durable checkpoints while its store holds a session lock. Implementations must leave the last committed checkpoint intact on error.
type Result ¶
type Result struct {
SessionID string
Created bool // a provider session was created during this operation
Accepted bool // submitted input or a draft was accepted (not agent completion)
BrowserOpened bool // this operation opened a browser
Warnings []Warning
}
Result distinguishes input admission from browser opening. A browser failure after admission is a warning, not a delivery error. Libraries never print logs.
type SendOptions ¶
type Service ¶
Service owns DSH Web session lifecycle. It never starts a terminal, agent-run, dsh CLI, or readiness probe. Client transport and Store are independently injectable; separate services using the same Store share durable checkpoints.
func (Service) Open ¶
Open only opens an existing, created DSH session. It never creates a provider session, submits/retries pending input, or consults a terminal runner.
func (Service) OpenSession ¶
OpenSession creates/reuses a caller-keyed DSH conversation, admits its first input once, and opens the selected browser unless NoOpen. Repeated calls do not resubmit an admitted initial prompt. Use Send for a subsequent message.
type SessionOptions ¶
type SessionOptions struct {
// ModelSelection is pinned only when a new binding is reserved.
ModelSelection *ModelSelection
Key string
Workspace string
Browser string
Prompt string
NoSubmit bool
NoOpen bool
}
SessionOptions identifies one caller-owned conversation and its first input. Workspace/Browser are pinned on first creation; later preference changes do not silently relocate an existing session. NoOpen suppresses automatic browser opening, but never changes prompt delivery semantics.
type State ¶
type State struct {
InitialModelSelection *ModelSelection `json:"initial_model_selection,omitempty"`
Runner string `json:"runner"`
Browser string `json:"browser,omitempty"`
Workspace string `json:"workspace,omitempty"`
DSHSessionID string `json:"dsh_session_id,omitempty"`
Created bool `json:"created,omitempty"`
InitialDelivered bool `json:"initial_delivered,omitempty"`
BrowserOpened bool `json:"browser_opened,omitempty"`
PendingRequestID string `json:"pending_request_id,omitempty"`
PendingHash string `json:"pending_hash,omitempty"`
PendingPrompt string `json:"pending_prompt,omitempty"`
PendingNoSubmit bool `json:"pending_no_submit,omitempty"`
}
State is a durable DSH conversation binding, not a business conversation. JSON names retain compatibility with the original Marcus binding records. Runner is a discriminator so a shared storage location cannot turn an existing terminal conversation into a DSH session. No launch tokens belong here.
type Store ¶
type Store interface {
Read(context.Context, string) (State, bool, error)
WithSession(context.Context, string, func(Record) error) error
}
Store separates application-chosen persistence from DSH orchestration. WithSession serializes a key across all instances sharing the same storage; Read observes the last atomic checkpoint without taking a delivery lock.