Skip to content

Commit 806d307

Browse files
authored
feat: Stabilize closeSession and resumeSession (#132)
Updates schema to v0.12.2 Make sure to update your `unstable_closeSession` and `unstable_resumeSession` method names!
1 parent f293b70 commit 806d307

8 files changed

Lines changed: 770 additions & 134 deletions

File tree

schema/meta.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"nes_reject": "nes/reject",
1414
"nes_start": "nes/start",
1515
"nes_suggest": "nes/suggest",
16+
"providers_disable": "providers/disable",
17+
"providers_list": "providers/list",
18+
"providers_set": "providers/set",
1619
"session_cancel": "session/cancel",
1720
"session_close": "session/close",
1821
"session_fork": "session/fork",

schema/schema.json

Lines changed: 290 additions & 10 deletions
Large diffs are not rendered by default.

scripts/generate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as fs from "fs/promises";
55
import { dirname } from "path";
66
import * as prettier from "prettier";
77

8-
const CURRENT_SCHEMA_RELEASE = "v0.11.6";
8+
const CURRENT_SCHEMA_RELEASE = "v0.12.2";
99

1010
await main();
1111

src/acp.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ describe("Connection", () => {
20012001
receivedForkSession = params;
20022002
return { sessionId: "forked-s1" };
20032003
}
2004-
async unstable_resumeSession(
2004+
async resumeSession(
20052005
params: ResumeSessionRequest,
20062006
): Promise<ResumeSessionResponse> {
20072007
receivedResumeSession = params;
@@ -2060,7 +2060,7 @@ describe("Connection", () => {
20602060
"/extra/root2",
20612061
]);
20622062

2063-
const resumeResponse = await agentConnection.unstable_resumeSession({
2063+
const resumeResponse = await agentConnection.resumeSession({
20642064
sessionId: "s1",
20652065
cwd: "/test",
20662066
additionalDirectories: ["/extra/root1", "/extra/root2"],

src/acp.ts

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,19 @@ export class AgentSideConnection {
8383
return agent.unstable_forkSession(validatedParams);
8484
}
8585
case schema.AGENT_METHODS.session_resume: {
86-
if (!agent.unstable_resumeSession) {
86+
if (!agent.resumeSession) {
8787
throw RequestError.methodNotFound(method);
8888
}
8989
const validatedParams = validate.zResumeSessionRequest.parse(params);
90-
return agent.unstable_resumeSession(validatedParams);
90+
return agent.resumeSession(validatedParams);
9191
}
9292
case schema.AGENT_METHODS.session_close: {
93-
if (!agent.unstable_closeSession) {
93+
if (!agent.closeSession) {
9494
throw RequestError.methodNotFound(method);
9595
}
9696
const validatedParams = validate.zCloseSessionRequest.parse(params);
97-
return agent.unstable_closeSession(validatedParams);
97+
const result = await agent.closeSession(validatedParams);
98+
return result ?? {};
9899
}
99100
case schema.AGENT_METHODS.session_set_mode: {
100101
if (!agent.setSessionMode) {
@@ -791,10 +792,6 @@ export class ClientSideConnection implements Agent {
791792
}
792793

793794
/**
794-
* **UNSTABLE**
795-
*
796-
* This capability is not part of the spec yet, and may be removed or changed at any point.
797-
*
798795
* Resumes an existing session without returning previous messages.
799796
*
800797
* This method is only available if the agent advertises the `session.resume` capability.
@@ -804,10 +801,8 @@ export class ClientSideConnection implements Agent {
804801
*
805802
* The request may include `additionalDirectories` to set the complete list of
806803
* additional workspace roots for the resumed session.
807-
*
808-
* @experimental
809804
*/
810-
async unstable_resumeSession(
805+
async resumeSession(
811806
params: schema.ResumeSessionRequest,
812807
): Promise<schema.ResumeSessionResponse> {
813808
return await this.connection.sendRequest(
@@ -817,20 +812,14 @@ export class ClientSideConnection implements Agent {
817812
}
818813

819814
/**
820-
* **UNSTABLE**
821-
*
822-
* This capability is not part of the spec yet, and may be removed or changed at any point.
823-
*
824815
* Closes an active session and frees up any resources associated with it.
825816
*
826817
* This method is only available if the agent advertises the `session.close` capability.
827818
*
828819
* The agent must cancel any ongoing work (as if `session/cancel` was called)
829820
* and then free up any resources associated with the session.
830-
*
831-
* @experimental
832821
*/
833-
async unstable_closeSession(
822+
async closeSession(
834823
params: schema.CloseSessionRequest,
835824
): Promise<schema.CloseSessionResponse> {
836825
return await this.connection.sendRequest(
@@ -1910,10 +1899,6 @@ export interface Agent {
19101899
params: schema.ListSessionsRequest,
19111900
): Promise<schema.ListSessionsResponse>;
19121901
/**
1913-
* **UNSTABLE**
1914-
*
1915-
* This capability is not part of the spec yet, and may be removed or changed at any point.
1916-
*
19171902
* Resumes an existing session without returning previous messages.
19181903
*
19191904
* This method is only available if the agent advertises the `session.resume` capability.
@@ -1923,29 +1908,21 @@ export interface Agent {
19231908
*
19241909
* The request may include `additionalDirectories` to set the complete list of
19251910
* additional workspace roots for the resumed session.
1926-
*
1927-
* @experimental
19281911
*/
1929-
unstable_resumeSession?(
1912+
resumeSession?(
19301913
params: schema.ResumeSessionRequest,
19311914
): Promise<schema.ResumeSessionResponse>;
19321915
/**
1933-
* **UNSTABLE**
1934-
*
1935-
* This capability is not part of the spec yet, and may be removed or changed at any point.
1936-
*
19371916
* Closes an active session and frees up any resources associated with it.
19381917
*
19391918
* This method is only available if the agent advertises the `session.close` capability.
19401919
*
19411920
* The agent must cancel any ongoing work (as if `session/cancel` was called)
19421921
* and then free up any resources associated with the session.
1943-
*
1944-
* @experimental
19451922
*/
1946-
unstable_closeSession?(
1923+
closeSession?(
19471924
params: schema.CloseSessionRequest,
1948-
): Promise<schema.CloseSessionResponse>;
1925+
): Promise<schema.CloseSessionResponse | void>;
19491926
/**
19501927
* Sets the operational mode for a session.
19511928
*

src/schema/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export type {
5050
DidOpenDocumentNotification,
5151
DidSaveDocumentNotification,
5252
Diff,
53+
DisableProvidersRequest,
54+
DisableProvidersResponse,
5355
ElicitationAcceptAction,
5456
ElicitationCapabilities,
5557
ElicitationContentValue,
@@ -84,8 +86,11 @@ export type {
8486
IntegerPropertySchema,
8587
KillTerminalRequest,
8688
KillTerminalResponse,
89+
ListProvidersRequest,
90+
ListProvidersResponse,
8791
ListSessionsRequest,
8892
ListSessionsResponse,
93+
LlmProtocol,
8994
LoadSessionRequest,
9095
LoadSessionResponse,
9196
LogoutCapabilities,
@@ -152,6 +157,9 @@ export type {
152157
PromptRequest,
153158
PromptResponse,
154159
ProtocolVersion,
160+
ProviderCurrentConfig,
161+
ProviderInfo,
162+
ProvidersCapabilities,
155163
Range,
156164
ReadTextFileRequest,
157165
ReadTextFileResponse,
@@ -192,6 +200,8 @@ export type {
192200
SessionNotification,
193201
SessionResumeCapabilities,
194202
SessionUpdate,
203+
SetProvidersRequest,
204+
SetProvidersResponse,
195205
SetSessionConfigOptionRequest,
196206
SetSessionConfigOptionResponse,
197207
SetSessionModelRequest,
@@ -246,6 +256,9 @@ export const AGENT_METHODS = {
246256
nes_reject: "nes/reject",
247257
nes_start: "nes/start",
248258
nes_suggest: "nes/suggest",
259+
providers_disable: "providers/disable",
260+
providers_list: "providers/list",
261+
providers_set: "providers/set",
249262
session_cancel: "session/cancel",
250263
session_close: "session/close",
251264
session_fork: "session/fork",

0 commit comments

Comments
 (0)