// Package agentserver 新 AI 助手对接 AgentServer 的客户端与代理。 // 接口与事件结构以 AgentServer 仓库 packages/shared/src/api.ts、events.ts 为准,这里只声明用到的字段。 package agentserver import "encoding/json" // SessionDto AgentServer 会话(POST/PATCH /v1/sessions 的返回) type SessionDto struct { Id string `json:"id"` Title string `json:"title"` Model string `json:"model"` ProfileId *string `json:"profileId"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` } // SessionDetailDto GET /v1/sessions/:id 的返回(只取索引子资源需要的字段) type SessionDetailDto struct { Id string `json:"id"` ActiveRunId *string `json:"activeRunId"` PendingInteractions []InteractionRefDto `json:"pendingInteractions"` } // RunDto Run 状态(POST /messages、GET /runs/:id 的返回) type RunDto struct { Id string `json:"id"` SessionId string `json:"sessionId"` } // FileDto 工作区文件(POST/GET /sessions/:id/files 的返回元素) type FileDto struct { Id string `json:"id"` SessionId string `json:"sessionId"` Path string `json:"path"` } // InteractionRefDto 交互请求(只取 ID) type InteractionRefDto struct { InteractionId string `json:"interactionId"` } // AgentEvent 事件信封(SSE data 与 /events items 的元素) type AgentEvent struct { Seq int64 `json:"seq"` Type string `json:"type"` SessionId string `json:"sessionId"` RunId *string `json:"runId"` Payload json.RawMessage `json:"payload"` } // EventsPage GET /v1/sessions/:id/events 的返回 type EventsPage struct { Items []AgentEvent `json:"items"` } // ErrorBody AgentServer 的错误格式:{ "error": { "code", "message" } } type ErrorBody struct { Error struct { Code string `json:"code"` Message string `json:"message"` } `json:"error"` } // 子资源 ID 前缀(AgentServer 使用带前缀的 ULID) const ( PrefixSession = "ses_" PrefixRun = "run_" PrefixInteraction = "itx_" PrefixFile = "file_" )