Documentation
¶
Overview ¶
Package mobilebridge exposes the mobile session boundary as a small, handle-based JSON API for native hosts. It deliberately has no UI or JNI dependency: the JNI entry points live in cmd/golder-mobile, and the service can be tested on a desktop with a fake backend.
Index ¶
- Constants
- func CatalogJSON() (string, error)
- type Backend
- type Catalog
- type CatalogProvider
- type Config
- type Factory
- type Service
- func (s *Service) Cancel(handle int) error
- func (s *Service) CatalogJSON() (string, error)
- func (s *Service) Close(handle int) error
- func (s *Service) LastError() string
- func (s *Service) ModelsJSON(providerName, baseURL, apiKey, cacheDir string, refresh bool) (string, error)
- func (s *Service) Open(configJSON string) (handle int, err error)
- func (s *Service) PauseForTakeover(handle int) error
- func (s *Service) PollJSON(handle, max int) (string, error)
- func (s *Service) ResumeAfterTakeover(handle int) error
- func (s *Service) SnapshotJSON(handle int) (string, error)
- func (s *Service) Start(handle int, prompt string) error
- func (s *Service) TakeoverReady(handle int) (bool, error)
Constants ¶
const Version = "0.1"
Version identifies the bridge ABI. A host must treat a mismatch as unsupported rather than guessing at field semantics.
Variables ¶
This section is empty.
Functions ¶
func CatalogJSON ¶
CatalogJSON returns the chat-provider catalog from the same registry the TUI uses. Decision-only endpoints are omitted because they cannot serve a turn.
Types ¶
type Backend ¶
type Backend interface {
Start(prompt string) error
PollJSON(max int) (string, error)
SnapshotJSON() (string, error)
Cancel()
Close() error
}
Backend is one live conversation. The Android implementation wraps mobileagent.Session; tests use a fake.
type Catalog ¶
type Catalog struct {
Providers []CatalogProvider `json:"providers"`
DefaultProvider string `json:"defaultProvider"`
DefaultModel string `json:"defaultModel"`
}
Catalog is the provider/model/thinking data shown by a native host.
type CatalogProvider ¶
type CatalogProvider struct {
Name string `json:"name"`
DefaultModel string `json:"defaultModel"`
Models []string `json:"models"`
Reasoning []string `json:"reasoning"`
}
CatalogProvider is one provider choice for the native picker. Models is intentionally small: it contains the registry default, and the host may add a custom model id. Remote model discovery can fill this list later without changing the picker contract.
type Config ¶
type Config struct {
Workspace string `json:"workspace"`
Model string `json:"model"`
Provider string `json:"provider,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
Protocol string `json:"protocol,omitempty"`
APIKey string `json:"apiKey,omitempty"`
SystemPrompt string `json:"systemPrompt,omitempty"`
ContextWindow int `json:"contextWindow,omitempty"`
// StateDir, when set, enables local session persistence under
// StateDir/sessions. SessionID selects an existing session; empty generates
// one. The host supplies an app-private directory.
StateDir string `json:"stateDir,omitempty"`
SessionID string `json:"sessionId,omitempty"`
// GitAuthor* provide the commit identity. GitToken is used only for HTTPS
// remotes. Empty token leaves clone/fetch/push unauthenticated (or denied by
// the remote); it never appears in output.
GitAuthorName string `json:"gitAuthorName,omitempty"`
GitAuthorEmail string `json:"gitAuthorEmail,omitempty"`
GitToken string `json:"gitToken,omitempty"`
// AllowNetworkGit is a session capability, not a per-call decision. When
// false, git clone/fetch/push fail closed; local Git still works.
AllowNetworkGit bool `json:"allowNetworkGit,omitempty"`
// ThinkingLevel is the selected reasoning level (low, medium, high, max).
ThinkingLevel string `json:"thinkingLevel,omitempty"`
// PermissionMode is one of read-only, ask, auto, full-access.
PermissionMode string `json:"permissionMode,omitempty"`
// AndroidUseEndpoint is the app-private loopback endpoint for the Phase 1
// AccessibilityService. Empty leaves android_use out of the catalog.
AndroidUseEndpoint string `json:"androidUseEndpoint,omitempty"`
// AndroidUsePhase2 enables the separately consented background-display
// surface. It is ignored unless AndroidUseEndpoint is also present.
AndroidUsePhase2 bool `json:"androidUsePhase2,omitempty"`
// DebugLog is an optional host-only diagnostic path. The Android backend
// appends loop event types and terminal errors (never prompts or secrets)
// to it. Empty disables the log.
DebugLog string `json:"debugLog,omitempty"`
}
Config is the host-owned setup for one mobile conversation. Secrets are accepted but never echoed in errors or events.
type Factory ¶
Factory builds a backend from host config. It must not expose the API key in an error.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the handle registry behind the JNI/C ABI. Operations on different handles proceed independently; operations on one handle are serialized so a close cannot race an in-flight poll.
func NewService ¶
NewService builds a registry around factory.
func (*Service) CatalogJSON ¶
CatalogJSON exposes the provider/model catalog without opening a session.
func (*Service) Close ¶
Close drops handle and closes its backend. It is idempotent for an unknown handle so a host's lifecycle cleanup can run twice.
func (*Service) ModelsJSON ¶
func (s *Service) ModelsJSON(providerName, baseURL, apiKey, cacheDir string, refresh bool) (string, error)
ModelsJSON returns a phone cache snapshot immediately when refresh is false, or performs a network refresh when refresh is true. A stale cache survives a failed refresh and is returned with Error set.
func (*Service) Open ¶
Open decodes configJSON, builds a backend, and returns a handle > 0. A failure returns 0 and records LastError.
func (*Service) PauseForTakeover ¶ added in v1.5.104
PauseForTakeover latches the host-only admission barrier without waiting for in-flight calls. Poll TakeoverReady before allowing the person to interact.
func (*Service) ResumeAfterTakeover ¶ added in v1.5.104
ResumeAfterTakeover is invoked only by the local host after handback.
func (*Service) SnapshotJSON ¶
SnapshotJSON returns one consistent state snapshot.