Documentation
¶
Overview ¶
Package client is the reference client for the dcode protocol.
It is the first consumer of the contract. If the API feels awkward here, the protocol is what needs fixing, not this package.
It holds no session state: only a read position, which is what lets a client die and rejoin without the session noticing.
Index ¶
- type Client
- func (c *Client) CreateSession(ctx context.Context, req protocol.CreateSessionRequest) (protocol.Session, error)
- func (c *Client) DeleteSession(ctx context.Context, id string) error
- func (c *Client) Exec(ctx context.Context, id, command string) error
- func (c *Client) GetSession(ctx context.Context, id string) (protocol.Session, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) Interrupt(ctx context.Context, id string) error
- func (c *Client) ListSessions(ctx context.Context) ([]protocol.Session, error)
- func (c *Client) RenameSession(ctx context.Context, id, name string) error
- func (c *Client) Resolve(ctx context.Context, id, approvalID string, d protocol.ApprovalDecision) error
- func (c *Client) SetMode(ctx context.Context, id, mode string) error
- func (c *Client) Steer(ctx context.Context, id, text string) error
- func (c *Client) Submit(ctx context.Context, id, text string, images ...protocol.TurnImage) error
- func (c *Client) Subscribe(ctx context.Context, id string, from uint64) (<-chan protocol.Event, <-chan error)
- func (c *Client) Undo(ctx context.Context, id string) (protocol.UndoResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a dcode daemon over a Unix socket.
func (*Client) CreateSession ¶
func (c *Client) CreateSession(ctx context.Context, req protocol.CreateSessionRequest) (protocol.Session, error)
CreateSession opens a session.
func (*Client) DeleteSession ¶
DeleteSession closes a session.
func (*Client) Exec ¶ added in v0.6.0
Exec runs a command the person typed, outside a turn.
It blocks until the command finishes. The output arrives on the event stream, not in the response: a client that disconnected mid-command and came back sees exactly what one that stayed sees.
func (*Client) GetSession ¶
GetSession returns one session.
func (*Client) ListSessions ¶
ListSessions returns live sessions.
func (*Client) RenameSession ¶ added in v0.2.0
RenameSession names a conversation, live or not.
An empty name restores the title derived from the first question. That is the way back rather than a second call for undoing: one operation with a meaningful zero value is one thing to get right.
func (*Client) SetMode ¶ added in v0.7.0
SetMode switches the session behavioural mode: plan, assist or auto.
The change is not in the response. It arrives on the event stream as session.mode_changed, so a client that was not attached when it happened still learns the mode from the log rather than from a call it missed.
func (*Client) Steer ¶
Steer hands a running turn something the person said, without ending it.
Refused when no turn is running: a correction to a turn that already finished is a new message, and quietly turning it into one would let the person believe an urgent instruction landed when it never did.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, id string, from uint64) (<-chan protocol.Event, <-chan error)
Subscribe streams events from `from`, reconnecting on its own.
Reconnection resumes at the last sequence seen plus one, which is why the read position is the only state a client keeps. Reconnecting therefore behaves exactly like connecting for the first time.