types

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RoleUser 用户角色
	RoleUser Role = "user"

	// RoleAssistant AI助手角色
	RoleAssistant Role = "assistant"

	// RoleSystem 系统角色
	RoleSystem Role = "system"

	// RoleTool 工具角色
	RoleTool Role = "tool"

	// 兼容性别名
	MessageRoleSystem    = RoleSystem
	MessageRoleAssistant = RoleAssistant
	MessageRoleUser      = RoleUser
	MessageRoleTool      = RoleTool
)

Variables

View Source
var BreakpointPostTool = BreakpointState{
	Enabled:   true,
	Condition: "post_tool",
}

BreakpointPostTool 工具执行后的断点

View Source
var BreakpointPreModel = BreakpointState{
	Enabled:   true,
	Condition: "pre_model",
}

BreakpointPreModel 模型调用前的断点

View Source
var BreakpointPreTool = BreakpointState{
	Enabled:   true,
	Condition: "pre_tool",
}

BreakpointPreTool 工具执行前的断点

View Source
var BreakpointReady = BreakpointState{
	Enabled: false,
}

BreakpointReady 就绪状态的断点(未启用)

View Source
var BreakpointStreamingModel = BreakpointState{
	Enabled:   true,
	Condition: "streaming_model",
}

BreakpointStreamingModel 模型流式响应中的断点

View Source
var BreakpointToolExecuting = BreakpointState{
	Enabled:   true,
	Condition: "tool_executing",
}

BreakpointToolExecuting 工具执行中的断点

View Source
var BreakpointToolPending = BreakpointState{
	Enabled:   true,
	Condition: "tool_pending",
}

BreakpointToolPending 工具调用待处理的断点

Functions

This section is empty.

Types

type AccumulatedToolCall

type AccumulatedToolCall struct {
	ID        string
	Type      string
	Name      string
	Arguments string // 累积的 JSON 参数
}

AccumulatedToolCall 累积的工具调用

type AgentChannel

type AgentChannel string

AgentChannel 事件通道类型

const (
	ChannelProgress AgentChannel = "progress"
	ChannelControl  AgentChannel = "control"
	ChannelMonitor  AgentChannel = "monitor"
)

type AgentConfig

type AgentConfig struct {
	AgentID          string                            `json:"agent_id,omitempty"`
	TemplateID       string                            `json:"template_id"`
	TemplateVersion  string                            `json:"template_version,omitempty"`
	ModelConfig      *ModelConfig                      `json:"model_config,omitempty"`
	Sandbox          *SandboxConfig                    `json:"sandbox,omitempty"`
	Tools            []string                          `json:"tools,omitempty"`
	Middlewares      []string                          `json:"middlewares,omitempty"`       // Middleware 列表 (Phase 6C)
	MiddlewareConfig map[string]map[string]interface{} `json:"middleware_config,omitempty"` // 各中间件的自定义配置
	ExposeThinking   bool                              `json:"expose_thinking,omitempty"`
	// RoutingProfile 可选的路由配置标识,例如 "quality-first"、"cost-first"。
	// 当配置了 Router 时,可以根据该字段选择不同的模型路由策略。
	RoutingProfile string                 `json:"routing_profile,omitempty"`
	Overrides      *AgentConfigOverrides  `json:"overrides,omitempty"`
	Context        *ContextManagerOptions `json:"context,omitempty"`
	SkillsPackage  *SkillsPackageConfig   `json:"skills_package,omitempty"` // Skills 包配置
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
}

AgentConfig Agent创建配置

type AgentConfigOverrides

type AgentConfigOverrides struct {
	Permission *PermissionConfig `json:"permission,omitempty"`
	Todo       *TodoConfig       `json:"todo,omitempty"`
}

AgentConfigOverrides Agent配置覆盖

type AgentEventEnvelope

type AgentEventEnvelope struct {
	Cursor   int64       `json:"cursor"`
	Bookmark Bookmark    `json:"bookmark"`
	Event    interface{} `json:"event"`
}

AgentEventEnvelope 事件封装(带Bookmark)

type AgentInfo

type AgentInfo struct {
	ID            string                 `json:"id"`                    // Agent ID
	AgentID       string                 `json:"agent_id"`              // Agent ID(别名)
	TemplateID    string                 `json:"template_id"`           // 使用的模板 ID
	Model         string                 `json:"model"`                 // 模型名称
	CreatedAt     time.Time              `json:"created_at"`            // 创建时间
	UpdatedAt     time.Time              `json:"updated_at"`            // 更新时间
	State         AgentState             `json:"state"`                 // 当前状态
	StepCount     int                    `json:"step_count"`            // 总步骤数
	Cursor        int                    `json:"cursor"`                // 当前游标
	MessageCount  int                    `json:"message_count"`         // 消息数量(新字段)
	Lineage       []string               `json:"lineage"`               // 血缘关系(新字段)
	ConfigVersion string                 `json:"config_version"`        // 配置版本(新字段)
	Metadata      map[string]interface{} `json:"metadata"`              // 自定义元数据
	Tags          []string               `json:"tags,omitempty"`        // 标签
	Description   string                 `json:"description,omitempty"` // 描述
}

AgentInfo Agent 元信息

type AgentRuntimeState

type AgentRuntimeState string

AgentRuntimeState Agent运行时状态

const (
	// AgentStateReady Agent就绪
	AgentStateReady AgentRuntimeState = "ready"

	// AgentStateWorking Agent工作中
	AgentStateWorking AgentRuntimeState = "working"

	// StateIdle Agent空闲
	StateIdle AgentRuntimeState = "idle"

	// StateRunning Agent运行中
	StateRunning AgentRuntimeState = "running"

	// StatePaused Agent暂停
	StatePaused AgentRuntimeState = "paused"

	// StateCompleted Agent完成
	StateCompleted AgentRuntimeState = "completed"

	// StateFailed Agent失败
	StateFailed AgentRuntimeState = "failed"
)

type AgentState

type AgentState string

AgentState Agent 状态

const (
	AgentStateIdle      AgentState = "idle"      // 空闲
	AgentStateRunning   AgentState = "running"   // 运行中
	AgentStateWaiting   AgentState = "waiting"   // 等待中(等待工具调用结果)
	AgentStateCompleted AgentState = "completed" // 已完成
	AgentStateFailed    AgentState = "failed"    // 失败
	AgentStateCancelled AgentState = "cancelled" // 已取消
)

type AgentStatus

type AgentStatus struct {
	AgentID      string            `json:"agent_id"`       // Agent ID
	State        AgentRuntimeState `json:"state"`          // 运行时状态
	StepCount    int               `json:"step_count"`     // 步骤数
	LastSfpIndex int               `json:"last_sfp_index"` // 最后 SFP 索引
	LastBookmark *Bookmark         `json:"last_bookmark"`  // 最后书签
	Cursor       int64             `json:"cursor"`         // 游标
	Breakpoint   BreakpointState   `json:"breakpoint"`     // 断点状态
}

AgentStatus Agent 实时状态

type AgentTemplateDefinition

type AgentTemplateDefinition struct {
	ID           string                `json:"id"`
	Version      string                `json:"version,omitempty"`
	SystemPrompt string                `json:"system_prompt"`
	Model        string                `json:"model,omitempty"`
	Tools        interface{}           `json:"tools"` // []string or "*"
	Permission   *PermissionConfig     `json:"permission,omitempty"`
	Runtime      *AgentTemplateRuntime `json:"runtime,omitempty"`
}

AgentTemplateDefinition Agent模板定义

type AgentTemplateRuntime

type AgentTemplateRuntime struct {
	ExposeThinking     bool                   `json:"expose_thinking,omitempty"`
	Todo               *TodoConfig            `json:"todo,omitempty"`
	SubAgents          *SubAgentConfig        `json:"subagents,omitempty"`
	Metadata           map[string]interface{} `json:"metadata,omitempty"`
	ToolTimeoutMs      int                    `json:"tool_timeout_ms,omitempty"`
	MaxToolConcurrency int                    `json:"max_tool_concurrency,omitempty"`
	ToolsManual        *ToolsManualConfig     `json:"tools_manual,omitempty"`
}

AgentTemplateRuntime Agent模板运行时配置

type AudioContent

type AudioContent struct {
	// Type 音频来源类型: "url", "base64"
	Type string `json:"type"`

	// Source 音频源
	Source string `json:"source"`

	// MimeType MIME 类型,如 "audio/mp3", "audio/wav"
	MimeType string `json:"mime_type,omitempty"`

	// Format 音频格式 (用于某些 Provider)
	Format string `json:"format,omitempty"`

	// Transcript 音频转录文本 (可选)
	Transcript string `json:"transcript,omitempty"`
}

AudioContent 音频内容

func (*AudioContent) GetMediaType

func (a *AudioContent) GetMediaType() string

func (*AudioContent) IsContentBlock

func (a *AudioContent) IsContentBlock()

type Bookmark

type Bookmark struct {
	// Cursor 游标位置
	Cursor int64 `json:"cursor"`

	// Timestamp 时间戳
	Timestamp int64 `json:"timestamp,omitempty"`
}

Bookmark 表示事件流的书签位置

type BreakpointState

type BreakpointState struct {
	// Enabled 是否启用
	Enabled bool `json:"enabled"`

	// Condition 断点条件
	Condition string `json:"condition,omitempty"`

	// HitCount 命中次数
	HitCount int `json:"hit_count,omitempty"`
}

BreakpointState 断点状态

type CacheControlBlock

type CacheControlBlock struct {
	// Type 缓存类型: "ephemeral"
	Type string `json:"type"`

	// Content 被缓存的内容
	Content ContentBlock `json:"content"`
}

CacheControlBlock 缓存控制块 用于 Prompt Caching 功能

func (*CacheControlBlock) IsContentBlock

func (c *CacheControlBlock) IsContentBlock()

type CloudCredentials

type CloudCredentials struct {
	AccessKeyID     string `json:"access_key_id,omitempty"`
	AccessKeySecret string `json:"access_key_secret,omitempty"`
	Token           string `json:"token,omitempty"`
}

CloudCredentials 云平台凭证

type CloudSandboxConfig

type CloudSandboxConfig struct {
	Provider    string           `json:"provider"` // "aliyun", "volcengine"
	Region      string           `json:"region"`
	Credentials CloudCredentials `json:"credentials"`
	SessionID   string           `json:"session_id,omitempty"`
	Resources   ResourceLimits   `json:"resources,omitempty"`
}

CloudSandboxConfig 云沙箱配置

type CompleteResult

type CompleteResult struct {
	Status        string    `json:"status"` // "ok" or "paused"
	Text          string    `json:"text,omitempty"`
	Last          *Bookmark `json:"last,omitempty"`
	PermissionIDs []string  `json:"permission_ids,omitempty"`
}

CompleteResult 完成结果

type ContentBlock

type ContentBlock interface {
	IsContentBlock()
}

ContentBlock 内容块接口

type ContentBlockHelper

type ContentBlockHelper struct{}

ContentBlockHelper 内容块辅助函数

func (ContentBlockHelper) ExtractText

func (h ContentBlockHelper) ExtractText(blocks []ContentBlock) string

ExtractText 从 ContentBlocks 中提取所有文本

func (ContentBlockHelper) GetMediaTypes

func (h ContentBlockHelper) GetMediaTypes(blocks []ContentBlock) []string

GetMediaTypes 获取所有媒体类型

func (ContentBlockHelper) HasMultimodal

func (h ContentBlockHelper) HasMultimodal(blocks []ContentBlock) bool

HasMultimodal 检查是否包含多模态内容

type ContextManagerOptions

type ContextManagerOptions struct {
	MaxTokens         int    `json:"max_tokens"`
	CompressToTokens  int    `json:"compress_to_tokens"`
	CompressionModel  string `json:"compression_model,omitempty"`
	EnableCompression bool   `json:"enable_compression"`
}

ContextManagerOptions 上下文管理配置

type ControlPermissionDecidedEvent

type ControlPermissionDecidedEvent struct {
	CallID    string `json:"call_id"`
	Decision  string `json:"decision"` // "allow" or "deny"
	DecidedBy string `json:"decided_by"`
	Note      string `json:"note,omitempty"`
}

ControlPermissionDecidedEvent 权限决策事件

func (*ControlPermissionDecidedEvent) Channel

func (*ControlPermissionDecidedEvent) EventType

func (e *ControlPermissionDecidedEvent) EventType() string

type ControlPermissionRequiredEvent

type ControlPermissionRequiredEvent struct {
	Call    ToolCallSnapshot `json:"call"`
	Respond RespondFunc      `json:"-"` // 不序列化回调函数
}

ControlPermissionRequiredEvent 权限请求事件

func (*ControlPermissionRequiredEvent) Channel

func (*ControlPermissionRequiredEvent) EventType

func (e *ControlPermissionRequiredEvent) EventType() string

type DocumentContent

type DocumentContent struct {
	// Type 文档类型: "url", "base64", "text"
	Type string `json:"type"`

	// Source 文档源
	Source string `json:"source"`

	// MimeType MIME 类型,如 "application/pdf", "text/plain"
	MimeType string `json:"mime_type,omitempty"`

	// Title 文档标题
	Title string `json:"title,omitempty"`
}

DocumentContent 文档内容

func (*DocumentContent) GetMediaType

func (d *DocumentContent) GetMediaType() string

func (*DocumentContent) IsContentBlock

func (d *DocumentContent) IsContentBlock()

type Event

type Event struct {
	Type      string                 `json:"type"`               // 事件类型
	Data      interface{}            `json:"data"`               // 事件数据
	Timestamp time.Time              `json:"timestamp"`          // 时间戳
	Source    string                 `json:"source,omitempty"`   // 事件源
	Metadata  map[string]interface{} `json:"metadata,omitempty"` // 元数据
}

Event 事件类型(用于工具和 Agent 之间的通信)

type EventType

type EventType interface {
	Channel() AgentChannel
	EventType() string
}

EventType 事件类型基础接口

type ExecutionMode

type ExecutionMode string

ExecutionMode 执行模式

const (
	// ExecutionModeStreaming 流式模式(默认,实时反馈)
	ExecutionModeStreaming ExecutionMode = "streaming"
	// ExecutionModeNonStreaming 非流式模式(快速,批量处理)
	ExecutionModeNonStreaming ExecutionMode = "non-streaming"
	// ExecutionModeAuto 自动选择(根据任务类型智能选择)
	ExecutionModeAuto ExecutionMode = "auto"
)

type ImageContent

type ImageContent struct {
	// Type 图片来源类型: "url", "base64"
	Type string `json:"type"`

	// Source 图片源
	// - 当 Type="url" 时,Source 是图片 URL
	// - 当 Type="base64" 时,Source 是 base64 编码的图片数据
	Source string `json:"source"`

	// MimeType MIME 类型,如 "image/jpeg", "image/png"
	MimeType string `json:"mime_type,omitempty"`

	// Detail 图片细节级别 (OpenAI)
	// - "low": 低分辨率快速处理
	// - "high": 高分辨率详细分析
	// - "auto": 自动选择
	Detail string `json:"detail,omitempty"`
}

ImageContent 图片内容

func (*ImageContent) GetMediaType

func (i *ImageContent) GetMediaType() string

func (*ImageContent) IsContentBlock

func (i *ImageContent) IsContentBlock()

type Message

type Message struct {
	// Role 消息角色
	Role Role `json:"role"`

	// Content 消息内容(简单文本格式,与 ContentBlocks 二选一)
	Content string `json:"content,omitempty"`

	// ContentBlocks 消息内容块(复杂格式,与 Content 二选一)
	// 用于支持多模态内容(文本、工具调用、工具结果等)
	ContentBlocks []ContentBlock `json:"-"`

	// Name 可选的名称字段(用于function/tool角色)
	Name string `json:"name,omitempty"`

	// ToolCalls 工具调用列表(仅assistant角色)
	ToolCalls []ToolCall `json:"tool_calls,omitempty"`

	// ToolCallID 工具调用ID(仅tool角色)
	ToolCallID string `json:"tool_call_id,omitempty"`
}

Message 表示一条消息

func (*Message) GetContent

func (m *Message) GetContent() string

GetContent 获取消息内容,优先返回 Content,如果为空则从 ContentBlocks 提取

func (*Message) SetContent

func (m *Message) SetContent(content string)

SetContent 设置消息内容(简单文本格式)

func (*Message) SetContentBlocks

func (m *Message) SetContentBlocks(blocks []ContentBlock)

SetContentBlocks 设置消息内容块(复杂格式)

type ModelConfig

type ModelConfig struct {
	Provider      string        `json:"provider"` // "anthropic", "openai", etc.
	Model         string        `json:"model"`
	APIKey        string        `json:"api_key,omitempty"`
	BaseURL       string        `json:"base_url,omitempty"`
	ExecutionMode ExecutionMode `json:"execution_mode,omitempty"` // 执行模式:streaming/non-streaming/auto
}

ModelConfig 模型配置

type MonitorAgentResumedEvent

type MonitorAgentResumedEvent struct {
	Strategy string             `json:"strategy"` // "crash" or "manual"
	Sealed   []ToolCallSnapshot `json:"sealed"`
}

MonitorAgentResumedEvent Agent恢复事件

func (*MonitorAgentResumedEvent) Channel

func (*MonitorAgentResumedEvent) EventType

func (e *MonitorAgentResumedEvent) EventType() string

type MonitorBreakpointChangedEvent

type MonitorBreakpointChangedEvent struct {
	Previous  BreakpointState `json:"previous"`
	Current   BreakpointState `json:"current"`
	Timestamp time.Time       `json:"timestamp"`
}

MonitorBreakpointChangedEvent 断点变更事件

func (*MonitorBreakpointChangedEvent) Channel

func (*MonitorBreakpointChangedEvent) EventType

func (e *MonitorBreakpointChangedEvent) EventType() string

type MonitorContextCompressionEvent

type MonitorContextCompressionEvent struct {
	Phase   string  `json:"phase"` // "start" or "end"
	Summary string  `json:"summary,omitempty"`
	Ratio   float64 `json:"ratio,omitempty"`
}

MonitorContextCompressionEvent 上下文压缩事件

func (*MonitorContextCompressionEvent) Channel

func (*MonitorContextCompressionEvent) EventType

func (e *MonitorContextCompressionEvent) EventType() string

type MonitorErrorEvent

type MonitorErrorEvent struct {
	Severity string                 `json:"severity"` // "info", "warn", "error"
	Phase    string                 `json:"phase"`    // "model", "tool", "system", "lifecycle"
	Message  string                 `json:"message"`
	Detail   map[string]interface{} `json:"detail,omitempty"`
}

MonitorErrorEvent 错误事件

func (*MonitorErrorEvent) Channel

func (e *MonitorErrorEvent) Channel() AgentChannel

func (*MonitorErrorEvent) EventType

func (e *MonitorErrorEvent) EventType() string

type MonitorFileChangedEvent

type MonitorFileChangedEvent struct {
	Path  string    `json:"path"`
	Mtime time.Time `json:"mtime"`
}

MonitorFileChangedEvent 文件变更事件

func (*MonitorFileChangedEvent) Channel

func (*MonitorFileChangedEvent) EventType

func (e *MonitorFileChangedEvent) EventType() string

type MonitorReminderSentEvent

type MonitorReminderSentEvent struct {
	Category string `json:"category"` // "file", "todo", "security", "performance", "general"
	Content  string `json:"content"`
}

MonitorReminderSentEvent 系统提醒事件

func (*MonitorReminderSentEvent) Channel

func (*MonitorReminderSentEvent) EventType

func (e *MonitorReminderSentEvent) EventType() string

type MonitorSchedulerTriggeredEvent

type MonitorSchedulerTriggeredEvent struct {
	TaskID      string    `json:"task_id"`
	Spec        string    `json:"spec"`
	Kind        string    `json:"kind"` // "steps", "time", "cron"
	TriggeredAt time.Time `json:"triggered_at"`
}

MonitorSchedulerTriggeredEvent 调度器触发事件

func (*MonitorSchedulerTriggeredEvent) Channel

func (*MonitorSchedulerTriggeredEvent) EventType

func (e *MonitorSchedulerTriggeredEvent) EventType() string

type MonitorStateChangedEvent

type MonitorStateChangedEvent struct {
	State AgentRuntimeState `json:"state"`
}

MonitorStateChangedEvent 状态变更事件

func (*MonitorStateChangedEvent) Channel

func (*MonitorStateChangedEvent) EventType

func (e *MonitorStateChangedEvent) EventType() string

type MonitorStepCompleteEvent

type MonitorStepCompleteEvent struct {
	Step       int   `json:"step"`
	DurationMs int64 `json:"duration_ms,omitempty"`
}

MonitorStepCompleteEvent 步骤完成事件

func (*MonitorStepCompleteEvent) Channel

func (*MonitorStepCompleteEvent) EventType

func (e *MonitorStepCompleteEvent) EventType() string

type MonitorTokenUsageEvent

type MonitorTokenUsageEvent struct {
	InputTokens  int64 `json:"input_tokens"`
	OutputTokens int64 `json:"output_tokens"`
	TotalTokens  int64 `json:"total_tokens"`
}

MonitorTokenUsageEvent Token使用统计事件

func (*MonitorTokenUsageEvent) Channel

func (e *MonitorTokenUsageEvent) Channel() AgentChannel

func (*MonitorTokenUsageEvent) EventType

func (e *MonitorTokenUsageEvent) EventType() string

type MonitorToolExecutedEvent

type MonitorToolExecutedEvent struct {
	Call ToolCallSnapshot `json:"call"`
}

MonitorToolExecutedEvent 工具执行完成事件

func (*MonitorToolExecutedEvent) Channel

func (*MonitorToolExecutedEvent) EventType

func (e *MonitorToolExecutedEvent) EventType() string

type MonitorToolManualUpdatedEvent

type MonitorToolManualUpdatedEvent struct {
	Tools     []string  `json:"tools"`
	Timestamp time.Time `json:"timestamp"`
}

MonitorToolManualUpdatedEvent 工具手册更新事件

func (*MonitorToolManualUpdatedEvent) Channel

func (*MonitorToolManualUpdatedEvent) EventType

func (e *MonitorToolManualUpdatedEvent) EventType() string

type MultimodalContent

type MultimodalContent interface {
	ContentBlock
	GetMediaType() string
}

MultimodalContent 多模态内容接口 扩展 ContentBlock 以支持图片、音频、视频等多模态输入

type PermissionConfig

type PermissionConfig struct {
	Mode  PermissionMode `json:"mode"`
	Allow []string       `json:"allow,omitempty"` // 白名单工具
	Deny  []string       `json:"deny,omitempty"`  // 黑名单工具
	Ask   []string       `json:"ask,omitempty"`   // 需要审批的工具
}

PermissionConfig 权限配置

type PermissionMode

type PermissionMode string

PermissionMode 权限模式

const (
	PermissionModeAuto     PermissionMode = "auto"     // 自动决策
	PermissionModeApproval PermissionMode = "approval" // 全部需要审批
	PermissionModeAllow    PermissionMode = "allow"    // 全部允许
)

type ProgressDoneEvent

type ProgressDoneEvent struct {
	Step   int    `json:"step"`
	Reason string `json:"reason"` // "completed" or "interrupted"
}

ProgressDoneEvent 单轮完成事件

func (*ProgressDoneEvent) Channel

func (e *ProgressDoneEvent) Channel() AgentChannel

func (*ProgressDoneEvent) EventType

func (e *ProgressDoneEvent) EventType() string

type ProgressTextChunkEndEvent

type ProgressTextChunkEndEvent struct {
	Step int    `json:"step"`
	Text string `json:"text"`
}

ProgressTextChunkEndEvent 文本块结束事件

func (*ProgressTextChunkEndEvent) Channel

func (*ProgressTextChunkEndEvent) EventType

func (e *ProgressTextChunkEndEvent) EventType() string

type ProgressTextChunkEvent

type ProgressTextChunkEvent struct {
	Step  int    `json:"step"`
	Delta string `json:"delta"`
}

ProgressTextChunkEvent 文本块内容事件

func (*ProgressTextChunkEvent) Channel

func (e *ProgressTextChunkEvent) Channel() AgentChannel

func (*ProgressTextChunkEvent) EventType

func (e *ProgressTextChunkEvent) EventType() string

type ProgressTextChunkStartEvent

type ProgressTextChunkStartEvent struct {
	Step int `json:"step"`
}

ProgressTextChunkStartEvent 文本块开始事件

func (*ProgressTextChunkStartEvent) Channel

func (*ProgressTextChunkStartEvent) EventType

func (e *ProgressTextChunkStartEvent) EventType() string

type ProgressThinkChunkEndEvent

type ProgressThinkChunkEndEvent struct {
	Step int `json:"step"`
}

ProgressThinkChunkEndEvent 思考块结束事件

func (*ProgressThinkChunkEndEvent) Channel

func (*ProgressThinkChunkEndEvent) EventType

func (e *ProgressThinkChunkEndEvent) EventType() string

type ProgressThinkChunkEvent

type ProgressThinkChunkEvent struct {
	Step  int    `json:"step"`
	Delta string `json:"delta"`
}

ProgressThinkChunkEvent 思考块内容事件

func (*ProgressThinkChunkEvent) Channel

func (*ProgressThinkChunkEvent) EventType

func (e *ProgressThinkChunkEvent) EventType() string

type ProgressThinkChunkStartEvent

type ProgressThinkChunkStartEvent struct {
	Step int `json:"step"`
}

ProgressThinkChunkStartEvent 思考块开始事件

func (*ProgressThinkChunkStartEvent) Channel

func (*ProgressThinkChunkStartEvent) EventType

func (e *ProgressThinkChunkStartEvent) EventType() string

type ProgressToolEndEvent

type ProgressToolEndEvent struct {
	Call ToolCallSnapshot `json:"call"`
}

ProgressToolEndEvent 工具执行结束事件

func (*ProgressToolEndEvent) Channel

func (e *ProgressToolEndEvent) Channel() AgentChannel

func (*ProgressToolEndEvent) EventType

func (e *ProgressToolEndEvent) EventType() string

type ProgressToolErrorEvent

type ProgressToolErrorEvent struct {
	Call  ToolCallSnapshot `json:"call"`
	Error string           `json:"error"`
}

ProgressToolErrorEvent 工具执行错误事件

func (*ProgressToolErrorEvent) Channel

func (e *ProgressToolErrorEvent) Channel() AgentChannel

func (*ProgressToolErrorEvent) EventType

func (e *ProgressToolErrorEvent) EventType() string

type ProgressToolStartEvent

type ProgressToolStartEvent struct {
	Call ToolCallSnapshot `json:"call"`
}

ProgressToolStartEvent 工具开始执行事件

func (*ProgressToolStartEvent) Channel

func (e *ProgressToolStartEvent) Channel() AgentChannel

func (*ProgressToolStartEvent) EventType

func (e *ProgressToolStartEvent) EventType() string

type PropertySchema

type PropertySchema struct {
	Type        string                     `json:"type"`                  // string, number, boolean, array, object
	Description string                     `json:"description,omitempty"` // 描述
	Enum        []interface{}              `json:"enum,omitempty"`        // 枚举值
	Items       *PropertySchema            `json:"items,omitempty"`       // 数组元素 schema
	Properties  map[string]*PropertySchema `json:"properties,omitempty"`  // 对象属性(嵌套)
	Required    []string                   `json:"required,omitempty"`    // 必需字段(对象)
	Default     interface{}                `json:"default,omitempty"`     // 默认值
}

PropertySchema 属性 Schema 定义

type ReasoningTrace

type ReasoningTrace struct {
	// Step 推理步骤序号
	Step int `json:"step"`

	// Thought 推理思考内容
	Thought string `json:"thought"`

	// ThoughtDelta 推理思考增量 (流式)
	ThoughtDelta string `json:"thought_delta,omitempty"`

	// Type 推理类型
	// - "thinking": 思考过程
	// - "reflection": 反思
	// - "conclusion": 结论
	Type string `json:"type,omitempty"`

	// Confidence 置信度 (0-1)
	Confidence float64 `json:"confidence,omitempty"`
}

ReasoningTrace 推理过程跟踪 用于 OpenAI o1/o3, DeepSeek R1 等推理模型

type ReminderOptions

type ReminderOptions struct {
	SkipStandardEnding bool   `json:"skip_standard_ending,omitempty"`
	Priority           string `json:"priority,omitempty"` // "low", "medium", "high"
	Category           string `json:"category,omitempty"` // "file", "todo", "security", "performance", "general"
}

ReminderOptions 提醒选项

type ResourceLimits

type ResourceLimits struct {
	CPUQuota    float64       `json:"cpu_quota,omitempty"`    // CPU配额(核数)
	MemoryLimit int64         `json:"memory_limit,omitempty"` // 内存限制(字节)
	Timeout     time.Duration `json:"timeout,omitempty"`      // 超时时间
	DiskQuota   int64         `json:"disk_quota,omitempty"`   // 磁盘配额(字节)
}

ResourceLimits 资源限制

type RespondFunc

type RespondFunc func(decision string, note string) error

RespondFunc 审批响应回调函数

type ResumeOptions

type ResumeOptions struct {
	Strategy  ResumeStrategy `json:"strategy,omitempty"`
	AutoRun   bool           `json:"auto_run,omitempty"`
	Overrides *AgentConfig   `json:"overrides,omitempty"`
}

ResumeOptions 恢复选项

type ResumeStrategy

type ResumeStrategy string

ResumeStrategy 恢复策略

const (
	ResumeStrategyCrash  ResumeStrategy = "crash"  // 自动封口未完成工具
	ResumeStrategyManual ResumeStrategy = "manual" // 手动处理
)

type Role

type Role string

Role 定义消息角色

type SandboxConfig

type SandboxConfig struct {
	Kind            SandboxKind            `json:"kind"`
	WorkDir         string                 `json:"work_dir,omitempty"`
	EnforceBoundary bool                   `json:"enforce_boundary,omitempty"`
	AllowPaths      []string               `json:"allow_paths,omitempty"`
	WatchFiles      bool                   `json:"watch_files,omitempty"`
	Extra           map[string]interface{} `json:"extra,omitempty"` // 云平台特定配置
}

SandboxConfig 沙箱配置

type SandboxKind

type SandboxKind string

SandboxKind 沙箱类型

const (
	SandboxKindLocal      SandboxKind = "local"
	SandboxKindDocker     SandboxKind = "docker"
	SandboxKindK8s        SandboxKind = "k8s"
	SandboxKindAliyun     SandboxKind = "aliyun"
	SandboxKindVolcengine SandboxKind = "volcengine"
	SandboxKindRemote     SandboxKind = "remote"
	SandboxKindMock       SandboxKind = "mock"
)

type SendOptions

type SendOptions struct {
	Kind     string           `json:"kind,omitempty"` // "user" or "reminder"
	Reminder *ReminderOptions `json:"reminder,omitempty"`
}

SendOptions 发送消息选项

type SkillsPackageConfig

type SkillsPackageConfig struct {
	// 技能包来源
	Source  string `json:"source"`  // "local" | "oss" | "s3" | "hybrid"
	Path    string `json:"path"`    // 本地路径或云端 URL
	Version string `json:"version"` // 版本号

	// 命令和技能目录
	CommandsDir string `json:"commands_dir"` // 默认 "commands"
	SkillsDir   string `json:"skills_dir"`   // 默认 "skills"

	// 启用的 commands 和 skills
	EnabledCommands []string `json:"enabled_commands"` // ["write", "analyze", ...]
	EnabledSkills   []string `json:"enabled_skills"`   // ["consistency-checker", ...]
}

SkillsPackageConfig Skills 包配置

type Snapshot

type Snapshot struct {
	ID          string                 `json:"id"`                    // 快照 ID
	AgentID     string                 `json:"agent_id"`              // Agent ID
	Timestamp   time.Time              `json:"timestamp"`             // 快照时间
	Messages    []Message              `json:"messages"`              // 消息历史
	ToolCalls   []ToolCallRecord       `json:"tool_calls"`            // 工具调用记录
	State       AgentState             `json:"state"`                 // Agent 状态
	StepCount   int                    `json:"step_count"`            // 步骤计数
	Cursor      int                    `json:"cursor"`                // 当前位置
	Metadata    map[string]interface{} `json:"metadata"`              // 元数据
	Description string                 `json:"description,omitempty"` // 快照描述
}

Snapshot Agent 状态快照

type StreamAccumulator

type StreamAccumulator struct {
	// Content 累积的文本内容
	Content string

	// Reasoning 累积的推理过程
	Reasoning []ReasoningTrace

	// ToolCalls 累积的工具调用
	ToolCalls map[int]*AccumulatedToolCall

	// Usage 最终的 Token 使用情况
	Usage *TokenUsage

	// FinishReason 完成原因
	FinishReason string
}

StreamAccumulator 流式响应累加器 用于累积流式响应,构建完整消息

func NewStreamAccumulator

func NewStreamAccumulator() *StreamAccumulator

NewStreamAccumulator 创建新的流式累加器

func (*StreamAccumulator) AddChunk

func (acc *StreamAccumulator) AddChunk(chunk *StreamChunk)

AddChunk 添加流式块

func (*StreamAccumulator) GetReasoningText

func (acc *StreamAccumulator) GetReasoningText() string

GetReasoningText 获取所有推理文本

func (*StreamAccumulator) IsComplete

func (acc *StreamAccumulator) IsComplete() bool

IsComplete 检查是否完成

func (*StreamAccumulator) ToMessage

func (acc *StreamAccumulator) ToMessage() Message

ToMessage 将累积的结果转换为 Message

type StreamChunk

type StreamChunk struct {
	// Type 块类型
	Type StreamChunkType `json:"type"`

	// Delta 增量文本内容 (用于 text 类型)
	Delta string `json:"delta,omitempty"`

	// ToolCall 工具调用信息 (用于 tool_call 类型)
	ToolCall *ToolCallDelta `json:"tool_call,omitempty"`

	// Usage Token 使用情况 (用于 usage 类型)
	Usage *TokenUsage `json:"usage,omitempty"`

	// Reasoning 推理过程 (用于 reasoning 类型)
	Reasoning *ReasoningTrace `json:"reasoning,omitempty"`

	// Error 错误信息 (用于 error 类型)
	Error *StreamError `json:"error,omitempty"`

	// FinishReason 完成原因 (用于 done 类型)
	FinishReason string `json:"finish_reason,omitempty"`

	// Raw 原始响应数据 (用于调试)
	Raw map[string]interface{} `json:"raw,omitempty"`
}

StreamChunk 流式响应块 (扩展版本)

type StreamChunkType

type StreamChunkType string

StreamChunkType 流式响应块类型

const (
	// ChunkTypeText 文本块
	ChunkTypeText StreamChunkType = "text"

	// ChunkTypeReasoning 推理过程块 (用于 o1/o3/R1 等推理模型)
	ChunkTypeReasoning StreamChunkType = "reasoning"

	// ChunkTypeUsage Token 使用情况块
	ChunkTypeUsage StreamChunkType = "usage"

	// ChunkTypeToolCall 工具调用块
	ChunkTypeToolCall StreamChunkType = "tool_call"

	// ChunkTypeError 错误块
	ChunkTypeError StreamChunkType = "error"

	// ChunkTypeDone 完成块
	ChunkTypeDone StreamChunkType = "done"
)

type StreamError

type StreamError struct {
	// Code 错误代码
	Code string `json:"code"`

	// Message 错误消息
	Message string `json:"message"`

	// Type 错误类型
	Type string `json:"type,omitempty"`

	// Param 错误参数
	Param string `json:"param,omitempty"`
}

StreamError 流式错误

type StreamOptions

type StreamOptions struct {
	Since *Bookmark `json:"since,omitempty"`
	Kinds []string  `json:"kinds,omitempty"` // 事件类型过滤
}

StreamOptions 流式订阅选项

type SubAgentConfig

type SubAgentConfig struct {
	Depth         int                   `json:"depth"`
	Templates     []string              `json:"templates,omitempty"`
	InheritConfig bool                  `json:"inherit_config"`
	Overrides     *AgentConfigOverrides `json:"overrides,omitempty"`
}

SubAgentConfig 子Agent配置

type SubscribeOptions

type SubscribeOptions struct {
	Since    *Bookmark      `json:"since,omitempty"`
	Kinds    []string       `json:"kinds,omitempty"`
	Channels []AgentChannel `json:"channels,omitempty"`
}

SubscribeOptions 订阅选项

type TextBlock

type TextBlock struct {
	Text string `json:"text"`
}

TextBlock 文本内容块

func (*TextBlock) IsContentBlock

func (t *TextBlock) IsContentBlock()

type TodoConfig

type TodoConfig struct {
	Enabled             bool `json:"enabled"`
	ReminderOnStart     bool `json:"reminder_on_start"`
	RemindIntervalSteps int  `json:"remind_interval_steps"`
}

TodoConfig Todo功能配置

type TokenUsage

type TokenUsage struct {
	// InputTokens 输入 Token 数
	InputTokens int `json:"input_tokens"`

	// OutputTokens 输出 Token 数
	OutputTokens int `json:"output_tokens"`

	// TotalTokens 总 Token 数
	TotalTokens int `json:"total_tokens"`

	// ReasoningTokens 推理 Token 数 (用于推理模型)
	ReasoningTokens int `json:"reasoning_tokens,omitempty"`

	// CachedTokens 缓存命中的 Token 数 (Prompt Caching)
	CachedTokens int `json:"cached_tokens,omitempty"`

	// CacheCreationTokens 缓存创建的 Token 数
	CacheCreationTokens int `json:"cache_creation_tokens,omitempty"`

	// CacheReadTokens 缓存读取的 Token 数
	CacheReadTokens int `json:"cache_read_tokens,omitempty"`
}

TokenUsage Token 使用情况 (扩展版本)

type ToolCall

type ToolCall struct {
	// ID 工具调用的唯一标识符
	ID string `json:"id"`

	// Type 工具类型,通常为 "function"
	Type string `json:"type,omitempty"`

	// Name 工具名称
	Name string `json:"name"`

	// Arguments 工具参数(JSON对象)
	Arguments map[string]interface{} `json:"arguments,omitempty"`
}

ToolCall 表示一个工具调用

type ToolCallApproval

type ToolCallApproval struct {
	CallID     string    `json:"call_id"`               // 工具调用 ID
	Required   bool      `json:"required"`              // 是否需要审批(新字段)
	Approved   bool      `json:"approved"`              // 是否批准
	Reason     string    `json:"reason,omitempty"`      // 原因
	Timestamp  time.Time `json:"timestamp"`             // 审批时间
	ApprovedBy string    `json:"approved_by,omitempty"` // 审批人
}

ToolCallApproval 工具调用审批

type ToolCallAuditEntry

type ToolCallAuditEntry struct {
	State     ToolCallState `json:"state"`     // 状态
	Timestamp time.Time     `json:"timestamp"` // 时间戳
	Note      string        `json:"note"`      // 备注
}

ToolCallAuditEntry 工具调用审计条目

type ToolCallDelta

type ToolCallDelta struct {
	// Index 工具调用索引
	Index int `json:"index"`

	// ID 工具调用 ID (第一个块)
	ID string `json:"id,omitempty"`

	// Type 工具类型 (通常是 "function")
	Type string `json:"type,omitempty"`

	// Name 工具名称 (第一个块)
	Name string `json:"name,omitempty"`

	// ArgumentsDelta 参数增量 (JSON 片段)
	ArgumentsDelta string `json:"arguments_delta,omitempty"`
}

ToolCallDelta 工具调用增量

type ToolCallRecord

type ToolCallRecord struct {
	ID          string                 `json:"id"`              // 工具调用 ID
	Name        string                 `json:"name"`            // 工具名称(新字段)
	ToolName    string                 `json:"tool_name"`       // 工具名称(兼容)
	Input       map[string]interface{} `json:"input"`           // 输入参数
	Output      interface{}            `json:"output"`          // 输出结果
	Result      interface{}            `json:"result"`          // 执行结果(新字段)
	Error       string                 `json:"error,omitempty"` // 错误信息
	IsError     bool                   `json:"is_error"`        // 是否有错误(新字段)
	StartTime   time.Time              `json:"start_time"`      // 开始时间
	EndTime     time.Time              `json:"end_time"`        // 结束时间
	StartedAt   *time.Time             `json:"started_at"`      // 开始时间(新字段,指针)
	CompletedAt *time.Time             `json:"completed_at"`    // 完成时间(新字段,指针)
	DurationMs  *int64                 `json:"duration_ms"`     // 执行时长(毫秒,改为指针)
	Status      ToolCallStatus         `json:"status"`          // 调用状态
	State       ToolCallState          `json:"state"`           // 工具调用状态(新字段)
	Approval    ToolCallApproval       `json:"approval"`        // 审批信息(新字段)
	CreatedAt   time.Time              `json:"created_at"`      // 创建时间(新字段)
	UpdatedAt   time.Time              `json:"updated_at"`      // 更新时间(新字段)
	AuditTrail  []ToolCallAuditEntry   `json:"audit_trail"`     // 审计跟踪(新字段)
}

ToolCallRecord 工具调用记录

type ToolCallSnapshot

type ToolCallSnapshot struct {
	// ID 工具调用ID
	ID string `json:"id"`

	// Name 工具名称
	Name string `json:"name"`

	// State 工具调用状态
	State ToolCallState `json:"state,omitempty"`

	// Arguments 工具参数
	Arguments map[string]interface{} `json:"arguments,omitempty"`

	// Result 工具执行结果
	Result interface{} `json:"result,omitempty"`

	// Error 错误信息
	Error string `json:"error,omitempty"`
}

ToolCallSnapshot 工具调用快照

type ToolCallState

type ToolCallState string

ToolCallState 工具调用状态(用于并发控制)

const (
	ToolCallStatePending   ToolCallState = "pending"   // 待执行
	ToolCallStateQueued    ToolCallState = "queued"    // 已排队
	ToolCallStateExecuting ToolCallState = "executing" // 执行中
	ToolCallStateCompleted ToolCallState = "completed" // 已完成
	ToolCallStateFailed    ToolCallState = "failed"    // 失败
)

type ToolCallStatus

type ToolCallStatus string

ToolCallStatus 工具调用状态

const (
	ToolCallStatusPending   ToolCallStatus = "pending"   // 待执行
	ToolCallStatusRunning   ToolCallStatus = "running"   // 执行中
	ToolCallStatusCompleted ToolCallStatus = "completed" // 已完成
	ToolCallStatusFailed    ToolCallStatus = "failed"    // 失败
	ToolCallStatusCancelled ToolCallStatus = "cancelled" // 已取消
)

type ToolDefinition

type ToolDefinition struct {
	Name        string                 `json:"name"`         // 工具名称
	Description string                 `json:"description"`  // 工具描述
	InputSchema map[string]interface{} `json:"input_schema"` // 输入 Schema
}

ToolDefinition 工具定义

type ToolResult

type ToolResult struct {
	// ToolCallID 关联的工具调用ID
	ToolCallID string `json:"tool_call_id"`

	// Content 工具执行结果
	Content string `json:"content"`

	// Error 错误信息(如果有)
	Error string `json:"error,omitempty"`
}

ToolResult 表示工具执行结果

type ToolResultBlock

type ToolResultBlock struct {
	ToolUseID string `json:"tool_use_id"`
	Content   string `json:"content"`
	IsError   bool   `json:"is_error,omitempty"`
}

ToolResultBlock 工具结果块

func (*ToolResultBlock) IsContentBlock

func (t *ToolResultBlock) IsContentBlock()

type ToolSchema

type ToolSchema struct {
	Type        string                     `json:"type"`                  // "object"
	Properties  map[string]*PropertySchema `json:"properties"`            // 属性定义
	Required    []string                   `json:"required,omitempty"`    // 必需字段
	Description string                     `json:"description,omitempty"` // 描述
}

ToolSchema 工具 Schema 定义

type ToolUseBlock

type ToolUseBlock struct {
	ID    string                 `json:"id"`
	Name  string                 `json:"name"`
	Input map[string]interface{} `json:"input"`
}

ToolUseBlock 工具使用块

func (*ToolUseBlock) IsContentBlock

func (t *ToolUseBlock) IsContentBlock()

type ToolsManualConfig

type ToolsManualConfig struct {
	// Mode 决定哪些工具会出现在 System Prompt 的 "Tools Manual" 中:
	// - "all"   : 默认值, 所有工具都会注入(除非在 Exclude 中显式排除)
	// - "listed": 仅注入 Include 列表中出现的工具
	// - "none"  : 完全不注入工具手册, 由模型自己通过名称和输入 Schema 推断
	Mode string `json:"mode,omitempty"`

	// Include 仅在 Mode 为 "listed" 时生效, 指定要注入手册的工具名称白名单。
	Include []string `json:"include,omitempty"`

	// Exclude 在 Mode 为 "all" 时生效, 指定不注入手册的工具名称黑名单。
	Exclude []string `json:"exclude,omitempty"`
}

ToolsManualConfig 控制工具手册的注入策略(用于减少 System Prompt 膨胀)。

type VideoContent

type VideoContent struct {
	// Type 视频来源类型: "url", "base64"
	Type string `json:"type"`

	// Source 视频源
	Source string `json:"source"`

	// MimeType MIME 类型,如 "video/mp4", "video/webm"
	MimeType string `json:"mime_type,omitempty"`

	// Thumbnail 视频缩略图 URL (可选)
	Thumbnail string `json:"thumbnail,omitempty"`

	// Duration 视频时长(秒)
	Duration float64 `json:"duration,omitempty"`
}

VideoContent 视频内容

func (*VideoContent) GetMediaType

func (v *VideoContent) GetMediaType() string

func (*VideoContent) IsContentBlock

func (v *VideoContent) IsContentBlock()

Jump to

Keyboard shortcuts

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