@anuma/sdk 6.27.7 → 6.27.9

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.
@@ -5954,6 +5954,12 @@ var ToolTimeoutError = class extends Error {
5954
5954
  this.name = "ToolTimeoutError";
5955
5955
  }
5956
5956
  };
5957
+ var ToolCancelledError = class extends Error {
5958
+ constructor() {
5959
+ super("Tool execution cancelled");
5960
+ this.name = "ToolCancelledError";
5961
+ }
5962
+ };
5957
5963
  function safeJsonStringify(value) {
5958
5964
  try {
5959
5965
  return JSON.stringify(value) ?? "null";
@@ -5961,7 +5967,7 @@ function safeJsonStringify(value) {
5961
5967
  return String(value);
5962
5968
  }
5963
5969
  }
5964
- async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS) {
5970
+ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS, signal) {
5965
5971
  let args = {};
5966
5972
  if (toolCall.arguments) {
5967
5973
  const parsed = parseToolArguments(toolCall.arguments);
@@ -5970,28 +5976,42 @@ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIM
5970
5976
  }
5971
5977
  args = parsed.args;
5972
5978
  }
5979
+ if (signal?.aborted) {
5980
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
5981
+ }
5982
+ let timer;
5983
+ let onAbort;
5973
5984
  try {
5974
- if (!isFinite(timeoutMs)) {
5975
- return { result: await executor(args) };
5985
+ const racers = [];
5986
+ if (signal) {
5987
+ racers.push(
5988
+ new Promise((_, reject) => {
5989
+ onAbort = () => reject(new ToolCancelledError());
5990
+ signal.addEventListener("abort", onAbort, { once: true });
5991
+ })
5992
+ );
5976
5993
  }
5977
- let timer;
5978
- try {
5979
- const result = await Promise.race([
5980
- executor(args),
5994
+ racers.push(Promise.resolve(signal ? executor(args, signal) : executor(args)));
5995
+ if (isFinite(timeoutMs)) {
5996
+ racers.push(
5981
5997
  new Promise((_, reject) => {
5982
5998
  timer = setTimeout(() => reject(new ToolTimeoutError()), timeoutMs);
5983
5999
  })
5984
- ]);
5985
- return { result };
5986
- } finally {
5987
- clearTimeout(timer);
6000
+ );
5988
6001
  }
6002
+ return { result: await Promise.race(racers) };
5989
6003
  } catch (e) {
6004
+ if (e instanceof ToolCancelledError) {
6005
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
6006
+ }
5990
6007
  const message = e instanceof Error ? e.message : String(e);
5991
6008
  return {
5992
6009
  error: `Tool execution failed: ${message}`,
5993
6010
  errorType: e instanceof ToolTimeoutError ? "timeout" : "execution"
5994
6011
  };
6012
+ } finally {
6013
+ clearTimeout(timer);
6014
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
5995
6015
  }
5996
6016
  }
5997
6017
  function toolsToApiFormat(tools, apiType) {
@@ -8347,11 +8367,12 @@ Executing tool: ${toolInfo}
8347
8367
  const blockedByFailure = failedDeps.some((d) => failedNames.has(d));
8348
8368
  const reason = blockedByFailure ? `failed dependencies: ${failedDeps.join(", ")}` : "a dependency cycle";
8349
8369
  const errorMsg = `Tool "${tc.name}" was not executed due to ${reason}`;
8370
+ const skipErrorType = combinedSignal?.aborted ? "cancelled" : "execution";
8350
8371
  executionResults.push({
8351
8372
  id: tc.id,
8352
8373
  name: tc.name,
8353
8374
  error: errorMsg,
8354
- errorType: "execution"
8375
+ errorType: skipErrorType
8355
8376
  });
8356
8377
  await safeAwait(
8357
8378
  () => hooks?.afterToolUse?.({
@@ -8360,7 +8381,7 @@ Executing tool: ${toolInfo}
8360
8381
  toolCallId: tc.id,
8361
8382
  name: tc.name,
8362
8383
  error: errorMsg,
8363
- errorType: "execution"
8384
+ errorType: skipErrorType
8364
8385
  })
8365
8386
  );
8366
8387
  }
@@ -8380,7 +8401,8 @@ Executing tool: ${toolInfo}
8380
8401
  const { result, error, errorType } = await executeToolCall(
8381
8402
  toolCallForExec,
8382
8403
  executorConfig.executor,
8383
- executorConfig.executorTimeout
8404
+ executorConfig.executorTimeout,
8405
+ combinedSignal
8384
8406
  );
8385
8407
  await safeAwait(
8386
8408
  () => hooks?.afterToolUse?.({
@@ -9449,6 +9471,7 @@ function useChat(options) {
9449
9471
  const abortControllerRef = (0, import_react3.useRef)(null);
9450
9472
  const detachControllerRef = (0, import_react3.useRef)(null);
9451
9473
  const pendingResumeRef = (0, import_react3.useRef)(null);
9474
+ const requestIdRef = (0, import_react3.useRef)(0);
9452
9475
  const fireCancel = (0, import_react3.useCallback)(
9453
9476
  (handle) => {
9454
9477
  const { inferenceId } = handle;
@@ -9577,6 +9600,8 @@ function useChat(options) {
9577
9600
  abortControllerRef.current = abortController;
9578
9601
  const detachController = new AbortController();
9579
9602
  detachControllerRef.current = detachController;
9603
+ const requestId = ++requestIdRef.current;
9604
+ const superseded = () => requestIdRef.current !== requestId;
9580
9605
  pendingResumeRef.current = null;
9581
9606
  setIsLoading(true);
9582
9607
  try {
@@ -9696,7 +9721,8 @@ function useChat(options) {
9696
9721
  piiRedaction: requestPiiRedaction ?? resolvedPiiRedaction,
9697
9722
  onPiiRedacted
9698
9723
  });
9699
- if ("detached" in result && result.detached && result.resume) {
9724
+ if (superseded()) {
9725
+ } else if ("detached" in result && result.detached && result.resume) {
9700
9726
  pendingResumeRef.current = result.resume;
9701
9727
  } else {
9702
9728
  pendingResumeRef.current = null;
@@ -9708,7 +9734,7 @@ function useChat(options) {
9708
9734
  onError
9709
9735
  );
9710
9736
  } finally {
9711
- setIsLoading(false);
9737
+ if (!superseded()) setIsLoading(false);
9712
9738
  if (abortControllerRef.current === abortController) {
9713
9739
  abortControllerRef.current = null;
9714
9740
  }
@@ -2177,12 +2177,12 @@ type ToolCallArgumentsDeltaEvent = {
2177
2177
  argumentsDelta: string;
2178
2178
  accumulatedArguments: string;
2179
2179
  };
2180
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
2180
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
2181
2181
 
2182
2182
  /**
2183
2183
  * Tool executor function type
2184
2184
  */
2185
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
2185
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
2186
2186
  /**
2187
2187
  * Tool configuration with optional executor
2188
2188
  */
@@ -2177,12 +2177,12 @@ type ToolCallArgumentsDeltaEvent = {
2177
2177
  argumentsDelta: string;
2178
2178
  accumulatedArguments: string;
2179
2179
  };
2180
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
2180
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
2181
2181
 
2182
2182
  /**
2183
2183
  * Tool executor function type
2184
2184
  */
2185
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
2185
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
2186
2186
  /**
2187
2187
  * Tool configuration with optional executor
2188
2188
  */
@@ -4351,6 +4351,12 @@ var ToolTimeoutError = class extends Error {
4351
4351
  this.name = "ToolTimeoutError";
4352
4352
  }
4353
4353
  };
4354
+ var ToolCancelledError = class extends Error {
4355
+ constructor() {
4356
+ super("Tool execution cancelled");
4357
+ this.name = "ToolCancelledError";
4358
+ }
4359
+ };
4354
4360
  function safeJsonStringify(value) {
4355
4361
  try {
4356
4362
  return JSON.stringify(value) ?? "null";
@@ -4358,7 +4364,7 @@ function safeJsonStringify(value) {
4358
4364
  return String(value);
4359
4365
  }
4360
4366
  }
4361
- async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS) {
4367
+ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS, signal) {
4362
4368
  let args = {};
4363
4369
  if (toolCall.arguments) {
4364
4370
  const parsed = parseToolArguments(toolCall.arguments);
@@ -4367,28 +4373,42 @@ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIM
4367
4373
  }
4368
4374
  args = parsed.args;
4369
4375
  }
4376
+ if (signal?.aborted) {
4377
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
4378
+ }
4379
+ let timer;
4380
+ let onAbort;
4370
4381
  try {
4371
- if (!isFinite(timeoutMs)) {
4372
- return { result: await executor(args) };
4382
+ const racers = [];
4383
+ if (signal) {
4384
+ racers.push(
4385
+ new Promise((_, reject) => {
4386
+ onAbort = () => reject(new ToolCancelledError());
4387
+ signal.addEventListener("abort", onAbort, { once: true });
4388
+ })
4389
+ );
4373
4390
  }
4374
- let timer;
4375
- try {
4376
- const result = await Promise.race([
4377
- executor(args),
4391
+ racers.push(Promise.resolve(signal ? executor(args, signal) : executor(args)));
4392
+ if (isFinite(timeoutMs)) {
4393
+ racers.push(
4378
4394
  new Promise((_, reject) => {
4379
4395
  timer = setTimeout(() => reject(new ToolTimeoutError()), timeoutMs);
4380
4396
  })
4381
- ]);
4382
- return { result };
4383
- } finally {
4384
- clearTimeout(timer);
4397
+ );
4385
4398
  }
4399
+ return { result: await Promise.race(racers) };
4386
4400
  } catch (e) {
4401
+ if (e instanceof ToolCancelledError) {
4402
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
4403
+ }
4387
4404
  const message = e instanceof Error ? e.message : String(e);
4388
4405
  return {
4389
4406
  error: `Tool execution failed: ${message}`,
4390
4407
  errorType: e instanceof ToolTimeoutError ? "timeout" : "execution"
4391
4408
  };
4409
+ } finally {
4410
+ clearTimeout(timer);
4411
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
4392
4412
  }
4393
4413
  }
4394
4414
  function toolsToApiFormat(tools, apiType) {
@@ -6744,11 +6764,12 @@ Executing tool: ${toolInfo}
6744
6764
  const blockedByFailure = failedDeps.some((d) => failedNames.has(d));
6745
6765
  const reason = blockedByFailure ? `failed dependencies: ${failedDeps.join(", ")}` : "a dependency cycle";
6746
6766
  const errorMsg = `Tool "${tc.name}" was not executed due to ${reason}`;
6767
+ const skipErrorType = combinedSignal?.aborted ? "cancelled" : "execution";
6747
6768
  executionResults.push({
6748
6769
  id: tc.id,
6749
6770
  name: tc.name,
6750
6771
  error: errorMsg,
6751
- errorType: "execution"
6772
+ errorType: skipErrorType
6752
6773
  });
6753
6774
  await safeAwait(
6754
6775
  () => hooks?.afterToolUse?.({
@@ -6757,7 +6778,7 @@ Executing tool: ${toolInfo}
6757
6778
  toolCallId: tc.id,
6758
6779
  name: tc.name,
6759
6780
  error: errorMsg,
6760
- errorType: "execution"
6781
+ errorType: skipErrorType
6761
6782
  })
6762
6783
  );
6763
6784
  }
@@ -6777,7 +6798,8 @@ Executing tool: ${toolInfo}
6777
6798
  const { result, error, errorType } = await executeToolCall(
6778
6799
  toolCallForExec,
6779
6800
  executorConfig.executor,
6780
- executorConfig.executorTimeout
6801
+ executorConfig.executorTimeout,
6802
+ combinedSignal
6781
6803
  );
6782
6804
  await safeAwait(
6783
6805
  () => hooks?.afterToolUse?.({
@@ -7841,6 +7863,7 @@ function useChat(options) {
7841
7863
  const abortControllerRef = useRef3(null);
7842
7864
  const detachControllerRef = useRef3(null);
7843
7865
  const pendingResumeRef = useRef3(null);
7866
+ const requestIdRef = useRef3(0);
7844
7867
  const fireCancel = useCallback3(
7845
7868
  (handle) => {
7846
7869
  const { inferenceId } = handle;
@@ -7969,6 +7992,8 @@ function useChat(options) {
7969
7992
  abortControllerRef.current = abortController;
7970
7993
  const detachController = new AbortController();
7971
7994
  detachControllerRef.current = detachController;
7995
+ const requestId = ++requestIdRef.current;
7996
+ const superseded = () => requestIdRef.current !== requestId;
7972
7997
  pendingResumeRef.current = null;
7973
7998
  setIsLoading(true);
7974
7999
  try {
@@ -8088,7 +8113,8 @@ function useChat(options) {
8088
8113
  piiRedaction: requestPiiRedaction ?? resolvedPiiRedaction,
8089
8114
  onPiiRedacted
8090
8115
  });
8091
- if ("detached" in result && result.detached && result.resume) {
8116
+ if (superseded()) {
8117
+ } else if ("detached" in result && result.detached && result.resume) {
8092
8118
  pendingResumeRef.current = result.resume;
8093
8119
  } else {
8094
8120
  pendingResumeRef.current = null;
@@ -8100,7 +8126,7 @@ function useChat(options) {
8100
8126
  onError
8101
8127
  );
8102
8128
  } finally {
8103
- setIsLoading(false);
8129
+ if (!superseded()) setIsLoading(false);
8104
8130
  if (abortControllerRef.current === abortController) {
8105
8131
  abortControllerRef.current = null;
8106
8132
  }
package/dist/index.d.mts CHANGED
@@ -7637,7 +7637,7 @@ declare function getImageModel(r: ApiResponse): string | undefined;
7637
7637
  /**
7638
7638
  * Tool executor function type
7639
7639
  */
7640
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
7640
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
7641
7641
  /**
7642
7642
  * Tool configuration with optional executor
7643
7643
  */
package/dist/index.d.ts CHANGED
@@ -7637,7 +7637,7 @@ declare function getImageModel(r: ApiResponse): string | undefined;
7637
7637
  /**
7638
7638
  * Tool executor function type
7639
7639
  */
7640
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
7640
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
7641
7641
  /**
7642
7642
  * Tool configuration with optional executor
7643
7643
  */
@@ -6344,6 +6344,12 @@ var ToolTimeoutError = class extends Error {
6344
6344
  this.name = "ToolTimeoutError";
6345
6345
  }
6346
6346
  };
6347
+ var ToolCancelledError = class extends Error {
6348
+ constructor() {
6349
+ super("Tool execution cancelled");
6350
+ this.name = "ToolCancelledError";
6351
+ }
6352
+ };
6347
6353
  function safeJsonStringify(value) {
6348
6354
  try {
6349
6355
  return JSON.stringify(value) ?? "null";
@@ -6351,7 +6357,7 @@ function safeJsonStringify(value) {
6351
6357
  return String(value);
6352
6358
  }
6353
6359
  }
6354
- async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS) {
6360
+ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS, signal) {
6355
6361
  let args = {};
6356
6362
  if (toolCall.arguments) {
6357
6363
  const parsed = parseToolArguments(toolCall.arguments);
@@ -6360,28 +6366,42 @@ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIM
6360
6366
  }
6361
6367
  args = parsed.args;
6362
6368
  }
6369
+ if (signal?.aborted) {
6370
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
6371
+ }
6372
+ let timer;
6373
+ let onAbort;
6363
6374
  try {
6364
- if (!isFinite(timeoutMs)) {
6365
- return { result: await executor(args) };
6375
+ const racers = [];
6376
+ if (signal) {
6377
+ racers.push(
6378
+ new Promise((_, reject) => {
6379
+ onAbort = () => reject(new ToolCancelledError());
6380
+ signal.addEventListener("abort", onAbort, { once: true });
6381
+ })
6382
+ );
6366
6383
  }
6367
- let timer;
6368
- try {
6369
- const result = await Promise.race([
6370
- executor(args),
6384
+ racers.push(Promise.resolve(signal ? executor(args, signal) : executor(args)));
6385
+ if (isFinite(timeoutMs)) {
6386
+ racers.push(
6371
6387
  new Promise((_, reject) => {
6372
6388
  timer = setTimeout(() => reject(new ToolTimeoutError()), timeoutMs);
6373
6389
  })
6374
- ]);
6375
- return { result };
6376
- } finally {
6377
- clearTimeout(timer);
6390
+ );
6378
6391
  }
6392
+ return { result: await Promise.race(racers) };
6379
6393
  } catch (e) {
6394
+ if (e instanceof ToolCancelledError) {
6395
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
6396
+ }
6380
6397
  const message = e instanceof Error ? e.message : String(e);
6381
6398
  return {
6382
6399
  error: `Tool execution failed: ${message}`,
6383
6400
  errorType: e instanceof ToolTimeoutError ? "timeout" : "execution"
6384
6401
  };
6402
+ } finally {
6403
+ clearTimeout(timer);
6404
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
6385
6405
  }
6386
6406
  }
6387
6407
  function toolsToApiFormat(tools, apiType) {
@@ -8737,11 +8757,12 @@ Executing tool: ${toolInfo}
8737
8757
  const blockedByFailure = failedDeps.some((d) => failedNames.has(d));
8738
8758
  const reason = blockedByFailure ? `failed dependencies: ${failedDeps.join(", ")}` : "a dependency cycle";
8739
8759
  const errorMsg = `Tool "${tc.name}" was not executed due to ${reason}`;
8760
+ const skipErrorType = combinedSignal?.aborted ? "cancelled" : "execution";
8740
8761
  executionResults.push({
8741
8762
  id: tc.id,
8742
8763
  name: tc.name,
8743
8764
  error: errorMsg,
8744
- errorType: "execution"
8765
+ errorType: skipErrorType
8745
8766
  });
8746
8767
  await safeAwait(
8747
8768
  () => hooks?.afterToolUse?.({
@@ -8750,7 +8771,7 @@ Executing tool: ${toolInfo}
8750
8771
  toolCallId: tc.id,
8751
8772
  name: tc.name,
8752
8773
  error: errorMsg,
8753
- errorType: "execution"
8774
+ errorType: skipErrorType
8754
8775
  })
8755
8776
  );
8756
8777
  }
@@ -8770,7 +8791,8 @@ Executing tool: ${toolInfo}
8770
8791
  const { result, error, errorType } = await executeToolCall(
8771
8792
  toolCallForExec,
8772
8793
  executorConfig.executor,
8773
- executorConfig.executorTimeout
8794
+ executorConfig.executorTimeout,
8795
+ combinedSignal
8774
8796
  );
8775
8797
  await safeAwait(
8776
8798
  () => hooks?.afterToolUse?.({
@@ -9406,6 +9428,7 @@ function useChat(options) {
9406
9428
  } = options || {};
9407
9429
  const [isLoading, setIsLoading] = (0, import_react.useState)(false);
9408
9430
  const abortControllerRef = (0, import_react.useRef)(null);
9431
+ const requestIdRef = (0, import_react.useRef)(0);
9409
9432
  const piiRedactorRef = (0, import_react.useRef)(null);
9410
9433
  if (piiRedaction === true && !piiRedactorRef.current) {
9411
9434
  piiRedactorRef.current = new PiiRedactor();
@@ -9455,6 +9478,7 @@ function useChat(options) {
9455
9478
  }
9456
9479
  const abortController = new AbortController();
9457
9480
  abortControllerRef.current = abortController;
9481
+ const requestId = ++requestIdRef.current;
9458
9482
  setIsLoading(true);
9459
9483
  try {
9460
9484
  const tokenGetterValidation = validateTokenGetter(getToken);
@@ -9554,8 +9578,8 @@ function useChat(options) {
9554
9578
  onError
9555
9579
  );
9556
9580
  } finally {
9557
- setIsLoading(false);
9558
- if (abortControllerRef.current === abortController) {
9581
+ if (requestIdRef.current === requestId) {
9582
+ setIsLoading(false);
9559
9583
  abortControllerRef.current = null;
9560
9584
  }
9561
9585
  }
@@ -2106,12 +2106,12 @@ type ToolCallArgumentsDeltaEvent = {
2106
2106
  argumentsDelta: string;
2107
2107
  accumulatedArguments: string;
2108
2108
  };
2109
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
2109
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
2110
2110
 
2111
2111
  /**
2112
2112
  * Tool executor function type
2113
2113
  */
2114
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
2114
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
2115
2115
  /**
2116
2116
  * Tool configuration with optional executor
2117
2117
  */
@@ -2106,12 +2106,12 @@ type ToolCallArgumentsDeltaEvent = {
2106
2106
  argumentsDelta: string;
2107
2107
  accumulatedArguments: string;
2108
2108
  };
2109
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
2109
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
2110
2110
 
2111
2111
  /**
2112
2112
  * Tool executor function type
2113
2113
  */
2114
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
2114
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
2115
2115
  /**
2116
2116
  * Tool configuration with optional executor
2117
2117
  */
@@ -4480,6 +4480,12 @@ var ToolTimeoutError = class extends Error {
4480
4480
  this.name = "ToolTimeoutError";
4481
4481
  }
4482
4482
  };
4483
+ var ToolCancelledError = class extends Error {
4484
+ constructor() {
4485
+ super("Tool execution cancelled");
4486
+ this.name = "ToolCancelledError";
4487
+ }
4488
+ };
4483
4489
  function safeJsonStringify(value) {
4484
4490
  try {
4485
4491
  return JSON.stringify(value) ?? "null";
@@ -4487,7 +4493,7 @@ function safeJsonStringify(value) {
4487
4493
  return String(value);
4488
4494
  }
4489
4495
  }
4490
- async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS) {
4496
+ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS, signal) {
4491
4497
  let args = {};
4492
4498
  if (toolCall.arguments) {
4493
4499
  const parsed = parseToolArguments(toolCall.arguments);
@@ -4496,28 +4502,42 @@ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIM
4496
4502
  }
4497
4503
  args = parsed.args;
4498
4504
  }
4505
+ if (signal?.aborted) {
4506
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
4507
+ }
4508
+ let timer;
4509
+ let onAbort;
4499
4510
  try {
4500
- if (!isFinite(timeoutMs)) {
4501
- return { result: await executor(args) };
4511
+ const racers = [];
4512
+ if (signal) {
4513
+ racers.push(
4514
+ new Promise((_, reject) => {
4515
+ onAbort = () => reject(new ToolCancelledError());
4516
+ signal.addEventListener("abort", onAbort, { once: true });
4517
+ })
4518
+ );
4502
4519
  }
4503
- let timer;
4504
- try {
4505
- const result = await Promise.race([
4506
- executor(args),
4520
+ racers.push(Promise.resolve(signal ? executor(args, signal) : executor(args)));
4521
+ if (isFinite(timeoutMs)) {
4522
+ racers.push(
4507
4523
  new Promise((_, reject) => {
4508
4524
  timer = setTimeout(() => reject(new ToolTimeoutError()), timeoutMs);
4509
4525
  })
4510
- ]);
4511
- return { result };
4512
- } finally {
4513
- clearTimeout(timer);
4526
+ );
4514
4527
  }
4528
+ return { result: await Promise.race(racers) };
4515
4529
  } catch (e) {
4530
+ if (e instanceof ToolCancelledError) {
4531
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
4532
+ }
4516
4533
  const message = e instanceof Error ? e.message : String(e);
4517
4534
  return {
4518
4535
  error: `Tool execution failed: ${message}`,
4519
4536
  errorType: e instanceof ToolTimeoutError ? "timeout" : "execution"
4520
4537
  };
4538
+ } finally {
4539
+ clearTimeout(timer);
4540
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
4521
4541
  }
4522
4542
  }
4523
4543
  function toolsToApiFormat(tools, apiType) {
@@ -6873,11 +6893,12 @@ Executing tool: ${toolInfo}
6873
6893
  const blockedByFailure = failedDeps.some((d) => failedNames.has(d));
6874
6894
  const reason = blockedByFailure ? `failed dependencies: ${failedDeps.join(", ")}` : "a dependency cycle";
6875
6895
  const errorMsg = `Tool "${tc.name}" was not executed due to ${reason}`;
6896
+ const skipErrorType = combinedSignal?.aborted ? "cancelled" : "execution";
6876
6897
  executionResults.push({
6877
6898
  id: tc.id,
6878
6899
  name: tc.name,
6879
6900
  error: errorMsg,
6880
- errorType: "execution"
6901
+ errorType: skipErrorType
6881
6902
  });
6882
6903
  await safeAwait(
6883
6904
  () => hooks?.afterToolUse?.({
@@ -6886,7 +6907,7 @@ Executing tool: ${toolInfo}
6886
6907
  toolCallId: tc.id,
6887
6908
  name: tc.name,
6888
6909
  error: errorMsg,
6889
- errorType: "execution"
6910
+ errorType: skipErrorType
6890
6911
  })
6891
6912
  );
6892
6913
  }
@@ -6906,7 +6927,8 @@ Executing tool: ${toolInfo}
6906
6927
  const { result, error, errorType } = await executeToolCall(
6907
6928
  toolCallForExec,
6908
6929
  executorConfig.executor,
6909
- executorConfig.executorTimeout
6930
+ executorConfig.executorTimeout,
6931
+ combinedSignal
6910
6932
  );
6911
6933
  await safeAwait(
6912
6934
  () => hooks?.afterToolUse?.({
@@ -7540,6 +7562,7 @@ function useChat(options) {
7540
7562
  } = options || {};
7541
7563
  const [isLoading, setIsLoading] = useState(false);
7542
7564
  const abortControllerRef = useRef(null);
7565
+ const requestIdRef = useRef(0);
7543
7566
  const piiRedactorRef = useRef(null);
7544
7567
  if (piiRedaction === true && !piiRedactorRef.current) {
7545
7568
  piiRedactorRef.current = new PiiRedactor();
@@ -7589,6 +7612,7 @@ function useChat(options) {
7589
7612
  }
7590
7613
  const abortController = new AbortController();
7591
7614
  abortControllerRef.current = abortController;
7615
+ const requestId = ++requestIdRef.current;
7592
7616
  setIsLoading(true);
7593
7617
  try {
7594
7618
  const tokenGetterValidation = validateTokenGetter(getToken);
@@ -7688,8 +7712,8 @@ function useChat(options) {
7688
7712
  onError
7689
7713
  );
7690
7714
  } finally {
7691
- setIsLoading(false);
7692
- if (abortControllerRef.current === abortController) {
7715
+ if (requestIdRef.current === requestId) {
7716
+ setIsLoading(false);
7693
7717
  abortControllerRef.current = null;
7694
7718
  }
7695
7719
  }
@@ -35383,6 +35383,12 @@ var ToolTimeoutError = class extends Error {
35383
35383
  this.name = "ToolTimeoutError";
35384
35384
  }
35385
35385
  };
35386
+ var ToolCancelledError = class extends Error {
35387
+ constructor() {
35388
+ super("Tool execution cancelled");
35389
+ this.name = "ToolCancelledError";
35390
+ }
35391
+ };
35386
35392
  function safeJsonStringify(value) {
35387
35393
  try {
35388
35394
  return JSON.stringify(value) ?? "null";
@@ -35390,7 +35396,7 @@ function safeJsonStringify(value) {
35390
35396
  return String(value);
35391
35397
  }
35392
35398
  }
35393
- async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS) {
35399
+ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS, signal) {
35394
35400
  let args = {};
35395
35401
  if (toolCall.arguments) {
35396
35402
  const parsed = parseToolArguments(toolCall.arguments);
@@ -35399,28 +35405,42 @@ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIM
35399
35405
  }
35400
35406
  args = parsed.args;
35401
35407
  }
35408
+ if (signal?.aborted) {
35409
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
35410
+ }
35411
+ let timer;
35412
+ let onAbort;
35402
35413
  try {
35403
- if (!isFinite(timeoutMs)) {
35404
- return { result: await executor(args) };
35414
+ const racers = [];
35415
+ if (signal) {
35416
+ racers.push(
35417
+ new Promise((_, reject) => {
35418
+ onAbort = () => reject(new ToolCancelledError());
35419
+ signal.addEventListener("abort", onAbort, { once: true });
35420
+ })
35421
+ );
35405
35422
  }
35406
- let timer;
35407
- try {
35408
- const result = await Promise.race([
35409
- executor(args),
35423
+ racers.push(Promise.resolve(signal ? executor(args, signal) : executor(args)));
35424
+ if (isFinite(timeoutMs)) {
35425
+ racers.push(
35410
35426
  new Promise((_, reject) => {
35411
35427
  timer = setTimeout(() => reject(new ToolTimeoutError()), timeoutMs);
35412
35428
  })
35413
- ]);
35414
- return { result };
35415
- } finally {
35416
- clearTimeout(timer);
35429
+ );
35417
35430
  }
35431
+ return { result: await Promise.race(racers) };
35418
35432
  } catch (e) {
35433
+ if (e instanceof ToolCancelledError) {
35434
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
35435
+ }
35419
35436
  const message = e instanceof Error ? e.message : String(e);
35420
35437
  return {
35421
35438
  error: `Tool execution failed: ${message}`,
35422
35439
  errorType: e instanceof ToolTimeoutError ? "timeout" : "execution"
35423
35440
  };
35441
+ } finally {
35442
+ clearTimeout(timer);
35443
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
35424
35444
  }
35425
35445
  }
35426
35446
  function toolsToApiFormat(tools, apiType) {
@@ -37776,11 +37796,12 @@ Executing tool: ${toolInfo}
37776
37796
  const blockedByFailure = failedDeps.some((d) => failedNames.has(d));
37777
37797
  const reason = blockedByFailure ? `failed dependencies: ${failedDeps.join(", ")}` : "a dependency cycle";
37778
37798
  const errorMsg = `Tool "${tc.name}" was not executed due to ${reason}`;
37799
+ const skipErrorType = combinedSignal?.aborted ? "cancelled" : "execution";
37779
37800
  executionResults.push({
37780
37801
  id: tc.id,
37781
37802
  name: tc.name,
37782
37803
  error: errorMsg,
37783
- errorType: "execution"
37804
+ errorType: skipErrorType
37784
37805
  });
37785
37806
  await safeAwait(
37786
37807
  () => hooks?.afterToolUse?.({
@@ -37789,7 +37810,7 @@ Executing tool: ${toolInfo}
37789
37810
  toolCallId: tc.id,
37790
37811
  name: tc.name,
37791
37812
  error: errorMsg,
37792
- errorType: "execution"
37813
+ errorType: skipErrorType
37793
37814
  })
37794
37815
  );
37795
37816
  }
@@ -37809,7 +37830,8 @@ Executing tool: ${toolInfo}
37809
37830
  const { result, error, errorType } = await executeToolCall(
37810
37831
  toolCallForExec,
37811
37832
  executorConfig.executor,
37812
- executorConfig.executorTimeout
37833
+ executorConfig.executorTimeout,
37834
+ combinedSignal
37813
37835
  );
37814
37836
  await safeAwait(
37815
37837
  () => hooks?.afterToolUse?.({
@@ -2093,7 +2093,7 @@ type ToolUseEndEvent = {
2093
2093
  name: string;
2094
2094
  result?: unknown;
2095
2095
  error?: string;
2096
- errorType?: "parse" | "timeout" | "execution";
2096
+ errorType?: "parse" | "timeout" | "execution" | "cancelled";
2097
2097
  };
2098
2098
  type RunStartEvent = {
2099
2099
  runId: string;
@@ -2219,7 +2219,7 @@ type ToolCallArgumentsDeltaEvent = {
2219
2219
  argumentsDelta: string;
2220
2220
  accumulatedArguments: string;
2221
2221
  };
2222
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
2222
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
2223
2223
 
2224
2224
  /** A tool result from an auto-executed tool. */
2225
2225
  type AutoExecutedToolResult = {
@@ -2679,7 +2679,7 @@ declare function runToolLoop(options: RunToolLoopOptions): Promise<RunToolLoopRe
2679
2679
  /**
2680
2680
  * Tool executor function type
2681
2681
  */
2682
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
2682
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
2683
2683
  /**
2684
2684
  * Tool configuration with optional executor
2685
2685
  */
@@ -2093,7 +2093,7 @@ type ToolUseEndEvent = {
2093
2093
  name: string;
2094
2094
  result?: unknown;
2095
2095
  error?: string;
2096
- errorType?: "parse" | "timeout" | "execution";
2096
+ errorType?: "parse" | "timeout" | "execution" | "cancelled";
2097
2097
  };
2098
2098
  type RunStartEvent = {
2099
2099
  runId: string;
@@ -2219,7 +2219,7 @@ type ToolCallArgumentsDeltaEvent = {
2219
2219
  argumentsDelta: string;
2220
2220
  accumulatedArguments: string;
2221
2221
  };
2222
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
2222
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
2223
2223
 
2224
2224
  /** A tool result from an auto-executed tool. */
2225
2225
  type AutoExecutedToolResult = {
@@ -2679,7 +2679,7 @@ declare function runToolLoop(options: RunToolLoopOptions): Promise<RunToolLoopRe
2679
2679
  /**
2680
2680
  * Tool executor function type
2681
2681
  */
2682
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
2682
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
2683
2683
  /**
2684
2684
  * Tool configuration with optional executor
2685
2685
  */
@@ -33629,6 +33629,12 @@ var ToolTimeoutError = class extends Error {
33629
33629
  this.name = "ToolTimeoutError";
33630
33630
  }
33631
33631
  };
33632
+ var ToolCancelledError = class extends Error {
33633
+ constructor() {
33634
+ super("Tool execution cancelled");
33635
+ this.name = "ToolCancelledError";
33636
+ }
33637
+ };
33632
33638
  function safeJsonStringify(value) {
33633
33639
  try {
33634
33640
  return JSON.stringify(value) ?? "null";
@@ -33636,7 +33642,7 @@ function safeJsonStringify(value) {
33636
33642
  return String(value);
33637
33643
  }
33638
33644
  }
33639
- async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS) {
33645
+ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIMEOUT_MS, signal) {
33640
33646
  let args = {};
33641
33647
  if (toolCall.arguments) {
33642
33648
  const parsed = parseToolArguments(toolCall.arguments);
@@ -33645,28 +33651,42 @@ async function executeToolCall(toolCall, executor, timeoutMs = TOOL_EXECUTOR_TIM
33645
33651
  }
33646
33652
  args = parsed.args;
33647
33653
  }
33654
+ if (signal?.aborted) {
33655
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
33656
+ }
33657
+ let timer;
33658
+ let onAbort;
33648
33659
  try {
33649
- if (!isFinite(timeoutMs)) {
33650
- return { result: await executor(args) };
33660
+ const racers = [];
33661
+ if (signal) {
33662
+ racers.push(
33663
+ new Promise((_, reject) => {
33664
+ onAbort = () => reject(new ToolCancelledError());
33665
+ signal.addEventListener("abort", onAbort, { once: true });
33666
+ })
33667
+ );
33651
33668
  }
33652
- let timer;
33653
- try {
33654
- const result = await Promise.race([
33655
- executor(args),
33669
+ racers.push(Promise.resolve(signal ? executor(args, signal) : executor(args)));
33670
+ if (isFinite(timeoutMs)) {
33671
+ racers.push(
33656
33672
  new Promise((_, reject) => {
33657
33673
  timer = setTimeout(() => reject(new ToolTimeoutError()), timeoutMs);
33658
33674
  })
33659
- ]);
33660
- return { result };
33661
- } finally {
33662
- clearTimeout(timer);
33675
+ );
33663
33676
  }
33677
+ return { result: await Promise.race(racers) };
33664
33678
  } catch (e) {
33679
+ if (e instanceof ToolCancelledError) {
33680
+ return { error: "Tool execution cancelled", errorType: "cancelled" };
33681
+ }
33665
33682
  const message = e instanceof Error ? e.message : String(e);
33666
33683
  return {
33667
33684
  error: `Tool execution failed: ${message}`,
33668
33685
  errorType: e instanceof ToolTimeoutError ? "timeout" : "execution"
33669
33686
  };
33687
+ } finally {
33688
+ clearTimeout(timer);
33689
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
33670
33690
  }
33671
33691
  }
33672
33692
  function toolsToApiFormat(tools, apiType) {
@@ -36022,11 +36042,12 @@ Executing tool: ${toolInfo}
36022
36042
  const blockedByFailure = failedDeps.some((d) => failedNames.has(d));
36023
36043
  const reason = blockedByFailure ? `failed dependencies: ${failedDeps.join(", ")}` : "a dependency cycle";
36024
36044
  const errorMsg = `Tool "${tc.name}" was not executed due to ${reason}`;
36045
+ const skipErrorType = combinedSignal?.aborted ? "cancelled" : "execution";
36025
36046
  executionResults.push({
36026
36047
  id: tc.id,
36027
36048
  name: tc.name,
36028
36049
  error: errorMsg,
36029
- errorType: "execution"
36050
+ errorType: skipErrorType
36030
36051
  });
36031
36052
  await safeAwait(
36032
36053
  () => hooks?.afterToolUse?.({
@@ -36035,7 +36056,7 @@ Executing tool: ${toolInfo}
36035
36056
  toolCallId: tc.id,
36036
36057
  name: tc.name,
36037
36058
  error: errorMsg,
36038
- errorType: "execution"
36059
+ errorType: skipErrorType
36039
36060
  })
36040
36061
  );
36041
36062
  }
@@ -36055,7 +36076,8 @@ Executing tool: ${toolInfo}
36055
36076
  const { result, error, errorType } = await executeToolCall(
36056
36077
  toolCallForExec,
36057
36078
  executorConfig.executor,
36058
- executorConfig.executorTimeout
36079
+ executorConfig.executorTimeout,
36080
+ combinedSignal
36059
36081
  );
36060
36082
  await safeAwait(
36061
36083
  () => hooks?.afterToolUse?.({
@@ -147,7 +147,7 @@ type ToolUseEndEvent = {
147
147
  name: string;
148
148
  result?: unknown;
149
149
  error?: string;
150
- errorType?: "parse" | "timeout" | "execution";
150
+ errorType?: "parse" | "timeout" | "execution" | "cancelled";
151
151
  };
152
152
  type RunStartEvent = {
153
153
  runId: string;
@@ -147,7 +147,7 @@ type ToolUseEndEvent = {
147
147
  name: string;
148
148
  result?: unknown;
149
149
  error?: string;
150
- errorType?: "parse" | "timeout" | "execution";
150
+ errorType?: "parse" | "timeout" | "execution" | "cancelled";
151
151
  };
152
152
  type RunStartEvent = {
153
153
  runId: string;
@@ -515,7 +515,7 @@ function createInteractiveTool(options, config) {
515
515
  description: config.description,
516
516
  arguments: config.parameters
517
517
  },
518
- executor: async (args) => {
518
+ executor: async (args, signal) => {
519
519
  if (config.validate && !config.validate(args)) {
520
520
  return { cancelled: true };
521
521
  }
@@ -525,6 +525,8 @@ function createInteractiveTool(options, config) {
525
525
  }
526
526
  const interactionId = generateInteractionId(config.interactionType);
527
527
  const interactionData = config.mapArgs ? config.mapArgs(args) : args;
528
+ const onAbort = () => context.cancelInteraction?.(interactionId);
529
+ signal?.addEventListener("abort", onAbort, { once: true });
528
530
  try {
529
531
  const result = await context.createInteraction(interactionId, config.interactionType, {
530
532
  ...interactionData,
@@ -536,6 +538,8 @@ function createInteractiveTool(options, config) {
536
538
  return result;
537
539
  } catch {
538
540
  return { cancelled: true };
541
+ } finally {
542
+ signal?.removeEventListener("abort", onAbort);
539
543
  }
540
544
  },
541
545
  // Interactive tools wait for user input and should not be subject
@@ -2,7 +2,7 @@ type LlmapiChatCompletionTool = {
2
2
  [key: string]: unknown;
3
3
  };
4
4
 
5
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
5
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
6
6
  type ToolExecutionResult = {
7
7
  result?: unknown;
8
8
  error?: string;
@@ -13,7 +13,7 @@ type ToolExecutionResult = {
13
13
  /**
14
14
  * Tool executor function type
15
15
  */
16
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
16
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
17
17
  /**
18
18
  * Tool configuration with optional executor
19
19
  */
@@ -140,6 +140,8 @@ declare function createChatTools(getAccessToken: () => string | null, requestCal
140
140
  */
141
141
  type UIInteractionContext = {
142
142
  createInteraction: (id: string, type: string, data: unknown) => Promise<unknown>;
143
+ /** Rejects and removes a pending interaction. Optional for older contexts. */
144
+ cancelInteraction?: (id: string) => void;
143
145
  createDisplayInteraction: (id: string, displayType: string, data: unknown, result: unknown, toolVersion?: number, replacesInteractionId?: string) => void;
144
146
  };
145
147
  /**
@@ -2,7 +2,7 @@ type LlmapiChatCompletionTool = {
2
2
  [key: string]: unknown;
3
3
  };
4
4
 
5
- type ToolExecutionErrorType = "parse" | "timeout" | "execution";
5
+ type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
6
6
  type ToolExecutionResult = {
7
7
  result?: unknown;
8
8
  error?: string;
@@ -13,7 +13,7 @@ type ToolExecutionResult = {
13
13
  /**
14
14
  * Tool executor function type
15
15
  */
16
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
16
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
17
17
  /**
18
18
  * Tool configuration with optional executor
19
19
  */
@@ -140,6 +140,8 @@ declare function createChatTools(getAccessToken: () => string | null, requestCal
140
140
  */
141
141
  type UIInteractionContext = {
142
142
  createInteraction: (id: string, type: string, data: unknown) => Promise<unknown>;
143
+ /** Rejects and removes a pending interaction. Optional for older contexts. */
144
+ cancelInteraction?: (id: string) => void;
143
145
  createDisplayInteraction: (id: string, displayType: string, data: unknown, result: unknown, toolVersion?: number, replacesInteractionId?: string) => void;
144
146
  };
145
147
  /**
@@ -359,7 +359,7 @@ function createInteractiveTool(options, config) {
359
359
  description: config.description,
360
360
  arguments: config.parameters
361
361
  },
362
- executor: async (args) => {
362
+ executor: async (args, signal) => {
363
363
  if (config.validate && !config.validate(args)) {
364
364
  return { cancelled: true };
365
365
  }
@@ -369,6 +369,8 @@ function createInteractiveTool(options, config) {
369
369
  }
370
370
  const interactionId = generateInteractionId(config.interactionType);
371
371
  const interactionData = config.mapArgs ? config.mapArgs(args) : args;
372
+ const onAbort = () => context.cancelInteraction?.(interactionId);
373
+ signal?.addEventListener("abort", onAbort, { once: true });
372
374
  try {
373
375
  const result = await context.createInteraction(interactionId, config.interactionType, {
374
376
  ...interactionData,
@@ -380,6 +382,8 @@ function createInteractiveTool(options, config) {
380
382
  return result;
381
383
  } catch {
382
384
  return { cancelled: true };
385
+ } finally {
386
+ signal?.removeEventListener("abort", onAbort);
383
387
  }
384
388
  },
385
389
  // Interactive tools wait for user input and should not be subject
@@ -5,7 +5,7 @@ type LlmapiChatCompletionTool = {
5
5
  /**
6
6
  * Tool executor function type
7
7
  */
8
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
8
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
9
9
  /**
10
10
  * Tool configuration with optional executor
11
11
  */
@@ -5,7 +5,7 @@ type LlmapiChatCompletionTool = {
5
5
  /**
6
6
  * Tool executor function type
7
7
  */
8
- type ToolExecutor = (args: Record<string, unknown>) => Promise<unknown> | unknown;
8
+ type ToolExecutor = (args: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown> | unknown;
9
9
  /**
10
10
  * Tool configuration with optional executor
11
11
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.27.7",
3
+ "version": "6.27.9",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",