agentadapter

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package agentadapter 提供 reference adapter harness,验证 Codex 和 Cohors adapter 能力协商、context request 渲染、proposal/handoff 转换和 failure isolation。

runtime-specific hook/config/plugin 不进入本包;只验证 common schema 100% 共用。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodexDescriptor

func CodexDescriptor() agentprotocol.AdapterDescriptor

CodexDescriptor 返回 Codex reference adapter 的 descriptor fixture。 只使用 common schema + optional metadata;不引入 Codex-specific required field。

func CodexPrincipal

func CodexPrincipal(agentID string) agentprotocol.Principal

CodexPrincipal 返回一个典型 Codex adapter principal fixture。

func CohorsDescriptor

func CohorsDescriptor() agentprotocol.AdapterDescriptor

CohorsDescriptor 返回 Cohors reference adapter 的 descriptor fixture。 与 Codex 共用 100% core schema;team-specific 信息放 Metadata。

func CohorsPrincipal

func CohorsPrincipal(agentID string) agentprotocol.Principal

CohorsPrincipal 返回一个典型 Cohors adapter principal fixture。

Types

type DegradedStatus

type DegradedStatus struct {
	AdapterID string `json:"adapter_id"`
	Reason    string `json:"reason"`
	Action    string `json:"action"` // continue_without_adapter, retry, escalate
}

DegradedStatus 描述 adapter 不可用时的降级行为。 adapter 失败不阻塞其他 transport;返回 degraded status 而非 panic。

type Harness

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

Harness 验证 adapter descriptor 与本地 runtime 的兼容性。

func NewHarness

func NewHarness(localVersions []string) *Harness

NewHarness 构造一个 reference adapter harness。 localVersions 是本地 runtime 支持的 schema 版本列表。

func (*Harness) CheckDegraded

func (h *Harness) CheckDegraded(ctx context.Context, desc agentprotocol.AdapterDescriptor, err error) DegradedStatus

CheckDegraded 返回 adapter 不可用时的安全降级状态。 不修改 ledger;调用方应根据 Action 决定后续行为。

func (*Harness) ConvertHandoff

func (h *Harness) ConvertHandoff(from, to agentprotocol.Principal, scope agentprotocol.Scope, objective string, decisions, blockers []string) agentprotocol.Handoff

ConvertHandoff 将 adapter-specific handoff 数据转换为 canonical Handoff。

func (*Harness) ConvertProposal

func (h *Harness) ConvertProposal(principal agentprotocol.Principal, scope agentprotocol.Scope, kind agentprotocol.MemoryKind, subject, summary string, sources agentprotocol.SourceRefList) agentprotocol.Proposal

ConvertProposal 将 adapter-specific proposal 数据转换为 canonical Proposal。 runtime-specific 信息进入 Proposal.Principal.Metadata,不进入 core fields。

func (*Harness) Negotiate

Negotiate 检查 adapter descriptor 是否兼容本地 runtime。 返回 degraded 状态时 adapter 仍可用(subset 能力),完全不兼容时返回 error。

func (*Harness) RenderContextRequest

func (h *Harness) RenderContextRequest(principal agentprotocol.Principal, scope agentprotocol.Scope, task string, adapterMetadata map[string]string) (agentprotocol.ContextRequest, error)

RenderContextRequest 将 adapter-specific 请求转换为 canonical ContextRequest。 adapter metadata 通过 ContextRequest.Metadata 传递,不污染 core fields。

type NegotiateResult

type NegotiateResult struct {
	agentprotocol.NegotiateResult
	Descriptor agentprotocol.AdapterDescriptor
}

NegotiateResult 包装 adapter negotiation 结果。

Jump to

Keyboard shortcuts

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