Documentation
¶
Index ¶
- Variables
- func InheritCredentials(fromHome, toHome string) ([]string, error)
- func RedactedID(value string) string
- type Client
- func (c *Client) AttachSession(ctx context.Context, id string) (Session, error)
- func (c *Client) Capabilities() []string
- func (c *Client) Close() error
- func (c *Client) CreateSession(ctx context.Context, options CreateSessionOptions) (Session, error)
- func (c *Client) DetachInstance() (Instance, bool)
- func (c *Client) Notify(req protocol.RawRequest) error
- func (c *Client) Reconnect(ctx context.Context) error
- func (c *Client) Request(ctx context.Context, req protocol.RawRequest) (protocol.ServerFrame, error)
- func (c *Client) RequestCapability(ctx context.Context, capability string, req protocol.RawRequest) (protocol.ServerFrame, error)
- func (c *Client) RequireCapability(capability string) error
- func (c *Client) SessionID() string
- func (c *Client) SetSessionID(sessionID string)
- func (c *Client) State() State
- func (c *Client) Subscribe(sessionID string) *Subscription
- func (c *Client) Supports(capability string) bool
- type ConnectOptions
- type CreateSessionOptions
- type Event
- type Instance
- type LaunchError
- type LaunchErrorCode
- type LaunchOptions
- type ModelInfo
- type Observation
- type Observer
- type Options
- type PermissionRequest
- type ReasoningDelta
- type ReconnectPolicy
- type SendOptions
- type Session
- type SessionInfo
- type State
- type Subscription
- type TextDelta
- type TokenUsage
- type ToolDone
- type ToolInputDelta
- type ToolStart
- type TurnDone
- type TypedEvent
- type TypedEventStream
- type UnknownEvent
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("jcode client closed") ErrDisconnected = errors.New("jcode client disconnected") ErrSubscriberOverflow = errors.New("jcode event subscriber fell behind") ErrCapability = errors.New("jcode capability is not supported") ErrResume = errors.New("jcode session resume failed") )
Functions ¶
func InheritCredentials ¶
InheritCredentials shares rotating auth files and copies mutable config.
func RedactedID ¶
RedactedID can be used by applications to correlate a session without placing the raw identifier in logs.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func Connect ¶
func Connect(ctx context.Context, options ConnectOptions) (*Client, error)
Connect attaches to a running local Jcode harness. It never starts or stops a process, and closing the returned client only closes its socket.
func Launch ¶
func Launch(ctx context.Context, options LaunchOptions) (*Client, error)
Launch starts a private bridge and connects a Client to it. Any failure after the process starts performs best-effort teardown before returning.
func NewClient ¶
NewClient starts reading from t and completes the protocol hello handshake. The transport is closed if the handshake fails. Reconnect is always explicit.
func (*Client) AttachSession ¶
func (*Client) Capabilities ¶
Capabilities returns the server-advertised capabilities in stable order. The returned slice is a copy and may be modified by the caller.
func (*Client) CreateSession ¶
func (*Client) DetachInstance ¶ added in v0.1.2
DetachInstance transfers ownership of a private runtime from the client to the caller. After a successful detach, closing the client only closes its protocol transport. The returned Instance remains responsible for the private process, daemon, and SDK-owned state until Shutdown is called.
This is the safe-run boundary for applications that let a worker client come and go while a session owner supervises the runtime independently.
func (*Client) Notify ¶ added in v0.1.3
func (c *Client) Notify(req protocol.RawRequest) error
Notify writes a request without waiting for a correlated request-level reply. Use this for protocol operations whose result is delivered as an event.
func (*Client) Reconnect ¶
Reconnect explicitly reconnects and, when configured, safely reattaches the remembered session. In-flight requests are never retried.
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, req protocol.RawRequest) (protocol.ServerFrame, error)
Request sends a raw request. It never retries, preserving caller control for non-idempotent operations such as send_message.
func (*Client) RequestCapability ¶
func (c *Client) RequestCapability(ctx context.Context, capability string, req protocol.RawRequest) (protocol.ServerFrame, error)
RequestCapability sends req only when the server advertised capability. Unlike Request, this performs a local check and never writes an unsupported request to the wire.
func (*Client) RequireCapability ¶
RequireCapability returns a stable error before a capability-gated request.
func (*Client) SessionID ¶
SessionID returns the caller-selected identity retained across reconnects.
func (*Client) SetSessionID ¶
func (*Client) Subscribe ¶
func (c *Client) Subscribe(sessionID string) *Subscription
Subscribe receives asynchronous events. A full buffer terminates only that subscription, keeping the reader bounded and other callers live.
type ConnectOptions ¶
ConnectOptions controls attaching to an already-running local harness.
type CreateSessionOptions ¶
type CreateSessionOptions struct {
WorkingDir string
}
type Event ¶
type Event struct {
Frame protocol.ServerFrame
Kind string
Fields json.RawMessage
}
Event is a server event with its stable kind and forward-compatible fields.
type Instance ¶
LaunchInstance is the ownership handle for a private runtime.
func LaunchInstance ¶
func LaunchInstance(options LaunchOptions) (Instance, error)
LaunchInstance starts an isolated bridge without connecting the protocol client. This is useful when the caller needs to control connection setup.
type LaunchError ¶
type LaunchError struct {
Code LaunchErrorCode
Binary string
Stderr string
Err error
}
LaunchError reports a failure in private-instance startup or connection.
func (*LaunchError) Error ¶
func (e *LaunchError) Error() string
func (*LaunchError) Unwrap ¶
func (e *LaunchError) Unwrap() error
type LaunchErrorCode ¶
type LaunchErrorCode string
LaunchErrorCode identifies the phase which failed while starting an instance. Callers can use errors.As to inspect a LaunchError without parsing its human-readable message.
const ( LaunchMissingBinary LaunchErrorCode = "missing_binary" LaunchStartupFailed LaunchErrorCode = "startup_failed" LaunchStartupTimeout LaunchErrorCode = "startup_timeout" LaunchHandshakeFailed LaunchErrorCode = "handshake_failed" LaunchTransportFailed LaunchErrorCode = "transport_failed" )
type LaunchOptions ¶
type LaunchOptions struct {
// JcodeHome is a persistent state directory. Empty creates a temporary
// SDK-owned directory which is removed by Shutdown.
JcodeHome string
WorkingDir string
// InheritLogins is tri-state so its nil zero value preserves the SDK
// behavior shared by the Rust and TypeScript SDKs: inherit by default.
InheritLogins *bool
Binary string
Env map[string]string
StartupTimeout time.Duration
CleanupTimeout time.Duration
InheritStderr bool
// ClientOptions controls the protocol client created by Launch.
ClientOptions Options
// Observer receives redacted startup lifecycle metadata. If set, it is also
// used by the protocol client created by Launch unless ClientOptions.Observer
// is explicitly provided.
Observer Observer
}
LaunchOptions controls a private jcode instance.
type Observation ¶
Observation contains only metadata. It intentionally excludes request fields, prompts, credentials, server messages, and session identifiers.
type Observer ¶
type Observer interface{ Observe(Observation) }
Observer receives redacted lifecycle metadata. Implementations must be safe for concurrent calls and should return quickly. Request lifecycle events are emitted as request_write_start, request_write_complete, request_reply, or request_timeout, so a missing phase identifies the stalled boundary without exposing payloads, credentials, or identifiers.
type Options ¶
type Options struct {
ClientName string
MaxFrameSize int
EventBuffer int
RequestBuffer int
// RequestTimeout bounds each request when the caller's context has no
// earlier deadline. Non-positive values use the 30-second default.
RequestTimeout time.Duration
SessionID string
Reconnect ReconnectPolicy
Observer Observer
}
Options controls client construction and event buffering.
type PermissionRequest ¶
type ReasoningDelta ¶
type ReconnectPolicy ¶
type SendOptions ¶
type Session ¶
type Session struct {
Info SessionInfo
ID string
// contains filtered or unexported fields
}
type SessionInfo ¶
type SessionInfo struct {
ID string `json:"session_id"`
WorkingDir string `json:"working_dir,omitempty"`
Title string `json:"title,omitempty"`
Status string `json:"status"`
TranscriptBytes uint64 `json:"transcript_bytes,omitempty"`
Archived bool `json:"archived,omitempty"`
ArchivedAtMS uint64 `json:"archived_at_ms,omitempty"`
}
SessionInfo is the stable session metadata returned by the harness API.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) Close ¶
func (s *Subscription) Close()
type TokenUsage ¶
type ToolInputDelta ¶
type TypedEvent ¶
type TypedEvent interface {
// contains filtered or unexported methods
}
type TypedEventStream ¶
type TypedEventStream struct {
// contains filtered or unexported fields
}
func (*TypedEventStream) Close ¶
func (s *TypedEventStream) Close()
func (*TypedEventStream) Next ¶
func (s *TypedEventStream) Next(ctx context.Context) (TypedEvent, error)
type UnknownEvent ¶
type UnknownEvent struct {
Kind string
Fields json.RawMessage
}