Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
394 changes: 227 additions & 167 deletions schema/schema.json

Large diffs are not rendered by default.

415 changes: 234 additions & 181 deletions schema/v2/schema.unstable.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import * as fs from "fs/promises";
import { dirname } from "path";
import * as prettier from "prettier";

const CURRENT_V1_SCHEMA_RELEASE = "schema-v1.20.0";
const CURRENT_V2_SCHEMA_RELEASE = "schema-v2.0.0-alpha.2";
const CURRENT_V1_SCHEMA_RELEASE = "schema-v1.21.0";
const CURRENT_V2_SCHEMA_RELEASE = "schema-v2.0.0-alpha.3";
const CHECK_GENERATED = process.argv.includes("--check");

// ── Extensible-union pipeline ────────────────────────────────────────────────
Expand Down
24 changes: 12 additions & 12 deletions src/acp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2685,8 +2685,8 @@ describe("Connection", () => {

async function exerciseElicitation(agentClient: AgentSideConnection) {
const response =
await agentClient.unstable_createElicitation(elicitationRequest);
await agentClient.unstable_completeElicitation({
await agentClient.createElicitation(elicitationRequest);
await agentClient.completeElicitation({
elicitationId: "elicitation-1",
});
return response;
Expand All @@ -2699,14 +2699,14 @@ describe("Connection", () => {
return { outcome: { outcome: "cancelled" } };
},
sessionUpdate(): void {},
unstable_createElicitation(params) {
createElicitation(params) {
received.push(["create", params.message]);
return {
action: "accept",
content: { name: "Alice" },
};
},
unstable_completeElicitation(params) {
completeElicitation(params) {
received.push(["complete", params.elicitationId]);
},
}),
Expand Down Expand Up @@ -5910,7 +5910,7 @@ describe("Connection", () => {
}
async sessionUpdate(_: SessionNotification): Promise<void> {}

async unstable_createElicitation(
async createElicitation(
params: CreateElicitationRequest,
): Promise<CreateElicitationResponse> {
receivedRequest = params;
Expand All @@ -5919,7 +5919,7 @@ describe("Connection", () => {
content: { name: "Alice" },
};
}
async unstable_completeElicitation(
async completeElicitation(
params: CompleteElicitationNotification,
): Promise<void> {
receivedNotification = params;
Expand Down Expand Up @@ -5954,7 +5954,7 @@ describe("Connection", () => {
);

// Test form-mode elicitation request
const response = await clientConnection.unstable_createElicitation({
const response = await clientConnection.createElicitation({
sessionId: "test-session",
mode: "form",
message: "Please enter your name",
Expand All @@ -5973,7 +5973,7 @@ describe("Connection", () => {

// Test url-mode elicitation request
receivedRequest = undefined;
const urlResponse = await clientConnection.unstable_createElicitation({
const urlResponse = await clientConnection.createElicitation({
sessionId: "test-session",
mode: "url",
message: "Please authenticate",
Expand All @@ -5988,7 +5988,7 @@ describe("Connection", () => {
expect((receivedRequest as any)?.elicitationId).toBe("elic-url-1");

// Test elicitation complete notification
await clientConnection.unstable_completeElicitation({
await clientConnection.completeElicitation({
elicitationId: "elic-1",
});

Expand Down Expand Up @@ -6044,13 +6044,13 @@ describe("Connection", () => {
ndJsonStream(agentToClient.writable, clientToAgent.readable),
);

await clientConnection.unstable_completeElicitation({
await clientConnection.completeElicitation({
elicitationId: "elic-1",
});
});

it("rejects elicitation request when client does not implement handler", async () => {
// Client WITHOUT unstable_createElicitation
// Client WITHOUT createElicitation
class TestClient implements Client {
async writeTextFile(
_: WriteTextFileRequest,
Expand Down Expand Up @@ -6098,7 +6098,7 @@ describe("Connection", () => {
);

await expect(
clientConnection.unstable_createElicitation({
clientConnection.createElicitation({
sessionId: "test-session",
mode: "form",
message: "Enter your name",
Expand Down
67 changes: 17 additions & 50 deletions src/acp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ const clientRequestSpecs = {
validate.zKillTerminalRequest,
emptyObjectResponse,
),
unstable_createElicitation: requestSpec<
createElicitation: requestSpec<
schema.CreateElicitationRequest,
schema.CreateElicitationResponse
>(
Expand All @@ -1392,11 +1392,10 @@ const clientNotificationSpecs = {
schema.CLIENT_METHODS.session_update,
validate.zSessionNotification,
),
unstable_completeElicitation:
notificationSpec<schema.CompleteElicitationNotification>(
schema.CLIENT_METHODS.elicitation_complete,
validate.zCompleteElicitationNotification,
),
completeElicitation: notificationSpec<schema.CompleteElicitationNotification>(
schema.CLIENT_METHODS.elicitation_complete,
validate.zCompleteElicitationNotification,
),
};

const agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
Expand Down Expand Up @@ -2605,14 +2604,14 @@ function legacyClientApp(implementation: Client): ClientApp {
async (ctx) => (await implementation.killTerminal?.(ctx.params)) ?? {},
);

if (implementation.unstable_createElicitation) {
if (implementation.createElicitation) {
app.onRequest(schema.CLIENT_METHODS.elicitation_create, (ctx) =>
implementation.unstable_createElicitation!(ctx.params),
implementation.createElicitation!(ctx.params),
);
}
if (implementation.unstable_completeElicitation) {
if (implementation.completeElicitation) {
app.onNotification(schema.CLIENT_METHODS.elicitation_complete, (ctx) =>
implementation.unstable_completeElicitation!(ctx.params),
implementation.completeElicitation!(ctx.params),
);
}

Expand Down Expand Up @@ -2799,16 +2798,8 @@ export class AgentSideConnection {
);
}

/**
* **UNSTABLE**
*
* This capability is not part of the spec yet, and may be removed or changed at any point.
*
* Creates an elicitation to request input from the user.
*
* @experimental
*/
unstable_createElicitation(
/** Creates an elicitation to request input from the user. */
createElicitation(
params: schema.CreateElicitationRequest,
): Promise<schema.CreateElicitationResponse> {
return this.connection.sendRequest(
Expand All @@ -2817,16 +2808,8 @@ export class AgentSideConnection {
);
}

/**
* **UNSTABLE**
*
* This capability is not part of the spec yet, and may be removed or changed at any point.
*
* Notifies the client that a URL-based elicitation is complete.
*
* @experimental
*/
unstable_completeElicitation(
/** Notifies the client that a URL-based elicitation is complete. */
completeElicitation(
params: schema.CompleteElicitationNotification,
): Promise<void> {
return this.connection.sendNotification(
Expand Down Expand Up @@ -3860,29 +3843,13 @@ export interface Client {
params: schema.KillTerminalRequest,
): MaybePromise<schema.KillTerminalResponse | void>;

/**
* **UNSTABLE**
*
* This capability is not part of the spec yet, and may be removed or changed at any point.
*
* Creates an elicitation to request input from the user.
*
* @experimental
*/
unstable_createElicitation?(
/** Creates an elicitation to request input from the user. */
createElicitation?(
params: schema.CreateElicitationRequest,
): MaybePromise<schema.CreateElicitationResponse>;

/**
* **UNSTABLE**
*
* This capability is not part of the spec yet, and may be removed or changed at any point.
*
* Called when a URL-based elicitation is complete.
*
* @experimental
*/
unstable_completeElicitation?(
/** Called when a URL-based elicitation is complete. */
completeElicitation?(
params: schema.CompleteElicitationNotification,
): MaybePromise<void>;

Expand Down
16 changes: 0 additions & 16 deletions src/schema/guards.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,11 @@ const zGuardCreateElicitationResponseCancel = z.object({
});

/**
* **UNSTABLE**
*
* This capability is not part of the spec yet, and may be removed or changed at any point.
*
* Request from the agent to elicit structured user input.
*
* The agent sends this to the client to request information from the user,
* either via a form or by directing them to a URL.
* Elicitations are tied to a session (optionally a tool call) or a request.
*
* @experimental
*/
export type CreateElicitationRequest = types.CreateElicitationRequest;
/**
Expand All @@ -75,8 +69,6 @@ export type CreateElicitationRequest = types.CreateElicitationRequest;
* another variant's payload) guards are conservative where wire parsing
* may still accept the value — narrow wire-parsed values when exact
* parity matters.
*
* @experimental
*/
export const CreateElicitationRequest = {
/** Narrow to the `form` variant, validating its payload. */
Expand Down Expand Up @@ -271,13 +263,7 @@ export const MultiSelectItems = {
} as const;

/**
* **UNSTABLE**
*
* This capability is not part of the spec yet, and may be removed or changed at any point.
*
* Response from the client to an elicitation request.
*
* @experimental
*/
export type CreateElicitationResponse = types.CreateElicitationResponse;
/**
Expand All @@ -294,8 +280,6 @@ export type CreateElicitationResponse = types.CreateElicitationResponse;
* another variant's payload) guards are conservative where wire parsing
* may still accept the value — narrow wire-parsed values when exact
* parity matters.
*
* @experimental
*/
export const CreateElicitationResponse = {
/** Narrow to the `accept` variant, validating its payload. */
Expand Down
7 changes: 5 additions & 2 deletions src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ export type {
AuthCapabilities,
AuthenticateRequest,
AuthenticateResponse,
AuthEnvVar,
AuthMethod,
AuthMethodAgent,
AuthMethodEnvVar,
AuthMethodId,
AuthMethodTerminal,
AvailableCommand,
Expand All @@ -36,6 +34,11 @@ export type {
CloseNesResponse,
CloseSessionRequest,
CloseSessionResponse,
CompactionCapabilities,
CompactionId,
CompactionStatus,
CompactionSummaryChunk,
CompactionUpdate,
CompleteElicitationNotification,
ConfigOptionUpdate,
ConnectMcpRequest,
Expand Down
Loading