public final class NegotiatedCapabilities
extends java.lang.Object
After the initialize exchange, both client and agent know what features
the other side supports. This class provides convenient methods to check capabilities
and validate that operations are supported before attempting them.
Example usage for an agent checking client capabilities:
NegotiatedCapabilities caps = NegotiatedCapabilities.fromClient(clientCapabilities);
// Check before calling fs/read_text_file
if (caps.supportsReadTextFile()) {
agent.readTextFile(request);
}
// Or require the capability (throws if not supported)
caps.requireReadTextFile();
agent.readTextFile(request);
Example usage for a client checking agent capabilities:
NegotiatedCapabilities caps = NegotiatedCapabilities.fromAgent(agentCapabilities);
// Check if agent supports image content
if (caps.supportsImageContent()) {
prompt.add(imageContent);
}
| 限定符和类型 | 类和说明 |
|---|---|
static class |
NegotiatedCapabilities.Builder
Builder for NegotiatedCapabilities.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static NegotiatedCapabilities |
fromAgent(AcpSchema.AgentCapabilities caps)
Creates negotiated capabilities from agent capabilities (used by clients).
|
static NegotiatedCapabilities |
fromClient(AcpSchema.ClientCapabilities caps)
Creates negotiated capabilities from client capabilities (used by agents).
|
void |
requireAudioContent()
Requires audio content capability, throwing if not supported.
|
void |
requireImageContent()
Requires image content capability, throwing if not supported.
|
void |
requireLoadSession()
Requires load session capability, throwing if not supported.
|
void |
requireReadTextFile()
Requires read text file capability, throwing if not supported.
|
void |
requireTerminal()
Requires terminal capability, throwing if not supported.
|
void |
requireWriteTextFile()
Requires write text file capability, throwing if not supported.
|
boolean |
supportsAudioContent()
Returns true if the agent supports audio content in prompts.
|
boolean |
supportsEmbeddedContext()
Returns true if the agent supports embedded context (resources) in prompts.
|
boolean |
supportsImageContent()
Returns true if the agent supports image content in prompts.
|
boolean |
supportsLoadSession()
Returns true if the agent supports loading sessions.
|
boolean |
supportsMcpHttp()
Returns true if the agent supports MCP servers via HTTP.
|
boolean |
supportsMcpSse()
Returns true if the agent supports MCP servers via SSE.
|
boolean |
supportsReadTextFile()
Returns true if the client supports reading text files.
|
boolean |
supportsTerminal()
Returns true if the client supports terminal operations.
|
boolean |
supportsWriteTextFile()
Returns true if the client supports writing text files.
|
java.lang.String |
toString() |
public static NegotiatedCapabilities fromClient(AcpSchema.ClientCapabilities caps)
caps - the client's advertised capabilities, may be nullpublic static NegotiatedCapabilities fromAgent(AcpSchema.AgentCapabilities caps)
caps - the agent's advertised capabilities, may be nullpublic boolean supportsReadTextFile()
public boolean supportsWriteTextFile()
public boolean supportsTerminal()
public void requireReadTextFile()
AcpCapabilityException - if the client doesn't support this capabilitypublic void requireWriteTextFile()
AcpCapabilityException - if the client doesn't support this capabilitypublic void requireTerminal()
AcpCapabilityException - if the client doesn't support this capabilitypublic boolean supportsLoadSession()
public boolean supportsImageContent()
public boolean supportsAudioContent()
public boolean supportsEmbeddedContext()
public boolean supportsMcpHttp()
public boolean supportsMcpSse()
public void requireLoadSession()
AcpCapabilityException - if the agent doesn't support this capabilitypublic void requireImageContent()
AcpCapabilityException - if the agent doesn't support this capabilitypublic void requireAudioContent()
AcpCapabilityException - if the agent doesn't support this capabilitypublic java.lang.String toString()
toString 在类中 java.lang.Object