@anthropic-ai/claude-agent-sdk 0.1.72 → 0.1.73

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.
@@ -311,14 +311,14 @@ export type HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput;
311
311
  */
312
312
  export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'delegate' | 'dontAsk';
313
313
  /**
314
- * Information about an available slash command.
314
+ * Information about an available skill (invoked via /command syntax).
315
315
  */
316
316
  export type SlashCommand = {
317
- /** Command name (without the leading slash) */
317
+ /** Skill name (without the leading slash) */
318
318
  name: string;
319
- /** Description of what the command does */
319
+ /** Description of what the skill does */
320
320
  description: string;
321
- /** Hint for command arguments (e.g., "<file>") */
321
+ /** Hint for skill arguments (e.g., "<file>") */
322
322
  argumentHint: string;
323
323
  };
324
324
  /**
@@ -561,9 +561,9 @@ export interface Query extends AsyncGenerator<SDKMessage, void> {
561
561
  */
562
562
  setMaxThinkingTokens(maxThinkingTokens: number | null): Promise<void>;
563
563
  /**
564
- * Get the list of available slash commands for the current session.
564
+ * Get the list of available skills for the current session.
565
565
  *
566
- * @returns Array of available slash commands with their names and descriptions
566
+ * @returns Array of available skills with their names and descriptions
567
567
  */
568
568
  supportedCommands(): Promise<SlashCommand[]>;
569
569
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/claude-agent-sdk",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
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.72
4
+ // Version: 0.1.73
5
5
 
6
6
  // Want to see the unminified source? We're hiring!
7
7
  // https://job-boards.greenhouse.io/anthropic/jobs/4816199008
@@ -13514,13 +13514,8 @@ class Query {
13514
13514
  nextCallbackId = 0;
13515
13515
  sdkMcpTransports = new Map;
13516
13516
  pendingMcpResponses = new Map;
13517
- lastActivityTime = Date.now();
13518
- userInputEndedResolve;
13519
- streamCloseTimeout;
13520
13517
  firstResultReceivedResolve;
13521
- resetLastActivityTime() {
13522
- this.lastActivityTime = Date.now();
13523
- }
13518
+ firstResultReceived = false;
13524
13519
  hasBidirectionalNeeds() {
13525
13520
  return this.sdkMcpTransports.size > 0 || this.hooks !== undefined && Object.keys(this.hooks).length > 0 || this.canUseTool !== undefined;
13526
13521
  }
@@ -13532,10 +13527,6 @@ class Query {
13532
13527
  this.abortController = abortController;
13533
13528
  this.jsonSchema = jsonSchema;
13534
13529
  this.initConfig = initConfig;
13535
- this.streamCloseTimeout = 5000;
13536
- if (typeof process !== "undefined" && process.env?.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT) {
13537
- this.streamCloseTimeout = parseInt(process.env.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT);
13538
- }
13539
13530
  for (const [name, server] of sdkMcpServers) {
13540
13531
  const sdkTransport = new SdkControlServerTransport((message) => this.sendMcpServerMessageToCli(name, message));
13541
13532
  this.sdkMcpTransports.set(name, sdkTransport);
@@ -13590,7 +13581,6 @@ class Query {
13590
13581
  async readMessages() {
13591
13582
  try {
13592
13583
  for await (const message of this.transport.readMessages()) {
13593
- this.resetLastActivityTime();
13594
13584
  if (message.type === "control_response") {
13595
13585
  const handler = this.pendingControlResponses.get(message.response.request_id);
13596
13586
  if (handler) {
@@ -13607,6 +13597,7 @@ class Query {
13607
13597
  continue;
13608
13598
  }
13609
13599
  if (message.type === "result") {
13600
+ this.firstResultReceived = true;
13610
13601
  if (this.firstResultReceivedResolve) {
13611
13602
  this.firstResultReceivedResolve();
13612
13603
  }
@@ -13617,14 +13608,14 @@ class Query {
13617
13608
  }
13618
13609
  this.inputStream.enqueue(message);
13619
13610
  }
13620
- if (this.userInputEndedResolve) {
13621
- this.userInputEndedResolve();
13611
+ if (this.firstResultReceivedResolve) {
13612
+ this.firstResultReceivedResolve();
13622
13613
  }
13623
13614
  this.inputStream.done();
13624
13615
  this.cleanup();
13625
13616
  } catch (error) {
13626
- if (this.userInputEndedResolve) {
13627
- this.userInputEndedResolve();
13617
+ if (this.firstResultReceivedResolve) {
13618
+ this.firstResultReceivedResolve();
13628
13619
  }
13629
13620
  this.inputStream.error(error);
13630
13621
  this.cleanup(error);
@@ -13840,8 +13831,8 @@ class Query {
13840
13831
  }
13841
13832
  logForDebugging(`[Query.streamInput] Finished processing ${messageCount} messages from input stream`);
13842
13833
  if (this.hasBidirectionalNeeds()) {
13843
- logForDebugging(`[Query.streamInput] Has bidirectional needs, waiting for inactivity`);
13844
- await this.waitForInactivity();
13834
+ logForDebugging(`[Query.streamInput] Has bidirectional needs, waiting for first result`);
13835
+ await this.waitForFirstResult();
13845
13836
  }
13846
13837
  logForDebugging(`[Query] Calling transport.endInput() to close stdin to CLI process`);
13847
13838
  this.transport.endInput();
@@ -13851,10 +13842,12 @@ class Query {
13851
13842
  }
13852
13843
  }
13853
13844
  }
13854
- async waitForInactivity() {
13855
- logForDebugging(`[Query.waitForInactivity] Waiting for inactivity (timeout: ${this.streamCloseTimeout}ms)`);
13845
+ waitForFirstResult() {
13846
+ if (this.firstResultReceived) {
13847
+ logForDebugging(`[Query.waitForFirstResult] Result already received, returning immediately`);
13848
+ return Promise.resolve();
13849
+ }
13856
13850
  return new Promise((resolve) => {
13857
- this.userInputEndedResolve = resolve;
13858
13851
  if (this.abortController?.signal.aborted) {
13859
13852
  resolve();
13860
13853
  return;
@@ -13862,22 +13855,7 @@ class Query {
13862
13855
  this.abortController?.signal.addEventListener("abort", () => resolve(), {
13863
13856
  once: true
13864
13857
  });
13865
- const checkInactivity = () => {
13866
- if (this.abortController?.signal.aborted) {
13867
- resolve();
13868
- return;
13869
- }
13870
- const elapsed = Date.now() - this.lastActivityTime;
13871
- if (elapsed >= this.streamCloseTimeout) {
13872
- logForDebugging(`[Query.waitForInactivity] Inactivity timeout reached (${elapsed}ms elapsed). ` + `Closing stdin. If your tools or hooks need more time, set CLAUDE_CODE_STREAM_CLOSE_TIMEOUT ` + `to a higher value (current: ${this.streamCloseTimeout}ms).`);
13873
- resolve();
13874
- } else {
13875
- const remaining = this.streamCloseTimeout - elapsed;
13876
- logForDebugging(`[Query.waitForInactivity] Still active, checking again in ${remaining}ms`);
13877
- setTimeout(checkInactivity, remaining);
13878
- }
13879
- };
13880
- checkInactivity();
13858
+ this.firstResultReceivedResolve = resolve;
13881
13859
  });
13882
13860
  }
13883
13861
  handleHookCallbacks(callbackId, input, toolUseID, abortSignal) {
@@ -26708,7 +26686,7 @@ function query({
26708
26686
  const dirname2 = join5(filename, "..");
26709
26687
  pathToClaudeCodeExecutable = join5(dirname2, "cli.js");
26710
26688
  }
26711
- process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.72";
26689
+ process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.73";
26712
26690
  const {
26713
26691
  abortController = createAbortController(),
26714
26692
  additionalDirectories = [],