Skip to content

Commit 16262ef

Browse files
authored
add unstable forkSession support (#37)
1 parent 88f6fd8 commit 16262ef

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/acp.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ export class AgentSideConnection {
6464
const validatedParams = validate.zLoadSessionRequest.parse(params);
6565
return agent.loadSession(validatedParams);
6666
}
67+
case schema.AGENT_METHODS.session_fork: {
68+
if (!agent.forkSession) {
69+
throw RequestError.methodNotFound(method);
70+
}
71+
const validatedParams = validate.zForkSessionRequest.parse(params);
72+
return agent.forkSession(validatedParams);
73+
}
6774
case schema.AGENT_METHODS.session_set_mode: {
6875
if (!agent.setSessionMode) {
6976
throw RequestError.methodNotFound(method);
@@ -603,6 +610,27 @@ export class ClientSideConnection implements Agent {
603610
);
604611
}
605612

613+
/**
614+
* **UNSTABLE**
615+
*
616+
* This capability is not part of the spec yet, and may be removed or changed at any point.
617+
*
618+
* Forks an existing session to create a new independent session.
619+
*
620+
* Creates a new session based on the context of an existing one, allowing
621+
* operations like generating summaries without affecting the original session's history.
622+
*
623+
* This method is only available if the agent advertises the `session.fork` capability.
624+
*/
625+
async forkSession(
626+
params: schema.ForkSessionRequest,
627+
): Promise<schema.ForkSessionResponse> {
628+
return await this.#connection.sendRequest(
629+
schema.AGENT_METHODS.session_fork,
630+
params,
631+
);
632+
}
633+
606634
/**
607635
* Sets the operational mode for a session.
608636
*
@@ -1373,6 +1401,21 @@ export interface Agent {
13731401
loadSession?(
13741402
params: schema.LoadSessionRequest,
13751403
): Promise<schema.LoadSessionResponse>;
1404+
/**
1405+
* **UNSTABLE**
1406+
*
1407+
* This capability is not part of the spec yet, and may be removed or changed at any point.
1408+
*
1409+
* Forks an existing session to create a new independent session.
1410+
*
1411+
* Creates a new session based on the context of an existing one, allowing
1412+
* operations like generating summaries without affecting the original session's history.
1413+
*
1414+
* This method is only available if the agent advertises the `session.fork` capability.
1415+
*/
1416+
forkSession?(
1417+
params: schema.ForkSessionRequest,
1418+
): Promise<schema.ForkSessionResponse>;
13761419
/**
13771420
* Sets the operational mode for a session.
13781421
*

0 commit comments

Comments
 (0)