diff --git a/README.md b/README.md index 7a0d9a3..25e51d3 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Learn more about the protocol itself at . ```bash -go get github.com/coder/acp-go-sdk@v0.12.0 +go get github.com/coder/acp-go-sdk@v0.12.2 ``` ## Get Started diff --git a/acp_test.go b/acp_test.go index 8919ebf..739092e 100644 --- a/acp_test.go +++ b/acp_test.go @@ -116,8 +116,10 @@ type agentFuncs struct { AuthenticateFunc func(context.Context, AuthenticateRequest) (AuthenticateResponse, error) PromptFunc func(context.Context, PromptRequest) (PromptResponse, error) CancelFunc func(context.Context, CancelNotification) error + CloseSessionFunc func(context.Context, CloseSessionRequest) (CloseSessionResponse, error) SetSessionModeFunc func(ctx context.Context, params SetSessionModeRequest) (SetSessionModeResponse, error) ListSessionsFunc func(context.Context, ListSessionsRequest) (ListSessionsResponse, error) + ResumeSessionFunc func(context.Context, ResumeSessionRequest) (ResumeSessionResponse, error) SetSessionConfigOptionFunc func(context.Context, SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) // Unstable (schema/meta.unstable.json) UnstableDidChangeDocumentFunc func(context.Context, UnstableDidChangeDocumentNotification) error @@ -134,9 +136,7 @@ type agentFuncs struct { UnstableDisableProvidersFunc func(context.Context, UnstableDisableProvidersRequest) (UnstableDisableProvidersResponse, error) UnstableListProvidersFunc func(context.Context, UnstableListProvidersRequest) (UnstableListProvidersResponse, error) UnstableSetProvidersFunc func(context.Context, UnstableSetProvidersRequest) (UnstableSetProvidersResponse, error) - UnstableCloseSessionFunc func(context.Context, UnstableCloseSessionRequest) (UnstableCloseSessionResponse, error) UnstableForkSessionFunc func(context.Context, UnstableForkSessionRequest) (UnstableForkSessionResponse, error) - UnstableResumeSessionFunc func(context.Context, UnstableResumeSessionRequest) (UnstableResumeSessionResponse, error) UnstableSetSessionModelFunc func(context.Context, UnstableSetSessionModelRequest) (UnstableSetSessionModelResponse, error) HandleExtensionMethodFunc func(context.Context, string, json.RawMessage) (any, error) @@ -191,6 +191,14 @@ func (a agentFuncs) Cancel(ctx context.Context, n CancelNotification) error { return nil } +// CloseSession implements Agent. +func (a agentFuncs) CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) { + if a.CloseSessionFunc != nil { + return a.CloseSessionFunc(ctx, params) + } + return CloseSessionResponse{}, nil +} + // SetSessionMode implements Agent. func (a agentFuncs) SetSessionMode(ctx context.Context, params SetSessionModeRequest) (SetSessionModeResponse, error) { if a.SetSessionModeFunc != nil { @@ -215,12 +223,12 @@ func (a agentFuncs) ListSessions(ctx context.Context, params ListSessionsRequest return ListSessionsResponse{}, nil } -// UnstableResumeSession implements AgentExperimental. -func (a agentFuncs) UnstableResumeSession(ctx context.Context, params UnstableResumeSessionRequest) (UnstableResumeSessionResponse, error) { - if a.UnstableResumeSessionFunc != nil { - return a.UnstableResumeSessionFunc(ctx, params) +// ResumeSession implements Agent. +func (a agentFuncs) ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) { + if a.ResumeSessionFunc != nil { + return a.ResumeSessionFunc(ctx, params) } - return UnstableResumeSessionResponse{}, nil + return ResumeSessionResponse{}, nil } // SetSessionConfigOption implements Agent. @@ -337,13 +345,6 @@ func (a agentFuncs) UnstableSetProviders(ctx context.Context, params UnstableSet return UnstableSetProvidersResponse{}, nil } -func (a agentFuncs) UnstableCloseSession(ctx context.Context, params UnstableCloseSessionRequest) (UnstableCloseSessionResponse, error) { - if a.UnstableCloseSessionFunc != nil { - return a.UnstableCloseSessionFunc(ctx, params) - } - return UnstableCloseSessionResponse{}, nil -} - func (a agentFuncs) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) { if a.HandleExtensionMethodFunc != nil { return a.HandleExtensionMethodFunc(ctx, method, params) @@ -367,6 +368,10 @@ func (a *forkOnlyUnstableAgent) Cancel(context.Context, CancelNotification) erro return nil } +func (a *forkOnlyUnstableAgent) CloseSession(context.Context, CloseSessionRequest) (CloseSessionResponse, error) { + return CloseSessionResponse{}, nil +} + func (a *forkOnlyUnstableAgent) NewSession(context.Context, NewSessionRequest) (NewSessionResponse, error) { return NewSessionResponse{}, nil } @@ -383,6 +388,10 @@ func (a *forkOnlyUnstableAgent) ListSessions(context.Context, ListSessionsReques return ListSessionsResponse{}, nil } +func (a *forkOnlyUnstableAgent) ResumeSession(context.Context, ResumeSessionRequest) (ResumeSessionResponse, error) { + return ResumeSessionResponse{}, nil +} + func (a *forkOnlyUnstableAgent) SetSessionConfigOption(context.Context, SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) { return SetSessionConfigOptionResponse{}, nil } @@ -1244,6 +1253,10 @@ func (agentNoExtensions) Initialize(ctx context.Context, params InitializeReques func (agentNoExtensions) Cancel(ctx context.Context, params CancelNotification) error { return nil } +func (agentNoExtensions) CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) { + return CloseSessionResponse{}, nil +} + func (agentNoExtensions) NewSession(ctx context.Context, params NewSessionRequest) (NewSessionResponse, error) { return NewSessionResponse{}, nil } @@ -1260,6 +1273,10 @@ func (agentNoExtensions) ListSessions(ctx context.Context, params ListSessionsRe return ListSessionsResponse{}, nil } +func (agentNoExtensions) ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) { + return ResumeSessionResponse{}, nil +} + func (agentNoExtensions) SetSessionConfigOption(ctx context.Context, params SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) { return SetSessionConfigOptionResponse{}, nil } diff --git a/agent_gen.go b/agent_gen.go index 87396a9..46f6479 100644 --- a/agent_gen.go +++ b/agent_gen.go @@ -313,20 +313,14 @@ func (a *AgentSideConnection) handle(ctx context.Context, method string, params } return nil, nil case AgentMethodSessionClose: - var p UnstableCloseSessionRequest + var p CloseSessionRequest if err := json.Unmarshal(params, &p); err != nil { return nil, NewInvalidParams(map[string]any{"error": err.Error()}) } if err := p.Validate(); err != nil { return nil, NewInvalidParams(map[string]any{"error": err.Error()}) } - exp, ok := a.agent.(interface { - UnstableCloseSession(context.Context, UnstableCloseSessionRequest) (UnstableCloseSessionResponse, error) - }) - if !ok { - return nil, NewMethodNotFound(method) - } - resp, err := exp.UnstableCloseSession(ctx, p) + resp, err := a.agent.CloseSession(ctx, p) if err != nil { return nil, toReqErr(err) } @@ -419,20 +413,14 @@ func (a *AgentSideConnection) handle(ctx context.Context, method string, params } return resp, nil case AgentMethodSessionResume: - var p UnstableResumeSessionRequest + var p ResumeSessionRequest if err := json.Unmarshal(params, &p); err != nil { return nil, NewInvalidParams(map[string]any{"error": err.Error()}) } if err := p.Validate(); err != nil { return nil, NewInvalidParams(map[string]any{"error": err.Error()}) } - exp, ok := a.agent.(interface { - UnstableResumeSession(context.Context, UnstableResumeSessionRequest) (UnstableResumeSessionResponse, error) - }) - if !ok { - return nil, NewMethodNotFound(method) - } - resp, err := exp.UnstableResumeSession(ctx, p) + resp, err := a.agent.ResumeSession(ctx, p) if err != nil { return nil, toReqErr(err) } diff --git a/client_gen.go b/client_gen.go index 318f686..8660983 100644 --- a/client_gen.go +++ b/client_gen.go @@ -226,8 +226,8 @@ func (c *ClientSideConnection) UnstableSetProviders(ctx context.Context, params func (c *ClientSideConnection) Cancel(ctx context.Context, params CancelNotification) error { return c.conn.SendNotification(ctx, AgentMethodSessionCancel, params) } -func (c *ClientSideConnection) UnstableCloseSession(ctx context.Context, params UnstableCloseSessionRequest) (UnstableCloseSessionResponse, error) { - resp, err := SendRequest[UnstableCloseSessionResponse](c.conn, ctx, AgentMethodSessionClose, params) +func (c *ClientSideConnection) CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) { + resp, err := SendRequest[CloseSessionResponse](c.conn, ctx, AgentMethodSessionClose, params) return resp, err } func (c *ClientSideConnection) UnstableForkSession(ctx context.Context, params UnstableForkSessionRequest) (UnstableForkSessionResponse, error) { @@ -255,8 +255,8 @@ func (c *ClientSideConnection) Prompt(ctx context.Context, params PromptRequest) } return resp, err } -func (c *ClientSideConnection) UnstableResumeSession(ctx context.Context, params UnstableResumeSessionRequest) (UnstableResumeSessionResponse, error) { - resp, err := SendRequest[UnstableResumeSessionResponse](c.conn, ctx, AgentMethodSessionResume, params) +func (c *ClientSideConnection) ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) { + resp, err := SendRequest[ResumeSessionResponse](c.conn, ctx, AgentMethodSessionResume, params) return resp, err } func (c *ClientSideConnection) SetSessionConfigOption(ctx context.Context, params SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) { diff --git a/example/agent/main.go b/example/agent/main.go index b603880..3092d5f 100644 --- a/example/agent/main.go +++ b/example/agent/main.go @@ -51,9 +51,9 @@ func (a *exampleAgent) ListSessions(ctx context.Context, params acp.ListSessions return acp.ListSessionsResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionList) } -// UnstableResumeSession implements acp.AgentExperimental. -func (a *exampleAgent) UnstableResumeSession(ctx context.Context, params acp.UnstableResumeSessionRequest) (acp.UnstableResumeSessionResponse, error) { - return acp.UnstableResumeSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionResume) +// ResumeSession implements acp.Agent. +func (a *exampleAgent) ResumeSession(ctx context.Context, params acp.ResumeSessionRequest) (acp.ResumeSessionResponse, error) { + return acp.ResumeSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionResume) } // SetSessionConfigOption implements acp.Agent. @@ -136,9 +136,9 @@ func (a *exampleAgent) UnstableSetProviders(ctx context.Context, params acp.Unst return acp.UnstableSetProvidersResponse{}, acp.NewMethodNotFound(acp.AgentMethodProvidersSet) } -// UnstableCloseSession implements acp.AgentExperimental. -func (a *exampleAgent) UnstableCloseSession(ctx context.Context, params acp.UnstableCloseSessionRequest) (acp.UnstableCloseSessionResponse, error) { - return acp.UnstableCloseSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionClose) +// CloseSession implements acp.Agent. +func (a *exampleAgent) CloseSession(ctx context.Context, params acp.CloseSessionRequest) (acp.CloseSessionResponse, error) { + return acp.CloseSessionResponse{}, acp.NewMethodNotFound(acp.AgentMethodSessionClose) } // Implement acp.AgentConnAware to receive the connection after construction. diff --git a/example_agent_test.go b/example_agent_test.go index 7eaf62c..58c2baa 100644 --- a/example_agent_test.go +++ b/example_agent_test.go @@ -22,6 +22,16 @@ func (a *agentExample) ListSessions(ctx context.Context, params ListSessionsRequ return ListSessionsResponse{}, nil } +// ResumeSession implements Agent. +func (a *agentExample) ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) { + return ResumeSessionResponse{}, nil +} + +// CloseSession implements Agent. +func (a *agentExample) CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) { + return CloseSessionResponse{}, nil +} + // SetSessionConfigOption implements Agent. func (a *agentExample) SetSessionConfigOption(ctx context.Context, params SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) { return SetSessionConfigOptionResponse{}, nil diff --git a/schema/meta.json b/schema/meta.json index d67543f..8dc36e9 100644 --- a/schema/meta.json +++ b/schema/meta.json @@ -3,10 +3,12 @@ "authenticate": "authenticate", "initialize": "initialize", "session_cancel": "session/cancel", + "session_close": "session/close", "session_list": "session/list", "session_load": "session/load", "session_new": "session/new", "session_prompt": "session/prompt", + "session_resume": "session/resume", "session_set_config_option": "session/set_config_option", "session_set_mode": "session/set_mode" }, diff --git a/schema/schema.json b/schema/schema.json index 9aca01f..77320ba 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -244,6 +244,22 @@ ], "title": "ListSessionsResponse" }, + { + "allOf": [ + { + "$ref": "#/$defs/ResumeSessionResponse" + } + ], + "title": "ResumeSessionResponse" + }, + { + "allOf": [ + { + "$ref": "#/$defs/CloseSessionResponse" + } + ], + "title": "CloseSessionResponse" + }, { "allOf": [ { @@ -653,6 +669,24 @@ "description": "Lists existing sessions known to the agent.\n\nThis method is only available if the agent advertises the `sessionCapabilities.list` capability.\n\nThe agent should return metadata about sessions with optional filtering and pagination support.", "title": "ListSessionsRequest" }, + { + "allOf": [ + { + "$ref": "#/$defs/ResumeSessionRequest" + } + ], + "description": "Resumes an existing session without returning previous messages.\n\nThis method is only available if the agent advertises the `sessionCapabilities.resume` capability.\n\nThe agent should resume the session context, allowing the conversation to continue\nwithout replaying the message history (unlike `session/load`).", + "title": "ResumeSessionRequest" + }, + { + "allOf": [ + { + "$ref": "#/$defs/CloseSessionRequest" + } + ], + "description": "Closes an active session and frees up any resources associated with it.\n\nThis method is only available if the agent advertises the `sessionCapabilities.close` capability.\n\nThe agent must cancel any ongoing work (as if `session/cancel` was called)\nand then free up any resources associated with the session.", + "title": "CloseSessionRequest" + }, { "allOf": [ { @@ -807,6 +841,41 @@ ], "x-docs-ignore": true }, + "CloseSessionRequest": { + "description": "Request parameters for closing an active session.\n\nIf supported, the agent **must** cancel any ongoing work related to the session\n(treat it as if `session/cancel` was called) and then free up any resources\nassociated with the session.\n\nOnly available if the Agent supports the `sessionCapabilities.close` capability.", + "properties": { + "_meta": { + "additionalProperties": true, + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", + "type": ["object", "null"] + }, + "sessionId": { + "allOf": [ + { + "$ref": "#/$defs/SessionId" + } + ], + "description": "The ID of the session to close." + } + }, + "required": ["sessionId"], + "type": "object", + "x-method": "session/close", + "x-side": "agent" + }, + "CloseSessionResponse": { + "description": "Response from closing a session.", + "properties": { + "_meta": { + "additionalProperties": true, + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", + "type": ["object", "null"] + } + }, + "type": "object", + "x-method": "session/close", + "x-side": "agent" + }, "ConfigOptionUpdate": { "description": "Session configuration options have been updated.", "properties": { @@ -2281,6 +2350,70 @@ "required": ["name", "uri"], "type": "object" }, + "ResumeSessionRequest": { + "description": "Request parameters for resuming an existing session.\n\nResumes an existing session without returning previous messages (unlike `session/load`).\nThis is useful for agents that can resume sessions but don't implement full session loading.\n\nOnly available if the Agent supports the `sessionCapabilities.resume` capability.", + "properties": { + "_meta": { + "additionalProperties": true, + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", + "type": ["object", "null"] + }, + "cwd": { + "description": "The working directory for this session.", + "type": "string" + }, + "mcpServers": { + "description": "List of MCP servers to connect to for this session.", + "items": { + "$ref": "#/$defs/McpServer" + }, + "type": "array" + }, + "sessionId": { + "allOf": [ + { + "$ref": "#/$defs/SessionId" + } + ], + "description": "The ID of the session to resume." + } + }, + "required": ["sessionId", "cwd"], + "type": "object", + "x-method": "session/resume", + "x-side": "agent" + }, + "ResumeSessionResponse": { + "description": "Response from resuming an existing session.", + "properties": { + "_meta": { + "additionalProperties": true, + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", + "type": ["object", "null"] + }, + "configOptions": { + "description": "Initial session configuration options if supported by the Agent.", + "items": { + "$ref": "#/$defs/SessionConfigOption" + }, + "type": ["array", "null"] + }, + "modes": { + "anyOf": [ + { + "$ref": "#/$defs/SessionModeState" + }, + { + "type": "null" + } + ], + "description": "Initial mode state if supported by the Agent\n\nSee protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)" + } + }, + "type": "object", + "x-method": "session/resume", + "x-side": "agent" + }, "Role": { "description": "The sender or recipient of messages and data in a conversation.", "enum": ["assistant", "user"], @@ -2314,6 +2447,17 @@ "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", "type": ["object", "null"] }, + "close": { + "anyOf": [ + { + "$ref": "#/$defs/SessionCloseCapabilities" + }, + { + "type": "null" + } + ], + "description": "Whether the agent supports `session/close`." + }, "list": { "anyOf": [ { @@ -2324,6 +2468,28 @@ } ], "description": "Whether the agent supports `session/list`." + }, + "resume": { + "anyOf": [ + { + "$ref": "#/$defs/SessionResumeCapabilities" + }, + { + "type": "null" + } + ], + "description": "Whether the agent supports `session/resume`." + } + }, + "type": "object" + }, + "SessionCloseCapabilities": { + "description": "Capabilities for the `session/close` method.\n\nBy supplying `{}` it means that the agent supports closing of sessions.", + "properties": { + "_meta": { + "additionalProperties": true, + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", + "type": ["object", "null"] } }, "type": "object" @@ -2676,6 +2842,17 @@ "x-method": "session/update", "x-side": "client" }, + "SessionResumeCapabilities": { + "description": "Capabilities for the `session/resume` method.\n\nBy supplying `{}` it means that the agent supports resuming of sessions.", + "properties": { + "_meta": { + "additionalProperties": true, + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", + "type": ["object", "null"] + } + }, + "type": "object" + }, "SessionUpdate": { "description": "Different types of updates that can be sent during session processing.\n\nThese updates provide real-time feedback about the agent's progress.\n\nSee protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)", "discriminator": { diff --git a/schema/schema.unstable.json b/schema/schema.unstable.json index abb6fb8..8b3ac00 100644 --- a/schema/schema.unstable.json +++ b/schema/schema.unstable.json @@ -1238,7 +1238,7 @@ "$ref": "#/$defs/ResumeSessionRequest" } ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nResumes an existing session without returning previous messages.\n\nThis method is only available if the agent advertises the `sessionCapabilities.resume` capability.\n\nThe agent should resume the session context, allowing the conversation to continue\nwithout replaying the message history (unlike `session/load`).", + "description": "Resumes an existing session without returning previous messages.\n\nThis method is only available if the agent advertises the `sessionCapabilities.resume` capability.\n\nThe agent should resume the session context, allowing the conversation to continue\nwithout replaying the message history (unlike `session/load`).", "title": "ResumeSessionRequest" }, { @@ -1247,7 +1247,7 @@ "$ref": "#/$defs/CloseSessionRequest" } ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCloses an active session and frees up any resources associated with it.\n\nThis method is only available if the agent advertises the `sessionCapabilities.close` capability.\n\nThe agent must cancel any ongoing work (as if `session/cancel` was called)\nand then free up any resources associated with the session.", + "description": "Closes an active session and frees up any resources associated with it.\n\nThis method is only available if the agent advertises the `sessionCapabilities.close` capability.\n\nThe agent must cancel any ongoing work (as if `session/cancel` was called)\nand then free up any resources associated with the session.", "title": "CloseSessionRequest" }, { @@ -1484,7 +1484,7 @@ "x-side": "agent" }, "CloseSessionRequest": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nRequest parameters for closing an active session.\n\nIf supported, the agent **must** cancel any ongoing work related to the session\n(treat it as if `session/cancel` was called) and then free up any resources\nassociated with the session.\n\nOnly available if the Agent supports the `sessionCapabilities.close` capability.", + "description": "Request parameters for closing an active session.\n\nIf supported, the agent **must** cancel any ongoing work related to the session\n(treat it as if `session/cancel` was called) and then free up any resources\nassociated with the session.\n\nOnly available if the Agent supports the `sessionCapabilities.close` capability.", "properties": { "_meta": { "additionalProperties": true, @@ -1506,7 +1506,7 @@ "x-side": "agent" }, "CloseSessionResponse": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nResponse from closing a session.", + "description": "Response from closing a session.", "properties": { "_meta": { "additionalProperties": true, @@ -4879,7 +4879,7 @@ "type": "null" } ], - "description": "Current effective non-secret routing config.\nNull means provider is disabled." + "description": "Current effective non-secret routing config.\nNull or omitted means provider is disabled." }, "id": { "description": "Provider identifier, for example \"main\" or \"openai\".", @@ -4897,7 +4897,7 @@ "type": "array" } }, - "required": ["id", "supported", "required", "current"], + "required": ["id", "supported", "required"], "type": "object" }, "ProvidersCapabilities": { @@ -5219,7 +5219,7 @@ "type": "object" }, "ResumeSessionRequest": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nRequest parameters for resuming an existing session.\n\nResumes an existing session without returning previous messages (unlike `session/load`).\nThis is useful for agents that can resume sessions but don't implement full session loading.\n\nOnly available if the Agent supports the `sessionCapabilities.resume` capability.", + "description": "Request parameters for resuming an existing session.\n\nResumes an existing session without returning previous messages (unlike `session/load`).\nThis is useful for agents that can resume sessions but don't implement full session loading.\n\nOnly available if the Agent supports the `sessionCapabilities.resume` capability.", "properties": { "_meta": { "additionalProperties": true, @@ -5259,7 +5259,7 @@ "x-side": "agent" }, "ResumeSessionResponse": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nResponse from resuming an existing session.", + "description": "Response from resuming an existing session.", "properties": { "_meta": { "additionalProperties": true, @@ -5364,7 +5364,7 @@ "type": "null" } ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `session/close`." + "description": "Whether the agent supports `session/close`." }, "fork": { "anyOf": [ @@ -5397,13 +5397,13 @@ "type": "null" } ], - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `session/resume`." + "description": "Whether the agent supports `session/resume`." } }, "type": "object" }, "SessionCloseCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for the `session/close` method.\n\nBy supplying `{}` it means that the agent supports closing of sessions.", + "description": "Capabilities for the `session/close` method.\n\nBy supplying `{}` it means that the agent supports closing of sessions.", "properties": { "_meta": { "additionalProperties": true, @@ -5834,7 +5834,7 @@ "x-side": "client" }, "SessionResumeCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for the `session/resume` method.\n\nBy supplying `{}` it means that the agent supports resuming of sessions.", + "description": "Capabilities for the `session/resume` method.\n\nBy supplying `{}` it means that the agent supports resuming of sessions.", "properties": { "_meta": { "additionalProperties": true, diff --git a/schema/version b/schema/version index ac454c6..26acbf0 100644 --- a/schema/version +++ b/schema/version @@ -1 +1 @@ -0.12.0 +0.12.2 diff --git a/types_gen.go b/types_gen.go index 7417e1c..76e41ed 100644 --- a/types_gen.go +++ b/types_gen.go @@ -1098,6 +1098,42 @@ func (u ClientResponse) MarshalJSON() ([]byte, error) { return []byte{}, nil } +// Request parameters for closing an active session. +// +// If supported, the agent **must** cancel any ongoing work related to the session +// (treat it as if 'session/cancel' was called) and then free up any resources +// associated with the session. +// +// Only available if the Agent supports the 'sessionCapabilities.close' capability. +type CloseSessionRequest struct { + // The _meta property is reserved by ACP to allow clients and agents to attach additional + // metadata to their interactions. Implementations MUST NOT make assumptions about values at + // these keys. + // + // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + Meta map[string]any `json:"_meta,omitempty"` + // The ID of the session to close. + SessionId SessionId `json:"sessionId"` +} + +func (v *CloseSessionRequest) Validate() error { + return nil +} + +// Response from closing a session. +type CloseSessionResponse struct { + // The _meta property is reserved by ACP to allow clients and agents to attach additional + // metadata to their interactions. Implementations MUST NOT make assumptions about values at + // these keys. + // + // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + Meta map[string]any `json:"_meta,omitempty"` +} + +func (v *CloseSessionResponse) Validate() error { + return nil +} + // Session configuration options have been updated. type ConfigOptionUpdate struct { // The _meta property is reserved by ACP to allow clients and agents to attach additional @@ -3829,6 +3865,70 @@ type ResourceLink struct { Uri string `json:"uri"` } +// Request parameters for resuming an existing session. +// +// Resumes an existing session without returning previous messages (unlike 'session/load'). +// This is useful for agents that can resume sessions but don't implement full session loading. +// +// Only available if the Agent supports the 'sessionCapabilities.resume' capability. +type ResumeSessionRequest struct { + // The _meta property is reserved by ACP to allow clients and agents to attach additional + // metadata to their interactions. Implementations MUST NOT make assumptions about values at + // these keys. + // + // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + Meta map[string]any `json:"_meta,omitempty"` + // **UNSTABLE** + // + // This capability is not part of the spec yet, and may be removed or changed at any point. + // + // Additional workspace roots to activate for this session. Each path must be absolute. + // + // When omitted or empty, no additional roots are activated. When non-empty, + // this is the complete resulting additional-root list for the resumed + // session. + AdditionalDirectories []string `json:"additionalDirectories,omitempty"` + // The working directory for this session. + Cwd string `json:"cwd"` + // List of MCP servers to connect to for this session. + McpServers []McpServer `json:"mcpServers,omitempty"` + // The ID of the session to resume. + SessionId SessionId `json:"sessionId"` +} + +func (v *ResumeSessionRequest) Validate() error { + if v.Cwd == "" { + return fmt.Errorf("cwd is required") + } + return nil +} + +// Response from resuming an existing session. +type ResumeSessionResponse struct { + // The _meta property is reserved by ACP to allow clients and agents to attach additional + // metadata to their interactions. Implementations MUST NOT make assumptions about values at + // these keys. + // + // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) + Meta map[string]any `json:"_meta,omitempty"` + // Initial session configuration options if supported by the Agent. + ConfigOptions []SessionConfigOption `json:"configOptions,omitempty"` + // **UNSTABLE** + // + // This capability is not part of the spec yet, and may be removed or changed at any point. + // + // Initial model state if supported by the Agent + Models *SessionModelState `json:"models,omitempty"` + // Initial mode state if supported by the Agent + // + // See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) + Modes *SessionModeState `json:"modes,omitempty"` +} + +func (v *ResumeSessionResponse) Validate() error { + return nil +} + // The sender or recipient of messages and data in a conversation. type Role string @@ -3888,10 +3988,6 @@ type SessionCapabilities struct { // // Whether the agent supports 'additionalDirectories' on supported session lifecycle requests and 'session/list'. AdditionalDirectories *SessionAdditionalDirectoriesCapabilities `json:"additionalDirectories,omitempty"` - // **UNSTABLE** - // - // This capability is not part of the spec yet, and may be removed or changed at any point. - // // Whether the agent supports 'session/close'. Close *SessionCloseCapabilities `json:"close,omitempty"` // **UNSTABLE** @@ -3902,18 +3998,10 @@ type SessionCapabilities struct { Fork *SessionForkCapabilities `json:"fork,omitempty"` // Whether the agent supports 'session/list'. List *SessionListCapabilities `json:"list,omitempty"` - // **UNSTABLE** - // - // This capability is not part of the spec yet, and may be removed or changed at any point. - // // Whether the agent supports 'session/resume'. Resume *SessionResumeCapabilities `json:"resume,omitempty"` } -// **UNSTABLE** -// -// This capability is not part of the spec yet, and may be removed or changed at any point. -// // Capabilities for the 'session/close' method. // // By supplying '{}' it means that the agent supports closing of sessions. @@ -4487,10 +4575,6 @@ func (v *SessionNotification) Validate() error { return nil } -// **UNSTABLE** -// -// This capability is not part of the spec yet, and may be removed or changed at any point. -// // Capabilities for the 'session/resume' method. // // By supplying '{}' it means that the agent supports resuming of sessions. @@ -6067,50 +6151,6 @@ func (v *UnstableCloseNesResponse) Validate() error { return nil } -// **UNSTABLE** -// -// This capability is not part of the spec yet, and may be removed or changed at any point. -// -// Request parameters for closing an active session. -// -// If supported, the agent **must** cancel any ongoing work related to the session -// (treat it as if 'session/cancel' was called) and then free up any resources -// associated with the session. -// -// Only available if the Agent supports the 'sessionCapabilities.close' capability. -type UnstableCloseSessionRequest struct { - // The _meta property is reserved by ACP to allow clients and agents to attach additional - // metadata to their interactions. Implementations MUST NOT make assumptions about values at - // these keys. - // - // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) - Meta map[string]any `json:"_meta,omitempty"` - // The ID of the session to close. - SessionId SessionId `json:"sessionId"` -} - -func (v *UnstableCloseSessionRequest) Validate() error { - return nil -} - -// **UNSTABLE** -// -// This capability is not part of the spec yet, and may be removed or changed at any point. -// -// Response from closing a session. -type UnstableCloseSessionResponse struct { - // The _meta property is reserved by ACP to allow clients and agents to attach additional - // metadata to their interactions. Implementations MUST NOT make assumptions about values at - // these keys. - // - // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) - Meta map[string]any `json:"_meta,omitempty"` -} - -func (v *UnstableCloseSessionResponse) Validate() error { - return nil -} - // **UNSTABLE** // // This capability is not part of the spec yet, and may be removed or changed at any point. @@ -7754,8 +7794,8 @@ type UnstableProviderInfo struct { // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) Meta map[string]any `json:"_meta,omitempty"` // Current effective non-secret routing config. - // Null means provider is disabled. - Current *UnstableProviderCurrentConfig `json:"current"` + // Null or omitted means provider is disabled. + Current *UnstableProviderCurrentConfig `json:"current,omitempty"` // Provider identifier, for example "main" or "openai". Id string `json:"id"` // Whether this provider is mandatory and cannot be disabled via 'providers/disable'. @@ -7796,78 +7836,6 @@ func (v *UnstableRejectNesNotification) Validate() error { return nil } -// **UNSTABLE** -// -// This capability is not part of the spec yet, and may be removed or changed at any point. -// -// Request parameters for resuming an existing session. -// -// Resumes an existing session without returning previous messages (unlike 'session/load'). -// This is useful for agents that can resume sessions but don't implement full session loading. -// -// Only available if the Agent supports the 'sessionCapabilities.resume' capability. -type UnstableResumeSessionRequest struct { - // The _meta property is reserved by ACP to allow clients and agents to attach additional - // metadata to their interactions. Implementations MUST NOT make assumptions about values at - // these keys. - // - // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) - Meta map[string]any `json:"_meta,omitempty"` - // **UNSTABLE** - // - // This capability is not part of the spec yet, and may be removed or changed at any point. - // - // Additional workspace roots to activate for this session. Each path must be absolute. - // - // When omitted or empty, no additional roots are activated. When non-empty, - // this is the complete resulting additional-root list for the resumed - // session. - AdditionalDirectories []string `json:"additionalDirectories,omitempty"` - // The working directory for this session. - Cwd string `json:"cwd"` - // List of MCP servers to connect to for this session. - McpServers []McpServer `json:"mcpServers,omitempty"` - // The ID of the session to resume. - SessionId SessionId `json:"sessionId"` -} - -func (v *UnstableResumeSessionRequest) Validate() error { - if v.Cwd == "" { - return fmt.Errorf("cwd is required") - } - return nil -} - -// **UNSTABLE** -// -// This capability is not part of the spec yet, and may be removed or changed at any point. -// -// Response from resuming an existing session. -type UnstableResumeSessionResponse struct { - // The _meta property is reserved by ACP to allow clients and agents to attach additional - // metadata to their interactions. Implementations MUST NOT make assumptions about values at - // these keys. - // - // See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility) - Meta map[string]any `json:"_meta,omitempty"` - // Initial session configuration options if supported by the Agent. - ConfigOptions []UnstableSessionConfigOption `json:"configOptions,omitempty"` - // **UNSTABLE** - // - // This capability is not part of the spec yet, and may be removed or changed at any point. - // - // Initial model state if supported by the Agent - Models *UnstableSessionModelState `json:"models,omitempty"` - // Initial mode state if supported by the Agent - // - // See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes) - Modes *SessionModeState `json:"modes,omitempty"` -} - -func (v *UnstableResumeSessionResponse) Validate() error { - return nil -} - // **UNSTABLE** // // This capability is not part of the spec yet, and may be removed or changed at any point. @@ -8430,6 +8398,14 @@ type Agent interface { // // See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation) Cancel(ctx context.Context, params CancelNotification) error + // Request parameters for closing an active session. + // + // If supported, the agent **must** cancel any ongoing work related to the session + // (treat it as if 'session/cancel' was called) and then free up any resources + // associated with the session. + // + // Only available if the Agent supports the 'sessionCapabilities.close' capability. + CloseSession(ctx context.Context, params CloseSessionRequest) (CloseSessionResponse, error) // Request parameters for listing existing sessions. // // Only available if the Agent supports the 'sessionCapabilities.list' capability. @@ -8444,6 +8420,13 @@ type Agent interface { // // See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message) Prompt(ctx context.Context, params PromptRequest) (PromptResponse, error) + // Request parameters for resuming an existing session. + // + // Resumes an existing session without returning previous messages (unlike 'session/load'). + // This is useful for agents that can resume sessions but don't implement full session loading. + // + // Only available if the Agent supports the 'sessionCapabilities.resume' capability. + ResumeSession(ctx context.Context, params ResumeSessionRequest) (ResumeSessionResponse, error) // Request parameters for setting a session configuration option. SetSessionConfigOption(ctx context.Context, params SetSessionConfigOptionRequest) (SetSessionConfigOptionResponse, error) // Request parameters for setting a session mode. @@ -8517,18 +8500,6 @@ type AgentExperimental interface { // // This capability is not part of the spec yet, and may be removed or changed at any point. // - // Request parameters for closing an active session. - // - // If supported, the agent **must** cancel any ongoing work related to the session - // (treat it as if 'session/cancel' was called) and then free up any resources - // associated with the session. - // - // Only available if the Agent supports the 'sessionCapabilities.close' capability. - UnstableCloseSession(ctx context.Context, params UnstableCloseSessionRequest) (UnstableCloseSessionResponse, error) - // **UNSTABLE** - // - // This capability is not part of the spec yet, and may be removed or changed at any point. - // // Request parameters for forking an existing session. // // Creates a new session based on the context of an existing one, allowing @@ -8540,17 +8511,6 @@ type AgentExperimental interface { // // This capability is not part of the spec yet, and may be removed or changed at any point. // - // Request parameters for resuming an existing session. - // - // Resumes an existing session without returning previous messages (unlike 'session/load'). - // This is useful for agents that can resume sessions but don't implement full session loading. - // - // Only available if the Agent supports the 'sessionCapabilities.resume' capability. - UnstableResumeSession(ctx context.Context, params UnstableResumeSessionRequest) (UnstableResumeSessionResponse, error) - // **UNSTABLE** - // - // This capability is not part of the spec yet, and may be removed or changed at any point. - // // Request parameters for setting a session model. UnstableSetSessionModel(ctx context.Context, params UnstableSetSessionModelRequest) (UnstableSetSessionModelResponse, error) } diff --git a/version b/version index ac454c6..26acbf0 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.12.0 +0.12.2