Documentation
¶
Overview ¶
Package socialbrowser manages the persistent stealth Chromium used by the Social Media agent. It wraps cloak-go to provide a singleton browser with a stable fingerprint seed and user-data-dir so cookies, localStorage, and login sessions survive across restarts.
Index ¶
- Constants
- type Autopilot
- type Manager
- func (m *Manager) Acquire(ctx context.Context, owner string, timeout time.Duration) error
- func (m *Manager) Close()
- func (m *Manager) DebugURL() (string, error)
- func (m *Manager) Holder() string
- func (m *Manager) ProfileDir() string
- func (m *Manager) Release(owner string)
- func (m *Manager) Renew(owner string) bool
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) Status() (string, string)
- func (m *Manager) Stop()
- func (m *Manager) TryReenter(owner string) bool
- func (m *Manager) WaitForRunning(timeout time.Duration) bool
- type State
Constants ¶
const LeaseTTL = 5 * time.Minute
LeaseTTL is how long a lease survives without a refresh from its owner. Every browser action the owner runs bumps the deadline, so a long publish keeps its lease as long as it is still touching the browser.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Autopilot ¶
type Autopilot struct {
// contains filtered or unexported fields
}
Autopilot manages the Social Media agent's autonomous scheduling. When enabled, it creates a recurring cron job that triggers the social-media-manager role to check inbox, learn platforms, and manage accounts.
func NewAutopilot ¶
NewAutopilot creates an Autopilot tied to the store and config.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns one persistent social media browser. Only one controller may drive the browser at a time; a mutex serializes start/stop/control calls.
func New ¶
func New() *Manager
New creates a Manager. The profile directory lives under the Antares home.
func (*Manager) Acquire ¶
Acquire takes the exclusive lease for owner. If another owner already holds an unexpired lease, waits up to timeout for it to release or expire. Returns the current holder in the busy error message so the caller can tell the agent whose turn it is.
func (*Manager) Close ¶
func (m *Manager) Close()
Close stops the browser if running. Called on shutdown.
func (*Manager) DebugURL ¶
DebugURL returns the CDP HTTP endpoint of the launched social browser (e.g. "http://127.0.0.1:41234"), or an error if the browser is not running yet. Callers dial /json/version off this URL to get the WebSocket URL and attach as a controller.
func (*Manager) ProfileDir ¶
ProfileDir returns the persistent browser profile path.
func (*Manager) Release ¶
Release drops the lease if owner holds it. Wrong-owner releases are a no-op — a busy caller cannot yank the tab from the real holder by asking to release.
func (*Manager) Renew ¶
Renew extends the lease if owner holds it. Every browser action the owner runs refreshes the deadline, so a long-running flow does not have its tab stolen by the expiry sweep while it is still working.
func (*Manager) Start ¶
Start launches the persistent browser if it is not already running. This is synchronous but may take up to 45 seconds on first launch (binary download + verification). The caller should run it in a goroutine.
func (*Manager) TryReenter ¶
TryReenter reports whether owner can act on the browser right now without blocking: either it already holds the lease (refreshing it), or the lease is free (and it does NOT take it — the caller decides whether to acquire). Used by the browser tool to distinguish "same session re-entering its held lease" from "some other session peeking".