aistudio

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 45 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

Index

Constants

View Source
const (
	// MakerSuiteRPCBase 是现场确认的 AI Studio RPC 根地址
	MakerSuiteRPCBase = "https://alkalimakersuite-pa.clients6.google.com/$rpc/google.internal.alkali.applications.makersuite.v1.MakerSuiteService/"
	// JSONProtobufContentType 是 MakerSuite 使用的数组协议媒体类型
	JSONProtobufContentType = "application/json+protobuf"
)
View Source
const DefaultTranscriptionModel = "gemini-3.5-transcribe"
View Source
const (
	// LoginMethodIsolatedBrowser 表示独立浏览器登录
	LoginMethodIsolatedBrowser = "isolated_browser"
)

Variables

View Source
var (
	// ErrInvalidArgument 表示请求参数在发送前已确定无效
	ErrInvalidArgument = errors.New("AI Studio 请求参数无效")
	// ErrModelNotFound 表示实时目录中不存在请求模型
	ErrModelNotFound = errors.New("AI Studio 实时目录中没有请求模型")
	// ErrNoEligibleAccount 表示没有账户具备请求所需能力
	ErrNoEligibleAccount = errors.New("没有符合条件的 AI Studio 账户")
	// ErrAccountNotFound 表示稳定账户 ID 不存在
	ErrAccountNotFound = errors.New("账户不存在")
	// ErrAccountLeased 表示账户当前存在进程内或跨进程租约
	ErrAccountLeased = errors.New("账户正在使用")
	// ErrResourceNotFound 表示资源没有创建账户映射
	ErrResourceNotFound = errors.New("资源账户映射不存在")
)

Functions

func ContextWithAccountLease

func ContextWithAccountLease(ctx context.Context, lease *AccountLease) context.Context

ContextWithAccountLease 将上层已持有的租约传给协议传输

func ContextWithAccountSelectionObserver

func ContextWithAccountSelectionObserver(ctx context.Context, observer func(*Account)) context.Context

ContextWithAccountSelectionObserver 观察请求最终选择的账户

func ContextWithRequestPhaseObserver

func ContextWithRequestPhaseObserver(ctx context.Context, observer func(RequestPhase)) context.Context

ContextWithRequestPhaseObserver 记录受保护请求阶段

func ContextWithStreamActivityObserver

func ContextWithStreamActivityObserver(ctx context.Context, observer func(int)) context.Context

ContextWithStreamActivityObserver 记录上游响应体实际到达的字节

func DecodeGenerateStream

func DecodeGenerateStream(source io.Reader, decoder *FrameDecoder, emit func(Event) error) error

DecodeGenerateStream 按网络到达顺序解码 GenerateContent repeated 帧

func DefaultAccountLocale

func DefaultAccountLocale() string

DefaultAccountLocale 返回当前用户的系统语言

func DefaultAccountTimezone

func DefaultAccountTimezone() string

DefaultAccountTimezone 返回当前用户的 IANA 时区

func DefinitiveAuthenticationFailure

func DefinitiveAuthenticationFailure(err error) bool

DefinitiveAuthenticationFailure 判断上游是否明确要求重新认证

func DefinitiveWAARuntimeFailure

func DefinitiveWAARuntimeFailure(err error) bool

DefinitiveWAARuntimeFailure 判断上游是否明确拒绝当前 WAA 运行态

func DiscoverPublicHeaders

func DiscoverPublicHeaders(ctx context.Context, client *http.Client) (http.Header, error)

DiscoverPublicHeaders 从 AI Studio 首页读取普通 RPC 所需的公开头

func EncodeBidiMediaEndRequest

func EncodeBidiMediaEndRequest() ([]byte, string, error)

EncodeBidiMediaEndRequest 编码官网实时媒体结束帧

func EncodeBidiMediaRequest

func EncodeBidiMediaRequest(mimeType string, data []byte) ([]byte, string, error)

EncodeBidiMediaRequest 编码官网实时音频或图像输入帧

func EncodeBidiSetupRequest

func EncodeBidiSetupRequest(request BidiRequest, runtime RequestContext) ([]byte, string, error)

EncodeBidiSetupRequest 编码 Live 或 Robotics 的已验证 setup 帧

func EncodeBidiTextRequest

func EncodeBidiTextRequest(text string) ([]byte, string, error)

EncodeBidiTextRequest 编码官网文本输入帧

func EncodeBidiToolResponseRequest

func EncodeBidiToolResponseRequest(results []FunctionResult) ([]byte, string, error)

EncodeBidiToolResponseRequest 编码官网函数响应帧

func EncodeCountTokensRequest

func EncodeCountTokensRequest(request TokenCountRequest) ([]byte, error)

EncodeCountTokensRequest 编码现场确认的 CountTokens 请求

func EncodeGenerateContentRequest

func EncodeGenerateContentRequest(request GenerateRequest, defaults GenerationDefaults, runtime RequestContext) ([]byte, error)

EncodeGenerateContentRequest 编码当前成功基线的 GenerateContent 数组

func EncodeGenerateVideoRequest

func EncodeGenerateVideoRequest(request VideoRequest) ([]byte, error)

EncodeGenerateVideoRequest 编码当前网页 GenerateVideo 数组协议

func EncodeGetGenerateVideoOperationRequest

func EncodeGetGenerateVideoOperationRequest(operationID string) ([]byte, error)

EncodeGetGenerateVideoOperationRequest 编码当前网页轮询数组协议

func EstimatedInputTokens

func EstimatedInputTokens(request GenerateRequest) int64

EstimatedInputTokens 返回文本、工具和引用元数据的本地输入 Token 估算

func ModelAccessKey

func ModelAccessKey(scope string, modelID string) string

ModelAccessKey 返回关联真实目录模型的独立资格键

func NewProxyHTTPClient

func NewProxyHTTPClient(proxyURL string) (*http.Client, error)

NewProxyHTTPClient 创建普通 HTTP、HTTPS 或 SOCKS5 固定出口客户端

func SignAuthorization

func SignAuthorization(cookies []StateCookie, origin string, timestamp int64) (string, error)

SignAuthorization 为指定来源和时间生成三段授权头

func TranscriptionGenerationFailure

func TranscriptionGenerationFailure(err error) bool

TranscriptionGenerationFailure 判断错误是否来自转录生成阶段

func WriteStorageState

func WriteStorageState(filePath string, state StorageState) error

WriteStorageState 原子写回 Playwright storage state

Types

type Account

type Account struct {
	ID           string        `json:"id"`
	Directory    string        `json:"-"`
	ConfigPath   string        `json:"-"`
	StoragePath  string        `json:"-"`
	RuntimePath  string        `json:"-"`
	Config       AccountConfig `json:"config"`
	StorageState StorageState  `json:"-"`
	Models       []Model       `json:"models,omitempty"`
	BenefitTier  BenefitTier   `json:"benefit_tier"`
	State        AccountState  `json:"state"`
	LastUsed     time.Time     `json:"last_used,omitempty"`
	// contains filtered or unexported fields
}

Account 表示一个稳定目录对应的 AI Studio 账户

func (*Account) AcceptLanguage

func (a *Account) AcceptLanguage() string

AcceptLanguage 返回账户 locale 对应的请求语言头

func (*Account) EffectiveProxy

func (a *Account) EffectiveProxy(globalProxy string) string

EffectiveProxy 返回账户固定代理或全局代理

func (*Account) SupportsMethod

func (a *Account) SupportsMethod(modelID string, method string) bool

SupportsMethod 判断账户模型是否声明目标方法

func (*Account) SupportsModel

func (a *Account) SupportsModel(modelID string) bool

SupportsModel 判断账户实时目录是否包含模型

type AccountCandidateGroups

type AccountCandidateGroups struct {
	WarmReady        []string
	WarmAvailable    []string
	WarmBusy         []string
	StandbyReady     []string
	StandbyBusy      []string
	EarliestCooldown time.Time
	Eligible         bool
}

AccountCandidateGroups 表示 warm 与 standby 账户的实时可调度状态

type AccountCandidateState

type AccountCandidateState struct {
	ModelAccess   ModelAccessState
	Active        int
	AvailableSlot int
}

AccountCandidateState 表示账户候选的实时调度指标

type AccountConfig

type AccountConfig struct {
	Label    string `json:"label"`
	Enabled  bool   `json:"enabled"`
	Proxy    string `json:"proxy"`
	Locale   string `json:"locale"`
	Timezone string `json:"timezone"`
}

AccountConfig 表示账户目录中的固定最小配置

func DefaultAccountConfig

func DefaultAccountConfig(label string) AccountConfig

DefaultAccountConfig 返回新账户的最小配置

func (AccountConfig) Validate

func (c AccountConfig) Validate() error

Validate 校验账户固定配置

type AccountLease

type AccountLease struct {
	// contains filtered or unexported fields
}

AccountLease 表示一个账户请求槽位

func AccountLeaseFromContext

func AccountLeaseFromContext(ctx context.Context) (*AccountLease, bool)

AccountLeaseFromContext 返回当前请求唯一的账户租约

func (*AccountLease) Account

func (l *AccountLease) Account() *Account

Account 返回当前租约持有的账户

func (*AccountLease) BeginAuthRefresh

func (l *AccountLease) BeginAuthRefresh() (func(), bool)

BeginAuthRefresh 为当前账户取得认证刷新独占窗口

func (*AccountLease) BindFileResource

func (l *AccountLease) BindFileResource(ctx context.Context, file FileRef, size int64, purpose string) error

BindFileResource 保存上传文件的账户绑定与公开元数据

func (*AccountLease) BindResource

func (l *AccountLease) BindResource(resourceID string, kind string) error

BindResource 将资源固定到当前租约账户

func (*AccountLease) BindVideoOperation

func (l *AccountLease) BindVideoOperation(
	ctx context.Context,
	resourceID string,
	metadata VideoResourceMetadata,
) (ResourceBinding, error)

BindVideoOperation 保存视频任务账户与公开对象元数据

func (*AccountLease) CheckedAt

func (l *AccountLease) CheckedAt() time.Time

CheckedAt 返回当前账户请求取得租约的时间

func (*AccountLease) MarkAuthenticationRequired

func (l *AccountLease) MarkAuthenticationRequired(reason string) error

MarkAuthenticationRequired 保存当前租约确认的认证失败状态

func (*AccountLease) MarkAuthenticationValid

func (l *AccountLease) MarkAuthenticationValid() error

MarkAuthenticationValid 保存当前租约确认的认证成功状态

func (*AccountLease) MergeSetCookieHeaders

func (l *AccountLease) MergeSetCookieHeaders(headers []string, requestURL string, now time.Time) error

MergeSetCookieHeaders 将响应 Cookie 合并到账户最新持久状态

func (*AccountLease) ModelAccessGeneration

func (l *AccountLease) ModelAccessGeneration() uint64

ModelAccessGeneration 返回租约开始时的模型资格目录代际

func (*AccountLease) RefreshStorageState

func (l *AccountLease) RefreshStorageState(
	update func(*StorageState) error,
	prepareCommit func() (func(bool), error),
) error

RefreshStorageState 保证并发认证失效只提交一次

func (*AccountLease) Release

func (l *AccountLease) Release() error

Release 释放账户文件和进程内租约

func (*AccountLease) ReloadStorageState

func (l *AccountLease) ReloadStorageState() (StorageState, error)

ReloadStorageState 在租约内重新读取认证状态

func (*AccountLease) ReplaceCookies

func (l *AccountLease) ReplaceCookies(cookies []StateCookie) error

ReplaceCookies 以固定指纹浏览器当前 Cookie 替换账户最新持久状态

func (*AccountLease) ReplaceResource

func (l *AccountLease) ReplaceResource(previousResourceID string, resourceID string, kind string) error

ReplaceResource 原子替换当前租约账户的单个资源绑定

func (*AccountLease) SaveConfig

func (l *AccountLease) SaveConfig(value AccountConfig) error

SaveConfig 在租约内原子写回账户固定配置

func (*AccountLease) SaveStorageState

func (l *AccountLease) SaveStorageState(state StorageState) error

SaveStorageState 在租约内原子写回认证状态

func (*AccountLease) VideoOperationBinding

func (l *AccountLease) VideoOperationBinding(resourceID string) (ResourceBinding, error)

VideoOperationBinding 返回当前账户持有的视频任务元数据

type AccountPool

type AccountPool struct {
	// contains filtered or unexported fields
}

AccountPool 在账户之间执行能力与并发槽位调度

func NewAccountPool

func NewAccountPool(accounts []*Account, perAccountConcurrency int) *AccountPool

NewAccountPool 创建账户独占调度池

func (*AccountPool) Account

func (p *AccountPool) Account(accountID string) (*Account, error)

Account 返回稳定 ID 对应的账户

func (*AccountPool) Acquire

func (p *AccountPool) Acquire(ctx context.Context, model string) (*AccountLease, error)

Acquire 为模型轮询获取一个账户槽位

func (*AccountPool) AcquireAccount

func (p *AccountPool) AcquireAccount(ctx context.Context, accountID string) (*AccountLease, error)

AcquireAccount 为管理操作获取不受调度状态限制的指定账户租约

func (*AccountPool) AcquireFor

func (p *AccountPool) AcquireFor(ctx context.Context, selection AccountSelection) (*AccountLease, error)

AcquireFor 按模型方法账户或资源粘性获取账户槽位

func (*AccountPool) AcquireResource

func (p *AccountPool) AcquireResource(ctx context.Context, resourceID string) (*AccountLease, error)

AcquireResource 获取创建资源的固定账户

func (*AccountPool) Add

func (p *AccountPool) Add(account *Account) (resultErr error)

Add 将新账户加入当前调度池

func (*AccountPool) BindResource

func (p *AccountPool) BindResource(resourceID string, accountID string) error

BindResource 将资源 ID 固定到创建账户

func (*AccountPool) BindResourceKind

func (p *AccountPool) BindResourceKind(resourceID string, accountID string, kind string) error

BindResourceKind 将带类型的资源 ID 固定到创建账户

func (*AccountPool) BootstrapModel

func (p *AccountPool) BootstrapModel(accountID string) (string, error)

BootstrapModel 返回账户使用的通用 WAA 初始化模型

func (*AccountPool) BootstrapModels

func (p *AccountPool) BootstrapModels(accountID string) ([]string, error)

BootstrapModels 返回账户实时目录中的 WAA 初始化模型

func (*AccountPool) CandidateStates

func (p *AccountPool) CandidateStates(accountIDs []string, modelID string) map[string]AccountCandidateState

CandidateStates 返回候选账户的权益与实时负载

func (*AccountPool) CandidateStatesForScope

func (p *AccountPool) CandidateStatesForScope(
	accountIDs []string,
	modelID string,
	modelAccessScope string,
) map[string]AccountCandidateState

CandidateStatesForScope 返回指定资格范围的候选账户状态

func (*AccountPool) ClassifyCandidates

func (p *AccountPool) ClassifyCandidates(
	ctx context.Context,
	selection AccountSelection,
	warmAccountIDs []string,
) (AccountCandidateGroups, error)

ClassifyCandidates 按 warm 集合分类目标请求的候选账户

func (*AccountPool) ClearCooldownIfGeneration

func (p *AccountPool) ClearCooldownIfGeneration(
	accountID string,
	modelAccessScope string,
	generation uint64,
	checkedAt time.Time,
) error

ClearCooldownIfGeneration 清除当前目录代际中的作用域冷却

func (*AccountPool) FileMetadata

func (p *AccountPool) FileMetadata(ctx context.Context, fileID string) (FileMetadata, error)

FileMetadata 返回 runtime-state 中的公开文件元数据

func (*AccountPool) ForgetModelAccessVerifiedIfGeneration

func (p *AccountPool) ForgetModelAccessVerifiedIfGeneration(
	accountID string,
	modelID string,
	generation uint64,
	checkedAt time.Time,
) (bool, error)

ForgetModelAccessVerifiedIfGeneration 删除当前目录代际中过期的模型成功记录

func (*AccountPool) MarkAuthRequired

func (p *AccountPool) MarkAuthRequired(accountID string, reason string) error

MarkAuthRequired 将账户标记为需要重新登录

func (*AccountPool) MarkCooldownIfGeneration

func (p *AccountPool) MarkCooldownIfGeneration(
	accountID string,
	modelAccessScope string,
	generation uint64,
	checkedAt time.Time,
	until time.Time,
	reason string,
) error

MarkCooldownIfGeneration 保存当前目录代际中的作用域冷却

func (*AccountPool) MarkModelAccessVerifiedIfGeneration

func (p *AccountPool) MarkModelAccessVerifiedIfGeneration(
	accountID string,
	modelID string,
	generation uint64,
	checkedAt time.Time,
) (bool, error)

MarkModelAccessVerifiedIfGeneration 保存当前目录代际中的模型生成成功记录

func (*AccountPool) MarkReady

func (p *AccountPool) MarkReady(accountID string) error

MarkReady 将账户恢复为可调度状态

func (*AccountPool) MarkUnavailable

func (p *AccountPool) MarkUnavailable(accountID string, reason string) error

MarkUnavailable 将账户标记为初始化或运行失败

func (*AccountPool) ModelAccessGeneration

func (p *AccountPool) ModelAccessGeneration(accountID string) uint64

ModelAccessGeneration 返回账户当前模型资格目录代际

func (*AccountPool) OrderCandidates

func (p *AccountPool) OrderCandidates(accountIDs []string, modelAccessScope string) []string

OrderCandidates 按当前策略排列候选账户而不推进轮询位置

func (*AccountPool) PreferWarmPool

func (p *AccountPool) PreferWarmPool(accountIDs []string) []string

PreferWarmPool 按权益分层轮选初始热账户

func (*AccountPool) Remove

func (p *AccountPool) Remove(accountID string, deleteDirectory func(*Account) error) (*Account, error)

Remove 在账户空闲时删除持久目录并移出调度池

func (*AccountPool) ResetModelAccess

func (p *AccountPool) ResetModelAccess(accountID string) error

ResetModelAccess 清空账户的实测模型资格

func (*AccountPool) ResourceIDForContents

func (pool *AccountPool) ResourceIDForContents(ctx context.Context, contents []Content) (string, error)

ResourceIDForContents 校验全部文件引用并返回首个资源供生成账户选择

func (*AccountPool) SetCatalog

func (p *AccountPool) SetCatalog(accountID string, tier BenefitTier, models []Model) error

SetCatalog 替换账户的权益等级与实时模型目录

func (*AccountPool) SetRoutingStrategy

func (p *AccountPool) SetRoutingStrategy(strategy string)

SetRoutingStrategy 设置账户轮询或优先填满策略

func (*AccountPool) Status

func (p *AccountPool) Status() []AccountStatus

Status 返回账户池的脱敏状态

func (*AccountPool) TryAcquireFor

func (p *AccountPool) TryAcquireFor(ctx context.Context, selection AccountSelection) (*AccountLease, bool, error)

TryAcquireFor 尝试获取账户槽位并立即返回当前结果

func (*AccountPool) UnbindResource

func (p *AccountPool) UnbindResource(resourceID string) error

UnbindResource 删除终态资源的账户映射

type AccountPublishLease

type AccountPublishLease struct {
	// contains filtered or unexported fields
}

AccountPublishLease 保护新账户从稳定目录发布到运行时

func (*AccountPublishLease) Release

func (lease *AccountPublishLease) Release() error

Release 结束新账户运行时发布窗口

type AccountRuntimeLease

type AccountRuntimeLease struct {
	// contains filtered or unexported fields
}

AccountRuntimeLease 保证同一邮箱只有一个 WAA runtime

func AcquireAccountRuntimeLease

func AcquireAccountRuntimeLease(accountID string) (*AccountRuntimeLease, error)

AcquireAccountRuntimeLease 锁定当前用户下的账户 WAA runtime

func (*AccountRuntimeLease) Release

func (lease *AccountRuntimeLease) Release() error

Release 释放账户 WAA runtime 锁

type AccountSelection

type AccountSelection struct {
	ModelID           string
	ModelAccessScope  string
	Method            string
	Capability        string
	AccountID         string
	ResourceID        string
	AllowedAccountIDs []string
}

AccountSelection 描述账户调度所需的能力或粘性条件

type AccountState

type AccountState string

AccountState 表示账户当前是否可调度

const (
	// AccountReady 表示账户可以接收请求
	AccountReady AccountState = "ready"
	// AccountBusy 表示账户存在活动请求
	AccountBusy AccountState = "busy"
	// AccountCooldown 表示账户或模型处于冷却期
	AccountCooldown AccountState = "cooldown"
	// AccountAuthRequired 表示账户需要重新登录
	AccountAuthRequired AccountState = "auth_required"
	// AccountUnavailable 表示账户初始化或运行失败
	AccountUnavailable AccountState = "unavailable"
	// AccountDisabled 表示账户已停用
	AccountDisabled AccountState = "disabled"
)

type AccountStatus

type AccountStatus struct {
	ID          string                   `json:"id"`
	Label       string                   `json:"label"`
	State       AccountState             `json:"state"`
	Enabled     bool                     `json:"enabled"`
	Proxy       string                   `json:"proxy"`
	Locale      string                   `json:"locale"`
	Timezone    string                   `json:"timezone"`
	Models      []string                 `json:"models"`
	BenefitTier string                   `json:"benefit_tier"`
	Cooldowns   map[string]CooldownState `json:"-"`
	LastUsed    *time.Time               `json:"last_used,omitempty"`
	Message     string                   `json:"message,omitempty"`
}

AccountStatus 表示管理界面使用的脱敏账户状态

type AccountStore

type AccountStore struct {
	// contains filtered or unexported fields
}

AccountStore 从一个或多个账户文件或目录加载账户

func NewAccountStore

func NewAccountStore(paths ...string) *AccountStore

NewAccountStore 创建账户目录存储

func (*AccountStore) Create

func (s *AccountStore) Create(accountConfig AccountConfig, state StorageState) (*Account, *AccountPublishLease, error)

Create 创建并锁定以认证邮箱命名的账户目录

func (*AccountStore) Delete

func (s *AccountStore) Delete(account *Account) error

Delete 删除属于当前存储的稳定账户目录

func (*AccountStore) Load

func (s *AccountStore) Load() ([]*Account, error)

Load 扫描账户目录并恢复冷却与资源粘性

type AuthExtension

type AuthExtension struct {
	Source AuthSource           `json:"source"`
	OAuth  *ChromeOAuthMaterial `json:"oauth,omitempty"`
}

AuthExtension 保存 aistudio2api 认证扩展

type AuthSource

type AuthSource struct {
	Browser string `json:"browser"`
	Profile string `json:"profile,omitempty"`
	Email   string `json:"email,omitempty"`
}

AuthSource 记录认证状态的来源

type BenefitTier

type BenefitTier int64

BenefitTier 表示 AI Studio 返回的账户权益等级

const (
	// BenefitTierFree 表示账户没有 Google AI 订阅权益
	BenefitTierFree BenefitTier = 0
	// BenefitTierPro 表示 Google AI Pro 权益
	BenefitTierPro BenefitTier = 1
	// BenefitTierUltra 表示 Google AI Ultra 权益
	BenefitTierUltra BenefitTier = 2
	// BenefitTierPlus 表示 Google AI Plus 权益
	BenefitTierPlus BenefitTier = 3
)

func (BenefitTier) HeaderValue

func (tier BenefitTier) HeaderValue() string

HeaderValue 返回官网 RPC 使用的权益请求头值

func (BenefitTier) String

func (tier BenefitTier) String() string

String 返回账户权益的稳定显示名称

type BidiEvent

type BidiEvent struct {
	Kind          BidiEventKind      `json:"kind"`
	Text          string             `json:"text,omitempty"`
	Media         *Media             `json:"media,omitempty"`
	Transcription *BidiTranscription `json:"transcription,omitempty"`
	ToolCall      *FunctionCall      `json:"tool_call,omitempty"`
	ToolCallIDs   []string           `json:"tool_call_ids,omitempty"`
	SessionToken  string             `json:"session_token,omitempty"`
	Resumable     bool               `json:"resumable,omitempty"`
	Raw           json.RawMessage    `json:"raw,omitempty"`
	Err           error              `json:"-"`
}

BidiEvent 保存按上游顺序输出的实时事件

func ParseBidiServerPayload

func ParseBidiServerPayload(raw json.RawMessage) ([]BidiEvent, error)

ParseBidiServerPayload 解码一条 WebChannel 业务 payload

type BidiEventKind

type BidiEventKind string

BidiEventKind 表示双向实时协议事件

const (
	// BidiEventSetupComplete 表示上游已接受会话配置
	BidiEventSetupComplete BidiEventKind = "setup_complete"
	// BidiEventText 表示模型文本增量
	BidiEventText BidiEventKind = "text"
	// BidiEventMedia 表示模型媒体增量
	BidiEventMedia BidiEventKind = "media"
	// BidiEventInputTranscription 表示输入转写增量
	BidiEventInputTranscription BidiEventKind = "input_transcription"
	// BidiEventOutputTranscription 表示输出转写增量
	BidiEventOutputTranscription BidiEventKind = "output_transcription"
	// BidiEventGenerationComplete 表示当前生成已完成
	BidiEventGenerationComplete BidiEventKind = "generation_complete"
	// BidiEventTurnComplete 表示当前对话轮次已完成
	BidiEventTurnComplete BidiEventKind = "turn_complete"
	// BidiEventInterrupted 表示当前模型输出被打断
	BidiEventInterrupted BidiEventKind = "interrupted"
	// BidiEventToolCall 表示模型发起函数调用
	BidiEventToolCall BidiEventKind = "tool_call"
	// BidiEventToolCallCancellation 表示模型取消尚未完成的函数调用
	BidiEventToolCallCancellation BidiEventKind = "tool_call_cancellation"
	// BidiEventSessionResumption 表示上游更新恢复令牌
	BidiEventSessionResumption BidiEventKind = "session_resumption"
	// BidiEventGoAway 表示上游要求结束当前连接
	BidiEventGoAway BidiEventKind = "go_away"
	// BidiEventUsage 表示上游返回用量字段
	BidiEventUsage BidiEventKind = "usage"
	// BidiEventProvider 表示已保留的未归一化上游字段
	BidiEventProvider BidiEventKind = "provider"
	// BidiEventClosed 表示 WebChannel 已结束
	BidiEventClosed BidiEventKind = "closed"
	// BidiEventError 表示双向实时协议错误
	BidiEventError BidiEventKind = "error"
)

type BidiMode

type BidiMode string

BidiMode 区分 Gemini Live 与 Robotics Streaming 的独立会话配置

const (
	// BidiModeLive 表示音频输出的 Gemini Live 会话
	BidiModeLive BidiMode = "live"
	// BidiModeRobotics 表示文本输出的 Robotics Streaming 会话
	BidiModeRobotics BidiMode = "robotics"
)

type BidiProtectedTransport

type BidiProtectedTransport interface {
	OpenBidiProtected(context.Context, BidiRequest, RequestContext, *AccountLease, func() error) (*BidiSession, error)
}

BidiProtectedTransport 建立持有当前账户租约的 WebChannel 会话

type BidiRequest

type BidiRequest struct {
	Model                    string
	Mode                     BidiMode
	Tools                    []FunctionDeclaration
	AccountID                string
	AllowedAccountIDs        []string
	SessionToken             string
	ModelAccessScope         string
	RecoverWAARuntime        func(context.Context, string, error) (bool, error)
	ObserveWAARuntime        func(string, uint64)
	ObserveModelAccessChange func()
	ObserveAccountFailure    func(string, error)
}

BidiRequest 定义一条双向实时会话

type BidiService

type BidiService interface {
	OpenBidi(context.Context, BidiRequest) (*BidiSession, error)
}

BidiService 创建 Gemini Live 或 Robotics Streaming 会话

type BidiSession

type BidiSession struct {
	// contains filtered or unexported fields
}

BidiSession 保存一条 Google WebChannel 双向会话

func (*BidiSession) Close

func (s *BidiSession) Close() error

Close 取消网络读取并等待账户租约释放

func (*BidiSession) Done

func (s *BidiSession) Done() <-chan struct{}

Done 在 WebChannel 释放账户后关闭

func (*BidiSession) Events

func (s *BidiSession) Events() <-chan BidiEvent

Events 返回上游按网络顺序产生的事件

func (*BidiSession) Model

func (s *BidiSession) Model() string

Model 返回会话使用的模型

func (*BidiSession) SendMedia

func (s *BidiSession) SendMedia(ctx context.Context, mimeType string, data []byte) error

SendMedia 发送一条官网实时音频或图像输入帧

func (*BidiSession) SendMediaEnd

func (s *BidiSession) SendMediaEnd(ctx context.Context) error

SendMediaEnd 发送官网实时媒体结束帧

func (*BidiSession) SendText

func (s *BidiSession) SendText(ctx context.Context, text string) error

SendText 发送一条官网文本输入帧

func (*BidiSession) SendToolResponses

func (s *BidiSession) SendToolResponses(ctx context.Context, results []FunctionResult) error

SendToolResponses 发送官网函数响应帧

type BidiTranscription

type BidiTranscription struct {
	Text         string `json:"text"`
	Finished     bool   `json:"finished,omitempty"`
	DurationMS   int64  `json:"duration_ms,omitempty"`
	LanguageCode string `json:"language_code,omitempty"`
}

BidiTranscription 保存实时转写字段

type Blob

type Blob struct {
	MIME string `json:"mime"`
	Data []byte `json:"data"`
}

Blob 表示内联二进制内容

type ChromeOAuthMaterial

type ChromeOAuthMaterial struct {
	GaiaID            string `json:"gaia_id"`
	RefreshToken      string `json:"refresh_token"`
	WrappedBindingKey []byte `json:"wrapped_binding_key"`
}

ChromeOAuthMaterial 保存 Chrome DBSC 续签材料

type Citation

type Citation struct {
	URL       string `json:"url"`
	Title     string `json:"title,omitempty"`
	Start     int    `json:"start,omitempty"`
	End       int    `json:"end,omitempty"`
	Publisher string `json:"publisher,omitempty"`
}

Citation 表示模型返回的来源

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 实现 AI Studio 私有协议核心

func NewClient

func NewClient(options ClientOptions) (*Client, error)

NewClient 创建协议客户端

func (*Client) BenefitTierForAccount

func (c *Client) BenefitTierForAccount(ctx context.Context, accountID string) (BenefitTier, error)

BenefitTierForAccount 读取并缓存指定账户的官网权益等级

func (*Client) CountTokens

func (c *Client) CountTokens(ctx context.Context, request TokenCountRequest) (TokenCount, error)

func (*Client) CountTokensForAccount

func (c *Client) CountTokensForAccount(ctx context.Context, accountID string, request TokenCountRequest) (TokenCount, error)

CountTokensForAccount 使用指定账户调用权威 token 计数

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, request GenerateRequest) (<-chan Event, error)

func (*Client) GenerateAccessToken

func (c *Client) GenerateAccessToken(ctx context.Context, accountID string) (string, error)

GenerateAccessToken 获取网页账户授权的短期 bearer token

func (*Client) GenerateVideo

func (c *Client) GenerateVideo(ctx context.Context, request VideoRequest) (VideoOperation, error)

GenerateVideo 创建 Veo 长任务

func (*Client) GetGenerateVideoOperation

func (c *Client) GetGenerateVideoOperation(ctx context.Context, accountID string, operationID string) (VideoOperation, error)

GetGenerateVideoOperation 读取 Veo 长任务当前状态

func (*Client) Models

func (c *Client) Models(ctx context.Context) ([]Model, error)

func (*Client) ModelsForAccount

func (c *Client) ModelsForAccount(ctx context.Context, accountID string) ([]Model, error)

ModelsForAccount 读取指定账户的实时模型目录

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, request UploadRequest) (FileRef, error)

UploadFile 上传文件并返回可用于 GenerateContent 的 Drive 引用

type ClientOptions

type ClientOptions struct {
	Transport       RPCTransport
	Protected       ProtectedTransport
	ContextProvider RequestContextProvider
}

ClientOptions 定义协议客户端的窄依赖

type CodeExecutionResult

type CodeExecutionResult struct {
	Outcome string `json:"outcome"`
	Output  string `json:"output,omitempty"`
	Error   string `json:"error,omitempty"`
}

CodeExecutionResult 表示 AI Studio 内置代码执行器返回的结果

type Content

type Content struct {
	Role  Role   `json:"role"`
	Parts []Part `json:"parts"`
}

Content 表示一条规范消息

type CooldownState

type CooldownState struct {
	Until  time.Time `json:"until"`
	Reason string    `json:"reason,omitempty"`
}

CooldownState 表示账户或模型暂时不可调度的状态

func (CooldownState) Active

func (c CooldownState) Active(now time.Time) bool

Active 判断冷却状态当前是否生效

type DriveTransport

type DriveTransport interface {
	UploadDrive(context.Context, string, string, UploadRequest) (FileRef, error)
	DownloadDrive(context.Context, string, string, string) (MediaStream, error)
	DeleteDrive(context.Context, string, string, string) error
}

DriveTransport 负责使用账户固定出口访问 Google Drive

type Event

type Event struct {
	Kind                EventKind            `json:"kind"`
	Text                string               `json:"text,omitempty"`
	ToolCall            *FunctionCall        `json:"tool_call,omitempty"`
	ExecutableCode      *ExecutableCode      `json:"executable_code,omitempty"`
	CodeExecutionResult *CodeExecutionResult `json:"code_execution_result,omitempty"`
	Grounding           *GroundingMetadata   `json:"grounding,omitempty"`
	Citation            *Citation            `json:"citation,omitempty"`
	Media               *Media               `json:"media,omitempty"`
	Transcript          *TranscriptMetadata  `json:"transcript,omitempty"`
	Usage               *Usage               `json:"usage,omitempty"`
	FinishReason        string               `json:"finish_reason,omitempty"`
	StopSequence        string               `json:"stop_sequence,omitempty"`
	ProviderModel       string               `json:"provider_model,omitempty"`
	ThoughtSignature    string               `json:"thought_signature,omitempty"`
	Err                 error                `json:"-"`
}

Event 表示协议核心输出的规范事件

type EventKind

type EventKind string

EventKind 表示规范流事件类型

const (
	// EventText 表示正文增量
	EventText EventKind = "text"
	// EventReasoning 表示思考摘要增量
	EventReasoning EventKind = "reasoning"
	// EventToolCall 表示函数调用
	EventToolCall EventKind = "tool_call"
	// EventExecutableCode 表示内置代码执行器生成代码
	EventExecutableCode EventKind = "executable_code"
	// EventCodeExecutionResult 表示内置代码执行结果
	EventCodeExecutionResult EventKind = "code_execution_result"
	// EventGrounding 表示 Google 工具来源信息
	EventGrounding EventKind = "grounding"
	// EventCitation 表示来源信息
	EventCitation EventKind = "citation"
	// EventMedia 表示媒体产物
	EventMedia EventKind = "media"
	// EventThoughtSignature 表示独立思考签名
	EventThoughtSignature EventKind = "thought_signature"
	// EventUsage 表示权威用量
	EventUsage EventKind = "usage"
	// EventFinish 表示正常完成
	EventFinish EventKind = "finish"
	// EventError 表示上游错误
	EventError EventKind = "error"
)

type ExecutableCode

type ExecutableCode struct {
	Language string `json:"language"`
	Code     string `json:"code"`
}

ExecutableCode 表示 AI Studio 内置代码执行器生成的代码

type ExternalMedia

type ExternalMedia struct {
	MIME string `json:"mime"`
	URL  string `json:"url"`
}

ExternalMedia 表示可由 AI Studio 直接读取的外部媒体

func ExternalMediaForURL

func ExternalMediaForURL(raw string) (*ExternalMedia, bool)

ExternalMediaForURL 返回 AI Studio 可直接读取的外部媒体

type FileMetadata

type FileMetadata struct {
	ID        string
	Name      string
	MIME      string
	Purpose   string
	Size      int64
	CreatedAt time.Time
}

FileMetadata 表示已上传文件的持久元数据

type FileRef

type FileRef struct {
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
	MIME string `json:"mime,omitempty"`
}

FileRef 表示已上传文件引用

type FileService

type FileService interface {
	UploadFile(context.Context, UploadRequest) (FileRef, error)
	FileMetadata(context.Context, string) (FileMetadata, error)
	DownloadFile(context.Context, string) (MediaStream, error)
	DeleteFile(context.Context, string) error
}

FileService 定义公开文件 API 依赖的能力

type FrameDecoder

type FrameDecoder struct {
	// contains filtered or unexported fields
}

FrameDecoder 将 field 1 repeated 帧转换为规范事件

func NewFrameDecoder

func NewFrameDecoder() *FrameDecoder

NewFrameDecoder 创建单次 GenerateContent 的有状态解码器

func (*FrameDecoder) Decode

func (d *FrameDecoder) Decode(raw json.RawMessage) ([]Event, error)

Decode 解码一条 repeated 流帧

func (*FrameDecoder) End

func (d *FrameDecoder) End() error

End 校验流已经出现正常完成帧

type FunctionCall

type FunctionCall struct {
	ID               string          `json:"id"`
	Name             string          `json:"name"`
	Arguments        json.RawMessage `json:"arguments"`
	ThoughtSignature string          `json:"thought_signature,omitempty"`
}

FunctionCall 表示模型发起的函数调用

type FunctionDeclaration

type FunctionDeclaration struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	Parameters  json.RawMessage `json:"parameters,omitempty"`
}

FunctionDeclaration 表示客户端声明的函数

type FunctionResult

type FunctionResult struct {
	ID      string          `json:"id"`
	Name    string          `json:"name,omitempty"`
	Content json.RawMessage `json:"content"`
}

FunctionResult 表示客户端返回的函数结果

type GenerateRequest

type GenerateRequest struct {
	ID        string           `json:"id"`
	Model     string           `json:"model"`
	System    string           `json:"system,omitempty"`
	Contents  []Content        `json:"contents"`
	Config    GenerationConfig `json:"config,omitempty"`
	Tools     Tools            `json:"tools,omitempty"`
	AccountID string           `json:"account_id,omitempty"`
}

GenerateRequest 表示供应商无关的生成请求

type GenerationConfig

type GenerationConfig struct {
	Temperature         *float64             `json:"temperature,omitempty"`
	TopP                *float64             `json:"top_p,omitempty"`
	TopK                *int                 `json:"top_k,omitempty"`
	MaxOutputTokens     *int64               `json:"max_output_tokens,omitempty"`
	StopSequences       []string             `json:"stop_sequences,omitempty"`
	ResponseMIMEType    string               `json:"response_mime_type,omitempty"`
	ResponseSchema      json.RawMessage      `json:"response_schema,omitempty"`
	ResponseModalities  []ResponseModality   `json:"response_modalities,omitempty"`
	ImageConfig         *ImageConfig         `json:"image_config,omitempty"`
	SpeechConfig        *SpeechConfig        `json:"speech_config,omitempty"`
	TranscriptionConfig *TranscriptionConfig `json:"transcription_config,omitempty"`
	ReasoningEffort     string               `json:"reasoning_effort,omitempty"`
	ThinkingBudget      *int64               `json:"thinking_budget,omitempty"`
	Seed                *int64               `json:"seed,omitempty"`
}

GenerationConfig 表示已验证的生成参数

type GenerationDefaults

type GenerationDefaults struct {
	MaxOutputTokens      int64
	Temperature          *float64
	TopP                 *float64
	TopK                 *int
	Thinking             bool
	ThinkingBudget       bool
	ThinkingLevel        bool
	DefaultThinkingLevel int64
	ThinkingLevels       []int64
}

GenerationDefaults 保存 ListModels 返回的生成默认值

type GoogleSearchOptions

type GoogleSearchOptions struct {
	WebSearch   bool                   `json:"web_search,omitempty"`
	ImageSearch bool                   `json:"image_search,omitempty"`
	TimeRange   *GoogleSearchTimeRange `json:"time_range,omitempty"`
}

GoogleSearchOptions 表示 Google Search 的检索类型与时间范围

type GoogleSearchTimeRange

type GoogleSearchTimeRange struct {
	StartTime time.Time `json:"start_time,omitzero"`
	EndTime   time.Time `json:"end_time,omitzero"`
}

GoogleSearchTimeRange 表示 Google Search 的检索时间范围

type GroundingChunk

type GroundingChunk struct {
	Source  string `json:"source"`
	URI     string `json:"uri,omitempty"`
	Title   string `json:"title,omitempty"`
	Text    string `json:"text,omitempty"`
	PlaceID string `json:"place_id,omitempty"`
}

GroundingChunk 表示 Google 工具检索到的一个来源

type GroundingMetadata

type GroundingMetadata struct {
	SearchEntryPoint       *SearchEntryPoint  `json:"search_entry_point,omitempty"`
	Chunks                 []GroundingChunk   `json:"chunks,omitempty"`
	Supports               []GroundingSupport `json:"supports,omitempty"`
	DynamicRetrievalScore  *float64           `json:"dynamic_retrieval_score,omitempty"`
	WebSearchQueries       []string           `json:"web_search_queries,omitempty"`
	MapsWidgetContextToken string             `json:"maps_widget_context_token,omitempty"`
}

GroundingMetadata 表示 Google Search、URL Context 和 Maps 的来源信息

type GroundingSegment

type GroundingSegment struct {
	PartIndex  int    `json:"part_index,omitempty"`
	StartIndex int    `json:"start_index,omitempty"`
	EndIndex   int    `json:"end_index,omitempty"`
	Text       string `json:"text,omitempty"`
}

GroundingSegment 表示正文中由来源支撑的片段

type GroundingSupport

type GroundingSupport struct {
	Segment          GroundingSegment `json:"segment"`
	ChunkIndices     []int            `json:"chunk_indices,omitempty"`
	ConfidenceScores []float64        `json:"confidence_scores,omitempty"`
}

GroundingSupport 表示正文片段与来源下标的关联

type HTTPTransportOptions

type HTTPTransportOptions struct {
	Pool        *AccountPool
	Signer      *Signer
	Headers     ProtocolHeaderProvider
	GlobalProxy string
}

HTTPTransportOptions 定义普通 MakerSuite RPC 的账户与网络依赖

type ImageConfig

type ImageConfig struct {
	AspectRatio string `json:"aspect_ratio,omitempty"`
	ImageSize   string `json:"image_size,omitempty"`
}

ImageConfig 表示图片生成参数

type IsolatedLoginDriver

IsolatedLoginDriver 定义独立浏览器登录与验证合同

type IsolatedLoginRequest

type IsolatedLoginRequest struct {
	AccountID string
	Directory string
	Proxy     string
	Locale    string
	Timezone  string
}

IsolatedLoginRequest 描述独立浏览器登录所需的稳定环境

type IsolatedLoginResult

type IsolatedLoginResult struct {
	StorageState StorageState
	Email        string
	VerifiedAt   time.Time
}

IsolatedLoginResult 返回独立浏览器导出的认证状态

type LoginMethod

type LoginMethod struct {
	ID          string `json:"id"`
	Interactive bool   `json:"interactive"`
}

LoginMethod 描述可发布的账户登录入口

func SupportedLoginMethods

func SupportedLoginMethods() []LoginMethod

SupportedLoginMethods 返回当前可发布的登录入口

type LoginVerification

type LoginVerification struct {
	Authenticated bool      `json:"authenticated"`
	VerifiedAt    time.Time `json:"verified_at"`
	Reason        string    `json:"reason,omitempty"`
}

LoginVerification 表示隔离运行时对登录态的验证结果

type MakerSuiteHTTPTransport

type MakerSuiteHTTPTransport struct {
	// contains filtered or unexported fields
}

MakerSuiteHTTPTransport 使用账户固定出口发送普通 RPC

func NewMakerSuiteHTTPTransport

func NewMakerSuiteHTTPTransport(options HTTPTransportOptions) (*MakerSuiteHTTPTransport, error)

NewMakerSuiteHTTPTransport 创建普通 MakerSuite RPC 传输

func (*MakerSuiteHTTPTransport) CloseIdleConnections

func (t *MakerSuiteHTTPTransport) CloseIdleConnections()

CloseIdleConnections 关闭全部固定出口的空闲连接

func (*MakerSuiteHTTPTransport) DeleteDrive

func (t *MakerSuiteHTTPTransport) DeleteDrive(ctx context.Context, accountID string, token string, fileID string) error

DeleteDrive 通过当前账户固定出口删除 Drive 文件

func (*MakerSuiteHTTPTransport) Do

Do 发送普通 MakerSuite RPC 并让响应 body 持有租约

func (*MakerSuiteHTTPTransport) DownloadDrive

func (t *MakerSuiteHTTPTransport) DownloadDrive(ctx context.Context, accountID string, token string, fileID string) (MediaStream, error)

DownloadDrive 通过当前账户固定出口下载 Drive 文件

func (*MakerSuiteHTTPTransport) UploadDrive

func (t *MakerSuiteHTTPTransport) UploadDrive(ctx context.Context, accountID string, token string, request UploadRequest) (FileRef, error)

UploadDrive 通过当前账户固定出口上传 Drive 文件

type Media

type Media struct {
	URL      string `json:"url,omitempty"`
	Data     []byte `json:"data,omitempty"`
	MIME     string `json:"mime,omitempty"`
	Name     string `json:"name,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
	Duration int64  `json:"duration_ms,omitempty"`
}

Media 表示生成的媒体产物

type MediaStream

type MediaStream struct {
	Body io.ReadCloser
	MIME string
	Name string
	Size int64
}

MediaStream 表示需要调用方关闭的媒体响应流

type Model

type Model struct {
	ID                string              `json:"id"`
	Name              string              `json:"name"`
	Description       string              `json:"description,omitempty"`
	Methods           []string            `json:"methods"`
	InputTokenLimit   int64               `json:"input_token_limit,omitempty"`
	OutputTokenLimit  int64               `json:"output_token_limit,omitempty"`
	Capabilities      map[string]bool     `json:"capabilities,omitempty"`
	CapabilityOptions map[string][]string `json:"capability_options,omitempty"`
	AccessModes       []int64             `json:"access_modes,omitempty"`
	Paid              bool                `json:"paid,omitempty"`
}

Model 表示实时模型目录中的模型

func ParseModels

func ParseModels(source io.Reader) ([]Model, error)

ParseModels 解码 ListModels 的现场数组协议

type ModelAccess

type ModelAccess struct {
	State     ModelAccessState `json:"state"`
	CheckedAt time.Time        `json:"checked_at"`
	Reason    string           `json:"reason,omitempty"`
}

ModelAccess 保存账户模型资格的实测结果

type ModelAccessState

type ModelAccessState string

ModelAccessState 表示账户对单个模型的实测调用资格

const (
	// ModelAccessVerified 表示账户已成功调用模型
	ModelAccessVerified ModelAccessState = "verified"
)

type NativeLoginDriver

type NativeLoginDriver struct {
	// contains filtered or unexported fields
}

NativeLoginDriver 通过纯 Go WebDriver BiDi 完成隔离登录

func NewNativeLoginDriver

func NewNativeLoginDriver(camoufoxPath string, timeout time.Duration) (*NativeLoginDriver, error)

NewNativeLoginDriver 创建纯 Go Camoufox 登录驱动

func (*NativeLoginDriver) Login

Login 启动可见隔离 Camoufox 并导出认证状态

func (*NativeLoginDriver) Verify

Verify 使用无头隔离 Camoufox 验证已有认证状态

type NativeWorker

type NativeWorker struct {
	// contains filtered or unexported fields
}

NativeWorker 将纯 Go Camoufox runtime 适配为 WAA preparer

func NewNativeWorker

func NewNativeWorker(ctx context.Context, accountID string, options camoufoxnative.Options) (*NativeWorker, error)

NewNativeWorker 启动单个账户的纯 Go Camoufox runtime

func (*NativeWorker) BrowserStorageState

func (worker *NativeWorker) BrowserStorageState(ctx context.Context) (StorageState, error)

BrowserStorageState 返回固定指纹浏览器当前 Cookie 状态

func (*NativeWorker) Close

func (worker *NativeWorker) Close() error

Close 关闭纯 Go runtime

func (*NativeWorker) Prepare

Prepare 生成 fresh proof 并写入 GenerateContent 第五槽

func (*NativeWorker) ProtocolHeaders

func (worker *NativeWorker) ProtocolHeaders(ctx context.Context, accountID string) (http.Header, error)

ProtocolHeaders 返回当前账户官网请求的动态公共头

func (*NativeWorker) SendProtected

func (worker *NativeWorker) SendProtected(ctx context.Context, request ProtectedRequest) (*RPCResponse, error)

SendProtected 通过账户固定指纹 Camoufox 流式发送已准备的请求

func (*NativeWorker) State

func (worker *NativeWorker) State() WorkerState

State 返回纯 Go runtime 状态

type Part

type Part struct {
	Text                string               `json:"text,omitempty"`
	InlineData          *Blob                `json:"inline_data,omitempty"`
	ExternalMedia       *ExternalMedia       `json:"external_media,omitempty"`
	File                *FileRef             `json:"file,omitempty"`
	FunctionCall        *FunctionCall        `json:"function_call,omitempty"`
	FunctionResult      *FunctionResult      `json:"function_result,omitempty"`
	ExecutableCode      *ExecutableCode      `json:"executable_code,omitempty"`
	CodeExecutionResult *CodeExecutionResult `json:"code_execution_result,omitempty"`
	Thought             bool                 `json:"thought,omitempty"`
	ThoughtSignature    string               `json:"thought_signature,omitempty"`
}

Part 表示规范消息中的一个内容块

type PoolRequestContextProvider

type PoolRequestContextProvider struct {
	// contains filtered or unexported fields
}

PoolRequestContextProvider 从租约账户读取协议上下文

func NewPoolRequestContextProvider

func NewPoolRequestContextProvider(pool *AccountPool) (*PoolRequestContextProvider, error)

NewPoolRequestContextProvider 创建账户协议上下文提供者

func (*PoolRequestContextProvider) RequestContext

func (p *PoolRequestContextProvider) RequestContext(_ context.Context, accountID string) (RequestContext, error)

RequestContext 返回账户时区

type PooledService

type PooledService struct {
	// contains filtered or unexported fields
}

PooledService 在账户租约内调用协议客户端

func NewPooledService

func NewPooledService(pool *AccountPool, client *Client) (*PooledService, error)

NewPooledService 创建多账户协议服务

func (*PooledService) CachedModels

func (s *PooledService) CachedModels() []Model

CachedModels 返回启用账户最近同步目录的并集

func (*PooledService) CopyFileReferencesToLease

func (s *PooledService) CopyFileReferencesToLease(
	ctx context.Context,
	target *AccountLease,
	contents []Content,
) ([]Content, *TemporaryFileCopies, error)

CopyFileReferencesToLease 将文件引用复制到目标账户并返回改写内容

func (*PooledService) CountTokens

func (s *PooledService) CountTokens(ctx context.Context, request TokenCountRequest) (TokenCount, error)

CountTokens 使用支持目标模型的独占账户计数

func (*PooledService) DeleteFile

func (s *PooledService) DeleteFile(ctx context.Context, fileID string) error

DeleteFile 使用资源创建账户删除 Drive 文件和持久绑定

func (*PooledService) DownloadFile

func (s *PooledService) DownloadFile(ctx context.Context, fileID string) (MediaStream, error)

DownloadFile 使用资源创建账户下载 Drive 文件

func (*PooledService) FileMetadata

func (s *PooledService) FileMetadata(ctx context.Context, fileID string) (FileMetadata, error)

FileMetadata 返回公开上传文件的持久元数据

func (*PooledService) Generate

func (s *PooledService) Generate(ctx context.Context, request GenerateRequest) (<-chan Event, error)

Generate 使用支持目标模型的独占账户生成事件流

func (*PooledService) GenerateVideo

func (s *PooledService) GenerateVideo(ctx context.Context, request VideoRequest) (VideoOperation, error)

GenerateVideo 使用一个独占账户创建任务并保存 operation 绑定

func (*PooledService) GetGenerateVideoOperation

func (s *PooledService) GetGenerateVideoOperation(ctx context.Context, operationID string) (VideoOperation, error)

GetGenerateVideoOperation 使用 operation 创建账户轮询并绑定结果文件

func (*PooledService) Models

func (s *PooledService) Models(ctx context.Context) ([]Model, error)

Models 刷新可用账户并返回实时模型并集

func (*PooledService) OpenBidi

func (s *PooledService) OpenBidi(ctx context.Context, request BidiRequest) (*BidiSession, error)

OpenBidi 使用支持目标模型的账户创建双向会话

func (*PooledService) RefreshAccountModels

func (s *PooledService) RefreshAccountModels(ctx context.Context, accountID string) ([]Model, error)

RefreshAccountModels 刷新指定账户的权益与模型目录

func (*PooledService) Transcribe

Transcribe 在同一账户租约内完成上传与生成

func (*PooledService) UploadFile

func (s *PooledService) UploadFile(ctx context.Context, request UploadRequest) (FileRef, error)

UploadFile 使用一个独占账户完成上传并保存资源绑定

func (*PooledService) UploadInlineMediaToLease

func (s *PooledService) UploadInlineMediaToLease(
	ctx context.Context,
	target *AccountLease,
	contents []Content,
	temporary *TemporaryFileCopies,
) ([]Content, *TemporaryFileCopies, error)

UploadInlineMediaToLease 将内联附件上传到目标账户并改写为临时 Drive 引用

type PreparedProtectedRequest

type PreparedProtectedRequest struct {
	Body    []byte
	Headers http.Header
}

PreparedProtectedRequest 表示已写入 fresh proof 的请求

type PromptFeedbackError

type PromptFeedbackError struct {
	Reason string
	Raw    json.RawMessage
}

PromptFeedbackError 表示上游拒绝当前输入且没有返回候选

func (*PromptFeedbackError) Error

func (e *PromptFeedbackError) Error() string

Error 返回上游输入拒绝原因

func (*PromptFeedbackError) Unwrap

func (e *PromptFeedbackError) Unwrap() error

Unwrap 将输入拒绝映射为无效请求

type ProtectedPreparer

type ProtectedPreparer interface {
	Prepare(context.Context, ProtectedRequest) (PreparedProtectedRequest, error)
	BrowserStorageState(context.Context) (StorageState, error)
	SendProtected(context.Context, ProtectedRequest) (*RPCResponse, error)
}

ProtectedPreparer 为一次请求写入 fresh WAA proof 并通过账户固定指纹浏览器发送

type ProtectedPreparerProvider

type ProtectedPreparerProvider interface {
	Worker(context.Context, string, string) (ProtectedPreparer, error)
}

ProtectedPreparerProvider 按账户返回 lazy WAA preparer

type ProtectedPreparerProviderFunc

type ProtectedPreparerProviderFunc func(context.Context, string, string) (ProtectedPreparer, error)

ProtectedPreparerProviderFunc 将函数适配为 ProtectedPreparerProvider

func (ProtectedPreparerProviderFunc) Worker

func (f ProtectedPreparerProviderFunc) Worker(ctx context.Context, accountID string, modelID string) (ProtectedPreparer, error)

Worker 返回账户的 lazy WAA preparer

type ProtectedRequest

type ProtectedRequest struct {
	URL        string
	Headers    http.Header
	Body       []byte
	Prompt     string
	ProofField int
}

ProtectedRequest 表示需要 WAA 保护的 AI Studio 请求

type ProtectedTransport

type ProtectedTransport interface {
	DoProtected(context.Context, GenerateRequest, RPCRequest) (*RPCResponse, error)
}

ProtectedTransport 原子完成 fresh WAA proof、field 5 写入和同 context 发送

type ProtectedTransportFunc

type ProtectedTransportFunc func(context.Context, GenerateRequest, RPCRequest) (*RPCResponse, error)

ProtectedTransportFunc 将函数适配为 ProtectedTransport

func (ProtectedTransportFunc) DoProtected

func (f ProtectedTransportFunc) DoProtected(ctx context.Context, request GenerateRequest, rpc RPCRequest) (*RPCResponse, error)

DoProtected 调用受保护传输函数

type ProtocolEvidenceError

type ProtocolEvidenceError struct {
	Method string
	Path   string
	Detail string
	Raw    json.RawMessage
}

ProtocolEvidenceError 保存无法解释的协议位置和原始值

func (*ProtocolEvidenceError) Error

func (e *ProtocolEvidenceError) Error() string

Error 返回协议证据错误

type ProtocolHeaderProvider

type ProtocolHeaderProvider interface {
	ProtocolHeaders(context.Context, string) (http.Header, error)
}

ProtocolHeaderProvider 按账户提供官方运行时发现的动态公共头

type ProtocolHeaderProviderFunc

type ProtocolHeaderProviderFunc func(context.Context, string) (http.Header, error)

ProtocolHeaderProviderFunc 将函数适配为 ProtocolHeaderProvider

func (ProtocolHeaderProviderFunc) ProtocolHeaders

func (f ProtocolHeaderProviderFunc) ProtocolHeaders(ctx context.Context, accountID string) (http.Header, error)

ProtocolHeaders 调用动态公共头函数

type QuotaCooldown

type QuotaCooldown struct {
	Until  time.Time
	Global bool
	Kind   string
	Reason string
}

QuotaCooldown 表示上游额度限制对应的调度冷却

func QuotaCooldownForError

func QuotaCooldownForError(err error, now time.Time) (QuotaCooldown, bool)

QuotaCooldownForError 解析上游分钟或每日额度限制

type RPCError

type RPCError struct {
	Method     string
	StatusCode int
	Code       int64
	Message    string
	Metadata   map[string]string
}

RPCError 保存上游状态和协议错误码

func (*RPCError) Error

func (e *RPCError) Error() string

Error 返回结构化上游错误

func (*RPCError) HTTPStatus

func (e *RPCError) HTTPStatus() int

HTTPStatus 返回上游 HTTP 状态

type RPCRequest

type RPCRequest struct {
	Method    string
	URL       string
	AccountID string
	RequestID string
	Header    http.Header
	Body      []byte
	Streaming bool
}

RPCRequest 描述交给认证传输层的单次 MakerSuite 请求

type RPCResponse

type RPCResponse struct {
	StatusCode int
	Header     http.Header
	Body       io.ReadCloser
}

RPCResponse 描述认证传输层返回的响应头和实时正文

type RPCTransport

type RPCTransport interface {
	Do(context.Context, RPCRequest) (*RPCResponse, error)
}

RPCTransport 负责认证、账户租约、Cookie 写回和真实网络发送

type RequestContext

type RequestContext struct {
	Timezone string
}

RequestContext 保存账户运行时提供的协议上下文

type RequestContextProvider

type RequestContextProvider interface {
	RequestContext(context.Context, string) (RequestContext, error)
}

RequestContextProvider 按账户返回当前协议上下文

type RequestContextProviderFunc

type RequestContextProviderFunc func(context.Context, string) (RequestContext, error)

RequestContextProviderFunc 将函数适配为 RequestContextProvider

func (RequestContextProviderFunc) RequestContext

func (f RequestContextProviderFunc) RequestContext(ctx context.Context, accountID string) (RequestContext, error)

RequestContext 调用上下文函数

type RequestPhase

type RequestPhase string

RequestPhase 表示受保护请求的当前准备阶段

const (
	// RequestPhasePreparingWAA 表示正在生成 fresh WAA proof
	RequestPhasePreparingWAA RequestPhase = "preparing_waa"
	// RequestPhaseSendingUpstream 表示正在等待 AI Studio 响应头
	RequestPhaseSendingUpstream RequestPhase = "sending_upstream"
	// RequestPhaseStreaming 表示 AI Studio 已经返回流式响应
	RequestPhaseStreaming RequestPhase = "streaming"
)

type ResourceBinding

type ResourceBinding struct {
	Kind      string                 `json:"kind,omitempty"`
	Name      string                 `json:"name,omitempty"`
	MIME      string                 `json:"mime,omitempty"`
	Size      int64                  `json:"size,omitempty"`
	Purpose   string                 `json:"purpose,omitempty"`
	CreatedAt time.Time              `json:"created_at"`
	Video     *VideoResourceMetadata `json:"video,omitempty"`
}

ResourceBinding 记录上游资源的创建账户

type ResponseModality

type ResponseModality string

ResponseModality 表示模型输出模态

const (
	// ResponseModalityText 表示文本输出
	ResponseModalityText ResponseModality = "TEXT"
	// ResponseModalityImage 表示图片输出
	ResponseModalityImage ResponseModality = "IMAGE"
	// ResponseModalityAudio 表示音频输出
	ResponseModalityAudio ResponseModality = "AUDIO"
)

type Role

type Role string

Role 表示规范消息角色

const (
	// RoleUser 表示用户消息
	RoleUser Role = "user"
	// RoleAssistant 表示模型消息
	RoleAssistant Role = "assistant"
	// RoleTool 表示工具结果消息
	RoleTool Role = "tool"
)

type SearchEntryPoint

type SearchEntryPoint struct {
	RenderedContent string `json:"rendered_content,omitempty"`
	SDKBlob         string `json:"sdk_blob,omitempty"`
}

SearchEntryPoint 表示 Google Search 返回的搜索入口

type Service

type Service interface {
	Models(context.Context) ([]Model, error)
	CountTokens(context.Context, TokenCountRequest) (TokenCount, error)
	Generate(context.Context, GenerateRequest) (<-chan Event, error)
}

Service 定义公开协议适配器依赖的最小能力

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer 为 AI Studio 请求生成三段 SAPISID 授权头

func NewSigner

func NewSigner() *Signer

NewSigner 创建 AI Studio 官方来源的签名器

func NewSignerForOrigin

func NewSignerForOrigin(origin string) (*Signer, error)

NewSignerForOrigin 创建指定来源的签名器

func (*Signer) Authorization

func (s *Signer) Authorization(state StorageState) (string, error)

Authorization 使用当前时间生成授权头

func (*Signer) AuthorizationAt

func (s *Signer) AuthorizationAt(state StorageState, now time.Time) (string, error)

AuthorizationAt 使用指定时间生成授权头

func (*Signer) Sign

func (s *Signer) Sign(state StorageState) (string, error)

Sign 使用当前时间生成授权头

type SpeakerVoiceConfig

type SpeakerVoiceConfig struct {
	Speaker   string `json:"speaker"`
	VoiceName string `json:"voice_name"`
}

SpeakerVoiceConfig 表示多说话人的声音选择

type SpeechConfig

type SpeechConfig struct {
	VoiceName string               `json:"voice_name,omitempty"`
	Speakers  []SpeakerVoiceConfig `json:"speakers,omitempty"`
}

SpeechConfig 表示语音生成参数

type StateCookie

type StateCookie struct {
	Name         string  `json:"name"`
	Value        string  `json:"value"`
	Domain       string  `json:"domain"`
	Path         string  `json:"path"`
	Expires      float64 `json:"expires"`
	HTTPOnly     bool    `json:"httpOnly"`
	Secure       bool    `json:"secure"`
	SameSite     string  `json:"sameSite"`
	PartitionKey string  `json:"partitionKey,omitempty"`
}

StateCookie 表示 Playwright storage state 中的 Cookie

type StorageItem

type StorageItem struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

StorageItem 表示浏览器本地存储项

type StorageOrigin

type StorageOrigin struct {
	Origin       string        `json:"origin"`
	LocalStorage []StorageItem `json:"localStorage"`
}

StorageOrigin 表示 Playwright storage state 中的站点数据

type StorageState

type StorageState struct {
	Cookies []StateCookie   `json:"cookies"`
	Origins []StorageOrigin `json:"origins"`
	// contains filtered or unexported fields
}

StorageState 表示可原样写回的 Playwright storage state

func LoadStorageState

func LoadStorageState(filePath string) (StorageState, error)

LoadStorageState 读取并校验 Playwright storage state

func (StorageState) AuthExtension

func (s StorageState) AuthExtension() (AuthExtension, bool, error)

AuthExtension 返回 aistudio2api 认证扩展

func (StorageState) CookieHeader

func (s StorageState) CookieHeader(targetURL string, now time.Time) (string, error)

CookieHeader 为目标 URL 构造当前有效的 Cookie 请求头

func (StorageState) CookieValue

func (s StorageState) CookieValue(name string, targetURL string, now time.Time) (string, bool)

CookieValue 返回目标 URL 下最具体的同名 Cookie

func (StorageState) MarshalJSON

func (s StorageState) MarshalJSON() ([]byte, error)

MarshalJSON 保留 storage state 的扩展根字段

func (*StorageState) MergeSetCookieHeaders

func (s *StorageState) MergeSetCookieHeaders(headers []string, sourceURL string, now time.Time) error

MergeSetCookieHeaders 将响应轮换的 Cookie 合并到 storage state

func (*StorageState) SetAuthExtension

func (s *StorageState) SetAuthExtension(extension AuthExtension) error

SetAuthExtension 写入 aistudio2api 认证扩展

func (*StorageState) UnmarshalJSON

func (s *StorageState) UnmarshalJSON(data []byte) error

UnmarshalJSON 解析 storage state 并保存扩展根字段

func (StorageState) Validate

func (s StorageState) Validate() error

Validate 校验 storage state 的浏览器字段

type TemporaryFileCopies

type TemporaryFileCopies struct {
	// contains filtered or unexported fields
}

TemporaryFileCopies 保存一次请求创建的临时 Drive 文件

func (*TemporaryFileCopies) Cleanup

func (copies *TemporaryFileCopies) Cleanup() error

Cleanup 在目标账户租约释放前删除全部临时 Drive 副本

func (*TemporaryFileCopies) Count

func (copies *TemporaryFileCopies) Count() int

Count 返回本次请求创建的临时文件数

func (*TemporaryFileCopies) SourceAccountIDs

func (copies *TemporaryFileCopies) SourceAccountIDs() []string

SourceAccountIDs 返回临时文件的来源账户

type TokenCount

type TokenCount struct {
	InputTokens int64 `json:"input_tokens"`
}

TokenCount 表示上游返回的权威计数

func ParseTokenCount

func ParseTokenCount(source io.Reader) (TokenCount, error)

ParseTokenCount 解码现场确认的 CountTokens field 1

type TokenCountRequest

type TokenCountRequest struct {
	Model    string    `json:"model"`
	System   string    `json:"system,omitempty"`
	Contents []Content `json:"contents"`
	Tools    Tools     `json:"tools,omitempty"`
}

TokenCountRequest 表示计数请求

type ToolConfig

type ToolConfig struct {
	Mode string `json:"mode,omitempty"`
}

ToolConfig 表示工具启用策略

type Tools

type Tools struct {
	Functions    []FunctionDeclaration `json:"functions,omitempty"`
	Google       []string              `json:"google,omitempty"`
	GoogleSearch *GoogleSearchOptions  `json:"google_search,omitempty"`
	ToolConfig   ToolConfig            `json:"tool_config,omitempty"`
}

Tools 表示一次请求启用的工具

type TranscriptDuration

type TranscriptDuration struct {
	Seconds int64 `json:"seconds"`
	Nanos   int64 `json:"nanos,omitempty"`
}

TranscriptDuration 表示转录时间值

type TranscriptMetadata

type TranscriptMetadata struct {
	Text       string                `json:"text"`
	Speaker    string                `json:"speaker,omitempty"`
	Timestamps []TranscriptTimestamp `json:"timestamps,omitempty"`
}

TranscriptMetadata 表示转录正文附带的说话人和时间信息

type TranscriptTimestamp

type TranscriptTimestamp struct {
	Start TranscriptDuration `json:"start"`
	End   TranscriptDuration `json:"end"`
}

TranscriptTimestamp 表示转录文本的时间范围

type TranscriptionConfig

type TranscriptionConfig struct {
	WordTimestamps     bool     `json:"word_timestamps,omitempty"`
	SpeakerLabels      bool     `json:"speaker_labels,omitempty"`
	CustomVocabulary   []string `json:"custom_vocabulary,omitempty"`
	LanguageCodes      []string `json:"language_codes,omitempty"`
	SmartTranscription bool     `json:"smart_transcription,omitempty"`
}

TranscriptionConfig 表示音频转录参数

type TranscriptionRequest

type TranscriptionRequest struct {
	ID                    string
	Model                 string
	Name                  string
	MIME                  string
	Size                  int64
	Reader                io.ReadSeeker
	Config                GenerationConfig
	CandidateAccountIDs   []string
	RecoverWAARuntime     func(context.Context, string, error) (bool, error)
	ObserveAccountFailure func(string, error)
}

TranscriptionRequest 表示一次音频上传与转录请求

type TranscriptionResult

type TranscriptionResult struct {
	Text          string
	Segments      []TranscriptMetadata
	Usage         Usage
	FinishReason  string
	ProviderModel string
	FirstEvent    time.Duration
	FirstContent  time.Duration
	// contains filtered or unexported fields
}

TranscriptionResult 表示完整转录及其上游元数据

type TranscriptionService

type TranscriptionService interface {
	Transcribe(context.Context, TranscriptionRequest) (TranscriptionResult, error)
}

TranscriptionService 定义音频转录公开端点所需能力

type UnverifiedProtocolError

type UnverifiedProtocolError struct {
	Feature string
}

UnverifiedProtocolError 表示当前现场证据尚不足以发送某项能力

func (*UnverifiedProtocolError) Error

func (e *UnverifiedProtocolError) Error() string

Error 返回未验证协议边界

type UploadRequest

type UploadRequest struct {
	AccountID      string
	Name           string
	MIME           string
	Purpose        string
	Size           int64
	MaxSize        int64
	Reader         io.Reader
	ResolvePurpose func(context.Context) (string, error)
}

UploadRequest 表示一次 Drive 文件上传

type Usage

type Usage struct {
	InputTokens         int64 `json:"input_tokens"`
	OutputTokens        int64 `json:"output_tokens"`
	ReasoningTokens     int64 `json:"reasoning_tokens,omitempty"`
	ToolTokens          int64 `json:"tool_tokens,omitempty"`
	TotalTokens         int64 `json:"total_tokens"`
	OutputTokensMissing bool  `json:"-"`
}

Usage 表示一次生成的 token 用量

type VideoImage

type VideoImage struct {
	InlineData *Blob
	File       *FileRef
}

VideoImage 表示 Veo 起始帧

type VideoOperation

type VideoOperation struct {
	ID        string
	Done      bool
	File      *FileRef
	Model     string
	Seconds   string
	Size      string
	CreatedAt time.Time
	// contains filtered or unexported fields
}

VideoOperation 表示 Veo 私有长任务状态

func ParseVideoOperation

func ParseVideoOperation(source io.Reader, method string) (VideoOperation, error)

ParseVideoOperation 解码 GenerateVideo 与轮询返回的 operation

func (VideoOperation) ModelAccessCheckedAt

func (operation VideoOperation) ModelAccessCheckedAt() time.Time

ModelAccessCheckedAt 返回上游接受视频任务的资格时间

type VideoProtectedTransport

type VideoProtectedTransport interface {
	DoProtectedVideo(context.Context, VideoRequest, RPCRequest) (*RPCResponse, error)
}

VideoProtectedTransport 原子完成 Veo fresh WAA proof、field 8 写入和同 context 发送

type VideoRequest

type VideoRequest struct {
	Model             string
	Prompt            string
	Count             int
	AspectRatio       string
	DurationSeconds   int
	Resolution        string
	Size              string
	AccountID         string
	StartImage        *VideoImage
	RecoverWAARuntime func(context.Context, string, error) (bool, error)
}

VideoRequest 表示一次 Veo 长任务请求

type VideoResourceMetadata

type VideoResourceMetadata struct {
	Model   string `json:"model"`
	Seconds string `json:"seconds"`
	Size    string `json:"size"`
}

VideoResourceMetadata 保存 OpenAI 视频对象的持久字段

type VideoService

type VideoService interface {
	GenerateVideo(context.Context, VideoRequest) (VideoOperation, error)
	GetGenerateVideoOperation(context.Context, string) (VideoOperation, error)
	DownloadFile(context.Context, string) (MediaStream, error)
}

VideoService 定义长任务视频适配器依赖的能力

type WorkerPhase

type WorkerPhase string

WorkerPhase 表示账户 runtime 当前阶段

const (
	// WorkerStarting 表示 runtime 进程正在启动
	WorkerStarting WorkerPhase = "starting"
	// WorkerBootstrapping 表示官方页面正在初始化 WAA
	WorkerBootstrapping WorkerPhase = "bootstrapping"
	// WorkerReady 表示 runtime 可以接受请求
	WorkerReady WorkerPhase = "ready"
	// WorkerBusy 表示 runtime 正在处理受保护请求
	WorkerBusy WorkerPhase = "busy"
	// WorkerClosing 表示 runtime 正在关闭
	WorkerClosing WorkerPhase = "closing"
	// WorkerClosed 表示 runtime 已关闭
	WorkerClosed WorkerPhase = "closed"
	// WorkerFailed 表示 runtime 已失效
	WorkerFailed WorkerPhase = "failed"
)

type WorkerProtectedTransport

type WorkerProtectedTransport struct {
	// contains filtered or unexported fields
}

WorkerProtectedTransport 将 fresh proof 交给同租约 HTTP 传输

func NewWorkerProtectedTransport

func NewWorkerProtectedTransport(options WorkerProtectedTransportOptions) (*WorkerProtectedTransport, error)

NewWorkerProtectedTransport 创建基于 lazy WAA preparer 的受保护传输

func (*WorkerProtectedTransport) DoProtected

func (t *WorkerProtectedTransport) DoProtected(ctx context.Context, request GenerateRequest, rpc RPCRequest) (*RPCResponse, error)

DoProtected 写入 fresh proof 后通过 Camoufox 发送 GenerateContent

func (*WorkerProtectedTransport) DoProtectedVideo

func (t *WorkerProtectedTransport) DoProtectedVideo(ctx context.Context, request VideoRequest, rpc RPCRequest) (*RPCResponse, error)

DoProtectedVideo 写入 Veo fresh proof 后发送请求

func (*WorkerProtectedTransport) OpenBidiProtected

func (t *WorkerProtectedTransport) OpenBidiProtected(
	ctx context.Context,
	request BidiRequest,
	runtime RequestContext,
	lease *AccountLease,
	release func() error,
) (*BidiSession, error)

OpenBidiProtected 使用当前租约建立 WebChannel 会话

type WorkerProtectedTransportOptions

type WorkerProtectedTransportOptions struct {
	Transport    *MakerSuiteHTTPTransport
	Workers      ProtectedPreparerProvider
	SetupTimeout time.Duration
}

WorkerProtectedTransportOptions 定义受保护请求的 proof 与 HTTP 依赖

type WorkerState

type WorkerState struct {
	AccountID    string
	Phase        WorkerPhase
	PID          int
	RuntimeID    string
	PageURL      string
	RequestCount uint64
	LastError    string
}

WorkerState 表示账户 runtime 的可观察状态

Jump to

Keyboard shortcuts

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