Documentation
¶
Overview ¶
Package agentcontinuity 实现 Agent 连续工作的产品编排层。
Continuity Pack 是 runtime context 的产品 projection,不创建第二套 memory ranking、ledger 或 source resolver。它只编排 scope resolution、 handoff selection、context compilation、source coverage、budget truncation 和 safe next actions。
Index ¶
Constants ¶
const ContinuitySchemaVersion = "yeisme.agent_continuity.v1"
ContinuitySchemaVersion 是 continuity pack 的 schema 版本。
Variables ¶
This section is empty.
Functions ¶
func SummaryLine ¶
func SummaryLine(pack ContinuityPack) string
SummaryLine 返回 pack 的一行摘要(用于 human output)。
Types ¶
type ContinuityBudget ¶
type ContinuityBudget struct {
MaxItems int `json:"max_items"`
MaxChars int `json:"max_chars"`
MaxSources int `json:"max_sources"`
}
ContinuityBudget 限制 continuity pack 的 section 大小。
type ContinuityPack ¶
type ContinuityPack struct {
SchemaVersion string `json:"schema_version"`
Principal agentprotocol.Principal `json:"principal"`
Scope agentprotocol.Scope `json:"scope"`
Task string `json:"task,omitempty"`
// Objective 来自最近的 handoff 或 scope 推断。
Objective string `json:"objective,omitempty"`
// CurrentState 描述任务当前进度。
CurrentState string `json:"current_state,omitempty"`
// Sections 按 kind 组织的 bounded sections。
Sections []ContinuitySection `json:"sections"`
// Conflicts 描述当前 scope 的记忆冲突。
Conflicts []agentprotocol.ContextConflict `json:"conflicts,omitempty"`
// Sources 引用的来源(bounded,不含 body)。
Sources agentprotocol.SourceRefList `json:"sources,omitempty"`
// SourceCoverage 描述来源解析情况。
SourceCoverage SourceCoverage `json:"source_coverage"`
// HandoffStatus 表示 handoff 的可用性。
HandoffStatus HandoffStatus `json:"handoff_status"`
// HandoffID 是被消费的 handoff ID(如有)。
HandoffID string `json:"handoff_id,omitempty"`
// Truncated 表示 pack 是否被 budget 截断。
Truncated bool `json:"truncated"`
// Freshness 描述 pack 中最新记忆的时间戳。
Freshness time.Time `json:"freshness"`
// NextActions 是安全的 drill-down 操作建议。
NextActions []agentprotocol.NextAction `json:"next_actions,omitempty"`
// Experimental 标记此 surface 为实验性。
Experimental bool `json:"experimental"`
}
ContinuityPack 是 orchestrator 产出的 bounded 产品 projection。 它包含目标、关键决策、偏好、未完成事项、失败经验、冲突、来源和下一步命令。 完整 note body、完整 transcript、raw prompt 与 provider payload 永不进入。
func (ContinuityPack) AssertNoBody ¶
func (p ContinuityPack) AssertNoBody(maxItemChars int) error
AssertNoBody 检查 pack 是否泄漏了看起来像完整 body 的大段文本。
func (ContinuityPack) SectionCount ¶
func (p ContinuityPack) SectionCount() int
SectionCount 返回所有 section 的 item 总数。
type ContinuityRequest ¶
type ContinuityRequest struct {
SchemaVersion string `json:"schema_version"`
Principal agentprotocol.Principal `json:"principal"`
Scope agentprotocol.Scope `json:"scope"`
Task string `json:"task,omitempty"`
// Intent 描述用户意图(可选),用于 entity boosting。
Intent string `json:"intent,omitempty"`
// Budget 限制 continuity pack 的大小。
Budget ContinuityBudget `json:"budget"`
// HandoffID 显式指定要消费的 handoff;空则自动选择最近可消费 handoff。
HandoffID string `json:"handoff_id,omitempty"`
}
ContinuityRequest 描述一次 continuity compilation 请求。 Principal 和 Scope 必须显式提供;intent/task 可选。
func (ContinuityRequest) Validate ¶
func (r ContinuityRequest) Validate() error
Validate 检查 request 必填字段。
type ContinuitySection ¶
type ContinuitySection struct {
Kind string `json:"kind"`
Title string `json:"title"`
Items []string `json:"items,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Omitted int `json:"omitted,omitempty"`
}
ContinuitySection 是 continuity pack 中的一个 bounded section。
type HandoffStatus ¶
type HandoffStatus string
HandoffStatus 表示 handoff 在 continuity 中的可用状态。
const ( // HandoffStatusConsumed 表示找到了可消费的 handoff。 HandoffStatusConsumed HandoffStatus = "consumed" // HandoffStatusMissing 表示没有匹配的 handoff,degrade to context-only。 HandoffStatusMissing HandoffStatus = "missing" // HandoffStatusExplicit 表示用户显式指定了 handoff。 HandoffStatusExplicit HandoffStatus = "explicit" // HandoffStatusDegraded 表示 handoff 存在但 adapter degraded。 HandoffStatusDegraded HandoffStatus = "degraded" )
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator 编译 bounded continuity pack。 它只编排 scope resolution、handoff selection、context compilation、 source coverage、budget truncation 和 safe next actions。 不创建第二套 memory ranking、ledger 或 source resolver。
func NewOrchestrator ¶
func NewOrchestrator(store *agentmemory.Store, compiler *agentcontext.Compiler) *Orchestrator
NewOrchestrator 构造 orchestrator。
func (*Orchestrator) Compile ¶
func (o *Orchestrator) Compile(ctx context.Context, req ContinuityRequest) (ContinuityPack, error)
Compile 执行 continuity compilation 管线。
type SourceCoverage ¶
type SourceCoverage struct {
// Total 是 pack 引用的来源总数。
Total int `json:"total"`
// Resolved 是成功解析的来源数。
Resolved int `json:"resolved"`
// Missing 是无法解析的来源数。
Missing int `json:"missing"`
// Stale 是存在但过期的来源数。
Stale int `json:"stale"`
}
SourceCoverage 描述 continuity pack 中来源的解析情况。
func (SourceCoverage) ResolvableRatio ¶
func (sc SourceCoverage) ResolvableRatio() float64
ResolvableRatio 返回来源可解析比例。