@anthropic-ai/claude-agent-sdk 0.1.69 → 0.1.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -306,9 +306,10 @@ export type HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput;
306
306
  * - `'acceptEdits'` - Auto-accept file edit operations
307
307
  * - `'bypassPermissions'` - Bypass all permission checks (requires `allowDangerouslySkipPermissions`)
308
308
  * - `'plan'` - Planning mode, no actual tool execution
309
+ * - `'delegate'` - Delegate mode, restricts team leader to only Teammate and Task tools
309
310
  * - `'dontAsk'` - Don't prompt for permissions, deny if not pre-approved
310
311
  */
311
- export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'dontAsk';
312
+ export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'delegate' | 'dontAsk';
312
313
  /**
313
314
  * Information about an available slash command.
314
315
  */
@@ -353,6 +354,17 @@ export type McpServerStatus = {
353
354
  version: string;
354
355
  };
355
356
  };
357
+ /**
358
+ * Result of a setMcpServers operation.
359
+ */
360
+ export type McpSetServersResult = {
361
+ /** Names of servers that were added */
362
+ added: string[];
363
+ /** Names of servers that were removed */
364
+ removed: string[];
365
+ /** Map of server names to error messages for servers that failed to connect */
366
+ errors: Record<string, string>;
367
+ };
356
368
  type SDKUserMessageContent = {
357
369
  type: 'user';
358
370
  message: APIUserMessage;
@@ -579,6 +591,18 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
579
591
  * @param userMessageId - UUID of the user message to rewind to
580
592
  */
581
593
  rewindFiles(userMessageId: string): Promise<void>;
594
+ /**
595
+ * Dynamically set the MCP servers for this session.
596
+ * This replaces the current set of dynamically-added MCP servers with the provided set.
597
+ * Servers that are removed will be disconnected, and new servers will be connected.
598
+ *
599
+ * Note: This only affects servers added dynamically via this method or the SDK.
600
+ * Servers configured via settings files are not affected.
601
+ *
602
+ * @param servers - Record of server name to configuration. Pass an empty object to remove all dynamic servers.
603
+ * @returns Information about which servers were added, removed, and any connection errors
604
+ */
605
+ setMcpServers(servers: Record<string, McpServerConfigForProcessTransport>): Promise<McpSetServersResult>;
582
606
  /**
583
607
  * Stream input messages to the query.
584
608
  * Used internally for multi-turn conversations.
@@ -1,4 +1,4 @@
1
- import { type AccountInfo, type PermissionMode, type SDKMessage, type SDKUserMessage, type HookInput, type HookEvent, type PermissionUpdate, type ModelInfo, type SlashCommand, type AgentDefinition } from './agentSdkTypes.js';
1
+ import { type AccountInfo, type PermissionMode, type SDKMessage, type SDKUserMessage, type HookInput, type HookEvent, type PermissionUpdate, type ModelInfo, type SlashCommand, type AgentDefinition, type McpServerConfigForProcessTransport } from './agentSdkTypes.js';
2
2
  import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
3
3
  export type SDKControlInitializeRequest = {
4
4
  subtype: 'initialize';
@@ -65,10 +65,19 @@ export type SDKControlMcpMessageRequest = {
65
65
  server_name: string;
66
66
  message: JSONRPCMessage;
67
67
  };
68
+ export type SDKControlMcpSetServersRequest = {
69
+ subtype: 'mcp_set_servers';
70
+ servers: Record<string, McpServerConfigForProcessTransport>;
71
+ };
72
+ export type SDKControlMcpSetServersResponse = {
73
+ added: string[];
74
+ removed: string[];
75
+ errors: Record<string, string>;
76
+ };
68
77
  export type SDKControlRequest = {
69
78
  type: 'control_request';
70
79
  request_id: string;
71
- request: SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlMcpStatusRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest;
80
+ request: SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlMcpStatusRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlMcpSetServersRequest;
72
81
  };
73
82
  export type SDKControlResponse = {
74
83
  type: 'control_response';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/claude-agent-sdk",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "main": "sdk.mjs",
5
5
  "types": "sdk.d.ts",
6
6
  "engines": {
package/sdk.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
3
3
 
4
- // Version: 0.1.69
4
+ // Version: 0.1.70
5
5
 
6
6
  // Want to see the unminified source? We're hiring!
7
7
  // https://job-boards.greenhouse.io/anthropic/jobs/4816199008
@@ -6862,6 +6862,8 @@ function getInitialState() {
6862
6862
  sessionPersistenceDisabled: false,
6863
6863
  hasExitedPlanMode: false,
6864
6864
  needsPlanModeExitAttachment: false,
6865
+ hasExitedDelegateMode: false,
6866
+ needsDelegateModeExitAttachment: false,
6865
6867
  initJsonSchema: null,
6866
6868
  registeredHooks: null,
6867
6869
  planSlugCache: new Map
@@ -8069,6 +8071,13 @@ class Query {
8069
8071
  const mcpStatusResponse = response.response;
8070
8072
  return mcpStatusResponse.mcpServers;
8071
8073
  }
8074
+ async setMcpServers(servers) {
8075
+ const response = await this.request({
8076
+ subtype: "mcp_set_servers",
8077
+ servers
8078
+ });
8079
+ return response.response;
8080
+ }
8072
8081
  async accountInfo() {
8073
8082
  return (await this.initialization).account;
8074
8083
  }
@@ -15209,7 +15218,7 @@ function query({
15209
15218
  const dirname2 = join5(filename, "..");
15210
15219
  pathToClaudeCodeExecutable = join5(dirname2, "cli.js");
15211
15220
  }
15212
- process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.69";
15221
+ process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.70";
15213
15222
  const {
15214
15223
  abortController = createAbortController(),
15215
15224
  additionalDirectories = [],