Documentation
¶
Index ¶
- func FindExecutable(ctx context.Context) (string, error)
- func PersistAccountFingerprint(sourceDirectory string, targetDirectory string) error
- func RemoveStaleProfiles() (int, error)
- type LoginOptions
- type LoginResult
- type LoginVerification
- type Options
- type ProtectedResponse
- type StartupStage
- type State
- type Worker
- func (worker *Worker) Close() error
- func (worker *Worker) Proof(ctx context.Context, digest string, prompt string) (string, error)
- func (worker *Worker) ProtocolHeaders(ctx context.Context) (http.Header, error)
- func (worker *Worker) SendProtected(ctx context.Context, rawURL string, headers http.Header, body []byte) (*ProtectedResponse, error)
- func (worker *Worker) State() State
- func (worker *Worker) StorageCookies(ctx context.Context) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindExecutable ¶
FindExecutable 定位源码环境或 Release 自带的 Camoufox
func PersistAccountFingerprint ¶
PersistAccountFingerprint 将隔离登录指纹保存到账户目录
func RemoveStaleProfiles ¶ added in v0.1.7
RemoveStaleProfiles 删除创建进程已退出的临时 profile 并返回删除数量
Types ¶
type LoginOptions ¶
type LoginOptions struct {
ExecutablePath string
Directory string
Locale string
Timezone string
Proxy string
ProxyBypass string
Timeout time.Duration
Log io.Writer
}
LoginOptions 定义纯 Go 隔离登录环境
type LoginResult ¶
type LoginResult struct {
StorageStateJSON []byte
Email string
PageURL string
VerifiedAt time.Time
DriveError string
}
LoginResult 返回隔离浏览器导出的 Playwright storage state
func Login ¶
func Login(ctx context.Context, options LoginOptions) (result LoginResult, err error)
Login 启动可见隔离 Camoufox 并在 AI Studio 可用后导出认证状态
type LoginVerification ¶
type LoginVerification struct {
Authenticated bool
PageURL string
VerifiedAt time.Time
Reason string
}
LoginVerification 返回已有登录态的页面验证结果
func Verify ¶
func Verify(ctx context.Context, options LoginOptions, storageStateJSON []byte) (verification LoginVerification, err error)
Verify 使用无头隔离 Camoufox 验证已有 Playwright storage state
type Options ¶
type Options struct {
ExecutablePath string
StorageStatePath string
Model string
BootstrapPrompt string
Locale string
Timezone string
Proxy string
ProxyBypass string
Headless bool
TemporaryChat bool
CacheDirectory string
ReadyTimeout time.Duration
Log io.Writer
StartupProgress func(StartupStage)
}
Options 定义单个 AI Studio 账户的原生 Camoufox runtime
type ProtectedResponse ¶
type ProtectedResponse struct {
StatusCode int
Header http.Header
Body io.ReadCloser
}
ProtectedResponse 表示由固定指纹浏览器流式返回的 MakerSuite 响应
type StartupStage ¶
type StartupStage string
StartupStage 表示 Camoufox runtime 的启动阶段
const ( // StartupPreparingBrowser 表示正在准备浏览器配置 StartupPreparingBrowser StartupStage = "preparing_browser" // StartupLaunchingBrowser 表示正在启动浏览器进程 StartupLaunchingBrowser StartupStage = "launching_browser" // StartupConnectingBiDi 表示正在连接 WebDriver BiDi StartupConnectingBiDi StartupStage = "connecting_bidi" // StartupLoadingAIStudio 表示正在载入 AI Studio 页面 StartupLoadingAIStudio StartupStage = "loading_ai_studio" // StartupLocatingWAA 表示正在定位 WAA 服务 StartupLocatingWAA StartupStage = "locating_waa" // StartupBootstrappingWAA 表示正在执行 WAA Bootstrap StartupBootstrappingWAA StartupStage = "bootstrapping_waa" )
type State ¶
type State struct {
PID int
PageURL string
UserAgent string
Platform string
Timezone string
SnapshotKey string
Headers http.Header
}
State 返回原生 runtime 的当前页面与 bootstrap 结果
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker 保存单个账户的长驻 Camoufox 与 WAA service
func (*Worker) ProtocolHeaders ¶
ProtocolHeaders 返回官网为 GenerateContent 构造的七个公共头