Skip to content

Commit f9384f5

Browse files
authored
feat(unstable): Add session delete handling (#152)
1 parent b15960b commit f9384f5

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

src/acp.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ export class AgentSideConnection {
7575
const validatedParams = validate.zListSessionsRequest.parse(params);
7676
return agent.listSessions(validatedParams);
7777
}
78+
case schema.AGENT_METHODS.session_delete: {
79+
if (!agent.unstable_deleteSession) {
80+
throw RequestError.methodNotFound(method);
81+
}
82+
const validatedParams = validate.zDeleteSessionRequest.parse(params);
83+
const result = await agent.unstable_deleteSession(validatedParams);
84+
return result ?? {};
85+
}
7886
case schema.AGENT_METHODS.session_fork: {
7987
if (!agent.unstable_forkSession) {
8088
throw RequestError.methodNotFound(method);
@@ -815,6 +823,28 @@ export class ClientSideConnection implements Agent {
815823
);
816824
}
817825

826+
/**
827+
* **UNSTABLE**
828+
*
829+
* This capability is not part of the spec yet, and may be removed or changed at any point.
830+
*
831+
* Deletes an existing session returned by `session/list`.
832+
*
833+
* This method is only available if the agent advertises the `sessionCapabilities.delete` capability.
834+
*
835+
* @experimental
836+
*/
837+
async unstable_deleteSession(
838+
params: schema.DeleteSessionRequest,
839+
): Promise<schema.DeleteSessionResponse> {
840+
return (
841+
(await this.connection.sendRequest(
842+
schema.AGENT_METHODS.session_delete,
843+
params,
844+
)) ?? {}
845+
);
846+
}
847+
818848
/**
819849
* Resumes an existing session without returning previous messages.
820850
*
@@ -1986,6 +2016,20 @@ export interface Agent {
19862016
listSessions?(
19872017
params: schema.ListSessionsRequest,
19882018
): Promise<schema.ListSessionsResponse>;
2019+
/**
2020+
* **UNSTABLE**
2021+
*
2022+
* This capability is not part of the spec yet, and may be removed or changed at any point.
2023+
*
2024+
* Deletes an existing session returned by `session/list`.
2025+
*
2026+
* This method is only available if the agent advertises the `sessionCapabilities.delete` capability.
2027+
*
2028+
* @experimental
2029+
*/
2030+
unstable_deleteSession?(
2031+
params: schema.DeleteSessionRequest,
2032+
): Promise<schema.DeleteSessionResponse | void>;
19892033
/**
19902034
* Resumes an existing session without returning previous messages.
19912035
*

0 commit comments

Comments
 (0)