@dudousxd/nestjs-agent-react 0.28.0 → 0.29.0

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.
package/README.md CHANGED
@@ -305,6 +305,46 @@ A refused settlement (403 "not your thread" or "not your approval", 410 "expired
305
305
  `call.error` with the affordance still live, rather than escaping as an unhandled rejection. Render
306
306
  it — a button that silently does nothing is indistinguishable from a broken one.
307
307
 
308
+ ### When a run fails
309
+
310
+ The server closes a failed run's stream with `event: error` + `{ code, message }`. `chat.error`
311
+ carries the message; `chat.runError` carries the whole frame — `{ code, message, runId? }`, `null`
312
+ again once the next attempt starts — so the app words each failure itself. The library renders
313
+ nothing for it:
314
+
315
+ ```tsx
316
+ import { isRunNotActiveError } from '@dudousxd/nestjs-agent-react';
317
+
318
+ const FRIENDLY: Record<string, string> = {
319
+ replay_diverged: 'This answer was interrupted by an update. Send your message again.',
320
+ model_no_output: 'The model returned nothing. Try again.',
321
+ run_failed: 'Something went wrong on our side. Try again.',
322
+ };
323
+
324
+ {chat.runError && <p role="alert">{FRIENDLY[chat.runError.code ?? ''] ?? chat.runError.message}</p>}
325
+ ```
326
+
327
+ `AGENT_RUN_ERROR_CODES` lists the codes this library's loop sends (`quota_exceeded`,
328
+ `output_rejected`, `structured_output_invalid`, `replay_diverged`, `model_no_output`, `run_failed`).
329
+ In production the `message` of the last three is one generic sentence — the error itself stays in
330
+ the server's log.
331
+
332
+ A failed turn leaves its thread usable: the next send starts a new turn. What it cannot do is
333
+ answer a card the dead turn left on screen. `approve` / `reject` / `answer` / `skip` on one reject
334
+ with an `AgentHttpError` whose `status` is `409` and `code` is `run_not_active`:
335
+
336
+ ```tsx
337
+ try {
338
+ await chat.approve({ toolCallId });
339
+ } catch (error) {
340
+ if (isRunNotActiveError(error)) showStale('This request expired with its turn — send it again.');
341
+ else throw error;
342
+ }
343
+ ```
344
+
345
+ On the transcript model the same refusal is `call.errorCode === 'run_not_active'` (and
346
+ `elicitation.errorCode`) next to `call.error`, the server's message.
347
+
308
348
  ### Completing as you type
309
349
 
310
350
  `useComposerAutocomplete` is the state machine behind a `/`-style menu in the composer. It is
@@ -436,4 +436,4 @@ declare class AgentClient implements AgentBackend {
436
436
  private handleResponse;
437
437
  }
438
438
 
439
- export { type AgentBackend as A, type CancelResult as C, type ErrorAnswer as E, type HttpErrorListener as H, type MessageFeedbackInput as M, type QueuedMessageUpdate as Q, type ResumeStreamRequest as R, type ThreadPatch as T, type UploadAttachmentOptions as U, type AttachmentUploadStrategy as a, AgentBackendUnsupportedError as b, AgentClient as c, type AgentClientOptions as d, type AgentConnection as e, AgentHttpError as f, type AgentRequestError as g, type ChatStreamRequest as h, type ChatStreamResponse as i, type QueuedSendResult as j, requireBackendMethod as r };
439
+ export { type AgentRequestError as A, type CancelResult as C, type ErrorAnswer as E, type HttpErrorListener as H, type MessageFeedbackInput as M, type QueuedMessageUpdate as Q, type ResumeStreamRequest as R, type ThreadPatch as T, type UploadAttachmentOptions as U, type AgentBackend as a, type AttachmentUploadStrategy as b, AgentBackendUnsupportedError as c, AgentClient as d, type AgentClientOptions as e, type AgentConnection as f, AgentHttpError as g, type ChatStreamRequest as h, type ChatStreamResponse as i, type QueuedSendResult as j, requireBackendMethod as r };
@@ -436,4 +436,4 @@ declare class AgentClient implements AgentBackend {
436
436
  private handleResponse;
437
437
  }
438
438
 
439
- export { type AgentBackend as A, type CancelResult as C, type ErrorAnswer as E, type HttpErrorListener as H, type MessageFeedbackInput as M, type QueuedMessageUpdate as Q, type ResumeStreamRequest as R, type ThreadPatch as T, type UploadAttachmentOptions as U, type AttachmentUploadStrategy as a, AgentBackendUnsupportedError as b, AgentClient as c, type AgentClientOptions as d, type AgentConnection as e, AgentHttpError as f, type AgentRequestError as g, type ChatStreamRequest as h, type ChatStreamResponse as i, type QueuedSendResult as j, requireBackendMethod as r };
439
+ export { type AgentRequestError as A, type CancelResult as C, type ErrorAnswer as E, type HttpErrorListener as H, type MessageFeedbackInput as M, type QueuedMessageUpdate as Q, type ResumeStreamRequest as R, type ThreadPatch as T, type UploadAttachmentOptions as U, type AgentBackend as a, type AttachmentUploadStrategy as b, AgentBackendUnsupportedError as c, AgentClient as d, type AgentClientOptions as e, type AgentConnection as f, AgentHttpError as g, type ChatStreamRequest as h, type ChatStreamResponse as i, type QueuedSendResult as j, requireBackendMethod as r };
@@ -329,6 +329,12 @@ interface TranscriptToolCall {
329
329
  reject: TranscriptSettleState;
330
330
  /** A failed decision — the call is still parked, so the affordance stays live. */
331
331
  error: string | null;
332
+ /**
333
+ * The server's machine-readable reason for {@link error}, when it gave one. `run_not_active`
334
+ * means the turn that asked has ended: nothing is waiting for the decision, and pressing again
335
+ * will be refused again — word it yourself and let the person send the message again.
336
+ */
337
+ errorCode: string | null;
332
338
  }
333
339
  /**
334
340
  * A run of CONSECUTIVE tool parts, grouped so a UI can collapse "5 tools ran" into one affordance.
@@ -452,6 +458,8 @@ interface TranscriptElicitationBlock {
452
458
  outcome: TranscriptElicitationOutcome | null;
453
459
  /** A failed submission — the run is still parked, so the form stays live. */
454
460
  error: string | null;
461
+ /** The server's machine-readable reason for {@link error} (`run_not_active`, …), when it gave one. */
462
+ errorCode: string | null;
455
463
  answer: TranscriptSettleState;
456
464
  skip: TranscriptSettleState;
457
465
  }
@@ -501,6 +509,8 @@ interface ElicitationBlockOptions {
501
509
  /** Which decision this call is sending, or `null` for none. */
502
510
  submitting: (toolCallId: string) => SettleAction | null;
503
511
  errorOf: (toolCallId: string) => string | null;
512
+ /** The `code` of the error `errorOf` reports, when the server sent one. */
513
+ errorCodeOf?: (toolCallId: string) => string | null;
504
514
  }
505
515
  /** Where an approval decision is sent, and what the last one did. */
506
516
  interface ApprovalBlockOptions {
@@ -511,6 +521,8 @@ interface ApprovalBlockOptions {
511
521
  /** Which decision this call is sending, or `null` for none. */
512
522
  submitting: (toolCallId: string) => SettleAction | null;
513
523
  errorOf: (toolCallId: string) => string | null;
524
+ /** The `code` of the error `errorOf` reports, when the server sent one. */
525
+ errorCodeOf?: (toolCallId: string) => string | null;
514
526
  }
515
527
  interface BuildBlocksOptions {
516
528
  /** Disclosure lookup for a reasoning run; `isStreaming` is the fallback when untouched. */
@@ -329,6 +329,12 @@ interface TranscriptToolCall {
329
329
  reject: TranscriptSettleState;
330
330
  /** A failed decision — the call is still parked, so the affordance stays live. */
331
331
  error: string | null;
332
+ /**
333
+ * The server's machine-readable reason for {@link error}, when it gave one. `run_not_active`
334
+ * means the turn that asked has ended: nothing is waiting for the decision, and pressing again
335
+ * will be refused again — word it yourself and let the person send the message again.
336
+ */
337
+ errorCode: string | null;
332
338
  }
333
339
  /**
334
340
  * A run of CONSECUTIVE tool parts, grouped so a UI can collapse "5 tools ran" into one affordance.
@@ -452,6 +458,8 @@ interface TranscriptElicitationBlock {
452
458
  outcome: TranscriptElicitationOutcome | null;
453
459
  /** A failed submission — the run is still parked, so the form stays live. */
454
460
  error: string | null;
461
+ /** The server's machine-readable reason for {@link error} (`run_not_active`, …), when it gave one. */
462
+ errorCode: string | null;
455
463
  answer: TranscriptSettleState;
456
464
  skip: TranscriptSettleState;
457
465
  }
@@ -501,6 +509,8 @@ interface ElicitationBlockOptions {
501
509
  /** Which decision this call is sending, or `null` for none. */
502
510
  submitting: (toolCallId: string) => SettleAction | null;
503
511
  errorOf: (toolCallId: string) => string | null;
512
+ /** The `code` of the error `errorOf` reports, when the server sent one. */
513
+ errorCodeOf?: (toolCallId: string) => string | null;
504
514
  }
505
515
  /** Where an approval decision is sent, and what the last one did. */
506
516
  interface ApprovalBlockOptions {
@@ -511,6 +521,8 @@ interface ApprovalBlockOptions {
511
521
  /** Which decision this call is sending, or `null` for none. */
512
522
  submitting: (toolCallId: string) => SettleAction | null;
513
523
  errorOf: (toolCallId: string) => string | null;
524
+ /** The `code` of the error `errorOf` reports, when the server sent one. */
525
+ errorCodeOf?: (toolCallId: string) => string | null;
514
526
  }
515
527
  interface BuildBlocksOptions {
516
528
  /** Disclosure lookup for a reasoning run; `isStreaming` is the fallback when untouched. */
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentRegistry } from '@json-render/react';
3
- import { n as GenuiProviderProps$1, c as GenerativeUIElement, q as GenuiRenderer, p as GenuiRegistry } from './generative-ui-jT9TYfCi.cjs';
3
+ import { n as GenuiProviderProps$1, c as GenerativeUIElement, q as GenuiRenderer, p as GenuiRegistry } from './generative-ui-VTZ1EADD.cjs';
4
4
  import '@dudousxd/nestjs-agent-core';
5
5
  import 'ai';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentRegistry } from '@json-render/react';
3
- import { n as GenuiProviderProps$1, c as GenerativeUIElement, q as GenuiRenderer, p as GenuiRegistry } from './generative-ui-jT9TYfCi.js';
3
+ import { n as GenuiProviderProps$1, c as GenerativeUIElement, q as GenuiRenderer, p as GenuiRegistry } from './generative-ui-VTZ1EADD.js';
4
4
  import '@dudousxd/nestjs-agent-core';
5
5
  import 'ai';
6
6
 
package/dist/genui.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GenerativeUIItem } from './generative-ui-jT9TYfCi.cjs';
2
- export { a as GENUI_TREE_COMPONENT, b as GenerativeUI, c as GenerativeUIElement, d as GenerativeUIFallback, e as GenerativeUIOptions, f as GenerativeUIProblem, g as GenerativeUIProps, h as GenerativeUIScope, i as GenerativeUIScopeProps, j as GenerativeUIState, k as GenuiCatalogLike, l as GenuiIssueLike, m as GenuiProvider, n as GenuiProviderProps, o as GenuiProviderValue, p as GenuiRegistry, q as GenuiRenderer, r as GenuiTree, R as ResolveComponent, u as useGenerativeUI, s as useGenuiProvider } from './generative-ui-jT9TYfCi.cjs';
1
+ import { G as GenerativeUIItem } from './generative-ui-VTZ1EADD.cjs';
2
+ export { a as GENUI_TREE_COMPONENT, b as GenerativeUI, c as GenerativeUIElement, d as GenerativeUIFallback, e as GenerativeUIOptions, f as GenerativeUIProblem, g as GenerativeUIProps, h as GenerativeUIScope, i as GenerativeUIScopeProps, j as GenerativeUIState, k as GenuiCatalogLike, l as GenuiIssueLike, m as GenuiProvider, n as GenuiProviderProps, o as GenuiProviderValue, p as GenuiRegistry, q as GenuiRenderer, r as GenuiTree, R as ResolveComponent, u as useGenerativeUI, s as useGenuiProvider } from './generative-ui-VTZ1EADD.cjs';
3
3
  import 'react';
4
4
  import '@dudousxd/nestjs-agent-core';
5
5
  import 'ai';
package/dist/genui.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GenerativeUIItem } from './generative-ui-jT9TYfCi.js';
2
- export { a as GENUI_TREE_COMPONENT, b as GenerativeUI, c as GenerativeUIElement, d as GenerativeUIFallback, e as GenerativeUIOptions, f as GenerativeUIProblem, g as GenerativeUIProps, h as GenerativeUIScope, i as GenerativeUIScopeProps, j as GenerativeUIState, k as GenuiCatalogLike, l as GenuiIssueLike, m as GenuiProvider, n as GenuiProviderProps, o as GenuiProviderValue, p as GenuiRegistry, q as GenuiRenderer, r as GenuiTree, R as ResolveComponent, u as useGenerativeUI, s as useGenuiProvider } from './generative-ui-jT9TYfCi.js';
1
+ import { G as GenerativeUIItem } from './generative-ui-VTZ1EADD.js';
2
+ export { a as GENUI_TREE_COMPONENT, b as GenerativeUI, c as GenerativeUIElement, d as GenerativeUIFallback, e as GenerativeUIOptions, f as GenerativeUIProblem, g as GenerativeUIProps, h as GenerativeUIScope, i as GenerativeUIScopeProps, j as GenerativeUIState, k as GenuiCatalogLike, l as GenuiIssueLike, m as GenuiProvider, n as GenuiProviderProps, o as GenuiProviderValue, p as GenuiRegistry, q as GenuiRenderer, r as GenuiTree, R as ResolveComponent, u as useGenerativeUI, s as useGenuiProvider } from './generative-ui-VTZ1EADD.js';
3
3
  import 'react';
4
4
  import '@dudousxd/nestjs-agent-core';
5
5
  import 'ai';
package/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ AGENT_RUN_ERROR_CODES: () => AGENT_RUN_ERROR_CODES,
33
34
  ALL_AGENTS: () => import_nestjs_agent_core4.ALL_AGENTS,
34
35
  AgentBackendUnsupportedError: () => AgentBackendUnsupportedError,
35
36
  AgentChatTransport: () => AgentChatTransport,
@@ -43,6 +44,7 @@ __export(src_exports, {
43
44
  MessageItemView: () => MessageItemView,
44
45
  MessageList: () => MessageList,
45
46
  QuotaBlockedError: () => QuotaBlockedError,
47
+ RUN_NOT_ACTIVE_CODE: () => RUN_NOT_ACTIVE_CODE,
46
48
  SPEECH_LANGUAGES: () => SPEECH_LANGUAGES,
47
49
  acceptsFile: () => acceptsFile,
48
50
  applyCompletion: () => applyCompletion,
@@ -68,6 +70,7 @@ __export(src_exports, {
68
70
  groupToolActivity: () => groupToolActivity,
69
71
  inferResultView: () => inferResultView,
70
72
  isActionCall: () => isActionCall,
73
+ isRunNotActiveError: () => isRunNotActiveError,
71
74
  loadStoredSpeechLang: () => loadStoredSpeechLang,
72
75
  messageFiles: () => messageFiles,
73
76
  notifyThreads: () => notifyThreads,
@@ -722,6 +725,15 @@ var AgentChatTransport = class {
722
725
  const backend = this.backend;
723
726
  const policy = this.reconnectPolicy();
724
727
  const notify = (state) => this.options.onConnectionChange?.(state);
728
+ const reportRunError = (failure) => {
729
+ try {
730
+ this.options.onRunError?.({
731
+ ...failure,
732
+ ...streamRunId !== void 0 ? { runId: streamRunId } : {}
733
+ });
734
+ } catch {
735
+ }
736
+ };
725
737
  const aborted = () => cancelled || context.signal?.aborted === true;
726
738
  const canResume = () => policy !== null && lastSeq !== void 0 && streamRunId !== void 0 && !aborted();
727
739
  const resume = async () => {
@@ -1046,7 +1058,9 @@ var AgentChatTransport = class {
1046
1058
  return;
1047
1059
  }
1048
1060
  if (frame.event === "error") {
1049
- fail(parseErrorText(frame.data));
1061
+ const failure = parseErrorFrame(frame.data);
1062
+ reportRunError(failure);
1063
+ fail(failure.message);
1050
1064
  return;
1051
1065
  }
1052
1066
  if (frame.event === "meta") {
@@ -1113,16 +1127,21 @@ function parseMeta(data) {
1113
1127
  }
1114
1128
  return null;
1115
1129
  }
1116
- function parseErrorText(data) {
1117
- if (!data) return "Agent run failed";
1130
+ function parseErrorFrame(data) {
1131
+ const fallback2 = { code: void 0, message: "Agent run failed" };
1132
+ if (!data) return fallback2;
1118
1133
  try {
1119
1134
  const parsed = JSON.parse(data);
1120
- if (parsed !== null && typeof parsed === "object" && "message" in parsed && typeof parsed.message === "string") {
1121
- return parsed.message;
1135
+ if (parsed !== null && typeof parsed === "object") {
1136
+ const record = parsed;
1137
+ return {
1138
+ code: typeof record.code === "string" && record.code !== "" ? record.code : void 0,
1139
+ message: typeof record.message === "string" && record.message !== "" ? record.message : fallback2.message
1140
+ };
1122
1141
  }
1123
1142
  } catch {
1124
1143
  }
1125
- return "Agent run failed";
1144
+ return fallback2;
1126
1145
  }
1127
1146
  function parseEvent(data) {
1128
1147
  try {
@@ -2958,7 +2977,8 @@ function buildToolCall(part, options, approval, catalog) {
2958
2977
  isSubmitting: sending === "reject",
2959
2978
  run: () => options?.reject(toolCallId)
2960
2979
  },
2961
- error: options?.errorOf(toolCallId) ?? null
2980
+ error: options?.errorOf(toolCallId) ?? null,
2981
+ errorCode: options?.errorCodeOf?.(toolCallId) ?? null
2962
2982
  };
2963
2983
  }
2964
2984
  function readElicitationRequest(part) {
@@ -3089,6 +3109,7 @@ function buildElicitationBlock(key, part, request, options) {
3089
3109
  isValid: questions.every((question) => question.error === null),
3090
3110
  outcome,
3091
3111
  error: options.errorOf(toolCallId),
3112
+ errorCode: options.errorCodeOf?.(toolCallId) ?? null,
3092
3113
  answer: {
3093
3114
  available: isPending && options.canAnswer,
3094
3115
  isSubmitting: sending === "answer",
@@ -3557,10 +3578,10 @@ function useTranscriptItems({
3557
3578
  return next;
3558
3579
  });
3559
3580
  setSettleErrors(
3560
- (current) => new Map(current).set(
3561
- toolCallId,
3562
- error instanceof Error ? error.message : "Could not settle this"
3563
- )
3581
+ (current) => new Map(current).set(toolCallId, {
3582
+ message: error instanceof Error ? error.message : "Could not settle this",
3583
+ code: settleErrorCode(error)
3584
+ })
3564
3585
  );
3565
3586
  };
3566
3587
  try {
@@ -3741,7 +3762,8 @@ function useTranscriptItems({
3741
3762
  answer,
3742
3763
  skip,
3743
3764
  submitting: (toolCallId) => settling.get(toolCallId) ?? null,
3744
- errorOf: (toolCallId) => settleErrors.get(toolCallId) ?? null
3765
+ errorOf: (toolCallId) => settleErrors.get(toolCallId)?.message ?? null,
3766
+ errorCodeOf: (toolCallId) => settleErrors.get(toolCallId)?.code ?? null
3745
3767
  }
3746
3768
  } : {},
3747
3769
  ...handlers.onApprove !== void 0 || handlers.onReject !== void 0 ? {
@@ -3751,7 +3773,8 @@ function useTranscriptItems({
3751
3773
  approve,
3752
3774
  reject,
3753
3775
  submitting: (toolCallId) => settling.get(toolCallId) ?? null,
3754
- errorOf: (toolCallId) => settleErrors.get(toolCallId) ?? null
3776
+ errorOf: (toolCallId) => settleErrors.get(toolCallId)?.message ?? null,
3777
+ errorCodeOf: (toolCallId) => settleErrors.get(toolCallId)?.code ?? null
3755
3778
  }
3756
3779
  } : {}
3757
3780
  }),
@@ -3871,6 +3894,10 @@ function contentSignature(messages) {
3871
3894
  }
3872
3895
  return `${messages.length}|${last.id}|${last.parts?.length ?? 0}|${length}`;
3873
3896
  }
3897
+ function settleErrorCode(error) {
3898
+ const code = error?.code;
3899
+ return typeof code === "string" && code !== "" ? code : null;
3900
+ }
3874
3901
 
3875
3902
  // src/components/message-item.tsx
3876
3903
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -4940,6 +4967,7 @@ function useAgentChat(options = {}) {
4940
4967
  const [activeRunId, setActiveRunId] = (0, import_react23.useState)(null);
4941
4968
  const [historyFor, setHistoryFor] = (0, import_react23.useState)(void 0);
4942
4969
  const [historyError, setHistoryError] = (0, import_react23.useState)(null);
4970
+ const [runError, setRunError] = (0, import_react23.useState)(null);
4943
4971
  const [threadModel, setThreadModel] = (0, import_react23.useState)(null);
4944
4972
  const [pickedModel, setPickedModel] = (0, import_react23.useState)(void 0);
4945
4973
  const pickedModelRef = (0, import_react23.useRef)(pickedModel);
@@ -5015,7 +5043,9 @@ function useAgentChat(options = {}) {
5015
5043
  onMeta,
5016
5044
  onAttemptStart: () => {
5017
5045
  settlingRunIdRef.current = void 0;
5046
+ setRunError(null);
5018
5047
  },
5048
+ onRunError: (failure) => setRunError(failure),
5019
5049
  // A queued turn this chat went to attach to had already finished: read what it wrote.
5020
5050
  onResumeGone: () => {
5021
5051
  void resyncFromThread();
@@ -5134,6 +5164,7 @@ function useAgentChat(options = {}) {
5134
5164
  setPickedModel(void 0);
5135
5165
  setBackgroundRuns([]);
5136
5166
  setHistoryError(null);
5167
+ setRunError(null);
5137
5168
  autoResumeRunIdRef.current = void 0;
5138
5169
  pendingPin.current = void 0;
5139
5170
  applyQueue(EMPTY_QUEUE);
@@ -5737,6 +5768,13 @@ function useAgentChat(options = {}) {
5737
5768
  isLoadingHistory,
5738
5769
  /** Reading the thread's history failed. */
5739
5770
  historyError,
5771
+ /**
5772
+ * How the last run's stream said it failed — the `event: error` frame's `code` and `message` —
5773
+ * or `null`. Cleared when the next attempt starts and when the chat moves to another thread.
5774
+ * `chat.error` still carries the message; this is where the `code` is, so the app can word each
5775
+ * failure itself (`replay_diverged`, `model_no_output`, `run_failed`, `quota_exceeded`, …).
5776
+ */
5777
+ runError,
5740
5778
  /**
5741
5779
  * The thread this chat is on right now: the `threadId` option, else the one the backend created
5742
5780
  * on the first send. A getter, because the created id is learned mid-stream.
@@ -5778,8 +5816,23 @@ var QuotaBlockedError = class extends Error {
5778
5816
  }
5779
5817
  block;
5780
5818
  };
5819
+
5820
+ // src/run-errors.ts
5821
+ var AGENT_RUN_ERROR_CODES = [
5822
+ "quota_exceeded",
5823
+ "output_rejected",
5824
+ "structured_output_invalid",
5825
+ "replay_diverged",
5826
+ "model_no_output",
5827
+ "run_failed"
5828
+ ];
5829
+ var RUN_NOT_ACTIVE_CODE = "run_not_active";
5830
+ function isRunNotActiveError(error) {
5831
+ return error instanceof Error && error.status === 409 && error.code === RUN_NOT_ACTIVE_CODE;
5832
+ }
5781
5833
  // Annotate the CommonJS export names for ESM import in node:
5782
5834
  0 && (module.exports = {
5835
+ AGENT_RUN_ERROR_CODES,
5783
5836
  ALL_AGENTS,
5784
5837
  AgentBackendUnsupportedError,
5785
5838
  AgentChatTransport,
@@ -5793,6 +5846,7 @@ var QuotaBlockedError = class extends Error {
5793
5846
  MessageItemView,
5794
5847
  MessageList,
5795
5848
  QuotaBlockedError,
5849
+ RUN_NOT_ACTIVE_CODE,
5796
5850
  SPEECH_LANGUAGES,
5797
5851
  acceptsFile,
5798
5852
  applyCompletion,
@@ -5818,6 +5872,7 @@ var QuotaBlockedError = class extends Error {
5818
5872
  groupToolActivity,
5819
5873
  inferResultView,
5820
5874
  isActionCall,
5875
+ isRunNotActiveError,
5821
5876
  loadStoredSpeechLang,
5822
5877
  messageFiles,
5823
5878
  notifyThreads,