From 295be10658c7d46dbc0bfafe047f116adeb233be Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Tue, 9 Dec 2025 12:16:45 +0100 Subject: [PATCH] add unstable forkSession support --- src/acp.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/acp.ts b/src/acp.ts index 7abacb9..a9ff39e 100644 --- a/src/acp.ts +++ b/src/acp.ts @@ -64,6 +64,13 @@ export class AgentSideConnection { const validatedParams = validate.zLoadSessionRequest.parse(params); return agent.loadSession(validatedParams); } + case schema.AGENT_METHODS.session_fork: { + if (!agent.forkSession) { + throw RequestError.methodNotFound(method); + } + const validatedParams = validate.zForkSessionRequest.parse(params); + return agent.forkSession(validatedParams); + } case schema.AGENT_METHODS.session_set_mode: { if (!agent.setSessionMode) { throw RequestError.methodNotFound(method); @@ -603,6 +610,27 @@ export class ClientSideConnection implements Agent { ); } + /** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Forks an existing session to create a new independent session. + * + * Creates a new session based on the context of an existing one, allowing + * operations like generating summaries without affecting the original session's history. + * + * This method is only available if the agent advertises the `session.fork` capability. + */ + async forkSession( + params: schema.ForkSessionRequest, + ): Promise { + return await this.#connection.sendRequest( + schema.AGENT_METHODS.session_fork, + params, + ); + } + /** * Sets the operational mode for a session. * @@ -1373,6 +1401,21 @@ export interface Agent { loadSession?( params: schema.LoadSessionRequest, ): Promise; + /** + * **UNSTABLE** + * + * This capability is not part of the spec yet, and may be removed or changed at any point. + * + * Forks an existing session to create a new independent session. + * + * Creates a new session based on the context of an existing one, allowing + * operations like generating summaries without affecting the original session's history. + * + * This method is only available if the agent advertises the `session.fork` capability. + */ + forkSession?( + params: schema.ForkSessionRequest, + ): Promise; /** * Sets the operational mode for a session. *