@anthropic-ai/claude-agent-sdk 0.1.55 → 0.1.56

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.
Files changed (5) hide show
  1. package/cli.js +1257 -1236
  2. package/package.json +1 -1
  3. package/sdk-tools.d.ts +1 -4
  4. package/sdk.d.ts +13 -2
  5. package/sdk.mjs +16 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/claude-agent-sdk",
3
- "version": "0.1.55",
3
+ "version": "0.1.56",
4
4
  "main": "sdk.mjs",
5
5
  "types": "sdk.d.ts",
6
6
  "engines": {
package/sdk-tools.d.ts CHANGED
@@ -94,10 +94,7 @@ export interface BashOutputInput {
94
94
  filter?: string;
95
95
  }
96
96
  export interface ExitPlanModeInput {
97
- /**
98
- * The plan you came up with, that you want to run by the user for approval. Supports markdown. The plan should be pretty concise.
99
- */
100
- plan: string;
97
+ [k: string]: unknown;
101
98
  }
102
99
  export interface FileEditInput {
103
100
  /**
package/sdk.d.ts CHANGED
@@ -161,7 +161,7 @@ export type CanUseTool = (toolName: string, input: Record<string, unknown>, opti
161
161
  /** If running within the context of a sub-agent, the sub-agent's ID. */
162
162
  agentID?: string;
163
163
  }) => Promise<PermissionResult>;
164
- export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest"];
164
+ export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest"];
165
165
  export type HookEvent = (typeof HOOK_EVENTS)[number];
166
166
  export type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
167
167
  signal: AbortSignal;
@@ -197,6 +197,14 @@ export type PostToolUseHookInput = BaseHookInput & {
197
197
  tool_response: unknown;
198
198
  tool_use_id: string;
199
199
  };
200
+ export type PostToolUseFailureHookInput = BaseHookInput & {
201
+ hook_event_name: 'PostToolUseFailure';
202
+ tool_name: string;
203
+ tool_input: unknown;
204
+ tool_use_id: string;
205
+ error: string;
206
+ is_interrupt?: boolean;
207
+ };
200
208
  export type NotificationHookInput = BaseHookInput & {
201
209
  hook_event_name: 'Notification';
202
210
  message: string;
@@ -237,7 +245,7 @@ export type SessionEndHookInput = BaseHookInput & {
237
245
  hook_event_name: 'SessionEnd';
238
246
  reason: ExitReason;
239
247
  };
240
- export type HookInput = PreToolUseHookInput | PostToolUseHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStartHookInput | SubagentStopHookInput | PreCompactHookInput | PermissionRequestHookInput;
248
+ export type HookInput = PreToolUseHookInput | PostToolUseHookInput | PostToolUseFailureHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStartHookInput | SubagentStopHookInput | PreCompactHookInput | PermissionRequestHookInput;
241
249
  export type AsyncHookJSONOutput = {
242
250
  async: true;
243
251
  asyncTimeout?: number;
@@ -267,6 +275,9 @@ export type SyncHookJSONOutput = {
267
275
  hookEventName: 'PostToolUse';
268
276
  additionalContext?: string;
269
277
  updatedMCPToolOutput?: unknown;
278
+ } | {
279
+ hookEventName: 'PostToolUseFailure';
280
+ additionalContext?: string;
270
281
  } | {
271
282
  hookEventName: 'PermissionRequest';
272
283
  decision: {
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://docs.claude.com/en/docs/claude-code/legal-and-compliance.
3
3
 
4
- // Version: 0.1.55
4
+ // Version: 0.1.56
5
5
 
6
6
  // Want to see the unminified source? We're hiring!
7
7
  // https://job-boards.greenhouse.io/anthropic/jobs/4816199008
@@ -6381,6 +6381,7 @@ function getFsImplementation() {
6381
6381
  var HOOK_EVENTS = [
6382
6382
  "PreToolUse",
6383
6383
  "PostToolUse",
6384
+ "PostToolUseFailure",
6384
6385
  "Notification",
6385
6386
  "UserPromptSubmit",
6386
6387
  "SessionStart",
@@ -6478,7 +6479,6 @@ class ProcessTransport {
6478
6479
  try {
6479
6480
  const {
6480
6481
  additionalDirectories = [],
6481
- agents,
6482
6482
  cwd,
6483
6483
  executable = isRunningWithBun() ? "bun" : "node",
6484
6484
  executableArgs = [],
@@ -6486,8 +6486,6 @@ class ProcessTransport {
6486
6486
  pathToClaudeCodeExecutable,
6487
6487
  env = { ...process.env },
6488
6488
  stderr,
6489
- customSystemPrompt,
6490
- appendSystemPrompt,
6491
6489
  maxThinkingTokens,
6492
6490
  maxTurns,
6493
6491
  maxBudgetUsd,
@@ -6515,10 +6513,6 @@ class ProcessTransport {
6515
6513
  "--input-format",
6516
6514
  "stream-json"
6517
6515
  ];
6518
- if (typeof customSystemPrompt === "string")
6519
- args.push("--system-prompt", customSystemPrompt);
6520
- if (appendSystemPrompt)
6521
- args.push("--append-system-prompt", appendSystemPrompt);
6522
6516
  if (maxThinkingTokens !== undefined) {
6523
6517
  args.push("--max-thinking-tokens", maxThinkingTokens.toString());
6524
6518
  }
@@ -6556,9 +6550,6 @@ class ProcessTransport {
6556
6550
  if (mcpServers && Object.keys(mcpServers).length > 0) {
6557
6551
  args.push("--mcp-config", JSON.stringify({ mcpServers }));
6558
6552
  }
6559
- if (agents && Object.keys(agents).length > 0) {
6560
- args.push("--agents", JSON.stringify(agents));
6561
- }
6562
6553
  if (settingSources) {
6563
6554
  args.push("--setting-sources", settingSources.join(","));
6564
6555
  }
@@ -7676,6 +7667,7 @@ class Query {
7676
7667
  hooks;
7677
7668
  abortController;
7678
7669
  jsonSchema;
7670
+ initConfig;
7679
7671
  pendingControlResponses = new Map;
7680
7672
  cleanupPerformed = false;
7681
7673
  sdkMessages;
@@ -7689,13 +7681,14 @@ class Query {
7689
7681
  firstResultReceivedPromise;
7690
7682
  firstResultReceivedResolve;
7691
7683
  streamCloseTimeout;
7692
- constructor(transport, isSingleUserTurn, canUseTool, hooks, abortController, sdkMcpServers = new Map, jsonSchema) {
7684
+ constructor(transport, isSingleUserTurn, canUseTool, hooks, abortController, sdkMcpServers = new Map, jsonSchema, initConfig) {
7693
7685
  this.transport = transport;
7694
7686
  this.isSingleUserTurn = isSingleUserTurn;
7695
7687
  this.canUseTool = canUseTool;
7696
7688
  this.hooks = hooks;
7697
7689
  this.abortController = abortController;
7698
7690
  this.jsonSchema = jsonSchema;
7691
+ this.initConfig = initConfig;
7699
7692
  this.streamCloseTimeout = 60000;
7700
7693
  if (typeof process !== "undefined" && process.env?.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT) {
7701
7694
  this.streamCloseTimeout = parseInt(process.env.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT);
@@ -7888,7 +7881,10 @@ class Query {
7888
7881
  subtype: "initialize",
7889
7882
  hooks,
7890
7883
  sdkMcpServers,
7891
- jsonSchema: this.jsonSchema
7884
+ jsonSchema: this.jsonSchema,
7885
+ systemPrompt: this.initConfig?.systemPrompt,
7886
+ appendSystemPrompt: this.initConfig?.appendSystemPrompt,
7887
+ agents: this.initConfig?.agents
7892
7888
  };
7893
7889
  const response = await this.request(initRequest);
7894
7890
  return response.response;
@@ -8102,7 +8098,6 @@ class SessionImpl {
8102
8098
  executable: options.executable ?? (isRunningWithBun() ? "bun" : "node"),
8103
8099
  executableArgs: options.executableArgs ?? [],
8104
8100
  extraArgs: {},
8105
- customSystemPrompt: "",
8106
8101
  maxThinkingTokens: undefined,
8107
8102
  maxTurns: undefined,
8108
8103
  maxBudgetUsd: undefined,
@@ -15075,7 +15070,7 @@ function query({
15075
15070
  const dirname2 = join5(filename, "..");
15076
15071
  pathToClaudeCodeExecutable = join5(dirname2, "cli.js");
15077
15072
  }
15078
- process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.55";
15073
+ process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.56";
15079
15074
  const {
15080
15075
  abortController = createAbortController(),
15081
15076
  additionalDirectories = [],
@@ -15138,7 +15133,6 @@ function query({
15138
15133
  const transport = new ProcessTransport({
15139
15134
  abortController,
15140
15135
  additionalDirectories,
15141
- agents,
15142
15136
  cwd: cwd2,
15143
15137
  executable,
15144
15138
  executableArgs,
@@ -15147,8 +15141,6 @@ function query({
15147
15141
  env: processEnv,
15148
15142
  forkSession,
15149
15143
  stderr,
15150
- customSystemPrompt,
15151
- appendSystemPrompt,
15152
15144
  maxThinkingTokens,
15153
15145
  maxTurns,
15154
15146
  maxBudgetUsd,
@@ -15171,7 +15163,12 @@ function query({
15171
15163
  includePartialMessages,
15172
15164
  plugins
15173
15165
  });
15174
- const queryInstance = new Query(transport, isSingleUserTurn, canUseTool, hooks, abortController, sdkMcpServers, jsonSchema);
15166
+ const initConfig = {
15167
+ systemPrompt: customSystemPrompt,
15168
+ appendSystemPrompt,
15169
+ agents
15170
+ };
15171
+ const queryInstance = new Query(transport, isSingleUserTurn, canUseTool, hooks, abortController, sdkMcpServers, jsonSchema, initConfig);
15175
15172
  if (typeof prompt === "string") {
15176
15173
  transport.write(JSON.stringify({
15177
15174
  type: "user",