socialbrowser

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NewAutopilot(db store.Store, cfg *config.Config) *Autopilot

NewAutopilot creates an Autopilot tied to the store and config.

func (*Autopilot) Sync

func (a *Autopilot) Sync(ctx context.Context) error

Sync ensures the social media autopilot cron job exists when enabled, and removes it when disabled. Call this on startup and after config reload.

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

func (m *Manager) Acquire(ctx context.Context, owner string, timeout time.Duration) error

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

func (m *Manager) DebugURL() (string, error)

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) Holder

func (m *Manager) Holder() string

Holder returns the current lease owner (or "" when free).

func (*Manager) ProfileDir

func (m *Manager) ProfileDir() string

ProfileDir returns the persistent browser profile path.

func (*Manager) Release

func (m *Manager) Release(owner string)

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

func (m *Manager) Renew(owner string) bool

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

func (m *Manager) Start(ctx context.Context) error

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) Status

func (m *Manager) Status() (string, string)

Status returns the current browser state and any error detail.

func (*Manager) Stop

func (m *Manager) Stop()

Stop closes the browser if it is running.

func (*Manager) TryReenter

func (m *Manager) TryReenter(owner string) bool

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".

func (*Manager) WaitForRunning

func (m *Manager) WaitForRunning(timeout time.Duration) bool

WaitForRunning polls the browser state until it is running or the timeout expires. Used by API handlers that started the browser asynchronously.

type State

type State string

State describes the browser's current runtime status.

const (
	StateDisabled    State = "disabled"
	StateUnavailable State = "unavailable"
	StateStopped     State = "stopped"
	StateStarting    State = "starting"
	StateRunning     State = "running"
	StateError       State = "error"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL