From 3a6a9bb380ce2470737e53b4143e5a6eab13593d Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Mon, 9 Nov 2026 13:16:54 +0100 Subject: [PATCH] feat: update to schema v1.30.0 and v2.0.0-alpha.14 Regenerate the v1 and v2 bindings. Client-provided system prompts are stable: the stable v1 and v2 entrypoints now export `SystemPrompt`, `SystemPromptMode`, and the `SessionSystemPrompt*Capabilities` types, and accept `systemPrompt` on `session/new`, `session/load` (v1), and `session/resume`. `systemPrompt` on `session/fork` still requires the unstable entrypoint. Request fields stay strict, so a malformed prompt fails with `-32602`. A malformed capability means no support. - MIGRATION_STABLE_UNSTABLE.md uses `ForkSessionRequest` as its unstable-only import example and limits the `systemPrompt` bullet to `session/fork`. - The v2 package docs no longer call `systemPrompt` unstable. - `ActiveSession.cancelToolCall` and `cancelTerminal` document that a subagent's tool calls and terminals are cancelled with the child's `sessionId`, enabled by the item's own `capabilities.cancel`. - Add v1 and v2 tests for the stable `systemPrompt` validators. Co-Authored-By: Claude --- MIGRATION_STABLE_UNSTABLE.md | 11 +- schema/v1/schema.json | 153 +++++++++++++++++++++++++++ schema/v1/schema.unstable.json | 22 ++-- schema/v2/schema.json | 142 +++++++++++++++++++++++++ schema/v2/schema.unstable.json | 20 ++-- scripts/generate.js | 4 +- src/v1/acp.test.ts | 54 ++++++++++ src/v1/schema/index.ts | 5 + src/v1/schema/types.gen.ts | 155 ++++++++++++++++++++++++++++ src/v1/schema/zod.gen.ts | 84 +++++++++++++++ src/v1/unstable/schema/types.gen.ts | 65 +----------- src/v1/unstable/schema/zod.gen.ts | 33 +----- src/v2/acp.test.ts | 49 +++++++++ src/v2/acp.ts | 21 +++- src/v2/schema/index.ts | 5 + src/v2/schema/types.gen.ts | 145 ++++++++++++++++++++++++++ src/v2/schema/zod.gen.ts | 83 +++++++++++++++ src/v2/stable/acp.ts | 21 +++- src/v2/unstable/schema/types.gen.ts | 58 +---------- src/v2/unstable/schema/zod.gen.ts | 32 +----- 20 files changed, 944 insertions(+), 218 deletions(-) diff --git a/MIGRATION_STABLE_UNSTABLE.md b/MIGRATION_STABLE_UNSTABLE.md index ebf63f8e..344f2931 100644 --- a/MIGRATION_STABLE_UNSTABLE.md +++ b/MIGRATION_STABLE_UNSTABLE.md @@ -60,7 +60,11 @@ narrowing helpers. Before: ```ts -import { client, methods, type SystemPrompt } from "@agentclientprotocol/sdk"; +import { + client, + methods, + type ForkSessionRequest, +} from "@agentclientprotocol/sdk"; ``` After: @@ -69,7 +73,7 @@ After: import { client, methods, - type SystemPrompt, + type ForkSessionRequest, } from "@agentclientprotocol/sdk/unstable"; ``` @@ -108,7 +112,8 @@ of APIs that require `/unstable` include: - Session forking and provider configuration. - MCP-over-ACP types and method constants. -- `systemPrompt` on session lifecycle requests and its advertised capabilities. +- `systemPrompt` on `session/fork`. On `session/new`, `session/load` (v1), and + `session/resume` it is stable. - Turn `usage` on v1 prompt responses and usage on v2 idle state updates. - Subagent capabilities and session updates. - Additional plan representations and `plan_removed` updates. V1's existing diff --git a/schema/v1/schema.json b/schema/v1/schema.json index 86683b3e..b8e9574c 100644 --- a/schema/v1/schema.json +++ b/schema/v1/schema.json @@ -2565,6 +2565,18 @@ ], "x-deserialize-default-on-error": true }, + "systemPrompt": { + "description": "Whether the agent supports `systemPrompt` on session lifecycle requests.\n\nOptional. Omitted or `null` both mean the agent does not advertise support.\nSupplying `{}` means the agent supports `systemPrompt` in `append` mode.", + "anyOf": [ + { + "$ref": "#/$defs/SessionSystemPromptCapabilities" + }, + { + "type": "null" + } + ], + "x-deserialize-default-on-error": true + }, "resume": { "description": "Whether the agent supports `session/resume`.\n\nOptional. Omitted or `null` both mean the agent does not advertise support.\nSupplying `{}` means the agent supports resuming sessions.", "anyOf": [ @@ -2633,6 +2645,66 @@ } } }, + "SessionSystemPromptCapabilities": { + "description": "Capabilities for client-provided system prompts.\n\nSupplying `{}` means the agent supports `systemPrompt` on session lifecycle\nrequests in `append` mode.", + "type": "object", + "properties": { + "mode": { + "description": "Delivery modes the agent supports in addition to `append`.\n\nOptional. Omitted or `null` both mean the agent supports only `append`.", + "anyOf": [ + { + "$ref": "#/$defs/SessionSystemPromptModeCapabilities" + }, + { + "type": "null" + } + ], + "x-deserialize-default-on-error": true + }, + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + } + }, + "SessionSystemPromptModeCapabilities": { + "description": "System prompt delivery modes the agent supports in addition to `append`.\n\n`append` has no entry because every agent advertising\n`sessionCapabilities.systemPrompt` supports it.", + "type": "object", + "properties": { + "override": { + "description": "Whether the agent supports `override` mode.\n\nOptional. Omitted or `null` both mean the agent does not advertise support.\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", + "anyOf": [ + { + "$ref": "#/$defs/SessionSystemPromptOverrideCapabilities" + }, + { + "type": "null" + } + ], + "x-deserialize-default-on-error": true + }, + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + } + }, + "SessionSystemPromptOverrideCapabilities": { + "description": "Capabilities for the `override` system prompt mode.\n\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", + "type": "object", + "properties": { + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + } + }, "SessionResumeCapabilities": { "description": "Capabilities for the `session/resume` method.\n\nSupplying `{}` means the agent supports resuming sessions.", "type": "object", @@ -5005,6 +5077,17 @@ }, "x-deserialize-default-on-null": true }, + "systemPrompt": { + "description": "System-level instructions for the new session.\n\nOptional. Omitted and `null` are equivalent and mean the Agent uses its\nown default instructions. Clients MUST only send this when the Agent\nadvertises `sessionCapabilities.systemPrompt`.", + "anyOf": [ + { + "$ref": "#/$defs/SystemPrompt" + }, + { + "type": "null" + } + ] + }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility)", "type": ["object", "null"], @@ -5178,6 +5261,54 @@ }, "required": ["name", "command", "args", "env"] }, + "SystemPrompt": { + "description": "Client-provided system-level instructions for a session.\n\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`. Agents that cannot apply it, for example\nbecause of an unadvertised mode or an unsupported content block type, MUST\nreturn an error instead of creating, loading, or resuming the session.", + "type": "object", + "properties": { + "mode": { + "description": "How the Agent combines `content` with its own instructions.\n\nRequired. Agents MUST return an error for a mode they do not support rather than\ntreating it as `append` or `override`.", + "allOf": [ + { + "$ref": "#/$defs/SystemPromptMode" + } + ] + }, + "content": { + "description": "The system prompt content.\n\nAgents advertising the capability MUST accept `text` content blocks.\nClients MUST NOT send other content block types until a future\ncapability allows them, and Agents MUST return an error for content\nblocks they do not support.\n\nClients MUST NOT send an empty array. Agents MAY reject one with\n`-32602` without creating, loading, or resuming the session.", + "type": "array", + "items": { + "$ref": "#/$defs/ContentBlock" + } + }, + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + }, + "required": ["mode", "content"] + }, + "SystemPromptMode": { + "description": "How the Agent combines a client-provided system prompt with its own instructions.\n\nUnknown modes are preserved so they can be stored,\nproxied, or forwarded. An Agent MUST return an error for a mode it does not\nsupport rather than treating it as `append` or `override`.", + "anyOf": [ + { + "description": "Add the content to the Agent's own instructions rather than replacing them.\n\nEvery Agent that advertises `sessionCapabilities.systemPrompt` supports this mode.\nAgents SHOULD give the content system-level precedence, for example in the\nmodel's system prompt or developer instructions rather than in user-turn\ncontent. Where it is placed and how it is formatted is implementation-defined.", + "type": "string", + "const": "append" + }, + { + "description": "Replace the Agent's built-in default instructions with the content.\n\nThis does not change tool availability, MCP servers, permissions, or session\nconfiguration. Context the Agent supplies from the workspace or environment\nMAY still be included. Clients that use this mode take responsibility for any\ntool guidance or safety instructions the Agent's default instructions\nprovided, and MUST only use it when the Agent advertises\n`sessionCapabilities.systemPrompt.mode.override`.", + "type": "string", + "const": "override" + }, + { + "title": "other", + "description": "Custom or future system prompt mode.\n\nValues beginning with `_` are reserved for implementation-specific\nextensions. Unknown values that do not begin with `_` are reserved for\nfuture ACP variants.", + "type": "string" + } + ] + }, "LoadSessionRequest": { "description": "Request parameters for loading an existing session.\n\nOnly available if the Agent supports the `loadSession` capability.\n\nSee protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/v1/session-setup#loading-sessions)", "type": "object", @@ -5210,6 +5341,17 @@ } ] }, + "systemPrompt": { + "description": "System-level instructions for the loaded session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nwhen the session was created.", + "anyOf": [ + { + "$ref": "#/$defs/SystemPrompt" + }, + { + "type": "null" + } + ] + }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility)", "type": ["object", "null"], @@ -5298,6 +5440,17 @@ }, "x-deserialize-default-on-null": true }, + "systemPrompt": { + "description": "System-level instructions for the resumed session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nwhen the session was created.", + "anyOf": [ + { + "$ref": "#/$defs/SystemPrompt" + }, + { + "type": "null" + } + ] + }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility)", "type": ["object", "null"], diff --git a/schema/v1/schema.unstable.json b/schema/v1/schema.unstable.json index ef9c8ab6..6659e8d7 100644 --- a/schema/v1/schema.unstable.json +++ b/schema/v1/schema.unstable.json @@ -2762,7 +2762,7 @@ "x-deserialize-default-on-error": true }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `systemPrompt` on session lifecycle requests.\n\nOptional. Omitted or `null` both mean the agent does not advertise support.\nSupplying `{}` means the agent supports `systemPrompt` in `append` mode.", + "description": "Whether the agent supports `systemPrompt` on session lifecycle requests.\n\nOptional. Omitted or `null` both mean the agent does not advertise support.\nSupplying `{}` means the agent supports `systemPrompt` in `append` mode.", "anyOf": [ { "$ref": "#/$defs/SessionSystemPromptCapabilities" @@ -2890,7 +2890,7 @@ } }, "SessionSystemPromptCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for client-provided system prompts.\n\nSupplying `{}` means the agent supports `systemPrompt` on session lifecycle\nrequests in `append` mode.", + "description": "Capabilities for client-provided system prompts.\n\nSupplying `{}` means the agent supports `systemPrompt` on session lifecycle\nrequests in `append` mode.", "type": "object", "properties": { "mode": { @@ -2914,7 +2914,7 @@ } }, "SessionSystemPromptModeCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem prompt delivery modes the agent supports in addition to `append`.\n\n`append` has no entry because every agent advertising\n`sessionCapabilities.systemPrompt` supports it.", + "description": "System prompt delivery modes the agent supports in addition to `append`.\n\n`append` has no entry because every agent advertising\n`sessionCapabilities.systemPrompt` supports it.", "type": "object", "properties": { "override": { @@ -2938,7 +2938,7 @@ } }, "SessionSystemPromptOverrideCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for the `override` system prompt mode.\n\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", + "description": "Capabilities for the `override` system prompt mode.\n\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", "type": "object", "properties": { "_meta": { @@ -6970,7 +6970,7 @@ "x-deserialize-default-on-null": true }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem-level instructions for the new session.\n\nOptional. Omitted and `null` are equivalent and mean the Agent uses its\nown default instructions. Clients MUST only send this when the Agent\nadvertises `sessionCapabilities.systemPrompt`.", + "description": "System-level instructions for the new session.\n\nOptional. Omitted and `null` are equivalent and mean the Agent uses its\nown default instructions. Clients MUST only send this when the Agent\nadvertises `sessionCapabilities.systemPrompt`.", "anyOf": [ { "$ref": "#/$defs/SystemPrompt" @@ -7195,7 +7195,7 @@ "required": ["name", "command", "args", "env"] }, "SystemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nClient-provided system-level instructions for a session.\n\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`. Agents that cannot apply it, for example\nbecause of an unadvertised mode or an unsupported content block type, MUST\nreturn an error instead of creating, loading, resuming, or forking the\nsession.", + "description": "Client-provided system-level instructions for a session.\n\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`. Agents that cannot apply it, for example\nbecause of an unadvertised mode or an unsupported content block type, MUST\nreturn an error instead of creating, loading, or resuming the session.", "type": "object", "properties": { "mode": { @@ -7207,7 +7207,7 @@ ] }, "content": { - "description": "The system prompt content.\n\nAgents advertising the capability MUST accept `text` content blocks.\nClients MUST NOT send other content block types until a future\ncapability allows them, and Agents MUST return an error for content\nblocks they do not support.\n\nClients MUST NOT send an empty array. Agents MAY reject one with\n`-32602` without creating, loading, resuming, or forking the session.", + "description": "The system prompt content.\n\nAgents advertising the capability MUST accept `text` content blocks.\nClients MUST NOT send other content block types until a future\ncapability allows them, and Agents MUST return an error for content\nblocks they do not support.\n\nClients MUST NOT send an empty array. Agents MAY reject one with\n`-32602` without creating, loading, or resuming the session.", "type": "array", "items": { "$ref": "#/$defs/ContentBlock" @@ -7223,7 +7223,7 @@ "required": ["mode", "content"] }, "SystemPromptMode": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nHow the Agent combines a client-provided system prompt with its own instructions.\n\nUnknown modes are preserved so they can be stored,\nproxied, or forwarded. An Agent MUST return an error for a mode it does not\nsupport rather than treating it as `append` or `override`.", + "description": "How the Agent combines a client-provided system prompt with its own instructions.\n\nUnknown modes are preserved so they can be stored,\nproxied, or forwarded. An Agent MUST return an error for a mode it does not\nsupport rather than treating it as `append` or `override`.", "anyOf": [ { "description": "Add the content to the Agent's own instructions rather than replacing them.\n\nEvery Agent that advertises `sessionCapabilities.systemPrompt` supports this mode.\nAgents SHOULD give the content system-level precedence, for example in the\nmodel's system prompt or developer instructions rather than in user-turn\ncontent. Where it is placed and how it is formatted is implementation-defined.", @@ -7275,7 +7275,7 @@ ] }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem-level instructions for the loaded session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nwhen the session was created.", + "description": "System-level instructions for the loaded session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nwhen the session was created.", "anyOf": [ { "$ref": "#/$defs/SystemPrompt" @@ -7410,7 +7410,7 @@ "x-deserialize-default-on-null": true }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem-level instructions for the forked session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the source session or use its default\ninstructions. Clients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nfor the source session.", + "description": "System-level instructions for the forked session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the source session or use its default\ninstructions. Clients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nfor the source session.", "anyOf": [ { "$ref": "#/$defs/SystemPrompt" @@ -7560,7 +7560,7 @@ "x-deserialize-default-on-null": true }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem-level instructions for the resumed session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nwhen the session was created.", + "description": "System-level instructions for the resumed session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`sessionCapabilities.systemPrompt`, and SHOULD send the same value they used\nwhen the session was created.", "anyOf": [ { "$ref": "#/$defs/SystemPrompt" diff --git a/schema/v2/schema.json b/schema/v2/schema.json index 01fc80f2..b62b87ef 100644 --- a/schema/v2/schema.json +++ b/schema/v2/schema.json @@ -2959,6 +2959,18 @@ ], "x-deserialize-default-on-error": true }, + "systemPrompt": { + "description": "Whether the agent supports `systemPrompt` on session lifecycle requests.\n\nOptional. Omitted and `null` are equivalent and mean the agent does not advertise support.\nSupplying `{}` means the agent supports `systemPrompt` in `append` mode.", + "anyOf": [ + { + "$ref": "#/$defs/SessionSystemPromptCapabilities" + }, + { + "type": "null" + } + ], + "x-deserialize-default-on-error": true + }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Omitted and `null` are equivalent and mean no metadata.\nImplementations MUST NOT assign meaning to keys they do not recognize.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)", "type": ["object", "null"], @@ -3135,6 +3147,66 @@ } } }, + "SessionSystemPromptCapabilities": { + "description": "Capabilities for client-provided system prompts.\n\nSupplying `{}` means the agent supports `systemPrompt` on session lifecycle\nrequests in `append` mode.", + "type": "object", + "properties": { + "mode": { + "description": "Delivery modes the agent supports in addition to `append`.\n\nOptional. Omitted and `null` are equivalent and mean the agent supports only `append`.", + "anyOf": [ + { + "$ref": "#/$defs/SessionSystemPromptModeCapabilities" + }, + { + "type": "null" + } + ], + "x-deserialize-default-on-error": true + }, + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Omitted and `null` are equivalent and mean no metadata.\nImplementations MUST NOT assign meaning to keys they do not recognize.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + } + }, + "SessionSystemPromptModeCapabilities": { + "description": "System prompt delivery modes the agent supports in addition to `append`.\n\n`append` has no entry because every agent advertising `session.systemPrompt`\nsupports it.", + "type": "object", + "properties": { + "override": { + "description": "Whether the agent supports `override` mode.\n\nOptional. Omitted and `null` are equivalent and mean the agent does not advertise support.\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", + "anyOf": [ + { + "$ref": "#/$defs/SessionSystemPromptOverrideCapabilities" + }, + { + "type": "null" + } + ], + "x-deserialize-default-on-error": true + }, + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Omitted and `null` are equivalent and mean no metadata.\nImplementations MUST NOT assign meaning to keys they do not recognize.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + } + }, + "SessionSystemPromptOverrideCapabilities": { + "description": "Capabilities for the `override` system prompt mode.\n\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", + "type": "object", + "properties": { + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Omitted and `null` are equivalent and mean no metadata.\nImplementations MUST NOT assign meaning to keys they do not recognize.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + } + }, "AgentAuthCapabilities": { "description": "Authentication-related extension capabilities supported by the agent.\n\nThis object does not advertise support for `auth/login` or `auth/logout`.\nThose methods are advertised by a non-empty `authMethods` list in the\n`initialize` response.", "type": "object", @@ -6560,6 +6632,17 @@ }, "x-deserialize-default-on-null": true }, + "systemPrompt": { + "description": "System-level instructions for the new session.\n\nOptional. Omitted and `null` are equivalent and mean the Agent uses its\nown default instructions. Clients MUST only send this when the Agent\nadvertises `session.systemPrompt`.", + "anyOf": [ + { + "$ref": "#/$defs/SystemPrompt" + }, + { + "type": "null" + } + ] + }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Omitted and `null` are equivalent and mean no metadata.\nImplementations MUST NOT assign meaning to keys they do not recognize.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)", "type": ["object", "null"], @@ -6737,6 +6820,54 @@ }, "required": ["name", "command"] }, + "SystemPrompt": { + "description": "Client-provided system-level instructions for a session.\n\nClients MUST only send this when the Agent advertises\n`session.systemPrompt`. Agents that cannot apply it, for example because of\nan unadvertised mode or an unsupported content block type, MUST return an\nerror instead of creating or resuming the session.", + "type": "object", + "properties": { + "mode": { + "description": "How the Agent combines `content` with its own instructions.\n\nRequired. Agents MUST return an error for a mode they do not support rather than\ntreating it as `append` or `override`.", + "allOf": [ + { + "$ref": "#/$defs/SystemPromptMode" + } + ] + }, + "content": { + "description": "The system prompt content.\n\nAgents advertising the capability MUST accept `text` content blocks.\nClients MUST NOT send other content block types until a future\ncapability allows them, and Agents MUST return an error for content\nblocks they do not support, including unknown types.\n\nClients MUST NOT send an empty array. Agents MAY reject one with\n`-32602` without creating or resuming the session.", + "type": "array", + "items": { + "$ref": "#/$defs/ContentBlock" + } + }, + "_meta": { + "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Omitted and `null` are equivalent and mean no metadata.\nImplementations MUST NOT assign meaning to keys they do not recognize.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)", + "type": ["object", "null"], + "x-deserialize-default-on-error": true, + "additionalProperties": true + } + }, + "required": ["mode", "content"] + }, + "SystemPromptMode": { + "description": "How the Agent combines a client-provided system prompt with its own instructions.\n\nUnknown modes are preserved so they can be stored,\nproxied, or forwarded. An Agent MUST return an error for a mode it does not\nsupport rather than treating it as `append` or `override`.", + "anyOf": [ + { + "description": "Add the content to the Agent's own instructions rather than replacing them.\n\nEvery Agent that advertises `session.systemPrompt` supports this mode.\nAgents SHOULD give the content system-level precedence, for example in the\nmodel's system prompt or developer instructions rather than in user-turn\ncontent. Where it is placed and how it is formatted is implementation-defined.", + "type": "string", + "const": "append" + }, + { + "description": "Replace the Agent's built-in default instructions with the content.\n\nThis does not change tool availability, MCP servers, permissions, or session\nconfiguration. Context the Agent supplies from the workspace or environment\nMAY still be included. Clients that use this mode take responsibility for any\ntool guidance or safety instructions the Agent's default instructions\nprovided, and MUST only use it when the Agent advertises\n`session.systemPrompt.mode.override`.", + "type": "string", + "const": "override" + }, + { + "title": "other", + "description": "Custom or future system prompt mode.\n\nValues beginning with `_` are reserved for implementation-specific\nextensions. Unknown values that do not begin with `_` are reserved for\nfuture ACP variants.", + "type": "string" + } + ] + }, "ListSessionsRequest": { "description": "Request parameters for listing existing sessions.", "type": "object", @@ -6843,6 +6974,17 @@ } ] }, + "systemPrompt": { + "description": "System-level instructions for the resumed session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`session.systemPrompt`, and SHOULD send the same value they used when the\nsession was created.", + "anyOf": [ + { + "$ref": "#/$defs/SystemPrompt" + }, + { + "type": "null" + } + ] + }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Omitted and `null` are equivalent and mean no metadata.\nImplementations MUST NOT assign meaning to keys they do not recognize.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility)", "type": ["object", "null"], diff --git a/schema/v2/schema.unstable.json b/schema/v2/schema.unstable.json index db7762f1..76c1915d 100644 --- a/schema/v2/schema.unstable.json +++ b/schema/v2/schema.unstable.json @@ -3148,7 +3148,7 @@ "x-deserialize-default-on-error": true }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `systemPrompt` on session lifecycle requests.\n\nOptional. Omitted and `null` are equivalent and mean the agent does not advertise support.\nSupplying `{}` means the agent supports `systemPrompt` in `append` mode.", + "description": "Whether the agent supports `systemPrompt` on session lifecycle requests.\n\nOptional. Omitted and `null` are equivalent and mean the agent does not advertise support.\nSupplying `{}` means the agent supports `systemPrompt` in `append` mode.", "anyOf": [ { "$ref": "#/$defs/SessionSystemPromptCapabilities" @@ -3408,7 +3408,7 @@ } }, "SessionSystemPromptCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for client-provided system prompts.\n\nSupplying `{}` means the agent supports `systemPrompt` on session lifecycle\nrequests in `append` mode.", + "description": "Capabilities for client-provided system prompts.\n\nSupplying `{}` means the agent supports `systemPrompt` on session lifecycle\nrequests in `append` mode.", "type": "object", "properties": { "mode": { @@ -3432,7 +3432,7 @@ } }, "SessionSystemPromptModeCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem prompt delivery modes the agent supports in addition to `append`.\n\n`append` has no entry because every agent advertising `session.systemPrompt`\nsupports it.", + "description": "System prompt delivery modes the agent supports in addition to `append`.\n\n`append` has no entry because every agent advertising `session.systemPrompt`\nsupports it.", "type": "object", "properties": { "override": { @@ -3456,7 +3456,7 @@ } }, "SessionSystemPromptOverrideCapabilities": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for the `override` system prompt mode.\n\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", + "description": "Capabilities for the `override` system prompt mode.\n\nSupplying `{}` means the agent supports replacing its built-in default\ninstructions with the client-provided system prompt.", "type": "object", "properties": { "_meta": { @@ -8201,7 +8201,7 @@ "x-deserialize-default-on-null": true }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem-level instructions for the new session.\n\nOptional. Omitted and `null` are equivalent and mean the Agent uses its\nown default instructions. Clients MUST only send this when the Agent\nadvertises `session.systemPrompt`.", + "description": "System-level instructions for the new session.\n\nOptional. Omitted and `null` are equivalent and mean the Agent uses its\nown default instructions. Clients MUST only send this when the Agent\nadvertises `session.systemPrompt`.", "anyOf": [ { "$ref": "#/$defs/SystemPrompt" @@ -8440,7 +8440,7 @@ "required": ["name", "command"] }, "SystemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nClient-provided system-level instructions for a session.\n\nClients MUST only send this when the Agent advertises\n`session.systemPrompt`. Agents that cannot apply it, for example because of\nan unadvertised mode or an unsupported content block type, MUST return an\nerror instead of creating, resuming, or forking the session.", + "description": "Client-provided system-level instructions for a session.\n\nClients MUST only send this when the Agent advertises\n`session.systemPrompt`. Agents that cannot apply it, for example because of\nan unadvertised mode or an unsupported content block type, MUST return an\nerror instead of creating or resuming the session.", "type": "object", "properties": { "mode": { @@ -8452,7 +8452,7 @@ ] }, "content": { - "description": "The system prompt content.\n\nAgents advertising the capability MUST accept `text` content blocks.\nClients MUST NOT send other content block types until a future\ncapability allows them, and Agents MUST return an error for content\nblocks they do not support, including unknown types.\n\nClients MUST NOT send an empty array. Agents MAY reject one with\n`-32602` without creating, resuming, or forking the session.", + "description": "The system prompt content.\n\nAgents advertising the capability MUST accept `text` content blocks.\nClients MUST NOT send other content block types until a future\ncapability allows them, and Agents MUST return an error for content\nblocks they do not support, including unknown types.\n\nClients MUST NOT send an empty array. Agents MAY reject one with\n`-32602` without creating or resuming the session.", "type": "array", "items": { "$ref": "#/$defs/ContentBlock" @@ -8468,7 +8468,7 @@ "required": ["mode", "content"] }, "SystemPromptMode": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nHow the Agent combines a client-provided system prompt with its own instructions.\n\nUnknown modes are preserved so they can be stored,\nproxied, or forwarded. An Agent MUST return an error for a mode it does not\nsupport rather than treating it as `append` or `override`.", + "description": "How the Agent combines a client-provided system prompt with its own instructions.\n\nUnknown modes are preserved so they can be stored,\nproxied, or forwarded. An Agent MUST return an error for a mode it does not\nsupport rather than treating it as `append` or `override`.", "anyOf": [ { "description": "Add the content to the Agent's own instructions rather than replacing them.\n\nEvery Agent that advertises `session.systemPrompt` supports this mode.\nAgents SHOULD give the content system-level precedence, for example in the\nmodel's system prompt or developer instructions rather than in user-turn\ncontent. Where it is placed and how it is formatted is implementation-defined.", @@ -8619,7 +8619,7 @@ "x-deserialize-default-on-null": true }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem-level instructions for the forked session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the source session or use its default\ninstructions. Clients MUST only send this when the Agent advertises\n`session.systemPrompt`, and SHOULD send the same value they used for the\nsource session.", + "description": "System-level instructions for the forked session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the source session or use its default\ninstructions. Clients MUST only send this when the Agent advertises\n`session.systemPrompt`, and SHOULD send the same value they used for the\nsource session.", "anyOf": [ { "$ref": "#/$defs/SystemPrompt" @@ -8784,7 +8784,7 @@ ] }, "systemPrompt": { - "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nSystem-level instructions for the resumed session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`session.systemPrompt`, and SHOULD send the same value they used when the\nsession was created.", + "description": "System-level instructions for the resumed session.\n\nOptional. Omitted and `null` are equivalent. The Agent may then keep a\nsystem prompt it stored with the session or use its default instructions.\nClients MUST only send this when the Agent advertises\n`session.systemPrompt`, and SHOULD send the same value they used when the\nsession was created.", "anyOf": [ { "$ref": "#/$defs/SystemPrompt" diff --git a/scripts/generate.js b/scripts/generate.js index 9b46e9b5..0bfbfa43 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -12,8 +12,8 @@ import * as prettier from "prettier"; import ts from "typescript"; import { generateBindings } from "./generate-bindings.js"; -const CURRENT_V1_SCHEMA_RELEASE = "schema-v1.29.1"; -const CURRENT_V2_SCHEMA_RELEASE = "schema-v2.0.0-alpha.13"; +const CURRENT_V1_SCHEMA_RELEASE = "schema-v1.30.0"; +const CURRENT_V2_SCHEMA_RELEASE = "schema-v2.0.0-alpha.14"; const CHECK_GENERATED = process.argv.includes("--check"); // ── Extensible-union pipeline ──────────────────────────────────────────────── diff --git a/src/v1/acp.test.ts b/src/v1/acp.test.ts index 17bbc743..353df364 100644 --- a/src/v1/acp.test.ts +++ b/src/v1/acp.test.ts @@ -5593,6 +5593,60 @@ describe("Schema deserialization compatibility", () => { ).toBe(false); }); + it("validates stable systemPrompt on session lifecycle requests", () => { + const systemPrompt = { + mode: "append", + content: [{ type: "text", text: "Review without editing." }], + }; + const cases = [ + [stableZod.zNewSessionRequest, { cwd: "/repo", mcpServers: [] }], + [ + stableZod.zLoadSessionRequest, + { cwd: "/repo", mcpServers: [], sessionId: "session-1" }, + ], + [stableZod.zResumeSessionRequest, { cwd: "/repo", sessionId: "s-1" }], + ] as const; + for (const [validator, base] of cases) { + expect(validator.parse({ ...base, systemPrompt }).systemPrompt).toEqual( + systemPrompt, + ); + // Omitted and null are equivalent. + expect( + validator.parse({ ...base, systemPrompt: null }).systemPrompt, + ).toBeNull(); + // The receiver acts on the prompt, so malformed values fail the request + // instead of creating a session without it. + for (const malformed of [ + "instructions", + { content: [] }, + { mode: "append", content: [{ type: "text" }] }, + ]) { + expect( + validator.safeParse({ ...base, systemPrompt: malformed }).success, + ).toBe(false); + } + } + // Unknown modes are preserved so the Agent can reject them. + expect( + stableZod.zNewSessionRequest.parse({ + cwd: "/repo", + mcpServers: [], + systemPrompt: { ...systemPrompt, mode: "_vendor_mode" }, + }).systemPrompt?.mode, + ).toBe("_vendor_mode"); + + expect( + stableZod.zSessionCapabilities.parse({ + systemPrompt: { mode: { override: {} } }, + }).systemPrompt, + ).toEqual({ mode: { override: {} } }); + // A malformed capability means the Agent does not advertise support. + expect( + stableZod.zSessionCapabilities.parse({ systemPrompt: "yes" }) + .systemPrompt, + ).toBeUndefined(); + }); + it("skips invalid nested tool call content and locations", () => { const toolCall = zToolCall.parse({ content: [ diff --git a/src/v1/schema/index.ts b/src/v1/schema/index.ts index 974d68c5..499adb12 100644 --- a/src/v1/schema/index.ts +++ b/src/v1/schema/index.ts @@ -149,6 +149,9 @@ export type { SessionModeState, SessionNotification, SessionResumeCapabilities, + SessionSystemPromptCapabilities, + SessionSystemPromptModeCapabilities, + SessionSystemPromptOverrideCapabilities, SessionUpdate, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, @@ -158,6 +161,8 @@ export type { StringFormat, StringMultiSelectItems, StringPropertySchema, + SystemPrompt, + SystemPromptMode, Terminal, TerminalExitStatus, TerminalId, diff --git a/src/v1/schema/types.gen.ts b/src/v1/schema/types.gen.ts index 3d096be4..9272f434 100644 --- a/src/v1/schema/types.gen.ts +++ b/src/v1/schema/types.gen.ts @@ -1660,6 +1660,13 @@ export type SessionCapabilities = { * additional-root list associated with a listed session. */ additionalDirectories?: SessionAdditionalDirectoriesCapabilities | null; + /** + * Whether the agent supports `systemPrompt` on session lifecycle requests. + * + * Optional. Omitted or `null` both mean the agent does not advertise support. + * Supplying `{}` means the agent supports `systemPrompt` in `append` mode. + */ + systemPrompt?: SessionSystemPromptCapabilities | null; /** * Whether the agent supports `session/resume`. * @@ -1743,6 +1750,77 @@ export type SessionAdditionalDirectoriesCapabilities = { } | null; }; +/** + * Capabilities for client-provided system prompts. + * + * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle + * requests in `append` mode. + */ +export type SessionSystemPromptCapabilities = { + /** + * Delivery modes the agent supports in addition to `append`. + * + * Optional. Omitted or `null` both mean the agent supports only `append`. + */ + mode?: SessionSystemPromptModeCapabilities | null; + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Implementations MUST NOT make assumptions about values at + * these keys. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + +/** + * System prompt delivery modes the agent supports in addition to `append`. + * + * `append` has no entry because every agent advertising + * `sessionCapabilities.systemPrompt` supports it. + */ +export type SessionSystemPromptModeCapabilities = { + /** + * Whether the agent supports `override` mode. + * + * Optional. Omitted or `null` both mean the agent does not advertise support. + * Supplying `{}` means the agent supports replacing its built-in default + * instructions with the client-provided system prompt. + */ + override?: SessionSystemPromptOverrideCapabilities | null; + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Implementations MUST NOT make assumptions about values at + * these keys. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + +/** + * Capabilities for the `override` system prompt mode. + * + * Supplying `{}` means the agent supports replacing its built-in default + * instructions with the client-provided system prompt. + */ +export type SessionSystemPromptOverrideCapabilities = { + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Implementations MUST NOT make assumptions about values at + * these keys. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + /** * Capabilities for the `session/resume` method. * @@ -3500,6 +3578,14 @@ export type NewSessionRequest = { * List of MCP (Model Context Protocol) servers the agent should connect to. */ mcpServers: Array; + /** + * System-level instructions for the new session. + * + * Optional. Omitted and `null` are equivalent and mean the Agent uses its + * own default instructions. Clients MUST only send this when the Agent + * advertises `sessionCapabilities.systemPrompt`. + */ + systemPrompt?: SystemPrompt | null; /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Implementations MUST NOT make assumptions about values at @@ -3641,6 +3727,55 @@ export type McpServerStdio = { } | null; }; +/** + * Client-provided system-level instructions for a session. + * + * Clients MUST only send this when the Agent advertises + * `sessionCapabilities.systemPrompt`. Agents that cannot apply it, for example + * because of an unadvertised mode or an unsupported content block type, MUST + * return an error instead of creating, loading, or resuming the session. + */ +export type SystemPrompt = { + /** + * How the Agent combines `content` with its own instructions. + * + * Required. Agents MUST return an error for a mode they do not support rather than + * treating it as `append` or `override`. + */ + mode: SystemPromptMode; + /** + * The system prompt content. + * + * Agents advertising the capability MUST accept `text` content blocks. + * Clients MUST NOT send other content block types until a future + * capability allows them, and Agents MUST return an error for content + * blocks they do not support. + * + * Clients MUST NOT send an empty array. Agents MAY reject one with + * `-32602` without creating, loading, or resuming the session. + */ + content: Array; + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Implementations MUST NOT make assumptions about values at + * these keys. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v1/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + +/** + * How the Agent combines a client-provided system prompt with its own instructions. + * + * Unknown modes are preserved so they can be stored, + * proxied, or forwarded. An Agent MUST return an error for a mode it does not + * support rather than treating it as `append` or `override`. + */ +export type SystemPromptMode = "append" | "override" | string; + /** * Request parameters for loading an existing session. * @@ -3670,6 +3805,16 @@ export type LoadSessionRequest = { * The ID of the session to load. */ sessionId: SessionId; + /** + * System-level instructions for the loaded session. + * + * Optional. Omitted and `null` are equivalent. The Agent may then keep a + * system prompt it stored with the session or use its default instructions. + * Clients MUST only send this when the Agent advertises + * `sessionCapabilities.systemPrompt`, and SHOULD send the same value they used + * when the session was created. + */ + systemPrompt?: SystemPrompt | null; /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Implementations MUST NOT make assumptions about values at @@ -3760,6 +3905,16 @@ export type ResumeSessionRequest = { * List of MCP servers to connect to for this session. */ mcpServers?: Array; + /** + * System-level instructions for the resumed session. + * + * Optional. Omitted and `null` are equivalent. The Agent may then keep a + * system prompt it stored with the session or use its default instructions. + * Clients MUST only send this when the Agent advertises + * `sessionCapabilities.systemPrompt`, and SHOULD send the same value they used + * when the session was created. + */ + systemPrompt?: SystemPrompt | null; /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Implementations MUST NOT make assumptions about values at diff --git a/src/v1/schema/zod.gen.ts b/src/v1/schema/zod.gen.ts index d13fe69f..b2de517d 100644 --- a/src/v1/schema/zod.gen.ts +++ b/src/v1/schema/zod.gen.ts @@ -997,6 +997,53 @@ export const zSessionAdditionalDirectoriesCapabilities = z.object({ ), }); +/** + * Capabilities for the `override` system prompt mode. + * + * Supplying `{}` means the agent supports replacing its built-in default + * instructions with the client-provided system prompt. + */ +export const zSessionSystemPromptOverrideCapabilities = z.object({ + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + +/** + * System prompt delivery modes the agent supports in addition to `append`. + * + * `append` has no entry because every agent advertising + * `sessionCapabilities.systemPrompt` supports it. + */ +export const zSessionSystemPromptModeCapabilities = z.object({ + override: defaultOnError( + zSessionSystemPromptOverrideCapabilities.nullish(), + () => undefined, + ), + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + +/** + * Capabilities for client-provided system prompts. + * + * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle + * requests in `append` mode. + */ +export const zSessionSystemPromptCapabilities = z.object({ + mode: defaultOnError( + zSessionSystemPromptModeCapabilities.nullish(), + () => undefined, + ), + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + /** * Capabilities for the `session/resume` method. * @@ -1039,6 +1086,10 @@ export const zSessionCapabilities = z.object({ zSessionAdditionalDirectoriesCapabilities.nullish(), () => undefined, ), + systemPrompt: defaultOnError( + zSessionSystemPromptCapabilities.nullish(), + () => undefined, + ), resume: defaultOnError(zSessionResumeCapabilities.nullish(), () => undefined), close: defaultOnError(zSessionCloseCapabilities.nullish(), () => undefined), _meta: defaultOnError( @@ -2346,6 +2397,36 @@ export const zMcpServer = z.union([ zMcpServerStdio, ]); +/** + * How the Agent combines a client-provided system prompt with its own instructions. + * + * Unknown modes are preserved so they can be stored, + * proxied, or forwarded. An Agent MUST return an error for a mode it does not + * support rather than treating it as `append` or `override`. + */ +export const zSystemPromptMode = z.union([ + z.literal("append"), + z.literal("override"), + z.string(), +]); + +/** + * Client-provided system-level instructions for a session. + * + * Clients MUST only send this when the Agent advertises + * `sessionCapabilities.systemPrompt`. Agents that cannot apply it, for example + * because of an unadvertised mode or an unsupported content block type, MUST + * return an error instead of creating, loading, or resuming the session. + */ +export const zSystemPrompt = z.object({ + mode: zSystemPromptMode, + content: z.array(zContentBlock), + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + /** * Request parameters for creating a new session. * @@ -2358,6 +2439,7 @@ export const zNewSessionRequest = z.object({ () => [], ).optional(), mcpServers: defaultOnNull(z.array(zMcpServer), () => []), + systemPrompt: zSystemPrompt.nullish(), _meta: defaultOnError( z.record(z.string(), z.unknown()).nullish(), () => undefined, @@ -2379,6 +2461,7 @@ export const zLoadSessionRequest = z.object({ () => [], ).optional(), sessionId: zSessionId, + systemPrompt: zSystemPrompt.nullish(), _meta: defaultOnError( z.record(z.string(), z.unknown()).nullish(), () => undefined, @@ -2428,6 +2511,7 @@ export const zResumeSessionRequest = z.object({ () => [], ).optional(), mcpServers: defaultOnNull(z.array(zMcpServer), () => []).optional(), + systemPrompt: zSystemPrompt.nullish(), _meta: defaultOnError( z.record(z.string(), z.unknown()).nullish(), () => undefined, diff --git a/src/v1/unstable/schema/types.gen.ts b/src/v1/unstable/schema/types.gen.ts index 54551c36..467f6545 100644 --- a/src/v1/unstable/schema/types.gen.ts +++ b/src/v1/unstable/schema/types.gen.ts @@ -1764,16 +1764,10 @@ export type SessionCapabilities = { */ additionalDirectories?: SessionAdditionalDirectoriesCapabilities | null; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Whether the agent supports `systemPrompt` on session lifecycle requests. * * Optional. Omitted or `null` both mean the agent does not advertise support. * Supplying `{}` means the agent supports `systemPrompt` in `append` mode. - * - * @experimental */ systemPrompt?: SessionSystemPromptCapabilities | null; /** @@ -1916,16 +1910,10 @@ export type SessionAdditionalDirectoriesCapabilities = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for client-provided system prompts. * * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle * requests in `append` mode. - * - * @experimental */ export type SessionSystemPromptCapabilities = { /** @@ -1947,16 +1935,10 @@ export type SessionSystemPromptCapabilities = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System prompt delivery modes the agent supports in addition to `append`. * * `append` has no entry because every agent advertising * `sessionCapabilities.systemPrompt` supports it. - * - * @experimental */ export type SessionSystemPromptModeCapabilities = { /** @@ -1980,16 +1962,10 @@ export type SessionSystemPromptModeCapabilities = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for the `override` system prompt mode. * * Supplying `{}` means the agent supports replacing its built-in default * instructions with the client-provided system prompt. - * - * @experimental */ export type SessionSystemPromptOverrideCapabilities = { /** @@ -5261,17 +5237,11 @@ export type NewSessionRequest = { */ mcpServers: Array; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System-level instructions for the new session. * * Optional. Omitted and `null` are equivalent and mean the Agent uses its * own default instructions. Clients MUST only send this when the Agent * advertises `sessionCapabilities.systemPrompt`. - * - * @experimental */ systemPrompt?: SystemPrompt | null; /** @@ -5455,19 +5425,12 @@ export type McpServerStdio = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Client-provided system-level instructions for a session. * * Clients MUST only send this when the Agent advertises * `sessionCapabilities.systemPrompt`. Agents that cannot apply it, for example * because of an unadvertised mode or an unsupported content block type, MUST - * return an error instead of creating, loading, resuming, or forking the - * session. - * - * @experimental + * return an error instead of creating, loading, or resuming the session. */ export type SystemPrompt = { /** @@ -5486,7 +5449,7 @@ export type SystemPrompt = { * blocks they do not support. * * Clients MUST NOT send an empty array. Agents MAY reject one with - * `-32602` without creating, loading, resuming, or forking the session. + * `-32602` without creating, loading, or resuming the session. */ content: Array; /** @@ -5502,17 +5465,11 @@ export type SystemPrompt = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * How the Agent combines a client-provided system prompt with its own instructions. * * Unknown modes are preserved so they can be stored, * proxied, or forwarded. An Agent MUST return an error for a mode it does not * support rather than treating it as `append` or `override`. - * - * @experimental */ export type SystemPromptMode = "append" | "override" | string; @@ -5546,10 +5503,6 @@ export type LoadSessionRequest = { */ sessionId: SessionId; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System-level instructions for the loaded session. * * Optional. Omitted and `null` are equivalent. The Agent may then keep a @@ -5557,8 +5510,6 @@ export type LoadSessionRequest = { * Clients MUST only send this when the Agent advertises * `sessionCapabilities.systemPrompt`, and SHOULD send the same value they used * when the session was created. - * - * @experimental */ systemPrompt?: SystemPrompt | null; /** @@ -5685,10 +5636,6 @@ export type ForkSessionRequest = { */ mcpServers?: Array; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System-level instructions for the forked session. * * Optional. Omitted and `null` are equivalent. The Agent may then keep a @@ -5696,8 +5643,6 @@ export type ForkSessionRequest = { * instructions. Clients MUST only send this when the Agent advertises * `sessionCapabilities.systemPrompt`, and SHOULD send the same value they used * for the source session. - * - * @experimental */ systemPrompt?: SystemPrompt | null; /** @@ -5885,10 +5830,6 @@ export type ResumeSessionRequest = { */ mcpServers?: Array; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System-level instructions for the resumed session. * * Optional. Omitted and `null` are equivalent. The Agent may then keep a @@ -5896,8 +5837,6 @@ export type ResumeSessionRequest = { * Clients MUST only send this when the Agent advertises * `sessionCapabilities.systemPrompt`, and SHOULD send the same value they used * when the session was created. - * - * @experimental */ systemPrompt?: SystemPrompt | null; /** diff --git a/src/v1/unstable/schema/zod.gen.ts b/src/v1/unstable/schema/zod.gen.ts index 014256ea..88ead184 100644 --- a/src/v1/unstable/schema/zod.gen.ts +++ b/src/v1/unstable/schema/zod.gen.ts @@ -1052,16 +1052,10 @@ export const zSessionAdditionalDirectoriesCapabilities = z.object({ }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for the `override` system prompt mode. * * Supplying `{}` means the agent supports replacing its built-in default * instructions with the client-provided system prompt. - * - * @experimental */ export const zSessionSystemPromptOverrideCapabilities = z.object({ _meta: defaultOnError( @@ -1071,16 +1065,10 @@ export const zSessionSystemPromptOverrideCapabilities = z.object({ }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System prompt delivery modes the agent supports in addition to `append`. * * `append` has no entry because every agent advertising * `sessionCapabilities.systemPrompt` supports it. - * - * @experimental */ export const zSessionSystemPromptModeCapabilities = z.object({ override: defaultOnError( @@ -1094,16 +1082,10 @@ export const zSessionSystemPromptModeCapabilities = z.object({ }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for client-provided system prompts. * * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle * requests in `append` mode. - * - * @experimental */ export const zSessionSystemPromptCapabilities = z.object({ mode: defaultOnError( @@ -3555,17 +3537,11 @@ export const zMcpServer = z.union([ ]); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * How the Agent combines a client-provided system prompt with its own instructions. * * Unknown modes are preserved so they can be stored, * proxied, or forwarded. An Agent MUST return an error for a mode it does not * support rather than treating it as `append` or `override`. - * - * @experimental */ export const zSystemPromptMode = z.union([ z.literal("append"), @@ -3574,19 +3550,12 @@ export const zSystemPromptMode = z.union([ ]); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Client-provided system-level instructions for a session. * * Clients MUST only send this when the Agent advertises * `sessionCapabilities.systemPrompt`. Agents that cannot apply it, for example * because of an unadvertised mode or an unsupported content block type, MUST - * return an error instead of creating, loading, resuming, or forking the - * session. - * - * @experimental + * return an error instead of creating, loading, or resuming the session. */ export const zSystemPrompt = z.object({ mode: zSystemPromptMode, diff --git a/src/v2/acp.test.ts b/src/v2/acp.test.ts index 53770a27..78edee82 100644 --- a/src/v2/acp.test.ts +++ b/src/v2/acp.test.ts @@ -300,6 +300,55 @@ describe("v2 schema parsing matches the Rust schema crate", () => { }); }); + it("validates stable systemPrompt on session lifecycle requests", () => { + const systemPrompt = { + mode: "append", + content: [{ type: "text", text: "Review without editing." }], + }; + const cases = [ + [stableZod.zNewSessionRequest, { cwd: "/repo" }], + [stableZod.zResumeSessionRequest, { cwd: "/repo", sessionId: "s-1" }], + ] as const; + for (const [validator, base] of cases) { + expect(validator.parse({ ...base, systemPrompt }).systemPrompt).toEqual( + systemPrompt, + ); + // Omitted and null are equivalent. + expect( + validator.parse({ ...base, systemPrompt: null }).systemPrompt, + ).toBeNull(); + // The receiver acts on the prompt, so malformed values fail the request + // instead of creating a session without it. + for (const malformed of [ + "instructions", + { content: [] }, + { mode: "append", content: [{ type: "text" }] }, + ]) { + expect( + validator.safeParse({ ...base, systemPrompt: malformed }).success, + ).toBe(false); + } + } + // Unknown modes are preserved so the Agent can reject them. + expect( + stableZod.zNewSessionRequest.parse({ + cwd: "/repo", + systemPrompt: { ...systemPrompt, mode: "_vendor_mode" }, + }).systemPrompt?.mode, + ).toBe("_vendor_mode"); + + expect( + stableZod.zSessionCapabilities.parse({ + systemPrompt: { mode: { override: {} } }, + }).systemPrompt, + ).toEqual({ mode: { override: {} } }); + // A malformed capability means the Agent does not advertise support. + expect( + stableZod.zSessionCapabilities.parse({ systemPrompt: "yes" }) + .systemPrompt, + ).toBeUndefined(); + }); + it("validates unstable u64 usage counters", () => { const usage = { totalTokens: 3, inputTokens: 1, outputTokens: 2 }; expect(unstableZod.zUsage.safeParse(usage).success).toBe(true); diff --git a/src/v2/acp.ts b/src/v2/acp.ts index b876d12b..9926007a 100644 --- a/src/v2/acp.ts +++ b/src/v2/acp.ts @@ -24,11 +24,10 @@ * snapshots, and `plan_update` is not an entity patch. * * Experimental operations follow their advertised capabilities; local schema - * selection does not establish peer support. When opting into unstable - * lifecycle `systemPrompt` instructions, only send them when the agent - * advertises `session.systemPrompt`, only use `override` when its - * `mode.override` capability is advertised, and never send an empty - * `content` array. + * selection does not establish peer support. Only send lifecycle + * `systemPrompt` instructions when the agent advertises + * `session.systemPrompt`, only use `override` when its `mode.override` + * capability is advertised, and never send an empty `content` array. * * @packageDocumentation * @experimental @@ -1856,6 +1855,12 @@ export class ActiveSession { * `canCancelToolCall`). The response means the Agent accepted the * cancellation, not that the work stopped. The Agent confirms it with a * `tool_call_update` to a final status. + * + * This only covers tool calls reported in this session. A subagent's tool + * call is reported in its child session, so send + * `methods.agent.toolCall.cancel` through `ClientContext.request` with the + * child's `sessionId`. The tool call's own `capabilities.cancel` enables + * that even when the child session doesn't advertise `cancel`. */ cancelToolCall( toolCallId: schema.ToolCallId, @@ -1883,6 +1888,12 @@ export class ActiveSession { * `canCancelTerminal`). The response means the Agent accepted the * cancellation, not that the process stopped. The Agent confirms it with a * `terminal_update` that sets `exitStatus`. The terminal is not released. + * + * This only covers terminals reported in this session. A subagent's + * terminal is reported in its child session, so send + * `methods.agent.terminal.cancel` through `ClientContext.request` with the + * child's `sessionId`. The terminal's own `capabilities.cancel` enables + * that even when the child session doesn't advertise `cancel`. */ cancelTerminal( terminalId: schema.TerminalId, diff --git a/src/v2/schema/index.ts b/src/v2/schema/index.ts index 6e36c699..c973316b 100644 --- a/src/v2/schema/index.ts +++ b/src/v2/schema/index.ts @@ -163,6 +163,9 @@ export type { SessionInfoUpdate, SessionListCursor, SessionNotFoundErrorData, + SessionSystemPromptCapabilities, + SessionSystemPromptModeCapabilities, + SessionSystemPromptOverrideCapabilities, SessionUpdate, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, @@ -170,6 +173,8 @@ export type { StringFormat, StringMultiSelectItems, StringPropertySchema, + SystemPrompt, + SystemPromptMode, Terminal, TerminalAuthCapabilities, TerminalCancelCapabilities, diff --git a/src/v2/schema/types.gen.ts b/src/v2/schema/types.gen.ts index c671ecda..8062b428 100644 --- a/src/v2/schema/types.gen.ts +++ b/src/v2/schema/types.gen.ts @@ -1928,6 +1928,13 @@ export type SessionCapabilities = { * complete ordered additional-root list associated with a listed session. */ additionalDirectories?: SessionAdditionalDirectoriesCapabilities | null; + /** + * Whether the agent supports `systemPrompt` on session lifecycle requests. + * + * Optional. Omitted and `null` are equivalent and mean the agent does not advertise support. + * Supplying `{}` means the agent supports `systemPrompt` in `append` mode. + */ + systemPrompt?: SessionSystemPromptCapabilities | null; /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Omitted and `null` are equivalent and mean no metadata. @@ -2150,6 +2157,77 @@ export type SessionAdditionalDirectoriesCapabilities = { } | null; }; +/** + * Capabilities for client-provided system prompts. + * + * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle + * requests in `append` mode. + */ +export type SessionSystemPromptCapabilities = { + /** + * Delivery modes the agent supports in addition to `append`. + * + * Optional. Omitted and `null` are equivalent and mean the agent supports only `append`. + */ + mode?: SessionSystemPromptModeCapabilities | null; + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Omitted and `null` are equivalent and mean no metadata. + * Implementations MUST NOT assign meaning to keys they do not recognize. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + +/** + * System prompt delivery modes the agent supports in addition to `append`. + * + * `append` has no entry because every agent advertising `session.systemPrompt` + * supports it. + */ +export type SessionSystemPromptModeCapabilities = { + /** + * Whether the agent supports `override` mode. + * + * Optional. Omitted and `null` are equivalent and mean the agent does not advertise support. + * Supplying `{}` means the agent supports replacing its built-in default + * instructions with the client-provided system prompt. + */ + override?: SessionSystemPromptOverrideCapabilities | null; + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Omitted and `null` are equivalent and mean no metadata. + * Implementations MUST NOT assign meaning to keys they do not recognize. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + +/** + * Capabilities for the `override` system prompt mode. + * + * Supplying `{}` means the agent supports replacing its built-in default + * instructions with the client-provided system prompt. + */ +export type SessionSystemPromptOverrideCapabilities = { + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Omitted and `null` are equivalent and mean no metadata. + * Implementations MUST NOT assign meaning to keys they do not recognize. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + /** * Authentication-related extension capabilities supported by the agent. * @@ -4631,6 +4709,14 @@ export type NewSessionRequest = { * List of MCP (Model Context Protocol) servers the agent should connect to. */ mcpServers?: Array; + /** + * System-level instructions for the new session. + * + * Optional. Omitted and `null` are equivalent and mean the Agent uses its + * own default instructions. Clients MUST only send this when the Agent + * advertises `session.systemPrompt`. + */ + systemPrompt?: SystemPrompt | null; /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Omitted and `null` are equivalent and mean no metadata. @@ -4769,6 +4855,55 @@ export type McpServerStdio = { } | null; }; +/** + * Client-provided system-level instructions for a session. + * + * Clients MUST only send this when the Agent advertises + * `session.systemPrompt`. Agents that cannot apply it, for example because of + * an unadvertised mode or an unsupported content block type, MUST return an + * error instead of creating or resuming the session. + */ +export type SystemPrompt = { + /** + * How the Agent combines `content` with its own instructions. + * + * Required. Agents MUST return an error for a mode they do not support rather than + * treating it as `append` or `override`. + */ + mode: SystemPromptMode; + /** + * The system prompt content. + * + * Agents advertising the capability MUST accept `text` content blocks. + * Clients MUST NOT send other content block types until a future + * capability allows them, and Agents MUST return an error for content + * blocks they do not support, including unknown types. + * + * Clients MUST NOT send an empty array. Agents MAY reject one with + * `-32602` without creating or resuming the session. + */ + content: Array; + /** + * The _meta property is reserved by ACP to allow clients and agents to attach additional + * metadata to their interactions. Omitted and `null` are equivalent and mean no metadata. + * Implementations MUST NOT assign meaning to keys they do not recognize. + * + * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) + */ + _meta?: { + [key: string]: unknown; + } | null; +}; + +/** + * How the Agent combines a client-provided system prompt with its own instructions. + * + * Unknown modes are preserved so they can be stored, + * proxied, or forwarded. An Agent MUST return an error for a mode it does not + * support rather than treating it as `append` or `override`. + */ +export type SystemPromptMode = "append" | "override" | string; + /** * Request parameters for listing existing sessions. */ @@ -4870,6 +5005,16 @@ export type ResumeSessionRequest = { * or resuming without replay. */ replayFrom?: ReplayFrom | null; + /** + * System-level instructions for the resumed session. + * + * Optional. Omitted and `null` are equivalent. The Agent may then keep a + * system prompt it stored with the session or use its default instructions. + * Clients MUST only send this when the Agent advertises + * `session.systemPrompt`, and SHOULD send the same value they used when the + * session was created. + */ + systemPrompt?: SystemPrompt | null; /** * The _meta property is reserved by ACP to allow clients and agents to attach additional * metadata to their interactions. Omitted and `null` are equivalent and mean no metadata. diff --git a/src/v2/schema/zod.gen.ts b/src/v2/schema/zod.gen.ts index 14c9c08e..d8836bfc 100644 --- a/src/v2/schema/zod.gen.ts +++ b/src/v2/schema/zod.gen.ts @@ -1213,6 +1213,53 @@ export const zSessionAdditionalDirectoriesCapabilities = z.object({ ), }); +/** + * Capabilities for the `override` system prompt mode. + * + * Supplying `{}` means the agent supports replacing its built-in default + * instructions with the client-provided system prompt. + */ +export const zSessionSystemPromptOverrideCapabilities = z.object({ + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + +/** + * System prompt delivery modes the agent supports in addition to `append`. + * + * `append` has no entry because every agent advertising `session.systemPrompt` + * supports it. + */ +export const zSessionSystemPromptModeCapabilities = z.object({ + override: defaultOnError( + zSessionSystemPromptOverrideCapabilities.nullish(), + () => undefined, + ), + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + +/** + * Capabilities for client-provided system prompts. + * + * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle + * requests in `append` mode. + */ +export const zSessionSystemPromptCapabilities = z.object({ + mode: defaultOnError( + zSessionSystemPromptModeCapabilities.nullish(), + () => undefined, + ), + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + /** * Session capabilities supported by the agent. * @@ -1234,6 +1281,10 @@ export const zSessionCapabilities = z.object({ zSessionAdditionalDirectoriesCapabilities.nullish(), () => undefined, ), + systemPrompt: defaultOnError( + zSessionSystemPromptCapabilities.nullish(), + () => undefined, + ), _meta: defaultOnError( z.record(z.string(), z.unknown()).nullish(), () => undefined, @@ -3049,6 +3100,36 @@ export const zMcpServer = preserveCustomPayload( ["http", "stdio"], ); +/** + * How the Agent combines a client-provided system prompt with its own instructions. + * + * Unknown modes are preserved so they can be stored, + * proxied, or forwarded. An Agent MUST return an error for a mode it does not + * support rather than treating it as `append` or `override`. + */ +export const zSystemPromptMode = z.union([ + z.literal("append"), + z.literal("override"), + z.string(), +]); + +/** + * Client-provided system-level instructions for a session. + * + * Clients MUST only send this when the Agent advertises + * `session.systemPrompt`. Agents that cannot apply it, for example because of + * an unadvertised mode or an unsupported content block type, MUST return an + * error instead of creating or resuming the session. + */ +export const zSystemPrompt = z.object({ + mode: zSystemPromptMode, + content: z.array(zContentBlock), + _meta: defaultOnError( + z.record(z.string(), z.unknown()).nullish(), + () => undefined, + ), +}); + /** * Request parameters for creating a new session. * @@ -3061,6 +3142,7 @@ export const zNewSessionRequest = z.object({ () => [], ).optional(), mcpServers: defaultOnNull(z.array(zMcpServer), () => []).optional(), + systemPrompt: zSystemPrompt.nullish(), _meta: defaultOnError( z.record(z.string(), z.unknown()).nullish(), () => undefined, @@ -3145,6 +3227,7 @@ export const zResumeSessionRequest = z.object({ ).optional(), mcpServers: defaultOnNull(z.array(zMcpServer), () => []).optional(), replayFrom: zReplayFrom.nullish(), + systemPrompt: zSystemPrompt.nullish(), _meta: defaultOnError( z.record(z.string(), z.unknown()).nullish(), () => undefined, diff --git a/src/v2/stable/acp.ts b/src/v2/stable/acp.ts index ae9087a3..572522a4 100644 --- a/src/v2/stable/acp.ts +++ b/src/v2/stable/acp.ts @@ -25,11 +25,10 @@ * snapshots, and `plan_update` is not an entity patch. * * Experimental operations follow their advertised capabilities; local schema - * selection does not establish peer support. When opting into unstable - * lifecycle `systemPrompt` instructions, only send them when the agent - * advertises `session.systemPrompt`, only use `override` when its - * `mode.override` capability is advertised, and never send an empty - * `content` array. + * selection does not establish peer support. Only send lifecycle + * `systemPrompt` instructions when the agent advertises + * `session.systemPrompt`, only use `override` when its `mode.override` + * capability is advertised, and never send an empty `content` array. * * @packageDocumentation * @experimental @@ -1716,6 +1715,12 @@ export class ActiveSession { * `canCancelToolCall`). The response means the Agent accepted the * cancellation, not that the work stopped. The Agent confirms it with a * `tool_call_update` to a final status. + * + * This only covers tool calls reported in this session. A subagent's tool + * call is reported in its child session, so send + * `methods.agent.toolCall.cancel` through `ClientContext.request` with the + * child's `sessionId`. The tool call's own `capabilities.cancel` enables + * that even when the child session doesn't advertise `cancel`. */ cancelToolCall( toolCallId: schema.ToolCallId, @@ -1742,6 +1747,12 @@ export class ActiveSession { * `canCancelTerminal`). The response means the Agent accepted the * cancellation, not that the process stopped. The Agent confirms it with a * `terminal_update` that sets `exitStatus`. The terminal is not released. + * + * This only covers terminals reported in this session. A subagent's + * terminal is reported in its child session, so send + * `methods.agent.terminal.cancel` through `ClientContext.request` with the + * child's `sessionId`. The terminal's own `capabilities.cancel` enables + * that even when the child session doesn't advertise `cancel`. */ cancelTerminal( terminalId: schema.TerminalId, diff --git a/src/v2/unstable/schema/types.gen.ts b/src/v2/unstable/schema/types.gen.ts index 44c392e7..7309e7d5 100644 --- a/src/v2/unstable/schema/types.gen.ts +++ b/src/v2/unstable/schema/types.gen.ts @@ -2019,16 +2019,10 @@ export type SessionCapabilities = { */ additionalDirectories?: SessionAdditionalDirectoriesCapabilities | null; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Whether the agent supports `systemPrompt` on session lifecycle requests. * * Optional. Omitted and `null` are equivalent and mean the agent does not advertise support. * Supplying `{}` means the agent supports `systemPrompt` in `append` mode. - * - * @experimental */ systemPrompt?: SessionSystemPromptCapabilities | null; /** @@ -2347,16 +2341,10 @@ export type SessionAdditionalDirectoriesCapabilities = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for client-provided system prompts. * * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle * requests in `append` mode. - * - * @experimental */ export type SessionSystemPromptCapabilities = { /** @@ -2378,16 +2366,10 @@ export type SessionSystemPromptCapabilities = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System prompt delivery modes the agent supports in addition to `append`. * * `append` has no entry because every agent advertising `session.systemPrompt` * supports it. - * - * @experimental */ export type SessionSystemPromptModeCapabilities = { /** @@ -2411,16 +2393,10 @@ export type SessionSystemPromptModeCapabilities = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for the `override` system prompt mode. * * Supplying `{}` means the agent supports replacing its built-in default * instructions with the client-provided system prompt. - * - * @experimental */ export type SessionSystemPromptOverrideCapabilities = { /** @@ -6199,17 +6175,11 @@ export type NewSessionRequest = { */ mcpServers?: Array; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System-level instructions for the new session. * * Optional. Omitted and `null` are equivalent and mean the Agent uses its * own default instructions. Clients MUST only send this when the Agent * advertises `session.systemPrompt`. - * - * @experimental */ systemPrompt?: SystemPrompt | null; /** @@ -6390,18 +6360,12 @@ export type McpServerStdio = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Client-provided system-level instructions for a session. * * Clients MUST only send this when the Agent advertises * `session.systemPrompt`. Agents that cannot apply it, for example because of * an unadvertised mode or an unsupported content block type, MUST return an - * error instead of creating, resuming, or forking the session. - * - * @experimental + * error instead of creating or resuming the session. */ export type SystemPrompt = { /** @@ -6420,7 +6384,7 @@ export type SystemPrompt = { * blocks they do not support, including unknown types. * * Clients MUST NOT send an empty array. Agents MAY reject one with - * `-32602` without creating, resuming, or forking the session. + * `-32602` without creating or resuming the session. */ content: Array; /** @@ -6436,17 +6400,11 @@ export type SystemPrompt = { }; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * How the Agent combines a client-provided system prompt with its own instructions. * * Unknown modes are preserved so they can be stored, * proxied, or forwarded. An Agent MUST return an error for a mode it does not * support rather than treating it as `append` or `override`. - * - * @experimental */ export type SystemPromptMode = "append" | "override" | string; @@ -6567,10 +6525,6 @@ export type ForkSessionRequest = { */ mcpServers?: Array; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System-level instructions for the forked session. * * Optional. Omitted and `null` are equivalent. The Agent may then keep a @@ -6578,8 +6532,6 @@ export type ForkSessionRequest = { * instructions. Clients MUST only send this when the Agent advertises * `session.systemPrompt`, and SHOULD send the same value they used for the * source session. - * - * @experimental */ systemPrompt?: SystemPrompt | null; /** @@ -6785,10 +6737,6 @@ export type ResumeSessionRequest = { */ replayFrom?: ReplayFrom | null; /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System-level instructions for the resumed session. * * Optional. Omitted and `null` are equivalent. The Agent may then keep a @@ -6796,8 +6744,6 @@ export type ResumeSessionRequest = { * Clients MUST only send this when the Agent advertises * `session.systemPrompt`, and SHOULD send the same value they used when the * session was created. - * - * @experimental */ systemPrompt?: SystemPrompt | null; /** diff --git a/src/v2/unstable/schema/zod.gen.ts b/src/v2/unstable/schema/zod.gen.ts index e6fcbbd4..65322418 100644 --- a/src/v2/unstable/schema/zod.gen.ts +++ b/src/v2/unstable/schema/zod.gen.ts @@ -1281,16 +1281,10 @@ export const zSessionAdditionalDirectoriesCapabilities = z.object({ }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for the `override` system prompt mode. * * Supplying `{}` means the agent supports replacing its built-in default * instructions with the client-provided system prompt. - * - * @experimental */ export const zSessionSystemPromptOverrideCapabilities = z.object({ _meta: defaultOnError( @@ -1300,16 +1294,10 @@ export const zSessionSystemPromptOverrideCapabilities = z.object({ }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * System prompt delivery modes the agent supports in addition to `append`. * * `append` has no entry because every agent advertising `session.systemPrompt` * supports it. - * - * @experimental */ export const zSessionSystemPromptModeCapabilities = z.object({ override: defaultOnError( @@ -1323,16 +1311,10 @@ export const zSessionSystemPromptModeCapabilities = z.object({ }); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Capabilities for client-provided system prompts. * * Supplying `{}` means the agent supports `systemPrompt` on session lifecycle * requests in `append` mode. - * - * @experimental */ export const zSessionSystemPromptCapabilities = z.object({ mode: defaultOnError( @@ -4045,17 +4027,11 @@ export const zMcpServer = preserveCustomPayload( ); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * How the Agent combines a client-provided system prompt with its own instructions. * * Unknown modes are preserved so they can be stored, * proxied, or forwarded. An Agent MUST return an error for a mode it does not * support rather than treating it as `append` or `override`. - * - * @experimental */ export const zSystemPromptMode = z.union([ z.literal("append"), @@ -4064,18 +4040,12 @@ export const zSystemPromptMode = z.union([ ]); /** - * **UNSTABLE** - * - * This capability is not part of the spec yet, and may be removed or changed at any point. - * * Client-provided system-level instructions for a session. * * Clients MUST only send this when the Agent advertises * `session.systemPrompt`. Agents that cannot apply it, for example because of * an unadvertised mode or an unsupported content block type, MUST return an - * error instead of creating, resuming, or forking the session. - * - * @experimental + * error instead of creating or resuming the session. */ export const zSystemPrompt = z.object({ mode: zSystemPromptMode,