Documentation
¶
Index ¶
- type AccountSource
- type Bootstrap
- type Citation
- type Client
- func (c *Client) AcquireRequest(ctx context.Context) (func(), error)
- func (c *Client) CloseIdleConnections()
- func (c *Client) ContextWindow() int
- func (c *Client) FetchMedia(ctx context.Context, mediaURL string) ([]byte, error)
- func (c *Client) FetchUsage(ctx context.Context) (UsageInfo, error)
- func (c *Client) Init(ctx context.Context) error
- func (c *Client) Models() []Model
- func (c *Client) ResolveModel(id string) (Model, error)
- func (c *Client) Stream(ctx context.Context, request GenerateRequest, emit func(Event) error) error
- func (c *Client) UploadFile(ctx context.Context, data []byte, filename string) (string, error)
- type CodeEventType
- type CodeExecutionEvent
- type ConversationSnapshot
- type ConversationState
- type Cookie
- type Event
- type EventKind
- type EventMetadataData
- type FileData
- type Fingerprint
- type FinishReason
- type FrameDecoder
- type GenerateRequest
- type Media
- type MediaType
- type Model
- type ModelCatalog
- type Phase
- type ProtocolError
- type SnapshotOperation
- type ThinkingMode
- type Usage
- type UsageInfo
- type UsageWindow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountSource ¶
type AccountSource struct {
ID string
Cookies []Cookie
Fingerprint Fingerprint
Save func([]Cookie) error
Refresh func(context.Context) ([]Cookie, error)
}
AccountSource 表示账号固定身份和 Cookie 持久化入口
type Bootstrap ¶
type Bootstrap struct {
SNlM0e string
BL string
FSID string
Catalog ModelCatalog
}
Bootstrap 表示首页和模型目录共同产生的运行参数
type Citation ¶
type Citation struct {
ID int `json:"id"`
SourceID string `json:"source_id,omitempty"`
Claim string `json:"claim,omitempty"`
Title string `json:"title,omitempty"`
URL string `json:"url"`
Favicon string `json:"favicon,omitempty"`
Snippet string `json:"snippet,omitempty"`
Publisher string `json:"publisher,omitempty"`
Start int `json:"start"`
End int `json:"end"`
}
Citation 表示正文引用标记对应的网页来源
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 表示与单一账号身份绑定的 Gemini Web 协议客户端
func NewClient ¶
func NewClient(source AccountSource, proxyURL string, saveHistory bool) (*Client, error)
NewClient 创建固定 Cookie、代理和指纹的账号客户端
func (*Client) AcquireRequest ¶
AcquireRequest 独占同一账号的完整上游请求链
func (*Client) CloseIdleConnections ¶
func (c *Client) CloseIdleConnections()
CloseIdleConnections 关闭协议客户端的空闲连接
func (*Client) FetchMedia ¶
FetchMedia 使用账号固定身份和 Cookie 下载媒体内容
func (*Client) FetchUsage ¶
FetchUsage 读取官网当前账号用量
func (*Client) ResolveModel ¶
ResolveModel 在当前账号模型目录中解析公开 ID
type CodeEventType ¶
type CodeEventType string
CodeEventType 表示 Gemini Web 内置代码执行事件类型
const ( CodeReference CodeEventType = "code_reference" CodeStdout CodeEventType = "code_stdout" CodeStderr CodeEventType = "code_stderr" )
type CodeExecutionEvent ¶
type CodeExecutionEvent struct {
Index int
Type CodeEventType
Language string
Offset int
Complete bool
}
CodeExecutionEvent 表示 Google 已执行的代码及其结果
type ConversationSnapshot ¶
ConversationSnapshot 表示可序列化的网页会话三元组
type ConversationState ¶
type ConversationState struct {
// contains filtered or unexported fields
}
ConversationState 保存线程安全的网页会话状态
func NewConversationState ¶
func NewConversationState() *ConversationState
NewConversationState 创建空网页会话状态
func NewConversationStateFrom ¶
func NewConversationStateFrom(snapshot ConversationSnapshot) *ConversationState
NewConversationStateFrom 从已有三元组创建网页会话状态
func (*ConversationState) Snapshot ¶
func (s *ConversationState) Snapshot() ConversationSnapshot
Snapshot 返回当前会话三元组副本
func (*ConversationState) Update ¶
func (s *ConversationState) Update(snapshot ConversationSnapshot)
Update 原子替换非空会话字段
type Cookie ¶
type Cookie struct {
Name string `json:"name"`
Value string `json:"value"`
Domain string `json:"domain"`
Path string `json:"path"`
Expires int64 `json:"expires"`
HTTPOnly bool `json:"http_only"`
Secure bool `json:"secure"`
SameSite string `json:"same_site"`
}
Cookie 表示可无损写回认证状态的 Cookie
type Event ¶
type Event struct {
Kind EventKind
Candidate int
Operation SnapshotOperation
Delta string
Snapshot string
PrefixLength int
Phase Phase
Session ConversationSnapshot
Code *CodeExecutionEvent
Citations []Citation
Media *Media
Metadata *EventMetadataData
Usage *Usage
FinishReason FinishReason
Err *ProtocolError
}
Event 表示所有公开适配器共享的上游事件
type EventKind ¶
type EventKind string
EventKind 表示规范化协议事件类型
const ( EventSession EventKind = "session" EventText EventKind = "text" EventThought EventKind = "thought" EventCode EventKind = "code" EventCitations EventKind = "citations" EventMedia EventKind = "media" EventImageProgress EventKind = "image_progress" EventPhase EventKind = "phase" EventMetadata EventKind = "metadata" EventError EventKind = "error" EventDone EventKind = "done" )
type EventMetadataData ¶
type EventMetadataData struct {
Title string
ControlToken string
ModelHash string
ModelName string
}
EventMetadataData 表示页面协议返回的附加元数据
type Fingerprint ¶
type Fingerprint struct {
Browser string `json:"browser"`
Version string `json:"version"`
Platform string `json:"platform"`
UserAgent string `json:"user_agent"`
Language string `json:"language"`
TLSProfile string `json:"tls_profile"`
}
Fingerprint 表示与账号长期绑定的 HTTP 客户端指纹
type FinishReason ¶
type FinishReason string
FinishReason 表示规范化结束原因
const ( FinishUnknown FinishReason = "unknown" FinishStop FinishReason = "stop" FinishCancelled FinishReason = "cancelled" FinishError FinishReason = "error" )
type FrameDecoder ¶
type FrameDecoder struct {
// contains filtered or unexported fields
}
FrameDecoder 将 Google 累计帧转换为唯一规范事件流
func (*FrameDecoder) Decode ¶
func (d *FrameDecoder) Decode(reader io.Reader, state *ConversationState, emit func(Event) error) error
Decode 增量解析协议帧并原子更新会话状态
type GenerateRequest ¶
type GenerateRequest struct {
Prompt string
Model string
ModelMode int
ThinkingMode ThinkingMode
Files []FileData
Conversation *ConversationState
}
GenerateRequest 表示一次网页协议生成请求
type Media ¶
type Media struct {
Type MediaType `json:"type"`
URL string `json:"url"`
Title string `json:"title,omitempty"`
Alt string `json:"alt,omitempty"`
FileName string `json:"file_name,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
Generator string `json:"generator,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
SizeBytes int `json:"size_bytes,omitempty"`
Offset int `json:"offset"`
}
Media 表示规范事件携带的网页或生成媒体
type MediaType ¶
type MediaType string
MediaType 表示 Gemini Web 媒体类型
const (
MediaGeneratedImage MediaType = "generated_image"
)
type Model ¶
type Model struct {
ID string
DisplayName string
Description string
Hash string
Header string
Capabilities []string
Mode int
Default bool
}
Model 表示账号启动时发现的网页模型
type ModelCatalog ¶
type ModelCatalog struct {
// contains filtered or unexported fields
}
ModelCatalog 表示单个账号当前可用的模型目录
type ProtocolError ¶
ProtocolError 表示 HTTP 或帧内协议错误
type SnapshotOperation ¶
type SnapshotOperation string
SnapshotOperation 表示累计快照相对上一版本的变化
const ( SnapshotAppend SnapshotOperation = "append" SnapshotReplace SnapshotOperation = "replace" SnapshotTruncate SnapshotOperation = "truncate" )
type ThinkingMode ¶
type ThinkingMode int
ThinkingMode 表示 Gemini Web 思考策略
const ( // ThinkingStandard 使用标准思考策略 ThinkingStandard ThinkingMode = iota // ThinkingExtended 使用扩展思考策略 ThinkingExtended )
type UsageInfo ¶
type UsageInfo struct {
Tier string `json:"tier"`
TierCode int `json:"tier_code"`
Current *UsageWindow `json:"current,omitempty"`
Weekly *UsageWindow `json:"weekly,omitempty"`
RemainingCredits *float64 `json:"remaining_credits,omitempty"`
UseOverageAICredits bool `json:"use_overage_ai_credits"`
FetchedAt time.Time `json:"fetched_at"`
}
UsageInfo 表示单个账号的官网用量信息
type UsageWindow ¶
type UsageWindow struct {
UsedRatio float64 `json:"used_ratio"`
ResetAt time.Time `json:"reset_at"`
}
UsageWindow 表示官网展示的一段用量窗口